From 8b9112843aec1727a2d7eb4228b0bc34bcadd318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Sun, 17 Nov 2024 22:07:15 +0100 Subject: [PATCH] fix tests --- xarray/tests/__init__.py | 2 +- xarray/tests/test_backends.py | 2 +- xarray/tests/test_coding_times.py | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/xarray/tests/__init__.py b/xarray/tests/__init__.py index cbc142845fe..7f6cea693cf 100644 --- a/xarray/tests/__init__.py +++ b/xarray/tests/__init__.py @@ -331,7 +331,7 @@ def create_test_data( pd.date_range( "2000-01-01", periods=20, - unit="s", + unit="ns", ), ) for v, dims in sorted(_vars.items()): diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 88c3f2c0bf6..e4093213e64 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -1618,7 +1618,7 @@ def test_open_encodings(self) -> None: ds.variables["time"][:] = np.arange(10) + 4 expected = Dataset() - time = pd.date_range("1999-01-05", periods=10, unit="s") + time = pd.date_range("1999-01-05", periods=10, unit="ns") encoding = {"units": units, "dtype": np.dtype("int32")} expected["time"] = ("time", time, {}, encoding) diff --git a/xarray/tests/test_coding_times.py b/xarray/tests/test_coding_times.py index ef2eabe9551..b0b2a91e736 100644 --- a/xarray/tests/test_coding_times.py +++ b/xarray/tests/test_coding_times.py @@ -671,13 +671,12 @@ def test_cf_timedelta_2d() -> None: ["deltas", "expected"], [ (pd.to_timedelta(["1 day", "2 days"]), "days"), - (pd.to_timedelta(["1 day", "2 days"]), "days"), - (pd.to_timedelta(["1 day", "2 days"]), "days"), - (pd.to_timedelta(["1 day", "2 days"]), "days"), + (pd.to_timedelta(["1h", "1 day 1 hour"]), "hours"), + (pd.to_timedelta(["1m", "2m", np.nan]), "minutes"), + (pd.to_timedelta(["1m3s", "1m4s"]), "seconds"), ], ) def test_infer_timedelta_units(deltas, expected) -> None: - # todo: why testing, the same thing four times? assert expected == infer_timedelta_units(deltas)