Repository navigation
fix(dynamictable): fix addRow errors for ragged columns - #895
Merged
Merged
Conversation
Three problems when adding rows to ragged columns: - addRow on a table with empty colnames failed with "Dot indexing is not supported" instead of the NoColumns error. The editability check read the id before the colnames check ran, and such a table has no id object yet. The check now treats a table without an id as editable. - A vector row whose orientation differed from the stored vector failed to concatenate. A vector row is a list of scalar elements, so addRow now reshapes it to the stored orientation. - A value wrapped in one cell too many added an index level to a column that already had an index, regrouping its existing rows without any error. addRow now rejects a value that needs more index levels than an indexed column has. A column without an index still becomes ragged when a multi-element row arrives. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ehennestad
marked this pull request as ready for review
September 29, 2026 21:28
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #895 +/- ##
=======================================
Coverage 95.29% 95.29%
=======================================
Files 239 239
Lines 8795 8805 +10
=======================================
+ Hits 8381 8391 +10
Misses 414 414 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ehennestad
enabled auto-merge
September 30, 2026 18:28
bendichter
approved these changes
Oct 6, 2026
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
Fixes three
addRowproblems with ragged columns: an unclear error on a table without column names, a failure when a row vector is added to a column stored as a column vector, and a doubly ragged row with one cell too many silently adding a third index level.Background — The ragged-array how-to in #855 describes how
addRowbuilds ragged columns. Checking that description against the code turned up the three problems below. All three are on main.Problem — A user who builds a ragged column row by row with
addRowruns into three problems.addRowfails with an error that does not say what is wrong.Solution —
addRownow reports the missing column names, accepts vector rows in either orientation, and rejects a value that needs more index levels than an indexed column has.What changed
addRowon a table with emptycolnamesraises the existingNWB:DynamicTable:AddRow:NoColumnserror, which says thatcolnamesmust be filled in.addRowappends a row vector to a column stored as a column vector, and a column vector to a column stored as a row vector. This covers numeric rows and cell rows of text.addRowraisesNWB:DynamicTable:AddRow:TooManyIndexLevelswhen a value needs more index levels than a column that already has an index. A column without an index still becomes ragged when a row with several elements arrives, as before.Implementation notes
DynamicTableBasereadobj.id.databefore thecolnamescheck ran. A table built without columns has no id object, so the call failed there. The check now treats a table without an id object as editable.addRawDatainfers how many index levels a value needs from its nesting, and addsVectorIndexobjects when the column has fewer. It now does so only for a column without an index. Adding a level to an indexed column regroups the rows already stored, each becoming a single sub-group of the new level.add2MemDatareshapes a vector value to the orientation of the stored vector before concatenating.Examples
Table without column names
The table is created without
colnames, andaddRowadds a value to a column that is not listed.Before — The call fails inside the editability check, and the message does not mention the column names.
After — The call fails with the error written for this case, which says to fill in
colnames.Vector rows in either orientation
The first row is a column vector of three spike times, which makes the stored data a column vector. The second row is a row vector of two spike times.
Before — The second
addRowcall fails, because the row vector cannot be stacked under the stored column vector.After — Both rows are stored.
spike_timesholds all five values, andspike_times_indexshows that row 1 ends after value 3 and row 2 after value 5.Row wrapped in an extra cell
The first row is a unit with two spikes, each a
[40 x 3]matrix of waveforms on three electrodes, which makeswaveformsa doubly ragged column. The second row wraps the second unit's cell of three spikes in one more cell.Before — Both calls succeed, but the result is wrong.
addRowadds a third index level,waveforms_index_index_index, with one entry per row. Each row now holds a single group that contains the unit's spikes, so the column is triply ragged.After — The second
addRowcall fails and points to the extra cell array. The column keeps its two index levels.How to test
Run the three examples above, or the new unit tests:
runtests('tests.unit.dynamicTableAddRowTest')Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Claude Code