-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Make TimeDelta a unitful Quantity #751
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
Conversation
astropy.time.TimeDelta inherits from astropy.units.Quantity, so that it
gains the .to() method and can be converted to seconds, hours, minutes,
etc.
Now you can do this:
>>> from astropy import time, units
>>> t1 = time.Time('2013-01-01T05:44:00', scale='utc', format='isot')
>>> t2 = time.Time('2013-01-01T06:45:00', scale='utc', format='isot')
>>> print (t2 - t1).to(units.min)
61.0 min
|
This seems like a good idea to me, unless @taldcroft has some issue with it. I could see a possible concern here with the @lpsinger, could you add a test or two to |
|
@eteq @lpsinger - sorry I haven't yet had a chance to play around with this. My immediate question shared with @eteq is API collision since this mixes two relatively complicated classes in a way that wasn't in the design of either. But maybe it just works. The idea of adding a suite of tests is good. A lighter-weight option would just be adding a |
|
I think that this is fine. The main problem that I see is that See issue #761, though. |
|
Some other thoughts on this idea:
I see the motivation for inheriting from After inheriting from So one possibility is to make sure all the combination rules above work, don't inherit from |
|
Hmm, the "near-misses" particular worry me. Although perhaps that means we should be doing things consistently in the first place... but that may be a separate issue (I'll open one). But even if that's fixed, I think I agree with @taldcroft that it's showing a potential danger/confusion from subclassing. There's also the issue of accidentally hurting precision is also higher because of the An alternative to a direct |
|
Found this while looking through old issues. I think @taldcroft's summary is good, and especially Note that it has become somewhat more tricky to emulate the new quantity, with its loads of short-cut conversions ( [1] Trial implementation at https://github.com/mhvk/astropy/tree/time-and-timelike-quantities |
|
Superceded by #1431. |
|
Since this was superseded not implemented as originally described I'm going to remove the milestone. In general we should remove milestones from any PRs that are never merged or implemented as-is to avoid confusion. |
|
@embray - copy. |
Allow Time input/interaction/output with Quantities (closes #751)
astropy.time.TimeDelta inherits from astropy.units.Quantity, so that it
gains the .to() method and can be converted to seconds, hours, minutes,
etc.
Now you can do this: