Exemple #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))
Exemple #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()
Exemple #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])
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)