Improve consistency of default engine and return memoryview instead of bytes from to_netcdf() #10656
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces two breaking changes:
engine
used byDataset.to_netcdf
andDataTree.to_netcdf
is now chosen consistently withopen_dataset
andopen_datatree
, using whichever netCDF libraries are available and valid, and preferring netCDF4 to h5netcdf to scipy. Previously,DataTree.to_netcdf
was hard-coded to use scipy for writing to file-like objects or bytes, andDataTree.to_netcdf
was hard-coded to use h5netcdf.Dataset.to_netcdf
withoutpath
is now amemoryview
object instead ofbytes
. This removes an unnecessary memory copy and ensures consistency when using eitherengine="scipy"
orengine="h5netcdf"
.It also includes a minor bug-fix, raising an error when returning a memoryview with
compute=False
Fixes #10654
whats-new.rst