Skip to content

Commit c1b0ad0

Browse files
author
John Halloran
committed
fix: use copies for safety
1 parent d3f31e9 commit c1b0ad0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/diffpy/snmf/snmf_class.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ def __init__(
156156
self.weights_ = np.maximum(0, self.weights_)
157157

158158
# Store the initial components, weights, and stretch
159-
self.init_components = self.components_
160-
self.init_weights = self.weights_
161-
self.init_stretch = self.stretch_
159+
self.init_components = self.components_.copy()
160+
self.init_weights = self.weights_.copy()
161+
self.init_stretch = self.stretch_.copy()
162162

163163
# Second-order spline: Tridiagonal (-2 on diagonal, 1 on sub/superdiagonals)
164164
self._spline_smooth_operator = 0.25 * diags(
@@ -185,9 +185,9 @@ def fit(self, rho=0, eta=0, reset=True):
185185
"""
186186

187187
if reset:
188-
self.components_ = self.init_components
189-
self.weights_ = self.init_weights
190-
self.stretch_ = self.init_stretch
188+
self.components_ = self.init_components.copy()
189+
self.weights_ = self.init_weights.copy()
190+
self.stretch_ = self.init_stretch.copy()
191191

192192
self.rho = rho
193193
self.eta = eta

0 commit comments

Comments
 (0)