Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix unintended space after comma as a decimal separator #25226

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 6 commits into from
Mar 28, 2023

Conversation

devRD
Copy link
Contributor

@devRD devRD commented Feb 16, 2023

PR Summary

Fixes #23626
Closes #24079
Replace unintended space in locale.format_string function

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

@devRD
Copy link
Contributor Author

devRD commented Feb 16, 2023

This PR is derived from abandoned PR #24079 combined with comments on that draft.

@devRD devRD marked this pull request as ready for review February 17, 2023 06:42
@rcomer
Copy link
Member

rcomer commented Feb 18, 2023

Thanks @devRD, if you edit your original message and change "Fixes issue: #23626” to “Fixes #23626”, then the issue will be linked to this pull request so it automatically closes when this is merged. You could also add “Closes #24079”, so the old PR will automatically close too.

@devRD
Copy link
Contributor Author

devRD commented Feb 19, 2023

@rcomer Thanks for the suggestion! I have updated the PR.

@devRD
Copy link
Contributor Author

devRD commented Feb 21, 2023

Thanks for the review! I have committed suggested changes.

@@ -1449,6 +1449,22 @@ def test_latex(self, is_latex, usetex, expected):
assert fmt.format_pct(50, 100) == expected


@pytest.mark.xfail(locale != "fy_DE.UTF-8",
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this condition; locale is the imported module and can never equal a string.

@devRD
Copy link
Contributor Author

devRD commented Feb 22, 2023

Hi @QuLogic , I updated the test.

@jklymak jklymak requested a review from QuLogic February 24, 2023 15:44
@@ -1449,6 +1449,23 @@ def test_latex(self, is_latex, usetex, expected):
assert fmt.format_pct(50, 100) == expected


@pytest.mark.xfail
Copy link
Member

Choose a reason for hiding this comment

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

I'm skeptical of adding an xfail test for this, it will likely go unnoticed if future changes affect this behavior.

Unfortunately, locale is very platform/install dependent behavior that makes this harder to work around.

My primary dev system, for instance (and seemingly our CI), does not have a fy_DE.UTF-8.
I do have de_DE.UTF-8, which I think has the same behavior regarding using commas as the decimal separator.

Even if we resort to xfail if the locale raises, I'd like to see something that at least passes on CI to prevent future regressions as best we can.

This could look something like:

try:
    ...
except locale.Error:
    pytest.skip("Locale ... not supported on this machine")
finally:
    locale.setlocale(locale.LC_ALL, currentLocale)

instead of using the pytest.mark.xfail decorator.

(And then looking at the CI output to make sure that at least some of our CI (preferably all, but may not be easy) does not skip the test.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially wanted to add a pytest.warn but that is being treated as a failure. I can see that pytest.skip is also used in test_use_locale. I'll update it according to your suggestion. Thanks for the review! @ksunden

@QuLogic
Copy link
Member

QuLogic commented Feb 27, 2023

If I've read all the CI logs correctly, it looks like most don't support that locale, but Windows on Azure is at least testing it?

@ksunden
Copy link
Member

ksunden commented Feb 28, 2023

I think so, though I do wonder if something like de_DE.UTF-8 would have better coverage by default, while testing the same mechanisms

@devRD
Copy link
Contributor Author

devRD commented Mar 1, 2023

Should I update the locale to de_DE.UTF-8 to check the CI logs for coverage?

@ksunden
Copy link
Member

ksunden commented Mar 1, 2023

I would prefer it, especially if it does have better coverage.

Getting better coverage without having to deal with figuring out how to install locales on CI would be better for ensuring it doesn't break. One is significantly better than None, but if we can get the majority and especially more than one platform represented, that is even better.

@QuLogic
Copy link
Member

QuLogic commented Mar 2, 2023

Unfortunately, it looks like we've only gained macOS on Azure from that locale.

Based on actions/runner-images#762 (comment), it looks like we could perhaps add a locale on Linux with sudo localegen de_DE.UTF-8 in the workflow setup. If we do so, we should perhaps remove the skip on CI by checking for the GITHUB_ACTION environment variable.

@devRD
Copy link
Contributor Author

devRD commented Mar 6, 2023

How should I update the changes?

@QuLogic
Copy link
Member

QuLogic commented Mar 8, 2023

Probably just leave it as is for now, but you'll need to rebase to fix the failing tests.

@QuLogic
Copy link
Member

QuLogic commented Mar 15, 2023

Is it possible for you to rebase instead of merging? https://matplotlib.org/devdocs/devel/development_workflow.html#rebasing-on-upstream-main

@devRD
Copy link
Contributor Author

devRD commented Mar 16, 2023

Hi, @QuLogic Thanks for the ref. I rebased to the current main.

@ksunden
Copy link
Member

ksunden commented Mar 28, 2023

Going to merge as is for now, it is at least testing on 2 platforms, but a follow-up that enables reliable testing on more CI (e.g. all the ghactions runs) would be welcome.

If that is explicitly enabled, I think adding the exception to the skip for ghactions at least would be warranted, to guarantee we continue to actually test and see failures in CI.

@ksunden ksunden merged commit 31e5682 into matplotlib:main Mar 28, 2023
@QuLogic QuLogic added this to the v3.8.0 milestone Mar 28, 2023
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.

[Bug]: unintended space between comma and digit when using useMathText = True together with comma as decimal separator
5 participants