Skip to content

Commit e39d991

Browse files
Jammy2211Jammy2211
authored andcommitted
restore old split_cross
1 parent 8d6089e commit e39d991

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

autoarray/structures/mesh/triangulation_2d.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,13 @@ def split_cross(self) -> np.ndarray:
487487
gradient regularization to an `Inversion` using a Delaunay triangulation or Voronoi mesh.
488488
"""
489489

490+
half_region_area_sqrt_lengths = 0.5 * np.sqrt(
491+
self.voronoi_pixel_areas_for_split
492+
)
493+
490494
return split_points_from(
491495
points=self.array,
492-
area_weights=0.5 * self.delaunay.areas,
496+
area_weights=half_region_area_sqrt_lengths,
493497
xp=self._xp,
494498
)
495499

@@ -502,21 +506,10 @@ def voronoi_pixel_areas(self) -> np.ndarray:
502506
an input value of N% the maximum area of the Voronoi mesh, which this value is suitable for different
503507
calculations.
504508
"""
505-
voronoi_vertices = self.voronoi.vertices
506-
voronoi_regions = self.voronoi.regions
507-
voronoi_point_region = self.voronoi.point_region
508-
region_areas = np.zeros(self.pixels)
509-
510-
for i in range(self.pixels):
511-
region_vertices_indexes = voronoi_regions[voronoi_point_region[i]]
512-
if -1 in region_vertices_indexes:
513-
region_areas[i] = -1
514-
else:
515-
region_areas[i] = grid_2d_util.compute_polygon_area(
516-
voronoi_vertices[region_vertices_indexes]
517-
)
518-
519-
return region_areas
509+
return voronoi_areas_via_delaunay_from(
510+
self.delaunay.points,
511+
self.delaunay.simplices,
512+
)
520513

521514
@property
522515
def voronoi_pixel_areas_for_split(self) -> np.ndarray:

0 commit comments

Comments
 (0)