Skip to content

Commit a39908a

Browse files
committed
[ModelicaSystem] remove obsolete inputs for set*() methods
1 parent eefb719 commit a39908a

File tree

1 file changed

+7
-50
lines changed

1 file changed

+7
-50
lines changed

OMPython/ModelicaSystem.py

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,44 +1060,13 @@ def getSolutions(self, varList: Optional[str | list[str]] = None, resultfile: Op
10601060

10611061
@staticmethod
10621062
def _prepare_input_data(
1063-
raw_input: str | list[str] | dict[str, Any],
1063+
raw_input: dict[str, Any],
10641064
) -> dict[str, str]:
10651065
"""
10661066
Convert raw input to a structured dictionary {'key1': 'value1', 'key2': 'value2'}.
10671067
"""
10681068

1069-
def prepare_str(str_in: str) -> dict[str, str]:
1070-
str_in = str_in.replace(" ", "")
1071-
key_val_list: list[str] = str_in.split("=")
1072-
if len(key_val_list) != 2:
1073-
raise ModelicaSystemError(f"Invalid 'key=value' pair: {str_in}")
1074-
1075-
input_data_from_str: dict[str, str] = {key_val_list[0]: key_val_list[1]}
1076-
1077-
return input_data_from_str
1078-
10791069
input_data: dict[str, str] = {}
1080-
1081-
if isinstance(raw_input, str):
1082-
warnings.warn(message="The definition of values to set should use a dictionary, "
1083-
"i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1084-
"use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]",
1085-
category=DeprecationWarning,
1086-
stacklevel=3)
1087-
return prepare_str(raw_input)
1088-
1089-
if isinstance(raw_input, list):
1090-
warnings.warn(message="The definition of values to set should use a dictionary, "
1091-
"i.e. {'key1': 'val1', 'key2': 'val2', ...}. Please convert all cases which "
1092-
"use a string ('key=val') or list ['key1=val1', 'key2=val2', ...]",
1093-
category=DeprecationWarning,
1094-
stacklevel=3)
1095-
1096-
for item in raw_input:
1097-
input_data |= prepare_str(item)
1098-
1099-
return input_data
1100-
11011070
if isinstance(raw_input, dict):
11021071
for key, val in raw_input.items():
11031072
# convert all values to strings to align it on one type: dict[str, str]
@@ -1174,14 +1143,12 @@ def isParameterChangeable(
11741143

11751144
def setContinuous(
11761145
self,
1177-
cvals: str | list[str] | dict[str, Any],
1146+
cvals: dict[str, Any],
11781147
) -> bool:
11791148
"""
11801149
This method is used to set continuous values. It can be called:
11811150
with a sequence of continuous name and assigning corresponding values as arguments as show in the example below:
11821151
usage
1183-
>>> setContinuous("Name=value") # depreciated
1184-
>>> setContinuous(["Name1=value1","Name2=value2"]) # depreciated
11851152
>>> setContinuous(cvals={"Name1": "value1", "Name2": "value2"})
11861153
"""
11871154
inputdata = self._prepare_input_data(raw_input=cvals)
@@ -1194,14 +1161,12 @@ def setContinuous(
11941161

11951162
def setParameters(
11961163
self,
1197-
pvals: str | list[str] | dict[str, Any],
1164+
pvals: dict[str, Any],
11981165
) -> bool:
11991166
"""
12001167
This method is used to set parameter values. It can be called:
12011168
with a sequence of parameter name and assigning corresponding value as arguments as show in the example below:
12021169
usage
1203-
>>> setParameters("Name=value") # depreciated
1204-
>>> setParameters(["Name1=value1","Name2=value2"]) # depreciated
12051170
>>> setParameters(pvals={"Name1": "value1", "Name2": "value2"})
12061171
"""
12071172
inputdata = self._prepare_input_data(raw_input=pvals)
@@ -1214,14 +1179,12 @@ def setParameters(
12141179

12151180
def setSimulationOptions(
12161181
self,
1217-
simOptions: str | list[str] | dict[str, Any],
1182+
simOptions: dict[str, Any],
12181183
) -> bool:
12191184
"""
12201185
This method is used to set simulation options. It can be called:
12211186
with a sequence of simulation options name and assigning corresponding values as arguments as show in the example below:
12221187
usage
1223-
>>> setSimulationOptions("Name=value") # depreciated
1224-
>>> setSimulationOptions(["Name1=value1","Name2=value2"]) # depreciated
12251188
>>> setSimulationOptions(simOptions={"Name1": "value1", "Name2": "value2"})
12261189
"""
12271190
inputdata = self._prepare_input_data(raw_input=simOptions)
@@ -1234,14 +1197,12 @@ def setSimulationOptions(
12341197

12351198
def setLinearizationOptions(
12361199
self,
1237-
linearizationOptions: str | list[str] | dict[str, Any],
1200+
linearizationOptions: dict[str, Any],
12381201
) -> bool:
12391202
"""
12401203
This method is used to set linearization options. It can be called:
12411204
with a sequence of linearization options name and assigning corresponding value as arguments as show in the example below
12421205
usage
1243-
>>> setLinearizationOptions("Name=value") # depreciated
1244-
>>> setLinearizationOptions(["Name1=value1","Name2=value2"]) # depreciated
12451206
>>> setLinearizationOptions(linearizationOtions={"Name1": "value1", "Name2": "value2"})
12461207
"""
12471208
inputdata = self._prepare_input_data(raw_input=linearizationOptions)
@@ -1254,14 +1215,12 @@ def setLinearizationOptions(
12541215

12551216
def setOptimizationOptions(
12561217
self,
1257-
optimizationOptions: str | list[str] | dict[str, Any],
1218+
optimizationOptions: dict[str, Any],
12581219
) -> bool:
12591220
"""
12601221
This method is used to set optimization options. It can be called:
12611222
with a sequence of optimization options name and assigning corresponding values as arguments as show in the example below:
12621223
usage
1263-
>>> setOptimizationOptions("Name=value") # depreciated
1264-
>>> setOptimizationOptions(["Name1=value1","Name2=value2"]) # depreciated
12651224
>>> setOptimizationOptions(optimizationOptions={"Name1": "value1", "Name2": "value2"})
12661225
"""
12671226
inputdata = self._prepare_input_data(raw_input=optimizationOptions)
@@ -1274,16 +1233,14 @@ def setOptimizationOptions(
12741233

12751234
def setInputs(
12761235
self,
1277-
name: str | list[str] | dict[str, Any],
1236+
name: dict[str, Any],
12781237
) -> bool:
12791238
"""
12801239
This method is used to set input values. It can be called with a sequence of input name and assigning
12811240
corresponding values as arguments as show in the example below. Compared to other set*() methods this is a
12821241
special case as value could be a list of tuples - these are converted to a string in _prepare_input_data()
12831242
and restored here via ast.literal_eval().
12841243
1285-
>>> setInputs("Name=value") # depreciated
1286-
>>> setInputs(["Name1=value1","Name2=value2"]) # depreciated
12871244
>>> setInputs(name={"Name1": "value1", "Name2": "value2"})
12881245
"""
12891246
inputdata = self._prepare_input_data(raw_input=name)

0 commit comments

Comments
 (0)