Skip to content

Commit e57c1f9

Browse files
Jammy2211Jammy2211
authored andcommitted
revert to bary
1 parent ea5e0b2 commit e57c1f9

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

autoarray/structures/mesh/delaunay_2d.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,27 @@ def scipy_delaunay(points_np, query_points_np, use_voronoi_areas, areas_factor):
4040

4141
# ---------- Voronoi or Barycentric Areas used to weight split points ----------
4242

43-
# if use_voronoi_areas:
44-
#
45-
# areas = voronoi_areas_numpy(
46-
# points,
47-
# )
48-
#
49-
# max_area = np.percentile(areas, 90.0)
50-
#
51-
# areas[areas == -1] = max_area
52-
# areas[areas > max_area] = max_area
53-
#
54-
# else:
43+
if use_voronoi_areas:
5544

56-
areas = barycentric_dual_area_from(
57-
points,
58-
simplices,
59-
xp=np,
60-
)
45+
try:
46+
areas = voronoi_areas_numpy(points)
47+
except Exception as e:
48+
# Qhull precision problems -> fallback
49+
print(f"[pure_callback] Voronoi failed ({type(e).__name__}); falling back to barycentric areas.")
50+
areas = barycentric_dual_area_from(points, simplices, xp=np)
51+
52+
max_area = np.percentile(areas, 90.0)
53+
54+
areas[areas == -1] = max_area
55+
areas[areas > max_area] = max_area
56+
57+
else:
58+
59+
areas = barycentric_dual_area_from(
60+
points,
61+
simplices,
62+
xp=np,
63+
)
6164

6265
split_point_areas = areas_factor * np.sqrt(areas)
6366

0 commit comments

Comments
 (0)