@@ -1214,49 +1214,13 @@ def getSolutions(
12141214
12151215 @staticmethod
12161216 def _prepare_input_data (
1217- input_args : Any ,
12181217 input_kwargs : dict [str , Any ],
12191218 ) -> dict [str , str ]:
12201219 """
12211220 Convert raw input to a structured dictionary {'key1': 'value1', 'key2': 'value2'}.
12221221 """
12231222
1224- def prepare_str (str_in : str ) -> dict [str , str ]:
1225- str_in = str_in .replace (" " , "" )
1226- key_val_list : list [str ] = str_in .split ("=" )
1227- if len (key_val_list ) != 2 :
1228- raise ModelicaSystemError (f"Invalid 'key=value' pair: { str_in } " )
1229-
1230- input_data_from_str : dict [str , str ] = {key_val_list [0 ]: key_val_list [1 ]}
1231-
1232- return input_data_from_str
1233-
12341223 input_data : dict [str , str ] = {}
1235-
1236- for input_arg in input_args :
1237- if isinstance (input_arg , str ):
1238- warnings .warn (message = "The definition of values to set should use a dictionary, "
1239- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1240- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1241- category = DeprecationWarning ,
1242- stacklevel = 3 )
1243- input_data = input_data | prepare_str (input_arg )
1244- elif isinstance (input_arg , list ):
1245- warnings .warn (message = "The definition of values to set should use a dictionary, "
1246- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1247- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1248- category = DeprecationWarning ,
1249- stacklevel = 3 )
1250-
1251- for item in input_arg :
1252- if not isinstance (item , str ):
1253- raise ModelicaSystemError (f"Invalid input data type for set*() function: { type (item )} !" )
1254- input_data = input_data | prepare_str (item )
1255- elif isinstance (input_arg , dict ):
1256- input_data = input_data | input_arg
1257- else :
1258- raise ModelicaSystemError (f"Invalid input data type for set*() function: { type (input_arg )} !" )
1259-
12601224 if len (input_kwargs ):
12611225 for key , val in input_kwargs .items ():
12621226 # ensure all values are strings to align it on one type: dict[str, str]
@@ -1330,21 +1294,15 @@ def isParameterChangeable(
13301294
13311295 def setContinuous (
13321296 self ,
1333- * args : Any ,
13341297 ** kwargs : dict [str , Any ],
13351298 ) -> bool :
13361299 """
1337- This method is used to set continuous values. It can be called:
1338- with a sequence of continuous name and assigning corresponding values as arguments as show in the example below:
1339- usage
1340- >>> setContinuous("Name=value") # depreciated
1341- >>> setContinuous(["Name1=value1","Name2=value2"]) # depreciated
1342-
1300+ This method is used to set continuous values.
13431301 >>> setContinuous(Name1="value1", Name2="value2")
13441302 >>> param = {"Name1": "value1", "Name2": "value2"}
13451303 >>> setContinuous(**param)
13461304 """
1347- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1305+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
13481306
13491307 return self ._set_method_helper (
13501308 inputdata = inputdata ,
@@ -1354,21 +1312,15 @@ def setContinuous(
13541312
13551313 def setParameters (
13561314 self ,
1357- * args : Any ,
13581315 ** kwargs : dict [str , Any ],
13591316 ) -> bool :
13601317 """
1361- This method is used to set parameter values. It can be called:
1362- with a sequence of parameter name and assigning corresponding value as arguments as show in the example below:
1363- usage
1364- >>> setParameters("Name=value") # depreciated
1365- >>> setParameters(["Name1=value1","Name2=value2"]) # depreciated
1366-
1318+ This method is used to set parameter values.
13671319 >>> setParameters(Name1="value1", Name2="value2")
13681320 >>> param = {"Name1": "value1", "Name2": "value2"}
13691321 >>> setParameters(**param)
13701322 """
1371- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1323+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
13721324
13731325 return self ._set_method_helper (
13741326 inputdata = inputdata ,
@@ -1378,22 +1330,15 @@ def setParameters(
13781330
13791331 def setSimulationOptions (
13801332 self ,
1381- * args : Any ,
13821333 ** kwargs : dict [str , Any ],
13831334 ) -> bool :
13841335 """
1385- This method is used to set simulation options. It can be called:
1386- with a sequence of simulation options name and assigning corresponding values as arguments as show in the
1387- example below:
1388- usage
1389- >>> setSimulationOptions("Name=value") # depreciated
1390- >>> setSimulationOptions(["Name1=value1","Name2=value2"]) # depreciated
1391-
1336+ This method is used to set simulation options.
13921337 >>> setSimulationOptions(Name1="value1", Name2="value2")
13931338 >>> param = {"Name1": "value1", "Name2": "value2"}
13941339 >>> setSimulationOptions(**param)
13951340 """
1396- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1341+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
13971342
13981343 return self ._set_method_helper (
13991344 inputdata = inputdata ,
@@ -1403,22 +1348,15 @@ def setSimulationOptions(
14031348
14041349 def setLinearizationOptions (
14051350 self ,
1406- * args : Any ,
14071351 ** kwargs : dict [str , Any ],
14081352 ) -> bool :
14091353 """
1410- This method is used to set linearization options. It can be called:
1411- with a sequence of linearization options name and assigning corresponding value as arguments as show in the
1412- example below
1413- usage
1414- >>> setLinearizationOptions("Name=value") # depreciated
1415- >>> setLinearizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1416-
1354+ This method is used to set linearization options.
14171355 >>> setLinearizationOptions(Name1="value1", Name2="value2")
14181356 >>> param = {"Name1": "value1", "Name2": "value2"}
14191357 >>> setLinearizationOptions(**param)
14201358 """
1421- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1359+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14221360
14231361 return self ._set_method_helper (
14241362 inputdata = inputdata ,
@@ -1428,22 +1366,18 @@ def setLinearizationOptions(
14281366
14291367 def setOptimizationOptions (
14301368 self ,
1431- * args : Any ,
14321369 ** kwargs : dict [str , Any ],
14331370 ) -> bool :
14341371 """
14351372 This method is used to set optimization options. It can be called:
14361373 with a sequence of optimization options name and assigning corresponding values as arguments as show in the
14371374 example below:
14381375 usage
1439- >>> setOptimizationOptions("Name=value") # depreciated
1440- >>> setOptimizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1441-
14421376 >>> setOptimizationOptions(Name1="value1", Name2="value2")
14431377 >>> param = {"Name1": "value1", "Name2": "value2"}
14441378 >>> setOptimizationOptions(**param)
14451379 """
1446- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1380+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14471381
14481382 return self ._set_method_helper (
14491383 inputdata = inputdata ,
@@ -1453,23 +1387,18 @@ def setOptimizationOptions(
14531387
14541388 def setInputs (
14551389 self ,
1456- * args : Any ,
14571390 ** kwargs : dict [str , Any ],
14581391 ) -> bool :
14591392 """
1460- This method is used to set input values. It can be called with a sequence of input name and assigning
1461- corresponding values as arguments as show in the example below. Compared to other set*() methods this is a
1462- special case as value could be a list of tuples - these are converted to a string in _prepare_input_data()
1463- and restored here via ast.literal_eval().
1464-
1465- >>> setInputs("Name=value") # depreciated
1466- >>> setInputs(["Name1=value1","Name2=value2"]) # depreciated
1393+ This method is used to set input values.
14671394
1395+ Compared to other set*() methods this is a special case as value could be a list of tuples - these are
1396+ converted to a string in _prepare_input_data() and restored here via ast.literal_eval().
14681397 >>> setInputs(Name1="value1", Name2="value2")
14691398 >>> param = {"Name1": "value1", "Name2": "value2"}
14701399 >>> setInputs(**param)
14711400 """
1472- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1401+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14731402
14741403 for key , val in inputdata .items ():
14751404 if key not in self ._inputs :
@@ -2005,7 +1934,7 @@ def prepare(self) -> int:
20051934 }
20061935 )
20071936
2008- self ._mod .setParameters (sim_param_non_structural )
1937+ self ._mod .setParameters (** sim_param_non_structural )
20091938 mscmd = self ._mod .simulate_cmd (
20101939 result_file = resultfile ,
20111940 timeout = self ._timeout ,
0 commit comments