Skip to content

Commit 1b60ad0

Browse files
committed
Adding local_slice method
1 parent 7b094f1 commit 1b60ad0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mpi4py_fft/distributedarray.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ def __new__(cls, global_shape, subcomm=None, val=0, dtype=np.float,
5555
obj.global_shape = global_shape
5656
return obj
5757

58-
def alignment(self):
59-
return self.p0.axis
60-
6158
def __array_finalize__(self, obj):
6259
if obj is None:
6360
return
6461
self.p0 = getattr(obj, 'p0', None)
6562
self.global_shape = getattr(obj, 'global_shape', None)
6663

64+
def alignment(self):
65+
return self.p0.axis
66+
67+
def local_slice(self):
68+
return [slice(start, start+shape) for start, shape in zip(self.p0.substart,
69+
self.p0.subshape)]
70+
6771
def redistribute(self, axis):
6872
"""Global redistribution of array into alignment in ``axis``
6973

0 commit comments

Comments
 (0)