Repository navigation
Allow the use of Distribution in Representations and SkyCoord - #15395
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
b4521d2 to
1e04dcc
Compare
nstarman
left a comment
There was a problem hiding this comment.
It's wonderful how few changes are actually required!
| if cls.__name__ == "BaseRepresentation": | ||
| # Register representation name (except for bases on which other representations | ||
| # are built, but which cannot themselves be used). | ||
| if cls.__name__.startswith("Base"): |
There was a problem hiding this comment.
This is good given the current check, but it would be nice to have a check not based on strings but on e.g. if the class is abstract.
There was a problem hiding this comment.
Agreed that this is not a very nice heuristic... But for another time!
Also adjust broadcast_arrays to ensure that regular arrays are not turned into Distribution after broadcasting.
1e04dcc to
446bbb5
Compare
446bbb5 to
9de420c
Compare
nstarman
left a comment
There was a problem hiding this comment.
LGTM! I like the code / test ratio.
We've identified some things for followup, so this PR is ready.
Probably want other Coordinates maintainers to OK this?
|
Thanks! I asked @eteq offline for a quick review, as the other |
|
@mhvk , I'll leave it to your discretion on when to merge then. But I would advise against waiting till the last minute before feature freeze. |
|
Thanks, all, merged! |
This pull request is updates the
Distributionclass to allow it to be used inside representations. After the PRs to get things to work withEarthLocation, the changes here are rather minimal: supportconcatenateand a small fix in howbroadcast_arraysis dealt with (plus a very small change in registration of representations, just for the tests to work more easily); the bulk of this PR is extra tests.Note that the support is not yet complete. E.g., the way representations do
__repr__means that thereprgives no sign that distributions are used. I think the best way to fix this, though, is through support ofarray2stringfor representations, which is a bit beyond what I can do here (similarly,Distribution.__repr__should go viaarray2stringso that one can indicate what are the samples more easily). There perhaps also is a more general question of whether things likeSkyCoordshould just allowDistributionto be used, or whether they should also gain a.distributionproperty.Anyway, I think it makes sense to proceed in small steps, so just go with what is here first...