diff --git a/nifty/operators/fft_operator/fft_operator.py b/nifty/operators/fft_operator/fft_operator.py index 56df4ca1f2cff84070be9b00cb9e6d3ce7eb2730..1b4cd3d0dcd61fabc0bb430049a4a83bea7258f3 100644 --- a/nifty/operators/fft_operator/fft_operator.py +++ b/nifty/operators/fft_operator/fft_operator.py @@ -34,8 +34,9 @@ from transformations import RGRGTransformation,\ class FFTOperator(LinearOperator): - """ Transforms between a pair of position and harmonic domains. - Possible domain pairs are + """Transforms between a pair of position and harmonic domains. + + Built-in domain pairs are - a harmonic and a non-harmonic RGSpace (with matching distances) - a HPSpace and a LMSpace - a GLSpace and a LMSpace @@ -48,40 +49,34 @@ class FFTOperator(LinearOperator): Parameters ---------- - domain: Space or single-element tuple of Spaces The domain of the data that is input by "times" and output by "adjoint_times". - - target: Space or single-element tuple of Spaces (optional) + target: Space or single-element tuple of Spaces (optional) The domain of the data that is output by "times" and input by "adjoint_times". If omitted, a co-domain will be chosen automatically. Whenever "domain" is an RGSpace, the codomain (and its parameters) are uniquely determined (except for "zerocenter"). - For GLSpace, HPSpace, and LMSpace, a sensible (but not unique) co-domain - is chosen that should work satisfactorily in most situations, + For GLSpace, HPSpace, and LMSpace, a sensible (but not unique) + co-domain is chosen that should work satisfactorily in most situations, but for full control, the user should explicitly specify a codomain. module: String (optional) Software module employed for carrying out the transform operations. - For RGSpace pairs this can be "numpy" or "fftw", where "numpy" is always - available, but "fftw" offers higher performance and parallelization. - For sphere-related domains, only "pyHealpix" is available. - If omitted, "fftw" is selected for RGSpaces if available, else "numpy"; - on the sphere the default is (unsurprisingly) "pyHealpix". + For RGSpace pairs this can be "numpy" or "fftw", where "numpy" is + always available, but "fftw" offers higher performance and + parallelization. For sphere-related domains, only "pyHealpix" is + available. If omitted, "fftw" is selected for RGSpaces if available, + else "numpy"; on the sphere the default is "pyHealpix". domain_dtype: data type (optional) Data type of the fields that go into "times" and come out of "adjoint_times". Default is "numpy.complex". target_dtype: data type (optional) Data type of the fields that go into "adjoint_times" and come out of "times". Default is "numpy.complex". - (MR: Wouldn't it make sense to specify data types - only to "times" and "adjoint_times"? Does the operator itself really - need to know this, or only the individual call?) Attributes ---------- - domain: Tuple of Spaces (with one entry) The domain of the data that is input by "times" and output by "adjoint_times". @@ -94,14 +89,12 @@ class FFTOperator(LinearOperator): Raises ------ - ValueError: if "domain" or "target" are not of the proper type. + """ - # ---Class attributes--- - # Domains for which FFTOperator is unitary - unitary_list = (RGSpace,) + # ---Class attributes--- default_codomain_dictionary = {RGSpace: RGSpace, HPSpace: LMSpace, @@ -220,23 +213,22 @@ class FFTOperator(LinearOperator): @property def unitary(self): - return type(self.domain[0]) in self.unitary_list + return (self._forward_transformation.unitary and + self._backward_transformation.unitary) # ---Added properties and methods--- @classmethod def get_default_codomain(cls, domain): - """ Returns a codomain to the given domain. + """Returns a codomain to the given domain. Parameters ---------- - domain: Space An instance of RGSpace, HPSpace, GLSpace or LMSpace. Returns ------- - target: Space A (more or less perfect) counterpart to "domain" with respect to a FFT operation. @@ -249,9 +241,9 @@ class FFTOperator(LinearOperator): Raises ------ - ValueError: if no default codomain is defined for "domain". + """ domain_class = domain.__class__ try: diff --git a/nifty/operators/fft_operator/transformations/gllmtransformation.py b/nifty/operators/fft_operator/transformations/gllmtransformation.py index 67c3047951c7cd7584d5ad01500ed05f4096d9e8..a0e47652b85fc8f17adf1c08e1bed23bc4130782 100644 --- a/nifty/operators/fft_operator/transformations/gllmtransformation.py +++ b/nifty/operators/fft_operator/transformations/gllmtransformation.py @@ -45,6 +45,10 @@ class GLLMTransformation(SlicingTransformation): # ---Mandatory properties and methods--- + @property + def unitary(self): + return False + @classmethod def get_codomain(cls, domain): """ diff --git a/nifty/operators/fft_operator/transformations/hplmtransformation.py b/nifty/operators/fft_operator/transformations/hplmtransformation.py index 29cd25589758097d17172360371d5dd3832fee9f..314caa008bc479aa6596ca658410da7fde233585 100644 --- a/nifty/operators/fft_operator/transformations/hplmtransformation.py +++ b/nifty/operators/fft_operator/transformations/hplmtransformation.py @@ -46,6 +46,10 @@ class HPLMTransformation(SlicingTransformation): # ---Mandatory properties and methods--- + @property + def unitary(self): + return False + @classmethod def get_codomain(cls, domain): """ diff --git a/nifty/operators/fft_operator/transformations/lmgltransformation.py b/nifty/operators/fft_operator/transformations/lmgltransformation.py index 504568c520792040f03d1c620885ad9a33eca0fa..5e743c4da5512902dedf85bdcf7c9353748c109d 100644 --- a/nifty/operators/fft_operator/transformations/lmgltransformation.py +++ b/nifty/operators/fft_operator/transformations/lmgltransformation.py @@ -45,6 +45,10 @@ class LMGLTransformation(SlicingTransformation): # ---Mandatory properties and methods--- + @property + def unitary(self): + return False + @classmethod def get_codomain(cls, domain): """ diff --git a/nifty/operators/fft_operator/transformations/lmhptransformation.py b/nifty/operators/fft_operator/transformations/lmhptransformation.py index ca39a2e602c5d1d214171c2fc17e4316df8d8470..6aa87e973ae1429e76d5eb8552d586a69ddea1c3 100644 --- a/nifty/operators/fft_operator/transformations/lmhptransformation.py +++ b/nifty/operators/fft_operator/transformations/lmhptransformation.py @@ -44,6 +44,10 @@ class LMHPTransformation(SlicingTransformation): # ---Mandatory properties and methods--- + @property + def unitary(self): + return False + @classmethod def get_codomain(cls, domain): """ diff --git a/nifty/operators/fft_operator/transformations/rgrgtransformation.py b/nifty/operators/fft_operator/transformations/rgrgtransformation.py index 7f26cafa3e13c3f8476f78cc720f55bcea881d0b..62212f351f6e0648d90e80f2d9a61406bd0c7cce 100644 --- a/nifty/operators/fft_operator/transformations/rgrgtransformation.py +++ b/nifty/operators/fft_operator/transformations/rgrgtransformation.py @@ -23,6 +23,9 @@ from nifty import RGSpace, nifty_configuration class RGRGTransformation(Transformation): + + # ---Overwritten properties and methods--- + def __init__(self, domain, codomain=None, module=None): super(RGRGTransformation, self).__init__(domain, codomain, module) @@ -42,6 +45,12 @@ class RGRGTransformation(Transformation): else: raise ValueError('Unsupported FFT module:' + module) + # ---Mandatory properties and methods--- + + @property + def unitary(self): + return True + @classmethod def get_codomain(cls, domain, zerocenter=None): """ diff --git a/nifty/operators/fft_operator/transformations/transformation.py b/nifty/operators/fft_operator/transformations/transformation.py index 8543bfd4fe00e4e4b8de0ecefc2f365b90e72a5e..3f8c850d27c1e2816bcf029da13ee7dd6bf72da4 100644 --- a/nifty/operators/fft_operator/transformations/transformation.py +++ b/nifty/operators/fft_operator/transformations/transformation.py @@ -37,6 +37,10 @@ class Transformation(Loggable, object): self.domain = domain self.codomain = codomain + @abc.abstractproperty + def unitary(self): + raise NotImplementedError + @classmethod def get_codomain(cls, domain): raise NotImplementedError