Commit 41bb082f authored by Martin Reinecke's avatar Martin Reinecke
Browse files

cleanups

parent 7a785d5e
Pipeline #22459 passed with stage
in 4 minutes and 48 seconds
...@@ -39,30 +39,22 @@ class ComposedOperator(LinearOperator): ...@@ -39,30 +39,22 @@ class ComposedOperator(LinearOperator):
The NIFTy.space in which the outcome of the operator lives The NIFTy.space in which the outcome of the operator lives
unitary : boolean unitary : boolean
Indicates whether the Operator is unitary or not. Indicates whether the Operator is unitary or not.
Raises
------
TypeError
Raised if
* an element of the operator list is not an instance of the
LinearOperator base class.
""" """
# ---Overwritten properties and methods---
def __init__(self, operators): def __init__(self, operators):
super(ComposedOperator, self).__init__() super(ComposedOperator, self).__init__()
for i in range(1, len(operators)):
if operators[i].domain != operators[i-1].target:
raise ValueError("incompatible domains")
self._operator_store = () self._operator_store = ()
old_op = None
for op in operators: for op in operators:
if not isinstance(op, LinearOperator): if not isinstance(op, LinearOperator):
raise TypeError("The elements of the operator list must be" raise TypeError("The elements of the operator list must be"
"instances of the LinearOperator base class") "instances of the LinearOperator base class")
if old_op is not None and op.domain != old_op.target:
raise ValueError("incompatible domains")
self._operator_store += (op,) self._operator_store += (op,)
old_op = op
# ---Mandatory properties and methods---
@property @property
def domain(self): def domain(self):
return self._operator_store[0].domain return self._operator_store[0].domain
......
...@@ -56,16 +56,15 @@ class ResponseOperator(LinearOperator): ...@@ -56,16 +56,15 @@ class ResponseOperator(LinearOperator):
if spaces is None: if spaces is None:
spaces = range(len(self._domain)) spaces = range(len(self._domain))
kernel_smoothing = [FFTSmoothingOperator(self._domain, sigma[x], kernel_smoothing = [
space=spaces[x]) FFTSmoothingOperator(self._domain, sigma[x], space=spaces[x])
for x in range(nsigma)] for x in range(nsigma)]
kernel_exposure = [DiagonalOperator(Field(self._domain[spaces[x]],
exposure[x]),
domain=self._domain,
spaces=(spaces[x],))
for x in range(nsigma)]
self._composed_kernel = ComposedOperator(kernel_smoothing) self._composed_kernel = ComposedOperator(kernel_smoothing)
kernel_exposure = [
DiagonalOperator(Field(self._domain[spaces[x]], exposure[x]),
domain=self._domain, spaces=(spaces[x],))
for x in range(nsigma)]
self._composed_exposure = ComposedOperator(kernel_exposure) self._composed_exposure = ComposedOperator(kernel_exposure)
target_list = [FieldArray(self._domain[i].shape) for i in spaces] target_list = [FieldArray(self._domain[i].shape) for i in spaces]
......
from .endomorphic_operator import EndomorphicOperator from .endomorphic_operator import EndomorphicOperator
from .laplace_operator import LaplaceOperator from .laplace_operator import LaplaceOperator
from .. import Field
class SmoothnessOperator(EndomorphicOperator): class SmoothnessOperator(EndomorphicOperator):
......
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