Skip to content

Commit

Permalink
FIX: only handle enumtypes if they are available grom h5netcdf
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuehlbauer committed Sep 18, 2024
1 parent 3681224 commit 801216c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
):
Expand Down

0 comments on commit 801216c

Please sign in to comment.