@@ -1794,19 +1794,30 @@ def test_scatter_color(self):
17941794
17951795 @pytest .mark .parametrize ('c_case, re_key' , params_test_scatter_c )
17961796 def test_scatter_c (self , c_case , re_key ):
1797+ def get_next_color ():
1798+ return 'blue' # currently unused
1799+
1800+ from matplotlib .axes import Axes
1801+
1802+ xshape = yshape = (4 ,)
1803+
17971804 # Additional checking of *c* (introduced in #11383).
17981805 REGEXP = {
17991806 "shape" : "^'c' argument has [0-9]+ elements" , # shape mismatch
18001807 "conversion" : "^'c' argument must be a mpl color" , # bad vals
18011808 }
1802- x = y = [0 , 1 , 2 , 3 ]
1803- fig , ax = plt .subplots ()
18041809
18051810 if re_key is None :
1806- ax .scatter (x , y , c = c_case , edgecolors = "black" )
1811+ Axes ._parse_scatter_color_args (
1812+ c = c_case , edgecolors = "black" , kwargs = {},
1813+ xshape = xshape , yshape = yshape ,
1814+ get_next_color_func = get_next_color )
18071815 else :
18081816 with pytest .raises (ValueError , match = REGEXP [re_key ]):
1809- ax .scatter (x , y , c = c_case , edgecolors = "black" )
1817+ Axes ._parse_scatter_color_args (
1818+ c = c_case , edgecolors = "black" , kwargs = {},
1819+ xshape = xshape , yshape = yshape ,
1820+ get_next_color_func = get_next_color )
18101821
18111822
18121823def _params (c = None , xshape = (2 ,), yshape = (2 ,), ** kwargs ):
@@ -1830,11 +1841,12 @@ def _params(c=None, xshape=(2,), yshape=(2,), **kwargs):
18301841 _result (c = ['b' , 'g' ], colors = np .array ([[0 , 0 , 1 , 1 ], [0 , .5 , 0 , 1 ]]))),
18311842 ])
18321843def test_parse_scatter_color_args (params , expected_result ):
1844+ def get_next_color ():
1845+ return 'blue' # currently unused
1846+
18331847 from matplotlib .axes import Axes
1834- dummyself = 'UNUSED' # self is only used in one case, which we do not
1835- # test. Therefore we can get away without costly
1836- # creating an Axes instance.
1837- c , colors , _edgecolors = Axes ._parse_scatter_color_args (dummyself , * params )
1848+ c , colors , _edgecolors = Axes ._parse_scatter_color_args (
1849+ * params , get_next_color_func = get_next_color )
18381850 assert c == expected_result .c
18391851 assert_allclose (colors , expected_result .colors )
18401852
@@ -1856,15 +1868,16 @@ def test_parse_scatter_color_args(params, expected_result):
18561868 (dict (color = 'r' , edgecolor = 'g' ), 'g' ),
18571869 ])
18581870def test_parse_scatter_color_args_edgecolors (kwargs , expected_edgecolors ):
1871+ def get_next_color ():
1872+ return 'blue' # currently unused
1873+
18591874 from matplotlib .axes import Axes
1860- dummyself = 'UNUSED' # self is only used in one case, which we do not
1861- # test. Therefore we can get away without costly
1862- # creating an Axes instance.
18631875 c = kwargs .pop ('c' , None )
18641876 edgecolors = kwargs .pop ('edgecolors' , None )
18651877 _ , _ , result_edgecolors = \
1866- Axes ._parse_scatter_color_args (dummyself , c , edgecolors , kwargs ,
1867- xshape = (2 ,), yshape = (2 ,))
1878+ Axes ._parse_scatter_color_args (c , edgecolors , kwargs ,
1879+ xshape = (2 ,), yshape = (2 ,),
1880+ get_next_color_func = get_next_color )
18681881 assert result_edgecolors == expected_edgecolors
18691882
18701883
0 commit comments