Repository navigation
refactor(dynamictable): rename getRow locals and use an arguments block - #940
Open
ehennestad wants to merge 3 commits into
Open
ehennestad wants to merge 3 commits into
ehennestad wants to merge 3 commits into
Conversation
The cell array that becomes the table's variables was named row, and several other names were abbreviations, snake_case, or shadowed a MATLAB function: - row -> columnData; ind and matInd -> rowIndices; cn -> columnName; the loop counters i -> iColumn and iField - indexNames and colIndStack -> vectorChainNames, the column followed by the VectorIndex columns after it - structNames -> compoundMemberNames; columnData in select -> memberData, so the name is not reused for a compound member - array_size, num_rows, is_row_dim -> arraySize, numRows, isRowDimension - rank, which shadows the matrix rank function, -> numSubscripts; refProp -> dataSize; selectInd -> subscripts - id, idMatch, column_name -> requestedIds, isIdFound, columnName - select -> getColumnRows, returning columnRows instead of selected; getIndById -> getRowIndicesById; InvalidVectorDataShapeError -> createInvalidShapeError, whose message now reads "does not match" Comments and error identifiers are unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…lock Replace the validateattributes calls and the inputParser with an arguments block. The table is validated by the existing matnwb.common.validation.mustBeDynamicTable, which accepts both the hdmf_common and the legacy core class. The two name lists keep the same rule as the old anonymous validators, empty or a cellstr, through a local validator, since no validator for that exists in matnwb.common.compatibility and mustBeText is newer than R2019b. The default categories come from a local function, as a default expression cannot branch on the table's class. Behaviour that changes: a column vector of row indices is reshaped to a row by the (1,:) size, which the public getRow methods already enforce; an empty index list is accepted and returns a table without rows; a numeric useId is converted to logical. Option names still match case-insensitively and partially, as with inputParser. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The header described a scalar 0-based index, an `id` keyword and a set of output arguments. The function takes a vector of 1-based row indices, or id values with the useId flag, and returns a table. Two comments in the column read called a column vector a row vector, the DataPipe permute kept a loose paragraph about "non-row vectors", and the N-d branch claimed to put the last dimension first where it moves whichever dimension spans the rows. Also explain the VectorIndex chain a column is read through, why a single array row is cell-wrapped, which columns reach the compound struct split, and give getRowIndicesById and validateRowIndices H1 lines. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ehennestad
added this pull request to stack #941
October 6, 2026 20:45
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #940 +/- ##
==========================================
- Coverage 95.46% 95.44% -0.03%
==========================================
Files 240 240
Lines 8869 8870 +1
==========================================
- Hits 8467 8466 -1
- Misses 402 404 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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
Refactor
getRowso it is easier to reason about. Its variable names and docstrings were unclear or misleading.Background —
getRowbuilds the table thatDynamicTable.getRowandtoTablereturn: one table variable per requested column, read for the requested rows only. #909 rewritesgetRowto read ragged columns in a few calls.Problem — A developer who reads
getRow, or reviews #909, has to learn what the code does from text that misdescribes it. Three things get in the way:row. The number of subscripts used to index a column is calledrank, which is also MATLAB's matrix-rank function. The helper that reads one column is calledselect. The row indices, the column name and the chain of index columns are abbreviated toind,cnandcolIndStack.validateattributescalls check the table and the indices, and aninputParserwith anonymous validators checks the options. A wrong option value is reported asIt must satisfy the function: @(x)isempty(x)||iscellstr(x)rather than as the rule.None of this changes what
getRowreturns, so nothing shows up for users or in CI.Solution — Names say what a variable holds or what a function does. Docstrings and comments describe the current code. An
argumentsblock validates the inputs, and its errors name the argument and the rule. #909, #923 and #912 are rebuilt on this branch, so their diffs read in the new vocabulary.What changed
getRowand its helpers; the full list is in the notes below. WhatgetRowreturns for valid input is unchanged.getRow, the header of every helper, and the comments on column orientation and on compound columns.argumentsblock. A wrong option value is reported asInvalid value for 'columns' argument. Value must be empty or a cell array of character vectors.useIdgiven as a number is converted to logical, an empty index list returns a table with no rows, and a column vector of row indices is reshaped to a row, which the publicgetRowmethods already do.Implementation notes
Renames, old to new:
rowcolumnDataind,matIndrowIndicescn,column_namecolumnNameiiColumn,iFieldindexNames,colIndStackvectorChainNamesstructNamescompoundMemberNamescolumnData(one compound member)memberDataarray_size,num_rows,is_row_dimarraySize,numRows,isRowDimensionranknumSubscriptsrefPropdataSizeselectIndsubscriptsid,idMatchrequestedIds,isIdFoundselect, returningselectedgetColumnRows, returningcolumnRowsgetIndByIdgetRowIndicesByIdInvalidVectorDataShapeErrorcreateInvalidShapeErrormatnwb.common.validation.mustBeDynamicTable, which accepts thehdmf_commonand the legacycoreclass as the oldvalidateattributescall did. The name lists keep the old rule, empty or a cellstr, through a local validator, becausemustBeTextis newer than R2019b. The default categories come from a local function, since a default expression cannot branch on the table's class.inputParser. The three callers in the repository pass exact names.getRow.m, so each keeps its author, message and diff. perf(io): read several DataStub selections in one pass #912 does not touch the file and was rebased.Examples
Validation messages and accepted inputs
The snippet builds a three-row table in memory and calls
getRowwithuseIdgiven as the number 1, with an empty index list, with a wrongcolumnsvalue, and with a column vector of row indices.Before — The first two calls stop with an error, and the third reports an anonymous function instead of the rule. Only the column vector of indices returns rows.
After —
useIdgiven as 1 selects the row with id 20, the empty index list gives a table with no rows and the one requested column, and the wrongcolumnsvalue is reported with the rule in words. The column vector gives the same rows as before.How to test
Run the snippet above on this branch. The output should match the After block.
Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Claude Code