Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Tweak argument checking in tripcolor().#22883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
oscargus merged 1 commit intomatplotlib:mainfromanntzer:tca
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
3 changes: 3 additions & 0 deletionsdoc/api/next_api_changes/deprecations/22883-AL.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
Passing too many positional arguments to ``tripcolor``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... is now deprecated (extra arguments were previously silently ignored).
8 changes: 4 additions & 4 deletionslib/matplotlib/tests/test_triangulation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -242,7 +242,7 @@ def test_tripcolor_color():
x = [-1, 0, 1, 0]
y = [0, -1, 0, 1]
fig, ax = plt.subplots()
with pytest.raises(ValueError, match="Missing color parameter"):
with pytest.raises(TypeError, match=r"tripcolor\(\) missing 1 required"):
ax.tripcolor(x, y)
with pytest.raises(ValueError, match="The length of C must match either"):
ax.tripcolor(x, y, [1, 2, 3])
Expand All@@ -255,8 +255,8 @@ def test_tripcolor_color():
with pytest.raises(ValueError,
match="'gouraud' .* at the points.* not at the faces"):
ax.tripcolor(x, y, [1, 2], shading='gouraud') # faces
with pytest.raises(ValueError,
match=r"pass C positionally or facecolors viakeyword"):
with pytest.raises(TypeError,
match="positional.*'C'.*keyword-only.*'facecolors'"):
ax.tripcolor(x, y, C=[1, 2, 3, 4])

# smoke test for valid color specifications (via C or facecolors)
Expand All@@ -282,7 +282,7 @@ def test_tripcolor_warnings():
C = [0.4, 0.5]
fig, ax = plt.subplots()
# additional parameters
with pytest.warns(UserWarning, match="Additional positionalparameters"):
with pytest.warns(DeprecationWarning, match="Additional positionalparam"):
ax.tripcolor(x, y, C, 'unused_positional')
# facecolors takes precednced over C
with pytest.warns(UserWarning, match="Positional parameter C .*no effect"):
Expand Down
12 changes: 7 additions & 5 deletionslib/matplotlib/tri/tripcolor.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -79,12 +79,14 @@ def tripcolor(ax, *args, alpha=1.0, norm=None, cmap=None, vmin=None,
else:
# Color from positional parameter C
if not args:
raiseValueError(
"Missing color parameter. Please pass C positionally or "
"facecolors via keyword")
raiseTypeError(
"tripcolor() missing 1 required positional argument: 'C'; or "
"1 required keyword-only argument: 'facecolors'")
elif len(args) > 1:
_api.warn_external(
"Additional positional parameters {args[1:]!r} are ignored")
_api.warn_deprecated(
"3.6", message=f"Additional positional parameters "
f"{args[1:]!r} are ignored; support for them is deprecated "
f"since %(since)s and will be removed %(removal)s")
C = np.asarray(args[0])
if len(C) == len(tri.x):
# having this before the len(tri.triangles) comparison gives
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp