Commit 254f007b authored by Istvan N Huszar's avatar Istvan N Huszar
Browse files

Bugfix: eliminate NaNs from interpolated mask (wasteful)

parent 74b8ea35
......@@ -472,9 +472,14 @@ class Cost(TIRLObject):
if mm == "and":
# Negative values are impossible, hence NaNs are not expected.
return (source_mask * target_mask) ** 0.5
# Wrong: spline interpolation can make values negative!
newmask = (source_mask * target_mask) ** 0.5
newmask[np.isnan(newmask)] = 0
return newmask
elif mm == "or":
return ((source_mask ** 2 + target_mask ** 2) / 2) ** 0.5
newmask = ((source_mask ** 2 + target_mask ** 2) / 2) ** 0.5
newmask[np.isnan(newmask)] = 0
return newmask
else:
raise ValueError(
f"Unrecognised mask combination method: '{mm}'. You may "
......
Supports Markdown
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