Commit dafe2922 authored by Martin Reinecke's avatar Martin Reinecke

fix and simplify

parent a7325040
Pipeline #47597 passed with stages
in 8 minutes and 14 seconds
...@@ -192,11 +192,10 @@ class PoissonianEnergy(EnergyOperator): ...@@ -192,11 +192,10 @@ class PoissonianEnergy(EnergyOperator):
def apply(self, x): def apply(self, x):
self._check_input(x) self._check_input(x)
res = x.sum() res = x.sum()
tmp = (res.val.local_data if isinstance(res, Linearization) tmp = res.val.local_data if isinstance(res, Linearization) else res
else res.local_data)
# if we have no infinity here, we can continue with the calculation; # if we have no infinity here, we can continue with the calculation;
# otherwise we know that the result must also be infinity # otherwise we know that the result must also be infinity
if not np.any(np.isinf(tmp)): if not np.isinf(tmp):
res = res - x.log().vdot(self._d) res = res - x.log().vdot(self._d)
if not isinstance(x, Linearization): if not isinstance(x, Linearization):
return Field.scalar(res) return Field.scalar(res)
......
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