Skip to content

Commit ffbb822

Browse files
committed
Addresses a bug in padding with random mutations
1 parent 7216766 commit ffbb822

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/poli_baselines/core/utils/mutations/random_mutations.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ def add_random_mutations_to_reach_pop_size(
2525
f"Expected x to have less elements than the population size. x.shape: {x.shape}, pop_size: {population_size}"
2626
)
2727

28-
x_as_1d_array_of_strings = np.array(["".join(x[i, :]) for i in range(b)])
28+
if len(x.shape) == 1:
29+
# Then the input as an array [b,] of strings
30+
x_as_1d_array_of_strings = x
31+
elif len(x.shape) == 2:
32+
# Then the input as an array [b, L] of strings
33+
x_as_1d_array_of_strings = np.array(["".join(x[i, :]) for i in range(b)])
34+
else:
35+
raise ValueError(f"Expected x to have shape [b,] or [b, L], but got {x.shape}.")
2936

3037
more_mutants = []
3138
for _ in range(population_size - b):

src/poli_baselines/tests/solvers/bayesian_optimization/test_lambo2.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import importlib
21
from pathlib import Path
32

4-
import pytest
5-
from poli.repository import EhrlichProblemFactory
3+
from poli.repository import EhrlichHoloProblemFactory
64

7-
if importlib.util.find_spec("cortex") is None:
8-
pytest.skip("Cortex is not installed.", allow_module_level=True)
5+
# if importlib.util.find_spec("cortex") is None:
6+
# pytest.skip("Cortex is not installed.", allow_module_level=True)
97

108
TEST_ASSETS = Path(__file__).parent.parent.parent / "test_files"
119

1210

1311
def test_lambo2_runs_on_ehrlich():
1412
from poli_baselines.solvers.bayesian_optimization.lambo2 import LaMBO2
1513

16-
problem = EhrlichProblemFactory().create(
14+
problem = EhrlichHoloProblemFactory().create(
1715
sequence_length=10,
1816
n_motifs=2,
1917
motif_length=4,

0 commit comments

Comments
 (0)