def test_snapshot_vars(self, model):
ds = xr.Dataset()
ds['clock'] = ('clock', [0, 2, 4, 6, 8],
{self._clock_key: 1, self._master_clock_key: 1})
ds['snap_clock'] = ('snap_clock', [0, 4, 8], {self._clock_key: 1})
# snapshot clock with no snapshot variable (attribute) set
ds['snap_clock2'] = ('snap_clock2', [0, 8], {self._clock_key: 1})
ds.xsimlab._set_snapshot_vars(model, None, grid='x')
ds.xsimlab._set_snapshot_vars(model, 'clock', quantity='quantity')
ds.xsimlab._set_snapshot_vars(model, 'snap_clock',
other_process=('other_effect', 'x2'))
expected = {None: set([('grid', 'x')]),
'clock': set([('quantity', 'quantity')]),
'snap_clock': set([('other_process', 'other_effect'),
('other_process', 'x2')])}
actual = {k: set(v) for k, v in ds.xsimlab.snapshot_vars.items()}
assert actual == expected
评论列表
文章目录