From e2981d34735803c0a29656f7f49352375fa77eb6 Mon Sep 17 00:00:00 2001 From: Illviljan <14371165+Illviljan@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:08:43 +0200 Subject: [PATCH] Use assert_duckarray_allclose instead of rounding the array (#9313) * Cleanup test_coding_times * Update test_coding_times.py * Update test_coding_times.py * Update test_coding_times.py --- xarray/tests/test_coding_times.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/tests/test_coding_times.py b/xarray/tests/test_coding_times.py index ef478af8786..9d048a2230c 100644 --- a/xarray/tests/test_coding_times.py +++ b/xarray/tests/test_coding_times.py @@ -146,14 +146,14 @@ def test_cf_datetime(num_dates, units, calendar) -> None: # https://github.com/Unidata/netcdf4-python/issues/355 assert (abs_diff <= np.timedelta64(1, "s")).all() encoded1, _, _ = encode_cf_datetime(actual, units, calendar) - assert_array_equal(num_dates, np.around(encoded1, 1)) + assert_duckarray_allclose(num_dates, encoded1) if hasattr(num_dates, "ndim") and num_dates.ndim == 1 and "1000" not in units: # verify that wrapping with a pandas.Index works # note that it *does not* currently work to put # non-datetime64 compatible dates into a pandas.Index encoded2, _, _ = encode_cf_datetime(pd.Index(actual), units, calendar) - assert_array_equal(num_dates, np.around(encoded2, 1)) + assert_duckarray_allclose(num_dates, encoded2) @requires_cftime