Skip to content

Commit ee99017

Browse files
committedAug 14, 2024
add test_rejection
wrote a test to check wheter the rejection class works as intendet
1 parent f3d3ae7 commit ee99017

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed
 

Diff for: ‎pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ indent-width = 4
7272

7373
[tool.ruff.lint]
7474
select = ["E", "F", "W"]
75-
ignore = ["F401"]
75+
ignore = ["F401"]

Diff for: ‎tests/test_rejection.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import numpy as np
2+
import pytest
3+
4+
from CADETPythonSimulator.rejection import (
5+
RejectionBase, StepCutOff
6+
)
7+
8+
9+
10+
11+
12+
13+
14+
15+
TestCaseCutof = {
16+
"model": StepCutOff,
17+
"model_param": {
18+
"cutoff_weight": 0.5
19+
},
20+
"weights": [0, 0.5, 1],
21+
"expected": [0, 1, 1]
22+
}
23+
24+
@pytest.mark.parametrize(
25+
"parameters",
26+
[
27+
TestCaseCutof
28+
]
29+
)
30+
31+
class TestRejection():
32+
def test_get_rejection(self, parameters):
33+
34+
model = parameters["model"](**parameters["model_param"])
35+
36+
solution = [model.get_rejection(weight) for weight in parameters["weights"]]
37+
np.testing.assert_array_almost_equal(solution, parameters["expected"])

Diff for: ‎tests/test_residual.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ def test_calculation_concentration_cstr(self, parameters):
9696

9797
param_vec_conc = parameters["values"].values()
9898

99-
np.testing.assert_array_almost_equal(calculate_residual_concentration_cstr(*param_vec_conc), parameters["expected"])
99+
np.testing.assert_array_almost_equal(
100+
calculate_residual_concentration_cstr(*param_vec_conc),
101+
parameters["expected"]
102+
)
100103

101104

102105

Diff for: ‎tests/test_unit_operation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def test_set_inlet_state(self, unit_operation: UnitOperationBase, expected: dict
316316
}
317317
if unit_operation.n_inlet_ports == 0:
318318
with pytest.raises(Exception):
319-
unit_operation.set_inlet_port_state(s_in, 0)
319+
unit_operation.set_inlet_state_flat(s_in, 0)
320320
else:
321321
for port in range(unit_operation.n_inlet_ports):
322322
unit_operation.set_inlet_state_flat(s_in, port)

0 commit comments

Comments
 (0)