Skip to content
Snippets Groups Projects
Commit bfd678e9 authored by Lukas Platz's avatar Lukas Platz
Browse files

change PoissonianEnergy to detect whether there are INFs but no NaNs

BROKEN FOR MPI if there are NaNs in the input
parent fb34b7ce
No related branches found
No related tags found
1 merge request!321Fixing NaNs in PoissonEnergy
Pipeline #47552 passed
......@@ -191,9 +191,21 @@ class PoissonianEnergy(EnergyOperator):
def apply(self, x):
self._check_input(x)
res = x.sum() - x.log().vdot(self._d)
if isinstance(x, Linearization):
inp_vals = x.val.local_data
else:
inp_vals = x.local_data
fix_inf = False
if np.any(inp_vals==np.inf):
if not np.any(np.isnan(inp_vals)):
fix_inf=True #Note: This will break for MPI if there are NaNs in some threads but not others
if not isinstance(x, Linearization):
if fix_inf:
res = np.inf
return Field.scalar(res)
res = x.sum() - x.log().vdot(self._d)
if fix_inf:
res = Linearization(Field.scalar(np.inf), res.jac)
if not x.want_metric:
return res
metric = SandwichOperator.make(x.jac, makeOp(1./x.val))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment