Description
HDMF 5 added constructor-time validation for DynamicTableRegion that checks all index values in data are valid row indices for the referenced table. When creating new objects (not reading from file), an IndexError is now raised if any index is out of bounds. When reading from file (construct mode), only a warning is issued to maintain backwards compatibility.
This breaks two NWB Inspector tests that intentionally create invalid DynamicTableRegion objects to test the inspector's own validation:
test_check_dynamic_table_region_data_validity_gt_len — data=[0, 20] where 20 exceeds the table length
test_check_dynamic_table_region_data_validity_lt_zero — data=[-1, 0] where -1 is negative
With HDMF 4, creating these invalid objects was allowed, and NWB Inspector would catch the bad data. With HDMF 5, HDMF itself prevents creating these invalid objects, so the tests fail during setup before the inspector checks can run.
Traceback
E IndexError: DynamicTableRegion values [20] are out of bounds for <class 'hdmf.common.table.DynamicTable'> 'test_table'.
E IndexError: DynamicTableRegion values [-1] are out of bounds for <class 'hdmf.common.table.DynamicTable'> 'test_table'.
Suggested fix
The tests should create the invalid DynamicTableRegion objects by bypassing HDMF's constructor validation (e.g., writing invalid data to an NWB file and reading it back, or constructing the object in construct mode). HDMF only warns (rather than raising) when reading from file, so the inspector checks are still useful in that context — which is the real-world scenario the inspector is designed for.
Related
Description
HDMF 5 added constructor-time validation for
DynamicTableRegionthat checks all index values indataare valid row indices for the referencedtable. When creating new objects (not reading from file), anIndexErroris now raised if any index is out of bounds. When reading from file (construct mode), only a warning is issued to maintain backwards compatibility.This breaks two NWB Inspector tests that intentionally create invalid
DynamicTableRegionobjects to test the inspector's own validation:test_check_dynamic_table_region_data_validity_gt_len—data=[0, 20]where20exceeds the table lengthtest_check_dynamic_table_region_data_validity_lt_zero—data=[-1, 0]where-1is negativeWith HDMF 4, creating these invalid objects was allowed, and NWB Inspector would catch the bad data. With HDMF 5, HDMF itself prevents creating these invalid objects, so the tests fail during setup before the inspector checks can run.
Traceback
Suggested fix
The tests should create the invalid
DynamicTableRegionobjects by bypassing HDMF's constructor validation (e.g., writing invalid data to an NWB file and reading it back, or constructing the object in construct mode). HDMF only warns (rather than raising) when reading from file, so the inspector checks are still useful in that context — which is the real-world scenario the inspector is designed for.Related