fix: keep every element when constructing controlled terms from a struct array - #109
Open
ehennestad wants to merge 2 commits into
Open
fix: keep every element when constructing controlled terms from a struct array#109ehennestad wants to merge 2 commits into
ehennestad wants to merge 2 commits into
Conversation
…uct array A multi-valued property that links to controlled instances kept only its first entry when read back. An AtlasAnnotation with laterality set to both left and right reloaded with left alone. Deserializing such a property assigns a struct array of references to it, which MATLAB converts by calling the controlled term constructor with the whole array. initializeControlledTerm expands obj to one element per struct, but it is a method on a handle class that returned nothing, so the expansion applied only to the local copy. The constructor kept the original scalar handle, which is the first element, and the rest were discarded. The method now returns the object array and the three constructors that call it take the returned value. This takes the round-trip suite from 261 to 288 of 292 types, and removes 30 entries from the known-gap list. The four remaining failures are unrelated to each other and are now listed individually: two types fail because serializing an unresolved MixedTypeReference is rejected by the meta type registry, ChemicalSubstance fails because a controlled instance whose name is not a valid MATLAB identifier cannot be looked up from a bare reference, and TermSuggestion fails because of the missing LINKED_PROPERTIES entry described in the previous PR. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ehennestad
force-pushed
the
fix-controlled-term-array-construction
branch
from
August 28, 2026 00:15
f04c567 to
a5ac5dd
Compare
Contributor
Test Results (R2022a)750 tests +2 748 ✅ +4 2m 31s ⏱️ -1s For more details on these failures, see this check. Results for commit a5ac5dd. ± Comparison against base commit 68c97f7. ♻️ This comment has been updated with latest results. |
ehennestad
force-pushed
the
fix-controlled-term-array-construction
branch
from
August 28, 2026 00:31
1fa140d to
a5ac5dd
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## add-graph-traversal-visitor #109 +/- ##
===============================================================
+ Coverage 79.17% 79.20% +0.02%
===============================================================
Files 419 419
Lines 4077 4077
===============================================================
+ Hits 3228 3229 +1
+ Misses 849 848 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ehennestad
force-pushed
the
fix-controlled-term-array-construction
branch
3 times, most recently
from
August 28, 2026 12:59
5bca673 to
a5ac5dd
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.
A multi-valued property linking to controlled instances kept only its first entry when read back. An
AtlasAnnotationwithlateralityset to both left and right reloaded with left alone. This is the defect the previous PRs listed as a known gap against 30 types.Cause
Deserializing such a property assigns a struct array of references to it:
MATLAB converts that by calling the controlled term constructor with the whole array.
initializeControlledTermhandles it correctly at first glance:But
initializeControlledTermis a method on a handle class that returned nothing. Growingobjinside it expands only the local copy; the caller keeps the original scalar handle it passed in, which is element one. Everything after the first element was built, populated and then discarded when the method returned.The
forloop below the expansion did populate each element, which is why this looked correct on inspection — the values existed, they just never left the method.Fix
initializeControlledTermreturns the object array, and the three constructors that call it take the returned value. That covers the currentControlledTermand the v2 and v3 variants under+abstract/private/controlledTerms.Effect
The round-trip suite goes from 261 to 288 of 292 types, and 30 entries come off
ommtest.helper.knownRoundTripGap.What is left
The four remaining failures have nothing to do with each other and are now listed individually rather than as a group:
ParcellationTerminologyVersionandQuantitativeRelationAssessmentfail during serialization, because a property holding an unresolvedMixedTypeReferencereachesopenminds.internal.meta.fromInstance, and the meta type registry does not recognise it as a metadata type.ChemicalSubstancefails because one of its controlled instances is named(N-methyl-(11c))2-(4''-methylaminophenyl)-6-hydroxybenzothiazole. Looking that up from a bare reference runs the name throughmatlab.lang.makeValidName, which mangles it beyond matching, so it reloads as an empty term with a fresh blank node identifier.TermSuggestionfails because of the missingLINKED_PROPERTIESentry described in the controlled term deserialization PR.Tests
Two cases in
ControlledTermTest: one constructs the terms directly from a struct array, one goes through a property, which is the path deserialization actually takes. Both assert the element count and the identifiers, so a regression that silently drops entries is caught rather than a regression that merely changes a count.🤖 Generated with Claude Code