From 801216c62528c4ac65a9748e258fd9d84e33be1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Wed, 18 Sep 2024 09:12:30 +0200 Subject: [PATCH] FIX: only handle enumtypes if they are available grom h5netcdf --- xarray/backends/h5netcdf_.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xarray/backends/h5netcdf_.py b/xarray/backends/h5netcdf_.py index 64a3bddefff..f7a4fff2c60 100644 --- a/xarray/backends/h5netcdf_.py +++ b/xarray/backends/h5netcdf_.py @@ -228,8 +228,6 @@ def open_store_variable(self, name, var): encoding["source"] = self._filename encoding["original_shape"] = data.shape - print("XX", var) - vlen_dtype = h5py.check_dtype(vlen=var.dtype) if vlen_dtype is str: encoding["dtype"] = str @@ -301,7 +299,8 @@ def prepare_variable( # check enum metadata and use h5netcdf.core.EnumType if ( - (meta := np.dtype(dtype).metadata) + hasattr(self.ds, "enumtypes") + and (meta := np.dtype(dtype).metadata) and (e_name := meta.get("enum_name")) and (e_dict := meta.get("enum")) ):