From d0d51595171813e50bb61ecd2551a474bb7a1570 Mon Sep 17 00:00:00 2001 From: Eduard Kerkhoven Date: Thu, 4 Jul 2024 23:49:25 +0200 Subject: [PATCH] doc: getIndexes error if model has duplicate IDs --- core/getIndexes.m | 3 +++ doc/core/getIndexes.html | 57 +++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/core/getIndexes.m b/core/getIndexes.m index db17b982..70e0fc57 100755 --- a/core/getIndexes.m +++ b/core/getIndexes.m @@ -92,6 +92,9 @@ if strcmpi(type,'metnames') indexes{i}=index; elseif ~isempty(index) + if length(index) > 1 + error('There are multiple instances of object "%s" in the model, while "%s" type should be unique', objects{i}, type) + end indexes(i)=index; else error(['Could not find object ''' objects{i} ''' in the model']); diff --git a/doc/core/getIndexes.html b/doc/core/getIndexes.html index 313df882..de9d5f40 100644 --- a/doc/core/getIndexes.html +++ b/doc/core/getIndexes.html @@ -161,33 +161,36 @@

SOURCE CODE ^if strcmpi(type,'metnames') 0093 indexes{i}=index; 0094 elseif ~isempty(index) -0095 indexes(i)=index; -0096 else -0097 error(['Could not find object ''' objects{i} ''' in the model']); -0098 end -0099 end -0100 else -0101 %Now it's either a logical (or 0/1) array or an array with indexes. We -0102 %want it to be an array with indexes. -0103 if all(objects) -0104 %This gets weird if it's all 1 -0105 indexes=objects; -0106 else -0107 indexes=find(objects); -0108 end -0109 end -0110 -0111 if returnLogical==true -0112 tempIndexes=false(numel(searchIn),1); -0113 tempIndexes(indexes)=true; -0114 indexes=tempIndexes; -0115 end -0116 -0117 indexes=indexes(:); -0118 if iscell(indexes) && length(indexes)==1 -0119 indexes=indexes{1}; -0120 end -0121 end +0095 if length(index) > 1 +0096 error('There are multiple instances of object "%s" in the model, while "%s" type should be unique', objects{i}, type) +0097 end +0098 indexes(i)=index; +0099 else +0100 error(['Could not find object ''' objects{i} ''' in the model']); +0101 end +0102 end +0103 else +0104 %Now it's either a logical (or 0/1) array or an array with indexes. We +0105 %want it to be an array with indexes. +0106 if all(objects) +0107 %This gets weird if it's all 1 +0108 indexes=objects; +0109 else +0110 indexes=find(objects); +0111 end +0112 end +0113 +0114 if returnLogical==true +0115 tempIndexes=false(numel(searchIn),1); +0116 tempIndexes(indexes)=true; +0117 indexes=tempIndexes; +0118 end +0119 +0120 indexes=indexes(:); +0121 if iscell(indexes) && length(indexes)==1 +0122 indexes=indexes{1}; +0123 end +0124 end
Generated by m2html © 2005
\ No newline at end of file