@@ -89,7 +89,11 @@ def test_cf_datetime(num_dates, units, calendar):
8989 actual = coding .times .decode_cf_datetime (num_dates , units ,
9090 calendar )
9191
92- assert_array_equal (expected , actual )
92+ abs_diff = np .atleast_1d (abs (actual - expected )).astype (np .timedelta64 )
93+ # once we no longer support versions of netCDF4 older than 1.1.5,
94+ # we could do this check with near microsecond accuracy:
95+ # https://github.com/Unidata/netcdf4-python/issues/355
96+ assert (abs_diff <= np .timedelta64 (1 , 's' )).all ()
9397 encoded , _ , _ = coding .times .encode_cf_datetime (actual , units ,
9498 calendar )
9599 if '1-1-1' not in units :
@@ -151,7 +155,11 @@ def test_decode_cf_datetime_non_iso_strings():
151155 (np .arange (100 ), 'hours since 2000-01-01 0:00' )]
152156 for num_dates , units in cases :
153157 actual = coding .times .decode_cf_datetime (num_dates , units )
154- assert_array_equal (actual , expected )
158+ abs_diff = abs (actual - expected )
159+ # once we no longer support versions of netCDF4 older than 1.1.5,
160+ # we could do this check with near microsecond accuracy:
161+ # https://github.com/Unidata/netcdf4-python/issues/355
162+ assert (abs_diff <= np .timedelta64 (1 , 's' )).all ()
155163
156164
157165@pytest .mark .skipif (not has_cftime_or_netCDF4 , reason = 'cftime not installed' )
0 commit comments