Пример #1
0
 def test_cftime_np_array(self):
     val = np.array(
         [CalendarDateTime(cftime.datetime(2012, 6, 4), '360_day')],
         dtype=np.object)
     result = NetCDFTimeConverter().convert(val, None, None)
     self.assertEqual(result, np.array([4473.]))
Пример #2
0
 def test_numeric_iterable(self):
     val = [12, 18]
     result = NetCDFTimeConverter().convert(val, None, None)
     np.testing.assert_array_equal(result, val)
Пример #3
0
 def test_cftime(self):
     val = CalendarDateTime(cftime.datetime(2014, 8, 12), '365_day')
     result = NetCDFTimeConverter().convert(val, None, None)
     np.testing.assert_array_equal(result, 5333.)
Пример #4
0
 def test_numpy_nd_array(self):
     shape = (4, 2)
     val = np.arange(8).reshape(shape)
     result = NetCDFTimeConverter().convert(val, None, None)
     np.testing.assert_array_equal(result, val)
     self.assertEqual(result.shape, shape)
Пример #5
0
 def test_numpy_array(self):
     val = np.array([7])
     result = NetCDFTimeConverter().convert(val, None, None)
     np.testing.assert_array_equal(result, val)
Пример #6
0
 def test_360_day_calendar_list(self):
     calendar = '360_day'
     unit = 'days since 2000-01-01'
     val = [CalendarDateTime(cftime.datetime(2014, 8, 12), calendar)]
     result = NetCDFTimeConverter().default_units(val, None)
     self.assertEqual(result, (calendar, unit))
Пример #7
0
 def test_non_CalendarDateTime(self):
     val = cftime.datetime(1988, 5, 6)
     msg = 'The values must be numbers or instances of ' \
           '"nc_time_axis.CalendarDateTime".'
     with assertRaisesRegex(self, ValueError, msg):
         result = NetCDFTimeConverter().convert(val, None, None)
Пример #8
0
 def test_non_cftime_datetime(self):
     val = CalendarDateTime(4, '360_day')
     msg = 'The datetime attribute of the CalendarDateTime object must ' \
           'be of type `cftime.datetime`.'
     with assertRaisesRegex(self, ValueError, msg):
         result = NetCDFTimeConverter().convert(val, None, None)