Repository navigation
fix(dynamictable): accept string descriptions in toTable - #947
Draft
ehennestad wants to merge 1 commit into
Draft
ehennestad wants to merge 1 commit into
ehennestad wants to merge 1 commit into
Conversation
toTable copies the description of each column, and of each category of an AlignedDynamicTable, into the VariableDescriptions property of the MATLAB table. That property takes a cell array of character vectors. A description may be held as a string scalar, because the description property accepts one, and the cell array then mixed strings with character vectors and the assignment failed with MATLAB:table:InvalidVarDescr. getColumnDescriptions and nwbToTable now convert each description to a character vector. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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
Makes
toTablework on aDynamicTablewhose column description, or category description for anAlignedDynamicTable, is a string scalar. It failed with an error aboutVariableDescriptions.Problem — A user creates a column with a double-quoted description, such as
types.hdmf_common.VectorData('description', "whether the trial was correct", ...). The table is created and exported without complaint, because thedescriptionproperty accepts a string scalar and keeps it as one.toTablethen fails withThe VariableDescriptions property must be a string array or a cell array of character vectors.The cause is thattoTablecollects the descriptions in a cell array that starts with''for theidcolumn, so a string description makes the cell array hold both character vectors and strings, which a MATLAB table does not accept asVariableDescriptions.Solution — The descriptions are converted to character vectors when they are collected, so
toTablereturns the table and itsVariableDescriptionshold the text of each description.What changed
toTableaccepts string scalar descriptions of columns and of the categories of anAlignedDynamicTable.types.util.dynamictable.internal.getColumnDescriptionsreturns a cell array of character vectors for any description class thedescriptionproperty accepts.Example
Before —
toTablestops while assigning the variable descriptions.After — The table is returned. The first description belongs to the
idcolumn, which has none.How to test the behavior?
testToTableWithStringDescriptionandtestToTableWithStringCategoryDescriptionfail onmainwithMATLAB:table:InvalidVarDescr.Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Claude Code