Skip to content

Commit

Permalink
Partially fix LocalArray.view().
Browse files Browse the repository at this point in the history
Raise NotImplemented in a case that didn't work properly.
  • Loading branch information
bgrant committed Mar 20, 2014
1 parent 7dcaf7d commit 8ef321c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 9 additions & 4 deletions distarray/local/localarray.py
Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions distarray/local/tests/paralleltest_localarray.py
Expand Up @@ -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)
Expand Down

0 comments on commit 8ef321c

Please sign in to comment.