Skip to content

Commit f1b11fc

Browse files
authored
fix h5netcdf backend for format=None, use same rule as netcdf4 backend (#10859)
* fix h5netcdf backend for format=None, use same rule as netcdf4 backend * add/fix whats-new.rst
1 parent 58f26f9 commit f1b11fc

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

doc/whats-new.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ New Features
1616
- :py:func:`merge` and :py:func:`concat` now support :py:class:`DataTree`
1717
objects (:issue:`9790`, :issue:`9778`).
1818
By `Stephan Hoyer <https://github.com/shoyer>`_.
19+
- The ``h5netcdf`` engine has support for pseudo ``NETCDF4_CLASSIC`` files, meaning variables and attributes are cast to supported types. Note that the saved files won't be recognized as genuine ``NETCDF4_CLASSIC`` files until ``h5netcdf`` adds support with version 1.7.0. (:issue:`10676`, :pull:`10686`).
20+
By `David Huard <https://github.com/huard>`_.
1921

2022
Breaking Changes
2123
~~~~~~~~~~~~~~~~
@@ -27,6 +29,8 @@ Deprecations
2729

2830
Bug Fixes
2931
~~~~~~~~~
32+
- Fix h5netcdf backend for format=None, use same rule as netcdf4 backend (:pull:`10859`).
33+
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_
3034

3135

3236
Documentation
@@ -285,8 +289,6 @@ New Features
285289
- ``compute=False`` is now supported by :py:meth:`DataTree.to_netcdf` and
286290
:py:meth:`DataTree.to_zarr`.
287291
By `Stephan Hoyer <https://github.com/shoyer>`_.
288-
- The ``h5netcdf`` engine has support for pseudo ``NETCDF4_CLASSIC`` files, meaning variables and attributes are cast to supported types. Note that the saved files won't be recognized as genuine ``NETCDF4_CLASSIC`` files until ``h5netcdf`` adds support. (:issue:`10676`, :pull:`10686`).
289-
By `David Huard <https://github.com/huard>`_.
290292
- ``open_dataset`` will now correctly infer a path ending in ``.zarr/`` as zarr
291293
By `Ian Hunt-Isaak <https://github.com/ianhi>`_.
292294

xarray/backends/h5netcdf_.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ def open(
204204
f"{magic_number!r} is not the signature of a valid netCDF4 file"
205205
)
206206

207-
if format not in [None, "NETCDF4", "NETCDF4_CLASSIC"]:
207+
if format is None:
208+
format = "NETCDF4"
209+
210+
if format not in ["NETCDF4", "NETCDF4_CLASSIC"]:
208211
raise ValueError(f"invalid format for h5netcdf backend: {format}")
209212

210213
kwargs = {

0 commit comments

Comments
 (0)