Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 771bb19

Browse filesBrowse files
authored
Merge pull request #14378 from timhoffm/remove-setup_method
Remove setup_method
2 parents e891b77 + f0ca07b commit 771bb19
Copy full SHA for 771bb19

File tree

Expand file treeCollapse file tree

1 file changed

+21
-30
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-30
lines changed

‎lib/matplotlib/tests/test_cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_cbook.py
+21-30Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
import matplotlib.cbook as cbook
1515
import matplotlib.colors as mcolors
16-
from matplotlib.cbook import (
17-
MatplotlibDeprecationWarning, delete_masked_points as dmp)
16+
from matplotlib.cbook import MatplotlibDeprecationWarning, delete_masked_points
1817

1918

2019
def test_is_hashable():
@@ -26,45 +25,37 @@ def test_is_hashable():
2625

2726

2827
class Test_delete_masked_points:
29-
def setup_method(self):
30-
self.mask1 = [False, False, True, True, False, False]
31-
self.arr0 = np.arange(1.0, 7.0)
32-
self.arr1 = [1, 2, 3, np.nan, np.nan, 6]
33-
self.arr2 = np.array(self.arr1)
34-
self.arr3 = np.ma.array(self.arr2, mask=self.mask1)
35-
self.arr_s = ['a', 'b', 'c', 'd', 'e', 'f']
36-
self.arr_s2 = np.array(self.arr_s)
37-
self.arr_dt = [datetime(2008, 1, 1), datetime(2008, 1, 2),
38-
datetime(2008, 1, 3), datetime(2008, 1, 4),
39-
datetime(2008, 1, 5), datetime(2008, 1, 6)]
40-
self.arr_dt2 = np.array(self.arr_dt)
41-
self.arr_colors = ['r', 'g', 'b', 'c', 'm', 'y']
42-
self.arr_rgba = mcolors.to_rgba_array(self.arr_colors)
43-
4428
def test_bad_first_arg(self):
4529
with pytest.raises(ValueError):
46-
dmp('a string', self.arr0)
30+
delete_masked_points('a string', np.arange(1.0, 7.0))
4731

4832
def test_string_seq(self):
49-
actual = dmp(self.arr_s, self.arr1)
33+
a1 = ['a', 'b', 'c', 'd', 'e', 'f']
34+
a2 = [1, 2, 3, np.nan, np.nan, 6]
35+
result1, result2 = delete_masked_points(a1, a2)
5036
ind = [0, 1, 2, 5]
51-
expected = (self.arr_s2[ind], self.arr2[ind])
52-
assert_array_equal(actual[0], expected[0])
53-
assert_array_equal(actual[1], expected[1])
37+
assert_array_equal(result1, np.array(a1)[ind])
38+
assert_array_equal(result2, np.array(a2)[ind])
5439

5540
def test_datetime(self):
56-
actual = dmp(self.arr_dt, self.arr3)
41+
dates = [datetime(2008, 1, 1), datetime(2008, 1, 2),
42+
datetime(2008, 1, 3), datetime(2008, 1, 4),
43+
datetime(2008, 1, 5), datetime(2008, 1, 6)]
44+
a_masked = np.ma.array([1, 2, 3, np.nan, np.nan, 6],
45+
mask=[False, False, True, True, False, False])
46+
actual = delete_masked_points(dates, a_masked)
5747
ind = [0, 1, 5]
58-
expected = (self.arr_dt2[ind], self.arr3[ind].compressed())
59-
assert_array_equal(actual[0], expected[0])
60-
assert_array_equal(actual[1], expected[1])
48+
assert_array_equal(actual[0], np.array(dates)[ind])
49+
assert_array_equal(actual[1], a_masked[ind].compressed())
6150

6251
def test_rgba(self):
63-
actual = dmp(self.arr3, self.arr_rgba)
52+
a_masked = np.ma.array([1, 2, 3, np.nan, np.nan, 6],
53+
mask=[False, False, True, True, False, False])
54+
a_rgba = mcolors.to_rgba_array(['r', 'g', 'b', 'c', 'm', 'y'])
55+
actual = delete_masked_points(a_masked, a_rgba)
6456
ind = [0, 1, 5]
65-
expected = (self.arr3[ind].compressed(), self.arr_rgba[ind])
66-
assert_array_equal(actual[0], expected[0])
67-
assert_array_equal(actual[1], expected[1])
57+
assert_array_equal(actual[0], a_masked[ind].compressed())
58+
assert_array_equal(actual[1], a_rgba[ind])
6859

6960

7061
class Test_boxplot_stats:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.