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
Don't allow adding new frames to transform graph if their attributes conflict with component names #6871
Don't allow adding new frames to transform graph if their attributes conflict with component names #6871
Conversation
Hi there @adrn 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. Everything looks good from my point of view! 👍 If there are any issues with this message, please report them here. |
Tests passed on last commit, so I just pushed up a changelog entry. |
1424a0f
to
8f10da1
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.
Minor change needed of moving the changelog, plus possible change needed for my bigger concern below about backwards compatibility.
First, I did a quick check and this has no noticeable impact in the time needed to import coordinates
, so that's good!
My concern, though, is that this is a backwards-incompatible change. Usually we give at least one version of deprecation warning. So maybe this error should be changed to a warning for this version, and then update to an error for 3.1?
CHANGES.rst
Outdated
the ``.parallax`` attributes. [#6855] | ||
|
||
- Coordinate frame classes now can't be added to the frame transform graph if |
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.
Technically this is an API change, right? Should probably put it there instead of "new feature"
@@ -38,6 +38,41 @@ | |||
'FunctionTransformWithFiniteDifference', 'CompositeTransform'] | |||
|
|||
|
|||
def frame_attrs_from_set(frame_set): |
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.
Do you mean for this (and the next function) to be part of the public API? I'm guessing not since it's not fully documented (and I'm OK with that), but if you do it needs to be in __all__
.
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.
No, I think they should be private.
Fair point RE: deprecation. I changed the error to a deprecation warning. |
8f10da1
to
6d996e8
Compare
Actually, even though we allow any attribute names right now, it breaks import astropy.coordinates as coord
import astropy.units as u
class BorkedFrame(coord.BaseCoordinateFrame):
ra = coord.Attribute(default=150)
dec = coord.Attribute(default=150)
def trans_func(coo1, f):
pass
trans = coord.FunctionTransform(trans_func, BorkedFrame, coord.ICRS)
trans.register(coord.frame_transform_graph)
icrs = coord.SkyCoord(ra=160*u.deg, dec=-11*u.deg)
icrs.transform_to(coord.FK5) results in a
So IMO it's somewhere in between an API change and a bugfix. Thoughts on whether this should raise a warning or error? |
CHANGES.rst
Outdated
@@ -25,6 +25,9 @@ astropy.coordinates | |||
properties that provide shorthands to the full-space Cartesian velocity as | |||
a ``CartesianDifferential``, the 2D proper motion as a ``Quantity``, and the | |||
radial or line-of-sight velocity as a ``Quantity``. [#6869] | |||
- Coordinate frame classes now can't be added to the frame transform graph if |
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.
need a blank line above (rebase issue?)
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.
Oops - yes...
re: @adrn's
I think it's still technically an API change, because the warning/error now happens earlier. But you're right it's less likely anyone will have used this because it will make Also, @adrn, I think I know why the tests are failing in a somewhat unpredictible way: the test that adds the |
I think I would prefer to error now: it's more work to deprecate and deal with cleaning up the |
6d996e8
to
6f027a0
Compare
See #6870 for a description of the problem.
This solves the problem by checking whether a new frame class added to the transform graph has invalid attribute names.