diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index ccec499b..1a979647 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -2276,12 +2276,12 @@ def get_doe_solutions( continue if var_list is None: - var_list_row = list(self._mod.getSolutions(resultfile=resultfile.as_posix())) + var_list_row = list(self._mod.getSolutions(resultfile=resultfile)) else: var_list_row = var_list try: - sol = self._mod.getSolutions(varList=var_list_row, resultfile=resultfile.as_posix()) + sol = self._mod.getSolutions(varList=var_list_row, resultfile=resultfile) sol_data = {var: sol[idx] for idx, var in enumerate(var_list_row)} sol_dict[resultfilename]['msg'] = 'Simulation available' sol_dict[resultfilename]['data'] = sol_data diff --git a/tests/test_FMIImport.py b/tests/test_FMIImport.py index 44249f5c..cb43e0ae 100644 --- a/tests/test_FMIImport.py +++ b/tests/test_FMIImport.py @@ -21,11 +21,12 @@ def model_firstorder(tmp_path): def test_FMIImport(model_firstorder): - filePath = model_firstorder.as_posix() - # create model & simulate it mod1 = OMPython.ModelicaSystem() - mod1.model(model_file=filePath, model_name="M") + mod1.model( + model_file=model_firstorder, + model_name="M", + ) mod1.simulate() # create FMU & check diff --git a/tests/test_ModelicaSystem.py b/tests/test_ModelicaSystem.py index f49fb20c..8567c426 100644 --- a/tests/test_ModelicaSystem.py +++ b/tests/test_ModelicaSystem.py @@ -40,10 +40,9 @@ def model_firstorder(tmp_path, model_firstorder_content): def test_ModelicaSystem_loop(model_firstorder): def worker(): - filePath = model_firstorder.as_posix() mod = OMPython.ModelicaSystem() mod.model( - model_file=filePath, + model_file=model_firstorder, model_name="M", ) mod.simulate() @@ -139,12 +138,11 @@ def test_relative_path(model_firstorder): def test_customBuildDirectory(tmp_path, model_firstorder): - filePath = model_firstorder.as_posix() tmpdir = tmp_path / "tmpdir1" tmpdir.mkdir() mod = OMPython.ModelicaSystem(work_directory=tmpdir) mod.model( - model_file=filePath, + model_file=model_firstorder, model_name="M", ) assert pathlib.Path(mod.getWorkDirectory()).resolve() == tmpdir.resolve() @@ -222,7 +220,7 @@ def test_getters(tmp_path): """) mod = OMPython.ModelicaSystem() mod.model( - model_file=model_file.as_posix(), + model_file=model_file, model_name="M_getters", ) @@ -418,7 +416,7 @@ def test_simulate_inputs(tmp_path): """) mod = OMPython.ModelicaSystem() mod.model( - model_file=model_file.as_posix(), + model_file=model_file, model_name="M_input", ) diff --git a/tests/test_ModelicaSystemCmd.py b/tests/test_ModelicaSystemCmd.py index d736d5ca..7eaf08ba 100644 --- a/tests/test_ModelicaSystemCmd.py +++ b/tests/test_ModelicaSystemCmd.py @@ -20,7 +20,7 @@ def model_firstorder(tmp_path): def mscmd_firstorder(model_firstorder): mod = OMPython.ModelicaSystem() mod.model( - model_file=model_firstorder.as_posix(), + model_file=model_firstorder, model_name="M", ) mscmd = OMPython.ModelicaSystemCmd( diff --git a/tests/test_ModelicaSystemDoE.py b/tests/test_ModelicaSystemDoE.py index d290c715..f9d70011 100644 --- a/tests/test_ModelicaSystemDoE.py +++ b/tests/test_ModelicaSystemDoE.py @@ -56,7 +56,7 @@ def test_ModelicaSystemDoE_local(tmp_path, model_doe, param_doe): tmpdir.mkdir(exist_ok=True) doe_mod = OMPython.ModelicaSystemDoE( - model_file=model_doe.as_posix(), + model_file=model_doe, model_name="M", parameters=param_doe, resultpath=tmpdir, @@ -74,7 +74,7 @@ def test_ModelicaSystemDoE_docker(tmp_path, model_doe, param_doe): assert omc.sendExpression("getVersion()") == "OpenModelica 1.25.0" doe_mod = OMPython.ModelicaSystemDoE( - model_file=model_doe.as_posix(), + model_file=model_doe, model_name="M", parameters=param_doe, omc_process=omcp, @@ -91,7 +91,7 @@ def test_ModelicaSystemDoE_WSL(tmp_path, model_doe, param_doe): tmpdir.mkdir(exist_ok=True) doe_mod = OMPython.ModelicaSystemDoE( - model_file=model_doe.as_posix(), + model_file=model_doe, model_name="M", parameters=param_doe, resultpath=tmpdir, diff --git a/tests/test_linearization.py b/tests/test_linearization.py index ebfbc100..c61462bb 100644 --- a/tests/test_linearization.py +++ b/tests/test_linearization.py @@ -62,7 +62,7 @@ def test_getters(tmp_path): """) mod = OMPython.ModelicaSystem() mod.model( - model_file=model_file.as_posix(), + model_file=model_file, model_name="Pendulum", libraries=["Modelica"], ) diff --git a/tests/test_optimization.py b/tests/test_optimization.py index 96c6fdbd..be6945f3 100644 --- a/tests/test_optimization.py +++ b/tests/test_optimization.py @@ -36,7 +36,7 @@ def test_optimization_example(tmp_path): mod = OMPython.ModelicaSystem() mod.model( - model_file=model_file.as_posix(), + model_file=model_file, model_name="BangBang2021", ) @@ -57,7 +57,10 @@ def test_optimization_example(tmp_path): # it is necessary to specify resultfile, otherwise it wouldn't find it. resultfile_str = r["resultFile"] resultfile_omcpath = mod.session().omcpath(resultfile_str) - time, f, v = mod.getSolutions(["time", "f", "v"], resultfile=resultfile_omcpath.as_posix()) + time, f, v = mod.getSolutions( + varList=["time", "f", "v"], + resultfile=resultfile_omcpath, + ) assert np.isclose(f[0], 10) assert np.isclose(f[-1], -10)