Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 38c092a

Browse filesBrowse files
committed
Added direct test of _parse method to attempt to make Codecov happy.
1 parent 8234066 commit 38c092a
Copy full SHA for 38c092a

File tree

1 file changed

+49
-18
lines changed
Filter options

1 file changed

+49
-18
lines changed

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+49-18Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2765,24 +2765,6 @@ def test_scatter_color_warning(self, kwargs):
27652765
plt.scatter([], [], c=[], **kwargs)
27662766
plt.scatter([1, 2], [3, 4], c=[4, 5], **kwargs)
27672767

2768-
@pytest.mark.parametrize('colors',
2769-
[
2770-
('red', 'blue'),
2771-
(['red', 'blue'], ['green', 'yellow']),
2772-
([[1, 0, 0], [0, 1, 0]], [[0, 0, 1], [1, 1, 0]])
2773-
])
2774-
def test_scatter_c_facecolor_warning(self, colors):
2775-
warn_match = (
2776-
"You passed both c and facecolor/facecolors for the markers. "
2777-
"c has precedence over facecolor/facecolors. This behavior may "
2778-
"change in the future."
2779-
)
2780-
fig, ax = plt.subplots()
2781-
x = [0, 1] if len(colors[0]) == 2 else [0]
2782-
y = x
2783-
with pytest.warns(UserWarning, match=warn_match):
2784-
ax.scatter(x, y, c=colors[0], facecolors=colors[1])
2785-
27862768
def test_scatter_unfilled(self):
27872769
coll = plt.scatter([0, 1, 2], [1, 3, 2], c=['0.1', '0.3', '0.5'],
27882770
marker=mmarkers.MarkerStyle('o', fillstyle='none'),
@@ -3066,6 +3048,55 @@ def get_next_color():
30663048
c, None, kwargs={}, xsize=2, get_next_color_func=get_next_color)
30673049

30683050

3051+
# Warning message tested in the next two tests.
3052+
WARN_MSG = (
3053+
"You passed both c and facecolor/facecolors for the markers. "
3054+
"c has precedence over facecolor/facecolors. This behavior may "
3055+
"change in the future."
3056+
)
3057+
# Test cases shared between direct and integration tests
3058+
COLOR_TEST_CASES = [
3059+
('red', 'blue'),
3060+
(['red', 'blue'], ['green', 'yellow']),
3061+
([[1, 0, 0], [0, 1, 0]], [[0, 0, 1], [1, 1, 0]])
3062+
]
3063+
3064+
3065+
@pytest.mark.parametrize('c, facecolor', COLOR_TEST_CASES)
3066+
def test_parse_c_facecolor_warning_direct(c, facecolor):
3067+
"""Test the internal _parse_scatter_color_args method directly."""
3068+
def get_next_color():
3069+
return 'blue'
3070+
3071+
# Test with facecolors (plural)
3072+
with pytest.warns(UserWarning, match=WARN_MSG):
3073+
mpl.axes.Axes._parse_scatter_color_args(
3074+
c=c, edgecolors=None, kwargs={'facecolors': facecolor},
3075+
xsize=2, get_next_color_func=get_next_color)
3076+
3077+
# Test with facecolor (singular)
3078+
with pytest.warns(UserWarning, match=WARN_MSG):
3079+
mpl.axes.Axes._parse_scatter_color_args(
3080+
c=c, edgecolors=None, kwargs={'facecolor': facecolor},
3081+
xsize=2, get_next_color_func=get_next_color)
3082+
3083+
3084+
@pytest.mark.parametrize('c, facecolor', COLOR_TEST_CASES)
3085+
def test_scatter_c_facecolor_warning_integration(c, facecolor):
3086+
"""Test the warning through the actual scatter plot creation."""
3087+
fig, ax = plt.subplots()
3088+
x = [0, 1] if isinstance(c, (list, tuple)) else [0]
3089+
y = x
3090+
3091+
# Test with facecolors (plural)
3092+
with pytest.warns(UserWarning, match=WARN_MSG):
3093+
ax.scatter(x, y, c=c, facecolors=facecolor)
3094+
3095+
# Test with facecolor (singular)
3096+
with pytest.warns(UserWarning, match=WARN_MSG):
3097+
ax.scatter(x, y, c=c, facecolor=facecolor)
3098+
3099+
30693100
def test_as_mpl_axes_api():
30703101
# tests the _as_mpl_axes api
30713102
class Polar:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.