-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
APE26: Removing data storage (representations) from coordinate frames #112
base: main
Are you sure you want to change the base?
Conversation
Pinging @eerovaher @eteq @StuartLittlefair @Cadair @ayshih @taldcroft as other "stakeholders" who may want to take a look at this and review! |
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 am convinced that there should be exactly one type for coordinate data. This would prevent users from getting confused about which type they should be using and simplifies things for both astropy
and downstream developers because we'll only have to support one type of coordinate data as input for our functions.
This leaves two possibilities: the single type is a class, which is what this APE proposes, or the single type is a Protocol, which is what Implement BaseCoordinateFrame.frame property
(astropy/astropy#16356) (that the APE mentions) proposed. Implementing a Protocol
would be backwards-compatible and wouldn't cause disruption for downstream packages. In every other regard this APE is a better idea.
Having both the frame classes as well as ``SkyCoord`` be able to store and handle data | ||
has resulted in a large amount of code duplication. Restructuring the ``Frame`` classes |
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.
Not just code. It's even worse in tests because we have to test both SkyCoord
and BaseCoordinateFrame
methods with both SkyCoord
and BaseCoordinateFrame
inputs. Not testing all the combinations has led to bugs going unnoticed, e.g. astropy/astropy#15659
this arena too, separating frames from data storage has its advantages. Perhaps most | ||
importantly, documentation will be more obvious: the methods and attributes are defined | ||
on ``SkyCoord``, and sphinx will know how to typeset those. It will also be easier: |
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 is relevant not only for documentation but also for type annotations. Looking up BaseCoordinateFrame
methods via SkyCoord.__getattr__()
is too dynamic for static type checkers. It is possible to partially alleviate this by writing out stubs in SkyCoord
(e.g. https://github.com/astropy/astropy/blob/24d48a9e2ef90af5383bf76e6d098e6d193d8186/astropy/coordinates/sky_coordinate.py#L178-L181), but type checkers cannot ensure that the stubs agree with the signatures of the actual methods.
APE26.rst
Outdated
``SkyCoord``: | ||
|
||
- *Add .to_table() to frames*: `https://github.com/astropy/astropy/pull/17009` | ||
- *Add .frame attribute to frames*: `https://github.com/astropy/astropy/pull/16356` |
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 find it confusing that you have not used the pull request titles.
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.
Good point, thank you. Fixed in 46f503e
Yes, yes and a thousand times yes. The devil will be in the implementation details but this is a thoroughly good idea. |
Does anyone else have thoughts before we ask the @astropy/coordinators to review this? cc @eteq @Cadair @ayshih @taldcroft! |
I have been traveling the last several weeks and haven't had a chance to review this in detail, but I will try to do so this week. I am fairly sure I will have Opinions ™️ (but hopefully positive ones?) |
@eteq OK cool. It'd be good to get your feedback ASAP, because @jeffjennings is starting to work through some of the changes we discuss here (in draft stages, but still, it is somewhat in progress). |
I have two main thoughts about some effects from this change, I think they can both be managed, but probably worth having a think about.
|
Thanks for pinging me about this change. If I'm following the end result will be that coordinate frames will no longer have Reading old files with
|
Coordinate frames in
astropy.coordinates
currently store metadata used to construct the frame (i.e. for transforming between frames) and may also store coordinate data itself. This duplicates functionality withSkyCoord
, which acts as a container for both coordinate data and reference frame information. We propose to change the frame classes such that they only store metadata and never coordinate data. This would make the implementation more modular, remove ambiguity for users from having nearly duplicate functionality with slightly different APIs, and better satisfy the principle of Separation of Concerns.Authors of this APE (alphabetical): Jeff Jennings @jeffjennings, Adrian Price-Whelan @adrn, Nathaniel Starkman @nstarman, Marten van Kerkwijk @mhvk