Skip to content

Error slicing LindiH5pyDataset with compound dtype #112

@stephprince

Description

@stephprince

I get a TypeError: Compound dataset /processing/optotagging/optogenetic_stimulation/timeseries does not support selection with slice(None, None, None) when attempting to get the html representation of a DynamicTable with a compound dtype when using Lindi. Using the local NWB file or streaming with remfile causes no error.

I think an additional case may need to be added for indexing into a LindiH5pyDataset with compound dtype using None values.

Code to reproduce:

import pynwb
import lindi
import remfile
import h5py

# load from remote nwb file
file = remfile.File("https://dandiarchive.s3.amazonaws.com/blobs/d5f/747/d5f74779-e41e-43af-b32c-1310e996a623")
f = h5py.File(file, 'r')
nwbfile = pynwb.NWBHDF5IO(file=f, mode='r').read()

stim_table = nwbfile.processing["optotagging"]["optogenetic_stimulation"]
stim_table._repr_html_()  # this works

# load from lindi file (same file as above, though any ogen nwbfile in dandiset 000253 should reproduce)
f = lindi.LindiH5pyFile.from_lindi_file("https://lindi.neurosift.org/dandi/dandisets/000253/assets/b305ccec-fa84-445e-aea5-0126d6eff558/nwb.lindi.json")
nwbfile = pynwb.NWBHDF5IO(file=f, mode='r').read()

stim_table = nwbfile.processing["optotagging"]["optogenetic_stimulation"]
stim_table._repr_html_()  # this errors

Traceback:

  File "/Users/smprince/Documents/code/Hippie/scratch.py", line 16, in <module>
    stim_table._repr_html_()
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/common/table.py", line 1279, in _repr_html_
    html_repr += self.generate_html_repr()
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/common/table.py", line 1289, in generate_html_repr
    inside = f"{self[:min(nrows, len(self))].to_html()}"
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/common/table.py", line 1011, in __getitem__
    ret = self.get(key)
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/common/table.py", line 1069, in get
    sel = self.__get_selection_as_dict(key, df, index, **kwargs)
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/common/table.py", line 1107, in __get_selection_as_dict
    ret[name] = col.get(arg, df=df, index=index, **kwargs)
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/common/table.py", line 211, in get
    data = self.target.get(slice(None),  **kwargs)
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/pynwb/base.py", line 797, in get
    vals = super().get(key)
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/common/table.py", line 61, in get
    return super().get(key)
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/container.py", line 982, in get
    return self.data[args]
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/backends/hdf5/h5_utils.py", line 231, in __getitem__
    rows = copy(super().__getitem__(arg))
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/hdmf/query.py", line 20, in __getitem__
    return self.dataset[idx]
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/lindi/LindiH5pyFile/LindiH5pyDataset.py", line 180, in __getitem__
    return self._get_item_for_zarr(self._zarr_array, args)
  File "/Users/smprince/anaconda3/envs/hippie/lib/python3.10/site-packages/lindi/LindiH5pyFile/LindiH5pyDataset.py", line 217, in _get_item_for_zarr
    raise TypeError(
TypeError: Compound dataset /processing/optotagging/optogenetic_stimulation/timeseries does not support selection with slice(None, None, None)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions