Skip to content

Commit 65b220b

Browse files
committed
adapt to zarr 2.11
1 parent 018d86e commit 65b220b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/cli/test_prune.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os.path
22
import sys
33

4-
import numpy as np
54
import xarray as xr
65

76
from test.cli.helpers import CliTest
@@ -25,12 +24,24 @@ class PruneDataTest(CliTest):
2524
def setUp(self) -> None:
2625
rimraf(self.TEST_CUBE)
2726
cube = new_cube(time_periods=3,
28-
variables=dict(precipitation=np.nan,
29-
temperature=np.nan)) \
27+
variables=dict(precipitation=1.0,
28+
temperature=1.0)) \
3029
.chunk(dict(time=1, lat=90, lon=90))
3130

3231
write_cube(cube, self.TEST_CUBE, "zarr", cube_asserted=True)
3332

33+
# we need to manually edit the fill values, otherwise, as of zarr 2.11,
34+
# empty chunks are not written
35+
import json
36+
with open(f'{self.TEST_CUBE}/.zmetadata') as metadata:
37+
metadata_dict = json.load(metadata)
38+
metadata_dict['metadata']['precipitation/.zarray']['fill_value'] \
39+
= 1.0
40+
metadata_dict['metadata']['temperature/.zarray']['fill_value'] \
41+
= 1.0
42+
with open(f'{self.TEST_CUBE}/.zmetadata', 'w') as metadata:
43+
json.dump(metadata_dict, metadata)
44+
3445
def tearDown(self) -> None:
3546
rimraf(self.TEST_CUBE)
3647

0 commit comments

Comments
 (0)