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

comment cleanup

parent c8928a36
Pipeline #19541 passed with stage
in 4 minutes and 11 seconds
......@@ -20,6 +20,7 @@ from builtins import range
from .linear_operator import LinearOperator
from .. import DomainTuple
class ComposedOperator(LinearOperator):
""" NIFTY class for composed operators.
......@@ -46,27 +47,6 @@ class ComposedOperator(LinearOperator):
Raised if
* an element of the operator list is not an instance of the
LinearOperator base class.
Notes
-----
Very useful in case one has to transform a Field living over a product
space (see example below).
Examples
--------
Minimal example of transforming a Field living on two domains into its
harmonic space.
>>> x1 = RGSpace(5)
>>> x2 = RGSpace(10)
>>> k1 = RGRGTransformation.get_codomain(x1)
>>> k2 = RGRGTransformation.get_codomain(x2)
>>> FFT1 = FFTOperator(domain=(x1,x2), target=(k1,x2), space=0)
>>> FFT2 = FFTOperator(domain=(k1,x2), target=(k1,k2), space=1)
>>> FFT = ComposedOperator((FFT1, FFT2)
>>> f = Field.from_random('normal', domain=(x1,x2))
>>> FFT.times(f)
"""
# ---Overwritten properties and methods---
......
......@@ -31,7 +31,6 @@ class DiagonalOperator(EndomorphicOperator):
EndomorphicOperator. It multiplies an input field pixel-wise with its
diagonal.
Parameters
----------
diagonal : Field
......@@ -55,14 +54,15 @@ class DiagonalOperator(EndomorphicOperator):
self_adjoint : boolean
Indicates whether the operator is self_adjoint or not.
NOTE: the fields given to __init__ and returned from .diagonal() are
considered to be bare, i.e. during operator application, the colume factors
are applied explicitly.
See Also
--------
EndomorphicOperator
"""
# ---Overwritten properties and methods---
def __init__(self, diagonal, domain=None, spaces=None):
super(DiagonalOperator, self).__init__()
......@@ -113,12 +113,9 @@ class DiagonalOperator(EndomorphicOperator):
-------
out : Field
The diagonal of the Operator.
"""
return self._diagonal.weight(-1)
# ---Mandatory properties and methods---
@property
def domain(self):
return self._domain
......@@ -138,8 +135,6 @@ class DiagonalOperator(EndomorphicOperator):
self._unitary = (abs(self._diagonal.val) == 1.).all()
return self._unitary
# ---Added properties and methods---
def _times_helper(self, x, operation):
if self._spaces is None:
return operation(self._diagonal)(x)
......
......@@ -71,7 +71,6 @@ class DirectSmoothingOperator(EndomorphicOperator):
wgt[i] is an array with nval[i] entries containing the
normalized smoothing weights.
"""
dxmax = self._effective_smoothing_width*self._sigma
x = np.asarray(x)
......
......@@ -38,17 +38,8 @@ class EndomorphicOperator(LinearOperator):
Indicates whether the Operator is unitary or not.
self_adjoint : boolean
Indicates whether the operator is self_adjoint or not.
Raises
------
NotImplementedError
Raised if
* self_adjoint is not defined
"""
# ---Overwritten properties and methods---
def inverse_times(self, x):
if self.self_adjoint and self.unitary:
return self.times(x)
......@@ -73,17 +64,11 @@ class EndomorphicOperator(LinearOperator):
else:
return super(EndomorphicOperator, self).inverse_adjoint_times(x)
# ---Mandatory properties and methods---
@property
def target(self):
return self.domain
# ---Added properties and methods---
@abc.abstractproperty
def self_adjoint(self):
""" States whether the Operator is self_adjoint or not.
"""
""" States whether the Operator is self_adjoint or not."""
raise NotImplementedError
......@@ -91,8 +91,6 @@ class FFTOperator(LinearOperator):
(LMSpace, GLSpace): LMGLTransformation
}
# ---Overwritten properties and methods---
def __init__(self, domain, target=None, space=None):
super(FFTOperator, self).__init__()
......@@ -141,8 +139,6 @@ class FFTOperator(LinearOperator):
def _adjoint_times(self, x):
return self._times_helper(x, self.domain, self._backward_transformation)
# ---Mandatory properties and methods---
@property
def domain(self):
return self._domain
......
......@@ -32,7 +32,6 @@ class FFTSmoothingOperator(EndomorphicOperator):
return self._smooth(x)
# ---Mandatory properties and methods---
@property
def domain(self):
return self._transformator.domain
......@@ -45,8 +44,6 @@ class FFTSmoothingOperator(EndomorphicOperator):
def unitary(self):
return False
# ---Added properties and methods---
def _smooth(self, x):
# transform to the (global-)default codomain and perform all remaining
# steps therein
......
......@@ -24,18 +24,17 @@ from ..field import Field
class InvertibleOperatorMixin(object):
""" Mixin class to invert implicit defined operators.
To invert the application of a given implicitly defined operator on a
field, this class gives the necessary functionality. Inheriting
functionality from this class provides the derived class with the inverse
to the given implicitly definied application of the operator on a field.
(e.g. .inverse_times vs. .times and
.adjoint_times vs. .adjoint_inverse_times)
This class provides the functionality necessary to invert the application
of a given implicitly defined operator on a field. Inheriting
functionality from this class provides the derived class with the
operations inverse to the defined operator applications
(e.g. .inverse_times if .times is defined and
.adjoint_times if .adjoint_inverse_times is defined)
Parameters
----------
inverter : Inverter
An instance of an Inverter class.
"""
def __init__(self, inverter, preconditioner=None,
......
......@@ -28,7 +28,7 @@ class LaplaceOperator(EndomorphicOperator):
"""An irregular LaplaceOperator with free boundary and excluding monopole.
This LaplaceOperator implements the second derivative of a Field in
PowerSpace on logarithmic or linear scale with vanishing curvature at the
PowerSpace on logarithmic or linear scale with vanishing curvature at the
boundary, starting at the second entry of the Field. The second derivative
of the Field on the irregular grid is calculated using finite differences.
......@@ -37,6 +37,8 @@ class LaplaceOperator(EndomorphicOperator):
logarithmic : boolean,
Whether smoothness is calculated on a logarithmic scale or linear scale
default : True
space : int
The index of the domain on which the operator acts
"""
def __init__(self, domain, space=None, logarithmic=True):
......@@ -70,10 +72,6 @@ class LaplaceOperator(EndomorphicOperator):
self._dposc[1:] += self._dpos
self._dposc *= 0.5
@property
def target(self):
return self._domain
@property
def domain(self):
return self._domain
......
......@@ -40,14 +40,6 @@ class LinearOperator(with_metaclass(
The domain in which the Operators result lives.
unitary : boolean
Indicates whether the Operator is unitary or not.
Raises
------
NotImplementedError
Raised if
* domain is not defined
* target is not defined
* unitary is not set to (True/False)
"""
def __init__(self):
......@@ -56,7 +48,7 @@ class LinearOperator(with_metaclass(
@abc.abstractproperty
def domain(self):
"""
domain : tuple of DomainObjects, i.e. Spaces and FieldTypes
domain : DomainTuple
The domain on which the Operator's input Field lives.
Every Operator which inherits from the abstract LinearOperator
base class must have this attribute.
......@@ -66,7 +58,7 @@ class LinearOperator(with_metaclass(
@abc.abstractproperty
def target(self):
"""
target : tuple of DomainObjects, i.e. Spaces and FieldTypes
target : DomainTuple
The domain on which the Operator's output Field lives.
Every Operator which inherits from the abstract LinearOperator
base class must have this attribute.
......@@ -89,35 +81,31 @@ class LinearOperator(with_metaclass(
def times(self, x):
""" Applies the Operator to a given Field.
Operator and Field have to live over the same domain.
Parameters
----------
x : Field
The input Field.
The input Field, living on the Operator's domain.
Returns
-------
out : Field
The processed Field living on the target-domain.
The processed Field living on the Operator's target domain.
"""
self._check_input_compatibility(x)
return self._times(x)
def inverse_times(self, x):
""" Applies the inverse-Operator to a given Field.
Operator and Field have to live over the same domain.
"""Applies the inverse Operator to a given Field.
Parameters
----------
x : Field
The input Field.
The input Field, living on the Operator's target domain
Returns
-------
out : Field
The processed Field living on the target-domain.
The processed Field living on the Operator's domain.
"""
self._check_input_compatibility(x, inverse=True)
try:
......@@ -130,21 +118,18 @@ class LinearOperator(with_metaclass(
return y
def adjoint_times(self, x):
""" Applies the adjoint-Operator to a given Field.
Operator and Field have to live over the same domain.
"""Applies the adjoint-Operator to a given Field.
Parameters
----------
x : Field
applies the Operator to the given Field
The input Field, living on the Operator's target domain
Returns
-------
out : Field
The processed Field living on the target-domain.
The processed Field living on the Operator's domain.
"""
if self.unitary:
return self.inverse_times(x)
......@@ -161,17 +146,15 @@ class LinearOperator(with_metaclass(
def adjoint_inverse_times(self, x):
""" Applies the adjoint-inverse Operator to a given Field.
Operator and Field have to live over the same domain.
Parameters
----------
x : Field
applies the Operator to the given Field
The input Field, living on the Operator's domain.
Returns
-------
out : Field
The processed Field living on the target-domain.
The processed Field living on the Operator's target domain.
Notes
-----
......
......@@ -27,8 +27,6 @@ class SmoothnessOperator(EndomorphicOperator):
default : True
"""
# ---Overwritten properties and methods---
def __init__(self, domain, strength=1., logarithmic=True, space=None):
super(SmoothnessOperator, self).__init__()
self._laplace = LaplaceOperator(domain,
......@@ -38,8 +36,6 @@ class SmoothnessOperator(EndomorphicOperator):
raise ValueError("ERROR: invalid sigma.")
self._strength = strength
# ---Mandatory properties and methods---
@property
def domain(self):
return self._laplace._domain
......@@ -64,8 +60,6 @@ class SmoothnessOperator(EndomorphicOperator):
result = Field.zeros_like(x)
return result
# ---Added properties and methods---
@property
def logarithmic(self):
return self._laplace.logarithmic
......
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