50
50
# the tests with multiple threads.
51
51
52
52
53
+ def get_next_color ():
54
+ """
55
+ Helper function for tests that need to call _parse_scatter_color_args directly.
56
+ Previously it was inserted in individual tests and would get flagged as untested.
57
+ """
58
+ return 'blue'
59
+
60
+
61
+ def test_get_next_color ():
62
+ result = mpl .axes .Axes ._parse_scatter_color_args (
63
+ c = None ,
64
+ edgecolors = None ,
65
+ kwargs = {},
66
+ xsize = 2 ,
67
+ get_next_color_func = get_next_color
68
+ )
69
+ assert result .colors == 'blue'
70
+
71
+
53
72
@check_figures_equal (extensions = ["png" ])
54
73
def test_invisible_axes (fig_test , fig_ref ):
55
74
ax = fig_test .subplots ()
@@ -2905,9 +2924,6 @@ def test_scatter_different_shapes(self, fig_test, fig_ref):
2905
2924
2906
2925
@pytest .mark .parametrize ('c_case, re_key' , params_test_scatter_c )
2907
2926
def test_scatter_c (self , c_case , re_key ):
2908
- def get_next_color ():
2909
- return 'blue' # currently unused
2910
-
2911
2927
xsize = 4
2912
2928
# Additional checking of *c* (introduced in #11383).
2913
2929
REGEXP = {
@@ -2999,9 +3015,6 @@ def _params(c=None, xsize=2, *, edgecolors=None, **kwargs):
2999
3015
_result (c = ['b' , 'g' ], colors = np .array ([[0 , 0 , 1 , 1 ], [0 , .5 , 0 , 1 ]]))),
3000
3016
])
3001
3017
def test_parse_scatter_color_args (params , expected_result ):
3002
- def get_next_color ():
3003
- return 'blue' # currently unused
3004
-
3005
3018
c , colors , _edgecolors = mpl .axes .Axes ._parse_scatter_color_args (
3006
3019
* params , get_next_color_func = get_next_color )
3007
3020
assert c == expected_result .c
@@ -3026,9 +3039,6 @@ def get_next_color():
3026
3039
(dict (color = 'r' , edgecolor = 'g' ), 'g' ),
3027
3040
])
3028
3041
def test_parse_scatter_color_args_edgecolors (kwargs , expected_edgecolors ):
3029
- def get_next_color ():
3030
- return 'blue' # currently unused
3031
-
3032
3042
c = kwargs .pop ('c' , None )
3033
3043
edgecolors = kwargs .pop ('edgecolors' , None )
3034
3044
_ , _ , result_edgecolors = \
@@ -3038,9 +3048,6 @@ def get_next_color():
3038
3048
3039
3049
3040
3050
def test_parse_scatter_color_args_error ():
3041
- def get_next_color ():
3042
- return 'blue' # currently unused
3043
-
3044
3051
with pytest .raises (ValueError ,
3045
3052
match = "RGBA values should be within 0-1 range" ):
3046
3053
c = np .array ([[0.1 , 0.2 , 0.7 ], [0.2 , 0.4 , 1.4 ]]) # value > 1
@@ -3065,20 +3072,17 @@ def get_next_color():
3065
3072
@pytest .mark .parametrize ('c, facecolor' , COLOR_TEST_CASES )
3066
3073
def test_parse_c_facecolor_warning_direct (c , facecolor ):
3067
3074
"""Test the internal _parse_scatter_color_args method directly."""
3068
- def get_next_color ():
3069
- return 'blue'
3070
-
3071
3075
# Test with facecolors (plural)
3072
3076
with pytest .warns (UserWarning , match = WARN_MSG ):
3073
3077
mpl .axes .Axes ._parse_scatter_color_args (
3074
3078
c = c , edgecolors = None , kwargs = {'facecolors' : facecolor },
3075
- xsize = 2 , get_next_color_func = get_next_color )
3079
+ xsize = 2 , get_next_color_func = get_next_color () )
3076
3080
3077
3081
# Test with facecolor (singular)
3078
3082
with pytest .warns (UserWarning , match = WARN_MSG ):
3079
3083
mpl .axes .Axes ._parse_scatter_color_args (
3080
3084
c = c , edgecolors = None , kwargs = {'facecolor' : facecolor },
3081
- xsize = 2 , get_next_color_func = get_next_color )
3085
+ xsize = 2 , get_next_color_func = get_next_color () )
3082
3086
3083
3087
3084
3088
@pytest .mark .parametrize ('c, facecolor' , COLOR_TEST_CASES )
@@ -9057,9 +9061,6 @@ def test_child_axes_removal():
9057
9061
9058
9062
9059
9063
def test_scatter_color_repr_error ():
9060
-
9061
- def get_next_color ():
9062
- return 'blue' # pragma: no cover
9063
9064
msg = (
9064
9065
r"'c' argument must be a color, a sequence of colors"
9065
9066
r", or a sequence of numbers, not 'red\\n'"
0 commit comments