From 47b93afbaac614ce50fa162bce7418af66e493789918dd3e6d27541db83e5f30 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Fri, 19 Jul 2024 02:34:13 +0000 Subject: [PATCH] - 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/package/show/devel:languages:python:numeric/python-fastcluster?expand=0&rev=17 --- .gitattributes | 23 +++++++ .gitignore | 1 + fastcluster-1.2.6.tar.gz | 3 + python-fastcluster.changes | 127 +++++++++++++++++++++++++++++++++++++ python-fastcluster.spec | 95 +++++++++++++++++++++++++++ support-numpy-2.patch | 46 ++++++++++++++ 6 files changed, 295 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 fastcluster-1.2.6.tar.gz create mode 100644 python-fastcluster.changes create mode 100644 python-fastcluster.spec create mode 100644 support-numpy-2.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/fastcluster-1.2.6.tar.gz b/fastcluster-1.2.6.tar.gz new file mode 100644 index 0000000..6cfd146 --- /dev/null +++ b/fastcluster-1.2.6.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aab886efa7b6bba7ac124f4498153d053e5a08b822d2254926b7206cdf5a8aa6 +size 173773 diff --git a/python-fastcluster.changes b/python-fastcluster.changes new file mode 100644 index 0000000..cc7cd83 --- /dev/null +++ b/python-fastcluster.changes @@ -0,0 +1,127 @@ +------------------------------------------------------------------- +Fri Jul 19 02:32:28 UTC 2024 - Steve Kowalik + +- 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 + +- update to version 1.2.6: + * Move to GitHub action for CI. No code changes. + +- changes from version 1.2.5: + * Updated pyproject.toml to work with Python 3.10 and future Python + versions. + +------------------------------------------------------------------- +Sat Jan 15 16:10:44 UTC 2022 - Dirk Müller + +- update to 1.2.4: + * Documentation update. + * Fixed #pragma in fastcluster.cpp. + * Fixed NumPy versions in Travis builds. + +------------------------------------------------------------------- +Sun May 23 21:17:09 UTC 2021 - Matej Cepl + +- Update to 1.2.0: + - Dropped support for Python 2. + - Python interface: Updated definition of the Yule distance + function, following a change in SciPy 1.6.3. + +------------------------------------------------------------------- +Sat May 22 11:40:08 UTC 2021 - Matej Cepl + +- Add skip_error_test.patch removing the erroring test_vector + test (gh#dmuellner/fastcluster#21). + +------------------------------------------------------------------- +Fri May 14 15:05:07 UTC 2021 - Matej Cepl + +- Update to 1.1.28: + - Replace deprecated “numpy.bool” and “numpy.int” by + “bool” and “int”. + - Updated NumPy dependency for Python 3.9. + +------------------------------------------------------------------- +Tue Jan 19 10:52:03 UTC 2021 - andy great + +- Disable build for python36 because scipy dependency. + +------------------------------------------------------------------- +Thu Jan 30 14:49:33 UTC 2020 - Todd R + +- update to version 1.1.26: + * Small updates for Python 3.8. + +------------------------------------------------------------------- +Mon Sep 17 14:56:58 UTC 2018 - Arun Persaud + +- update to version 1.1.25: + * Removed all “#pragma GCC diagnostic” directives in .cpp files due + to changed CRAN requirements (CRAN repository only, not the GitHub + repository). + +------------------------------------------------------------------- +Wed Jul 18 11:38:41 UTC 2018 - tchvatal@suse.com + +- Stricten version requirements on numpy to >= 1.9 + +------------------------------------------------------------------- +Sat Nov 4 16:00:03 UTC 2017 - arun@gmx.de + +- update to version 1.1.24: + * R 3.5 corrects the formula for the “Canberra” metric. See + https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17285. + The formula in the fastcluster package was changed accordingly. This + concerns only the R interface. SciPy and fastcluster's Python interface + always had the correct formula. + +------------------------------------------------------------------- +Thu May 4 16:09:16 UTC 2017 - toddrme2178@gmail.com + +- Update to Version 1.1.23 + * setup.py: Late NumPy import for better dependency management. +- Update to Version 1.1.22 + * No fenv header usage if software floating-point emulation is used (bug + report: NaN test failed on Debian armel). +- Implement single-spec version. + +------------------------------------------------------------------- +Sun Oct 30 23:29:41 UTC 2016 - jengelh@inai.de + +- Update descriptions. Drop authorship and irrelevant future notes. + +------------------------------------------------------------------- +Fri Oct 28 14:48:39 UTC 2016 - toddrme2178@gmail.com + +- Update to version 1.1.21: + * Appropiate use of std namespace +- Update to version 1.1.20: + * New version number due to PyPI upload error. +- Update to version 1.1.19: + * Fixed unit tests. They can be run with "python setup.py test" now. +- Update to version 1.1.18: + * Fixed missing NumPy header include path. +- Update to version 1.1.17: + * Resolved MSVC compiler warnings. +- Update to version 1.1.16: + * Support for large distance matrices (more than 2^31 entries, R's long + vector support since version 3.0.0). +- Update to version 1.1.15: + * Fixed the unit test to work with old and new R versions (see the changes + in stats::hclust in R 3.1.0). +- Update to version 1.1.14: + * Updated the DESCRIPTION file according to CRAN rules. + * Renamed the "ward" method for dissimilarity input to "ward.D" in the R + interface and created a new method "ward.D2", following changes in R's + hclust package. + +------------------------------------------------------------------- +Fri Nov 28 12:21:40 UTC 2014 - toddrme2178@gmail.com + +- Initial version + diff --git a/python-fastcluster.spec b/python-fastcluster.spec new file mode 100644 index 0000000..7cbcab5 --- /dev/null +++ b/python-fastcluster.spec @@ -0,0 +1,95 @@ +# +# spec file for package python-fastcluster +# +# 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 +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: python-fastcluster +Version: 1.2.6 +Release: 0 +Summary: Hierarchical clustering routines for Python +License: BSD-2-Clause +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 +Requires: python-numpy +Requires: python-scipy +%python_subpackages + +%description +This library provides Python functions for hierarchical clustering. +It generates hierarchical clusters from distance matrices or from +vector data. + +Part of this module is intended to replace the functions +linkage, single, complete, average, weighted, centroid, median, ward +in the module scipy.cluster.hierarchy with the same functionality but +much faster algorithms. Moreover, the function 'linkage_vector' +provides memory-efficient clustering for vector data. + +The interface is very similar to MATLAB's Statistics Toolbox API to +make code easier to port from MATLAB to Python/Numpy. The core +implementation of this library is in C++ for efficiency. + +%package -n %{name}-doc +Summary: Documentation for %{name} +Group: Documentation/Other +Provides: %{python_module fastcluster-doc = %{version}} + +%description -n %{name}-doc +Documentation and help files for %{name}. + +%prep +%autosetup -p1 -n fastcluster-%{version} + +sed -i 's/\r$//' CITATION.txt +sed -i 's/\r$//' NEWS.txt +sed -i 's/\r$//' README.txt + +%build +export CFLAGS="%{optflags}" +%pyproject_wheel + +%install +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} + +%check +export LANG=en_US.UTF-8 +%pyunittest_arch -v tests + +%files %{python_files} +%license COPYING.txt +%doc CITATION.txt NEWS.txt README.txt +%{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 + +%changelog diff --git a/support-numpy-2.patch b/support-numpy-2.patch new file mode 100644 index 0000000..682e905 --- /dev/null +++ b/support-numpy-2.patch @@ -0,0 +1,46 @@ +From 58cffa97fff38ca4dda3166b4ccb1a8eb27a124f Mon Sep 17 00:00:00 2001 +From: Steve Kowalik +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))