Skip to content

Commit

Permalink
revert test__num2date_to_nearest_second.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rcomer committed May 10, 2021
1 parent 7dc3c29 commit 0b89777
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions cf_units/tests/integration/test__num2date_to_nearest_second.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2016 - 2021, Met Office
# (C) British Crown Copyright 2016 - 2020, Met Office
#
# This file is part of cf-units.
#
Expand Down Expand Up @@ -32,12 +32,10 @@ def setup_units(self, calendar):
self.uhours = cftime.utime('hours since 1970-01-01', calendar)
self.udays = cftime.utime('days since 1970-01-01', calendar)

def check_dates(self, nums, utimes, expected, only_cftime=False):
def check_dates(self, nums, utimes, expected):
for num, utime, exp in zip(nums, utimes, expected):
res = _num2date_to_nearest_second(
num, utime, only_use_cftime_datetimes=only_cftime)
res = _num2date_to_nearest_second(num, utime)
self.assertEqual(exp, res)
self.assertIsInstance(res, type(exp))

def check_timedelta(self, nums, utimes, expected):
for num, utime, exp in zip(nums, utimes, expected):
Expand All @@ -53,7 +51,6 @@ def test_scalar(self):
exp = datetime.datetime(1970, 1, 1, 0, 0, 5)
res = _num2date_to_nearest_second(num, utime)
self.assertEqual(exp, res)
self.assertIsInstance(res, datetime.datetime)

def test_sequence(self):
utime = cftime.utime('seconds since 1970-01-01', 'gregorian')
Expand Down Expand Up @@ -106,27 +103,6 @@ def test_simple_gregorian(self):

self.check_dates(nums, utimes, expected)

def test_simple_gregorian_cftime_type(self):
self.setup_units('gregorian')
nums = [20., 40.,
75., 150.,
8., 16.,
300., 600.]
utimes = [self.useconds, self.useconds,
self.uminutes, self.uminutes,
self.uhours, self.uhours,
self.udays, self.udays]
expected = [cftime.DatetimeGregorian(1970, 1, 1, 0, 0, 20),
cftime.DatetimeGregorian(1970, 1, 1, 0, 0, 40),
cftime.DatetimeGregorian(1970, 1, 1, 1, 15),
cftime.DatetimeGregorian(1970, 1, 1, 2, 30),
cftime.DatetimeGregorian(1970, 1, 1, 8),
cftime.DatetimeGregorian(1970, 1, 1, 16),
cftime.DatetimeGregorian(1970, 10, 28),
cftime.DatetimeGregorian(1971, 8, 24)]

self.check_dates(nums, utimes, expected, only_cftime=True)

def test_fractional_gregorian(self):
self.setup_units('gregorian')
nums = [5./60., 10./60.,
Expand Down

0 comments on commit 0b89777

Please sign in to comment.