def test_reshape(): array = ImmutableDenseNDimArray(range(50), 50) assert array.shape == (50,) assert array.rank() == 1 array = array.reshape(5, 5, 2) assert array.shape == (5, 5, 2) assert array.rank() == 3 assert len(array) == 50 pytest.raises(ValueError, lambda: array.reshape(1, 1))
def test_iterator(): array = ImmutableDenseNDimArray(range(4), (2, 2)) j = 0 for i in array: assert i == j j += 1 array = array.reshape(4) j = 0 for i in array: assert i == j j += 1