projects/guix·blob python-team · refs

95 lines · 2.9 KiB

1This patch is from the upstream pull request.
2https://github.com/daleroberts/hdmedians/pull/10.
3It adds compatibility with Pytest and drops Nose.
4
5diff --git a/hdmedians/tests/test_geomedian.py b/hdmedians/tests/test_geomedian.py
6index 0bc37e9..ff5f938 100644
7--- a/hdmedians/tests/test_geomedian.py
8+++ b/hdmedians/tests/test_geomedian.py
9@@ -4,9 +4,9 @@ Tests.
10
11 import numpy as np
12 import hdmedians as hd
13+import pytest
14
15 from numpy.testing import assert_equal, assert_array_almost_equal
16-from nose.tools import assert_true, assert_raises
17
18 # shape (6, 25)
19 DATA1 = np.array([[693, 990, 1281, 2101, 3524, 2577],
20@@ -124,10 +124,12 @@ def test_nangeomedian_axis_one_two_good():
21 def test_nangeomedian_axis_bad():
22 data = np.array([[1.0, np.nan, 1.0],
23 [2.0, 1.0, 1.0]])
24- assert_raises(IndexError, hd.nangeomedian, data, axis=2)
25+ with pytest.raises(IndexError):
26+ hd.nangeomedian(data, axis=2)
27
28
29 def test_nangeomedian_all_nan():
30 data = np.array([[np.nan, np.nan, np.nan],
31 [np.nan, np.nan, np.nan]])
32- assert_raises(ValueError, hd.nangeomedian, data)
33+ with pytest.raises(ValueError):
34+ hd.nangeomedian(data)
35diff --git a/hdmedians/tests/test_medoid.py b/hdmedians/tests/test_medoid.py
36index c5e0a7f..4fbdf80 100644
37--- a/hdmedians/tests/test_medoid.py
38+++ b/hdmedians/tests/test_medoid.py
39@@ -4,9 +4,9 @@ Tests.
40
41 import numpy as np
42 import hdmedians as hd
43+import pytest
44
45 from numpy.testing import assert_equal, assert_array_almost_equal
46-from nose.tools import assert_true, assert_raises
47
48 # shape (6, 25)
49 DATA1 = np.array([[693, 990, 1281, 2101, 3524, 2577],
50@@ -59,7 +59,7 @@ def test_medoid_in_set_random():
51 s = [list(x) for x in a.T]
52 m = hd.medoid(a)
53 idx = s.index(list(m))
54- assert_true(idx > -1)
55+ assert(idx > -1)
56
57
58 def test_medoid_noaxis():
59@@ -85,7 +85,8 @@ def test_medoid_axis_one():
60
61
62 def test_medoid_axis_bad():
63- assert_raises(IndexError, hd.medoid, DATA1, axis=2)
64+ with pytest.raises(IndexError):
65+ hd.medoid(DATA1, axis=2)
66
67
68 def test_medoid_noaxis_indexonly():
69@@ -136,7 +137,8 @@ def test_nanmedoid_two_obs():
70 def test_nanmedoid_all_nan():
71 data = np.array([[np.nan, np.nan, np.nan],
72 [np.nan, np.nan, np.nan]])
73- assert_raises(ValueError, hd.nanmedoid, data)
74+ with pytest.raises(ValueError):
75+ hd.nanmedoid(data)
76
77
78 def test_nanmedoid_axis_zero():
79@@ -170,7 +172,8 @@ def test_nanmedoid_axis_one_indexonly():
80
81
82 def test_nanmedoid_axis_bad():
83- assert_raises(IndexError, hd.nanmedoid, DATA1, axis=2)
84+ with pytest.raises(IndexError):
85+ hd.nanmedoid(DATA1, axis=2)
86
87
88 def test_nanmedoid_two_obs():
89@@ -184,4 +187,5 @@ def test_nanmedoid_two_obs():
90 def test_nanmedoid_all_nan():
91 data = np.array([[np.nan, np.nan, np.nan],
92 [np.nan, np.nan, np.nan]])
93- assert_raises(ValueError, hd.nanmedoid, data)
94+ with pytest.raises(ValueError):
95+ hd.nanmedoid(data)