Skip to content

Commit b909dcb

Browse files
author
John Halloran
committed
fix: guard against zero/NaN stretches in apply_interpolation_matrix
1 parent 3c54016 commit b909dcb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/diffpy/snmf/snmf_class.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ def apply_interpolation_matrix(self, components=None, weights=None, stretch=None
384384
if stretch is None:
385385
stretch = self.stretch_
386386

387+
eps = 1e-8 # guard against divide by zero/NaN stretches
388+
stretch = np.maximum(stretch, eps)
389+
387390
# Compute scaled indices
388391
stretch_flat = stretch.reshape(1, self.n_signals * self.n_components) ** -1
389392
stretch_tiled = np.tile(stretch_flat, (self.signal_length, 1))

0 commit comments

Comments
 (0)