Skip to content

Commit 6777a87

Browse files
committed
remove not needed calls to as_posix()
1 parent 53abbc1 commit 6777a87

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

OMPython/ModelicaSystem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,12 +2271,12 @@ def get_doe_solutions(
22712271
continue
22722272

22732273
if var_list is None:
2274-
var_list_row = list(self._mod.getSolutions(resultfile=resultfile.as_posix()))
2274+
var_list_row = list(self._mod.getSolutions(resultfile=resultfile))
22752275
else:
22762276
var_list_row = var_list
22772277

22782278
try:
2279-
sol = self._mod.getSolutions(varList=var_list_row, resultfile=resultfile.as_posix())
2279+
sol = self._mod.getSolutions(varList=var_list_row, resultfile=resultfile)
22802280
sol_data = {var: sol[idx] for idx, var in enumerate(var_list_row)}
22812281
sol_dict[resultfilename]['msg'] = 'Simulation available'
22822282
sol_dict[resultfilename]['data'] = sol_data

tests/test_FMIImport.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ def model_firstorder(tmp_path):
2020

2121

2222
def test_FMIImport(model_firstorder):
23-
filePath = model_firstorder.as_posix()
24-
2523
# create model & simulate it
2624
mod1 = OMPython.ModelicaSystem()
27-
mod1.model(model_file=filePath, model_name="M")
25+
mod1.model(
26+
model_file=model_firstorder,
27+
model_name="M",
28+
)
2829
mod1.simulate()
2930

3031
# create FMU & check

tests/test_ModelicaSystem.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ def model_firstorder(tmp_path, model_firstorder_content):
3737

3838
def test_ModelicaSystem_loop(model_firstorder):
3939
def worker():
40-
filePath = model_firstorder.as_posix()
4140
mod = OMPython.ModelicaSystem()
4241
mod.model(
43-
model_file=filePath,
42+
model_file=model_firstorder,
4443
model_name="M",
4544
)
4645
mod.simulate()
@@ -136,12 +135,11 @@ def test_relative_path(model_firstorder):
136135

137136

138137
def test_customBuildDirectory(tmp_path, model_firstorder):
139-
filePath = model_firstorder.as_posix()
140138
tmpdir = tmp_path / "tmpdir1"
141139
tmpdir.mkdir()
142140
mod = OMPython.ModelicaSystem(work_directory=tmpdir)
143141
mod.model(
144-
model_file=filePath,
142+
model_file=model_firstorder,
145143
model_name="M",
146144
)
147145
assert pathlib.Path(mod.getWorkDirectory()).resolve() == tmpdir.resolve()
@@ -219,7 +217,7 @@ def test_getters(tmp_path):
219217
""")
220218
mod = OMPython.ModelicaSystem()
221219
mod.model(
222-
model_file=model_file.as_posix(),
220+
model_file=model_file,
223221
model_name="M_getters",
224222
)
225223

@@ -415,7 +413,7 @@ def test_simulate_inputs(tmp_path):
415413
""")
416414
mod = OMPython.ModelicaSystem()
417415
mod.model(
418-
model_file=model_file.as_posix(),
416+
model_file=model_file,
419417
model_name="M_input",
420418
)
421419

tests/test_ModelicaSystemCmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def model_firstorder(tmp_path):
1919
def mscmd_firstorder(model_firstorder):
2020
mod = OMPython.ModelicaSystem()
2121
mod.model(
22-
model_file=model_firstorder.as_posix(),
22+
model_file=model_firstorder,
2323
model_name="M",
2424
)
2525
mscmd = OMPython.ModelicaSystemCmd(

tests/test_ModelicaSystemDoE.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_ModelicaSystemDoE_local(tmp_path, model_doe, param_doe):
5454
tmpdir.mkdir(exist_ok=True)
5555

5656
doe_mod = OMPython.ModelicaSystemDoE(
57-
model_file=model_doe.as_posix(),
57+
model_file=model_doe,
5858
model_name="M",
5959
parameters=param_doe,
6060
resultpath=tmpdir,
@@ -72,7 +72,7 @@ def test_ModelicaSystemDoE_docker(tmp_path, model_doe, param_doe):
7272
assert omc.sendExpression("getVersion()") == "OpenModelica 1.25.0"
7373

7474
doe_mod = OMPython.ModelicaSystemDoE(
75-
model_file=model_doe.as_posix(),
75+
model_file=model_doe,
7676
model_name="M",
7777
parameters=param_doe,
7878
omc_process=omcp,
@@ -89,7 +89,7 @@ def test_ModelicaSystemDoE_WSL(tmp_path, model_doe, param_doe):
8989
tmpdir.mkdir(exist_ok=True)
9090

9191
doe_mod = OMPython.ModelicaSystemDoE(
92-
model_file=model_doe.as_posix(),
92+
model_file=model_doe,
9393
model_name="M",
9494
parameters=param_doe,
9595
resultpath=tmpdir,

tests/test_linearization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_getters(tmp_path):
6161
""")
6262
mod = OMPython.ModelicaSystem()
6363
mod.model(
64-
model_file=model_file.as_posix(),
64+
model_file=model_file,
6565
model_name="Pendulum",
6666
libraries=["Modelica"],
6767
)

tests/test_optimization.py

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

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

@@ -56,7 +56,10 @@ def test_optimization_example(tmp_path):
5656
# it is necessary to specify resultfile, otherwise it wouldn't find it.
5757
resultfile_str = r["resultFile"]
5858
resultfile_omcpath = mod.session().omcpath(resultfile_str)
59-
time, f, v = mod.getSolutions(["time", "f", "v"], resultfile=resultfile_omcpath.as_posix())
59+
time, f, v = mod.getSolutions(
60+
varList=["time", "f", "v"],
61+
resultfile=resultfile_omcpath,
62+
)
6063
assert np.isclose(f[0], 10)
6164
assert np.isclose(f[-1], -10)
6265

0 commit comments

Comments
 (0)