From 6acd346e9c17c9ba87eb2d1d7861873d5a44dcd0 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Thu, 20 Feb 2025 11:04:37 +0100 Subject: [PATCH] Align with new xarray's defaults (#141) * align with xarray new defaults * fix test --- cacholote/extra_encoders.py | 2 ++ tests/test_40_xarray_encoder.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cacholote/extra_encoders.py b/cacholote/extra_encoders.py index 603a0f1..b47d43a 100644 --- a/cacholote/extra_encoders.py +++ b/cacholote/extra_encoders.py @@ -246,6 +246,8 @@ def decode_xr_object( **{protocol: fs.storage_options for protocol in protocols}, ) as of: filename_or_obj = of.name + + kwargs.setdefault("decode_timedelta", False) if xr_type == "Dataset": return xr.open_dataset(filename_or_obj, **kwargs) return xr.open_dataarray(filename_or_obj, **kwargs) diff --git a/tests/test_40_xarray_encoder.py b/tests/test_40_xarray_encoder.py index 6cda718..606909e 100644 --- a/tests/test_40_xarray_encoder.py +++ b/tests/test_40_xarray_encoder.py @@ -21,7 +21,7 @@ def get_grib_ds() -> xr.Dataset: pytest.importorskip("cfgrib") eccodes = pytest.importorskip("eccodes") filename = pathlib.Path(eccodes.codes_samples_path()) / "GRIB2.tmpl" - ds = xr.open_dataset(filename, engine="cfgrib") + ds = xr.open_dataset(filename, engine="cfgrib", decode_timedelta=False) del ds.attrs["history"] return ds