예제 #1
0
 def test_distance(self):
     point_1 = np.array([1.5, np.pi, np.exp(2.0)])
     point_2 = np.array([np.pi, np.exp(1), -1.9])
     d1 = G.distance(point_1, point_2)
     d2 = np.linalg.norm(point_1 - point_2)
     assert d1 == pytest.approx(d2)
     assert G.distance(point_1) == pytest.approx(np.linalg.norm(point_1))
예제 #2
0
 def test_get_3d_sphere(self):
     dx = 0.23
     center = np.random.random_sample(3)
     radius = 2.0
     x, y, z = get_3d_sphere(dx, radius, center)
     count = 0
     for i in range(len(x)):
         point = np.array([x[i], y[i], z[i]])
         dist = distance(point, center)
         if dist >= radius * (1.0 + dx * 1.0e-04):
             count += 1
     assert count == 0
예제 #3
0
 def test_distance(self):
     point_1 = np.random.random_sample(3)
     point_2 = np.random.random_sample(3)
     self.assertAlmostEqual(distance(point_1, point_2),
                            np.linalg.norm(point_1 - point_2))