1
- """Test the OSQP solver.
1
+ """Test the hybrid solver.
2
2
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.
4
4
"""
5
5
6
6
from .fixtures import community
19
19
from pytest import approx
20
20
21
21
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"
24
24
)
25
25
26
26
medium = load_qiime_medium (md .test_medium )
30
30
@pytest .mark .parametrize ("strategy" , ["none" , "minimal imports" , "pFBA" ])
31
31
def test_grow (tmp_path , strategy ):
32
32
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 " )
34
34
grown = grow (built , str (tmp_path ), medium , 0.5 , strategy = strategy )
35
35
assert len (grown ) == 3
36
36
assert "growth_rate" in grown .growth_rates .columns
@@ -41,7 +41,7 @@ def test_grow(tmp_path, strategy):
41
41
42
42
def test_tradeoff (tmp_path ):
43
43
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 " )
45
45
rates = tradeoff (built , str (tmp_path ), medium )
46
46
assert "growth_rate" in rates .columns
47
47
assert "tradeoff" in rates .columns
@@ -50,7 +50,7 @@ def test_tradeoff(tmp_path):
50
50
51
51
def test_media (tmp_path ):
52
52
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 " )
54
54
media = minimal_media (built , str (tmp_path ), 0.5 )
55
55
assert media .shape [0 ] > 3
56
56
assert "flux" in media .columns
@@ -59,15 +59,15 @@ def test_media(tmp_path):
59
59
60
60
def test_fix_medium (tmp_path ):
61
61
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 " )
63
63
bad_medium = medium .iloc [0 :2 , :]
64
64
fixed = fix_medium (built , str (tmp_path ), bad_medium , 0.5 , 0.001 , 10 )
65
65
assert fixed .shape [0 ] > 3
66
66
assert "description" in fixed .columns
67
67
68
68
69
69
def test_community_objective (community ):
70
- community .solver = "osqp "
70
+ community .solver = "hybrid "
71
71
x = community .optimize ()
72
72
y = community .optimize (fluxes = True )
73
73
assert isinstance (x , CommunitySolution )
@@ -78,14 +78,14 @@ def test_community_objective(community):
78
78
79
79
80
80
def test_cooperative_tradeoff (community ):
81
- community .solver = "osqp "
81
+ community .solver = "hybrid "
82
82
sol = community .cooperative_tradeoff (fraction = 1.0 )
83
83
for g in sol .members .growth_rate .dropna ():
84
84
assert g == approx (0.874 , 1e-2 , 1e-2 )
85
85
86
86
87
87
def test_multiple_tradeoffs (community ):
88
- community .solver = "osqp "
88
+ community .solver = "hybrid "
89
89
fs = [1.0 , 0.5 , 0.3 , 0.1 ]
90
90
sol = community .cooperative_tradeoff (fraction = fs )
91
91
assert sol .shape == (4 , 2 )
0 commit comments