Skip to content

Commit d77fcd3

Browse files
committed
Simplifies test by mocking a function call
1 parent 51c7da9 commit d77fcd3

File tree

2 files changed

+13
-1967
lines changed

2 files changed

+13
-1967
lines changed
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import importlib
22
from pathlib import Path
3+
from unittest.mock import patch
34

45
import pytest
56

6-
from poli.repository import RaspProblemFactory
7+
import numpy as np
8+
9+
from poli.repository import AlohaProblemFactory
710

811
if importlib.util.find_spec("cortex") is None:
912
pytest.skip("Cortex is not installed.", allow_module_level=True)
1013

1114
TEST_ASSETS = Path(__file__).parent.parent.parent / "test_files"
1215

1316

14-
def test_lambo2_runs_on_rasp():
17+
def test_lambo2_runs_on_mocked_function():
1518
from poli_baselines.solvers.bayesian_optimization.lambo2 import LaMBO2
1619

17-
problem = RaspProblemFactory().create(
18-
wildtype_pdb_path=TEST_ASSETS / "2vad_A.pdb",
19-
chains_to_keep=["A"],
20-
additive=True,
21-
)
20+
problem = AlohaProblemFactory().create()
2221
f, x0 = problem.black_box, problem.x0
2322

24-
solver = LaMBO2(
25-
black_box=f,
26-
x0=x0,
27-
y0=f(x0),
28-
)
23+
with patch.object(f, "__call__", new=lambda x: np.zeros((x.shape[0], 1))) as _:
24+
solver = LaMBO2(
25+
black_box=f,
26+
x0=x0,
27+
y0=f(x0),
28+
)
2929

30-
solver.solve(max_iter=1)
30+
solver.solve(max_iter=1)

0 commit comments

Comments
 (0)