-
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: improve API consistency for ProjectionPlot VS SlicePlot #3489
ENH: improve API consistency for ProjectionPlot VS SlicePlot #3489
Conversation
6b0f806
to
90aae3f
Compare
Same failures as seen in other recent PRs as well as on the daily run for Jenkins these days. |
Close + reopen to retrigger tests |
90aae3f
to
295ee64
Compare
there may be a way to reduce the diff size of this PR using |
I don't want to make this anymore confusing so I'll ignore my own previous comment. |
Sigh. I realize my current reimplementation of the compatibility layer doesn't work: class Base:
def __new__(cls, *args, **kwargs):
if 'hello' in kwargs:
val = kwargs['hello']
print(f"CATPURED VALUE {val}")
del kwargs["hello"]
self = object.__new__(cls)
return self
def __init__(self, *args, **kwargs):
if 'hello' in kwargs:
raise RuntimeError("this is not supposed to be possible")
Base(hello=True) raises the "impossible" error. I need to reiterate on this |
295ee64
to
7495515
Compare
I think I solved this in the less disruptive fashion possible. Ideally I'd want to really align signatures for |
adding the bug label now that this fixes #3528 |
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.
Seems pretty good. Anything in particular you want eyes on? I've read and it seems OK but there might be things I'm missing?
This is intended as a no-op for the most part, but I did change (supposedly improved) the way normal vectors are validated. I think this would be the part worth the most attention. |
@chummels could you take a look, and if this looks OK to you can you merge? |
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 looks great to me! Especially, I am very happy with the dispatching mechanism inserted in the __new__
method, very clean!
I however left few comments that I think should be addressed before this goes in.
- rename ProjectionPlot -> AxisAlignedProejctionPlot - make SlicePlot a dispatch class instead of a factory function - a similar dispatch class with the name ProjectionPlot - add an abstract layer (NormalPlot) as a common ancestor for plot classes with a "normal"/"axis" argument
7495515
to
cb738cb
Compare
@yt-fido test this please |
@yt-fido test this please (this seems to keep hitting a randomly failing test in the athenapp frontend) |
So this has two approvals already but @chummels would like to review it too, so we'll hold this off for the time being :-) |
PR Summary
This is another jab at the current API inconsistency between slice plots and projection plots.
This replaces #3450.
main branch
SlicePlot
is a "factory function" that dispatches betweenAxisAlignedSlicePlot
andOffAxisSlicePlot
classesProjectionPlot
is a class, but it only performs "axis aligned" projections, and we haveOffAxisProjectionPlot
but noAxisAlignedProjectionPlot
this work
SlicePlot
becomes a class, but does the same exact thing as the original factory functionProjectionPlot
becomesAxisAlignedProjectionPlot
, making room for a "dispatch class"ProjectionPlot
with the same dispatching pattern asSlicePlot
This eleviate the inconsistency, plus it allows users to rely on the fact that
SlicePlot
andProjectionPlot
are classes (as the camel case suggests).I've checked that filenames generated by the
PWViewerMPL.save
method are consistent with the main branch.The only possible backward compat breakage I can think of would be if anyone downstream relied on
SlicePlot
being a function, which seems terribly unlikely to me.Note
The "dispatch class" pattern as implemented here is heavily inspired from the standard lib
pathlib.Path
class which instantiatepathlib.PosixPath
orpathlib.WindowsPath
depending on the OS, and provides a general abstraction for the two specialised classes.PR Checklist