From 36b5c855bca2a0c7cc263b9f40196d04060d87dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Wed, 15 Oct 2025 17:48:58 +0200 Subject: [PATCH 1/2] fix h5netcdf backend for format=None, use same rule as netcdf4 backend --- xarray/backends/h5netcdf_.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xarray/backends/h5netcdf_.py b/xarray/backends/h5netcdf_.py index 78719960f63..8967ae97802 100644 --- a/xarray/backends/h5netcdf_.py +++ b/xarray/backends/h5netcdf_.py @@ -204,7 +204,10 @@ def open( f"{magic_number!r} is not the signature of a valid netCDF4 file" ) - if format not in [None, "NETCDF4", "NETCDF4_CLASSIC"]: + if format is None: + format = "NETCDF4" + + if format not in ["NETCDF4", "NETCDF4_CLASSIC"]: raise ValueError(f"invalid format for h5netcdf backend: {format}") kwargs = { From dc1ad57f092f90a4cc1b3255a11f629ab84d8e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Wed, 15 Oct 2025 18:01:07 +0200 Subject: [PATCH 2/2] add/fix whats-new.rst --- doc/whats-new.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index b981ae9427c..0497c4a031f 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -16,6 +16,8 @@ New Features - :py:func:`merge` and :py:func:`concat` now support :py:class:`DataTree` objects (:issue:`9790`, :issue:`9778`). By `Stephan Hoyer `_. +- 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`). + By `David Huard `_. Breaking Changes ~~~~~~~~~~~~~~~~ @@ -27,6 +29,8 @@ Deprecations Bug Fixes ~~~~~~~~~ +- Fix h5netcdf backend for format=None, use same rule as netcdf4 backend (:pull:`10859`). + By `Kai Mühlbauer `_ Documentation @@ -285,8 +289,6 @@ New Features - ``compute=False`` is now supported by :py:meth:`DataTree.to_netcdf` and :py:meth:`DataTree.to_zarr`. By `Stephan Hoyer `_. -- 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`). - By `David Huard `_. - ``open_dataset`` will now correctly infer a path ending in ``.zarr/`` as zarr By `Ian Hunt-Isaak `_.