Skip to content

Commit ba03555

Browse files
committed
Use setCommandLineOptions()
... instead of raw sendExpression. Seems cleaner and improves test coverage.
1 parent 1ce9ab8 commit ba03555

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

OMPython/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ def __init__(self, fileName=None, modelName=None, lmodel=None, commandLineOption
697697
# set default command Line Options for linearization as
698698
# linearize() will use the simulation executable and runtime
699699
# flag -l to perform linearization
700-
self.sendExpression('setCommandLineOptions("--linearizationDumpLanguage=python")')
701-
self.sendExpression('setCommandLineOptions("--generateSymbolicLinearization")')
700+
self.setCommandLineOptions("--linearizationDumpLanguage=python")
701+
self.setCommandLineOptions("--generateSymbolicLinearization")
702702

703703
self.setTempDirectory(customBuildDirectory)
704704

@@ -714,10 +714,11 @@ def __init__(self, fileName=None, modelName=None, lmodel=None, commandLineOption
714714

715715
def setCommandLineOptions(self, commandLineOptions: str):
716716
# set commandLineOptions if provided by users
717-
if commandLineOptions is not None:
718-
exp = f'setCommandLineOptions("{commandLineOptions}")'
719-
if not self.sendExpression(exp):
720-
self._check_error()
717+
if commandLineOptions is None:
718+
return
719+
exp = f'setCommandLineOptions("{commandLineOptions}")'
720+
if not self.sendExpression(exp):
721+
self._check_error()
721722

722723
def loadFile(self):
723724
# load file
@@ -1540,7 +1541,7 @@ def optimize(self): # 21
15401541
"""
15411542
cName = self.modelName
15421543
properties = ','.join(f"{key}={val}" for key, val in self.optimizeOptions.items())
1543-
self.sendExpression('setCommandLineOptions("-g=Optimica")')
1544+
self.setCommandLineOptions("-g=Optimica")
15441545
optimizeResult = self.requestApi('optimize', cName, properties)
15451546
self._check_error()
15461547

0 commit comments

Comments
 (0)