Bug#1067233: python-pomegranate: autopkgtest regression with NumPy 1.26

2024-04-08 Thread Graham Inggs
Control: tags -1 + patch

Hi Maintainer

The attached patch fixes the test failures for me.

I noticed in this package's changelog that its only purpose is to work
with cnvkit.  I have not tested whether cnvkit still functions with
this patch in place.

Regards
Graham
Description: Only compare init as a string after determining its type
 Avoids the following with error NumPy 1.26:
 ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Bug-Debian: https://bugs.debian.org/1067233
Author: Graham Inggs 
Last-Update: 2024-04-06

--- a/pomegranate/kmeans.pyx
+++ b/pomegranate/kmeans.pyx
@@ -229,10 +229,6 @@
 
 	def __init__(self, k, init='kmeans++', n_init=10):
 		self.k = k
-		if init != 'first-k':
-			self.n_init = n_init
-		else:
-			self.n_init = 1
 		self.centroid_norms =  calloc(self.k, sizeof(double))
 
 		if isinstance(init, (list, numpy.ndarray)):
@@ -246,8 +242,14 @@
 self.centroid_norms[i] = self.centroids[i].dot(self.centroids[i])
 
 			self.init = 'fixed'
+			self.n_init = n_init
 		elif isinstance(init, str):
 			self.init = init
+			if init != 'first-k':
+self.n_init = n_init
+			else:
+self.n_init = 1
+
 
 	def __dealloc__(self):
 		free(self.centroid_norms)


Bug#1067233: python-pomegranate: autopkgtest regression with NumPy 1.26

2024-03-20 Thread Timo Röhling
Source: python-pomegranate
Version: 0.14.8-4
Severity: serious

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Dear maintainer,

your package has an autopkgtest regression with NumPy 1.26.
Hopefully relevent excerpt from the test log:

 52s >   ???
 52s E   ValueError: The truth value of an array with more than one element is 
ambiguous. Use a.any() or a.all()
 52s
 52s pomegranate/kmeans.pyx:232: ValueError
 52s === warnings summary 
===
 52s ../../../../usr/lib/python3/dist-packages/dateutil/tz/tz.py:37
 52s   /usr/lib/python3/dist-packages/dateutil/tz/tz.py:37: DeprecationWarning: 
datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in 
a future version. Use timezone-aware objects to represent datetimes in UTC: 
datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
 52s EPOCH = datetime.datetime.utcfromtimestamp(0)
 52s
 52s tests/test_custom_distributions.py: 29600 warnings
 52s tests/test_hmm.py: 375 warnings
 52s   /usr/lib/python3/dist-packages/joblib/parallel.py:1792: 
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing this operation. (Deprecated NumPy 1.25.)
 52s res = func(*args, **kwargs)
 52s
 52s tests/test_custom_distributions.py: 40 warnings
 52s   
/tmp/autopkgtest-lxc.qczb1z7m/downtmp/autopkgtest_tmp/tests/test_custom_distributions.py:223:
 DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing this operation. (Deprecated NumPy 1.25.)
 52s assert_array_almost_equal(model1.log_probability(X), 
model2.log_probability(X))
 52s
 52s tests/test_custom_distributions.py: 400 warnings
 52s   
/tmp/autopkgtest-lxc.qczb1z7m/downtmp/autopkgtest_tmp/tests/test_custom_distributions.py:232:
 DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing this operation. (Deprecated NumPy 1.25.)
 52s assert_array_almost_equal(model1.log_probability(X), 
model2.log_probability(X))
 52s
 52s tests/test_custom_distributions.py: 200 warnings
 52s   
/tmp/autopkgtest-lxc.qczb1z7m/downtmp/autopkgtest_tmp/tests/test_custom_distributions.py:345:
 DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing this operation. (Deprecated NumPy 1.25.)
 52s assert_array_almost_equal(model1.log_probability(X), 
model2.log_probability(X))
 52s
 52s tests/test_custom_distributions.py: 200 warnings
 52s   
/tmp/autopkgtest-lxc.qczb1z7m/downtmp/autopkgtest_tmp/tests/test_custom_distributions.py:359:
 DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing this operation. (Deprecated NumPy 1.25.)
 52s assert_array_almost_equal(model1.predict(X), model2.predict(X))
 52s
 52s tests/test_custom_distributions.py: 200 warnings
 52s   
/tmp/autopkgtest-lxc.qczb1z7m/downtmp/autopkgtest_tmp/tests/test_custom_distributions.py:373:
 DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing this operation. (Deprecated NumPy 1.25.)
 52s assert_array_almost_equal(model1.predict_proba(X), 
model2.predict_proba(X))
 52s
 52s tests/test_custom_distributions.py: 200 warnings
 52s   
/tmp/autopkgtest-lxc.qczb1z7m/downtmp/autopkgtest_tmp/tests/test_custom_distributions.py:387:
 DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing this operation. (Deprecated NumPy 1.25.)
 52s assert_array_almost_equal(model1.predict_log_proba(X), 
model2.predict_log_proba(X))
 52s
 52s tests/test_custom_distributions.py: 200 warnings
 52s   
/tmp/autopkgtest-lxc.qczb1z7m/downtmp/autopkgtest_tmp/tests/test_custom_distributions.py:402:
 DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing this operation. (Deprecated NumPy 1.25.)
 52s assert_array_almost_equal(model1.log_probability(X), 
model2.log_probability(X))
 52s
 52s tests/test_custom_distributions.py: 2000 warnings
 52s   
/tmp/autopkgtest-lxc.qczb1z7m/downtmp/autopkgtest_tmp/tests/test_custom_distributions.py:411:
 DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is 
deprecated, and will error in future. Ensure you extract a single element from 
your array before performing