Skip to content

Commit

Permalink
Account for different ordering of result (#531)
Browse files Browse the repository at this point in the history
Use consistent random seed for reproducibility
  • Loading branch information
blckmaxima authored Aug 31, 2023
1 parent 822894e commit e6a2447
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/hmmlearn/tests/test_gaussian_hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_fit_ignored_init_warns(self, implementation, caplog):
h = hmm.GaussianHMM(self.n_components, self.covariance_type,
implementation=implementation)
h.startprob_ = self.startprob
h.fit(np.random.randn(100, self.n_components))
h.fit(self.prng.randn(100, self.n_components))
assert len(caplog.records) == 1, caplog
assert "will be overwritten" in caplog.records[0].getMessage()

Expand All @@ -135,7 +135,7 @@ def test_fit_too_little_data(self, implementation, caplog):
h.transmat_ = self.transmat
h.means_ = 20 * self.means
h.covars_ = np.maximum(self.covars, 0.1)
h._init(np.random.randn(5, self.n_components), 5)
h._init(self.prng.randn(5, self.n_components), 5)
assert len(caplog.records) == 1
assert "degenerate solution" in caplog.records[0].getMessage()

Expand Down Expand Up @@ -295,7 +295,7 @@ class TestGaussianHMMWithDiagonalCovars(GaussianHMMTestMixin):
def test_covar_is_writeable(self, implementation):
h = hmm.GaussianHMM(n_components=1, covariance_type="diag",
init_params="c", implementation=implementation)
X = np.random.normal(size=(1000, 5))
X = self.prng.normal(size=(1000, 5))
h._init(X, 1000)

# np.diag returns a read-only view of the array in NumPy 1.9.X.
Expand Down
2 changes: 1 addition & 1 deletion lib/hmmlearn/tests/test_variational_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_fit_mcgrory_titterington1d(self, implementation):
vi_uniform_startprob_and_transmat(model, lengths)
model.fit(sequences, lengths)
# Perform one check that we are converging to the right answer
assert (model.means_posterior_[-1][0]
assert (list(sorted(model.means_posterior_.ravel()))[3]
== pytest.approx(self.test_fit_mcgrory_titterington1d_mean)), \
model.means_posterior_

Expand Down

0 comments on commit e6a2447

Please sign in to comment.