def test_reshape(): sa = StackedArray([da.random.random(size=(4, 4)) for _ in range(7)]) for new_shape in [(16, ), (2, 8), (4, 4), (8, 2)]: sa1 = sa.reshape(new_shape) assert sa1.shape == new_shape np.testing.assert_array_almost_equal(sa1.mean(), sa.mean(), decimal=12) np.testing.assert_array_almost_equal(sa1.std(), sa.std(), decimal=12)
def test_fallback_methods(): sa = StackedArray([da.random.random(size=(4, 4)) for x in range(7)]) assert sa.shape == sa.array.shape assert sa.chunks == sa.array.chunks for axis in [None, 0, 1]: np.testing.assert_array_almost_equal(sa.std(axis=axis), sa.array.std(axis=axis), decimal=12) np.testing.assert_array_almost_equal(sa.mean(axis=axis), sa.array.mean(axis=axis), decimal=12) np.testing.assert_array_almost_equal(sa.max(axis=axis), sa.array.max(axis=axis), decimal=12) np.testing.assert_array_almost_equal(sa.min(axis=axis), sa.array.min(axis=axis), decimal=12)