fix: remove VectorData unit generation patch#823
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #823 +/- ##
==========================================
- Coverage 95.42% 95.41% -0.01%
==========================================
Files 215 215
Lines 7648 7632 -16
==========================================
- Hits 7298 7282 -16
Misses 350 350 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Removes MatNWB’s legacy, schema-injecting VectorData.unit compatibility patch to prevent property redefinition conflicts in NWB schema 2.10+ (e.g., TimestampVectorData.unit), while relying on the schema-driven promoted Units.*_unit API introduced in #797.
Changes:
- Removed the hidden read-only
unit="volts"injection fromtypes.hdmf_common.VectorData(constructor parsing and export-conditional attribute write). - Removed generator-side
VectorData.unitpatching and related export/hidden-property special-casing. - Added a unit test asserting
VectorDatano longer hasunit, whilesampling_rate/resolutionremain andUnitsexposeswaveform_*_unitpromoted properties.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
+types/+hdmf_common/VectorData.m |
Drops the generated hidden unit property and stops writing /unit on export. |
+tests/+unit/+file/VectorDataPatchTest.m |
Adds coverage ensuring unit is not injected into VectorData and promoted Units unit properties exist. |
+file/processClass.m |
Removes the generator patch that injected the unit attribute into VectorData. |
+file/fillExport.m |
Removes VectorData-specific unit export conditional generation. |
+file/fillClass.m |
Stops treating unit as a special hidden VectorData property during class generation. |
+file/+internal/isPropertyHidden.m |
Stops hiding unit for VectorData in generator internals. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ch' into codex/remove-vectordata-unit-patch
|
Just realised that The drawback is that existing(?) code relying on setting the resolution of The property was already hidden and the syntax was not described in any tutorials, so I expect the number of affected users would be very small. Would appreciate your input! |
Motivation
NWB schema 2.10 introduces
types.core.TimestampVectorData.unit(andtypes.core.DurationVectorData.unit) with fixed valueseconds. MatNWB currently injects a hiddenunit = "volts"property onto thetypes.hdmf_common.VectorDataclass as an olderUnits-table compatibility patch.The current type generation pipeline now generates an invalid
TimestampVectorDataclass definition under NWB schema2.10.0, because a property (unitin this case) can not be defined on both a subclass (TimestampVectorData) and a superclass (VectorData).This PR fixes that by removing the hidden
unitsproperty from theVectorDataclass.What changed
unitsproperty compatibility patch when generatingVectorDataclassUnitscompatibility backfill that copied nestedVectorData.unitvalues into promoted*_unitproperties, e.g.obj.waveforms.unitintoobj.waveforms_unitAdditional details
The Units-table compatibility patch creates
unit,sampling_rateandresolutionas hidden properties on theVectorDataclass in order to assign those properties toVectorDatafor thewaveform_mean,waveform_sd,waveformscolumns of aUnitstable.This PR removes only the global
VectorData.unitpatch. Units-table waveform unit attributes are already handled by the schema-driven promoted-container API recently added in #797 (waveform_mean_unit,waveform_sd_unit, andwaveforms_unit), so MatNWB no longer needs to leakunitonto allVectorDatasubclasses.We could also remove the compatibility patch for
sampling_rateandresolutionin this PR, but that would risk breaking existing scripts/conversion code that depends on the legacy syntax. Removing only theunitpatch is safer, because this was already a read-only property, whereassampling_rateandresolutionare also settable via the API.This PR also removes the generated
Unitscompatibility backfill that copied nestedVectorData.unitvalues into promoted*_unitproperties, e.g.obj.waveforms.unitintoobj.waveforms_unit. That backfill was introduced in #797 to preserve the old nested syntax, but it depends on the same globalVectorData.unitpatch removed here. The promoted*_unitproperties remain generated and exported directly from the containingUnitsobject.How to test the behavior?
Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Codex