From f7593777dcf0f035f1934c68589f4b1e871a0ca3 Mon Sep 17 00:00:00 2001 From: syntron Date: Sat, 24 Jan 2026 15:14:31 +0100 Subject: [PATCH 1/3] [ModelicaSystemOMC] add docstring for sendExpression() --- OMPython/ModelicaSystem.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 03c24b51..3a8521b4 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -560,6 +560,9 @@ def buildModel(self, variableFilter: Optional[str] = None): self._xmlparse(xml_file=xml_file) def sendExpression(self, expr: str, parsed: bool = True) -> Any: + """ + Wrapper for OMCSession.sendExpression(). + """ try: retval = self._session.sendExpression(expr=expr, parsed=parsed) except OMCSessionException as ex: From 33685c8d14564d2e6dff357edf120cfd940819e7 Mon Sep 17 00:00:00 2001 From: syntron Date: Wed, 21 Jan 2026 20:23:21 +0100 Subject: [PATCH 2/3] [ModelicaSystemBase] define parse_om_version() as staticmethod --- OMPython/ModelicaSystem.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 3a8521b4..aae06327 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -1026,8 +1026,12 @@ def getOptimizationOptions( raise ModelicaSystemError("Unhandled input for getOptimizationOptions()") - def _parse_om_version(self, version: str) -> tuple[int, int, int]: - match = re.search(r"v?(\d+)\.(\d+)\.(\d+)", version) + @staticmethod + def _parse_om_version(version: str) -> tuple[int, int, int]: + """ + Evaluate an OMC version string and return a tuple of (epoch, major, minor). + """ + match = re.search(pattern=r"v?(\d+)\.(\d+)\.(\d+)", string=version) if not match: raise ValueError(f"Version not found in: {version}") major, minor, patch = map(int, match.groups()) From bf1491a7bfbf87a25e301d9515abd48f39413e5a Mon Sep 17 00:00:00 2001 From: syntron Date: Sat, 24 Jan 2026 15:16:44 +0100 Subject: [PATCH 3/3] [ModelicaSystemBase] include the original exception if reraised as ModelExecutionException --- OMPython/ModelicaSystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index aae06327..cc219cab 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -1860,7 +1860,7 @@ def linearize( linear_data[target] = value_ast except (AttributeError, IndexError, ValueError, SyntaxError, TypeError) as ex: - raise ModelicaSystemError(f"Error parsing linearization file {linear_file}!") from ex + raise ModelicaSystemError(f"Error parsing linearization file {linear_file}: {ex}") from ex # remove the file linear_file.unlink()