Skip to content

Commit

Permalink
fix(mpiarray): load zarr file into numpy view of mpiarray and include…
Browse files Browse the repository at this point in the history
… reshape order

This fix allows us to use the most recent versions of zarr
  • Loading branch information
ljgray committed Aug 1, 2024
1 parent 22e33fd commit c7f8de8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions caput/mpiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
-------
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c7f8de8

Please sign in to comment.