TimeDelta and quantity input checking
- Dominant language
- Python
- Stars
- 5.3k
- Forks
- 2.2k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 74
Description
A TypeError is raised when passing in a TimeDelta to a function decorated with the quantity input decorator and a time-like type annotation for the input.
The code below illustrates the issue. To me it seems natural to pass in a TimeDelta object as a way of expressing a duration, but perhaps I using TimeDelta incorrectly.
```
import astropy.units as u
from astropy.time import Time
@u.quantity_input
def f(t: u.s):
print(t)
dt = Time('2018-10-09') - Time('2018-10-08')
f(dt)
```
Contributor guide
Research direction
Start by reproducing the example involving the quantity_input decorator, the u.s time-like annotation, and the TimeDelta value. Then inspect the decorator's input checking and time-like type handling; done means the intended TimeDelta behavior is established and the example no longer raises an unexpected TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100