Skip to content

Commit 3bc1314

Browse files
committed
Updated with recursive test separately
1 parent d4763a1 commit 3bc1314

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

tests/test_active.py

+43-6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,47 @@ def test_active():
55

66
path_to_active = f'tests/rain_test.nc'
77

8+
try:
9+
ds = xr.open_dataset(
10+
path_to_active,
11+
engine='Active',
12+
active_options={})#{'chunks':{'time':2}})
13+
except Exception as err:
14+
assert isinstance(err, NotImplementedError)
15+
16+
ds = xr.open_dataset(
17+
path_to_active,
18+
engine='Active',
19+
active_options={'chunks':{'time':2}})
20+
21+
assert 'p' in ds
22+
assert ds['p'].shape == (20, 180, 360)
23+
24+
p_sel = ds['p'].isel(time=slice(0,3),latitude=slice(140,145), longitude=slice(90,100))
25+
26+
assert p_sel.shape == (3, 5, 10)
27+
28+
p_value = p_sel.mean()
29+
30+
assert p_value.shape == ()
31+
assert (p_value.to_numpy() - 0.53279) < 0.01
32+
33+
def test_active_recursive():
34+
35+
path_to_active = f'tests/rain_test.nc'
36+
37+
try:
38+
ds = xr.open_dataset(
39+
path_to_active,
40+
engine='Active',
41+
active_options={})#{'chunks':{'time':2}})
42+
except Exception as err:
43+
assert isinstance(err, NotImplementedError)
44+
845
ds = xr.open_dataset(
9-
path_to_active,
10-
engine='Active',
11-
active_options={})
46+
path_to_active,
47+
engine='Active',
48+
active_options={'chunks':{'time':2}})
1249

1350
assert 'p' in ds
1451
assert ds['p'].shape == (20, 180, 360)
@@ -22,7 +59,7 @@ def test_active():
2259
assert p_mean.shape == (5, 10)
2360
assert (p_mean[0][0].to_numpy() - 0.683402) < 0.01
2461

25-
p_value = p_sel.mean()
62+
if __name__ == '__main__':
63+
test_active()
2664

27-
assert p_value.shape == ()
28-
assert (p_value.to_numpy() - 0.53279) < 0.01
65+
test_active_recursive()

0 commit comments

Comments
 (0)