Skip to content

Commit 977b49d

Browse files
committed
[ModelicaSystem] simplify _set_method_helper()
1 parent 31a7ad2 commit 977b49d

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
@@ -1196,24 +1196,24 @@ def _set_method_helper(
11961196

11971197
inputdata_status: dict[str, bool] = {}
11981198
for key, val in inputdata.items():
1199-
status = False
1200-
if key in classdata:
1201-
if datatype == "parameter" and not self.isParameterChangeable(key):
1202-
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1203-
"structural, final, protected, evaluated or has a non-constant binding. "
1204-
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1205-
"sendExpression(\"setParameterValue("
1206-
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1207-
")\") ")
1208-
else:
1209-
classdata[key] = val
1210-
if overwritedata is not None:
1211-
overwritedata[key] = val
1212-
status = True
1213-
else:
1199+
if key not in classdata:
12141200
raise ModelicaSystemError("Unhandled case in setMethodHelper.apply_single() - "
12151201
f"{repr(key)} is not a {repr(datatype)} variable")
12161202

1203+
status = False
1204+
if datatype == "parameter" and not self.isParameterChangeable(key):
1205+
logger.debug(f"It is not possible to set the parameter {repr(key)}. It seems to be "
1206+
"structural, final, protected, evaluated or has a non-constant binding. "
1207+
"Use sendExpression(...) and rebuild the model using buildModel() API; example: "
1208+
"sendExpression(\"setParameterValue("
1209+
f"{self.modelName}, {key}, {val if val is not None else '<?value?>'}"
1210+
")\") ")
1211+
else:
1212+
classdata[key] = val
1213+
if overwritedata is not None:
1214+
overwritedata[key] = val
1215+
status = True
1216+
12171217
inputdata_status[key] = status
12181218

12191219
return all(inputdata_status.values())

0 commit comments

Comments
 (0)