@@ -1793,19 +1793,30 @@ def test_scatter_color(self):
17931793
17941794 @pytest .mark .parametrize ('c_case, re_key' , params_test_scatter_c )
17951795 def test_scatter_c (self , c_case , re_key ):
1796+ def get_next_color ():
1797+ return 'blue' # currently unused
1798+
1799+ from matplotlib .axes import Axes
1800+
1801+ xshape = yshape = (4 ,)
1802+
17961803 # Additional checking of *c* (introduced in #11383).
17971804 REGEXP = {
17981805 "shape" : "^'c' argument has [0-9]+ elements" , # shape mismatch
17991806 "conversion" : "^'c' argument must be a mpl color" , # bad vals
18001807 }
1801- x = y = [0 , 1 , 2 , 3 ]
1802- fig , ax = plt .subplots ()
18031808
18041809 if re_key is None :
1805- ax .scatter (x , y , c = c_case , edgecolors = "black" )
1810+ Axes ._parse_scatter_color_args (
1811+ c = c_case , edgecolors = "black" , kwargs = {},
1812+ xshape = xshape , yshape = yshape ,
1813+ get_next_color_func = get_next_color )
18061814 else :
18071815 with pytest .raises (ValueError , match = REGEXP [re_key ]):
1808- ax .scatter (x , y , c = c_case , edgecolors = "black" )
1816+ Axes ._parse_scatter_color_args (
1817+ c = c_case , edgecolors = "black" , kwargs = {},
1818+ xshape = xshape , yshape = yshape ,
1819+ get_next_color_func = get_next_color )
18091820
18101821
18111822def _params (c = None , xshape = (2 ,), yshape = (2 ,), ** kwargs ):
@@ -1829,11 +1840,12 @@ def _params(c=None, xshape=(2,), yshape=(2,), **kwargs):
18291840 _result (c = ['b' , 'g' ], colors = np .array ([[0 , 0 , 1 , 1 ], [0 , .5 , 0 , 1 ]]))),
18301841 ])
18311842def test_parse_scatter_color_args (params , expected_result ):
1843+ def get_next_color ():
1844+ return 'blue' # currently unused
1845+
18321846 from matplotlib .axes import Axes
1833- dummyself = 'UNUSED' # self is only used in one case, which we do not
1834- # test. Therefore we can get away without costly
1835- # creating an Axes instance.
1836- c , colors , _edgecolors = Axes ._parse_scatter_color_args (dummyself , * params )
1847+ c , colors , _edgecolors = Axes ._parse_scatter_color_args (
1848+ * params , get_next_color_func = get_next_color )
18371849 assert c == expected_result .c
18381850 assert_allclose (colors , expected_result .colors )
18391851
@@ -1855,15 +1867,16 @@ def test_parse_scatter_color_args(params, expected_result):
18551867 (dict (color = 'r' , edgecolor = 'g' ), 'g' ),
18561868 ])
18571869def test_parse_scatter_color_args_edgecolors (kwargs , expected_edgecolors ):
1870+ def get_next_color ():
1871+ return 'blue' # currently unused
1872+
18581873 from matplotlib .axes import Axes
1859- dummyself = 'UNUSED' # self is only used in one case, which we do not
1860- # test. Therefore we can get away without costly
1861- # creating an Axes instance.
18621874 c = kwargs .pop ('c' , None )
18631875 edgecolors = kwargs .pop ('edgecolors' , None )
18641876 _ , _ , result_edgecolors = \
1865- Axes ._parse_scatter_color_args (dummyself , c , edgecolors , kwargs ,
1866- xshape = (2 ,), yshape = (2 ,))
1877+ Axes ._parse_scatter_color_args (c , edgecolors , kwargs ,
1878+ xshape = (2 ,), yshape = (2 ,),
1879+ get_next_color_func = get_next_color )
18671880 assert result_edgecolors == expected_edgecolors
18681881
18691882
0 commit comments