Skip to content

Commit 971add6

Browse files
committed
[ModelicaSystem] simplify _set_method_helper()
1 parent df7b037 commit 971add6

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

OMPython/ModelicaSystem.py

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

11561156
inputdata_status: dict[str, bool] = {}
11571157
for key, val in inputdata.items():
1158-
status = False
1159-
if key in classdata:
1160-
if datatype == "parameter" and not self.isParameterChangeable(key):
1161-
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1162-
"structural, final, protected, evaluated or has a non-constant binding. "
1163-
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1164-
"sendExpression(\"setParameterValue("
1165-
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1166-
")\") ")
1167-
else:
1168-
classdata[key] = val
1169-
if overwritedata is not None:
1170-
overwritedata[key] = val
1171-
status = True
1172-
else:
1158+
if key not in classdata:
11731159
raise ModelicaSystemError("Unhandled case in setMethodHelper.apply_single() - "
11741160
f"{repr(key)} is not a {repr(datatype)} variable")
11751161

1162+
status = False
1163+
if datatype == "parameter" and not self.isParameterChangeable(key):
1164+
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1165+
"structural, final, protected, evaluated or has a non-constant binding. "
1166+
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1167+
"sendExpression(\"setParameterValue("
1168+
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1169+
")\") ")
1170+
else:
1171+
classdata[key] = val
1172+
if overwritedata is not None:
1173+
overwritedata[key] = val
1174+
status = True
1175+
11761176
inputdata_status[key] = status
11771177

11781178
return all(inputdata_status.values())

0 commit comments

Comments
 (0)