Skip to content

Commit 7f8e33d

Browse files
author
John Halloran
committed
Flag self.rng as private
1 parent c783a02 commit 7f8e33d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/diffpy/snmf/snmf_class.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ def __init__(
6060
objective function to allow without terminating the optimization. Note that
6161
a minimum of 20 updates are run before this parameter is checked.
6262
n_components : int
63-
The number of components to attempt to extract from MM. Note that this will
63+
The number of components to extract from MM. Note that this will
6464
be overridden by Y0 if that is provided, but must be provided if no Y0 is
6565
provided.
6666
random_state : int
67-
The seed for the initial matrices used in the optimization.
67+
The seed for the initial guesses at the matrices (A, X, and Y) created by
68+
the decomposition.
6869
"""
6970

7071
self.MM = MM
@@ -76,21 +77,21 @@ def __init__(
7677
# Capture matrix dimensions
7778
self.N, self.M = MM.shape
7879
self.num_updates = 0
79-
self.rng = np.random.default_rng(random_state)
80+
self._rng = np.random.default_rng(random_state)
8081

8182
if Y0 is None:
8283
if n_components is None:
8384
raise ValueError("Must provide either Y0 or n_components.")
8485
else:
8586
self.K = n_components
86-
self.Y0 = self.rng.beta(a=2.5, b=1.5, size=(self.K, self.M))
87+
self.Y0 = self._rng.beta(a=2.5, b=1.5, size=(self.K, self.M))
8788
else:
8889
self.K = Y0.shape[0]
8990

9091
if self.A is None:
91-
self.A = np.ones((self.K, self.M)) + self.rng.normal(0, 1e-3, size=(self.K, self.M))
92+
self.A = np.ones((self.K, self.M)) + self._rng.normal(0, 1e-3, size=(self.K, self.M))
9293
if self.X0 is None:
93-
self.X0 = self.rng.random((self.N, self.K))
94+
self.X0 = self._rng.random((self.N, self.K))
9495

9596
self.X = np.maximum(0, self.X0)
9697
self.Y = np.maximum(0, self.Y0)

0 commit comments

Comments
 (0)