From b680b06386aa874f63a2a4dfa4766e58ffe4bdc6 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Sat, 25 Apr 2026 20:29:49 +0200 Subject: [PATCH] Case-insensitive name matching and indexing fix Remove struct concatenation, not guaranteed that the types vocab is homogeneous --- code/internal/+openminds/+internal/+vocab/getSchemaColor.m | 6 +++--- .../+openminds/+internal/+vocab/getSchemaLabelFromName.m | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/internal/+openminds/+internal/+vocab/getSchemaColor.m b/code/internal/+openminds/+internal/+vocab/getSchemaColor.m index 40eeec950..45c9b06a6 100644 --- a/code/internal/+openminds/+internal/+vocab/getSchemaColor.m +++ b/code/internal/+openminds/+internal/+vocab/getSchemaColor.m @@ -7,12 +7,12 @@ end C = struct2cell(typesVocab); - S = [C{:}]; - isMatch = strcmp({S.name}, schemaName); + allNames = cellfun(@(c) string(c.name), C); + isMatch = strcmpi(allNames, schemaName); if any(isMatch) - color = S(isMatch).color; + color = C{isMatch}.color; else error('No schemas matched name "%s"', schemaName) end diff --git a/code/internal/+openminds/+internal/+vocab/getSchemaLabelFromName.m b/code/internal/+openminds/+internal/+vocab/getSchemaLabelFromName.m index 65ef146b2..0eb7a3c78 100644 --- a/code/internal/+openminds/+internal/+vocab/getSchemaLabelFromName.m +++ b/code/internal/+openminds/+internal/+vocab/getSchemaLabelFromName.m @@ -10,16 +10,15 @@ end C = struct2cell(typesVocab); - S = [C{:}]; - allNames = {S.name}; + allNames = cellfun(@(c) string(c.name), C); isMatch = strcmpi(allNames, schemaName); if ~any(isMatch) throwNoMatchingSchemaException(schemaName); end - S = S(isMatch); + S = C{isMatch}; schemaLabel = string( S(1).label ); if isscalar(S)