@@ -1061,44 +1061,13 @@ def getSolutions(self, varList: Optional[str | list[str]] = None, resultfile: Op
1061
1061
1062
1062
@staticmethod
1063
1063
def _prepare_input_data (
1064
- raw_input : str | list [ str ] | dict [str , Any ],
1064
+ raw_input : dict [str , Any ],
1065
1065
) -> dict [str , str ]:
1066
1066
"""
1067
1067
Convert raw input to a structured dictionary {'key1': 'value1', 'key2': 'value2'}.
1068
1068
"""
1069
1069
1070
- def prepare_str (str_in : str ) -> dict [str , str ]:
1071
- str_in = str_in .replace (" " , "" )
1072
- key_val_list : list [str ] = str_in .split ("=" )
1073
- if len (key_val_list ) != 2 :
1074
- raise ModelicaSystemError (f"Invalid 'key=value' pair: { str_in } " )
1075
-
1076
- input_data_from_str : dict [str , str ] = {key_val_list [0 ]: key_val_list [1 ]}
1077
-
1078
- return input_data_from_str
1079
-
1080
1070
input_data : dict [str , str ] = {}
1081
-
1082
- if isinstance (raw_input , str ):
1083
- warnings .warn (message = "The definition of values to set should use a dictionary, "
1084
- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1085
- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1086
- category = DeprecationWarning ,
1087
- stacklevel = 3 )
1088
- return prepare_str (raw_input )
1089
-
1090
- if isinstance (raw_input , list ):
1091
- warnings .warn (message = "The definition of values to set should use a dictionary, "
1092
- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1093
- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1094
- category = DeprecationWarning ,
1095
- stacklevel = 3 )
1096
-
1097
- for item in raw_input :
1098
- input_data |= prepare_str (item )
1099
-
1100
- return input_data
1101
-
1102
1071
if isinstance (raw_input , dict ):
1103
1072
for key , val in raw_input .items ():
1104
1073
# convert all values to strings to align it on one type: dict[str, str]
@@ -1175,14 +1144,12 @@ def isParameterChangeable(
1175
1144
1176
1145
def setContinuous (
1177
1146
self ,
1178
- cvals : str | list [ str ] | dict [str , Any ],
1147
+ cvals : dict [str , Any ],
1179
1148
) -> bool :
1180
1149
"""
1181
1150
This method is used to set continuous values. It can be called:
1182
1151
with a sequence of continuous name and assigning corresponding values as arguments as show in the example below:
1183
1152
usage
1184
- >>> setContinuous("Name=value") # depreciated
1185
- >>> setContinuous(["Name1=value1","Name2=value2"]) # depreciated
1186
1153
>>> setContinuous(cvals={"Name1": "value1", "Name2": "value2"})
1187
1154
"""
1188
1155
inputdata = self ._prepare_input_data (raw_input = cvals )
@@ -1195,14 +1162,12 @@ def setContinuous(
1195
1162
1196
1163
def setParameters (
1197
1164
self ,
1198
- pvals : str | list [ str ] | dict [str , Any ],
1165
+ pvals : dict [str , Any ],
1199
1166
) -> bool :
1200
1167
"""
1201
1168
This method is used to set parameter values. It can be called:
1202
1169
with a sequence of parameter name and assigning corresponding value as arguments as show in the example below:
1203
1170
usage
1204
- >>> setParameters("Name=value") # depreciated
1205
- >>> setParameters(["Name1=value1","Name2=value2"]) # depreciated
1206
1171
>>> setParameters(pvals={"Name1": "value1", "Name2": "value2"})
1207
1172
"""
1208
1173
inputdata = self ._prepare_input_data (raw_input = pvals )
@@ -1215,14 +1180,12 @@ def setParameters(
1215
1180
1216
1181
def setSimulationOptions (
1217
1182
self ,
1218
- simOptions : str | list [ str ] | dict [str , Any ],
1183
+ simOptions : dict [str , Any ],
1219
1184
) -> bool :
1220
1185
"""
1221
1186
This method is used to set simulation options. It can be called:
1222
1187
with a sequence of simulation options name and assigning corresponding values as arguments as show in the example below:
1223
1188
usage
1224
- >>> setSimulationOptions("Name=value") # depreciated
1225
- >>> setSimulationOptions(["Name1=value1","Name2=value2"]) # depreciated
1226
1189
>>> setSimulationOptions(simOptions={"Name1": "value1", "Name2": "value2"})
1227
1190
"""
1228
1191
inputdata = self ._prepare_input_data (raw_input = simOptions )
@@ -1235,14 +1198,12 @@ def setSimulationOptions(
1235
1198
1236
1199
def setLinearizationOptions (
1237
1200
self ,
1238
- linearizationOptions : str | list [ str ] | dict [str , Any ],
1201
+ linearizationOptions : dict [str , Any ],
1239
1202
) -> bool :
1240
1203
"""
1241
1204
This method is used to set linearization options. It can be called:
1242
1205
with a sequence of linearization options name and assigning corresponding value as arguments as show in the example below
1243
1206
usage
1244
- >>> setLinearizationOptions("Name=value") # depreciated
1245
- >>> setLinearizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1246
1207
>>> setLinearizationOptions(linearizationOtions={"Name1": "value1", "Name2": "value2"})
1247
1208
"""
1248
1209
inputdata = self ._prepare_input_data (raw_input = linearizationOptions )
@@ -1255,14 +1216,12 @@ def setLinearizationOptions(
1255
1216
1256
1217
def setOptimizationOptions (
1257
1218
self ,
1258
- optimizationOptions : str | list [ str ] | dict [str , Any ],
1219
+ optimizationOptions : dict [str , Any ],
1259
1220
) -> bool :
1260
1221
"""
1261
1222
This method is used to set optimization options. It can be called:
1262
1223
with a sequence of optimization options name and assigning corresponding values as arguments as show in the example below:
1263
1224
usage
1264
- >>> setOptimizationOptions("Name=value") # depreciated
1265
- >>> setOptimizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1266
1225
>>> setOptimizationOptions(optimizationOptions={"Name1": "value1", "Name2": "value2"})
1267
1226
"""
1268
1227
inputdata = self ._prepare_input_data (raw_input = optimizationOptions )
@@ -1275,16 +1234,14 @@ def setOptimizationOptions(
1275
1234
1276
1235
def setInputs (
1277
1236
self ,
1278
- name : str | list [ str ] | dict [str , Any ],
1237
+ name : dict [str , Any ],
1279
1238
) -> bool :
1280
1239
"""
1281
1240
This method is used to set input values. It can be called with a sequence of input name and assigning
1282
1241
corresponding values as arguments as show in the example below. Compared to other set*() methods this is a
1283
1242
special case as value could be a list of tuples - these are converted to a string in _prepare_input_data()
1284
1243
and restored here via ast.literal_eval().
1285
1244
1286
- >>> setInputs("Name=value") # depreciated
1287
- >>> setInputs(["Name1=value1","Name2=value2"]) # depreciated
1288
1245
>>> setInputs(name={"Name1": "value1", "Name2": "value2"})
1289
1246
"""
1290
1247
inputdata = self ._prepare_input_data (raw_input = name )
0 commit comments