Commit 3cf07f85 authored by Sebastian Hutschenreuter's avatar Sebastian Hutschenreuter
Browse files

Reviewed docs on operators, library, sugar. Fixed bug in makeOp due to the...

Reviewed docs on operators, library, sugar. Fixed bug in makeOp due to the recent BlochdiagonalOperator interface change
parent 3996cb92
......@@ -23,7 +23,7 @@ from .linear_operator import LinearOperator
class OuterProduct(LinearOperator):
"""Performs the pointwise outer product of two fields.
"""Performs the point-wise outer product of two fields.
Parameters
---------
......
......@@ -36,7 +36,7 @@ class QHTOperator(LinearOperator):
The full output domain
space : int
The index of the domain on which the operator acts.
target[space] must be a nonharmonic LogRGSpace.
target[space] must be a non-harmonic LogRGSpace.
"""
def __init__(self, target, space=0):
......
......@@ -26,7 +26,7 @@ from .linear_operator import LinearOperator
class RegriddingOperator(LinearOperator):
'''Linearly interpolates a RGSpace to an RGSpace with coarser resolution.
"""Linearly interpolates a RGSpace to an RGSpace with coarser resolution.
Parameters
----------
......@@ -38,7 +38,7 @@ class RegriddingOperator(LinearOperator):
space : int
Index of space in `domain` on which the operator shall act.
Default is 0.
'''
"""
def __init__(self, domain, new_shape, space=0):
self._domain = DomainTuple.make(domain)
self._space = infer_space(self._domain, space)
......
......@@ -23,7 +23,7 @@ from .endomorphic_operator import EndomorphicOperator
class SamplingEnabler(EndomorphicOperator):
"""Class which acts as the operator object (likelihood + prior)
"""Class which acts as a operator object built of (`likelihood` + `prior`)
and enables sampling from its inverse even if the operator object
itself does not support it.
......@@ -38,8 +38,8 @@ class SamplingEnabler(EndomorphicOperator):
The iteration controller to use for the iterative numerical inversion
done by a :class:`ConjugateGradient` object.
approximation : :class:`LinearOperator`, optional
if not None, this operator should be an approximation to `op`, which
supports the operation modes that `op` doesn't have. It is used as a
if not None, this linear operator should be an approximation to the operator, which
supports the operation modes that the operator doesn't have. It is used as a
preconditioner during the iterative inversion, to accelerate
convergence.
"""
......
......@@ -25,7 +25,12 @@ from .scaling_operator import ScalingOperator
class SandwichOperator(EndomorphicOperator):
"""Operator which is equivalent to the expression
`bun.adjoint(cheese(bun))`."""
`bun.adjoint(cheese(bun))`.
Notes
-----
This operator should always be called using the `make` method.
"""
def __init__(self, bun, cheese, op, _callingfrommake=False):
if not _callingfrommake:
......
......@@ -46,7 +46,14 @@ class VdotOperator(LinearOperator):
class ConjugationOperator(EndomorphicOperator):
"""Operator computing the complex conjugate of its input."""
"""Operator computing the complex conjugate of its input.
Parameters
----------
domain: Domain, tuple of domains or DomainTuple
domain of the input field
"""
def __init__(self, domain):
self._domain = DomainTuple.make(domain)
self._capability = self._all_ops
......@@ -57,7 +64,14 @@ class ConjugationOperator(EndomorphicOperator):
class Realizer(EndomorphicOperator):
"""Operator returning the real component of its input."""
"""Operator returning the real component of its input.
Parameters
----------
domain: Domain, tuple of domains or DomainTuple
domain of the input field
"""
def __init__(self, domain):
self._domain = DomainTuple.make(domain)
self._capability = self.TIMES | self.ADJOINT_TIMES
......@@ -173,8 +187,8 @@ class GeometryRemover(LinearOperator):
domain: Domain, tuple of Domain, or DomainTuple:
the full input domain of the operator.
space: int, optional
The index of the subdomain on which the operator should act
If None, it acts on all spaces
The index of the subdomain on which the operator should act. Default is None.
If None, it acts on all spaces.
Notes
-----
......
......@@ -29,10 +29,10 @@ class SlopeOperator(LinearOperator):
Slope and y-intercept of this line are the two parameters which are
defined on an UnstructeredDomain (in this order) which is the domain of
the operator. Being a LogRGSpace each pixel has a well-defined coordinate
the operator. Being a LogRGSpace instance each pixel has a well-defined coordinate
value.
y-intercept is defined to be the value at t_0 of the target.
The y-intercept is defined to be the value at t_0 of the target.
Parameters
----------
......
......@@ -26,7 +26,12 @@ from .linear_operator import LinearOperator
class SumOperator(LinearOperator):
"""Class representing sums of operators."""
"""Class representing sums of operators.
Notes
-----
This operator has to be called using the `make` method.
"""
def __init__(self, ops, neg, dom, tgt, _callingfrommake=False):
if not _callingfrommake:
......
......@@ -23,7 +23,7 @@ from .endomorphic_operator import EndomorphicOperator
class SymmetrizingOperator(EndomorphicOperator):
'''Subtracts the field axes-wise in reverse order from itself. The slice of
"""Subtracts the field axes-wise in reverse order from itself. The slice of
all elements with at least one index being zero is not touched.
Parameters
......@@ -33,7 +33,7 @@ class SymmetrizingOperator(EndomorphicOperator):
:class:`LogRGSpace`.
space : int
Index of space in domain on which the operator shall act. Default is 0.
'''
"""
def __init__(self, domain, space=0):
self._domain = DomainTuple.make(domain)
self._capability = self.TIMES | self.ADJOINT_TIMES
......
......@@ -65,7 +65,7 @@ def get_signal_variance(spec, space):
"""
Computes how much a field with a given power spectrum will vary in space
This is a small helper function that computes how the expected variance
This is a small helper function that computes the expected variance
of a harmonically transformed sample of this power spectrum.
Parameters
......@@ -103,14 +103,14 @@ def power_analyze(field, spaces=None, binbounds=None,
"""Computes the power spectrum for a subspace of `field`.
Creates a PowerSpace for the space addressed by `spaces` with the given
binning and computes the power spectrum as a Field over this
binning and computes the power spectrum as a :class:`Field` over this
PowerSpace. This can only be done if the subspace to be analyzed is a
harmonic space. The resulting field has the same units as the square of the
initial field.
Parameters
----------
field : Field
field : :class:`Field`
The field to be analyzed
spaces : None or int or tuple of int, optional
The indices of subdomains for which the power spectrum shall be
......@@ -122,18 +122,18 @@ def power_analyze(field, spaces=None, binbounds=None,
if binbounds is None : bins are inferred.
keep_phase_information : bool, optional
If False, return a real-valued result containing the power spectrum
of the input Field.
of `field`.
If True, return a complex-valued result whose real component
contains the power spectrum computed from the real part of the
input Field, and whose imaginary component contains the power
spectrum computed from the imaginary part of the input Field.
contains the power spectrum computed from the real part of `field`,
and whose imaginary component contains the power
spectrum computed from the imaginary part of `field`.
The absolute value of this result should be identical to the output
of power_analyze with keep_phase_information=False.
(default : False).
Returns
-------
Field
:class:`Field`
The output object. Its domain is a PowerSpace and it contains
the power spectrum of `field`.
"""
......@@ -363,7 +363,7 @@ def makeOp(input):
return DiagonalOperator(input)
if isinstance(input, MultiField):
return BlockDiagonalOperator(
input.domain, tuple(makeOp(val) for val in input.values()))
input.domain, input.to_dict())
raise NotImplementedError
......
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