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