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
Make AstrometricFrame behave like other coordinate frames. #4941
Conversation
CC: @taldcroft @eteq @mhvk and @cdeil who all discussed this API earlier. |
# See above for why this is necessary. Basically, because some child | ||
# may override __new__, we must override it here to never pass | ||
# arguments to the object.__new__ method. | ||
if super(AstrometricFrame, cls).__new__ is object.__new__: |
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.
Can this ever happen, given that AstrometricFrame
is always a subclass of BaseCoordinateFrame
?
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.
In fact, because BaseCoordinateFrame doesn't implement __new__
, this is always triggered right now. If another frame were to implement a custom __new__
, this would be skipped by the parent class when traversing the class hierarchy if AstrometricFrame
came before the framecls
above, which ideally it would, but that breaks something about ordered descriptor that I don't understand (but maybe @eteq could fix?)
Regardless, right now, this is required to prevent this __new__
method from breaking should an descendant implement __new__
in the future. When this happens, if we didn't put in this statement, arguments would never get passed to a subclass __new__
, since we'd need to assume we are calling object.__new__
. As this is kind of a subtle bug when that happens, I would advocate for leaving this check in 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.
OK, yes, I was sloppy in looking through the chain. Given that object
is one up as far as __new__
is concerned, it definitely makes sense to have this in.
This looks rather nice! |
@@ -124,9 +123,9 @@ def astrometric_to_astrometric(from_astrometric_coord, to_astrometric_frame): | |||
# Otherwise, the transform occurs just by setting the new origin. | |||
return to_astrometric_frame.realize_frame(from_astrometric_coord.cartesian) | |||
|
|||
@frame_transform_graph.transform(DynamicMatrixTransform, framecls, Astrometric) | |||
@frame_transform_graph.transform(DynamicMatrixTransform, framecls, _Astrometric) | |||
def icrs_to_astrometric(reference_frame, astrometric_frame): |
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.
Change icrs_to_astrometric
to reference_to_astrometric
here?
This was a suggestion @taldcroft made in the other issue and I also found this confusing to name this icrs
when it's not specific to icrs.
ec76e72
to
bb8a7a9
Compare
I need to spend some time to wrap my head around this, which I will try to do soon... But to address my biggest initial concern:
I emphatically say it should - e.g. And that's why I ended up doing the whole metaclass magic in the first place: if you change the |
@eteq I'm still using your metaclass under the hood, so it is easy to have the class name change, it just pushes a little bit against @taldcroft's initial idea behind the API. I actually found that I left the class name changing while debugging so that I could see what was happening, then removed that part for the final version (maybe a good sign that the class name should change). From the original API request:
The tricky part is that we don't want to confuse users too much either way. In this new API, |
How is this situation different from On the question of the frame that defines the coordinate origin for distance and velocity, what could be more natural than I'll say that the first time I saw |
0224d26
to
6f95339
Compare
6f95339
to
b0b752b
Compare
@taldcroft - actually, what @cdeil's original use case as communicated to me was exactly this: he needs both the AltAz oriented "FOV frame" and the Ra/Dec oriented frame (centered on the same point). So in his use case there'd be two things in use floating around called More to the point, though, I agree wholeheartedly with @alexrudy's second statement:
"hiding" the fact that it's a subclass will just make users even more confused if they do anything beyond the basic cases outlined here (and if they just do the basic case, it doesn't hurt them any). Beyond @alexrudy's point, there's the additional bit that this really has to create a new frame anyway for the transformations to work, so if you were to, say, plot up the transform graph now, you would see lots of different frames called TL;DR: I'm fine with this approach, except with the modification of putting the name of the frame back in as @alexrudy indicates can easily be done in #4941 (comment) |
Oh, and I'm noticing the other remaining checkbox from @alexrudy at the top: I think you're asking if the frame attributes from |
Removes a duplicate line.
@eteq I agree I was actually asking about the re-implementation of I've left the TL;DR; Its not really a problem, the current implementation works and there isn't an easy way to do something better. |
@eteq - I see your points about how this gets a little sticky given the transform-graph infrastructure. I'll stop quibbling now if you'll agree to Is the plan then to have something like:
|
As a user, I don't care much about the class name. Even if you make it Some more thoughts:
FYI: here's what I eventually want to do with this, but I haven't tried it yet:
|
I'm +1 to |
Also OK with |
Finalizes attribute and frame naming conventions for AstrometricFrame and subclasses.
Oops, forgot to leave a comment here about my alexrudy#1 ... There I implemented I see @alexrudy merged it right away and the tests are passing. So I think if we merge this it closes #4931 now (unless all of a sudden a lot of opinions appear on changing the sign of the rotation). @taldcroft - in the branch as it stands right now, it's almost what you said, but instead:
To better match all the other frames, which don't have "frame" in the class name. And @mhvk, the
|
Oh, and re: @cdeil's thoughts:
That's a good idea... @alexrudy do you think you can whip this out? (Or @cdeil, maybe PR to @alexrudy's branch?)
Agreed... Although someone has to do the point one up to do that ;)
Definitely not in two places. Every time we've done that in two places we've forgotten to remove both at the same time... But It could quite reasonably go in the astrometric part of |
@eteq I'll write a test that goes between the same frame but with different attributes, and between two frames, to make sure those both work! |
Awesome, thanks @alexrudy - once that's in, and a final decision is made on the note/warning in the docs, this should be good to go. |
I don't think a warning is needed. Might it be an idea to adjust the Separately, for the coordinates inside the frame when used inside p.s. None of the above is essential, obviously. |
- Multi-parent transforms must go through both origin frames to ensure all frame attributes are accounted for. - Tests for multi-parent transforms.
I've added tests for AstrometricAltAz to AstrometricAltAz with differing attributes. It required a tweak to the transform (hey, I guess that's why we write tests?). I have not added a warning about instability to the docs anywhere, but I think I agree with @eteq and I'm sort of -0 on that one. @mhvk I think changing the |
@mhvk - mechanics aside (I agree with @alexrudy that it's potentially difficult), I disagree that hiding the (e.g.) At any rate (aside from that point above, possibly?), I think this is now ready to go, as the tests are passing, and it has had quite a bit of review! Will give another day or so to see if any dissenting opinions (Esp. re: @cdeil's thought on the warning, although so far on balance the vote seems to be towards "not needed"), then merge. |
I'm fine with this, though my point about the |
Refinements to AstrometricFrame based on early feedback
This is a stub trying to make the AstrometricFrame behave like @taldcroft suggested in #4931.
Some things are still a little bit wonky:
AstrometricFrame
andframecls
(so thatAstrometricFrame
is first, which I think makes more sense in this case)? When I do this, theFrameMeta
doesn't seem to pick up on the representation info fromframecls
.AstrometricFrame
in_AstrometricFrame
_frame
variable? In this case, I think it would have to live on the class and not the descriptor, and theconvert_input
function onCoordinateFrame
does not have access to theAstrometricFrame
class, so maybe this is too complicated.