-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
When two DynamicTable objects have DynamicTableRegion columns pointing to each other, HDMF encounters infinite recursion when reading the file:
RecursionError: maximum recursion depth exceeded
File "hdmf/backends/hdf5/h5tools.py", line __read_ref
File "hdmf/backends/hdf5/h5tools.py", line __read_group
[... repeats infinitely ...]
Minimal example:
import tempfile
from pathlib import Path
from pynwb import NWBHDF5IO
from pynwb.testing.mock.file import mock_NWBFile
from pynwb.testing.mock.ecephys import mock_ElectrodeTable, mock_Units
nwbfile = mock_NWBFile()
mock_ElectrodeTable(n_rows=3, nwbfile=nwbfile)
mock_Units(num_units=3, nwbfile=nwbfile)
nwbfile.units.add_column(name='electrode_ref', description='Reference to electrodes', data=[0, 1, 2], table=nwbfile.electrodes)
nwbfile.electrodes.add_column(name='unit_ref', description='Reference to units', data=[[i] for i in range(3)], table=nwbfile.units)
with tempfile.TemporaryDirectory() as tmpdir:
nwb_path = Path(tmpdir) / 'test.nwb'
with NWBHDF5IO(nwb_path, 'w') as io:
io.write(nwbfile)
# This will cause RecursionError
with NWBHDF5IO(nwb_path, 'r') as io:
io.read()Writing actually works it is reading that fails as @rly mentioned.
Metadata
Metadata
Assignees
Labels
No labels