Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: prepare h5netcdf backend for (coming) change in dimension handling #6200

Merged
merged 2 commits into from Jan 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 21 additions & 5 deletions xarray/backends/h5netcdf_.py
Expand Up @@ -81,7 +81,11 @@ def _read_attributes(h5netcdf_var):


_extract_h5nc_encoding = functools.partial(
_extract_nc4_variable_encoding, lsd_okay=False, h5py_okay=True, backend="h5netcdf"
_extract_nc4_variable_encoding,
lsd_okay=False,
h5py_okay=True,
backend="h5netcdf",
unlimited_dims=None,
)


Expand Down Expand Up @@ -231,12 +235,24 @@ def get_attrs(self):
return FrozenDict(_read_attributes(self.ds))

def get_dimensions(self):
return self.ds.dimensions
if Version(h5netcdf.__version__) >= Version("0.14.0.dev0"):
return FrozenDict((k, len(v)) for k, v in self.ds.dimensions.items())
else:
return self.ds.dimensions

def get_encoding(self):
return {
"unlimited_dims": {k for k, v in self.ds.dimensions.items() if v is None}
}
if Version(h5netcdf.__version__) >= Version("0.14.0.dev0"):
return {
"unlimited_dims": {
k for k, v in self.ds.dimensions.items() if v.isunlimited()
}
}
else:
return {
"unlimited_dims": {
k for k, v in self.ds.dimensions.items() if v is None
}
}

def set_dimension(self, name, length, is_unlimited=False):
if is_unlimited:
Expand Down