Commit ab7eb7b6 authored by Jan Klaus Rieck's avatar Jan Klaus Rieck

test depth_ave()

parent 59ff6e25
Pipeline #3611 failed with stage
in 1 minute and 30 seconds
......@@ -133,6 +133,34 @@ ds_z_l = xr.Dataset({'dummy_0cc': (['t', 'y_c', 'x_c'], dummy_3Dt),
'e2t': (['y_c', 'x_c'], dummy_e2D),
'e3w': (['z_l', 'y_c', 'x_c'], dummy_e3D)})
ds_2d = xr.Dataset({'dummy_0cc': (['t', 'y_c', 'x_c'], dummy_3Dt),
'dummy_ccc': (['t', 'y_c', 'x_c'], dummy_3Dt),
'dummy_ccr': (['t', 'y_c', 'x_r'], dummy_3Dt),
'dummy_crc': (['t', 'y_r', 'x_c'], dummy_3Dt),
'dummy_crr': (['t', 'y_r', 'x_r'], dummy_3Dt)},
coords={'t': (['t'], t),
'y_c': (['y_c'], y_c),
'y_r': (['y_r'], y_r),
'x_c': (['x_c'], x_c),
'x_r': (['x_r'], x_r),
'depth_c': (['z_c'], depth_c),
'llat_cc': (['y_c', 'x_c'], llat_cc),
'llat_cr': (['y_c', 'x_r'], llat_cr),
'llat_rc': (['y_r', 'x_c'], llat_rc),
'llat_rr': (['y_r', 'x_r'], llat_rr),
'llon_cc': (['y_c', 'x_c'], llon_cc),
'llon_cr': (['y_c', 'x_r'], llon_cr),
'llon_rc': (['y_r', 'x_c'], llon_rc),
'llon_rr': (['y_r', 'x_r'], llon_rr),
'e1t': (['y_c', 'x_c'], dummy_e2D),
'e2t': (['y_c', 'x_c'], dummy_e2D),
'e1u': (['y_c', 'x_r'], dummy_e2D),
'e2u': (['y_c', 'x_r'], dummy_e2D),
'e1v': (['y_r', 'x_c'], dummy_e2D),
'e2v': (['y_r', 'x_c'], dummy_e2D),
'e1f': (['y_r', 'x_r'], dummy_e2D),
'e2f': (['y_r', 'x_r'], dummy_e2D)})
expected_depths = {}
expected_depths['1'] = {'z_c': 9, 'z_l': 10}
expected_depths['2'] = {'z_c': slice(17, 23, None), 'z_l': slice(18, 24, None)}
......@@ -282,7 +310,7 @@ def test_timeave(monthly):
def test_timeave_raises_keyerror():
""" Test whether timeave() raises key errorself.
""" Test whether timeave() raises key error.
ds_t_ave = ds_z_l.mean('t')
......@@ -290,6 +318,25 @@ def test_timeave_raises_keyerror():
[ds, ds_z_c, ds_z_l])
def test_depth_ave(ds):
""" Test depth_ave().
ds_d_ave = xbox.depth_ave(ds)[0]
assert 'z_c' and 'z_l' not in ds_d_ave.dims,\
'depth averaging failed'
def test_depth_ave_raises_valueerror():
""" Test whether depth_ave() raises value error.
with pytest.raises(ValueError):
[['2000-01-01', '2000-01-31'],
['2000-01-01', '2000-06-30']])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment