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

ENH: Add digits parameter to EngFormatter for significant figures#30827

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
giparraguirre wants to merge4 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromgiparraguirre:enh-engformatter-digits

Conversation

@giparraguirre
Copy link

…ed digits parameter for significant figure formatting, trim_zeros parameter to control trailing zeros, ensured mutual exclusion with places parameter, implemented boundary rollover (e.g., 999.95 → 1.000 k), added comprehensive tests for new functionality, and maintained backward compatibility. Should address#30727

PR summary

PR checklist

Closes#30727

…ed digits parameter for significant figure formatting, trim_zeros parameter to control trailing zeros, ensured mutual exclusion with places parameter, implemented boundary rollover (e.g., 999.95 → 1.000 k), added comprehensive tests for new functionality, and maintained backward compatibility. Should addressmatplotlib#30727
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.

Please add aWhat's new entry

"Cannot specify 'places' and 'digits'"
)

iftrim_zerosnotin ("keep","trim"):
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to not maketrim_zeros a bool?

Copy link
Author

Choose a reason for hiding this comment

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

I initially chose string values to make the intent more explicit in code (e.g.,trim_zeros="trim" reads clearly), but a bool would be simpler. I'm happy to change it to 'trim_zeros=False' to keep trailing zeros (i.e., default) and 'trim_zeros=True' to trim trailing zeros. Would you prefer this bool approach?

"""
sign=1
fmt="g"ifself.placesisNoneelsef".{self.places:d}f"
fmt="g"ifself.placesisNoneandself.digitsisNoneelseNone
Copy link
Member

@timhoffmtimhoffmDec 9, 2025
edited
Loading

Choose a reason for hiding this comment

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

Move to the block "# Determine format string based on digits or places" so that all the logic is in one place.

Copy link
Author

Choose a reason for hiding this comment

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

Sure thing!

@timhoffm
Copy link
Member

Please fix the issues marked by ruff and mypy-stubtest.

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

Reviewers

@timhoffmtimhoffmtimhoffm left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[ENH]: EngFormatter to print as significant figures

2 participants

@giparraguirre@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp