diff --git a/nifty5/operators/scaling_operator.py b/nifty5/operators/scaling_operator.py index 1e14b62ed13de6c5e3cddfa0b1f8b6f6c3366ee3..a4b20ab07044e05c2e2eaaf24711e5688bd69401 100644 --- a/nifty5/operators/scaling_operator.py +++ b/nifty5/operators/scaling_operator.py @@ -35,14 +35,6 @@ class ScalingOperator(EndomorphicOperator): ----- :class:`Operator` supports the multiplication with a scalar. So one does not need instantiate :class:`ScalingOperator` explicitly in most cases. - - Formally, this operator always supports all operation modes (times, - adjoint_times, inverse_times and inverse_adjoint_times), even if `factor` - is 0 or infinity. It is the user's responsibility to apply the operator - only in appropriate ways (e.g. call inverse_times only if `factor` is - nonzero). - - This shortcoming will hopefully be fixed in the future. """ def __init__(self, factor, domain): @@ -52,7 +44,10 @@ class ScalingOperator(EndomorphicOperator): raise TypeError("Scalar required") self._factor = factor self._domain = makeDomain(domain) - self._capability = self._all_ops + if self._factor == 0.: + self._capability = self.TIMES | self.ADJOINT_TIMES + else: + self._capability = self._all_ops def apply(self, x, mode): self._check_input(x, mode) diff --git a/nifty5/operators/sum_operator.py b/nifty5/operators/sum_operator.py index 9daf7311c32143be78976b5e6a0cdad2726ec3e7..961dab946031206f3c74c18dbae1d3b770a84345 100644 --- a/nifty5/operators/sum_operator.py +++ b/nifty5/operators/sum_operator.py @@ -23,6 +23,7 @@ from ..sugar import domain_union from ..utilities import indent from .block_diagonal_operator import BlockDiagonalOperator from .linear_operator import LinearOperator +from .simple_linear_operators import NullOperator class SumOperator(LinearOperator): @@ -59,6 +60,8 @@ class SumOperator(LinearOperator): negnew += [not n for n in op._neg] else: negnew += list(op._neg) + elif isinstance(op, NullOperator): + pass else: opsnew.append(op) negnew.append(ng)