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