Skip to content

Commit eedbe45

Browse files
committed
[ModelicaSystem] rename variables
1 parent 2f32f32 commit eedbe45

8 files changed

Lines changed: 42 additions & 42 deletions

OMPython/ModelicaSystem.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ def __init__(
389389

390390
def model(
391391
self,
392-
name: str,
393-
file: Optional[str | os.PathLike] = None,
392+
model_name: str,
393+
model_file: Optional[str | os.PathLike] = None,
394394
libraries: Optional[list[str | tuple[str, str]]] = None,
395395
variable_filter: Optional[str] = None,
396396
build: bool = True,
@@ -400,9 +400,9 @@ def model(
400400
This method loads the model file and builds it if requested (build == True).
401401
402402
Args:
403-
file: Path to the model file. Either absolute or relative to
403+
model_file: Path to the model file. Either absolute or relative to
404404
the current working directory.
405-
name: The name of the model class. If it is contained within
405+
model_name: The name of the model class. If it is contained within
406406
a package, "PackageName.ModelName" should be used.
407407
libraries: List of libraries to be loaded before the model itself is
408408
loaded. Two formats are supported for the list elements:
@@ -428,7 +428,7 @@ def model(
428428
raise ModelicaSystemError("Can not reuse this instance of ModelicaSystem "
429429
f"defined for {repr(self._model_name)}!")
430430

431-
if not isinstance(name, str):
431+
if not isinstance(model_name, str):
432432
raise ModelicaSystemError("A model name must be provided!")
433433

434434
if libraries is None:
@@ -438,16 +438,16 @@ def model(
438438
raise ModelicaSystemError(f"Invalid input type for libraries: {type(libraries)} - list expected!")
439439

440440
# set variables
441-
self._model_name = name # Model class name
441+
self._model_name = model_name # Model class name
442442
self._libraries = libraries # may be needed if model is derived from other model
443443
self._variable_filter = variable_filter
444444

445445
if self._libraries:
446446
self._loadLibrary(libraries=self._libraries)
447447

448448
self._file_name = None
449-
if file is not None:
450-
file_path = pathlib.Path(file)
449+
if model_file is not None:
450+
file_path = pathlib.Path(model_file)
451451
# special handling for OMCProcessLocal - consider a relative path
452452
if isinstance(self._session.omc_process, OMCProcessLocal) and not file_path.is_absolute():
453453
file_path = pathlib.Path.cwd() / file_path
@@ -1676,8 +1676,8 @@ def convertFmu2Mo(
16761676
raise ModelicaSystemError(f"Missing file {filepath.as_posix()}")
16771677

16781678
self.model(
1679-
name=f"{fmu_path.stem}_me_FMU",
1680-
file=filepath,
1679+
model_name=f"{fmu_path.stem}_me_FMU",
1680+
model_file=filepath,
16811681
)
16821682

16831683
return filepath
@@ -1951,8 +1951,8 @@ def __init__(
19511951
omc_process=omc_process,
19521952
)
19531953
self._mod.model(
1954-
file=fileName,
1955-
name=modelName,
1954+
model_file=fileName,
1955+
model_name=modelName,
19561956
libraries=lmodel,
19571957
variable_filter=variableFilter,
19581958
)

tests/test_FMIExport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
def test_CauerLowPassAnalog():
88
mod = OMPython.ModelicaSystem()
99
mod.model(
10-
name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog",
10+
model_name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog",
1111
libraries=["Modelica"],
1212
)
1313
tmp = pathlib.Path(mod.getWorkDirectory())
@@ -21,7 +21,7 @@ def test_CauerLowPassAnalog():
2121
def test_DrumBoiler():
2222
mod = OMPython.ModelicaSystem()
2323
mod.model(
24-
name="Modelica.Fluid.Examples.DrumBoiler.DrumBoiler",
24+
model_name="Modelica.Fluid.Examples.DrumBoiler.DrumBoiler",
2525
libraries=["Modelica"],
2626
)
2727
tmp = pathlib.Path(mod.getWorkDirectory())

tests/test_FMIImport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_FMIImport(model_firstorder):
2424

2525
# create model & simulate it
2626
mod1 = OMPython.ModelicaSystem()
27-
mod1.model(file=filePath, name="M")
27+
mod1.model(model_file=filePath, model_name="M")
2828
mod1.simulate()
2929

3030
# create FMU & check

tests/test_ModelicaSystem.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def worker():
4040
filePath = model_firstorder.as_posix()
4141
mod = OMPython.ModelicaSystem()
4242
mod.model(
43-
file=filePath,
44-
name="M",
43+
model_file=filePath,
44+
model_name="M",
4545
)
4646
mod.simulate()
4747
mod.convertMo2Fmu(fmuType="me")
@@ -55,8 +55,8 @@ def test_setParameters():
5555
model_path = omc.omcpath(model_path_str)
5656
mod = OMPython.ModelicaSystem()
5757
mod.model(
58-
file=model_path / "BouncingBall.mo",
59-
name="BouncingBall",
58+
model_file=model_path / "BouncingBall.mo",
59+
model_name="BouncingBall",
6060
)
6161

6262
# method 1 (test depreciated variants)
@@ -90,8 +90,8 @@ def test_setSimulationOptions():
9090
model_path = omc.omcpath(model_path_str)
9191
mod = OMPython.ModelicaSystem()
9292
mod.model(
93-
file=model_path / "BouncingBall.mo",
94-
name="BouncingBall",
93+
model_file=model_path / "BouncingBall.mo",
94+
model_name="BouncingBall",
9595
)
9696

9797
# method 1
@@ -127,8 +127,8 @@ def test_relative_path(model_firstorder):
127127

128128
mod = OMPython.ModelicaSystem()
129129
mod.model(
130-
file=model_relative,
131-
name="M",
130+
model_file=model_relative,
131+
model_name="M",
132132
)
133133
assert float(mod.getParameters("a")[0]) == -1
134134
finally:
@@ -141,8 +141,8 @@ def test_customBuildDirectory(tmp_path, model_firstorder):
141141
tmpdir.mkdir()
142142
mod = OMPython.ModelicaSystem(customBuildDirectory=tmpdir)
143143
mod.model(
144-
file=filePath,
145-
name="M",
144+
model_file=filePath,
145+
model_name="M",
146146
)
147147
assert pathlib.Path(mod.getWorkDirectory()).resolve() == tmpdir.resolve()
148148
result_file = tmpdir / "a.mat"
@@ -161,8 +161,8 @@ def test_getSolutions_docker(model_firstorder):
161161
omc_process=omc.omc_process,
162162
)
163163
mod.model(
164-
name="M",
165-
file=model_firstorder.as_posix(),
164+
model_file=model_firstorder,
165+
model_name="M",
166166
)
167167

168168
_run_getSolutions(mod)
@@ -171,8 +171,8 @@ def test_getSolutions_docker(model_firstorder):
171171
def test_getSolutions(model_firstorder):
172172
mod = OMPython.ModelicaSystem()
173173
mod.model(
174-
file=model_firstorder.as_posix(),
175-
name="M",
174+
model_file=model_firstorder,
175+
model_name="M",
176176
)
177177

178178
_run_getSolutions(mod)
@@ -219,8 +219,8 @@ def test_getters(tmp_path):
219219
""")
220220
mod = OMPython.ModelicaSystem()
221221
mod.model(
222-
file=model_file.as_posix(),
223-
name="M_getters",
222+
model_file=model_file.as_posix(),
223+
model_name="M_getters",
224224
)
225225

226226
q = mod.getQuantities()
@@ -415,8 +415,8 @@ def test_simulate_inputs(tmp_path):
415415
""")
416416
mod = OMPython.ModelicaSystem()
417417
mod.model(
418-
file=model_file.as_posix(),
419-
name="M_input",
418+
model_file=model_file.as_posix(),
419+
model_name="M_input",
420420
)
421421

422422
simOptions = {"stopTime": 1.0}

tests/test_ModelicaSystemCmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def model_firstorder(tmp_path):
1919
def mscmd_firstorder(model_firstorder):
2020
mod = OMPython.ModelicaSystem()
2121
mod.model(
22-
file=model_firstorder.as_posix(),
23-
name="M",
22+
model_file=model_firstorder.as_posix(),
23+
model_name="M",
2424
)
2525
mscmd = OMPython.ModelicaSystemCmd(
2626
session=mod.session(),

tests/test_OMSessionCmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_isPackage():
1010
def test_isPackage2():
1111
mod = OMPython.ModelicaSystem()
1212
mod.model(
13-
name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog",
13+
model_name="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog",
1414
libraries=["Modelica"],
1515
)
1616
omccmd = OMPython.OMCSessionCmd(session=mod.session())

tests/test_linearization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def model_linearTest(tmp_path):
2626
def test_example(model_linearTest):
2727
mod = OMPython.ModelicaSystem()
2828
mod.model(
29-
file=model_linearTest,
30-
name="linearTest",
29+
model_file=model_linearTest,
30+
model_name="linearTest",
3131
)
3232
[A, B, C, D] = mod.linearize()
3333
expected_matrixA = [[-3, 2, 0, 0], [-7, 0, -5, 1], [-1, 0, -1, 4], [0, 1, -1, 5]]
@@ -61,8 +61,8 @@ def test_getters(tmp_path):
6161
""")
6262
mod = OMPython.ModelicaSystem()
6363
mod.model(
64-
file=model_file.as_posix(),
65-
name="Pendulum",
64+
model_file=model_file.as_posix(),
65+
model_name="Pendulum",
6666
libraries=["Modelica"],
6767
)
6868

tests/test_optimization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def test_optimization_example(tmp_path):
3535

3636
mod = OMPython.ModelicaSystem()
3737
mod.model(
38-
file=model_file.as_posix(),
39-
name="BangBang2021",
38+
model_file=model_file.as_posix(),
39+
model_name="BangBang2021",
4040
)
4141

4242
optimizationOptions = {

0 commit comments

Comments
 (0)