@@ -350,7 +350,8 @@ def __init__(
350350 self ._session = OMCSessionLocal (omhome = omhome )
351351
352352 # get OpenModelica version
353- self ._version = self ._session .sendExpression ("getVersion()" , parsed = True )
353+ version_str = self ._session .sendExpression ("getVersion()" , parsed = True )
354+ self ._version = self ._parse_om_version (version = version_str )
354355 # set commandLineOptions using default values or the user defined list
355356 if command_line_options is None :
356357 # set default command line options to improve the performance of linearization and to avoid recompilation if
@@ -1022,11 +1023,12 @@ def getOptimizationOptions(
10221023
10231024 raise ModelicaSystemError ("Unhandled input for getOptimizationOptions()" )
10241025
1025- def parse_om_version (self , version : str ) -> tuple [int , int , int ]:
1026+ def _parse_om_version (self , version : str ) -> tuple [int , int , int ]:
10261027 match = re .search (r"v?(\d+)\.(\d+)\.(\d+)" , version )
10271028 if not match :
10281029 raise ValueError (f"Version not found in: { version } " )
10291030 major , minor , patch = map (int , match .groups ())
1031+
10301032 return major , minor , patch
10311033
10321034 def simulate_cmd (
@@ -1078,8 +1080,7 @@ def simulate_cmd(
10781080 # simulation options are not read from override file from version >= 1.26.0,
10791081 # pass them to simulation executable directly as individual arguments
10801082 # see https://github.com/OpenModelica/OpenModelica/pull/14813
1081- major , minor , patch = self .parse_om_version (self ._version )
1082- if (major , minor , patch ) >= (1 , 26 , 0 ):
1083+ if self ._version >= Version ("1.26.0" ):
10831084 for key , opt_value in self ._simulate_options_override .items ():
10841085 om_cmd .arg_set (key = key , val = str (opt_value ))
10851086 override_content = (
@@ -1775,8 +1776,7 @@ def linearize(
17751776 )
17761777
17771778 # See comment in simulate_cmd regarding override file and OM version
1778- major , minor , patch = self .parse_om_version (self ._version )
1779- if (major , minor , patch ) >= (1 , 26 , 0 ):
1779+ if self ._version >= Version ("1.26.0" ):
17801780 for key , opt_value in self ._linearization_options .items ():
17811781 om_cmd .arg_set (key = key , val = str (opt_value ))
17821782 override_content = (
0 commit comments