-
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 heuristic to switch from log scale to symlog scale #3793
BUG: fix heuristic to switch from log scale to symlog scale #3793
Conversation
Not sure what's happening in the two tests that failed. If I can't figure it out quickly I'll just remove this from the milestone |
Found that the failing tests were a consequence of #2517, and I discovered that the hack introduced back then isn't necessary after MPL 3.2 so I'm making it conditional. Now I'm expecting everything to stay green |
085fb9f
to
d7f927b
Compare
This is now in the intented state. The only failing image tests are the ones I intend to update. I'll wait for an approval to bump them. |
yt/visualization/base_plot_types.py
Outdated
data[~np.isfinite(data)] = np.nan | ||
|
||
zmin = float(self.zmin if self.zmin is not None else np.nanmin(data)) | ||
zmax = float(self.zmax if self.zmax is not None else np.nanmax(data)) |
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.
the diff here is that we convert to float
even in the second case np.nanmin...
specifically to strip out units, so we can easily increment with +1
later on.
caa8ae0
to
df34049
Compare
@@ -298,7 +307,7 @@ def _init_image(self, data, cbnorm, cblinthresh, cmap, extent, aspect): | |||
10 | |||
** np.arange( | |||
np.rint(np.log10(cblinthresh)), | |||
np.ceil(np.log10(zmax)), | |||
np.ceil(np.log10(1.1 * zmax)), |
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.
The idea here is to intentionally overshoot zmax with the (excluded) upper boundary so that zmax can be used as a major tick location if it is itself an exact power of 10.
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.
Makes sense.
) | ||
) | ||
) | ||
if yticks[-1] > zmax: | ||
yticks.pop() |
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.
necessary cleanup with matplotlib 3.5 where having a ticks that's above the actual maximal value creates a white region at the top end of the colorbar (see #3554)
df34049
to
25e4ff3
Compare
… and all other values are equals)
25e4ff3
to
822b319
Compare
@@ -334,10 +343,12 @@ def _init_image(self, data, cbnorm, cblinthresh, cmap, extent, aspect): | |||
10 |
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.
Just so I understand, would it be possible to do this with np.logspace
? I do not think we should in this PR, for continuity sake, however.
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.
yes it should be possible to refactor this with np.logspace. I also agree that it's preferable to keep diffs minimal for a bugfix PR
Seems like the Jenkins job got killed because of network issues ?
Let's try this again: @yt-fido test this please |
…ale to symlog scale
…3-on-yt-4.0.x Backport PR #3793 on branch yt-4.0.x (BUG: fix heuristic to switch from log scale to symlog scale)
PR Summary
Fix #3791
Here's a simpler demo
on main
this branch
While the original issue was only about 2D plots, I'm also fixing a similar bug in line plots that I found on the way