Skip to content

Commit 36c0bc9

Browse files
committed
port tests to hybrid solver
1 parent 76133eb commit 36c0bc9

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/test_osqp.py renamed to tests/test_hybrid.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"""Test the OSQP solver.
1+
"""Test the hybrid solver.
22
3-
We only test the core functions with relaxed accuracies as OSQP is not good with LPs.
3+
We only test the core functions with relaxed accuracies as hybrid is not good with LPs.
44
"""
55

66
from .fixtures import community
@@ -19,8 +19,8 @@
1919
from pytest import approx
2020

2121
pytestmark = pytest.mark.skipif(
22-
"osqp" not in su.solvers,
23-
reason="OSQP not functional here"
22+
"hybrid" not in su.solvers,
23+
reason="hybrid not functional here"
2424
)
2525

2626
medium = load_qiime_medium(md.test_medium)
@@ -30,7 +30,7 @@
3030
@pytest.mark.parametrize("strategy", ["none", "minimal imports", "pFBA"])
3131
def test_grow(tmp_path, strategy):
3232
data = md.test_data()
33-
built = build(data, db, str(tmp_path), cutoff=0, solver="osqp")
33+
built = build(data, db, str(tmp_path), cutoff=0, solver="hybrid")
3434
grown = grow(built, str(tmp_path), medium, 0.5, strategy=strategy)
3535
assert len(grown) == 3
3636
assert "growth_rate" in grown.growth_rates.columns
@@ -41,7 +41,7 @@ def test_grow(tmp_path, strategy):
4141

4242
def test_tradeoff(tmp_path):
4343
data = md.test_data()
44-
built = build(data, db, str(tmp_path), cutoff=0, solver="osqp")
44+
built = build(data, db, str(tmp_path), cutoff=0, solver="hybrid")
4545
rates = tradeoff(built, str(tmp_path), medium)
4646
assert "growth_rate" in rates.columns
4747
assert "tradeoff" in rates.columns
@@ -50,7 +50,7 @@ def test_tradeoff(tmp_path):
5050

5151
def test_media(tmp_path):
5252
data = md.test_data()
53-
built = build(data, db, str(tmp_path), cutoff=0, solver="osqp")
53+
built = build(data, db, str(tmp_path), cutoff=0, solver="hybrid")
5454
media = minimal_media(built, str(tmp_path), 0.5)
5555
assert media.shape[0] > 3
5656
assert "flux" in media.columns
@@ -59,15 +59,15 @@ def test_media(tmp_path):
5959

6060
def test_fix_medium(tmp_path):
6161
data = md.test_data()
62-
built = build(data, db, str(tmp_path), cutoff=0, solver="osqp")
62+
built = build(data, db, str(tmp_path), cutoff=0, solver="hybrid")
6363
bad_medium = medium.iloc[0:2, :]
6464
fixed = fix_medium(built, str(tmp_path), bad_medium, 0.5, 0.001, 10)
6565
assert fixed.shape[0] > 3
6666
assert "description" in fixed.columns
6767

6868

6969
def test_community_objective(community):
70-
community.solver = "osqp"
70+
community.solver = "hybrid"
7171
x = community.optimize()
7272
y = community.optimize(fluxes=True)
7373
assert isinstance(x, CommunitySolution)
@@ -78,14 +78,14 @@ def test_community_objective(community):
7878

7979

8080
def test_cooperative_tradeoff(community):
81-
community.solver = "osqp"
81+
community.solver = "hybrid"
8282
sol = community.cooperative_tradeoff(fraction=1.0)
8383
for g in sol.members.growth_rate.dropna():
8484
assert g == approx(0.874, 1e-2, 1e-2)
8585

8686

8787
def test_multiple_tradeoffs(community):
88-
community.solver = "osqp"
88+
community.solver = "hybrid"
8989
fs = [1.0, 0.5, 0.3, 0.1]
9090
sol = community.cooperative_tradeoff(fraction=fs)
9191
assert sol.shape == (4, 2)

0 commit comments

Comments
 (0)