Commit 86b8fa17 by Philipp Arras

### Move NonlinearOperators to nifty

parent a940abf2
Pipeline #31011 passed with stages
in 1 minute and 23 seconds
 ... @@ -5,6 +5,7 @@ from .domains import * ... @@ -5,6 +5,7 @@ from .domains import * from .domain_tuple import DomainTuple from .domain_tuple import DomainTuple from .field import Field from .field import Field from .operators import * from .operators import * from .nonlinear_operators import * from .probing.utils import probe_with_posterior_samples, probe_diagonal, \ from .probing.utils import probe_with_posterior_samples, probe_diagonal, \ StatCalculator StatCalculator from .minimization import * from .minimization import * ... ...
 from .nonlinear_operator import NonlinearOperator, LinearModel from .constant import ConstantModel from .local_nonlinearity import LocalModel from .position import PositionModel __all__ = ['NonlinearOperator', 'ConstantModel', 'LocalModel', 'PositionModel', 'LinearModel']
 from ..operators import MultiSkyGradientOperator from .nonlinear_operator import NonlinearOperator class ConstantModel(NonlinearOperator): def __init__(self, position, constant): super(ConstantModel, self).__init__(position) self._constant = constant self._value = self._constant self._gradient = MultiSkyGradientOperator({}, position.domain, self.value.domain) def at(self, position): return self.__class__(position, self._constant)
 from nifty4.sugar import makeOp from .nonlinear_operator import NonlinearOperator class LocalModel(NonlinearOperator): def __init__(self, position, inp, nonlinearity): """ Computes nonlinearity(inp) """ super(LocalModel, self).__init__(position) self._inp = inp.at(self.position) self._nonlinearity = nonlinearity self._value = nonlinearity(self._inp.value) # Gradient self._gradient = makeOp(self._nonlinearity.derivative(self._inp.value))*self._inp.gradient def at(self, position): return self.__class__(position, self._inp, self._nonlinearity)