Skip to content

timelib.calendar_tuple fails on array inputs #102

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

Closed
jrs65 opened this issue Aug 4, 2016 · 2 comments
Closed

timelib.calendar_tuple fails on array inputs #102

jrs65 opened this issue Aug 4, 2016 · 2 comments
Assignees

Comments

@jrs65
Copy link
Contributor

jrs65 commented Aug 4, 2016

I'm getting an Exception thrown when I try to use timelib.calendar_tuple with an array.

>>> import numpy as np
>>> from skyfield import timelib                                                                                         
>>> jd_array = 2440587.5 + np.arange(10.0)                                                                                                            
>>> years, months, days, hours, minutes, seconds = timelib.calendar_tuple(jd_array)
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/bg01/homescinet/k/krs/jrs65/sfdev/python-skyfield/skyfield/timelib.py", line 575, in calendar_tuple
    whole = whole.astype(whole)
TypeError: data type not understood

I think the issue is that the offending line (skyfield/timelib.py:575) has a slight typo and that it should be changed from:

whole = whole.astype(whole)

to

whole = whole.astype(int)

Making that change allows it to work correctly on array inputs, and doesn't cause any regressions in the unit tests.

I'll try and put together a PR for it later on today.

@jrs65 jrs65 changed the title timelib.calendar tuple fails on array inputs timelib.calendar_tuple fails on array inputs Aug 4, 2016
@jrs65
Copy link
Contributor Author

jrs65 commented Aug 4, 2016

A quick comment...

This issue crops up when calling Time.tt_calendar() or Time.tai_calendar(), e.g.

tv = ts.utc(range(2000, 2010))
tv.tt_calendar()  # Fails

jrs65 added a commit to jrs65/python-skyfield that referenced this issue Aug 4, 2016
Also added _to_array to protect routine against failure when called with Python scalar.
@brandon-rhodes brandon-rhodes self-assigned this Aug 5, 2016
jrs65 added a commit to jrs65/python-skyfield that referenced this issue Aug 25, 2016
Also added _to_array to protect routine against failure when called with Python scalar.
@brandon-rhodes
Copy link
Member

Fixed in 10d7a89.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants