Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -1023,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())
Expand Down Expand Up @@ -1853,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()
Expand Down