Repository navigation
Conversation
|
👋 Thank you for your draft pull request! Do you know that you can use |
de2fc3e to
c2e77a5
Compare
|
@astropy/testing-infrastructure-maintainers |
|
Sorry pressed the "convert to real PR" in the wrong PR. Though I like the idea, so I guess we might as well. |
mhvk
left a comment
There was a problem hiding this comment.
I like splitting up the module, but am less sure about also moving tests (partially since that means my memory of where test files lives will go haywire, while for representations itself, I'll tab-complete my way easily). I also think the tests themselves could do with a bit of reorganization, so I'd suggest separating the two steps. (An additional advantage is that then the test files will help ensure all from astropy.coordinates.reoresentation import ??? continue to work.)
I would also not split the various spherical representations - they are so clearly related that I think it is easier if they stay together (e.g., to keep the various quick transformations in one place), i.e., I would combine back radial, spherical, base_sphere, physicssphere and unitsphere, leaving as new modules base, cartesian, cylindrical, and spherical.
|
Re: doctestplus -- no idea, hard to see with |
c2e77a5 to
06b1675
Compare
|
Interesting. De-serialization is an issue since the qualitative name has changed. |
|
I just reran the last CI on |
06b1675 to
a380c95
Compare
|
|
d24f7f6 to
679db4c
Compare
|
About the test failure This is real assuming the class full name changed. There is a hard-coded lists of classes that the mixin constructor is allowed to construct, which is there for security reasons. It's hard-coded as strings so table doesn't have to import the rest of astropy always. @mhvk have talked about this before and never come up with a better way. It's probably OK to just changed that hardcoded list, but doing stuff like this always makes you wonder if you will be breaking anything outside of astropy. [EDIT: now I see you did exactly that in 679db4c] |
|
Oops, I guess that also means that we have to continue to support both |
|
Maaaybe we need to hold off on this until we unpin Sphinx. The coordinate imports galore already broke compat with Sphinx. I don't want this to break it more. |
|
I opened #13689 to discuss improvements to |
aa9f0da to
7e21a10
Compare
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
7e21a10 to
d379868
Compare
|
v5.2 is out, so this PR is ready to go in 🤞! |
|
@mhvk requested changes in the review status, so maybe he wants to re-review? And just to make sure, you did rebase recently enough to pick up the Sphinx unpinning, right? |
|
I believe so. That was some time last week, right? |
eerovaher
left a comment
There was a problem hiding this comment.
Splitting up the representation classes into separate files is a good idea, but such a pull request that is moving lots of code around should try to avoid making any changes that are not necessary, at least not in the same commit that moves the code. @nstarman, it looks like you have some automatic tool (at least I hope it's an automatic tool) that edits comments and multi-line strings so that they fit into an 80 character line length limit. This does not affect the working of the code, but it is creating a lot of clutter in the diffs. Furthermore, the actual line length limit in astropy is now 88 characters. I've only marked two cases where the difference of enforced line lengths has led to needless editing of multi-line strings, but I expect there are more.
| diff = differentials[key] | ||
| except TypeError as err: | ||
| raise TypeError( | ||
| "'differentials' argument must be a " "dictionary-like object" |
There was a problem hiding this comment.
Why is this split into two strings? It's a single string in main:
astropy/astropy/coordinates/representation.py
Lines 745 to 747 in 2fab3d7
| "To attach a RadialDifferential to a " | ||
| "UnitSphericalRepresentation, you must supply " | ||
| "a dictionary with an appropriate key." |
There was a problem hiding this comment.
On main this error message is written in two lines, both within the 88 character line length limit, so there's no reason to split this into three lines here.
astropy/astropy/coordinates/representation.py
Lines 733 to 736 in 2fab3d7
Yes, VSCode. I'll go thru the comments and compare. Revert where necessary. Or maybe change VSCode to have an 88 character limit and let it auto format... 🤔 |
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
|
@eerovaher, I did the latter and then went and compressed error message strings into the minimum number of lines. |
| from .base import _invalidate_reprdiff_cls_hash # noqa: F401 | ||
| from .base import get_reprdiff_cls_hash # noqa: F401 | ||
|
|
||
| __all__ = [ |
There was a problem hiding this comment.
Should this __all__ be empty so only the coordinates namespace explicitly holds these objects?
There was a problem hiding this comment.
I'm with @eerovaher -- as few changes here as possible. So, let's keep this the same as the one originally in representations.py.
| "To attach a RadialDifferential to a " | ||
| "UnitSphericalRepresentation, you must supply " | ||
| "a dictionary with an appropriate key." |
| diff = differentials[key] | ||
| except TypeError as err: | ||
| raise TypeError( | ||
| "'differentials' argument must be a " "dictionary-like object" |
mhvk
left a comment
There was a problem hiding this comment.
Looks mostly OK, but I'm still unhappy with the empty __all__ -- readability counts, and this is done not for people reading the code, for whom it would be useful to know what classes are actually the ones being defined that get used elsewhere. Plus, that's how its done elsewhere in astropy.
| from .base import _invalidate_reprdiff_cls_hash # noqa: F401 | ||
| from .base import get_reprdiff_cls_hash # noqa: F401 | ||
|
|
||
| __all__ = [ |
There was a problem hiding this comment.
I'm with @eerovaher -- as few changes here as possible. So, let's keep this the same as the one originally in representations.py.
| from astropy.utils.data_info import MixinInfo | ||
| from astropy.utils.exceptions import DuplicateRepresentationWarning | ||
|
|
||
| __all__: list[str] = [] # Not public. Import from ``astropy.coordinates`` |
There was a problem hiding this comment.
I disagree with this still. Let's put things in here that get transferred up (like is done in modules in builtin_frames). If you feel strongly otherwise, I would suggest for now not having any __all__ (like in matrix_utilities, which is also not exposed). Though to me it is helpful to the code reader -- the ones for whom this matters most -- that it lists the classes, etc., that this file actually defines for use elsewhere.
|
|
||
| def _fqn_class(cls: type) -> str: | ||
| """Get the fully qualified name of a class.""" | ||
| return f"{cls.__module__}.{cls.__qualname__}" |
|
|
||
| from .base import BaseDifferential, BaseRepresentation | ||
|
|
||
| __all__: list[str] = [] # Not public. Import from ``astropy.coordinates`` |
| @@ -0,0 +1,156 @@ | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
So, why is the license file still not added automatically then?
| @@ -0,0 +1,1600 @@ | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
I think there is no need for this if we remove __all__.
| from .base import BaseDifferential, BaseRepresentation | ||
| from .cartesian import CartesianRepresentation | ||
|
|
||
| __all__: list[str] = [] # Not public. Import from ``astropy.coordinates`` |
|
|
||
| The representation can be supplied either as a | ||
| `~astropy.coordinates.representation.BaseRepresentation` class (e.g., | ||
| `~astropy.coordinates.representation.base.BaseRepresentation` class (e.g., |
There was a problem hiding this comment.
I think this is better changed to ~astropy.coordinates.BaseRepresentation, since that is where we want users to import from.
eerovaher
left a comment
There was a problem hiding this comment.
I've highlighted a couple of needless changes to strings that are still present, but I have not made a thorough search even in the one file I looked at, so I expect there to be many more cases of this.
@nstarman, the tool that you are using now seems to respect the 88 character line length limit, but it is being very aggressive about it, i.e. it adds words from the beginning of the next line to the end of the current line if they fit. This is being done in multi-line strings, comments and docstrings.
I supported adopting black because I was annoyed with the number of commits in this repository that introduced formatting problems that had to be fixed in a separate commit. Such formatting fixes add clutter to the commit log and make it more difficult to track actual functional changes. black together with pre-commit can prevent such formatting-only commits from ever happening (although not everyone is making use of these tools). The tool you are using is making cosmetic changes to a codebase that black is happy with. This is adding clutter to the commit history, which I cannot approve. I recommend you turn off any code-formatting features VSCode might have and just let black do its job.
|
|
||
| if not hasattr(cls, "attr_classes"): | ||
| raise NotImplementedError( | ||
| "Representations must have an " '"attr_classes" class attribute.' |
There was a problem hiding this comment.
This string is still getting needlessly split up. Here's what it looks like in current main:
astropy/astropy/coordinates/representation.py
Line 653 in 8796307
| msg = ( | ||
| f'Representation "{repr_name}" already defined, removing it to avoid ' | ||
| f'confusion. Use qualnames "{fqn_cls}" and "{fqn_existing}" or class ' | ||
| "instances directly" | ||
| ) |
There was a problem hiding this comment.
Here the placement of spaces separating the sub-strings is being needlessly changed. Currently on main the spaces are put in the beginning of the sub-strings:
astropy/astropy/coordinates/representation.py
Lines 669 to 673 in 8796307
| def __setitem__(self, item, value): | ||
| if not isinstance(value, BaseRepresentation): | ||
| raise TypeError( | ||
| f"value must be a representation instance, " f"not {type(value)}." |
There was a problem hiding this comment.
One f-string is good enough for main, it should be good enough here as well.
astropy/astropy/coordinates/representation.py
Line 1070 in 8796307
|
Wow I would recommend you wrap this up early in the v6.0 dev cycle. Or maybe breaking it into a series of smaller PRs. |
|
See #14792 for a re-implementation of this - I still think this is an excellent idea but this PR was getting behind |
Signed-off-by: Nathaniel Starkman (@nstarman) [email protected]
It's a long file that does many things. Now it's one module with many files, each of which do fewer things.
For reviewers: I didn't change the test files, only moved them, so that should show that no (tested) functionality has changed!TODO?
BREAKING CHANGE: change folder name torepresentationsChecklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CIlabel. Codestyle issues can be fixed by the bot.no-changelog-entry-neededlabel. If this is a manual backport, use theskip-changelog-checkslabel unless special changelog handling is necessary.astropy-botcheck might be missing; do not let the green checkmark fool you.backport-X.Y.xlabel(s) before merge.