This repository was archived by the owner on Oct 24, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +16
-3
lines changed
Expand file tree Collapse file tree 4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -11,4 +11,5 @@ dependencies:
1111 - black
1212 - codecov
1313 - pytest-cov
14+ - h5netcdf
1415 - zarr
Original file line number Diff line number Diff line change @@ -33,12 +33,12 @@ def _get_nc_dataset_class(engine):
3333 if engine == "netcdf4" :
3434 from netCDF4 import Dataset
3535 elif engine == "h5netcdf" :
36- from h5netcdf import Dataset
36+ from h5netcdf . legacyapi import Dataset
3737 elif engine is None :
3838 try :
3939 from netCDF4 import Dataset
4040 except ImportError :
41- from h5netcdf import Dataset
41+ from h5netcdf . legacyapi import Dataset
4242 else :
4343 raise ValueError (f"unsupported engine: { engine } " )
4444 return Dataset
Original file line number Diff line number Diff line change @@ -25,4 +25,5 @@ def LooseVersion(vstring):
2525
2626
2727has_zarr , requires_zarr = _importorskip ("zarr" )
28+ has_h5netcdf , requires_h5netcdf = _importorskip ("h5netcdf" )
2829has_netCDF4 , requires_netCDF4 = _importorskip ("netCDF4" )
Original file line number Diff line number Diff line change 66from datatree import DataTree
77from datatree .io import open_datatree
88from datatree .testing import assert_equal
9- from datatree .tests import requires_netCDF4 , requires_zarr
9+ from datatree .tests import requires_h5netcdf , requires_netCDF4 , requires_zarr
1010
1111
1212def create_test_datatree (modify = lambda ds : ds ):
@@ -340,6 +340,17 @@ def test_to_netcdf(self, tmpdir):
340340 roundtrip_dt = open_datatree (filepath )
341341 assert_equal (original_dt , roundtrip_dt )
342342
343+ @requires_h5netcdf
344+ def test_to_h5netcdf (self , tmpdir ):
345+ filepath = str (
346+ tmpdir / "test.nc"
347+ ) # casting to str avoids a pathlib bug in xarray
348+ original_dt = create_test_datatree ()
349+ original_dt .to_netcdf (filepath , engine = "h5netcdf" )
350+
351+ roundtrip_dt = open_datatree (filepath )
352+ assert_equal (original_dt , roundtrip_dt )
353+
343354 @requires_zarr
344355 def test_to_zarr (self , tmpdir ):
345356 filepath = str (
You can’t perform that action at this time.
0 commit comments