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

improved testing of possible_grids

parent 424baeb0
Pipeline #3601 passed with stage
in 1 minute and 43 seconds
......@@ -84,6 +84,55 @@ ds = xr.Dataset({'dummy_0cc': (['t', 'y_c', 'x_c'], dummy_3Dt),
'vmask': (['z_c', 'y_r', 'x_c'], tmask),
'fmask': (['z_c', 'y_r', 'x_r'], tmask)})
ds_z_c = xr.Dataset({'dummy_0cc': (['t', 'y_c', 'x_c'], dummy_3Dt),
'dummy_ccc': (['t', 'z_c', 'y_c', 'x_c'], dummy_4D),
'dummy_ccr': (['t', 'z_c', 'y_c', 'x_r'], dummy_4D),
'dummy_crc': (['t', 'z_c', 'y_r', 'x_c'], dummy_4D),
'dummy_crr': (['t', 'z_c', 'y_r', 'x_r'], dummy_4D)},
coords={'t': (['t'], t),
'z_c': (['z_c'], z_c),
'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),
'e3t': (['z_c', 'y_c', 'x_c'], dummy_e3D),
'e1u': (['y_c', 'x_r'], dummy_e2D),
'e2u': (['y_c', 'x_r'], dummy_e2D),
'e3u': (['z_c', 'y_c', 'x_r'], dummy_e3D),
'e1v': (['y_r', 'x_c'], dummy_e2D),
'e2v': (['y_r', 'x_c'], dummy_e2D),
'e3v': (['z_c', 'y_r', 'x_c'], dummy_e3D),
'e1f': (['y_r', 'x_r'], dummy_e2D),
'e2f': (['y_r', 'x_r'], dummy_e2D),
'tmask': (['z_c', 'y_c', 'x_c'], tmask),
'umask': (['z_c', 'y_c', 'x_r'], tmask),
'vmask': (['z_c', 'y_r', 'x_c'], tmask),
'fmask': (['z_c', 'y_r', 'x_r'], tmask)})
ds_z_l = xr.Dataset({'dummy_0cc': (['t', 'y_c', 'x_c'], dummy_3Dt),
'dummy_lcc': (['t', 'z_l', 'y_c', 'x_c'], dummy_4D)},
coords={'t': (['t'], t),
'z_l': (['z_l'], z_l),
'y_c': (['y_c'], y_c),
'x_c': (['x_c'], x_c),
'depth_l': (['z_l'], depth_l),
'llat_cc': (['y_c', 'x_c'], llat_cc),
'llon_cc': (['y_c', 'x_c'], llon_cc),
'e1t': (['y_c', 'x_c'], dummy_e2D),
'e2t': (['y_c', 'x_c'], dummy_e2D),
'e3w': (['z_l', 'y_c', 'x_c'], dummy_e3D)})
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)}
......@@ -151,13 +200,24 @@ def test_checklatlon_raises_valueerror(x, y):
xbox.checklatlon(ds['llat_cc'], ds['llon_cc'], y, x)
def test_possible_grids():
@pytest.mark.parametrize('ds_in',
[ds, ds_z_c, ds_z_l])
def test_possible_grids(ds_in):
""" Test possible_grids().
"""
grids = xbox.possible_grids(ds)
grids = xbox.possible_grids(ds_in)
assert isinstance(grids, dict),\
'defining of grid dictionary failed'
if ('z_c' in ds_in.dims) and ('z_l' in ds_in.dims):
assert ('T' in grids) and ('W' in grids),\
'not all possible grids were defined'
elif ('z_c' in ds_in.dims):
assert ('T' and 'U' and 'V' and 'F' in grids),\
'not all possible grids were defined'
elif ('z_l' in ds_in.dims):
assert ('W' in grids),\
'not all possible grids were defined'
def test_inner_broadcasting_possible():
......
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