You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problem with base classes for coordinate-frame classes needing to have name #11096
# This may be a subclass of a subclass of BaseCoordinateFrame,
# like ICRS(BaseRADecFrame). In this case, cls.name will have been
# set by init_subclass
cls.name=cls.__name__.lower()
We have a base class for a frame that does not have a name attribute, so the base.name access produces an error. It's easy enough to add a dummy name attribute to "fix" this on our side, but presumably the Astropy code needs some protection?
The error does not occur directly with our RotatedSunFrame metaframe, but rather when it tries to dynamically create a coordinate frame. For example, RotatedSunFrame can create RotatedSunHeliographicStonyhurst, which has two base classes: the coordinate frame HeliographicStonyhurst and the non-coordinate-frame RotatedSunFrame. The problem is that the latter doesn't have the name attribute.
Astropy's SkyOffsetFrame doesn't have an issue because that metaframe itself subclasses BaseCoordinateFrame, so will automatically have .name. I found that I needed RotatedSunFrame to not subclass BaseCoordinateFrame to work properly, although I don't currently recall why.
Hm. First off, I think that RotatedSunFrame should probably just subclass from BaseCoordinateFrame. I did some experiments with the Sunpy frames to figure out why that was failing before, and I think I now know why. For SkyOffsetFrame, we intentionally do not use the frame-specific representation information from the parent coordinate frame class because we wanted the SkyOffsetFrame to have the same (default) component names as the default representation class. So, for example, a SkyOffsetFrame with an ICRS origin expects lon, lat, distance not ra, dec, distance. But it looks like that is not how you want RotatedSunFrame to work: It looks like your tests expect RotatedSunFrame to have the same component names as the base frame? So, in the construction of the Rotated<framecls>'s in RotatedSunMeta, I think you need to copy the _frame_specific_representation_info from the frame class into members. See sunpy/sunpy#4691 for a possible solution (fingers crossed)
Activity
adrn commentedon Nov 27, 2020
Ah, yes, an oversight on my part - oops! I'll submit a follow-up PR now, and add a regression test.
adrn commentedon Nov 27, 2020
I'm assuming this is
RotatedSunFrame? I'm a little confused about why it misses the firstifclause then, if it doesn't have a definednameattribute?ayshih commentedon Nov 27, 2020
The error does not occur directly with our
RotatedSunFramemetaframe, but rather when it tries to dynamically create a coordinate frame. For example,RotatedSunFramecan createRotatedSunHeliographicStonyhurst, which has two base classes: the coordinate frameHeliographicStonyhurstand the non-coordinate-frameRotatedSunFrame. The problem is that the latter doesn't have thenameattribute.Astropy's
SkyOffsetFramedoesn't have an issue because that metaframe itself subclassesBaseCoordinateFrame, so will automatically have.name. I found that I neededRotatedSunFrameto not subclassBaseCoordinateFrameto work properly, although I don't currently recall why.adrn commentedon Nov 28, 2020
Hm. First off, I think that
RotatedSunFrameshould probably just subclass fromBaseCoordinateFrame. I did some experiments with the Sunpy frames to figure out why that was failing before, and I think I now know why. ForSkyOffsetFrame, we intentionally do not use the frame-specific representation information from the parent coordinate frame class because we wanted theSkyOffsetFrameto have the same (default) component names as the default representation class. So, for example, aSkyOffsetFramewith anICRSorigin expectslon, lat, distancenotra, dec, distance. But it looks like that is not how you wantRotatedSunFrameto work: It looks like your tests expectRotatedSunFrameto have the same component names as thebaseframe? So, in the construction of theRotated<framecls>'s inRotatedSunMeta, I think you need to copy the_frame_specific_representation_infofrom the frame class intomembers. See sunpy/sunpy#4691 for a possible solution (fingers crossed)ayshih commentedon Nov 29, 2020
Thanks for fixing the bug in Astropy! Re
RotatedSunFrame, I'll continue the discussion in SunPy PR.Merge pull request #11101 from adrn/coordinates/fix-cls-name
mhvk commentedon Nov 29, 2020
fixed by #11101