Commit fc902894 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

re-enable convenience functions

parent b08f3234
Pipeline #72497 passed with stages
in 19 minutes and 34 seconds
......@@ -52,7 +52,7 @@ if __name__ == '__main__':
A = ift.create_power_operator(harmonic_space, sqrtpspec)
# Set up a sky operator and instrumental response
sky = HT(A).ptw("sigmoid")
sky = ift.sigmoid(HT(A))
GR = ift.GeometryRemover(position_space)
R = GR
......
......@@ -80,7 +80,7 @@ if __name__ == '__main__':
A = pd(a)
# Define sky operator
sky = HT(ift.makeOp(A)).ptw("exp")
sky = ift.exp(HT(ift.makeOp(A)))
M = ift.DiagonalOperator(exposure)
GR = ift.GeometryRemover(position_space)
......
......@@ -85,7 +85,7 @@ if __name__ == '__main__':
A = cfmaker.amplitude
# Apply a nonlinearity
signal = correlated_field.ptw("sigmoid")
signal = ift.sigmoid(correlated_field)
# Build the line-of-sight response and define signal response
LOS_starts, LOS_ends = random_los(100) if mode == 0 else radial_los(100)
......@@ -149,7 +149,7 @@ if __name__ == '__main__':
filename_res = filename.format("results")
plot = ift.Plot()
plot.add(sc.mean, title="Posterior Mean")
plot.add(sc.var.ptw("sqrt"), title="Posterior Standard Deviation")
plot.add(ift.sqrt(sc.var), title="Posterior Standard Deviation")
powers = [A.force(s + KL.position) for s in KL.samples]
plot.add(
......
......@@ -84,7 +84,7 @@ if __name__ == '__main__':
DC = SingleDomain(correlated_field.target, position_space)
## Apply a nonlinearity
signal = DC @ correlated_field.ptw("sigmoid")
signal = DC @ ift.sigmoid(correlated_field)
# Build the line-of-sight response and define signal response
LOS_starts, LOS_ends = random_los(100) if mode == 0 else radial_los(100)
......@@ -170,7 +170,7 @@ if __name__ == '__main__':
filename_res = filename.format("results")
plot = ift.Plot()
plot.add(sc.mean, title="Posterior Mean")
plot.add(sc.var.ptw("sqrt"), title="Posterior Standard Deviation")
plot.add(ift.sqrt(sc.var), title="Posterior Standard Deviation")
powers1 = [A1.force(s + KL.position) for s in KL.samples]
powers2 = [A2.force(s + KL.position) for s in KL.samples]
......
......@@ -18,6 +18,7 @@
import numpy as np
from ..utilities import NiftyMeta, indent
from .. import pointwise
class Operator(metaclass=NiftyMeta):
......@@ -280,6 +281,14 @@ class Operator(metaclass=NiftyMeta):
return _OpChain.make((_FunctionApplier(self.target, op, *args, **kwargs), self))
for f in pointwise.ptw_dict.keys():
def func(f):
def func2(self, *args, **kwargs):
return self.ptw(f, *args, **kwargs)
return func2
setattr(Operator, f, func(f))
class _ConstCollector(object):
def __init__(self):
self._const = None
......
......@@ -33,13 +33,15 @@ from .operators.distributors import PowerDistributor
from .operators.operator import Operator
from .operators.scaling_operator import ScalingOperator
from .plot import Plot
from . import pointwise
__all__ = ['PS_field', 'power_analyze', 'create_power_operator',
'create_harmonic_smoothing_operator', 'from_random',
'full', 'makeField',
'makeDomain', 'get_signal_variance', 'makeOp', 'domain_union',
'get_default_codomain', 'single_plot', 'exec_time',
'calculate_position']
'calculate_position'] + list(pointwise.ptw_dict.keys())
def PS_field(pspace, func):
......@@ -373,8 +375,16 @@ def domain_union(domains):
return MultiDomain.union(domains)
def clip(a, a_min=None, a_max=None):
return a.clip(a_min, a_max)
# Pointwise functions
_current_module = sys.modules[__name__]
for f in pointwise.ptw_dict.keys():
def func(f):
def func2(x, *args, **kwargs):
return x.ptw(f, *args, **kwargs)
return func2
setattr(_current_module, f, func(f))
def get_default_codomain(domainoid, space=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment