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
SkyCoord.replicate returns underlying BaseFrame type, not SkyCoord #15643
SkyCoord class has no replicate() method. SkyCoord instances expose the replicate() method of their underlying frame, just like how they expose many other methods and attributes.
Aside: it is slightly unfortunate that astropy has replicate and copy instead of copy and deepcopy
We also have clone!
but I fear that ship has sailed.
When Cosmology becomes a dataclass I'm planning to deprecate the .clone method in favor of replace, which is the dataclasses library standard and suggestion. The .clone method will just be a deprecated alias of replace that'll stick around for a good long while.
We can do the same for all the other miscellaneous implementations!
Hmm, that's pretty bad, SkyCoord should not have exposed that, or, arguably better, implement its own replicate.
SkyCoord having its own replicate() makes a lot of sense, since otherwise there's no way to perserve attributes that are not used for the particular frame. I'll note that it creates a bit of non-parallelism if replicate_without_data() is still exposed, because the output of that method cannot be a SkyCoord. (That is, it's unfortunate the name of that method didn't happen to be something like replicate_only_frame().)
I guess generally one might expose all attributes, but probably should be more selective with methods.
I'll point out that sunpy has multiple frame-specific methods and properties (beyond the frame attributes) that are defined on frame subclasses, and it's convenient that they are automatically exposed as methods and properties of corresponding SkyCoord instances. It wouldn't be a huge deal to educate users to call coord.frame.whatever() instead of coord.whatever(), but some internals might need to do more SkyCoord/not-SkyCoord checking. It may also have users thinking more about the implementation than they need to be.
Aside: it is slightly unfortunate that astropy has replicate and copy instead of copy and deepcopy, resp., but I fear that ship has sailed.
I imagine that the vast majority of calls to replicate() are to change the value of at least one frame attribute. As such, copy()/deepcopy() are not great analogies, but as mentioned by @nstarman, the dataclasses replace() would be.
Activity
eerovaher commentedon Nov 23, 2023
SkyCoordclass has noreplicate()method.SkyCoordinstances expose thereplicate()method of their underlying frame, just like how they expose many other methods and attributes.mhvk commentedon Nov 24, 2023
Hmm, that's pretty bad,
SkyCoordshould not have exposed that, or, arguably better, implement its ownreplicate.I guess generally one might expose all attributes, but probably should be more selective with methods.
Aside: it is slightly unfortunate that astropy has
replicateandcopyinstead ofcopyanddeepcopy, resp., but I fear that ship has sailed.nstarman commentedon Nov 24, 2023
We also have
clone!When
Cosmologybecomes a dataclass I'm planning to deprecate the.clonemethod in favor ofreplace, which is thedataclasseslibrary standard and suggestion. The.clonemethod will just be a deprecated alias ofreplacethat'll stick around for a good long while.We can do the same for all the other miscellaneous implementations!
ayshih commentedon Nov 24, 2023
SkyCoordhaving its ownreplicate()makes a lot of sense, since otherwise there's no way to perserve attributes that are not used for the particular frame. I'll note that it creates a bit of non-parallelism ifreplicate_without_data()is still exposed, because the output of that method cannot be aSkyCoord. (That is, it's unfortunate the name of that method didn't happen to be something likereplicate_only_frame().)I'll point out that
sunpyhas multiple frame-specific methods and properties (beyond the frame attributes) that are defined on frame subclasses, and it's convenient that they are automatically exposed as methods and properties of correspondingSkyCoordinstances. It wouldn't be a huge deal to educate users to callcoord.frame.whatever()instead ofcoord.whatever(), but some internals might need to do moreSkyCoord/not-SkyCoordchecking. It may also have users thinking more about the implementation than they need to be.I imagine that the vast majority of calls to
replicate()are to change the value of at least one frame attribute. As such,copy()/deepcopy()are not great analogies, but as mentioned by @nstarman, the dataclassesreplace()would be.nstarman commentedon Dec 4, 2024
#16887!