Skip to content

Commit

Permalink
rollback caching
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Sep 27, 2024
1 parent 491855e commit 10784f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/nwbinspector/utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def _cache_data_retrieval_command(


def cache_data_selection(
data: Union[h5py.Dataset, zarr.Array, ArrayLike], selection: Union[slice, tuple[slice]]
data: Union[h5py.Dataset, ArrayLike], selection: Union[slice, tuple[slice]]
) -> np.ndarray:
"""Extract the selection lazily from the data object for efficient caching (most beneficial during streaming)."""
if isinstance(data, np.memmap): # np.memmap objects are not hashable - simply return the selection lazily
return data[selection]
if not (
isinstance(data, (h5py.Dataset, zarr.Array)) or isinstance(data, H5Dataset)
isinstance(data, h5py.Dataset) or isinstance(data, H5Dataset)
): # No need to attempt to cache if data is already in-memory
# Cast as numpy array for efficient fancy indexing
# Note that this technically copies the entire data, so could use more than 2x RAM for that object
Expand Down

0 comments on commit 10784f9

Please sign in to comment.