1
1
from cycler import cycler
2
- import matplotlib as mpl
3
- import matplotlib .colors
4
2
import pytest
5
3
6
4
from pandas import Series
@@ -20,6 +18,8 @@ class TestGetStandardColors:
20
18
],
21
19
)
22
20
def test_default_colors_named_from_prop_cycle (self , num_colors , expected ):
21
+ import matplotlib as mpl
22
+
23
23
mpl_params = {
24
24
"axes.prop_cycle" : cycler (color = ["red" , "green" , "blue" ]),
25
25
}
@@ -38,6 +38,8 @@ def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
38
38
],
39
39
)
40
40
def test_default_colors_named_from_prop_cycle_string (self , num_colors , expected ):
41
+ import matplotlib as mpl
42
+
41
43
mpl_params = {
42
44
"axes.prop_cycle" : cycler (color = "bgry" ),
43
45
}
@@ -70,8 +72,11 @@ def test_default_colors_named_from_prop_cycle_string(self, num_colors, expected)
70
72
],
71
73
)
72
74
def test_default_colors_named_undefined_prop_cycle (self , num_colors , expected_name ):
75
+ import matplotlib as mpl
76
+ import matplotlib .colors as mcolors
77
+
73
78
with mpl .rc_context (rc = {}):
74
- expected = [matplotlib . colors .to_hex (x ) for x in expected_name ]
79
+ expected = [mcolors .to_hex (x ) for x in expected_name ]
75
80
result = get_standard_colors (num_colors = num_colors )
76
81
assert result == expected
77
82
@@ -138,8 +143,8 @@ def test_empty_color_raises(self, color):
138
143
@pytest .mark .parametrize (
139
144
"color" ,
140
145
[
141
- "BAD_COLOR " ,
142
- ("red" , "green" , "BAD_COLOR " ),
146
+ "bad_color " ,
147
+ ("red" , "green" , "bad_color " ),
143
148
(0.1 ,),
144
149
(0.1 , 0.2 ),
145
150
(0.1 , 0.2 , 0.3 , 0.4 , 0.5 ), # must be either 3 or 4 floats
0 commit comments