-
Notifications
You must be signed in to change notification settings - Fork 280
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 a bug where 2D plots in spherical geometries would always use code-units in plot axes #3618
Conversation
0ae06f0
to
7ad6ea7
Compare
@@ -2530,7 +2530,7 @@ def __call__(self, plot): | |||
un = self.time_unit.latex_representation() | |||
time_unit = r"$\ \ (" + un + r")$" | |||
except AttributeError as err: | |||
if plot.ds.unit_system._code_flag == "code": | |||
if plot.ds.unit_system._code_flag: |
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.
this isn't strictly necessary here but this looks like a different bug I stumbled upon while working here. The bug is that the _code_flag
attribute is defined as a boolean, so this condition seems impossible to satisfy and probably dates back from an earlier implementation.
yt/visualization/plot_window.py
Outdated
@@ -998,7 +998,7 @@ def _setup_plots(self): | |||
axis_index = self.data_source.axis | |||
|
|||
xc, yc = self._setup_origin() | |||
if self.ds.unit_system._code_flag or self.ds.no_cgs_equiv_length: | |||
if self.ds.unit_system._code_flag: |
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.
I suspect this is a breaking change in other cases:
self.ds.no_cgs_equiv_length
was apparently used as a proxy to detect some cartopy operations, but it happens to collide with how spherical dataset behave. Possibly the real bug is that this flag shouldn't be true for spherical datasets.
7ad6ea7
to
8e0c1ea
Compare
some cartopy tests failed, let's try again step by step |
I think the bug dates back from #2378 |
8e0c1ea
to
1937bcd
Compare
so the current patch is still not satisfactory because it breaks units conversion for 'r-normal' plots where both axes are angular coordinates. It's starting to look like we need a replacement for the single |
1937bcd
to
e8505cc
Compare
I think the current iteration is now stable in all cases I know of 🤞🏻 |
yt/data_objects/static_output.py
Outdated
|
||
self.unit_system = us | ||
self.unit_registry.unit_system = self.unit_system | ||
|
||
@property | ||
def _code_length(self): |
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.
I'm making this a property because self.no_cgs_equiv_length
's value seems to be updated (True
-> False
) at some point during initialisation that I can not decipher
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.
comment still relevant even though GH marks it as "outdated" because I've changed the name of the property
e8505cc
to
4612717
Compare
…use code-units in plot axes
4612717
to
fda512b
Compare
pinging for reviews: |
@neutrinoceros Do you have an example where |
Unfortunately I don't. The only spherical data sets I know of are from the Athena++ and AMRVAC formats, none of which outputs unit metadata (I think ?) so both frontends default to cgs. |
Could you force it by making them non-identical?
…On Fri, Oct 22, 2021 at 8:55 AM Clément Robert ***@***.***> wrote:
Unfortunately I don't. The only spherical data sets I know of are from the
Athena++ and AMRVAC formats, none of which outputs unit metadata (I think
?) so both frontends default to cgs.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3618 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAVXO7TWPC5KDNMRPGGYEDUIFUMHANCNFSM5GNVPKCA>
.
|
I don't know what you mean. What's identical to what ? |
I'd like to see the difference before and after where it's also changing the values, not just the displayed units. If you can force this to happen by setting the unit system to be one where |
I could just provide units to the AMRVAC frontend at load time, would that work ? |
Thanks -- this satisfies me! |
great, now let's bump this bad boy :) |
@matthewturk I'm not sure you meant to do that: it seems like you set up auto merge but didn't approve |
@neutrinoceros yeah, I like to withhold my approval |
@meeseeksdev backport to yt-4.0.x |
…al geometries would always use code-units in plot axes
…8-on-yt-4.0.x Backport PR #3618 on branch yt-4.0.x (BUG: fix a bug where 2D plots in spherical geometries would always use code-units in plot axes)
PR Summary
fix #2913
gives
Marking this as draft because I ended up removing initialization code that was problematic in this specific case but I'd expect the tests to reveal why it was necessary.
In any cases, the code in question is duplicated in a lot of plot classes, so I'd need to apply consistent changes everywhere even if it turns out that it doesn't break anything.