Skip to content

Commit fba7e4d

Browse files
authored
Replace deprecated np.bmat with np.block in Voronoi Delaunay triangulation (#2915)
Replace np.bmat with np.block in Delaunay._circumcenter to fix PendingDeprecationWarning about numpy.matrix subclass. The nested lists are wrapped in np.array() calls to ensure consistent array depths required by np.block.
1 parent 87e500e commit fba7e4d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mesa/discrete_space/voronoi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def _circumcenter(self, triangle: list) -> tuple:
6262
"""Compute circumcenter and circumradius of a triangle in 2D."""
6363
points = np.asarray([self.coords[v] for v in triangle])
6464
points2 = np.dot(points, points.T)
65-
a = np.bmat([[2 * points2, [[1], [1], [1]]], [[[1, 1, 1, 0]]]])
65+
a = np.block(
66+
[[2 * points2, np.array([[1], [1], [1]])], [np.array([[1, 1, 1, 0]])]]
67+
)
6668

6769
b = np.hstack((np.sum(points * points, axis=1), [1]))
6870
x = np.linalg.solve(a, b)

0 commit comments

Comments
 (0)