Skip to content

Commit 0389dfe

Browse files
committed
??? fix errors ...
1 parent 7c88663 commit 0389dfe

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

OMPython/ModelicaSystem.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def __init__(
131131
variableFilter: Optional[str] = None,
132132
customBuildDirectory: Optional[str | os.PathLike] = None,
133133
omhome: Optional[str] = None,
134-
session: Optional[OMCSessionBase] = None
134+
session: Optional[OMCSessionZMQ] = None
135135
):
136136
"""Initialize, load and build a model.
137137
@@ -237,7 +237,7 @@ def setCommandLineOptions(self, commandLineOptions: str):
237237
exp = f'setCommandLineOptions("{commandLineOptions}")'
238238
self.sendExpression(exp)
239239

240-
def loadFile(self, fileName: Path):
240+
def loadFile(self, fileName: pathlib.Path):
241241
# load file
242242
self.sendExpression(f'loadFile("{fileName.as_posix()}")')
243243

@@ -460,7 +460,7 @@ def getContinuous(self, names=None): # 4
460460
raise ModelicaSystemError(f"{i} is not continuous")
461461
return valuelist
462462

463-
raise ModelicaSystemError(f"Unhandled input for getContinous()")
463+
raise ModelicaSystemError("Unhandled input for getContinous()")
464464

465465
def getParameters(self, names: Optional[str | list[str]] = None) -> dict[str, str] | list[str]: # 5
466466
"""Get parameter values.
@@ -491,7 +491,7 @@ def getParameters(self, names: Optional[str | list[str]] = None) -> dict[str, st
491491
elif isinstance(names, list):
492492
return [self.paramlist.get(x, "NotExist") for x in names]
493493

494-
raise ModelicaSystemError(f"Unhandled input for getParameters()")
494+
raise ModelicaSystemError("Unhandled input for getParameters()")
495495

496496
def getInputs(self, names: Optional[str | list[str]] = None) -> dict | list: # 6
497497
"""Get input values.
@@ -527,7 +527,7 @@ def getInputs(self, names: Optional[str | list[str]] = None) -> dict | list: #
527527
elif isinstance(names, list):
528528
return [self.inputlist.get(x, "NotExist") for x in names]
529529

530-
raise ModelicaSystemError(f"Unhandled input for getInputs()")
530+
raise ModelicaSystemError("Unhandled input for getInputs()")
531531

532532
def getOutputs(self, names: Optional[str | list[str]] = None): # 7
533533
"""Get output values.
@@ -925,7 +925,7 @@ def checkValidInputs(self, name):
925925
else:
926926
ModelicaSystemError('Error!!! Value must be in tuple format')
927927

928-
def createCSVData(self) -> Path:
928+
def createCSVData(self) -> pathlib.Path:
929929
start_time: float = float(self.simulateOptions["startTime"])
930930
stop_time: float = float(self.simulateOptions["stopTime"])
931931

@@ -972,7 +972,7 @@ def createCSVData(self) -> Path:
972972
writer = csv.writer(f)
973973
writer.writerows(csv_rows)
974974

975-
return csvfile
975+
return csvFile
976976

977977
# to convert Modelica model to FMU
978978
def convertMo2Fmu(self, version="2.0", fmuType="me_cs", fileNamePrefix="<default>", includeResources=True): # 19
@@ -1012,10 +1012,10 @@ def convertFmu2Mo(self, fmuName): # 20
10121012
fmuFileName = self.requestApi('importFMU', fmuName)
10131013

10141014
# report proper error message
1015-
if not os.path.exists(fileName):
1015+
if not os.path.exists(fmuFileName):
10161016
raise ModelicaSystemError(f"Missing FMU file {fmuFileName}")
10171017

1018-
return fileName
1018+
return fmuFileName
10191019

10201020
# to optimize model
10211021
def optimize(self): # 21
@@ -1105,7 +1105,7 @@ def linearize(self, lintime: Optional[float] = None, simflags: Optional[str] = N
11051105
linearFile = pathlib.Path(f'linear_{self.modelName}.py')
11061106

11071107
if not linearFile.exists():
1108-
raise ModelicaSystemError(f"Linearization failed: {linearFile} not found: {errormsg}")
1108+
raise ModelicaSystemError(f"Linearization failed: {linearFile} not found!")
11091109

11101110
# this function is called from the generated python code linearized_model.py at runtime,
11111111
# to improve the performance by directly reading the matrices A, B, C and D from the julia code and avoid building the linearized modelica model

OMPython/OMCSession.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ def _ask(self, question: str, opt: Optional[list[str]] = None, parsed: Optional[
116116
if opt is None:
117117
expression = question
118118
elif isinstance(opt, list):
119-
expression = f'{question}({','.join(opt)})'
119+
expression = f"{question}({','.join(opt)})"
120120
else:
121-
raise OMCSessionException(f"Invalid definition of options: {repr(opt)}")
121+
raise OMCSessionException(f"Invalid definition of options for {repr(question)}: {repr(opt)}")
122122

123123
p = (expression, parsed)
124124

@@ -313,8 +313,6 @@ def __init__(self, readonly=False, timeout=10.00,
313313
if dockerExtraArgs is None:
314314
dockerExtraArgs = []
315315

316-
super().__init__(readonly=readonly)
317-
318316
self.omhome = self._get_omhome(omhome=omhome)
319317

320318
self._omc_process = None

0 commit comments

Comments
 (0)