Skip to content

Commit

Permalink
Fix scalar indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
magland committed May 9, 2024
1 parent e03bd6a commit eefdcff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lindi/LindiH5pyFile/LindiH5pyDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def dtype(self):
# but validate seems to work only when I put in vlen = bytes
#
vlen = bytes
ret = np.dtype(str(ret), metadata={'vlen': vlen})
ret = np.dtype(str(ret), metadata={'vlen': vlen}) # type: ignore
return ret

@property
Expand Down Expand Up @@ -213,7 +213,9 @@ def _get_item_for_zarr(self, zarr_array: zarr.Array, selection: Any):
# make sure selection is ()
if selection != ():
raise TypeError(f'Cannot slice a scalar dataset with {selection}')
return zarr_array[0]
# For some reason, with the newest version of zarr (2.18.0) we need to use [:][0] rather than just [0].
# Otherwise we get an error "ValueError: buffer source array is read-only"
return zarr_array[:][0]
return decode_references(zarr_array[selection])

def _get_external_hdf5_client(self, url: str) -> h5py.File:
Expand Down

0 comments on commit eefdcff

Please sign in to comment.