Skip to content

Commit a1500ab

Browse files
committed
[ModelicaSystem] fix mypy - plot_result_file could be None
1 parent c459f6a commit a1500ab

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

OMPython/ModelicaSystem.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,12 +1154,13 @@ def plot(
11541154
ModelicaSystemError("No resultfile available - either run simulate() before plotting "
11551155
"or provide a result file!")
11561156

1157-
if not plot_result_file.is_file():
1157+
if plot_result_file is None:
1158+
ModelicaSystemError("No resultfile defined!")
1159+
elif not plot_result_file.is_file():
11581160
ModelicaSystemError(f"Provided resultfile {repr(plot_result_file.as_posix())} does not exists!")
1159-
1160-
expr = f'plot({plotdata}, fileName="{plot_result_file.as_posix()}")'
1161-
1162-
self.sendExpression(expr=expr)
1161+
else:
1162+
expr = f'plot({plotdata}, fileName="{plot_result_file.as_posix()}")'
1163+
self.sendExpression(expr=expr)
11631164

11641165
def getSolutions(self, varList: Optional[str | list[str]] = None, resultfile: Optional[str] = None) -> tuple[str] | np.ndarray:
11651166
"""Extract simulation results from a result data file.

0 commit comments

Comments
 (0)