| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
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. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
Sorry, something went wrong.
EngFormatter subclasses ScalarFormatter, but the inherited locale machinery is reachable only in the offset path. The normal engineering formatting path both forces the flag off at construction, by passing useLocale=False to super().__init__, and bypasses locale-aware formatting, by interpolating the mantissa directly. The rcParam therefore had no effect, and set_useLocale flipped a flag that format_data never consulted. Pass useLocale through to ScalarFormatter and add the matching keyword argument, so that the rcParam applies and an explicit value overrides it. When locale formatting is on, the mantissa goes through locale.format_string, and the separators it introduces are escaped for mathtext the same way ScalarFormatter already escapes them.
|
CI is green now apart from codecov/patch. The locale test runs in a subprocess so it doesn't leak locale state, which means coverage doesn't see those lines. @QuLogic, since you reviewed #28495, would you mind taking a look when you have a chance? Thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
EngFormatter ignores axes.formatter.use_locale when formatting the mantissa.
With de_DE.UTF-8:
There are two causes: EngFormatter.__init__ passes useLocale=False to ScalarFormatter, and format_data formats the mantissa directly instead of using locale-aware formatting. Because of the latter, even set_useLocale(True) does not affect the normal format_data path. Locale-aware formatting is currently only used for the offset path.
This change passes useLocale through to ScalarFormatter, adds it as an EngFormatter keyword argument, and applies locale formatting to the mantissa. For MathText, locale separators are escaped to avoid punctuation spacing.
Tests cover the rcParam, explicit useLocale values, the inherited setter, and MathText.
I consider this a bug fix: EngFormatter already inherits the locale API from ScalarFormatter, but does not honor it consistently. #13477 fixed the same kind of issue for axes.unicode_minus.
The new constructor keyword is the only public API addition here and can be split out if preferred.
Related: #25006 concerns the same rcParam, but a different issue involving locale initialization/reset behavior.
PR quality check