Dear Maintainer,
After Build-Depending on dh-sequence-numpy, I get this error during build:
[...]
======================================================================
ERROR: test_nan (tests.fastcluster_test.test_nan)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/build/r-cran-fastcluster-1.2.6/.pybuild/cpython3_3.13_fastcluster/build/tests/__init__.py",
line 10, in test_nan
test()
~~~~^^
File
"/build/r-cran-fastcluster-1.2.6/.pybuild/cpython3_3.13_fastcluster/build/tests/nantest.py",
line 49, in test
fastcluster.linkage([np.inf,-np.inf,-np.inf], method=method)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/build/r-cran-fastcluster-1.2.6/.pybuild/cpython3_3.13_fastcluster/build/fastcluster.py",
line 230, in linkage
X = array(X, copy=False, subok=True)
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow
a copy when needed (no behavior change in NumPy 1.x).
For more details, see
https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
======================================================================
ERROR: test_vector (tests.fastcluster_test.test_vector)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/build/r-cran-fastcluster-1.2.6/.pybuild/cpython3_3.13_fastcluster/build/tests/__init__.py",
line 14, in test_vector
test(10)
~~~~^^^^
File
"/build/r-cran-fastcluster-1.2.6/.pybuild/cpython3_3.13_fastcluster/build/tests/vectortest.py",
line 236, in test
test_all(n,dim)
~~~~~~~~^^^^^^^
File
"/build/r-cran-fastcluster-1.2.6/.pybuild/cpython3_3.13_fastcluster/build/tests/vectortest.py",
line 106, in test_all
Z2 = fc.linkage_vector(pcd, method, metric)
File
"/build/r-cran-fastcluster-1.2.6/.pybuild/cpython3_3.13_fastcluster/build/fastcluster.py",
line 467, in linkage_vector
X = array(X, dtype=dtype, copy=False, order='C', subok=True)
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow
a copy when needed (no behavior change in NumPy 1.x).
For more details, see
https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
----------------------------------------------------------------------
Ran 3 tests in 2.920s
FAILED (errors=2)
[...]
There is an issue opened upstream at
https://github.com/fastcluster/fastcluster/issues/93.
Attached patch makes r-cran-fastcluster build again.
Kind Regards.
--- a/src/python/fastcluster.py
+++ b/src/python/fastcluster.py
@@ -23,7 +23,7 @@
__version_info__ = ('1', '2', '6')
__version__ = '.'.join(__version_info__)
-from numpy import double, empty, array, ndarray, var, cov, dot, expand_dims, \
+from numpy import double, empty, array, asarray, ndarray, var, cov, dot, expand_dims, \
ceil, sqrt
from numpy.linalg import inv
try:
@@ -227,7 +227,7 @@
The linkage method does not treat NumPy's masked arrays as special
and simply ignores the mask.'''
- X = array(X, copy=False, subok=True)
+ X = asarray(X)
if X.ndim==1:
if method=='single':
preserve_input = False
@@ -241,7 +241,7 @@
assert X.ndim==2
N = len(X)
X = pdist(X, metric=metric)
- X = array(X, dtype=double, copy=False, order='C', subok=True)
+ X = asarray(X, dtype=double, order='C')
Z = empty((N-1,4))
if N > 1:
linkage_wrap(N, X, Z, mthidx[method])
@@ -460,14 +460,17 @@
if method=='single':
assert metric!='USER'
if metric in ('hamming', 'jaccard'):
- X = array(X, copy=False, subok=True)
+ X = asarray(X)
dtype = bool if X.dtype==bool else double
else:
dtype = bool if metric in booleanmetrics else double
- X = array(X, dtype=dtype, copy=False, order='C', subok=True)
+ X = asarray(X, dtype=dtype, order='C')
else:
assert metric=='euclidean'
- X = array(X, dtype=double, copy=(method=='ward'), order='C', subok=True)
+ if method == 'ward':
+ X = array(X, dtype=double, order='C', subok=True)
+ else:
+ X = asarray(X, dtype=double, order='C')
assert X.ndim==2
N = len(X)
Z = empty((N-1,4))
@@ -480,7 +483,7 @@
extraarg = inv(cov(X, rowvar=False))
# instead of the inverse covariance matrix, pass the matrix product
# with the data matrix!
- extraarg = array(dot(X,extraarg),dtype=double, copy=False, order='C', subok=True)
+ extraarg = asarray(dot(X,extraarg),dtype=double, order='C')
elif metric=='correlation':
X = X-expand_dims(X.mean(axis=1),1)
metric='cosine'