Skip to content

Commit 0907e3f

Browse files
committed
Merge remote-tracking branch 'origin/method-set-param-and-boundary-file' into method-set-param-and-boundary-file
# Conflicts: # modelitool/simulate.py
2 parents 30abed1 + 1fa780c commit 0907e3f

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

tests/test_simulate.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pathlib import Path
2+
23
import pytest
4+
35
import numpy as np
46
import pandas as pd
57

@@ -114,12 +116,19 @@ def test_set_boundaries_df(self):
114116
)
115117

116118
simulation_options_with_x = simulation_options.copy()
117-
simulation_options_with_x['x'] = x_options
119+
simulation_options_with_x["x"] = x_options
118120
res1 = simu.simulate(simulation_options=simulation_options_with_x)
119121
res1 = res1.loc[:, ["Boundaries.y[1]", "Boundaries.y[2]"]]
120122
np.testing.assert_allclose(x_options.to_numpy(), res1.to_numpy())
121-
assert np.all([x_options.index[i] == res1.index[i] for i in range(len(x_options.index))])
122-
assert np.all([x_options.columns[i] == res1.columns[i] for i in range(len(x_options.columns))])
123+
assert np.all(
124+
[x_options.index[i] == res1.index[i] for i in range(len(x_options.index))]
125+
)
126+
assert np.all(
127+
[
128+
x_options.columns[i] == res1.columns[i]
129+
for i in range(len(x_options.columns))
130+
]
131+
)
123132

124133
simu = OMModel(
125134
model_path="TestLib.boundary_test",
@@ -129,18 +138,29 @@ def test_set_boundaries_df(self):
129138
res2 = simu.simulate(simulation_options=simulation_options, x=x_direct)
130139
res2 = res2.loc[:, ["Boundaries.y[1]", "Boundaries.y[2]"]]
131140
np.testing.assert_allclose(x_direct.to_numpy(), res2.to_numpy())
132-
assert np.all([x_direct.index[i] == res2.index[i] for i in range(len(x_direct.index))])
133-
assert np.all([x_direct.columns[i] == res2.columns[i] for i in range(len(x_direct.columns))])
141+
assert np.all(
142+
[x_direct.index[i] == res2.index[i] for i in range(len(x_direct.index))]
143+
)
144+
assert np.all(
145+
[
146+
x_direct.columns[i] == res2.columns[i]
147+
for i in range(len(x_direct.columns))
148+
]
149+
)
134150

135151
simu = OMModel(
136152
model_path="TestLib.boundary_test",
137153
package_path=PACKAGE_DIR / "package.mo",
138154
lmodel=["Modelica"],
139155
)
140-
with pytest.warns(UserWarning,
141-
match="Boundary file 'x' specified both in simulation_options and as a direct parameter"):
142-
res3 = simu.simulate(simulation_options=simulation_options_with_x, x=x_direct)
156+
with pytest.warns(
157+
UserWarning,
158+
match="Boundary file 'x' specified both in simulation_options and as a direct parameter",
159+
):
160+
res3 = simu.simulate(
161+
simulation_options=simulation_options_with_x, x=x_direct
162+
)
143163
res3 = res3.loc[:, ["Boundaries.y[1]", "Boundaries.y[2]"]]
144164
np.testing.assert_allclose(x_direct.to_numpy(), res3.to_numpy())
145165
with pytest.raises(AssertionError):
146-
np.testing.assert_allclose(x_options.to_numpy(), res3.to_numpy())
166+
np.testing.assert_allclose(x_options.to_numpy(), res3.to_numpy())

0 commit comments

Comments
 (0)