コード例 #1
0
 def test_voronoi_circles(self):
     sv = spherical_voronoi.SphericalVoronoi(self.points)
     for vertex in sv.vertices:
         distances = distance.cdist(sv.points, np.array([vertex]))
         closest = np.array(sorted(distances)[0:3])
         assert_almost_equal(closest[0], closest[1], 7, str(vertex))
         assert_almost_equal(closest[0], closest[2], 7, str(vertex))
コード例 #2
0
 def test_sort_vertices_of_regions_dimensionality(self):
     points = np.array([[1, 0, 0, 0],
                        [0, 1, 0, 0],
                        [0, 0, 1, 0],
                        [0, 0, 0, 1],
                        [0.5, 0.5, 0.5, 0.5]])
     with pytest.raises(TypeError, match="three-dimensional"):
         sv = spherical_voronoi.SphericalVoronoi(points)
         sv.sort_vertices_of_regions()
コード例 #3
0
 def test_incorrect_center_handling(self):
     # an exception should be raised if the center provided
     # cannot possibly match the input generators
     with assert_raises(ValueError):
         sv = spherical_voronoi.SphericalVoronoi(self.points,
                                                 center=[0.1, 0, 0])
コード例 #4
0
 def test_duplicate_point_handling(self):
     # an exception should be raised for degenerate generators
     # related to Issue# 7046
     self.degenerate = np.concatenate((self.points, self.points))
     with assert_raises(ValueError):
         sv = spherical_voronoi.SphericalVoronoi(self.degenerate)
コード例 #5
0
 def test_rank_deficient(self):
     # rank-1 input cannot be triangulated
     points = np.array([[-1, 0, 0], [1, 0, 0]])
     with pytest.raises(ValueError, match="Rank of input points"):
         spherical_voronoi.SphericalVoronoi(points)
コード例 #6
0
 def test_incorrect_radius_handling(self):
     # an exception should be raised if the radius provided
     # cannot possibly match the input generators
     with assert_raises(ValueError):
         spherical_voronoi.SphericalVoronoi(self.points, radius=0.98)
コード例 #7
0
 def test_rank_deficient(self, n, center):
     thetas = np.linspace(0, 2 * np.pi, n, endpoint=False)
     points = np.vstack([np.sin(thetas), np.cos(thetas), np.zeros(n)]).T
     with pytest.raises(ValueError, match="Rank of input points"):
         spherical_voronoi.SphericalVoronoi(points + center, center=center)