Commit 78464494 authored by Philipp Arras's avatar Philipp Arras
Browse files


parent aea26fdf
...@@ -19,6 +19,12 @@ from .operator import Operator ...@@ -19,6 +19,12 @@ from .operator import Operator
class OffsetOperator(Operator): class OffsetOperator(Operator):
'''Shifts the input by a fixed field.
field : Field
The field by which the input is shifted.'''
def __init__(self, field): def __init__(self, field):
self._field = field self._field = field
self._domain = self._target = field.domain self._domain = self._target = field.domain
...@@ -26,16 +26,23 @@ class Operator(NiftyMetaBase()): ...@@ -26,16 +26,23 @@ class Operator(NiftyMetaBase()):
@property @property
def domain(self): def domain(self):
"""DomainTuple or MultiDomain : the operator's input domain """The domain on which the Operator's input Field is defined.
The domain on which the Operator's input Field is defined.""" Returns
domain : DomainTuple or MultiDomain
return self._domain return self._domain
@property @property
def target(self): def target(self):
"""DomainTuple or MultiDomain : the operator's output domain """The domain on which the Operator's output Field is defined.
target : DomainTuple or MultiDomain
The domain on which the Operator's output Field is defined."""
return self._target return self._target
@staticmethod @staticmethod
...@@ -103,10 +110,19 @@ class Operator(NiftyMetaBase()): ...@@ -103,10 +110,19 @@ class Operator(NiftyMetaBase()):
return _OpChain.make((_Clipper(, min, max), self)) return _OpChain.make((_Clipper(, min, max), self))
def apply(self, x): def apply(self, x):
'''Applies the operator to a Field or MultiField.
x : Field or MultiField
Input on which the operator shall act. Needs to be defined on
raise NotImplementedError raise NotImplementedError
def force(self, x): def force(self, x):
"""Extract correct subset of domain of x and apply operator.""" """Extract subset of domain of x according to `self.domain` and apply
return self.apply(x.extract(self.domain)) return self.apply(x.extract(self.domain))
def _check_input(self, x): def _check_input(self, x):
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