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
Disallow the use of quantity input for 'decimalyear' format. #14566
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.
|
dev failures unrelated (URL timeouts) |
https://datacenter.iers.org appears to be down. Do you know who we should contact? |
I think it is temporary - I can open the URL now. |
I restarted the remote data job |
There are two real failures on the remote data job (that also picks up numpy dev), so I cannot tell if they are related to your PR or not: https://github.com/astropy/astropy/actions/runs/4495274221/jobs/7921203286?pr=14566 |
Both failures are weird, but definitely unrelated to this PR. It looks like a location has moved according to google (I guess we just pick a more guaranteed example...), while something much have changed with |
Looking at the code it looks like there is another related mistake that the But with 3 classes using the same checker maybe it is time for a mixin class that provides just that |
@taldcroft -
But I'm happy to combine |
Personally I find this surprising, or at least contrary to the documentation for the float Alas that ship has already sailed and some of the epoch classes will accept a Quantity and some won't, so I agree with the approach here to fix |
Yes, perhaps in hindsight it was not that great an idea to allow quantities in |
Using quantities with units of time for ``Time`` format 'decimalyear' will now raise an error instead of converting the quantity to days and then interpreting the value as years. An error is raised instead of attempting to interpret the unit as years, since the interpretation is ambiguous: in 'decimaltime' years are equal to 365 or 366 days, while for regular time units the year is defined as 365.25 days.
786016a
to
f22d534
Compare
@taldcroft - I added an extra commit that refactors out a new |
1ece0b3
to
8a8dc93
Compare
Actually, a failure makes clear that we do have a bit of text in the |
8a8dc93
to
b223d80
Compare
OK, tests all passed, ready for final review... |
Thinking about this again, I'm not 100% sure I like the new |
@mhvk - one possibility is a helper function or static method that implements the no-Quantity check. Lately I find myself trying to avoid so much inheritance. An advantage of helper functions is that they can be easier to test in unit tests, and it is definitely easier to understand when reading the code. E.g.
|
b223d80
to
108196b
Compare
OK, I went with your suggestion - that does leave us free to change things if we find a better way to do this. (E.g., I experimented with |
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 - looks great! CI hasn't fully passed yet, but assuming that it does you can click the "CI passed" checkbox and merge.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
…cimalyear' format.
…cimalyear' format (cherry picked from commit b40081f)
Backport PR #14566: Disallow the use of quantity input for 'decimalyear' format
This comment was marked as resolved.
This comment was marked as resolved.
Backport PR #14566: Disallow the use of quantity input for 'decimalyear' format (v5.0.x)
Using quantities with units of time for
Time
format 'decimalyear' will now raise an error instead of converting the quantity to days and then interpreting the value as years. An error is raised instead of attempting to interpret the unit as years, since the interpretation is ambiguous: in 'decimaltime' years are equal to 365 or 366 days, while for regular time units the year is defined as 365.25 days.Fixes #14541