From 69c3175cc71606da0cfef511473d273c2d1b90ef Mon Sep 17 00:00:00 2001 From: lachlangrose Date: Mon, 9 Nov 2026 16:08:46 +1030 Subject: [PATCH] fix(loop_common): compute the 2D element size without np.cross numpy 2.5 raises ValueError for np.cross of 2D vectors. Use the z part of the 3D cross product. This fixes 7 tests in tests/unit/interpolator/test_2d_p1_p2_support.py. --- .../src/loop_common/supports/_2d_base_unstructured.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/loop_common/src/loop_common/supports/_2d_base_unstructured.py b/packages/loop_common/src/loop_common/supports/_2d_base_unstructured.py index 6ee091c56..3f1fb4d51 100644 --- a/packages/loop_common/src/loop_common/supports/_2d_base_unstructured.py +++ b/packages/loop_common/src/loop_common/supports/_2d_base_unstructured.py @@ -173,8 +173,9 @@ def shared_element_size(self): def element_size(self): v1 = self.nodes[self.elements[:, 1], :] - self.nodes[self.elements[:, 0], :] v2 = self.nodes[self.elements[:, 2], :] - self.nodes[self.elements[:, 0], :] - # cross product isn't defined in 2d, numpy returns the magnitude of the orthogonal vector. - return 0.5 * np.cross(v1, v2, axisa=1, axisb=1) + # The cross product is not defined in 2d. Use the z part of the 3d cross product + # (numpy 2 no longer accepts 2d vectors in np.cross). + return 0.5 * (v1[:, 0] * v2[:, 1] - v1[:, 1] * v2[:, 0]) @abstractmethod def evaluate_shape(self, locations) -> tuple[np.ndarray, np.ndarray, np.ndarray]: