Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_ineq_constraints_all_branches(self):

Missing coverage: lines 167-172 in functions.py
"""
# Test case 1: Normal case
# Test case 1: Normal case -- both constraints satisfied

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this get modified in a concurrent PR?

Pch = 0.080
dmdt = 0.05
Tpr_crit = -30.0
Expand All @@ -333,30 +333,38 @@ def test_ineq_constraints_all_branches(self):
Pch, dmdt, Tpr_crit, Tbot, eq_cap_a, eq_cap_b, nVial
)

# Should return two inequality constraints
# C1 = eq_cap_a + eq_cap_b*Pch - nVial*dmdt
expected_C1 = eq_cap_a + eq_cap_b * Pch - nVial * dmdt
# C2 = Tpr_crit - Tbot
expected_C2 = Tpr_crit - Tbot

assert len(result) == 2
assert isinstance(result[0], (int, float))
assert isinstance(result[1], (int, float))
assert result[0] == pytest.approx(expected_C1)
assert result[1] == pytest.approx(expected_C2)
assert result[0] < 0 # Equipment capability violated (dmdt too high for these params)
assert result[1] == pytest.approx(2.0) # 2 degrees of margin

# Test case 2: Equipment capability constraint active
dmdt_high = 0.5 # High sublimation rate
result2 = functions.Ineq_Constraints(
Pch, dmdt_high, Tpr_crit, Tbot, eq_cap_a, eq_cap_b, nVial
)
assert len(result2) == 2
assert result2[0] < 0 # Equipment capability violated
assert result2[1] == pytest.approx(2.0) # Temperature still OK

# Test case 3: Temperature constraint active
Tbot_high = -25.0 # Higher than critical
result3 = functions.Ineq_Constraints(
Pch, dmdt, Tpr_crit, Tbot_high, eq_cap_a, eq_cap_b, nVial
)
assert len(result3) == 2
assert result3[1] < 0 # Temperature constraint violated

# Test case 4: Both constraints active
result4 = functions.Ineq_Constraints(
Pch, dmdt_high, Tpr_crit, Tbot_high, eq_cap_a, eq_cap_b, nVial
)
assert len(result4) == 2
assert result4[0] < 0 # Equipment violated
assert result4[1] < 0 # Temperature violated

def test_ineq_constraints_boundary_cases(self):
"""Test Ineq_Constraints at boundary conditions."""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_opt_Tsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_multi_chamber_pressure_setpoints(self, optimizer_params):
assert_complete_drying(output)

def test_short_time(self, optimizer_params):
"""Test with multiple chamber pressure setpoints."""
"""Test with short total time (should not complete drying)."""
vial, product, ht, Pchamber, Tshelf, dt, eq_cap, nVial = optimizer_params

# Very short total time
Expand Down
Loading