11from cycler import cycler
2- import matplotlib as mpl
3- import matplotlib .colors
42import pytest
53
64from pandas import Series
@@ -20,6 +18,8 @@ class TestGetStandardColors:
2018 ],
2119 )
2220 def test_default_colors_named_from_prop_cycle (self , num_colors , expected ):
21+ import matplotlib as mpl
22+
2323 mpl_params = {
2424 "axes.prop_cycle" : cycler (color = ["red" , "green" , "blue" ]),
2525 }
@@ -38,6 +38,8 @@ def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
3838 ],
3939 )
4040 def test_default_colors_named_from_prop_cycle_string (self , num_colors , expected ):
41+ import matplotlib as mpl
42+
4143 mpl_params = {
4244 "axes.prop_cycle" : cycler (color = "bgry" ),
4345 }
@@ -70,8 +72,11 @@ def test_default_colors_named_from_prop_cycle_string(self, num_colors, expected)
7072 ],
7173 )
7274 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+
7378 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 ]
7580 result = get_standard_colors (num_colors = num_colors )
7681 assert result == expected
7782
@@ -138,8 +143,8 @@ def test_empty_color_raises(self, color):
138143 @pytest .mark .parametrize (
139144 "color" ,
140145 [
141- "BAD_COLOR " ,
142- ("red" , "green" , "BAD_COLOR " ),
146+ "bad_color " ,
147+ ("red" , "green" , "bad_color " ),
143148 (0.1 ,),
144149 (0.1 , 0.2 ),
145150 (0.1 , 0.2 , 0.3 , 0.4 , 0.5 ), # must be either 3 or 4 floats
0 commit comments