[med-svn] [Git][med-team/python-hmmlearn][master] 4 commits: Add https://github.com/hmmlearn/hmmlearn/pull/545 to solve a problem with macs version 3.0

Andreas Tille (@tille) gitlab at salsa.debian.org
Mon Feb 19 09:46:06 GMT 2024



Andreas Tille pushed to branch master at Debian Med / python-hmmlearn


Commits:
2fe0fa06 by Andreas Tille at 2024-02-19T09:20:53+01:00
Add https://github.com/hmmlearn/hmmlearn/pull/545 to solve a problem with macs version 3.0

- - - - -
2038f90a by Andreas Tille at 2024-02-19T09:22:39+01:00
Run autopkgtest for all supported Python3 vesions

- - - - -
e0d9d7c2 by Andreas Tille at 2024-02-19T10:13:20+01:00
Fix variational gaussian tests with sklearn 1.4

- - - - -
78d42ad8 by Andreas Tille at 2024-02-19T10:18:20+01:00
Upload to unstable

- - - - -


8 changed files:

- debian/changelog
- + debian/patches/799352376a16e9d1658cbf00e103af1b74f4c76a.patch
- + debian/patches/863f4844c2c1ebc59be361ea081309259a1eb842.patch
- + debian/patches/ba2bab6b731044bbccd0a36024ae6ebe50ce80d7.patch
- + debian/patches/c68714f53109536ce39d108f578f290e19c769fd.patch
- + debian/patches/series
- debian/tests/control
- debian/tests/run-unit-test


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,13 @@
+python-hmmlearn (0.3.0-4) unstable; urgency=medium
+
+  * Add https://github.com/hmmlearn/hmmlearn/pull/545 to solve a problem
+    with macs version 3.0
+  * Run autopkgtest for all supported Python3 versions
+  * Fix variational gaussian tests with sklearn 1.4
+    Closes: #1064224
+
+ -- Andreas Tille <tille at debian.org>  Mon, 19 Feb 2024 10:13:36 +0100
+
 python-hmmlearn (0.3.0-3) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/patches/799352376a16e9d1658cbf00e103af1b74f4c76a.patch
=====================================
@@ -0,0 +1,57 @@
+From 799352376a16e9d1658cbf00e103af1b74f4c76a Mon Sep 17 00:00:00 2001
+From: Matthew Danielson <matt.danielson at gmail.com>
+Date: Wed, 30 Aug 2023 16:02:51 -0700
+Subject: [PATCH] Account for different ordering of result Use consistent
+ random seed for reproducibility
+Origin: https://github.com/hmmlearn/hmmlearn/pull/531
+Bug-Debian: https://bugs.debian.org/1064224
+
+---
+ lib/hmmlearn/tests/test_gaussian_hmm.py         | 6 +++---
+ lib/hmmlearn/tests/test_variational_gaussian.py | 2 +-
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/lib/hmmlearn/tests/test_gaussian_hmm.py b/lib/hmmlearn/tests/test_gaussian_hmm.py
+index 6bf6c9eb..af11b07f 100644
+--- a/lib/hmmlearn/tests/test_gaussian_hmm.py
++++ b/lib/hmmlearn/tests/test_gaussian_hmm.py
+@@ -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()
+ 
+@@ -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()
+ 
+@@ -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.
+diff --git a/lib/hmmlearn/tests/test_variational_gaussian.py b/lib/hmmlearn/tests/test_variational_gaussian.py
+index 33413ee8..0a4635a5 100644
+--- a/lib/hmmlearn/tests/test_variational_gaussian.py
++++ b/lib/hmmlearn/tests/test_variational_gaussian.py
+@@ -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_
+ 


=====================================
debian/patches/863f4844c2c1ebc59be361ea081309259a1eb842.patch
=====================================
@@ -0,0 +1,35 @@
+From 863f4844c2c1ebc59be361ea081309259a1eb842 Mon Sep 17 00:00:00 2001
+From: Matthew Danielson <matt.danielson at gmail.com>
+Date: Thu, 18 Jan 2024 10:06:34 -0800
+Subject: [PATCH] Make a test about detecting a produced warning more robust
+ and don't be concerned about model convergence.
+Origin: https://github.com/hmmlearn/hmmlearn/pull/545
+Bug-Debian: https://bugs.debian.org/1056813
+
+---
+ lib/hmmlearn/tests/test_gaussian_hmm.py | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+--- a/lib/hmmlearn/tests/test_gaussian_hmm.py
++++ b/lib/hmmlearn/tests/test_gaussian_hmm.py
+@@ -119,12 +119,18 @@ class GaussianHMMTestMixin:
+ 
+     @pytest.mark.parametrize("implementation", ["scaling", "log"])
+     def test_fit_ignored_init_warns(self, implementation, caplog):
++        # This test occasionally will be flaky in learning the model.
++        # What is important here, is that the expected log message is produced
++        # We can test convergence properties elsewhere.
+         h = hmm.GaussianHMM(self.n_components, self.covariance_type,
+                             implementation=implementation)
+         h.startprob_ = self.startprob
+         h.fit(self.prng.randn(100, self.n_components))
+-        assert len(caplog.records) == 1, caplog
+-        assert "will be overwritten" in caplog.records[0].getMessage()
++        found = False
++        for record in caplog.records:
++            if "will be overwritten" in record.getMessage():
++                found = True
++        assert found, "Did not find expected warning message"
+ 
+     @pytest.mark.parametrize("implementation", ["scaling", "log"])
+     def test_fit_too_little_data(self, implementation, caplog):


=====================================
debian/patches/ba2bab6b731044bbccd0a36024ae6ebe50ce80d7.patch
=====================================
@@ -0,0 +1,31 @@
+From ba2bab6b731044bbccd0a36024ae6ebe50ce80d7 Mon Sep 17 00:00:00 2001
+From: Matthew Danielson <matt.danielson at gmail.com>
+Date: Fri, 19 Jan 2024 13:33:03 -0800
+Subject: [PATCH] Increaseing the number of iterations for this model appears
+ to increase it's stability/decrease flakiness
+Origin: https://github.com/hmmlearn/hmmlearn/pull/545
+Bug-Debian: https://bugs.debian.org/1056813
+
+---
+ lib/hmmlearn/tests/test_gaussian_hmm.py | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/lib/hmmlearn/tests/test_gaussian_hmm.py b/lib/hmmlearn/tests/test_gaussian_hmm.py
+index a8e41a7..2342669 100644
+--- a/lib/hmmlearn/tests/test_gaussian_hmm.py
++++ b/lib/hmmlearn/tests/test_gaussian_hmm.py
+@@ -188,7 +188,13 @@ def test_fit_zero_variance(self, implementation):
+ 
+     @pytest.mark.parametrize("implementation", ["scaling", "log"])
+     def test_fit_with_priors(self, implementation, init_params='mc',
+-                             params='stmc', n_iter=5):
++                             params='stmc', n_iter=20):
++        # We have a few options to make this a robust test, such as
++        # a. increase the amount of training data to ensure convergence
++        # b. Only learn some of the parameters (simplify the problem)
++        # c. Increase the number of iterations
++        #
++        # (c) seems to not affect the ci/cd time too much.
+         startprob_prior = 10 * self.startprob + 2.0
+         transmat_prior = 10 * self.transmat + 2.0
+         means_prior = self.means


=====================================
debian/patches/c68714f53109536ce39d108f578f290e19c769fd.patch
=====================================
@@ -0,0 +1,22 @@
+From c68714f53109536ce39d108f578f290e19c769fd Mon Sep 17 00:00:00 2001
+From: Matthew Danielson <matt.danielson at gmail.com>
+Date: Thu, 18 Jan 2024 10:36:14 -0800
+Subject: [PATCH] Use consistent number of kmeans inits
+Origin: https://github.com/hmmlearn/hmmlearn/pull/545
+Bug-Debian: https://bugs.debian.org/1056813
+
+---
+ lib/hmmlearn/hmm.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/lib/hmmlearn/hmm.py
++++ b/lib/hmmlearn/hmm.py
+@@ -298,7 +298,7 @@ class GaussianHMM(_emissions.BaseGaussia
+         if self._needs_init("m", "means_"):
+             kmeans = cluster.KMeans(n_clusters=self.n_components,
+                                     random_state=self.random_state,
+-                                    n_init=1)  # sklearn <1.4 backcompat.
++                                    n_init=10)  # sklearn <1.4 backcompat.
+             kmeans.fit(X)
+             self.means_ = kmeans.cluster_centers_
+         if self._needs_init("c", "covars_"):


=====================================
debian/patches/series
=====================================
@@ -0,0 +1,4 @@
+799352376a16e9d1658cbf00e103af1b74f4c76a.patch
+863f4844c2c1ebc59be361ea081309259a1eb842.patch
+c68714f53109536ce39d108f578f290e19c769fd.patch
+ba2bab6b731044bbccd0a36024ae6ebe50ce80d7.patch


=====================================
debian/tests/control
=====================================
@@ -1,3 +1,3 @@
 Tests: run-unit-test
-Depends: @, python3-pytest
+Depends: @, python3-pytest, python3-all
 Restrictions: allow-stderr


=====================================
debian/tests/run-unit-test
=====================================
@@ -10,4 +10,8 @@ fi
 
 cd "${AUTOPKGTEST_TMP}"
 
-pytest-3 /usr/lib/python3/dist-packages/hmmlearn
+# Run build-time tests
+for py in $(py3versions -s 2> /dev/null)
+do
+    ${py} -m pytest -v /usr/lib/python3/dist-packages/hmmlearn
+done



View it on GitLab: https://salsa.debian.org/med-team/python-hmmlearn/-/compare/6a5610e8134a1d70f079bd58dccfd0223b60707e...78d42ad8b22e5d1a1cd8d2a744e16f3dcccb0e0c

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-hmmlearn/-/compare/6a5610e8134a1d70f079bd58dccfd0223b60707e...78d42ad8b22e5d1a1cd8d2a744e16f3dcccb0e0c
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20240219/e2401c38/attachment-0001.htm>


More information about the debian-med-commit mailing list