| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
We use the convention that underscore attributes are private. So no one should be accessing that attribute, so I don’t think you should add it until we provide a public interface. |
Sorry, something went wrong.
|
following in the footsteps of ScalarFormatter, added a public interface (i.e. the property usemathtext). |
Sorry, something went wrong.
|
This comment is written with respect to the first commit here. This would at least allow to work around the issue by plt.rcParams["text.usetex"] = False plt.gca().xaxis.set_major_formatter(EngFormatter()) plt.rcParams["text.usetex"] = True So even if the argument is that "private" should not be used by anyone, this is still a useful change. Also, I'm not actually convinced that the general approach of #12847 is useful for the EngFormatter "${mant:{fmt}}${sep}{prefix}"
This will now lead to the numbers being rendered in a different font than the unit prefixes. I can hardly imagine that this is what people want by default, and it's especially annoying if there isn't even any workaround for it. |
Sorry, something went wrong.
|
I agree with both the views presented here. I think I have stepped into something which is far beyond my reach... I will wait for all the experienced core developers to weigh-in before making any changes. I will be happy to implement the suggestions on how to move forward. Please feel free to take this over if it would be easier that way. |
Sorry, something went wrong.
|
This comment is written with respect to the second commit here. This goes in the right direction IMO. But... the useMathText argument is now interpreted inconsistently between ScalarFormatter and EngFormatter. The problem is also that the notion "MathText" explicitely means the unicode rendering used outside of tex. Maybe some more bikeshedding is needed here? |
Sorry, something went wrong.
|
Would the following approach work? (1) not treating usetex and usemathtext as being equivalent inside ScalarFormatter (as suggested in #12847 (comment)) |
Sorry, something went wrong.
|
Possibly... I'm not having the complete overview of ScalarFormatter currently - but it's a total mess. So once you start changing that, the rabbit hole will soon become even deeper. In fact, ._usetex and useMathText are currently mutually exclusive in ScalarFormatter. As of now I think I would be happy with either of (a) leaving EngFormatter untouched, i.e. revert #12847, (b) Get the first commit here in, in case people think that the different fonts for numbers and unit prefix are acceptable. |
Sorry, something went wrong.
|
out of those two options I think I would prefer to go with (b) since that allows for the most flexible behavior (for now). I will wait for comments from other core/experienced developers before proceeding. Ideally I would like to fix ScalarFormatter and "go down the rabbit hole" but I do not have sufficient expertise to do that. |
Sorry, something went wrong.
|
should I proceed by reverting the change in #12847? I would appreciate some advice from core/experienced developers. Thanks! |
Sorry, something went wrong.
|
(sorry started working on this yesterday, and got distracted) Well, this is a fun pickle of inconsistent APIs. To check my understanding:
Did I get the facts/history right? |
Sorry, something went wrong.
|
Yes! |
Sorry, something went wrong.
|
May I just add that allowing for the ._usetex attribute is not only about allowing users to bypass the public API, but would also simplify any future work on those formatters by using the same internal structure. |
Sorry, something went wrong.
|
I think(??) the end target would be to have
? |
Sorry, something went wrong.
|
Seems correct; not to forget to have those arguments settable in the init. |
Sorry, something went wrong.
|
Thanks all for the feedback. I will implement the suggestions. |
Sorry, something went wrong.
|
I have made the changes as suggested. Please note that I have assumed an equivalence between usetex and useMathText when inserting $ signs around numbers (to be consistent with the ScalarFormatter and based on the comment here). A positive implication of this decision: |
Sorry, something went wrong.
| } | ||
|
|
||
| def __init__(self, unit="", places=None, sep=" "): | ||
| def __init__(self, unit="", places=None, sep=" ", usetex=None, |
There was a problem hiding this comment.
Please make the new arguments keyword-only (sep=" ", *, usetex=None, ...).
Sorry, something went wrong.
| * ``sep="\\N{THIN SPACE}"`` (``U+2009``); | ||
| * ``sep="\\N{NARROW NO-BREAK SPACE}"`` (``U+202F``); | ||
| * ``sep="\\N{NO-BREAK SPACE}"`` (``U+00A0``). | ||
| ` |
There was a problem hiding this comment.
the extra, spurious backtick here makes the doc build unhappy
Sorry, something went wrong.
There was a problem hiding this comment.
modulo CI.
Sorry, something went wrong.
|
I am glad this came to a conclusion! Does this same public API also exist on ScalerFormatter? Could you please add a whats_new entry? |
Sorry, something went wrong.
|
Added a what's new entry. I don't think there is a public API for controling the usetex behavior in ScalarFormatter. I can open a new PR to add that if this is ok with the core developers. Thank you everyone involved in this discussion for guiding me through this! |
Sorry, something went wrong.
|
Thanks! |
Sorry, something went wrong.
…856-on-v3.1.x Backport PR #12856 on branch v3.1.x (added property usemathtext to EngFormatter)
|
@pharshalp Did you end up adding a public API for usetex in ScalarFormatter? |
Sorry, something went wrong.
|
If not, I might be able to take a crack at it over winter break. |
Sorry, something went wrong.
|
@mattdutson I didn't end up adding a public API for usetex in ScalarFormatter (since I didn't hear from any of the the core developers -- quoting my response relevant to this).
Please feel free to take a crack at it. Thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Based on #12847 (comment)
Adding ._usetex as an attribute for EngFormatter so as to allow the user to set it to False (resulting in numbers being displayed using text font instead of math font). This will be consistent with what ScalarFormatter allows.
PR Checklist