@@ -1793,19 +1793,30 @@ def test_scatter_color(self):
1793
1793
1794
1794
@pytest .mark .parametrize ('c_case, re_key' , params_test_scatter_c )
1795
1795
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
+
1796
1803
# Additional checking of *c* (introduced in #11383).
1797
1804
REGEXP = {
1798
1805
"shape" : "^'c' argument has [0-9]+ elements" , # shape mismatch
1799
1806
"conversion" : "^'c' argument must be a mpl color" , # bad vals
1800
1807
}
1801
- x = y = [0 , 1 , 2 , 3 ]
1802
- fig , ax = plt .subplots ()
1803
1808
1804
1809
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 )
1806
1814
else :
1807
1815
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 )
1809
1820
1810
1821
1811
1822
def _params (c = None , xshape = (2 ,), yshape = (2 ,), ** kwargs ):
@@ -1829,11 +1840,12 @@ def _params(c=None, xshape=(2,), yshape=(2,), **kwargs):
1829
1840
_result (c = ['b' , 'g' ], colors = np .array ([[0 , 0 , 1 , 1 ], [0 , .5 , 0 , 1 ]]))),
1830
1841
])
1831
1842
def test_parse_scatter_color_args (params , expected_result ):
1843
+ def get_next_color ():
1844
+ return 'blue' # currently unused
1845
+
1832
1846
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 )
1837
1849
assert c == expected_result .c
1838
1850
assert_allclose (colors , expected_result .colors )
1839
1851
@@ -1855,15 +1867,16 @@ def test_parse_scatter_color_args(params, expected_result):
1855
1867
(dict (color = 'r' , edgecolor = 'g' ), 'g' ),
1856
1868
])
1857
1869
def test_parse_scatter_color_args_edgecolors (kwargs , expected_edgecolors ):
1870
+ def get_next_color ():
1871
+ return 'blue' # currently unused
1872
+
1858
1873
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.
1862
1874
c = kwargs .pop ('c' , None )
1863
1875
edgecolors = kwargs .pop ('edgecolors' , None )
1864
1876
_ , _ , 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 )
1867
1880
assert result_edgecolors == expected_edgecolors
1868
1881
1869
1882
0 commit comments