Skip to content

Commit 4c89099

Browse files
authored
remove not needed calls to as_posix() (#378)
1 parent 8926af4 commit 4c89099

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
@@ -2276,12 +2276,12 @@ def get_doe_solutions(
22762276
continue
22772277

22782278
if var_list is None:
2279-
var_list_row = list(self._mod.getSolutions(resultfile=resultfile.as_posix()))
2279+
var_list_row = list(self._mod.getSolutions(resultfile=resultfile))
22802280
else:
22812281
var_list_row = var_list
22822282

22832283
try:
2284-
sol = self._mod.getSolutions(varList=var_list_row, resultfile=resultfile.as_posix())
2284+
sol = self._mod.getSolutions(varList=var_list_row, resultfile=resultfile)
22852285
sol_data = {var: sol[idx] for idx, var in enumerate(var_list_row)}
22862286
sol_dict[resultfilename]['msg'] = 'Simulation available'
22872287
sol_dict[resultfilename]['data'] = sol_data

tests/test_FMIImport.py

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

2222

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

3132
# create FMU & check

tests/test_ModelicaSystem.py

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

4141
def test_ModelicaSystem_loop(model_firstorder):
4242
def worker():
43-
filePath = model_firstorder.as_posix()
4443
mod = OMPython.ModelicaSystem()
4544
mod.model(
46-
model_file=filePath,
45+
model_file=model_firstorder,
4746
model_name="M",
4847
)
4948
mod.simulate()
@@ -139,12 +138,11 @@ def test_relative_path(model_firstorder):
139138

140139

141140
def test_customBuildDirectory(tmp_path, model_firstorder):
142-
filePath = model_firstorder.as_posix()
143141
tmpdir = tmp_path / "tmpdir1"
144142
tmpdir.mkdir()
145143
mod = OMPython.ModelicaSystem(work_directory=tmpdir)
146144
mod.model(
147-
model_file=filePath,
145+
model_file=model_firstorder,
148146
model_name="M",
149147
)
150148
assert pathlib.Path(mod.getWorkDirectory()).resolve() == tmpdir.resolve()
@@ -222,7 +220,7 @@ def test_getters(tmp_path):
222220
""")
223221
mod = OMPython.ModelicaSystem()
224222
mod.model(
225-
model_file=model_file.as_posix(),
223+
model_file=model_file,
226224
model_name="M_getters",
227225
)
228226

@@ -418,7 +416,7 @@ def test_simulate_inputs(tmp_path):
418416
""")
419417
mod = OMPython.ModelicaSystem()
420418
mod.model(
421-
model_file=model_file.as_posix(),
419+
model_file=model_file,
422420
model_name="M_input",
423421
)
424422

tests/test_ModelicaSystemCmd.py

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

tests/test_ModelicaSystemDoE.py

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

5858
doe_mod = OMPython.ModelicaSystemDoE(
59-
model_file=model_doe.as_posix(),
59+
model_file=model_doe,
6060
model_name="M",
6161
parameters=param_doe,
6262
resultpath=tmpdir,
@@ -74,7 +74,7 @@ def test_ModelicaSystemDoE_docker(tmp_path, model_doe, param_doe):
7474
assert omc.sendExpression("getVersion()") == "OpenModelica 1.25.0"
7575

7676
doe_mod = OMPython.ModelicaSystemDoE(
77-
model_file=model_doe.as_posix(),
77+
model_file=model_doe,
7878
model_name="M",
7979
parameters=param_doe,
8080
omc_process=omcp,
@@ -91,7 +91,7 @@ def test_ModelicaSystemDoE_WSL(tmp_path, model_doe, param_doe):
9191
tmpdir.mkdir(exist_ok=True)
9292

9393
doe_mod = OMPython.ModelicaSystemDoE(
94-
model_file=model_doe.as_posix(),
94+
model_file=model_doe,
9595
model_name="M",
9696
parameters=param_doe,
9797
resultpath=tmpdir,

tests/test_linearization.py

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

tests/test_optimization.py

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

3737
mod = OMPython.ModelicaSystem()
3838
mod.model(
39-
model_file=model_file.as_posix(),
39+
model_file=model_file,
4040
model_name="BangBang2021",
4141
)
4242

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

0 commit comments

Comments
 (0)