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

[MNT]: Cleanup ticklabel_format (style=)#26801

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
timhoffm merged 8 commits intomatplotlib:mainfrompedrompecanha:cleanup-ticklabel
Sep 20, 2023

Conversation

@pedrompecanha
Copy link
Contributor

@pedrompecanhapedrompecanha commentedSep 17, 2023
edited
Loading

PR summary

Fixes#25974.
-->

PR checklist

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

Copy link
Member

@rcomerrcomer left a comment

Choose a reason for hiding this comment

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

Thank you for your work on this@pedrompecanha! Just a couple of comments on the implementation...

This line will break ifstyle isNone, so perhaps should be moved into theelse of your new if loop below.

style=style.lower()

is_sci_style=_api.check_getitem(STYLES,style=style)
STYLES= {'sci':True,'scientific':True,'plain':False}
ifstyleisNone:
is_sci_style=False
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
is_sci_style=False
is_sci_style=None

None here should mean that the style is not changed from what it previously was. Settingis_sci_style also toNone achieves that.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I'm changing it so that everything is in the dictionary. I believe it solves it more effectively. About setting it to None or False, I thought this variable should be either True or False but, after reading the logic after it, I've seen it can be None, indeed.

rcomer reacted with thumbs up emoji
@rcomer
Copy link
Member

rcomer commentedSep 18, 2023
edited
Loading

The typing stub file will also need updating to match the new signature

defticklabel_format(
self,
*,
axis:Literal["both","x","y"]= ...,
style:Literal["","sci","scientific","plain"]= ...,
scilimits:tuple[int,int]|None= ...,
useOffset:bool|float|None= ...,
useLocale:bool|None= ...,
useMathText:bool|None= ...
)->None: ...

)fromerr
STYLES= {'sci':True,'scientific':True,'plain':False,'':None}
is_sci_style=_api.check_getitem(STYLES,style=style)
STYLES= {'sci':True,'scientific':True,'plain':False}
Copy link
Member

@oscargusoscargusSep 18, 2023
edited
Loading

Choose a reason for hiding this comment

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

An option here (and also in case someone has setstyle='' explicitly), is to do:

Suggested change
STYLES= {'sci':True,'scientific':True,'plain':False}
STYLES= {'sci':True,'scientific':True,'plain':False,'':None,None:None}
is_sci_style=_api.check_getitem(STYLES,style=style)

Copy link
Member

Choose a reason for hiding this comment

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

in case someone has setstyle='' explicitly

That's a good point. I suggest to also add a comment that'' is included for backwards-compatibility, as I do not think it would be obvious to future readers of the code.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I added the comment and added the empty string into the dictionary. Actually, I was playing tennis and thought about how my changes weren't backwards compatible. Nice to see we are in the same page :)

rcomer reacted with heart emoji
Whether to use scientific notation.
The formatter default is to use scientific notation.
Sci is equivalent to scientific.
The '' option is included solely for backwards-compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

Apologies, I think I was unclear. I meant to add a code comment where the dictionary is defined, so that future developers know that it’s there for a reason. I don’t think it’s needed in the docstring.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done in the latest commit!

Copy link
Member

@rcomerrcomer left a comment

Choose a reason for hiding this comment

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

The last test failure comes withinstructions (which I admit are new to me!)

)fromerr
STYLES= {'sci':True,'scientific':True,'plain':False,'':None}
STYLES= {'sci':True,'scientific':True,'plain':False,'':None,None:None}
# 'sci' is equivalent to 'scientific'.
Copy link
Member

Choose a reason for hiding this comment

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

I think the fact that 'sci' and ‘scientific' are equivalentshould be in the docstring, as this is useful information for the user.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Just put them back there! As for the pyplot issue, I attempted following the instructions and it told me, in my system, that the file got reformatted. Let's see how it goes!

Copy link
Member

Choose a reason for hiding this comment

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

It seems the pyplot change has not appeared here on GitHub...

Copy link
ContributorAuthor

@pedrompecanhapedrompecanhaSep 19, 2023
edited
Loading

Choose a reason for hiding this comment

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

Yeah! I tried running the command again, but the file remained unchanged. I tried to change the file by hand, although this is not encouraged, and the commit went through on my fork, but it won't open here on Github. Just goes straight to a 404 page. Weird.

Here is the final change I made:pedrompecanha@3cf0234

Copy link
ContributorAuthor

@pedrompecanhapedrompecanhaSep 19, 2023
edited
Loading

Choose a reason for hiding this comment

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

I believe it has gone through now. Must have been a GitHub instability. The tests seem to be running well, although I'm kind of scared of having to change this file by hand. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Your manual change matches what I get by running the script, so I think it's OK.

pedrompecanha reacted with thumbs up emoji
Copy link
Member

@rcomerrcomer left a comment

Choose a reason for hiding this comment

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

Thanks@pedrompecanha, I think this is in good shape now. I just have a tiny suggestion on the docstring.

…ers that default to None.Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
@pedrompecanha
Copy link
ContributorAuthor

@rcomer,@timhoffm and@oscargus, thank you for the support and patience during this process! I'd like to ask that, if you find any similar cleanup or refactoring tasks, if you could please tag me, as I'll be really active in the next 1-2 months in here. Of course, if that is allowed by the rules of the project. I'll try my best to solve the issues. Again, thank you!

@timhoffmtimhoffm merged commit2cbdff8 intomatplotlib:mainSep 20, 2023
@timhoffm
Copy link
Member

Thanks@pedrompecanha and congratulations on your first contribution to Matplotlib! We hope to see you back.

pedrompecanha reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@oscargusoscargusoscargus left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@timhoffmtimhoffmtimhoffm approved these changes

@rcomerrcomerrcomer approved these changes

Assignees

No one assigned

Projects

Milestone

v3.9.0

Development

Successfully merging this pull request may close these issues.

[MNT]: Cleanup ticklabel_format(..., style=)

4 participants

@pedrompecanha@rcomer@timhoffm@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp