From 3d353ecaf3cc0d48ea62ecd1b5233c582014d223 Mon Sep 17 00:00:00 2001 From: Philipp Arras Date: Thu, 14 Mar 2019 14:57:08 +0100 Subject: [PATCH] Fix handling of metric in _OpSum --- nifty5/operators/operator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nifty5/operators/operator.py b/nifty5/operators/operator.py index a674ccd5..069382c6 100644 --- a/nifty5/operators/operator.py +++ b/nifty5/operators/operator.py @@ -384,7 +384,6 @@ class _OpSum(Operator): v = x._val if lin else x v1 = v.extract(self._op1.domain) v2 = v.extract(self._op2.domain) - res = None if not lin: return self._op1(v1).unite(self._op2(v2)) wm = x.want_metric @@ -393,7 +392,7 @@ class _OpSum(Operator): op = lin1._jac._myadd(lin2._jac, False) res = lin1.new(lin1._val.unite(lin2._val), op(x.jac)) if lin1._metric is not None and lin2._metric is not None: - res = res.add_metric(lin1._metric + lin2._metric) + res = res.add_metric(self._op1(x)._metric + self._op2(x)._metric) return res def _simplify_for_constant_input_nontrivial(self, c_inp): -- GitLab