Unnamed group mixin improvements#784
Open
ehennestad wants to merge 22 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #784 +/- ##
==========================================
- Coverage 95.43% 95.18% -0.25%
==========================================
Files 228 229 +1
Lines 8064 8124 +60
==========================================
+ Hits 7696 7733 +37
- Misses 368 391 +23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f12e5db to
b9517fb
Compare
6552e99 to
fafc9bf
Compare
Contributor
|
Could use more motivation and examples |
9ad5c40 to
ea8b815
Compare
7c1e3c1 to
525159e
Compare
930c148 to
234ecdf
Compare
- Replaces the abstract protected GroupPropertyNames property with a private dependent property and a static protected method for retrieval. - Adds caching for GroupPropertyNames -Implements getGroupPropertyNamesAcrossTypeHierarchy to aggregate unnamed group property names across the class hierarchy. - Updates fillClass to generate appropriate method overrides for classes with anonymous groups or data.
Refactored the logic to add 'matnwb.mixin.HasUnnamedGroups' as a superclass by combining checks for 'hasAnonGroups' and 'hasAnonData' into a single condition.
Add methods that are present on the Set class, to support accessing Anon values from the HasUnnamedGroups mixin.
- Moved mixin setup and DynamicTable validation logic from fillBody and fillCheck into the main constructor generation flow. - Introduced isDynamicTableDescendent helper for cleaner ancestry checks. - Removed the now-redundant fillCheck function.
Fix warning suppression in sprintf statement (add escape char)
- Renamed getStaticProperties to getNonDynamicProperties with internal caching - Added isDynamicProperty helper
setupHasUnnamedGroupsMixin() was gated on a class directly declaring unnamed (anonymous/constrained) groups. Subclasses that inherit the mixin from an ancestor without declaring their own groups (e.g. DynamicTable subclasses such as Units, TimeIntervals, PlaneSegmentation) therefore never ran the setup, because the ancestor's call is guarded to execute only for the leaf class being constructed. Derive the gate from the full processed type hierarchy so the call is emitted whenever the class or any ancestor uses the mixin. Regenerate the affected core types. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Simplify, use string and shape validators to normalize input
Fix failing test. The HasUnnamedGroups mixin adds every element as a dynamic property, so the old verification is not valid anymore
Routes vectordata additions through addColumn, mirroring the existing hook in AlignedDynamicTableBase that routes category additions through addCategory. AlignedDynamicTableBase now inherits from DynamicTableBase (matching the NWB schema hierarchy) and delegates to the superclass hook before applying its own category logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
For alignedDynamicTable, display tip now recommends addCategroy and addVector
Regenerate core classes from the merged generator so the HasUnnamedGroups private-constant handling and the AlignedDynamicTable/DynamicTable base-class integration are reflected consistently in the generated +types. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The mixin work renamed the hidden TypeName property to a getTypeShortName method (in types.untyped.MetaClass), but ensureAlignedTableConsistency still referenced obj.TypeName, which no longer exists. Route it through obj.getTypeShortName(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Function was moved and generalised
53d10d0 to
fe01dd8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Background — PR #705 added
matnwb.mixin.HasUnnamedGroups, a convenience layer that lets you add, dot-access, and neatly display the members of a container's unnamed subgroup (e.g.ProcessingModule) instead of going through the rawtypes.untyped.SetAPI.Problem — For a user building a table, that convenience stopped short:
vectordatacolumns of aDynamicTable, thebaseimageset of anImages— still exposed a bare[1×1 types.untyped.Set]property with noadd, no dot-access, and no grouped display.AlignedDynamicTablealready grouped its owndynamictableset, but its empty-group hint pointed users at a genericaddmethod rather than the idiomaticaddColumn/addCategory.Solution — Extend the convenience layer to unnamed datasets and add a routing hook so
add()dispatches to each type's idiomatic method (DynamicTable→addColumn,AlignedDynamicTable→addCategory).What changed
DynamicTableandImagesnow expose their unnamed members throughadd/ dot-access / grouped display instead of a rawtypes.untyped.Setproperty.add()routes to the type-specific method:vectordataadditions go throughaddColumn, category additions throughaddCategory.AlignedDynamicTablepoints ataddColumn(for columns) andaddCategory(for category tables) instead of a genericadd.Implementation notes
matnwb.mixin.HasUnnamedGroups. The generator now applies it to types with unnamed datasets (declaringGroupPropertyNames, e.g.["vectordata"]onDynamicTable,["baseimage"]onImages) — previously only unnamed groups qualified.handleUnnamedGroupAdd(groupName, name, value)hook.matnwb.neurodata.DynamicTableBaseroutesvectordata→addColumn;matnwb.neurodata.AlignedDynamicTableBasecalls the superclass hook first, then routes category tables →addCategory.AlignedDynamicTableis the first type to inherit an unnamed group (vectordata, now onDynamicTable) while declaring its own (dynamictable).matnwb.neurodata.internal.collectConstantPropertiesAcrossHierarchygathersGroupPropertyNamesacross the class hierarchy so both groups resolve. This logic affects no pre-existing type — the two-level case only arises onceDynamicTablegains the mixin in this PR.Examples
Example 1 —
types.core.ImagesBefore — add/get go through the raw
Set:After —
add/ dot-access, grouped display:Example 2 —
types.hdmf_common.DynamicTableBefore —
vectordatais a rawSetproperty:After —
vectordatais a group,dt.add(...)routes toaddColumn:Example 3 —
types.hdmf_common.AlignedDynamicTableAn
AlignedDynamicTablehas two unnamed groups with different idiomatic add-methods.Before —
dynamictableis grouped but hints at a genericadd;vectordatais a rawSet:After — both groups shown, each with its own hint:
How to test
Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Claude Code