Browse code

test the fix of !95

Bas Nijholt authored on 10/09/2018 13:01:45
Showing 1 changed files
... ...
@@ -363,7 +363,7 @@ def test_learner1d_first_iteration():
363 363
     """Edge cases where we ask for a few points at the start."""
364 364
     learner = Learner1D(lambda x: None, (-1, 1))
365 365
     points, loss_improvements = learner.ask(2)
366
-    assert set(points) == set([-1, 1])
366
+    assert set(points) == set(learner.bounds)
367 367
 
368 368
     learner = Learner1D(lambda x: None, (-1, 1))
369 369
     points, loss_improvements = learner.ask(3)
... ...
@@ -371,17 +371,27 @@ def test_learner1d_first_iteration():
371 371
 
372 372
     learner = Learner1D(lambda x: None, (-1, 1))
373 373
     points, loss_improvements = learner.ask(1)
374
-    assert len(points) == 1 and points[0] in [-1, 1]
374
+    assert len(points) == 1 and points[0] in learner.bounds
375 375
     rest = set([-1, 0, 1]) - set(points)
376 376
     points, loss_improvements = learner.ask(2)
377 377
     assert set(points) == set(rest)
378 378
 
379 379
     learner = Learner1D(lambda x: None, (-1, 1))
380 380
     points, loss_improvements = learner.ask(1)
381
-    to_see = set([-1, 1]) - set(points)
381
+    to_see = set(learner.bounds) - set(points)
382 382
     points, loss_improvements = learner.ask(1)
383 383
     assert set(points) == set(to_see)
384 384
 
385
+    learner = Learner1D(lambda x: None, (-1, 1))
386
+    learner.tell(1, 0)
387
+    points, loss_improvements = learner.ask(1)
388
+    assert points == [-1]
389
+
390
+    learner = Learner1D(lambda x: None, (-1, 1))
391
+    learner.tell(-1, 0)
392
+    points, loss_improvements = learner.ask(1)
393
+    assert points == [1]
394
+
385 395
 
386 396
 def _run_on_discontinuity(x_0, bounds):
387 397