Skip to content

Commit 2f7af43

Browse files
committed
FIX: only handle enumtypes if they are available grom h5netcdf
1 parent ec83935 commit 2f7af43

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

xarray/backends/h5netcdf_.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ def open_store_variable(self, name, var):
228228
encoding["source"] = self._filename
229229
encoding["original_shape"] = data.shape
230230

231-
print("XX", var)
232-
233231
vlen_dtype = h5py.check_dtype(vlen=var.dtype)
234232
if vlen_dtype is str:
235233
encoding["dtype"] = str
@@ -301,7 +299,8 @@ def prepare_variable(
301299

302300
# check enum metadata and use h5netcdf.core.EnumType
303301
if (
304-
(meta := np.dtype(dtype).metadata)
302+
hasattr(self.ds, "enumtypes")
303+
and (meta := np.dtype(dtype).metadata)
305304
and (e_name := meta.get("enum_name"))
306305
and (e_dict := meta.get("enum"))
307306
):

0 commit comments

Comments
 (0)