* Support both numpy 1 and 2 - Switch to pyproject macros. - No more greedy globs in %files. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-fastcluster?expand=0&rev=17
47 lines
1.6 KiB
Diff
47 lines
1.6 KiB
Diff
From 58cffa97fff38ca4dda3166b4ccb1a8eb27a124f Mon Sep 17 00:00:00 2001
|
|
From: Steve Kowalik <steven@wedontsleep.org>
|
|
Date: Fri, 19 Jul 2024 12:21:11 +1000
|
|
Subject: [PATCH] Support Numpy 2
|
|
|
|
Switch to using np.asarray() where required to support both Numpy 1 and
|
|
2.
|
|
---
|
|
fastcluster.py | 8 ++++----
|
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/fastcluster.py b/fastcluster.py
|
|
index f5325a6..8778605 100644
|
|
--- a/fastcluster.py
|
|
+++ b/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 @@ def linkage(X, method='single', metric='euclidean', preserve_input=True):
|
|
|
|
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
|
|
@@ -464,10 +464,10 @@ def linkage_vector(X, method='single', metric='euclidean', extraarg=None):
|
|
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)
|
|
else:
|
|
assert metric=='euclidean'
|
|
- X = array(X, dtype=double, copy=(method=='ward'), order='C', subok=True)
|
|
+ dtype = double
|
|
+ X = asarray(X, dtype=dtype, order='C')
|
|
assert X.ndim==2
|
|
N = len(X)
|
|
Z = empty((N-1,4))
|