[med-svn] [Git][med-team/python-skbio][master] 3 commits: Import upstream pull request to make tests working with scipy 1.11
Andreas Tille (@tille)
gitlab at salsa.debian.org
Sun Feb 11 20:34:38 GMT 2024
Andreas Tille pushed to branch master at Debian Med / python-skbio
Commits:
1b932dd8 by Andreas Tille at 2024-02-11T20:47:13+01:00
Import upstream pull request to make tests working with scipy 1.11
- - - - -
6b863945 by Andreas Tille at 2024-02-11T21:23:32+01:00
Remove autogenerated *.c files, Make sure backup of simde-sse2.h
- - - - -
ecca3182 by Andreas Tille at 2024-02-11T21:31:00+01:00
routine-update: Ready to upload to unstable
- - - - -
7 changed files:
- debian/changelog
- debian/clean
- + debian/patches/290da0472e3a0af01b242cd1d3dd6a24588db0e5.patch
- + debian/patches/6a2d1268a6c5c7d63edb9727f66e3de6d61f087e.patch
- + debian/patches/9dd9c6dd68a015f1159f884c57878b8a00fad14c.patch
- debian/patches/series
- debian/rules
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,14 @@
+python-skbio (0.5.9-4) unstable; urgency=medium
+
+ * Import upstream pull request to make tests working with scipy 1.11
+ Closes: #1063584
+ * Remove autogenerated *.c files
+ Closes: #1048510
+ * Make sure backup of simde-sse2.h
+ Closes: #1049511
+
+ -- Andreas Tille <tille at debian.org> Sun, 11 Feb 2024 21:24:22 +0100
+
python-skbio (0.5.9-3) unstable; urgency=medium
* Fix cython issue
=====================================
debian/clean
=====================================
@@ -1 +1,3 @@
.eggs/
+skbio/stats/distance/_cutils.c
+skbio/stats/ordination/_cutils.c
=====================================
debian/patches/290da0472e3a0af01b242cd1d3dd6a24588db0e5.patch
=====================================
@@ -0,0 +1,77 @@
+From 290da0472e3a0af01b242cd1d3dd6a24588db0e5 Mon Sep 17 00:00:00 2001
+From: qiyunzhu <qiyunzhu at gmail.com>
+Date: Sat, 4 Nov 2023 12:59:54 -0700
+Subject: [PATCH] removed kulsinski
+Bug-Debian: https://bugs.debian.org/1063584
+
+---
+ CHANGELOG.md | 6 ++++++
+ ci/aarch64.conda_requirements.txt | 2 +-
+ ci/conda_requirements.txt | 2 +-
+ setup.py | 2 +-
+ skbio/diversity/_driver.py | 2 --
+ 5 files changed, 9 insertions(+), 5 deletions(-)
+
+--- a/CHANGELOG.md
++++ b/CHANGELOG.md
+@@ -16,6 +16,12 @@
+ * Complex multiple axis indexing operations with `TabularMSA` have been removed from testing due to incompatibilities with modern versions of Pandas. ([#1851](https://github.com/biocore/scikit-bio/pull/1851))
+ * Pinning `scipy <= 1.10.1` ([#1851](https://github.com/biocore/scikit-bio/pull/1867))
+
++### Features
++* SciPy 1.11+ is now supported.
++
++### Backward-incompatible changes [experimental]
++* Beta diversity metric `kulsinski` was removed. This was motivated by that SciPy replaced this distance metric with `kulczynski1` in version 1.11 (see SciPy issue [#2009](https://github.com/scipy/scipy/issues/2009)), and that both metrics do not return 0 on two identical vectors.
++
+ ### Bug fixes
+
+ * Fixed a bug that caused build failure on the ARM64 microarchitecture due to floating-point number handling. ([#1859](https://github.com/biocore/scikit-bio/pull/1859))
+--- a/ci/aarch64.conda_requirements.txt
++++ b/ci/aarch64.conda_requirements.txt
+@@ -5,5 +5,5 @@ matplotlib >= 1.4.3
+ natsort >= 4.0.3
+ numpy >= 1.9.2
+ pandas >= 1.5.0
+-scipy <= 1.10.1
++scipy >= 1.9.0
+ h5py >= 3.6.0
+--- a/ci/conda_requirements.txt
++++ b/ci/conda_requirements.txt
+@@ -5,6 +5,6 @@ matplotlib >= 1.4.3
+ natsort >= 4.0.3
+ numpy >= 1.9.2
+ pandas >= 1.5.0
+-scipy <= 1.10.1
++scipy >= 1.9.0
+ h5py >= 3.6.0
+ hdmedians >= 0.14.1
+--- a/setup.py
++++ b/setup.py
+@@ -150,7 +150,7 @@ setup(name='scikit-bio',
+ 'natsort >= 4.0.3',
+ 'numpy >= 1.9.2',
+ 'pandas >= 1.5.0',
+- 'scipy <= 1.10.1',
++ 'scipy >= 1.9.0',
+ 'h5py >= 3.6.0',
+ 'hdmedians >= 0.14.1',
+ ],
+--- a/skbio/diversity/_driver.py
++++ b/skbio/diversity/_driver.py
+@@ -296,7 +296,6 @@ _valid_beta_metrics = [
+ "dice",
+ "hamming",
+ "jaccard",
+- "kulsinski",
+ "mahalanobis",
+ "manhattan", # aliases to "cityblock" in beta_diversity
+ "matching",
+@@ -314,7 +313,6 @@ _valid_beta_metrics = [
+ _qualitative_beta_metrics = [
+ "dice",
+ "jaccard",
+- "kulsinski",
+ "matching",
+ "rogerstanimoto",
+ "russellrao",
=====================================
debian/patches/6a2d1268a6c5c7d63edb9727f66e3de6d61f087e.patch
=====================================
@@ -0,0 +1,339 @@
+From 989a64b2cb04c164460f9527a9565a51521be2e2 Mon Sep 17 00:00:00 2001
+From: John Eppley <jmeppley at gmail.com>
+Date: Sat, 4 Nov 2023 19:55:37 -0700
+Subject: [PATCH 1/4] Corrected typo in skbio.diversity docs (#1873)
+Bug-Debian: https://bugs.debian.org/1063584
+
+---
+ skbio/diversity/__init__.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/skbio/diversity/__init__.py
++++ b/skbio/diversity/__init__.py
+@@ -139,7 +139,7 @@ run is not one that scikit-bio knows abo
+ example, if you're applying a custom metric that you've developed. To discover
+ the metric names that scikit-bio knows about as strings that can be passed as
+ ``metric`` to ``alpha_diversity`` or ``beta_diversity``, you can call
+-``get_alpha_diversity_metrices`` or ``get_beta_diversity_metrics``,
++``get_alpha_diversity_metrics`` or ``get_beta_diversity_metrics``,
+ respectively. These functions return lists of alpha and beta diversity metrics
+ that are implemented in scikit-bio. There may be additional metrics that can be
+ passed as strings which won't be listed here, such as those implemented in
+--- a/README.rst
++++ b/README.rst
+@@ -108,6 +108,12 @@ Logo
+
+ scikit-bio's logo was created by `Alina Prassas <http://cargocollective.com/alinaprassas>`_.
+
++Citing scikit-bio
++-----------------
++
++If you use scikit-bio for any published research, please see our `Zenodo page` <https://zenodo.org/record/8209901> for how to cite.
++
++
+ .. |Build Status| image:: https://travis-ci.org/biocore/scikit-bio.svg?branch=master
+ :target: https://travis-ci.org/biocore/scikit-bio
+ .. |Coverage Status| image:: https://coveralls.io/repos/biocore/scikit-bio/badge.png
+--- a/ci/aarch64.conda_requirements.txt
++++ b/ci/aarch64.conda_requirements.txt
+@@ -3,7 +3,7 @@ decorator >= 3.4.2
+ ipython >= 3.2.0
+ matplotlib >= 1.4.3
+ natsort >= 4.0.3
+-numpy >= 1.9.2
++numpy >= 1.17.0
+ pandas >= 1.5.0
+ scipy >= 1.9.0
+ h5py >= 3.6.0
+--- a/ci/conda_requirements.txt
++++ b/ci/conda_requirements.txt
+@@ -3,7 +3,7 @@ decorator >= 3.4.2
+ ipython >= 3.2.0
+ matplotlib >= 1.4.3
+ natsort >= 4.0.3
+-numpy >= 1.9.2
++numpy >= 1.17.0
+ pandas >= 1.5.0
+ scipy >= 1.9.0
+ h5py >= 3.6.0
+--- a/setup.py
++++ b/setup.py
+@@ -148,7 +148,7 @@ setup(name='scikit-bio',
+ 'IPython >= 3.2.0',
+ 'matplotlib >= 1.4.3',
+ 'natsort >= 4.0.3',
+- 'numpy >= 1.9.2',
++ 'numpy >= 1.17.0',
+ 'pandas >= 1.5.0',
+ 'scipy >= 1.9.0',
+ 'h5py >= 3.6.0',
+--- a/skbio/util/__init__.py
++++ b/skbio/util/__init__.py
+@@ -53,13 +53,13 @@ Warnings
+ # ----------------------------------------------------------------------------
+
+ from ._warning import EfficiencyWarning, RepresentationWarning, SkbioWarning
+-from ._misc import cardinal_to_ordinal, find_duplicates, safe_md5
++from ._misc import cardinal_to_ordinal, find_duplicates, safe_md5, get_rng
+ from ._testing import (get_data_path,
+ assert_ordination_results_equal,
+ assert_data_frame_almost_equal, pytestrunner)
+ from ._decorator import classproperty
+
+ __all__ = ['SkbioWarning', 'EfficiencyWarning', 'RepresentationWarning',
+- 'cardinal_to_ordinal', 'find_duplicates', 'safe_md5',
++ 'cardinal_to_ordinal', 'find_duplicates', 'safe_md5', 'get_rng',
+ 'get_data_path', 'assert_ordination_results_equal',
+ 'assert_data_frame_almost_equal', 'classproperty', 'pytestrunner']
+--- a/skbio/util/_misc.py
++++ b/skbio/util/_misc.py
+@@ -10,6 +10,8 @@ import hashlib
+ import inspect
+ from types import FunctionType
+
++import numpy as np
++
+ from ._decorator import experimental
+
+
+@@ -199,3 +201,43 @@ def find_duplicates(iterable):
+ else:
+ seen.add(e)
+ return repeated
++
++
++ at experimental(as_of="0.5.10")
++def get_rng(seed=None):
++ """Get a random generator.
++
++ Parameters
++ ----------
++ seed : int or np.random.Generator, optional
++ A user-provided random seed or random generator instance.
++
++ Returns
++ -------
++ np.random.Generator
++ Random generator instance.
++
++ Notes
++ -----
++ NumPy's new random generator [1]_ was introduced in version 1.17. It is not
++ backward compatible with ``RandomState``, the legacy random generator [2]_.
++ See NEP 19 [3]_ for an introduction to this change.
++
++ References
++ ----------
++ .. [1] https://numpy.org/devdocs/reference/random/generator.html
++
++ .. [2] https://numpy.org/doc/stable/reference/random/legacy.html
++
++ .. [3] https://numpy.org/neps/nep-0019-rng-policy.html
++ """
++ try:
++ if seed is None or isinstance(seed, int):
++ return np.random.default_rng(seed)
++ if isinstance(seed, np.random.Generator):
++ return seed
++ raise ValueError('Invalid seed. It must be an integer or an '
++ 'instance of np.random.Generator.')
++ except AttributeError:
++ raise ValueError('The installed NumPy version does not support '
++ 'random.Generator. Please use NumPy >= 1.17.')
+--- a/skbio/util/tests/test_misc.py
++++ b/skbio/util/tests/test_misc.py
+@@ -9,7 +9,9 @@
+ import io
+ import unittest
+
+-from skbio.util import cardinal_to_ordinal, safe_md5, find_duplicates
++import numpy as np
++
++from skbio.util import cardinal_to_ordinal, safe_md5, find_duplicates, get_rng
+ from skbio.util._misc import MiniRegistry, chunk_str, resolve_key
+
+
+@@ -231,5 +233,47 @@ class TestFindDuplicates(unittest.TestCa
+ self.assertEqual(find_duplicates(gen()), set(['a', 2]))
+
+
++class TestGetRng(unittest.TestCase):
++
++ def test_get_rng(self):
++
++ # no seed
++ obs0 = get_rng()
++ self.assertTrue(isinstance(obs0, np.random.Generator))
++
++ # integer seed
++ obs1 = get_rng(42)
++ self.assertTrue(isinstance(obs1, np.random.Generator))
++
++ # generator instance
++ obs2 = get_rng(obs1)
++ self.assertTrue(isinstance(obs2, np.random.Generator))
++
++ # invalide seed
++ msg = ('Invalid seed. It must be an integer or an instance of '
++ 'np.random.Generator.')
++ with self.assertRaises(ValueError) as cm:
++ get_rng('hello')
++ self.assertEqual(str(cm.exception), msg)
++
++ # test if seeds are disjoint and results are reproducible
++ obs = [get_rng(i).integers(1e6) for i in range(10)]
++ exp = [850624, 473188, 837575, 811504, 726442,
++ 670790, 445045, 944904, 719549, 421547]
++ self.assertListEqual(obs, exp)
++
++ # mimic legacy numpy
++ delattr(np.random, 'default_rng')
++ delattr(np.random, 'Generator')
++ msg = ('The installed NumPy version does not support '
++ 'random.Generator. Please use NumPy >= 1.17.')
++ with self.assertRaises(ValueError) as cm:
++ get_rng()
++ self.assertEqual(str(cm.exception), msg)
++ with self.assertRaises(ValueError) as cm:
++ get_rng('hello')
++ self.assertEqual(str(cm.exception), msg)
++
++
+ if __name__ == '__main__':
+ unittest.main()
+--- a/skbio/diversity/alpha/_base.py
++++ b/skbio/diversity/alpha/_base.py
+@@ -256,6 +256,7 @@ def esty_ci(counts):
+
+
+ @experimental(as_of="0.4.0")
++ at np.errstate(invalid='ignore')
+ def fisher_alpha(counts):
+ r"""Calculate Fisher's alpha, a metric of diversity.
+
+@@ -282,39 +283,56 @@ def fisher_alpha(counts):
+ Raises
+ ------
+ RuntimeError
+- If the optimizer fails to converge (error > 1.0).
++ If the optimizer fails to solve for Fisher's alpha.
+
+ Notes
+ -----
+- The implementation here is based on the description given in the SDR-IV
+- online manual [1]_. Uses ``scipy.optimize.minimize_scalar`` to find
+- Fisher's alpha.
++ Fisher's alpha is defined in [1]_. See also [2]_.
++
++ There is no analytical solution to Fisher's alpha. However, one can use
++ optimization techniques to obtain a numeric solution. This function calls
++ SciPy's ``minimize_scalar`` to find alpha. It is deterministic. The result
++ should be reasonably close to the true alpha.
++
++ Alpha can become large when most species are singletons. Alpha = +inf when
++ all species are singletons.
++
++ When the community is empty (i.e., all counts are zero), alpha = 0.
+
+ References
+ ----------
+- .. [1] http://www.pisces-conservation.com/sdrhelp/index.html
++ .. [1] Fisher, R.A., Corbet, A.S. and Williams, C.B., 1943. The relation
++ between the number of species and the number of individuals in a random
++ sample of an animal population. The Journal of Animal Ecology, pp.42-58.
+
++ .. [2] https://en.wikipedia.org/wiki/Relative_species_abundance#Logseries_
++ (Fisher_et_al_1943)
+ """
+ counts = _validate_counts_vector(counts)
++
++ # alpha = 0 when community has no individual
+ n = counts.sum()
++ if n == 0:
++ return 0.0
++
++ # alpha = +inf when all species are singletons
+ s = observed_otus(counts)
++ if n == s:
++ return np.inf
+
+- def f(alpha):
+- return (alpha * np.log(1 + (n / alpha)) - s) ** 2
++ # objective function to minimize:
++ # S = alpha * ln (1 + N / alpha), where alpha > 0
++ def f(x):
++ return (x * np.log(1 + (n / x)) - s) ** 2 if x > 0 else np.inf
++
++ # minimize the function using the default method (Brent's algorithm)
++ res = minimize_scalar(f)
++
++ # there is a chance optimization could fail
++ if res.success is False:
++ raise RuntimeError("Optimizer failed to solve for Fisher's alpha.")
+
+- # Temporarily silence RuntimeWarnings (invalid and division by zero) during
+- # optimization in case invalid input is provided to the objective function
+- # (e.g. alpha=0).
+- orig_settings = np.seterr(divide='ignore', invalid='ignore')
+- try:
+- alpha = minimize_scalar(f).x
+- finally:
+- np.seterr(**orig_settings)
+-
+- if f(alpha) > 1.0:
+- raise RuntimeError("Optimizer failed to converge (error > 1.0), so "
+- "could not compute Fisher's alpha.")
+- return alpha
++ return res.x
+
+
+ @experimental(as_of="0.4.0")
+--- a/skbio/diversity/alpha/tests/test_base.py
++++ b/skbio/diversity/alpha/tests/test_base.py
+@@ -107,25 +107,41 @@ class BaseTests(TestCase):
+ npt.assert_array_almost_equal(observed_upper, expected_upper)
+
+ def test_fisher_alpha(self):
+- exp = 2.7823795367398798
++ exp = 2.7823796
+ arr = np.array([4, 3, 4, 0, 1, 0, 2])
+ obs = fisher_alpha(arr)
+- self.assertAlmostEqual(obs, exp)
++ self.assertAlmostEqual(obs, exp, places=6)
+
+ # Should depend only on S and N (number of OTUs, number of
+ # individuals / seqs), so we should obtain the same output as above.
+ obs = fisher_alpha([1, 6, 1, 0, 1, 0, 5])
+- self.assertAlmostEqual(obs, exp)
++ self.assertAlmostEqual(obs, exp, places=6)
+
+ # Should match another by hand:
+ # 2 OTUs, 62 seqs, alpha is 0.39509
+ obs = fisher_alpha([61, 0, 0, 1])
+- self.assertAlmostEqual(obs, 0.39509, delta=0.0001)
++ self.assertAlmostEqual(obs, 0.3950909, places=6)
+
+ # Test case where we have >1000 individuals (SDR-IV makes note of this
+ # case). Verified against R's vegan::fisher.alpha.
+ obs = fisher_alpha([999, 0, 10])
+- self.assertAlmostEqual(obs, 0.2396492)
++ self.assertAlmostEqual(obs, 0.2396492, places=6)
++
++ # Should be infinite when all species are singletons
++ obs = fisher_alpha([1, 1, 1, 1, 1])
++ self.assertEqual(obs, np.inf)
++
++ # Should be zero when there is no individual
++ obs = fisher_alpha([0, 0, 0, 0, 0])
++ self.assertEqual(obs, 0)
++
++ # Should be large when most species are singletons
++ obs = fisher_alpha([1] * 99 + [2])
++ self.assertAlmostEqual(obs, 5033.278, places=3)
++
++ # Similar but even larger
++ obs = fisher_alpha([1] * 999 + [2])
++ TestCase().assertAlmostEqual(obs, 500333.3, places=1)
+
+ def test_goods_coverage(self):
+ counts = [1] * 75 + [2, 2, 2, 2, 2, 2, 3, 4, 4]
=====================================
debian/patches/9dd9c6dd68a015f1159f884c57878b8a00fad14c.patch
=====================================
@@ -0,0 +1,23 @@
+From 9dd9c6dd68a015f1159f884c57878b8a00fad14c Mon Sep 17 00:00:00 2001
+From: Qiyun Zhu <qiyunzhu at gmail.com>
+Date: Tue, 7 Nov 2023 22:42:10 -0700
+Subject: [PATCH] fixing numpy exception
+Bug-Debian: https://bugs.debian.org/1063584
+
+---
+ skbio/stats/tests/test_composition.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/skbio/stats/tests/test_composition.py b/skbio/stats/tests/test_composition.py
+index 90921be5b..e720a594f 100644
+--- a/skbio/stats/tests/test_composition.py
++++ b/skbio/stats/tests/test_composition.py
+@@ -1222,7 +1222,7 @@ def test_ancom_fail_alpha(self):
+ ancom(self.table1, self.cats1, alpha=1.1)
+
+ def test_ancom_fail_multiple_groups(self):
+- with self.assertRaises(TypeError):
++ with self.assertRaises((TypeError, np.AxisError)):
+ ancom(self.table4, self.cats4,
+ significance_test=scipy.stats.ttest_ind)
+
=====================================
debian/patches/series
=====================================
@@ -8,3 +8,6 @@ modify-test.patch
numpy-1.24.patch
python3.12-xfail-tests.patch
cython3.patch
+290da0472e3a0af01b242cd1d3dd6a24588db0e5.patch
+6a2d1268a6c5c7d63edb9727f66e3de6d61f087e.patch
+9dd9c6dd68a015f1159f884c57878b8a00fad14c.patch
=====================================
debian/rules
=====================================
@@ -39,6 +39,7 @@ override_dh_auto_clean:
if [ "`find . -name "*.pyo"`" = "" ] ; then echo no need to clean up ; else dh_auto_clean; fi
override_dh_clean:
+ if [ -f simde-sse2.h.orig ] ; then mv simde-sse2.h.orig simde-sse2.h ; fi
dh_clean
find ./skbio -name '*.so' -delete
find ./skbio -name '*.o' -delete
View it on GitLab: https://salsa.debian.org/med-team/python-skbio/-/compare/6b6382c1bab2b3d06ab70c89f16b8f99c736fdca...ecca31828bf64c2cfba265dec8a690333c58178c
--
View it on GitLab: https://salsa.debian.org/med-team/python-skbio/-/compare/6b6382c1bab2b3d06ab70c89f16b8f99c736fdca...ecca31828bf64c2cfba265dec8a690333c58178c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20240211/cba4e4dd/attachment-0001.htm>
More information about the debian-med-commit
mailing list