-
Notifications
You must be signed in to change notification settings - Fork 276
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
BUG: fix default math font in yt plots against matplotlib >= 3.4 #3520
Conversation
test cases to add: import matplotlib as mpl
from yt.testing import fake_amr_ds
from yt.visualization.api import SlicePlot
ds = fake_amr_ds(fields=[("gas", "density")], units=["g/cm**-3"])
sp = SlicePlot(ds, "z", ("gas", "density")) Expected result # this case requires matplotlib 3.4 or greater
sp = ySlicePlot(ds, "z", ("gas", "density"))
sp.set_font({"math_fontfamily": "dejavusans"})
# same result is expected here
with mpl.rc_context({"mathtext.fontset": "dejavusans"}):
sp = yt.SlicePlot(ds, "z", ("gas", "density")) Note that this last case currently only works with matplotlib 3.4 + yt's main branch. It doesn't work with matplotlib 3.3 or earlier or with the current state of this PR, so I'm not 100% sure we need to support it, but it would be nice if we could avoid closing a door that matplotlib just opened for us. |
So the image tests revealed two kinds of failures:
For illustration: main branchthis patch |
36f6de6
to
2723612
Compare
049d76a
to
f7f4da0
Compare
I'm now down to 9 errors (previously 41) for GH answer tests. All remaining errors are the kind I described in the previous comment, so I believe it' is mature enough to warrant bumping the answer store. |
Here's the PR to the answer store yt-project/answer-store#23 |
69cbbdf
to
e1c0e98
Compare
Alright I believe that all failures, GH and Jenkins alike, are the kind I propose to adopt. Opening this proposing to approvals before I can bump references. |
e1c0e98
to
ea72d90
Compare
Note to reviewers: please consider reviewing this soon, the reports are not going to stay available for more than a couple days, after which we’d need to manually retrigger tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@yt-fido test this please |
I got "no old answer" twice on Jenkins after bumping the answer number. Either I don't understand how it's supposed to be done anymore or something isn't working. @Xarthisius, can you have a look ? |
@yt-fido test this please |
@@ -1336,77 +1337,6 @@ def save(self, name=None, suffix=".png", mpl_kwargs=None): | |||
self.plots[f].save(name, mpl_kwargs) | |||
return names | |||
|
|||
@invalidate_plot | |||
def set_font(self, font_dict=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, so can we no longer manually set the font in our plots? I don't think i ever have, but it might be something people have used in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it will still be possible, thanks to inheritance. Because I'm making ProfilePlot
a subclass of PlotContainer
, we don't need to have this method here, which was duplicated code from PlotContainer
anyway :-)
OK, I'm a bit confused based on the description of this PR and the comments what this PR actually does (e.g., two "expected results" plots) Presumably this continues to use the old math font instead of the new MPL fonts for our plots. can you confirm? |
Yes, this PR forces matplotlib to use the "cm" math font family, which was its default before matplotlib 3.4.0 A side effect of doing so, using matplotlib 3.4's api, is that negative exponents in tick labels are also forced to use this font, something we apparently were not doing in yt already, but arguably should have. This is the reason that I have a "bump answer store" PR attached :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, looks good to me. Thanks!
Great, it's now down to a single error, same kind as the ones already bumped. Can I bump that one too ? |
Sure, but be careful about numbering. |
alright, going straight to 009 then, thanks for the heads ! |
1d7340b
to
3662538
Compare
Something went wrong but at least it doesn't look like I corrupted the database. Let's try bumping one last time. |
🎉 this is finally ready for merging |
@meeseeksdev backport to yt-4.0.x |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove If these instruction are inaccurate, feel free to suggest an improvement. |
@meeseeksdev backport to yt-4.0.x |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove If these instruction are inaccurate, feel free to suggest an improvement. |
@meeseeksdev backport to yt-4.0.x |
…gainst matplotlib >= 3.4
…0-on-yt-4.0.x Backport PR #3520 on branch yt-4.0.x (BUG: fix default math font in yt plots against matplotlib >= 3.4)
PR Summary
Endgoal: resolve #3514
Basic testing seems to indicate this works, however I need to further check a few things. Is it still possible to change the math font using the matplotlib API ?
Submitting as a draft for now so I can at least check if image comparison tests pass as is.
Note: this reverts a temporary patch in
tests/matplotlibrc
from #3153.PR Checklist