Skip to content

Commit 6897f89

Browse files
authored
Merge pull request #308 from MachineLearningLifeScience/fix/integer-inf
Defaults to None in `evaluation_budget`
2 parents b0f3a25 + 2ea0982 commit 6897f89

60 files changed

Lines changed: 152 additions & 148 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/poli/benchmarks/guacamol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(
8585
batch_size: Union[int, None] = None,
8686
parallelize: bool = False,
8787
num_workers: Union[int, None] = None,
88-
evaluation_budget: int = float("inf"),
88+
evaluation_budget: Union[int, None] = None,
8989
) -> None:
9090
super().__init__(
9191
seed=seed,

src/poli/benchmarks/pmo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(
7575
batch_size: Union[int, None] = None,
7676
parallelize: bool = False,
7777
num_workers: Union[int, None] = None,
78-
evaluation_budget: int = float("inf"),
78+
evaluation_budget: int = None,
7979
) -> None:
8080
super().__init__(
8181
string_representation=string_representation,

src/poli/benchmarks/toy_continuous_functions_benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(
5454
batch_size: Union[int, None] = None,
5555
parallelize: bool = False,
5656
num_workers: Union[int, None] = None,
57-
evaluation_budget: Union[int, List[int]] = float("inf"),
57+
evaluation_budget: Union[int, List[int]] = None,
5858
) -> None:
5959
super().__init__(
6060
seed=seed,
@@ -121,7 +121,7 @@ def __init__(
121121
batch_size: Union[int, None] = None,
122122
parallelize: bool = False,
123123
num_workers: Union[int, None] = None,
124-
evaluation_budget: Union[int, List[int]] = float("inf"),
124+
evaluation_budget: Union[int, List[int]] = None,
125125
) -> None:
126126
super().__init__(
127127
seed,
@@ -174,7 +174,7 @@ def __init__(
174174
batch_size: Union[int, None] = None,
175175
parallelize: bool = False,
176176
num_workers: Union[int, None] = None,
177-
evaluation_budget: Union[int, List[int]] = float("inf"),
177+
evaluation_budget: Union[int, List[int]] = None,
178178
) -> None:
179179
super().__init__(
180180
seed,

src/poli/core/abstract_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(
1616
batch_size: Union[int, None] = None,
1717
parallelize: bool = False,
1818
num_workers: Union[int, None] = None,
19-
evaluation_budget: int = float("inf"),
19+
evaluation_budget: int = None,
2020
) -> None:
2121
self.seed = seed
2222
self.batch_size = batch_size

src/poli/core/abstract_black_box.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
all objective functions should inherit.
33
"""
44

5+
from __future__ import annotations
6+
57
from multiprocessing import Pool, cpu_count
68
from warnings import warn
79

@@ -30,7 +32,7 @@ class AbstractBlackBox:
3032
which uses half of the available CPU cores.
3133
evaluation_budget : int, optional
3234
The maximum number of evaluations allowed for the black box function.
33-
Default is float("inf").
35+
Default is None).
3436
3537
Attributes
3638
----------
@@ -71,10 +73,10 @@ class AbstractBlackBox:
7173

7274
def __init__(
7375
self,
74-
batch_size: int = None,
76+
batch_size: int | None = None,
7577
parallelize: bool = False,
76-
num_workers: int = None,
77-
evaluation_budget: int = float("inf"),
78+
num_workers: int | None = None,
79+
evaluation_budget: int | None = None,
7880
force_isolation: bool = False,
7981
):
8082
"""
@@ -89,12 +91,14 @@ def __init__(
8991
num_workers : int, optional
9092
The number of workers for parallel execution, by default we use half the available CPUs.
9193
evaluation_budget : int, optional
92-
The maximum number of evaluations allowed for the black box function, by default float("inf").
94+
The maximum number of evaluations allowed for the black box function, by default it is None, which means no limit.
9395
"""
9496
self.observer = None
9597
self.observer_info = None
9698
self.parallelize = parallelize
97-
self.evaluation_budget = evaluation_budget
99+
self.evaluation_budget = (
100+
evaluation_budget if evaluation_budget is not None else float("inf")
101+
)
98102
self.num_evaluations = 0
99103
self.force_isolation = force_isolation
100104

src/poli/core/abstract_problem_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def create(
3434
batch_size: int = None,
3535
parallelize: bool = False,
3636
num_workers: int = None,
37-
evaluation_budget: int = float("inf"),
37+
evaluation_budget: int = None,
3838
force_isolation: bool = False,
3939
) -> Problem:
4040
"""

src/poli/core/chemistry/tdc_black_box.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class TDCBlackBox(AbstractBlackBox):
6464
6565
Methods
6666
-------
67-
__init__(self, oracle_name, string_representation="SMILES", force_isolation=False, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=float("inf"), **kwargs_for_oracle
67+
__init__(self, oracle_name, string_representation="SMILES", force_isolation=False, batch_size=None, parallelize=False, num_workers=None, evaluation_budget=None, **kwargs_for_oracle
6868
Initializes a new instance of the abstract TDC class.
6969
7070
References
@@ -83,7 +83,7 @@ def __init__(
8383
batch_size: int = None,
8484
parallelize: bool = False,
8585
num_workers: int = None,
86-
evaluation_budget: int = float("inf"),
86+
evaluation_budget: int = None,
8787
**kwargs_for_oracle,
8888
):
8989
if parallelize:

src/poli/core/lambda_black_box.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LambdaBlackBox(AbstractBlackBox):
4343
which uses half of the available CPU cores.
4444
evaluation_budget : int, optional
4545
The maximum number of evaluations allowed for the black box function.
46-
Default is float("inf").
46+
Default is None).
4747
force_isolation : bool, optional
4848
Flag indicating whether to force isolation of the black
4949
box function. In this black box, this flag is ignored.
@@ -56,7 +56,7 @@ def __init__(
5656
batch_size=None,
5757
parallelize=False,
5858
num_workers=None,
59-
evaluation_budget=float("inf"),
59+
evaluation_budget=None,
6060
force_isolation=False,
6161
):
6262
super().__init__(

src/poli/core/proteins/foldx_black_box.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(
8989
batch_size: int = None,
9090
parallelize: bool = False,
9191
num_workers: int = None,
92-
evaluation_budget: int = float("inf"),
92+
evaluation_budget: int = None,
9393
wildtype_pdb_path: Union[Path, List[Path]] = None,
9494
alphabet: List[str] = None,
9595
experiment_id: str = None,

src/poli/core/util/isolation/isolated_black_box.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(
88
batch_size: int = None,
99
parallelize: bool = False,
1010
num_workers: int = None,
11-
evaluation_budget: int = float("inf"),
11+
evaluation_budget: int = None,
1212
**kwargs_for_black_box,
1313
):
1414

0 commit comments

Comments
 (0)