Skip to content

Commit

Permalink
Merge pull request #94 from Unidata/issue93
Browse files Browse the repository at this point in the history
fix issue #93
  • Loading branch information
jswhit committed Dec 2, 2018
2 parents 03bbb9f + b6d55aa commit 7cad6ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cftime/_cftime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def DateFromJulianDay(JD, calendar='standard', only_use_cftime_datetimes=False,
# get the day (Z) and the fraction of the day (F)
# use 'round half up' rounding instead of numpy's even rounding
# so that 0.5 is rounded to 1.0, not 0 (cftime issue #49)
Z = np.int32(_round_half_up(julian))
Z = np.atleast_1d(np.int32(_round_half_up(julian)))
F = (julian + 0.5 - Z).astype(np.longdouble)

cdef Py_ssize_t i_max = len(Z)
Expand Down Expand Up @@ -498,7 +498,7 @@ def DateFromJulianDay(JD, calendar='standard', only_use_cftime_datetimes=False,
# recomputing year,month,day etc
# ms_eps is proportional to julian day,
# about 47 microseconds in 2000 for Julian base date in -4713
ms_eps = np.array(np.finfo(np.float64).eps,np.longdouble)
ms_eps = np.atleast_1d(np.array(np.finfo(np.float64).eps,np.longdouble))
ms_eps = 86400000000.*np.maximum(ms_eps*julian, ms_eps)
microsecond = np.where(microsecond < ms_eps, 0, microsecond)
indxms = microsecond > 1000000-ms_eps
Expand Down
12 changes: 6 additions & 6 deletions test/test_cftime.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def runTest(self):
assert(err < eps)
assert(date1.strftime(dateformat) == date2.strftime(dateformat))
if verbose:
print('calender = %s max abs err (microsecs) = %s eps = %s' % \
print('calendar = %s max abs err (microsecs) = %s eps = %s' % \
(calendar,maxerr,eps))
units = 'milliseconds since 1800-01-30 01:01:01'
eps = 0.1
Expand All @@ -370,7 +370,7 @@ def runTest(self):
assert(err < eps)
assert(date1.strftime(dateformat) == date2.strftime(dateformat))
if verbose:
print('calender = %s max abs err (millisecs) = %s eps = %s' % \
print('calendar = %s max abs err (millisecs) = %s eps = %s' % \
(calendar,maxerr,eps))
eps = 1.e-3
units = 'seconds since 0001-01-30 01:01:01'
Expand All @@ -386,7 +386,7 @@ def runTest(self):
assert(err < eps)
assert(date1.strftime(dateformat) == date2.strftime(dateformat))
if verbose:
print('calender = %s max abs err (secs) = %s eps = %s' % \
print('calendar = %s max abs err (secs) = %s eps = %s' % \
(calendar,maxerr,eps))
eps = 1.e-5
units = 'minutes since 0001-01-30 01:01:01'
Expand All @@ -402,7 +402,7 @@ def runTest(self):
assert(err < eps)
assert(date1.strftime(dateformat) == date2.strftime(dateformat))
if verbose:
print('calender = %s max abs err (mins) = %s eps = %s' % \
print('calendar = %s max abs err (mins) = %s eps = %s' % \
(calendar,maxerr,eps))
eps = 1.e-6
units = 'hours since 0001-01-30 01:01:01'
Expand All @@ -418,7 +418,7 @@ def runTest(self):
assert(err < eps)
assert(date1.strftime(dateformat) == date2.strftime(dateformat))
if verbose:
print('calender = %s max abs err (hours) = %s eps = %s' % \
print('calendar = %s max abs err (hours) = %s eps = %s' % \
(calendar,maxerr,eps))
eps = 1.e-8
units = 'days since 0001-01-30 01:01:01'
Expand All @@ -434,7 +434,7 @@ def runTest(self):
assert(err < eps)
assert(date1.strftime(dateformat) == date2.strftime(dateformat))
if verbose:
print('calender = %s max abs err (days) = %s eps = %s' % \
print('calendar = %s max abs err (days) = %s eps = %s' % \
(calendar,maxerr,eps))

# issue 353
Expand Down

0 comments on commit 7cad6ff

Please sign in to comment.