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