@@ -930,44 +930,13 @@ def getSolutions(self, varList=None, resultfile=None): # 12
930
930
931
931
@staticmethod
932
932
def _prepare_input_data (
933
- raw_input : str | list [ str ] | dict [str , Any ],
933
+ raw_input : dict [str , Any ],
934
934
) -> dict [str , str ]:
935
935
"""
936
936
Convert raw input to a structured dictionary {'key1': 'value1', 'key2': 'value2'}.
937
937
"""
938
938
939
- def prepare_str (str_in : str ) -> dict [str , str ]:
940
- str_in = str_in .replace (" " , "" )
941
- key_val_list : list [str ] = str_in .split ("=" )
942
- if len (key_val_list ) != 2 :
943
- raise ModelicaSystemError (f"Invalid 'key=value' pair: { str_in } " )
944
-
945
- input_data_from_str : dict [str , str ] = {key_val_list [0 ]: key_val_list [1 ]}
946
-
947
- return input_data_from_str
948
-
949
939
input_data : dict [str , str ] = {}
950
-
951
- if isinstance (raw_input , str ):
952
- warnings .warn (message = "The definition of values to set should use a dictionary, "
953
- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
954
- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
955
- category = DeprecationWarning ,
956
- stacklevel = 3 )
957
- return prepare_str (raw_input )
958
-
959
- if isinstance (raw_input , list ):
960
- warnings .warn (message = "The definition of values to set should use a dictionary, "
961
- "i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
962
- "use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]" ,
963
- category = DeprecationWarning ,
964
- stacklevel = 3 )
965
-
966
- for item in raw_input :
967
- input_data |= prepare_str (item )
968
-
969
- return input_data
970
-
971
940
if isinstance (raw_input , dict ):
972
941
for key , val in raw_input .items ():
973
942
# convert all values to strings to align it on one type: dict[str, str]
@@ -1042,13 +1011,11 @@ def isParameterChangeable(
1042
1011
return False
1043
1012
return True
1044
1013
1045
- def setContinuous (self , cvals : str | list [ str ] | dict [str , Any ]) -> bool :
1014
+ def setContinuous (self , cvals : dict [str , Any ]) -> bool :
1046
1015
"""
1047
1016
This method is used to set continuous values. It can be called:
1048
1017
with a sequence of continuous name and assigning corresponding values as arguments as show in the example below:
1049
1018
usage
1050
- >>> setContinuous("Name=value") # depreciated
1051
- >>> setContinuous(["Name1=value1","Name2=value2"]) # depreciated
1052
1019
>>> setContinuous(cvals={"Name1": "value1", "Name2": "value2"})
1053
1020
"""
1054
1021
inputdata = self ._prepare_input_data (raw_input = cvals )
@@ -1059,13 +1026,11 @@ def setContinuous(self, cvals: str | list[str] | dict[str, Any]) -> bool:
1059
1026
datatype = "continuous" ,
1060
1027
overwritedata = self .overridevariables )
1061
1028
1062
- def setParameters (self , pvals : str | list [ str ] | dict [str , Any ]) -> bool :
1029
+ def setParameters (self , pvals : dict [str , Any ]) -> bool :
1063
1030
"""
1064
1031
This method is used to set parameter values. It can be called:
1065
1032
with a sequence of parameter name and assigning corresponding value as arguments as show in the example below:
1066
1033
usage
1067
- >>> setParameters("Name=value") # depreciated
1068
- >>> setParameters(["Name1=value1","Name2=value2"]) # depreciated
1069
1034
>>> setParameters(pvals={"Name1": "value1", "Name2": "value2"})
1070
1035
"""
1071
1036
inputdata = self ._prepare_input_data (raw_input = pvals )
@@ -1076,13 +1041,11 @@ def setParameters(self, pvals: str | list[str] | dict[str, Any]) -> bool:
1076
1041
datatype = "parameter" ,
1077
1042
overwritedata = self .overridevariables )
1078
1043
1079
- def setSimulationOptions (self , simOptions : str | list [ str ] | dict [str , Any ]) -> bool :
1044
+ def setSimulationOptions (self , simOptions : dict [str , Any ]) -> bool :
1080
1045
"""
1081
1046
This method is used to set simulation options. It can be called:
1082
1047
with a sequence of simulation options name and assigning corresponding values as arguments as show in the example below:
1083
1048
usage
1084
- >>> setSimulationOptions("Name=value") # depreciated
1085
- >>> setSimulationOptions(["Name1=value1","Name2=value2"]) # depreciated
1086
1049
>>> setSimulationOptions(simOptions={"Name1": "value1", "Name2": "value2"})
1087
1050
"""
1088
1051
inputdata = self ._prepare_input_data (raw_input = simOptions )
@@ -1093,13 +1056,11 @@ def setSimulationOptions(self, simOptions: str | list[str] | dict[str, Any]) ->
1093
1056
datatype = "simulation-option" ,
1094
1057
overwritedata = self .simoptionsoverride )
1095
1058
1096
- def setLinearizationOptions (self , linearizationOptions : str | list [ str ] | dict [str , Any ]) -> bool :
1059
+ def setLinearizationOptions (self , linearizationOptions : dict [str , Any ]) -> bool :
1097
1060
"""
1098
1061
This method is used to set linearization options. It can be called:
1099
1062
with a sequence of linearization options name and assigning corresponding value as arguments as show in the example below
1100
1063
usage
1101
- >>> setLinearizationOptions("Name=value") # depreciated
1102
- >>> setLinearizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1103
1064
>>> setLinearizationOptions(linearizationOtions={"Name1": "value1", "Name2": "value2"})
1104
1065
"""
1105
1066
inputdata = self ._prepare_input_data (raw_input = linearizationOptions )
@@ -1110,13 +1071,11 @@ def setLinearizationOptions(self, linearizationOptions: str | list[str] | dict[s
1110
1071
datatype = "Linearization-option" ,
1111
1072
overwritedata = None )
1112
1073
1113
- def setOptimizationOptions (self , optimizationOptions : str | list [ str ] | dict [str , Any ]) -> bool :
1074
+ def setOptimizationOptions (self , optimizationOptions : dict [str , Any ]) -> bool :
1114
1075
"""
1115
1076
This method is used to set optimization options. It can be called:
1116
1077
with a sequence of optimization options name and assigning corresponding values as arguments as show in the example below:
1117
1078
usage
1118
- >>> setOptimizationOptions("Name=value") # depreciated
1119
- >>> setOptimizationOptions(["Name1=value1","Name2=value2"]) # depreciated
1120
1079
>>> setOptimizationOptions(optimizationOptions={"Name1": "value1", "Name2": "value2"})
1121
1080
"""
1122
1081
inputdata = self ._prepare_input_data (raw_input = optimizationOptions )
@@ -1127,15 +1086,13 @@ def setOptimizationOptions(self, optimizationOptions: str | list[str] | dict[str
1127
1086
datatype = "optimization-option" ,
1128
1087
overwritedata = None )
1129
1088
1130
- def setInputs (self , name : str | list [ str ] | dict [str , Any ]) -> bool :
1089
+ def setInputs (self , name : dict [str , Any ]) -> bool :
1131
1090
"""
1132
1091
This method is used to set input values. It can be called with a sequence of input name and assigning
1133
1092
corresponding values as arguments as show in the example below. Compared to other set*() methods this is a
1134
1093
special case as value could be a list of tuples - these are converted to a string in _prepare_input_data()
1135
1094
and restored here via ast.literal_eval().
1136
1095
1137
- >>> setInputs("Name=value") # depreciated
1138
- >>> setInputs(["Name1=value1","Name2=value2"]) # depreciated
1139
1096
>>> setInputs(name={"Name1": "value1", "Name2": "value2"})
1140
1097
"""
1141
1098
inputdata = self ._prepare_input_data (raw_input = name )
0 commit comments