New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate coordinates.get_moon()
#14354
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.
|
Hi @eerovaher!
I implemented a convenience function called A bit of history: my original Unlike astropy/astropy/coordinates/funcs.py Lines 150 to 154 in 01d2839
TL;DR: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
@@ -0,0 +1,3 @@ | |||
``get_moon()`` is deprecated and may be removed in a future version of | |||
``astropy``. The geocentric coordinates of the Moon can be obtained by calling | |||
``get_body("moon")``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``get_body("moon")``. | |
``get_body("moon", time, [location])``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the phrasing of the change log entry, although I tried to make the example function calls less shell-like and more Python-like.
I'm happy to approve this in principle, since there really is no need for However, it does make me question why we don't deprecate Therefore, by default both |
I've found that removing |
Interesting, I’d like to hear @eteq ’s view on why get_sun should survive. Either way, given that there is definitely no reason to keep |
fda1bfc
to
96af5f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that get_moon
can be deprecated. Just a small comment on another line that can be removed.
astropy = astropy.transform_to(self.apparent_frame) | ||
|
||
# Assert sky coordinates are close. | ||
assert astropy.separation(horizons) < de432s_separation_tolerance_moon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the definition of de432s_separation_tolerance_moon
can also be removed (and it is the same as for planets, so the tests indeed stay the same)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed de432s_separation_tolerance_moon
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhvk, I've implemented your suggestion. Can this be merged now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, completely missed that, thanks for pinging. Yes, let's get this in!
`get_moon()` is simply a shortcut to calling `get_body("moon")`.
96af5f3
to
b7a0a96
Compare
Description
get_moon()
is simply a shortcut to callingget_body("moon")
with a docstring that tends to get out of sync from the docstring ofget_body()
(as evidenced by #12683), and the presence of which complicates unit tests inastropy.coordinates.tests.test_solar_system
because Moon is treated differently from all the other Solar System bodies. Deprecating and eventually removing it simplifies the code without sacrificing functionality or readability. Note that this pull request removes a net2223 lines of code despite adding a deprecation test and a change log entry andget_moon()
hasn't even been removed yet.It seems to me the reason a separate function was created for the Moon in the first place was because it was introduced in 4a59bb8 together with a function called
get_planet()
, and callingthe equivalent ofget_planet("moon")
get_planet("moon")
would have been confusing. Butget_planet()
was renamed toget_body()
already in cd408c2 (committed on the same day). I don't understand whyget_moon()
was not removed then.