Skip to content

Commit c131fbf

Browse files
authored
Fix reverting default netCDF engine (and prepare 2025.10.1 release) (#10828)
* Actually revert default netCDF engine * Fix unit tests for engine * Tweak defaults again, preferring h5netcdf over scipy * Fix default netcdf engine in docstrings * update whats-new
1 parent 7659b2d commit c131fbf

File tree

7 files changed

+49
-61
lines changed

7 files changed

+49
-61
lines changed

doc/whats-new.rst

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,7 @@ What's New
77

88
.. _whats-new.2025.10.1:
99

10-
v2025.10.1 (unreleased)
11-
-----------------------
12-
13-
New Features
14-
~~~~~~~~~~~~
15-
16-
17-
Breaking changes
18-
~~~~~~~~~~~~~~~~
19-
20-
21-
Deprecations
22-
~~~~~~~~~~~~
23-
24-
25-
Bug fixes
26-
~~~~~~~~~
27-
28-
29-
Documentation
30-
~~~~~~~~~~~~~
31-
32-
33-
Internal Changes
34-
~~~~~~~~~~~~~~~~
35-
36-
37-
.. _whats-new.2025.10.0:
38-
39-
v2025.10.0 (October 6, 2025)
10+
v2025.10.1 (October 7, 2025)
4011
----------------------------
4112

4213
This release reverts a breaking change to Xarray's preferred netCDF backend.
@@ -45,14 +16,19 @@ Breaking changes
4516
~~~~~~~~~~~~~~~~
4617

4718
- Xarray's default engine for reading/writing netCDF files has been reverted to
48-
prefer netCDF4, which was the default before v2025.09.1. This change
49-
had larger implications for the ecosystem than we anticipated. We are still
50-
considering changing the default in the future, but will be a bit more careful
51-
about the implications. See :issue:`10657` and linked issues for discussion.
52-
The behavior can still be customized, e.g., with
19+
prefer netCDF4 over h5netcdf over scipy, which was the default before
20+
v2025.09.1. This change had larger implications for the ecosystem than we
21+
anticipated. We are still considering changing the default in the future, but
22+
will be a bit more careful about the implications. See :issue:`10657` and
23+
linked issues for discussion. The behavior can still be customized, e.g., with
5324
``xr.set_options(netcdf_engine_order=['h5netcdf', 'netcdf4', 'scipy'])``.
5425
By `Stephan Hoyer <https://github.com/shoyer>`_.
5526

27+
New features
28+
~~~~~~~~~~~~
29+
30+
- Coordinates are ordered to match dims when displaying Xarray objects. (:pull:`10778`).
31+
By `Julia Signell <https://github.com/jsignell>`_.
5632

5733
Bug fixes
5834
~~~~~~~~~
@@ -86,9 +62,6 @@ New Features
8662
(:pull:`10624`).
8763
By `Stephan Hoyer <https://github.com/shoyer>`_.
8864

89-
- Coordinates are ordered to match dims when displaying Xarray objects. (:pull:`10778`).
90-
By `Julia Signell <https://github.com/jsignell>`_.
91-
9265
Breaking changes
9366
~~~~~~~~~~~~~~~~
9467

xarray/backends/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def open_dataset(
416416
or subclass of xarray.backends.BackendEntrypoint, optional
417417
Engine to use when reading files. If not provided, the default engine
418418
is chosen based on available dependencies, by default preferring
419-
"h5netcdf" over "scipy" over "netcdf4" (customizable via
419+
"netcdf4" over "h5netcdf" over "scipy" (customizable via
420420
``netcdf_engine_order`` in ``xarray.set_options()``). A custom backend
421421
class (a subclass of ``BackendEntrypoint``) can also be used.
422422
chunks : int, dict, 'auto' or None, default: None
@@ -660,7 +660,7 @@ def open_dataarray(
660660
or subclass of xarray.backends.BackendEntrypoint, optional
661661
Engine to use when reading files. If not provided, the default engine
662662
is chosen based on available dependencies, by default preferring
663-
"h5netcdf" over "scipy" over "netcdf4" (customizable via
663+
"netcdf4" over "h5netcdf" over "scipy" (customizable via
664664
``netcdf_engine_order`` in ``xarray.set_options()``). A custom backend
665665
class (a subclass of ``BackendEntrypoint``) can also be used.
666666
chunks : int, dict, 'auto' or None, default: None
@@ -1450,7 +1450,7 @@ def open_mfdataset(
14501450
or subclass of xarray.backends.BackendEntrypoint, optional
14511451
Engine to use when reading files. If not provided, the default engine
14521452
is chosen based on available dependencies, by default preferring
1453-
"h5netcdf" over "scipy" over "netcdf4" (customizable via
1453+
"netcdf4" over "h5netcdf" over "scipy" (customizable via
14541454
``netcdf_engine_order`` in ``xarray.set_options()``). A custom backend
14551455
class (a subclass of ``BackendEntrypoint``) can also be used.
14561456
data_vars : {"minimal", "different", "all"} or list of str, default: "all"

xarray/backends/writers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,10 @@ def save_mfdataset(
544544
Paths to the netCDF4 group in each corresponding file to which to save
545545
datasets (only works for format="NETCDF4"). The groups will be created
546546
if necessary.
547-
engine : {"netcdf4", "scipy", "h5netcdf"}, optional
547+
engine : {"netcdf4", "h5netcdf", "scipy"}, optional
548548
Engine to use when writing netCDF files. If not provided, the
549549
default engine is chosen based on available dependencies, by default
550-
preferring "h5netcdf" over "scipy" over "netcdf4" (customizable via
550+
preferring "netcdf4" over "h5netcdf" over "scipy" (customizable via
551551
``netcdf_engine_order`` in ``xarray.set_options()``).
552552
compute : bool
553553
If true compute immediately, otherwise return a

xarray/core/dataarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4168,10 +4168,10 @@ def to_netcdf(
41684168
group : str, optional
41694169
Path to the netCDF4 group in the given file to open (only works for
41704170
format='NETCDF4'). The group(s) will be created if necessary.
4171-
engine : {"netcdf4", "scipy", "h5netcdf"}, optional
4171+
engine : {"netcdf4", "h5netcdf", "scipy"}, optional
41724172
Engine to use when writing netCDF files. If not provided, the
41734173
default engine is chosen based on available dependencies, by default
4174-
preferring "h5netcdf" over "scipy" over "netcdf4" (customizable via
4174+
preferring "netcdf4" over "h5netcdf" over "scipy" (customizable via
41754175
``netcdf_engine_order`` in ``xarray.set_options()``).
41764176
encoding : dict, optional
41774177
Nested dictionary with variable names as keys and dictionaries of

xarray/core/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,10 +2055,10 @@ def to_netcdf(
20552055
group : str, optional
20562056
Path to the netCDF4 group in the given file to open (only works for
20572057
format='NETCDF4'). The group(s) will be created if necessary.
2058-
engine : {"netcdf4", "scipy", "h5netcdf"}, optional
2058+
engine : {"netcdf4", "h5netcdf", "scipy"}, optional
20592059
Engine to use when writing netCDF files. If not provided, the
20602060
default engine is chosen based on available dependencies, by default
2061-
preferring "h5netcdf" over "scipy" over "netcdf4" (customizable via
2061+
preferring "netcdf4" over "h5netcdf" over "scipy" (customizable via
20622062
``netcdf_engine_order`` in ``xarray.set_options()``).
20632063
encoding : dict, optional
20642064
Nested dictionary with variable names as keys and dictionaries of

xarray/core/options.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class T_Options(TypedDict):
8989
"enable_cftimeindex": True,
9090
"file_cache_maxsize": 128,
9191
"keep_attrs": "default",
92-
"netcdf_engine_order": ("h5netcdf", "scipy", "netcdf4"),
92+
"netcdf_engine_order": ("netcdf4", "h5netcdf", "scipy"),
9393
"warn_for_unclosed_files": False,
9494
"use_bottleneck": True,
9595
"use_flox": True,
@@ -100,7 +100,7 @@ class T_Options(TypedDict):
100100

101101
_JOIN_OPTIONS = frozenset(["inner", "outer", "left", "right", "exact"])
102102
_DISPLAY_OPTIONS = frozenset(["text", "html"])
103-
_NETCDF_ENGINES = frozenset(["h5netcdf", "scipy", "netcdf4"])
103+
_NETCDF_ENGINES = frozenset(["netcdf4", "h5netcdf", "scipy"])
104104

105105

106106
def _positive_integer(value: Any) -> bool:
@@ -260,11 +260,11 @@ class set_options:
260260
* ``False`` : to always discard attrs
261261
* ``default`` : to use original logic that attrs should only
262262
be kept in unambiguous circumstances
263-
netcdf_engine_order : sequence, default ['h5netcdf', 'scipy', 'netcdf4']
263+
netcdf_engine_order : sequence, default ['netcdf4', 'h5netcdf', 'scipy']
264264
Preference order of backend engines to use when reading or writing
265265
netCDF files with ``open_dataset()`` and ``to_netcdf()`` if ``engine``
266266
is not explicitly specified. May be any permutation or subset of
267-
``['h5netcdf', 'scipy', 'netcdf4']``.
267+
``['netcdf4', 'h5netcdf', 'scipy']``.
268268
use_bottleneck : bool, default: True
269269
Whether to use ``bottleneck`` to accelerate 1D reductions and
270270
1D rolling reduction operations.

xarray/tests/test_backends_api.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@
2424
@requires_scipy
2525
@requires_h5netcdf
2626
def test_get_default_netcdf_write_engine() -> None:
27+
assert xr.get_options()["netcdf_engine_order"] == ("netcdf4", "h5netcdf", "scipy")
28+
2729
engine = get_default_netcdf_write_engine("", format=None)
28-
assert engine == "h5netcdf"
30+
assert engine == "netcdf4"
2931

3032
engine = get_default_netcdf_write_engine("", format="NETCDF4")
31-
assert engine == "h5netcdf"
33+
assert engine == "netcdf4"
3234

3335
engine = get_default_netcdf_write_engine("", format="NETCDF4_CLASSIC")
3436
assert engine == "netcdf4"
3537

36-
engine = get_default_netcdf_write_engine(io.BytesIO(), format="NETCDF4")
38+
engine = get_default_netcdf_write_engine("", format="NETCDF3_CLASSIC")
39+
assert engine == "netcdf4"
40+
41+
engine = get_default_netcdf_write_engine(io.BytesIO(), format=None)
3742
assert engine == "h5netcdf"
3843

39-
engine = get_default_netcdf_write_engine("", format="NETCDF3_CLASSIC")
40-
assert engine == "scipy"
44+
engine = get_default_netcdf_write_engine(io.BytesIO(), format="NETCDF4")
45+
assert engine == "h5netcdf"
4146

4247
engine = get_default_netcdf_write_engine(io.BytesIO(), format="NETCDF3_CLASSIC")
4348
assert engine == "scipy"
@@ -46,11 +51,21 @@ def test_get_default_netcdf_write_engine() -> None:
4651
assert engine == "netcdf4"
4752

4853
with xr.set_options(netcdf_engine_order=["netcdf4", "scipy", "h5netcdf"]):
54+
engine = get_default_netcdf_write_engine(io.BytesIO(), format=None)
55+
assert engine == "scipy"
56+
57+
engine = get_default_netcdf_write_engine(io.BytesIO(), format="NETCDF4")
58+
assert engine == "h5netcdf"
59+
60+
engine = get_default_netcdf_write_engine(io.BytesIO(), format="NETCDF3_CLASSIC")
61+
assert engine == "scipy"
62+
63+
with xr.set_options(netcdf_engine_order=["h5netcdf", "scipy", "netcdf4"]):
4964
engine = get_default_netcdf_write_engine("", format=None)
50-
assert engine == "netcdf4"
65+
assert engine == "h5netcdf"
5166

5267
engine = get_default_netcdf_write_engine("", format="NETCDF4")
53-
assert engine == "netcdf4"
68+
assert engine == "h5netcdf"
5469

5570
engine = get_default_netcdf_write_engine("", format="NETCDF4_CLASSIC")
5671
assert engine == "netcdf4"
@@ -59,7 +74,7 @@ def test_get_default_netcdf_write_engine() -> None:
5974
assert engine == "h5netcdf"
6075

6176
engine = get_default_netcdf_write_engine("", format="NETCDF3_CLASSIC")
62-
assert engine == "netcdf4"
77+
assert engine == "scipy"
6378

6479
engine = get_default_netcdf_write_engine(io.BytesIO(), format="NETCDF3_CLASSIC")
6580
assert engine == "scipy"
@@ -80,8 +95,8 @@ def test_default_engine_h5netcdf(monkeypatch):
8095
ValueError,
8196
match=re.escape(
8297
"cannot write NetCDF files with format='NETCDF3_CLASSIC' because "
83-
"none of the suitable backend libraries (scipy, netCDF4) are installed"
84-
),
98+
"none of the suitable backend libraries (SUITABLE_BACKENDS) are installed"
99+
).replace("SUITABLE_BACKENDS", r"(scipy, netCDF4)|(netCDF4, scipy)"),
85100
):
86101
get_default_netcdf_write_engine("", format="NETCDF3_CLASSIC")
87102

0 commit comments

Comments
 (0)