13
13
14
14
import matplotlib .cbook as cbook
15
15
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
18
17
19
18
20
19
def test_is_hashable ():
@@ -26,45 +25,37 @@ def test_is_hashable():
26
25
27
26
28
27
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
-
44
28
def test_bad_first_arg (self ):
45
29
with pytest .raises (ValueError ):
46
- dmp ('a string' , self . arr0 )
30
+ delete_masked_points ('a string' , np . arange ( 1.0 , 7.0 ) )
47
31
48
32
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 )
50
36
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 ])
54
39
55
40
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 )
57
47
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 ())
61
50
62
51
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 )
64
56
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 ])
68
59
69
60
70
61
class Test_boxplot_stats :
0 commit comments