Example #1
0
 def test_gregorian_calendar_conversion_setup(self):
     # Reproduces a situation where a unit's gregorian calendar would not
     # match (using the `is` operator) to the literal string 'gregorian',
     # causing an `is not` test to return a false negative.
     cal_str = iris.unit.CALENDAR_GREGORIAN
     calendar = self.MyStr(cal_str)
     self.assertIsNot(calendar, cal_str)
     u1 = Unit('hours since 1970-01-01 00:00:00', calendar=calendar)
     u2 = Unit('hours since 1969-11-30 00:00:00', calendar=calendar)
     u1point = np.array([8.], dtype=np.float32)
     expected = np.array([776.], dtype=np.float32)
     result = u1.convert(u1point, u2)
     return expected, result
Example #2
0
 def test_gregorian_calendar_conversion_setup(self):
     # Reproduces a situation where a unit's gregorian calendar would not
     # match (using the `is` operator) to the literal string 'gregorian',
     # causing an `is not` test to return a false negative.
     cal_str = iris.unit.CALENDAR_GREGORIAN
     calendar = self.MyStr(cal_str)
     self.assertIsNot(calendar, cal_str)
     u1 = Unit('hours since 1970-01-01 00:00:00', calendar=calendar)
     u2 = Unit('hours since 1969-11-30 00:00:00', calendar=calendar)
     u1point = np.array([8.], dtype=np.float32)
     expected = np.array([776.], dtype=np.float32)
     result = u1.convert(u1point, u2)
     return expected, result
Example #3
0
 def test_non_gregorian_calendar_conversion_dtype(self):
     data = np.arange(4, dtype=np.float32)
     u1 = Unit('hours since 2000-01-01 00:00:00', calendar='360_day')
     u2 = Unit('hours since 2000-01-02 00:00:00', calendar='360_day')
     result = u1.convert(data, u2)
     self.assertEqual(result.dtype, np.float32)
Example #4
0
 def test_non_gregorian_calendar_conversion_dtype(self):
     data = np.arange(4, dtype=np.float32)
     u1 = Unit('hours since 2000-01-01 00:00:00', calendar='360_day')
     u2 = Unit('hours since 2000-01-02 00:00:00', calendar='360_day')
     result = u1.convert(data, u2)
     self.assertEqual(result.dtype, np.float32)