@@ -201,6 +201,7 @@ def __init__(self, function, bounds, loss_per_interval=None):
201
201
self ._dx_eps = 2 * max (np .abs (bounds )) * np .finfo (float ).eps
202
202
203
203
self .bounds = list (bounds )
204
+ self .__missing_bounds = set (self .bounds )
204
205
205
206
self ._vdim = None
206
207
@@ -231,6 +232,8 @@ def npoints(self):
231
232
232
233
@cache_latest
233
234
def loss (self , real = True ):
235
+ if self ._missing_bounds ():
236
+ return np .inf
234
237
losses = self .losses if real else self .losses_combined
235
238
if not losses :
236
239
return np .inf
@@ -496,6 +499,15 @@ def ask(self, n, tell_pending=True):
496
499
497
500
return points , loss_improvements
498
501
502
+ def _missing_bounds (self ):
503
+ missing_bounds = []
504
+ for b in self .__missing_bounds :
505
+ if b in self .data :
506
+ self .__missing_bounds .remove (b )
507
+ elif b not in self .pending_points :
508
+ missing_bounds .append (b )
509
+ return missing_bounds
510
+
499
511
def _ask_points_without_adding (self , n ):
500
512
"""Return 'n' points that are expected to maximally reduce the loss.
501
513
Without altering the state of the learner"""
@@ -511,12 +523,7 @@ def _ask_points_without_adding(self, n):
511
523
return [], []
512
524
513
525
# If the bounds have not been chosen yet, we choose them first.
514
- missing_bounds = [
515
- b
516
- for b in self .bounds
517
- if b not in self .data and b not in self .pending_points
518
- ]
519
-
526
+ missing_bounds = self ._missing_bounds ()
520
527
if len (missing_bounds ) >= n :
521
528
return missing_bounds [:n ], [np .inf ] * n
522
529
0 commit comments