@@ -105,37 +105,11 @@ def test__voronoi_areas_via_delaunay_from():
105105 [[0.0 , 0.0 ], [1.1 , 0.6 ], [2.1 , 0.1 ], [0.4 , 1.1 ], [1.1 , 7.1 ], [2.1 , 1.1 ]]
106106 )
107107
108- delaunay = scipy . spatial . Delaunay (mesh_grid )
108+ delaunay = aa . Mesh2DDelaunay (mesh_grid )
109109
110- voronoi_areas = voronoi_areas_from (
111- mesh_grid ,
112- )
113-
114- voronoi = scipy .spatial .Voronoi (
115- mesh_grid ,
116- qhull_options = "Qbb Qc Qx Qm" ,
117- )
118-
119- voronoi_vertices = voronoi .vertices
120- voronoi_regions = voronoi .regions
121- voronoi_point_region = voronoi .point_region
122-
123- pixels = mesh_grid .shape [0 ]
124-
125- region_areas = np .zeros (pixels )
126-
127- for i in range (pixels ):
128- region_vertices_indexes = voronoi_regions [voronoi_point_region [i ]]
129- if - 1 in region_vertices_indexes :
130- region_areas [i ] = - 1
131- else :
132- region_areas [i ] = aa .util .grid_2d .compute_polygon_area (
133- voronoi_vertices [region_vertices_indexes ]
134- )
135-
136- assert voronoi_areas [1 ] == pytest .approx (region_areas [1 ], 1.0e-4 )
137- assert voronoi_areas [3 ] == pytest .approx (region_areas [3 ], 1.0e-4 )
110+ voronoi_areas = delaunay .delaunay .voronoi_areas
138111
139- # Old Voronoi cell code put -1 in edge pixels, new code puts large area
140112
141- assert voronoi_areas [4 ] == pytest .approx (32.83847776 , 1.0e-4 )
113+ assert voronoi_areas [1 ] == pytest .approx (1.39137102 , 1.0e-4 )
114+ assert voronoi_areas [3 ] == pytest .approx (29.836324 , 1.0e-4 )
115+ assert voronoi_areas [4 ] == pytest .approx (- 1.0 , 1.0e-4 )
0 commit comments