From 6f14021b45d03d7a6df82b201816989b66f09835 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Mon, 22 Feb 2021 17:29:05 -0800 Subject: [PATCH] fix: only perform a view when the distributed axis has changed --- caput/mpiarray.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/caput/mpiarray.py b/caput/mpiarray.py index 14196e6b..670560c0 100644 --- a/caput/mpiarray.py +++ b/caput/mpiarray.py @@ -220,11 +220,15 @@ def __getitem__(self, slobj): index for index, sl in enumerate(slobj) if not isinstance(sl, int) ].index(self.axis) - return MPIArray.wrap( - self.array.view(np.ndarray)[slobj], - axis=dist_axis, - comm=self.array._comm, - ) + if dist_axis != self.axis: + + return MPIArray.wrap( + self.array.view(np.ndarray)[slobj], + axis=dist_axis, + comm=self.array._comm, + ) + else: + return MPIArray.wrap(self.array[slobj], axis=dist_axis, comm=self.array._comm) def __setitem__(self, slobj, value):