Add AlignedDynamicTable non-generated base class with category table validation#837
Conversation
|
What would be the warning with the old syntax? |
ic_rec_table = types.core.IntracellularRecordingsTable( ...
'categories', {'electrodes', 'stimuli', 'responses'}, ...
'colnames', {'recordings_tag'}, ...
'description', [ ...
'A table to group together a stimulus and response from a single ', ...
'electrode and a single simultaneous recording and for storing ', ...
'metadata about the intracellular recording.'], ...
'id', types.hdmf_common.ElementIdentifiers('data', int64([0; 1; 2])), ...
'recordings_tag', types.hdmf_common.VectorData( ...
'data', repmat({'Tag'}, 3, 1), ...
'description', 'Column for storing a custom recordings tag' ...
) ...
);Current warning: Maybe a better version: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #837 +/- ##
==========================================
+ Coverage 95.33% 95.43% +0.10%
==========================================
Files 226 228 +2
Lines 7821 8064 +243
==========================================
+ Hits 7456 7696 +240
- Misses 365 368 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b6fb4bc to
3b9944c
Compare
Introduce matnwb.neurodata.AlignedDynamicTableBase, the non-generated base class that owns aligned-table behavior the generated schema class cannot express: category table registration and lookup, category-name validation, and row-height consistency between the parent table and its category tables. It extends DynamicTableBase so aligned tables inherit the shared DynamicTable behavior. Add matnwb.neurodata.internal.collectConstantPropertiesAcrossHierarchy, used to gather schema-declared categories across the class hierarchy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
getTableHeight now also reports whether the table height is established, getColumnHeight accounts for unbound DataPipe offsets, and initDynamicTableId fills an existing but empty id column. These helpers back the row-height consistency checks used by both DynamicTable and AlignedDynamicTable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Attach matnwb.neurodata.AlignedDynamicTableBase to AlignedDynamicTable via the customBaseClasses map and emit its schema-declared category constant block. Route aligned tables through obj.ensureAlignedTableConsistency() in the constructor and custom-constraint hooks, and register schema-defined category properties with post-set hooks. Replace file.isDynamicTableDescendant with the more general file.internal.isDescendantOf. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
AlignedDynamicTable inherits matnwb.neurodata.AlignedDynamicTableBase and gains its DeclaredSchemaCategories constant and category post-set hooks; IntracellularRecordingsTable, an AlignedDynamicTable descendant, is regenerated accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add system tests for AlignedDynamicTable category construction and a DynamicTable test factory double, plus unit coverage for the refined height and id helpers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Use addCategory to add custom category table
3b9944c to
e5b48fd
Compare
Pull request was converted to draft
|
Warning: The categories property lists category table(s) that have not been added to the IntracellularRecordingsTable: electrodes, stimuli, responses. Add the missing table(s) with the IntracellularRecordingsTable.addCategory method before exporting. |
…thub.com/NeurodataWithoutBorders/matnwb into codex/aligned-dynamic-table-add-category
…thub.com/NeurodataWithoutBorders/matnwb into codex/aligned-dynamic-table-add-category
Warning is updated to that text here: 7f3bb6a |
Depends on #836 — merge that first - mergedMotivation
The
AlignedDynamicTableschema defines two requirements in docstrings that cannot be enforced by the generated class alone:AlignedDynamicTable"MUST have the same number of rows" (source).categoriesproperty MUST match the names of category tables in theAlignedDynamicTable(source).Without additional runtime validation, users can create invalid NWB files when using
AlignedDynamicTableor its subtypes.This PR adds validation hooks for
AlignedDynamicTablethrough a custom base class. It also adds convenience APIs so valid tables are easier to construct: schema-defined category tables auto-register incategorieswhen assigned, and custom category tables can be added withaddCategory(name, table).This PR stacks on #836 and uses its schema validation reporting context to maintain backwards-compatibility by making
AlignedDynamicTablevalidation on construction warn instead of error to ensure pre-PRicephystutorial examples can still run without breaking.Example usage (updated snippets from icephys tutorial)
1.
categoriesdo not need to be listed when the table is initialized with rows — assigning a category table later registers it automatically:2. Use
addCategoryfor custom categories instead of the manual two-step:How to test the behavior?
runtests('+tests/+system/AlignedDynamicTableTest.m')Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Codex