diff --git a/lib/hmmlearn/tests/test_gaussian_hmm.py b/lib/hmmlearn/tests/test_gaussian_hmm.py index af11b07..613d417 100644 --- a/lib/hmmlearn/tests/test_gaussian_hmm.py +++ b/lib/hmmlearn/tests/test_gaussian_hmm.py @@ -225,15 +225,20 @@ def test_fit_with_priors(self, implementation, init_params='mc', assert_log_likelihood_increasing(h_learn, X, lengths, n_iter) # Make sure we've converged to the right parameters. + # In general, to account for state switching, + # compare sorted values. # a) means - assert_allclose(sorted(h.means_.tolist()), - sorted(h_learn.means_.tolist()), + assert_allclose(sorted(h.means_.ravel().tolist()), + sorted(h_learn.means_.ravel().tolist()), 0.01) # b) covars are hard to estimate precisely from a relatively small # sample, thus the large threshold + + # account for how we store the covars_compressed + orig = np.broadcast_to(h._covars_, h_learn._covars_.shape) assert_allclose( - *np.broadcast_arrays(sorted(h._covars_.tolist()), - sorted(h_learn._covars_.tolist())), + sorted(orig.ravel().tolist()), + sorted(h_learn._covars_.ravel().tolist()), 10)