Skip to content

Commit

Permalink
Add new h5netcdf backend phony_dims kwarg (#3753)
Browse files Browse the repository at this point in the history
* ADD: add `phony_dims` keyword arg to h5netcdf backend available from h5netcdf v0.8.0

* ADD: add `whats-new.rst` entry

* FIX: raise ValueError

Co-authored-by: Deepak Cherian <[email protected]>
  • Loading branch information
kmuehlbauer and dcherian authored Feb 23, 2020
1 parent 66625c9 commit 24cfdd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ Breaking changes

New Features
~~~~~~~~~~~~

- Support new h5netcdf backend keyword `phony_dims` (available from h5netcdf
v0.8.0 for :py:class:`~xarray.backends.H5NetCDFStore`.
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
- implement pint support. (:issue:`3594`, :pull:`3706`)
By `Justus Magin <https://github.com/keewis>`_.


Bug fixes
~~~~~~~~~
- Use ``dask_array_type`` instead of ``dask_array.Array`` for type
Expand Down
10 changes: 10 additions & 0 deletions xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
from distutils.version import LooseVersion

import numpy as np

Expand Down Expand Up @@ -117,13 +118,22 @@ def open(
lock=None,
autoclose=False,
invalid_netcdf=None,
phony_dims=None,
):
import h5netcdf

if format not in [None, "NETCDF4"]:
raise ValueError("invalid format for h5netcdf backend")

kwargs = {"invalid_netcdf": invalid_netcdf}
if phony_dims is not None:
if LooseVersion(h5netcdf.__version__) >= LooseVersion("0.8.0"):
kwargs["phony_dims"] = phony_dims
else:
raise ValueError(
"h5netcdf backend keyword argument 'phony_dims' needs "
"h5netcdf >= 0.8.0."
)

if lock is None:
if mode == "r":
Expand Down

0 comments on commit 24cfdd2

Please sign in to comment.