-
Notifications
You must be signed in to change notification settings - Fork 279
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
ENH: make plot callbacks with 'factor' argument accept 2-tuples to distinguish x/y resolutions #3686
Conversation
ce48909
to
a5d2e8f
Compare
aca83e7
to
807aede
Compare
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 think we're mostly OK here but I want to verify from @neutrinoceros that it's in the right x,y order, and ask why it has to be an integer.
if ( | ||
is_sequence(factor) | ||
and len(factor) == 2 | ||
and all(isinstance(_, Integral) for _ in factor) |
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.
Why does it have to be an integer?
nx = plot.image._A.shape[1] // self.factor[0] | ||
ny = plot.image._A.shape[0] // self.factor[1] |
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.
@matthewturk this is why I'm checking for integers. While floats are mathematically compatible here, ultimately we're counting pixels, so I think that passing a float signals either a misconception on the user side or a bug
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 not sure I agree with that. We're specifically talking about the factor for changing the resolution; there is a substantial use case possible (even if not necessarily typically desirable) for values betweeen 0 and 1.
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.
would that work, really ? Running this on the main branch
import yt
ds = yt.load_sample("IsolatedGalaxy")
plot = yt.SlicePlot(ds, "z", "density", width=(0.04, 0.01))
plot.annotate_quiver(
"velocity_x",
"velocity_y",
factor=0.5,
normalize=True,
plot_args={"color": "white"},
)
plot.save("/tmp/factor.png")
I'm getting
YTPlotCallbackError: annotate_quiver callback failed
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.
Alright! Let's consider that addressed then.
Sorry I don't understand what I need to justify/explain here |
@neutrinoceros I mean, just say you checked that the order of x and y factors versus the image make sense, since we often do some strange transposition etc. |
It works in cases that I've tried, but I'm not sure how to test is extensively. |
Alright guys thank you for reviewing this early but I need to solve a conflict so I expect your approvals to go away after that. I'll remove the draft status when everything is green again :) |
72779ff
807aede
to
72779ff
Compare
well actually we could also use auto-merge so no-one has to wait... removing the draft status now |
@yt-fido test this please |
…tinguish x/y resolutions
ce5d9c1
to
172d892
Compare
I pushed again to resolve a conflict. Auto merge is still enabled but I lost aprovals here. Could anyone approve (again) ? |
PR Summary
Fix #3685