11# -*- coding: utf-8 -*-
22
33from ..learner import LearnerND
4- from ..runner import replay_log
4+ from ..runner import replay_log , BlockingRunner
5+ import numpy as np
56
67
7- def test_faiure_case_LearnerND ():
8+ def sphere (xyz ):
9+ x , y , z = xyz
10+ a = 0.4
11+ return x + z ** 2 + np .exp (- (x ** 2 + y ** 2 + z ** 2 - 0.75 ** 2 )** 2 / a ** 4 )
12+
13+
14+ def test_failure_case_LearnerND ():
815 log = [
916 ('ask' , 4 ),
1017 ('tell' , (- 1 , - 1 , - 1 ), 1.607873907219222e-101 ),
@@ -21,3 +28,18 @@ def test_faiure_case_LearnerND():
2128 ]
2229 learner = LearnerND (lambda * x : x , bounds = [(- 1 , 1 ), (- 1 , 1 ), (- 1 , 1 )])
2330 replay_log (learner , log )
31+
32+
33+ def test_anisotropic_3d ():
34+ # there was this bug that the total volume would exceed the bounding box
35+ # volume for the anisotropic 3d learnerND
36+ # learner = adaptive.LearnerND(ring, bounds=[(-1, 1), (-1, 1)], anisotropic=True)
37+ learner = LearnerND (sphere , bounds = [(- 1 , 1 ), (- 1 , 1 ), (- 1 , 1 )], anisotropic = True )
38+ def goal (l ):
39+ if l .tri :
40+ sum_of_simplex_volumes = np .sum (l .tri .volumes ())
41+ assert sum_of_simplex_volumes < 8.00000000001
42+ return l .npoints >= 1000
43+ BlockingRunner (learner , goal , ntasks = 1 )
44+
45+ assert learner .npoints >= 1000
0 commit comments