Skip to content

Commit

Permalink
add test for issue #143
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed Mar 13, 2020
1 parent 297337d commit 9bd495c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/test_cftime.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,17 @@ def test_tz_naive(self):
d = datetime.strptime('2018-01-23 09:27:10.950000',"%Y-%m-%d %H:%M:%S.%f")
units = 'seconds since 2018-01-23 09:31:42.94'
assert(cftime.date2num(d, units) == -271.99)
# issue 143 - same answer for arrays vs scalars.
units = 'seconds since 1970-01-01 00:00:00'
times_in = [1261440000.0, 1261440001.0, 1261440002.0, 1261440003.0,
1261440004.0, 1261440005.0]
times_out1 = cftime.num2date(times_in, units)
times_out2 = []
for time_in in times_in:
times_out2.append(cftime.num2date(time_in, units))
dates1 = [str(d) for d in times_out1]
dates2 = [str(d) for d in times_out2]
assert(dates1 == dates2)

class TestDate2index(unittest.TestCase):

Expand Down Expand Up @@ -1518,6 +1529,5 @@ def test_replace_dayofyr_or_dayofwk_error(date_type, argument):
with pytest.raises(ValueError):
date_type(1, 1, 1).replace(**{argument: 3})


if __name__ == '__main__':
unittest.main()

0 comments on commit 9bd495c

Please sign in to comment.