Browse code

Update test_triangulation.py

Add black formatted code.

philippeitis authored on 16/12/2019 08:32:48 • Joseph Weston committed on 05/05/2020 19:10:25
Showing 1 changed files
... ...
@@ -63,14 +63,13 @@ def test_triangulation_find_opposing_vertices_raises_if_simplex_is_invalid():
63 63
 
64 64
 
65 65
 def 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
68 67
     from numpy import allclose
69
-    from numpy.random import normal, uniform
70
-    center_diff_err = "Calculated center (%s) differs from true center (%s)\n"
71 68
 
72 69
     def generate_random_sphere_points(dim, radius=0):
73 70
         """ Refer to https://math.stackexchange.com/a/1585996 """
71
+        from numpy.random import normal, uniform
72
+        from adaptive.learner.triangulation import fast_norm
74 73
 
75 74
         vec = [None] * (dim + 1)
76 75
         center = uniform(-100, 100, dim)
... ...
@@ -83,13 +82,20 @@ def test_circumsphere():
83 82
 
84 83
         return radius, center, vec
85 84
 
85
+    center_diff_err = "Calculated center [%s] differs from true center [%s]\n"
86 86
     for dim in range(2, 10):
87 87
         radius, center, points = generate_random_sphere_points(dim)
88 88
         circ_center, circ_radius = circumsphere(points)
89 89
         err_msg = ""
90 90
         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
+            )
92 95
         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
+            )
94 100
         if err_msg:
95 101
             raise AssertionError(err_msg)