Skip to content

Commit

Permalink
Fix #103 by casting python float to numpy float explicitly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Paulik committed May 25, 2016
1 parent 1687a3f commit 4a0cc85
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pytesmo/timedate/julian.py
Expand Up @@ -152,7 +152,7 @@ def julian2date(julian):
year = year - (month > 2)

fraction = (julian + 0.5 - jn).astype(np.float64)
eps = (1e-12 * np.abs(jn)).astype(np.float64)
eps = (np.float64(1e-12) * np.abs(jn)).astype(np.float64)
eps.clip(min=np.float64(1e-12), max=None)
hour = (fraction * 24. + eps).astype(np.int64)
hour.clip(min=0, max=23)
Expand Down Expand Up @@ -182,8 +182,13 @@ def julian2datetime(julian, tz=None):
type(julian) == np.ndarray or type(julian) == np.flatiter:
return np.array([dt.datetime(y, m, d, h, mi, s, ms, tz)
for y, m, d, h, mi, s, ms in
zip(year, month, day, hour, minute,
second, microsecond)])
zip(np.asanyarray(year),
np.asanyarray(month),
np.asanyarray(day),
np.asanyarray(hour),
np.asanyarray(minute),
np.asanyarray(second),
np.asanyarray(microsecond))])

return dt.datetime(year, month, day, hour, minute, second, microsecond, tz)

Expand Down

0 comments on commit 4a0cc85

Please sign in to comment.