8000 Tick formatter does not support grouping with locale by z0rgy · Pull Request #8987 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Tick formatter does not support grouping with locale #8987

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 24, 2020

Conversation

z0rgy
Copy link
Contributor
@z0rgy z0rgy commented Aug 4, 2017

When formatting and setting useLocale to True, the numbers greater than 1000 are not grouped as specified by the locale. 1000 should be 1,000 in certain locales. By setting the last argument to locale.format_string the locale dependent grouping is honored.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell
Copy link
Member

Thanks, 👍 this seems reasonable.

This needs a test (does not need an image test, just create a formatter with the right settings and check that the formater returns the expected string) and as it is a subtle API change (the same user code will now produce a different plot) it also needs a note in https://github.com/matplotlib/matplotlib/tree/master/doc/api/api_changes (see the README).

@tacaswell tacaswell added this to the 2.2 (next next feature release) milestone Aug 4, 2017
@QuLogic
Copy link
Member
QuLogic commented Sep 9, 2020

As it's been 3 years, I went ahead and rebased this to fix the conflicts.

I'm not sure how we can test this, as it appears locale-specific, and when I run locale.format_string('%d', 123456789, grouping=True), I see no difference.

@QuLogic
Copy link
Member
QuLogic commented Sep 9, 2020

Oops, I needed to set the locale, which is done in tests, so this should be possible.

@QuLogic
Copy link
Member
QuLogic commented Sep 12, 2020

Locally, I found out that this didn't work, as setting exclude_lines overrides the defaults, so I've added the default exclusion rule to our config. I don't know if that also applie 8000 s to codecov, but there's a bit of CI backlog, so I replaced this anyway.

@QuLogic
Copy link
Member
QuLogic commented Sep 16, 2020

With the previous nbconvert-failing tests restarted, this passes codecov now.

z0rgy and others added 3 commits September 23, 2020 19:19
When formatting and setting useLocale to True, the numbers greater than
1000 are not grouped as specified by the locale. 1000 should be 1,000 in
certain locales. By setting the last argument to locale.format_string
the locale dependent grouping is honored.
Once `exclude_lines` is set, the default exclusion is overridden, so we
can't ignore coverage on specific lines. This adds the default rule back
so that can be done again.
@QuLogic
Copy link
Member
QuLogic commented Sep 23, 2020

Rebased to fix conflicts.

tmp_form.create_dummy_axis()
tmp_form.set_bounds(0, 10)
tmp_form.set_locs([1, 2, 3])
assert sep in tmp_form(1e9)
Copy link
Member

Choose a reason for hiding this comment

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

This is not the easiest test to follow, and seems to use a default locale? If the locale doesn't have the separator does this test anything?

Copy link
Member

Choose a reason for hiding this comment

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

As it accesses the POSIX locale database, I wasn't sure if you would need to have the locale installed to have it work, so didn't want to hardcode anything specific. But note that the test framework does set the locale to en_US, so it's not an environment-specific default.

Copy link
Member

Choose a reason for hiding this comment

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

I you feel it tests something real then I'm fine with it, but it just seems a little self-referential.

Copy link
Member

Choose a reason for hiding this comment

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

True, a little self-referential, but it would catch if say, in the recent refactor that caused the conflicts, the locale setting was lost somewhere.

@@ -7,6 +7,7 @@ omit = matplotlib/_version.py

[report]
exclude_lines =
pragma: no cover
Copy link
Member
8000

Choose a reason for hiding this comment

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

is this intentional?

Copy link
Member
@QuLogic QuLogic Sep 24, 2020

Choose a reason for hiding this comment

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

Copy link
Member
@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Anyone can merge when Green

@jklymak jklymak merged commit 2e61658 into matplotlib:master Sep 24, 2020
@jklymak
Copy link
Member
jklymak commented Sep 24, 2020

Thanks @z0rgy and @QuLogic ! (ahem we are sorry it was so slow ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0