Skip to content

Commit 36ca683

Browse files
committed
[ModelicaSystem] simplify _set_method_helper()
1 parent 9ec7edd commit 36ca683

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

OMPython/ModelicaSystem.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,24 +1075,24 @@ def _set_method_helper(
10751075

10761076
inputdata_status: dict[str, bool] = {}
10771077
for key, val in inputdata.items():
1078-
status = False
1079-
if key in classdata:
1080-
if datatype == "parameter" and not self.isParameterChangeable(key):
1081-
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1082-
"structural, final, protected, evaluated or has a non-constant binding. "
1083-
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1084-
"sendExpression(\"setParameterValue("
1085-
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1086-
")\") ")
1087-
else:
1088-
classdata[key] = val
1089-
if overwritedata is not None:
1090-
overwritedata[key] = val
1091-
status = True
1092-
else:
1078+
if key not in classdata:
10931079
raise ModelicaSystemError("Unhandled case in setMethodHelper.apply_single() - "
10941080
f"{repr(key)} is not a {repr(datatype)} variable")
10951081

1082+
status = False
1083+
if datatype == "parameter" and not self.isParameterChangeable(key):
1084+
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1085+
"structural, final, protected, evaluated or has a non-constant binding. "
1086+
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1087+
"sendExpression(\"setParameterValue("
1088+
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1089+
")\") ")
1090+
else:
1091+
classdata[key] = val
1092+
if overwritedata is not None:
1093+
overwritedata[key] = val
1094+
status = True
1095+
10961096
inputdata_status[key] = status
10971097

10981098
return all(inputdata_status.values())

0 commit comments

Comments
 (0)