Skip to content

Commit a0d8c86

Browse files
authored
Addresses a bug in padding with random mutations (#65)
* Addresses a bug in padding with random mutations * Updates the lambo2 test to skip on base env * Bumps patch version
1 parent 7216766 commit a0d8c86

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "poli-baselines"
7-
version = "1.0.1"
7+
version = "1.0.2"
88
description = "poli-baselines, a library of discrete objective optimizers"
99
readme = "README.md"
1010
authors = [{name="Miguel González-Duque", email="miguelgondu@gmail.com"}]
@@ -94,7 +94,7 @@ markers = [
9494
profile = "black"
9595

9696
[tool.bumpversion]
97-
current_version = "1.0.1"
97+
current_version = "1.0.2"
9898
parse = """(?x)
9999
(?P<major>0|[1-9]\\d*)\\.
100100
(?P<minor>0|[1-9]\\d*)\\.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = poli_baselines
3-
version = 1.0.1
3+
version = 1.0.2
44
author_email = miguelgondu@gmail.com
55
description = Baselines for Discrete Sequence Optimization, focusing on proteins
66
long_description = file: readme.md

src/poli_baselines/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.1"
1+
__version__ = "1.0.2"

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

Lines changed: 8 additions & 1 deletion
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import importlib
1+
import importlib.util
22
from pathlib import Path
33

44
import pytest
5-
from poli.repository import EhrlichProblemFactory
5+
from poli.repository import EhrlichHoloProblemFactory
66

77
if importlib.util.find_spec("cortex") is None:
88
pytest.skip("Cortex is not installed.", allow_module_level=True)
@@ -13,7 +13,7 @@
1313
def test_lambo2_runs_on_ehrlich():
1414
from poli_baselines.solvers.bayesian_optimization.lambo2 import LaMBO2
1515

16-
problem = EhrlichProblemFactory().create(
16+
problem = EhrlichHoloProblemFactory().create(
1717
sequence_length=10,
1818
n_motifs=2,
1919
motif_length=4,

0 commit comments

Comments
 (0)