Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5a26bb9
Raise warning if both c and facecolors are used in scatter plot. In t…
NGWi Nov 12, 2024
f1966c2
Corrected flake8 formatting warnings.
NGWi Nov 12, 2024
53a0825
Removed offending whitespace and extra line.
NGWi Nov 13, 2024
a777a15
Merge branch 'issue24404_addwarning' of https://github.com/NGWi/matpl…
NGWi Nov 13, 2024
8031809
Corrected old test that qualified for the new warning.
NGWi Nov 13, 2024
8ae213c
Made message more concise, and straightened old test, to fulfill @tim…
NGWi Nov 18, 2024
49f03f7
Added test.
NGWi Nov 18, 2024
8234066
Corrected flake8 linting objections.
NGWi Nov 18, 2024
38c092a
Added direct test of _parse method to attempt to make Codecov happy.
NGWi Nov 18, 2024
e6e49aa
Added pragma tags for code coverage to ignore unused but untested sim…
NGWi Dec 3, 2024
39e1899
Raise warning if both c and facecolors are used in scatter plot. In t…
NGWi Nov 12, 2024
06c8a76
Corrected flake8 formatting warnings.
NGWi Nov 12, 2024
72138c6
Corrected old test that qualified for the new warning.
NGWi Nov 13, 2024
319b92b
Made message more concise, and straightened old test, to fulfill @tim…
NGWi Nov 18, 2024
e348dfc
Added test.
NGWi Nov 18, 2024
fcf6ce2
Corrected flake8 linting objections.
NGWi Nov 18, 2024
9601975
Added direct test of _parse method to attempt to make Codecov happy.
NGWi Nov 18, 2024
a18364c
Added pragma tags for code coverage to ignore unused but untested sim…
NGWi Dec 3, 2024
310a15f
Corrected placement of pragma tags and added 'currently unused' to Je…
NGWi Dec 4, 2024
7c01a7b
Tim's suggestion for naming test's list of colors.
NGWi Dec 4, 2024
fd3d9db
Corrected call to changed variable name.
NGWi Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added direct test of _parse method to attempt to make Codecov happy.
  • Loading branch information
NGWi committed Dec 4, 2024
commit 96019754b07f48c3ff3058007bc3a1a7637740ae
67 changes: 49 additions & 18 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2779,24 +2779,6 @@ def test_scatter_color_warning(self, kwargs):
plt.scatter([], [], c=[], **kwargs)
plt.scatter([1, 2], [3, 4], c=[4, 5], **kwargs)

@pytest.mark.parametrize('colors',
[
('red', 'blue'),
(['red', 'blue'], ['green', 'yellow']),
([[1, 0, 0], [0, 1, 0]], [[0, 0, 1], [1, 1, 0]])
])
def test_scatter_c_facecolor_warning(self, colors):
warn_match = (
"You passed both c and facecolor/facecolors for the markers. "
"c has precedence over facecolor/facecolors. This behavior may "
"change in the future."
)
fig, ax = plt.subplots()
x = [0, 1] if len(colors[0]) == 2 else [0]
y = x
with pytest.warns(UserWarning, match=warn_match):
ax.scatter(x, y, c=colors[0], facecolors=colors[1])

def test_scatter_unfilled(self):
coll = plt.scatter([0, 1, 2], [1, 3, 2], c=['0.1', '0.3', '0.5'],
marker=mmarkers.MarkerStyle('o', fillstyle='none'),
Expand Down Expand Up @@ -3080,6 +3062,55 @@ def get_next_color():
c, None, kwargs={}, xsize=2, get_next_color_func=get_next_color)


# Warning message tested in the next two tests.
WARN_MSG = (
"You passed both c and facecolor/facecolors for the markers. "
"c has precedence over facecolor/facecolors. This behavior may "
"change in the future."
)
# Test cases shared between direct and integration tests
COLOR_TEST_CASES = [
('red', 'blue'),
(['red', 'blue'], ['green', 'yellow']),
([[1, 0, 0], [0, 1, 0]], [[0, 0, 1], [1, 1, 0]])
]


@pytest.mark.parametrize('c, facecolor', COLOR_TEST_CASES)
def test_parse_c_facecolor_warning_direct(c, facecolor):
"""Test the internal _parse_scatter_color_args method directly."""
def get_next_color():
return 'blue'

# Test with facecolors (plural)
with pytest.warns(UserWarning, match=WARN_MSG):
mpl.axes.Axes._parse_scatter_color_args(
c=c, edgecolors=None, kwargs={'facecolors': facecolor},
xsize=2, get_next_color_func=get_next_color)

# Test with facecolor (singular)
with pytest.warns(UserWarning, match=WARN_MSG):
mpl.axes.Axes._parse_scatter_color_args(
c=c, edgecolors=None, kwargs={'facecolor': facecolor},
xsize=2, get_next_color_func=get_next_color)


@pytest.mark.parametrize('c, facecolor', COLOR_TEST_CASES)
def test_scatter_c_facecolor_warning_integration(c, facecolor):
"""Test the warning through the actual scatter plot creation."""
fig, ax = plt.subplots()
x = [0, 1] if isinstance(c, (list, tuple)) else [0]
y = x

# Test with facecolors (plural)
with pytest.warns(UserWarning, match=WARN_MSG):
ax.scatter(x, y, c=c, facecolors=facecolor)

# Test with facecolor (singular)
with pytest.warns(UserWarning, match=WARN_MSG):
ax.scatter(x, y, c=c, facecolor=facecolor)


def test_as_mpl_axes_api():
# tests the _as_mpl_axes api
class Polar:
Expand Down