Skip to content

Commit fda379b

Browse files
committed
[ModelicaSystem] simplify _set_method_helper()
1 parent 48791a2 commit fda379b

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
@@ -1068,24 +1068,24 @@ def _set_method_helper(
10681068

10691069
inputdata_status: dict[str, bool] = {}
10701070
for key, val in inputdata.items():
1071-
status = False
1072-
if key in classdata:
1073-
if datatype == "parameter" and not self.isParameterChangeable(key):
1074-
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1075-
"structural, final, protected, evaluated or has a non-constant binding. "
1076-
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1077-
"sendExpression(\"setParameterValue("
1078-
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1079-
")\") ")
1080-
else:
1081-
classdata[key] = val
1082-
if overwritedata is not None:
1083-
overwritedata[key] = val
1084-
status = True
1085-
else:
1071+
if key not in classdata:
10861072
raise ModelicaSystemError("Unhandled case in setMethodHelper.apply_single() - "
10871073
f"{repr(key)} is not a {repr(datatype)} variable")
10881074

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

10911091
return all(inputdata_status.values())

0 commit comments

Comments
 (0)