Skip to content

Compatibility with HDMF 5: DynamicTableRegion constructor validation breaks tests #675

@rly

Description

@rly

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_lendata=[0, 20] where 20 exceeds the table length
  • test_check_dynamic_table_region_data_validity_lt_zerodata=[-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

Metadata

Metadata

Assignees

No one assigned

    Labels

    category: bugerrors in the code or code behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions