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

Fix argument types in examples and tests#28764

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

Open
oscargus wants to merge3 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromoscargus:exampletesttyping

Conversation

oscargus
Copy link
Member

PR summary

Not sure if this is wanted, so I have only done this for a few methods as a discussion opener.

Background: I got a typing error in my editor when looking at an example.

It seems to me that if we type something as a tuple (and not as a tuple or a list), it makes sense to provide a tuple in all examples (and tests as I did some search-and-replace). But then I do not know the background to typing it as a tuple only.

PR checklist

@@ -509,7 +509,7 @@ def test_invalid_figure_add_axes():
fig.add_axes((.1, .1, .5, np.nan))

with pytest.raises(TypeError, match="multiple values for argument 'rect'"):
fig.add_axes([0, 0, 1, 1], rect=[0, 0, 1, 1])
fig.add_axes((0, 0, 1, 1), rect=[0, 0, 1, 1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

rect should also be a tuple, though I'm surprised you don't get a type error for invalid parameters here (though that's on purpose and should be ignored.)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is because I identify one type of error and then do regex-based search and replace for that on all files.

@@ -168,7 +168,7 @@ def test_rotation():
mpl.rcParams['text.usetex'] = True

fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
ax = fig.add_axes((0, 0, 1, 1))
ax.set(xlim=[-0.5, 5], xticks=[], ylim=[-0.5, 3], yticks=[], frame_on=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ax.set probably won't type check, but for consistency,xlim andylim here should also be tuples.

oscargus reacted with thumbs up emoji
Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I approve, subject to addressing@QuLogic's comments.

@oscargus
Copy link
MemberAuthor

Will sort the comments out and over time find and fix more if this type when bored.

@rcomer
Copy link
Member

I take the liberty of putting this one in draft since it seems to be contingent on@oscargus' boredom levels.

@rcomerrcomer marked this pull request as draftSeptember 7, 2024 11:58
@ksunden
Copy link
Member

I am also in favor of these changes, of course listswork, but don't allow you to specify length, which is why the type hints are Tuple... since the number of elements is super important for these cases

@QuLogic
Copy link
Member

I took the liberty to rebase and fix the commented issues.

@QuLogicQuLogic marked this pull request as ready for reviewApril 16, 2025 23:48
@QuLogicQuLogic added this to thev3.11.0 milestoneApr 16, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.11.0
Development

Successfully merging this pull request may close these issues.

5 participants
@oscargus@rcomer@ksunden@QuLogic@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp