mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-25 12:05:19 -06:00
gnu: python-hdmedians: Switch to Pytest backend.
* gnu/packages/statistics.scm (python-hdmedians)[source]<patch>: Add patch fixing tests. [arguments] <test-flags>: Provide "--pyargs" option to tests against compiled module. <phases>: Remove 'build-extensions. [native-inputs]: Remove python-nose; add python-pytest. * gnu/packages/patches/python-hdmedians-replace-nose.patch: New file * gnu/local.mk (dist_patch_DATA): Register new patch. Change-Id: I86c577a55c2c273bd6504d225af8056f65593f77
This commit is contained in:
parent
cd06ad91e9
commit
d8e2caa60b
3 changed files with 106 additions and 10 deletions
|
|
@ -2039,6 +2039,7 @@ dist_patch_DATA = \
|
|||
%D%/packages/patches/python-clarabel-blas.patch \
|
||||
%D%/packages/patches/python-docrepr-fix-tests.patch \
|
||||
%D%/packages/patches/python-feedparser-missing-import.patch \
|
||||
%D%/packages/patches/python-hdmedians-replace-nose.patch \
|
||||
%D%/packages/patches/python-louvain-fix-test.patch \
|
||||
%D%/packages/patches/python-matplotlib-fix-legend-loc-best-test.patch \
|
||||
%D%/packages/patches/python-mohawk-pytest.patch \
|
||||
|
|
|
|||
95
gnu/packages/patches/python-hdmedians-replace-nose.patch
Normal file
95
gnu/packages/patches/python-hdmedians-replace-nose.patch
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
This patch is from the upstream pull request.
|
||||
https://github.com/daleroberts/hdmedians/pull/10.
|
||||
It adds compatibility with Pytest and drops Nose.
|
||||
|
||||
diff --git a/hdmedians/tests/test_geomedian.py b/hdmedians/tests/test_geomedian.py
|
||||
index 0bc37e9..ff5f938 100644
|
||||
--- a/hdmedians/tests/test_geomedian.py
|
||||
+++ b/hdmedians/tests/test_geomedian.py
|
||||
@@ -4,9 +4,9 @@ Tests.
|
||||
|
||||
import numpy as np
|
||||
import hdmedians as hd
|
||||
+import pytest
|
||||
|
||||
from numpy.testing import assert_equal, assert_array_almost_equal
|
||||
-from nose.tools import assert_true, assert_raises
|
||||
|
||||
# shape (6, 25)
|
||||
DATA1 = np.array([[693, 990, 1281, 2101, 3524, 2577],
|
||||
@@ -124,10 +124,12 @@ def test_nangeomedian_axis_one_two_good():
|
||||
def test_nangeomedian_axis_bad():
|
||||
data = np.array([[1.0, np.nan, 1.0],
|
||||
[2.0, 1.0, 1.0]])
|
||||
- assert_raises(IndexError, hd.nangeomedian, data, axis=2)
|
||||
+ with pytest.raises(IndexError):
|
||||
+ hd.nangeomedian(data, axis=2)
|
||||
|
||||
|
||||
def test_nangeomedian_all_nan():
|
||||
data = np.array([[np.nan, np.nan, np.nan],
|
||||
[np.nan, np.nan, np.nan]])
|
||||
- assert_raises(ValueError, hd.nangeomedian, data)
|
||||
+ with pytest.raises(ValueError):
|
||||
+ hd.nangeomedian(data)
|
||||
diff --git a/hdmedians/tests/test_medoid.py b/hdmedians/tests/test_medoid.py
|
||||
index c5e0a7f..4fbdf80 100644
|
||||
--- a/hdmedians/tests/test_medoid.py
|
||||
+++ b/hdmedians/tests/test_medoid.py
|
||||
@@ -4,9 +4,9 @@ Tests.
|
||||
|
||||
import numpy as np
|
||||
import hdmedians as hd
|
||||
+import pytest
|
||||
|
||||
from numpy.testing import assert_equal, assert_array_almost_equal
|
||||
-from nose.tools import assert_true, assert_raises
|
||||
|
||||
# shape (6, 25)
|
||||
DATA1 = np.array([[693, 990, 1281, 2101, 3524, 2577],
|
||||
@@ -59,7 +59,7 @@ def test_medoid_in_set_random():
|
||||
s = [list(x) for x in a.T]
|
||||
m = hd.medoid(a)
|
||||
idx = s.index(list(m))
|
||||
- assert_true(idx > -1)
|
||||
+ assert(idx > -1)
|
||||
|
||||
|
||||
def test_medoid_noaxis():
|
||||
@@ -85,7 +85,8 @@ def test_medoid_axis_one():
|
||||
|
||||
|
||||
def test_medoid_axis_bad():
|
||||
- assert_raises(IndexError, hd.medoid, DATA1, axis=2)
|
||||
+ with pytest.raises(IndexError):
|
||||
+ hd.medoid(DATA1, axis=2)
|
||||
|
||||
|
||||
def test_medoid_noaxis_indexonly():
|
||||
@@ -136,7 +137,8 @@ def test_nanmedoid_two_obs():
|
||||
def test_nanmedoid_all_nan():
|
||||
data = np.array([[np.nan, np.nan, np.nan],
|
||||
[np.nan, np.nan, np.nan]])
|
||||
- assert_raises(ValueError, hd.nanmedoid, data)
|
||||
+ with pytest.raises(ValueError):
|
||||
+ hd.nanmedoid(data)
|
||||
|
||||
|
||||
def test_nanmedoid_axis_zero():
|
||||
@@ -170,7 +172,8 @@ def test_nanmedoid_axis_one_indexonly():
|
||||
|
||||
|
||||
def test_nanmedoid_axis_bad():
|
||||
- assert_raises(IndexError, hd.nanmedoid, DATA1, axis=2)
|
||||
+ with pytest.raises(IndexError):
|
||||
+ hd.nanmedoid(DATA1, axis=2)
|
||||
|
||||
|
||||
def test_nanmedoid_two_obs():
|
||||
@@ -184,4 +187,5 @@ def test_nanmedoid_two_obs():
|
||||
def test_nanmedoid_all_nan():
|
||||
data = np.array([[np.nan, np.nan, np.nan],
|
||||
[np.nan, np.nan, np.nan]])
|
||||
- assert_raises(ValueError, hd.nanmedoid, data)
|
||||
+ with pytest.raises(ValueError):
|
||||
+ hd.nanmedoid(data)
|
||||
|
|
@ -1100,19 +1100,19 @@ correlated samples from Markov Chain Monte Carlo (MCMC).")
|
|||
(uri (pypi-uri "hdmedians" version))
|
||||
(sha256
|
||||
(base32
|
||||
"1mn2k8srnmfy451l7zvb2l4hn9701bc5awjm6q3vmqbicyqyqyml"))))
|
||||
"1mn2k8srnmfy451l7zvb2l4hn9701bc5awjm6q3vmqbicyqyqyml"))
|
||||
(patches (search-patches "python-hdmedians-replace-nose.patch"))))
|
||||
(build-system pyproject-build-system)
|
||||
(arguments
|
||||
(list
|
||||
#:phases
|
||||
'(modify-phases %standard-phases
|
||||
(add-before 'check 'build-extensions
|
||||
(lambda _
|
||||
;; Cython extensions have to be built before running the tests.
|
||||
(invoke "python" "setup.py" "build_ext" "--inplace"))))))
|
||||
(propagated-inputs (list python-cython python-numpy python-setuptools
|
||||
python-wheel))
|
||||
(native-inputs (list python-nose))
|
||||
#:test-flags #~(list "--pyargs" "hdmedians")))
|
||||
(native-inputs
|
||||
(list python-pytest))
|
||||
(propagated-inputs
|
||||
(list python-cython
|
||||
python-numpy
|
||||
python-setuptools
|
||||
python-wheel))
|
||||
(home-page "http://github.com/daleroberts/hdmedians")
|
||||
(synopsis "High-dimensional medians")
|
||||
(description "Various definitions for a high-dimensional median exist and
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue