From c0ffd8a1f35b006ab9b5747543145706dd734f7d Mon Sep 17 00:00:00 2001 From: Liam Gray Date: Wed, 31 Jul 2024 16:00:49 -0700 Subject: [PATCH] fix(mpiarray): load zarr file into numpy view of mpiarray and include reshape order This fix allows us to use the most recent versions of zarr --- caput/mpiarray.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/caput/mpiarray.py b/caput/mpiarray.py index 8c7cc35b..830d0176 100644 --- a/caput/mpiarray.py +++ b/caput/mpiarray.py @@ -1017,7 +1017,7 @@ def from_file( fh.close() else: # If using zarr we can directly read the full dataset into the final array - dset.get_basic_selection(sel, out=dist_arr) + dset.get_basic_selection(sel, out=dist_arr.local_array) return dist_arr @@ -1308,7 +1308,7 @@ def transpose(self, *axes): return tdata - def reshape(self, *shape): + def reshape(self, *shape, order="C"): """Reshape the array. Must not attempt to reshape the distributed axis. That axis must be @@ -1318,6 +1318,11 @@ def reshape(self, *shape): ---------- shape : tuple Tuple of axis lengths. The distributed must be given `None`. + order : str + Read/write index order, ignoring memory layout of underlying array. + 'C' means C-like order, 'F' means Fortran-like order. 'A' uses Fortran + order _if_ array is Fortran-contiguous in memory, and C order otherwise. + Returns ------- @@ -1390,7 +1395,7 @@ def _check_shapes( local_shape = new_pre_shape[:new_axis] + new_post_shape # Now we actually try the resize... - new_data = self.local_array.reshape(local_shape) + new_data = self.local_array.reshape(local_shape, order=order) # ...and then construct the final MPIArray object return self.__class__._view_from_data_and_params(