Skip to content

np.array on LindiH5pyDataset fails due to calling dataset.id #107

@rly

Description

@rly
import pynwb
import lindi
import numpy as np
h5_url = "https://api.dandiarchive.org/api/assets/11f512ba-5bcf-4230-a8cb-dc8d36db38cb/download/"
f = lindi.LindiH5pyFile.from_hdf5_file(h5_url)
io = pynwb.NWBHDF5IO(file=f, mode="r")
nwbfile = io.read()

nwbfile.processing["ecephys"]["LFP"]["LFP"].data # <LindiH5pyDataset: /processing/ecephys/LFP/LFP/data>
np.array(nwbfile.processing["ecephys"]["LFP"]["LFP"].data)

# Output: 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/Users/rly/miniconda3/envs/test7/lib/python3.12/site-packages/h5py/_hl/dataset.py", line 1112, in __array__
    self.read_direct(arr)
  File "/Users/rly/miniconda3/envs/test7/lib/python3.12/site-packages/h5py/_hl/dataset.py", line 1054, in read_direct
    if self._is_empty:
       ^^^^^^^^^^^^^^
  File "/Users/rly/miniconda3/envs/test7/lib/python3.12/site-packages/h5py/_hl/base.py", line 532, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
                                               ^^^^^^^^^^^^^^
  File "/Users/rly/miniconda3/envs/test7/lib/python3.12/site-packages/h5py/_hl/dataset.py", line 666, in _is_empty
    return self._extent_type == h5s.NULL
           ^^^^^^^^^^^^^^^^^
  File "/Users/rly/miniconda3/envs/test7/lib/python3.12/site-packages/h5py/_hl/base.py", line 532, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
                                               ^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/Users/rly/miniconda3/envs/test7/lib/python3.12/site-packages/h5py/_hl/dataset.py", line 661, in _extent_type
    return self.id.get_space().get_simple_extent_type()
           ^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get_space'

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