Scheduled maintenance on Monday 2019-06-24 between 10:00-11:00 CEST

Commit cc59f4ba authored by Martin Reinecke's avatar Martin Reinecke

fixes

parent 081deabf
......@@ -219,10 +219,16 @@ class _ConstantOperator(Operator):
def apply(self, x):
from ..linearization import Linearization
from .simple_linear_operators import NullOperator
from ..domain_tuple import DomainTuple
self._check_input(x)
if not isinstance(x, Linearization):
return self._output
return x.new(self._output, NullOperator(self._domain, self._target))
if x.want_metric and self._target is DomainTuple.scalar_domain():
met = NullOperator(self._domain, self._domain)
else:
met = None
return x.new(self._output, NullOperator(self._domain, self._target),
met)
def __repr__(self):
return 'ConstantOperator <- {}'.format(self.domain.keys())
......
......@@ -48,3 +48,8 @@ def test_simplification():
assert_equal(isinstance(op2._op1, _ConstantOperator), True)
assert_allclose(op(f1)["a"].local_data, op2(f1)["a"].local_data)
assert_allclose(op(f1)["b"].local_data, op2(f1)["b"].local_data)
lin = ift.Linearization.make_var(ift.MultiField.full(op2.domain, 2.), True)
assert_allclose(op(lin).val["a"].local_data,
op2(lin).val["a"].local_data)
assert_allclose(op(lin).val["b"].local_data,
op2(lin).val["b"].local_data)
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