22all objective functions should inherit.
33"""
44
5+ from __future__ import annotations
6+
57from multiprocessing import Pool , cpu_count
68from 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
0 commit comments