diff --git a/distarray/local/localarray.py b/distarray/local/localarray.py index 1f48b1d6..5287b35f 100644 --- a/distarray/local/localarray.py +++ b/distarray/local/localarray.py @@ -273,11 +273,16 @@ def local_view(self, dtype=None): def view(self, dtype=None): if dtype is None: - new_da = LocalArray(self.global_shape, self.dtype, self.dist, - self.grid_shape, self.base_comm, buf=self.data) + new_da = self.__class__.from_dim_data(dim_data=self.dim_data, + dtype=self.dtype, + comm=self.base_comm, + buf=self.local_array) else: - new_da = LocalArray(self.global_shape, dtype, self.dist, - self.grid_shape, self.base_comm, buf=self.data) + raise_nie() + #new_da = self.__class__.from_dim_data(dim_data=self.dim_data, + # dtype=dtype, + # comm=self.base_comm, + # buf=self.local_array) return new_da def __array__(self, dtype=None): diff --git a/distarray/local/tests/paralleltest_localarray.py b/distarray/local/tests/paralleltest_localarray.py index a63aac72..7bcee160 100644 --- a/distarray/local/tests/paralleltest_localarray.py +++ b/distarray/local/tests/paralleltest_localarray.py @@ -489,6 +489,13 @@ def test_astype_cbc(self): self.assertEqual(b.dtype, new_dtype) self.assertEqual(b.local_array.dtype, new_dtype) + def test_view_bn(self): + a = LocalArray((16,16), dtype=np.int32, dist=('b', 'n'), comm=self.comm) + a.fill(11) + b = a.view() + self.assert_localarrays_allclose(a, b) + self.assertEqual(id(a.data), id(b.data)) + def test_asdist_like(self): """Test asdist_like for success and failure.""" a = LocalArray((16,16), dist=('b', 'n'), comm=self.comm)