Commit 1b9f64a2 authored by Jan Klaus Rieck's avatar Jan Klaus Rieck

test depthsum()

parent 6cbaec1c
Pipeline #3640 failed with stage
in 1 minute and 38 seconds
......@@ -487,7 +487,7 @@ def depthave(ds, std_count=False):
+ ' vertical average!')
for gr in grids:
grid = grids[gr]
if ('z_c' in ds.dims) ^ ('z_l' in ds.dims):
if ('z_c' in ds.dims) or ('z_l' in ds.dims):
argu = {'dim': grid['z'], 'skipna': True, 'keep_attrs': True}
arg_count = {'dim': grid['z'], 'keep_attrs': True}
elif ('z_c' in ds.dims) and ('z_l' in ds.dims):
......
......@@ -330,12 +330,12 @@ def test_timesum(monthly):
def test_timesum_raises_keyerror():
""" Test whether timeave() raises key error.
""" Test whether timesum() raises key error.
"""
ds_t_sum = ds_z_l.sum('t')
with pytest.raises(KeyError):
xbox.timeave(ds_t_sum)
xbox.timesum(ds_t_sum)
@pytest.mark.parametrize('ds',
......@@ -359,6 +359,27 @@ def test_depthave_raises_valueerror():
xbox.depthave(ds_2d)
@pytest.mark.parametrize('ds',
[ds, ds_z_c])
def test_depthsum(ds):
""" Test depthsum().
"""
ds_box = xbox.getbox(ds, time=['2000-01-01', '2000-06-30'],
depth=[500, 1000], x=[10, 20], y=[0, 40])
ds_d_sum = xbox.depthsum(ds_box)[0]
assert 'z_c' and 'z_l' not in ds_d_sum.dims,\
'depth summing failed'
def test_depthsum_raises_valueerror():
""" Test whether depthsum() raises value error.
"""
with pytest.raises(ValueError):
xbox.depthsum(ds_2d)
@pytest.mark.parametrize('time',
[['2000-01-01', '2000-01-31'],
['2000-01-01', '2000-06-30']])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment