Repository navigation
Fix for the annoying skyoffset origin bugs - #11730
Conversation
|
Am a bit unsure about the milestone - was this a bug in 4.0 as well? Also, will add a changelog entry once the tests have run. |
| from astropy.tests.helper import assert_quantity_allclose as assert_allclose | ||
|
|
||
|
|
||
| def test_altaz_attribute_transforms(): |
There was a problem hiding this comment.
The large diff here is just because I swapped test_altaz and test_icrs as that made the bug appear much more reliably. There is no change in code.
| # See gh-11277. | ||
| # TODO: Should it be a property of the frame attribute that it can | ||
| # or cannot be stored on a SkyCoord? | ||
| frame_kwargs.pop('origin', None) |
There was a problem hiding this comment.
Does this means that SkyCoord(SkyOffsetFrame(...)).origin no longer works?
There was a problem hiding this comment.
#11730 (comment) Answers ↑.
Followup: given that users can make their own frames with arbitrary frame attributes, perhaps this special-casing of "origin" should be further special-cased by first checking if the 'from'-frame is SkyOffsetFrame
| frame_kwargs.pop('origin', None) | |
| if self.frame.__class__ is SkyOffsetFrame: | |
| frame_kwargs.pop('origin', None) |
There was a problem hiding this comment.
You are right. I never liked this somewhat arbitrary popping of a name - really, SkyOffsetFrame itself should somehow tell that its attribute should not be propagated.
|
@nstarman - let me take your question out of the code comments, since it is important:
I checked and, no, the regular usage works: What will fail, though, is This would seem OK - there is no particular use to still know what the origin is once you have transformed away from it. The reason it is there for other attributes like Though, this does make me realize this is an API change: what worked before but is now impossible is, I think to keep that, we'll need to distinguish between different |
👍.
Agreed. Especially since one can transform from one sky-offset to another.
Wow. That's dangerous and seems a good thing to deprecate. As there can be many different skyoffset frames defined, the following would be super confusing
Perhaps SkyOffsetFrame could have a kwarg "name" to register in frames. Unnamed SkyOffsetFrames cannot be referred to by a string. |
There was a problem hiding this comment.
This looks good as a bugfix! I think in the long term, as discussed by @mhvk and @nstarman, we should add support to Attribute to allow a defined attribute to tell the transform machinery not to propagate it through a frame change. For example, maybe it would be sufficient to add a propagate=False argument to Attribute?
Note: see #11782 to track the general case.
|
Ah, but this does need a changelog entry! |
This was promised to be the case in _parse_coordinate_arg, but actually did not happen.
This causes problems with validation, since origin can be defined on different SkyOffsetFrame classes, which have different rules for what is valid. But it also makes little sense to carry it around, as it is not an attribute that can be used to set defaults for a transformation.
1d5f5bc to
aeb422c
Compare
|
Oops, now added an entry. Running tests again just in case. |
…n-bugs Fix for the annoying skyoffset origin bugs
Fix for the annoying skyoffset origin bugs
|
backported to 4.3.x in 2cf2248 |
Fixes #11277!
It turned out there were two separate bugs: one that the
originvalidation cannot generally be done, since it varies by SkyOffsetFrame class. For that, I ended up just not propagating 'origin' toSkyCoord. After all, it is not like the other atttributes, which can still be used in a future transformation.But it turned out 'origin' was also set on the SkyCoord at the end of a transformation (where for reasons we need to fix, the whole initialization gets redone even though everything is perfectly organized already). This was because of a bug in the argument parser, which led to frame attributes to be needlessly set on the SkyCoord.
@eteq - am hoping this can still be backported...