@@ -1296,49 +1296,13 @@ def getSolutions(
12961296
12971297 @staticmethod
12981298 def _prepare_input_data (
1299- input_args : Any ,
13001299 input_kwargs : dict [str , Any ],
13011300 ) -> dict [str , str ]:
13021301 """
13031302 Convert raw input to a structured dictionary {'key1': 'value1', 'key2': 'value2'}.
13041303 """
13051304
1306- def prepare_str (str_in : str ) -> dict [str , str ]:
1307- str_in = str_in .replace (" " , "" )
1308- key_val_list : list [str ] = str_in .split ("=" )
1309- if len (key_val_list ) != 2 :
1310- raise ModelicaSystemError (f"Invalid 'key=value' pair: { str_in } " )
1311-
1312- input_data_from_str : dict [str , str ] = {key_val_list [0 ]: key_val_list [1 ]}
1313-
1314- return input_data_from_str
1315-
13161305 input_data : dict [str , str ] = {}
1317-
1318- for input_arg in input_args :
1319- if isinstance (input_arg , str ):
1320- warnings .warn (message = "The definition of values to set should use a dictionary, "
1321- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1322- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1323- category = DeprecationWarning ,
1324- stacklevel = 3 )
1325- input_data = input_data | prepare_str (input_arg )
1326- elif isinstance (input_arg , list ):
1327- warnings .warn (message = "The definition of values to set should use a dictionary, "
1328- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1329- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1330- category = DeprecationWarning ,
1331- stacklevel = 3 )
1332-
1333- for item in input_arg :
1334- if not isinstance (item , str ):
1335- raise ModelicaSystemError (f"Invalid input data type for set*() function: { type (item )} !" )
1336- input_data = input_data | prepare_str (item )
1337- elif isinstance (input_arg , dict ):
1338- input_data = input_data | input_arg
1339- else :
1340- raise ModelicaSystemError (f"Invalid input data type for set*() function: { type (input_arg )} !" )
1341-
13421306 if len (input_kwargs ):
13431307 for key , val in input_kwargs .items ():
13441308 # ensure all values are strings to align it on one type: dict[str, str]
@@ -1412,21 +1376,15 @@ def isParameterChangeable(
14121376
14131377 def setContinuous (
14141378 self ,
1415- * args : Any ,
14161379 ** kwargs : dict [str , Any ],
14171380 ) -> bool :
14181381 """
1419- This method is used to set continuous values. It can be called:
1420- with a sequence of continuous name and assigning corresponding values as arguments as show in the example below:
1421- usage
1422- >>> setContinuous("Name=value") # depreciated
1423- >>> setContinuous(["Name1=value1","Name2=value2"]) # depreciated
1424-
1382+ This method is used to set continuous values.
14251383 >>> setContinuous(Name1="value1", Name2="value2")
14261384 >>> param = {"Name1": "value1", "Name2": "value2"}
14271385 >>> setContinuous(**param)
14281386 """
1429- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1387+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14301388
14311389 return self ._set_method_helper (
14321390 inputdata = inputdata ,
@@ -1436,21 +1394,15 @@ def setContinuous(
14361394
14371395 def setParameters (
14381396 self ,
1439- * args : Any ,
14401397 ** kwargs : dict [str , Any ],
14411398 ) -> bool :
14421399 """
1443- This method is used to set parameter values. It can be called:
1444- with a sequence of parameter name and assigning corresponding value as arguments as show in the example below:
1445- usage
1446- >>> setParameters("Name=value") # depreciated
1447- >>> setParameters(["Name1=value1","Name2=value2"]) # depreciated
1448-
1400+ This method is used to set parameter values.
14491401 >>> setParameters(Name1="value1", Name2="value2")
14501402 >>> param = {"Name1": "value1", "Name2": "value2"}
14511403 >>> setParameters(**param)
14521404 """
1453- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1405+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14541406
14551407 return self ._set_method_helper (
14561408 inputdata = inputdata ,
@@ -1460,22 +1412,15 @@ def setParameters(
14601412
14611413 def setSimulationOptions (
14621414 self ,
1463- * args : Any ,
14641415 ** kwargs : dict [str , Any ],
14651416 ) -> bool :
14661417 """
1467- This method is used to set simulation options. It can be called:
1468- with a sequence of simulation options name and assigning corresponding values as arguments as show in the
1469- example below:
1470- usage
1471- >>> setSimulationOptions("Name=value") # depreciated
1472- >>> setSimulationOptions(["Name1=value1","Name2=value2"]) # depreciated
1473-
1418+ This method is used to set simulation options.
14741419 >>> setSimulationOptions(Name1="value1", Name2="value2")
14751420 >>> param = {"Name1": "value1", "Name2": "value2"}
14761421 >>> setSimulationOptions(**param)
14771422 """
1478- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1423+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14791424
14801425 return self ._set_method_helper (
14811426 inputdata = inputdata ,
@@ -1485,22 +1430,15 @@ def setSimulationOptions(
14851430
14861431 def setLinearizationOptions (
14871432 self ,
1488- * args : Any ,
14891433 ** kwargs : dict [str , Any ],
14901434 ) -> bool :
14911435 """
1492- This method is used to set linearization options. It can be called:
1493- with a sequence of linearization options name and assigning corresponding value as arguments as show in the
1494- example below
1495- usage
1496- >>> setLinearizationOptions("Name=value") # depreciated
1497- >>> setLinearizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1498-
1436+ This method is used to set linearization options.
14991437 >>> setLinearizationOptions(Name1="value1", Name2="value2")
15001438 >>> param = {"Name1": "value1", "Name2": "value2"}
15011439 >>> setLinearizationOptions(**param)
15021440 """
1503- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1441+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
15041442
15051443 return self ._set_method_helper (
15061444 inputdata = inputdata ,
@@ -1510,22 +1448,18 @@ def setLinearizationOptions(
15101448
15111449 def setOptimizationOptions (
15121450 self ,
1513- * args : Any ,
15141451 ** kwargs : dict [str , Any ],
15151452 ) -> bool :
15161453 """
15171454 This method is used to set optimization options. It can be called:
15181455 with a sequence of optimization options name and assigning corresponding values as arguments as show in the
15191456 example below:
15201457 usage
1521- >>> setOptimizationOptions("Name=value") # depreciated
1522- >>> setOptimizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1523-
15241458 >>> setOptimizationOptions(Name1="value1", Name2="value2")
15251459 >>> param = {"Name1": "value1", "Name2": "value2"}
15261460 >>> setOptimizationOptions(**param)
15271461 """
1528- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1462+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
15291463
15301464 return self ._set_method_helper (
15311465 inputdata = inputdata ,
@@ -1535,23 +1469,18 @@ def setOptimizationOptions(
15351469
15361470 def setInputs (
15371471 self ,
1538- * args : Any ,
15391472 ** kwargs : dict [str , Any ],
15401473 ) -> bool :
15411474 """
1542- This method is used to set input values. It can be called with a sequence of input name and assigning
1543- corresponding values as arguments as show in the example below. Compared to other set*() methods this is a
1544- special case as value could be a list of tuples - these are converted to a string in _prepare_input_data()
1545- and restored here via ast.literal_eval().
1546-
1547- >>> setInputs("Name=value") # depreciated
1548- >>> setInputs(["Name1=value1","Name2=value2"]) # depreciated
1475+ This method is used to set input values.
15491476
1477+ Compared to other set*() methods this is a special case as value could be a list of tuples - these are
1478+ converted to a string in _prepare_input_data() and restored here via ast.literal_eval().
15501479 >>> setInputs(Name1="value1", Name2="value2")
15511480 >>> param = {"Name1": "value1", "Name2": "value2"}
15521481 >>> setInputs(**param)
15531482 """
1554- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1483+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
15551484
15561485 for key , val in inputdata .items ():
15571486 if key not in self ._inputs :
@@ -2095,7 +2024,7 @@ def prepare(self) -> int:
20952024 }
20962025 )
20972026
2098- self ._mod .setParameters (sim_param_non_structural )
2027+ self ._mod .setParameters (** sim_param_non_structural )
20992028 mscmd = self ._mod .simulate_cmd (
21002029 result_file = resultfile ,
21012030 timeout = self ._timeout ,
0 commit comments