17
0

Accepting request 1188506 from devel:languages:python:numeric

- Add patch support-numpy-2.patch:
  * Support both numpy 1 and 2
- Switch to pyproject macros.
- No more greedy globs in %files.

OBS-URL: https://build.opensuse.org/request/show/1188506
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-fastcluster?expand=0&rev=12
This commit is contained in:
2024-07-22 15:14:58 +00:00
committed by Git OBS Bridge
3 changed files with 65 additions and 8 deletions

View File

@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Jul 19 02:32:28 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch support-numpy-2.patch:
* Support both numpy 1 and 2
- Switch to pyproject macros.
- No more greedy globs in %files.
-------------------------------------------------------------------
Wed Sep 28 14:00:59 UTC 2022 - Arun Persaud <arun@gmx.de>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-fastcluster
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,22 +16,22 @@
#
%define skip_python2 1
%define skip_python36 1
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-fastcluster
Version: 1.2.6
Release: 0
Summary: Hierarchical clustering routines for Python
License: BSD-2-Clause
Group: Development/Languages/Python
URL: https://github.com/dmuellner/fastcluster
Source: https://files.pythonhosted.org/packages/source/f/fastcluster/fastcluster-%{version}.tar.gz
# PATCH-FIX-UPSTREAM gh#fastcluster/fastcluster#94
Patch0: support-numpy-2.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module numpy-devel >= 1.9}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module scipy}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: python-rpm-macros
@@ -71,10 +71,10 @@ sed -i 's/\r$//' README.txt
%build
export CFLAGS="%{optflags}"
%python_build
%pyproject_wheel
%install
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}
%check
@@ -84,7 +84,10 @@ export LANG=en_US.UTF-8
%files %{python_files}
%license COPYING.txt
%doc CITATION.txt NEWS.txt README.txt
%{python_sitearch}/*
%{python_sitearch}/fastcluster.py
%{python_sitearch}/_fastcluster.cpython-*.so
%pycache_only %{python_sitearch}/__pycache__/fastcluster.*.pyc
%{python_sitearch}/fastcluster-%{version}.dist-info
%files -n %{name}-doc
%doc docs/fastcluster.pdf

46
support-numpy-2.patch Normal file
View File

@@ -0,0 +1,46 @@
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))