-
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: ProjectionPlot as a factory function #3450
ENH: ProjectionPlot as a factory function #3450
Conversation
6fbdb5c
to
50803ec
Compare
A potentially controversial implementation detail is how I approached consistency in the existing API, trying to improve it without breaking backwards compatibility. I'm introducing
In summary here's the change I have now:
Short term, I don't think there is any need to deprecate camel-cased Long term, maybe we'll want to define I'll leave this open for discussion and reserve the sweeping change for a follow up PR if it is deemed worth by other maintainers. |
cfaaed2
to
7bd9fc2
Compare
I'm opening this for review. I'd like to keep documentation out of this PR so as to make it as easy to review as possible. Any feedback is appreciated. |
pinging @matthewturk @chummels and @brittonsmith for reviews/feedback since you guys participated in the discussion on Slack. |
So changing |
Is documentation challenging to review? I'm not sure I understand. |
@jzuhone Would it be fine to introduce the snake_case names as the aliases instead, even undocumented ? Or would you prefer we avoid the double api altogether and reserve the transition for an hypothetical version 5.0.0 ? @munkm two reasons:
|
Yeah, that sounds good to me. |
e6ff406
to
ce567af
Compare
@jzuhone I've updated the PR to integrate this, and provided a rather extensive historical explanation as a comment. |
f441515
to
6bad0f8
Compare
# e.g., rounding errors, parsing error... | ||
assert_raises(TypeError, _sanitize_normal_vector, ds, ui) | ||
for ui in [ | ||
"X", |
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.
Should be reject X
, Y
and Z
?
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.
IMO yes. If we start making part of the public API case-insensitive for no reason it may create friction later and it will create inconsistencies now.
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.
Fair enough
if retv.shape != (3,): | ||
raise ValueError(f"{normal} is incorrectly shape.") | ||
except ValueError as exc: | ||
raise TypeError(f"{normal} is not a valid normal vector.") from exc |
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.
Is it really a TypeError
?
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.
Arguably. Quoting the standard lib: (https://docs.python.org/3/library/exceptions.html#TypeError):
Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError.
So here, numpy is raising ValueError
when it fails to cast values to floats, but really it seems to me that it's a TypeError
by definition
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.
Either way is fine to me 🤷
…Plot, introducing the AxisAlignedProjectionPlot class. Add snake case aliases projection_plot -> ProjectionPlot and slice_plot -> SlicePlot, and update SlicePlot's docstring
…ss in documentation where due
c8a78a7
to
3e4ef92
Compare
I want to rework this in a way that |
This is now superseded and replaced by #3489 |
PR Summary
Following a question by @chummels on Slack, I'm trying here to make
yt.ProjectionPlot
work similarly toSlicePlot
, i.e, as a factory function rather than a class, so as to embraceOffAxisProjectionPlot
as well asAxisAlignedProjectionPlot
, which is here the new name of the oldProjectionPlot
class.Two remarks:
SlicePlot
gets much simpler to maintain and reproduce after the end of the 4.0 -> 4.1 deprecation cycle, so I applied the same patch as in DEPR: deprecation cycle (4.0 -> 4.1) #3240 where due.SlicePlot
regarding thenormal
argument, I refactored it a little to improve the specificity of error messagesPR Checklist