def test_ncGetTimeValues(self): """Test ncGetTimes returns correct time values""" ncobj = netCDF4.Dataset(self.ncfile) times = nctools.ncGetTimes(ncobj) start = datetime.strptime(ncobj.variables['time'].units, 'hours since %Y-%m-%d %H:%M:%S') t = np.array([start + timedelta(hours=t) for t in range(self.nrecs)]) self.numpyAssertEqual(t, times) ncobj.close()
def test_ncGetTimes(self): """Test ncGetTimes returns datetime objects""" ncobj = netCDF4.Dataset(self.ncfile) times = nctools.ncGetTimes(ncobj) ncobj.close() #self.assertEqual(type(times[0]), datetime) # Note: cftype.real_datetime inherits from datetime.datetime print(type(times[0])) self.assertTrue(issubclass(type(times[0]), datetime))
def test_ncGetTimes(self): """Test ncGetTimes returns datetime objects""" ncobj = netCDF4.Dataset(self.ncfile) times = nctools.ncGetTimes(ncobj) ncobj.close() self.assertEqual(type(times[0]), datetime)