@@ -63,14 +63,13 @@ def test_triangulation_find_opposing_vertices_raises_if_simplex_is_invalid():
6363
6464
6565def test_circumsphere ():
66- """ Test that circumsphere works correctly for a random center and random points on a sphere """
67- from adaptive .learner .triangulation import circumsphere , fast_norm
66+ from adaptive .learner .triangulation import circumsphere
6867 from numpy import allclose
69- from numpy .random import normal , uniform
70- center_diff_err = "Calculated center (%s) differs from true center (%s)\n "
7168
7269 def generate_random_sphere_points (dim , radius = 0 ):
7370 """ Refer to https://math.stackexchange.com/a/1585996 """
71+ from numpy .random import normal , uniform
72+ from adaptive .learner .triangulation import fast_norm
7473
7574 vec = [None ] * (dim + 1 )
7675 center = uniform (- 100 , 100 , dim )
@@ -83,13 +82,20 @@ def generate_random_sphere_points(dim, radius=0):
8382
8483 return radius , center , vec
8584
85+ center_diff_err = "Calculated center [%s] differs from true center [%s]\n "
8686 for dim in range (2 , 10 ):
8787 radius , center , points = generate_random_sphere_points (dim )
8888 circ_center , circ_radius = circumsphere (points )
8989 err_msg = ""
9090 if not allclose (circ_center , center ):
91- err_msg += center_diff_err % (", " .join ([str (x ) for x in circ_center ]), ", " .join ([str (x ) for x in center ]))
91+ err_msg += center_diff_err % (
92+ "," .join ([str (x ) for x in circ_center ]),
93+ "," .join ([str (x ) for x in center ]),
94+ )
9295 if not allclose (radius , circ_radius ):
93- err_msg += "Calculated radius %s differs from true radius %s" % (circ_radius , radius )
96+ err_msg += "Calculated radius %s differs from true radius %s" % (
97+ circ_radius ,
98+ radius ,
99+ )
94100 if err_msg :
95101 raise AssertionError (err_msg )
0 commit comments