test_xr_interface.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:xarray-simlab 作者: benbovy 项目源码 文件源码
def test_snapshot_to_xarray_variable(self, ds_model_interface):
        ds_model_interface.init_snapshots()
        ds_model_interface.set_model_inputs(ds_model_interface.dataset)
        ds_model_interface.model.initialize()

        ds_model_interface.take_snapshots(0)

        expected = xr.Variable('x', np.zeros(10),
                               {'description': 'a quantity'})
        actual = ds_model_interface.snapshot_to_xarray_variable(
            ('quantity', 'quantity'), clock='clock')
        xr.testing.assert_identical(actual, expected)

        ds_model_interface.take_snapshots(-1)

        expected = xr.Variable(('clock', 'x'), np.zeros((2, 10)))
        actual = ds_model_interface.snapshot_to_xarray_variable(
            ('quantity', 'quantity'), clock='clock')
        xr.testing.assert_equal(actual, expected)

        expected = xr.Variable('x', np.arange(10))
        actual = ds_model_interface.snapshot_to_xarray_variable(('grid', 'x'))
        xr.testing.assert_equal(actual, expected)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号