@@ -1291,49 +1291,13 @@ def getSolutions(
12911291
12921292 @staticmethod
12931293 def _prepare_input_data (
1294- input_args : Any ,
12951294 input_kwargs : dict [str , Any ],
12961295 ) -> dict [str , str ]:
12971296 """
12981297 Convert raw input to a structured dictionary {'key1': 'value1', 'key2': 'value2'}.
12991298 """
13001299
1301- def prepare_str (str_in : str ) -> dict [str , str ]:
1302- str_in = str_in .replace (" " , "" )
1303- key_val_list : list [str ] = str_in .split ("=" )
1304- if len (key_val_list ) != 2 :
1305- raise ModelicaSystemError (f"Invalid 'key=value' pair: { str_in } " )
1306-
1307- input_data_from_str : dict [str , str ] = {key_val_list [0 ]: key_val_list [1 ]}
1308-
1309- return input_data_from_str
1310-
13111300 input_data : dict [str , str ] = {}
1312-
1313- for input_arg in input_args :
1314- if isinstance (input_arg , str ):
1315- warnings .warn (message = "The definition of values to set should use a dictionary, "
1316- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1317- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1318- category = DeprecationWarning ,
1319- stacklevel = 3 )
1320- input_data = input_data | prepare_str (input_arg )
1321- elif isinstance (input_arg , list ):
1322- warnings .warn (message = "The definition of values to set should use a dictionary, "
1323- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1324- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
1325- category = DeprecationWarning ,
1326- stacklevel = 3 )
1327-
1328- for item in input_arg :
1329- if not isinstance (item , str ):
1330- raise ModelicaSystemError (f"Invalid input data type for set*() function: { type (item )} !" )
1331- input_data = input_data | prepare_str (item )
1332- elif isinstance (input_arg , dict ):
1333- input_data = input_data | input_arg
1334- else :
1335- raise ModelicaSystemError (f"Invalid input data type for set*() function: { type (input_arg )} !" )
1336-
13371301 if len (input_kwargs ):
13381302 for key , val in input_kwargs .items ():
13391303 # ensure all values are strings to align it on one type: dict[str, str]
@@ -1411,21 +1375,15 @@ def isParameterChangeable(
14111375
14121376 def setContinuous (
14131377 self ,
1414- * args : Any ,
14151378 ** kwargs : dict [str , Any ],
14161379 ) -> bool :
14171380 """
1418- This method is used to set continuous values. It can be called:
1419- with a sequence of continuous name and assigning corresponding values as arguments as show in the example below:
1420- usage
1421- >>> setContinuous("Name=value") # depreciated
1422- >>> setContinuous(["Name1=value1","Name2=value2"]) # depreciated
1423-
1381+ This method is used to set continuous values.
14241382 >>> setContinuous(Name1="value1", Name2="value2")
14251383 >>> param = {"Name1": "value1", "Name2": "value2"}
14261384 >>> setContinuous(**param)
14271385 """
1428- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1386+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14291387
14301388 return self ._set_method_helper (
14311389 inputdata = inputdata ,
@@ -1435,21 +1393,15 @@ def setContinuous(
14351393
14361394 def setParameters (
14371395 self ,
1438- * args : Any ,
14391396 ** kwargs : dict [str , Any ],
14401397 ) -> bool :
14411398 """
1442- This method is used to set parameter values. It can be called:
1443- with a sequence of parameter name and assigning corresponding value as arguments as show in the example below:
1444- usage
1445- >>> setParameters("Name=value") # depreciated
1446- >>> setParameters(["Name1=value1","Name2=value2"]) # depreciated
1447-
1399+ This method is used to set parameter values.
14481400 >>> setParameters(Name1="value1", Name2="value2")
14491401 >>> param = {"Name1": "value1", "Name2": "value2"}
14501402 >>> setParameters(**param)
14511403 """
1452- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1404+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14531405
14541406 return self ._set_method_helper (
14551407 inputdata = inputdata ,
@@ -1459,22 +1411,15 @@ def setParameters(
14591411
14601412 def setSimulationOptions (
14611413 self ,
1462- * args : Any ,
14631414 ** kwargs : dict [str , Any ],
14641415 ) -> bool :
14651416 """
1466- This method is used to set simulation options. It can be called:
1467- with a sequence of simulation options name and assigning corresponding values as arguments as show in the
1468- example below:
1469- usage
1470- >>> setSimulationOptions("Name=value") # depreciated
1471- >>> setSimulationOptions(["Name1=value1","Name2=value2"]) # depreciated
1472-
1417+ This method is used to set simulation options.
14731418 >>> setSimulationOptions(Name1="value1", Name2="value2")
14741419 >>> param = {"Name1": "value1", "Name2": "value2"}
14751420 >>> setSimulationOptions(**param)
14761421 """
1477- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1422+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
14781423
14791424 return self ._set_method_helper (
14801425 inputdata = inputdata ,
@@ -1484,22 +1429,15 @@ def setSimulationOptions(
14841429
14851430 def setLinearizationOptions (
14861431 self ,
1487- * args : Any ,
14881432 ** kwargs : dict [str , Any ],
14891433 ) -> bool :
14901434 """
1491- This method is used to set linearization options. It can be called:
1492- with a sequence of linearization options name and assigning corresponding value as arguments as show in the
1493- example below
1494- usage
1495- >>> setLinearizationOptions("Name=value") # depreciated
1496- >>> setLinearizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1497-
1435+ This method is used to set linearization options.
14981436 >>> setLinearizationOptions(Name1="value1", Name2="value2")
14991437 >>> param = {"Name1": "value1", "Name2": "value2"}
15001438 >>> setLinearizationOptions(**param)
15011439 """
1502- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1440+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
15031441
15041442 return self ._set_method_helper (
15051443 inputdata = inputdata ,
@@ -1509,22 +1447,18 @@ def setLinearizationOptions(
15091447
15101448 def setOptimizationOptions (
15111449 self ,
1512- * args : Any ,
15131450 ** kwargs : dict [str , Any ],
15141451 ) -> bool :
15151452 """
15161453 This method is used to set optimization options. It can be called:
15171454 with a sequence of optimization options name and assigning corresponding values as arguments as show in the
15181455 example below:
15191456 usage
1520- >>> setOptimizationOptions("Name=value") # depreciated
1521- >>> setOptimizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1522-
15231457 >>> setOptimizationOptions(Name1="value1", Name2="value2")
15241458 >>> param = {"Name1": "value1", "Name2": "value2"}
15251459 >>> setOptimizationOptions(**param)
15261460 """
1527- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1461+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
15281462
15291463 return self ._set_method_helper (
15301464 inputdata = inputdata ,
@@ -1534,23 +1468,18 @@ def setOptimizationOptions(
15341468
15351469 def setInputs (
15361470 self ,
1537- * args : Any ,
15381471 ** kwargs : dict [str , Any ],
15391472 ) -> bool :
15401473 """
1541- This method is used to set input values. It can be called with a sequence of input name and assigning
1542- corresponding values as arguments as show in the example below. Compared to other set*() methods this is a
1543- special case as value could be a list of tuples - these are converted to a string in _prepare_input_data()
1544- and restored here via ast.literal_eval().
1545-
1546- >>> setInputs("Name=value") # depreciated
1547- >>> setInputs(["Name1=value1","Name2=value2"]) # depreciated
1474+ This method is used to set input values.
15481475
1476+ Compared to other set*() methods this is a special case as value could be a list of tuples - these are
1477+ converted to a string in _prepare_input_data() and restored here via ast.literal_eval().
15491478 >>> setInputs(Name1="value1", Name2="value2")
15501479 >>> param = {"Name1": "value1", "Name2": "value2"}
15511480 >>> setInputs(**param)
15521481 """
1553- inputdata = self ._prepare_input_data (input_args = args , input_kwargs = kwargs )
1482+ inputdata = self ._prepare_input_data (input_kwargs = kwargs )
15541483
15551484 for key , val in inputdata .items ():
15561485 if key not in self ._inputs :
@@ -2086,7 +2015,7 @@ def prepare(self) -> int:
20862015 }
20872016 )
20882017
2089- self ._mod .setParameters (sim_param_non_structural )
2018+ self ._mod .setParameters (** sim_param_non_structural )
20902019 mscmd = self ._mod .simulate_cmd (
20912020 result_file = resultfile ,
20922021 )
0 commit comments