@@ -5663,12 +5663,14 @@ def test_write_file_from_np_str(str_type, tmpdir) -> None:
5663
5663
@requires_zarr
5664
5664
@requires_netCDF4
5665
5665
class TestNCZarr :
5666
- @staticmethod
5667
- def _create_nczarr (filename ):
5668
- netcdfc_version = Version (nc4 .getlibversion ().split ()[0 ])
5669
- if netcdfc_version < Version ("4.8.1" ):
5666
+ @property
5667
+ def netcdfc_version (self ):
5668
+ return Version (nc4 .getlibversion ().split ()[0 ])
5669
+
5670
+ def _create_nczarr (self , filename ):
5671
+ if self .netcdfc_version < Version ("4.8.1" ):
5670
5672
pytest .skip ("requires netcdf-c>=4.8.1" )
5671
- if ( platform .system () == "Windows" ) and ( netcdfc_version == Version ("4.8.1" ) ):
5673
+ if platform .system () == "Windows" and self . netcdfc_version == Version ("4.8.1" ):
5672
5674
# Bug in netcdf-c==4.8.1 (typo: Nan instead of NaN)
5673
5675
# https://github.com/Unidata/netcdf-c/issues/2265
5674
5676
pytest .skip ("netcdf-c==4.8.1 has issues on Windows" )
@@ -5678,9 +5680,7 @@ def _create_nczarr(filename):
5678
5680
# https://github.com/Unidata/netcdf-c/issues/2259
5679
5681
ds = ds .drop_vars ("dim3" )
5680
5682
5681
- # netcdf-c>4.8.1 will add _ARRAY_DIMENSIONS by default
5682
- mode = "nczarr" if netcdfc_version == Version ("4.8.1" ) else "nczarr,noxarray"
5683
- ds .to_netcdf (f"file://{ filename } #mode={ mode } " )
5683
+ ds .to_netcdf (f"file://{ filename } #mode=nczarr" )
5684
5684
return ds
5685
5685
5686
5686
def test_open_nczarr (self ) -> None :
@@ -5700,6 +5700,9 @@ def test_overwriting_nczarr(self) -> None:
5700
5700
@pytest .mark .parametrize ("mode" , ["a" , "r+" ])
5701
5701
@pytest .mark .filterwarnings ("ignore:.*non-consolidated metadata.*" )
5702
5702
def test_raise_writing_to_nczarr (self , mode ) -> None :
5703
+ if self .netcdfc_version > Version ("4.8.1" ):
5704
+ pytest .skip ("netcdf-c>4.8.1 adds the _ARRAY_DIMENSIONS attribute" )
5705
+
5703
5706
with create_tmp_file (suffix = ".zarr" ) as tmp :
5704
5707
ds = self ._create_nczarr (tmp )
5705
5708
with pytest .raises (
0 commit comments