Skip to content

Commit d0aab31

Browse files
authored
Fix several deprecation warnings (#481)
1 parent 1eae4ae commit d0aab31

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

adaptive/learner/learner2D.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ def custom_loss(ip: LinearNDInterpolator) -> np.ndarray:
287287
return custom_loss
288288

289289

290+
def _cross_2d(x, y):
291+
return x[..., 0] * y[..., 1] - x[..., 1] * y[..., 0]
292+
293+
290294
def choose_point_in_triangle(triangle: np.ndarray, max_badness: int) -> np.ndarray:
291295
"""Choose a new point in inside a triangle.
292296
@@ -310,7 +314,7 @@ def choose_point_in_triangle(triangle: np.ndarray, max_badness: int) -> np.ndarr
310314
The x and y coordinate of the suggested new point.
311315
"""
312316
a, b, c = triangle
313-
area = 0.5 * np.cross(b - a, c - a)
317+
area = 0.5 * _cross_2d(b - a, c - a)
314318
triangle_roll = np.roll(triangle, 1, axis=0)
315319
edge_lengths = np.linalg.norm(triangle - triangle_roll, axis=1)
316320
i = edge_lengths.argmax()

adaptive/learner/learnerND.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,10 @@ def _compute_loss(self, simplex):
726726

727727
if self.nth_neighbors == 0:
728728
# compute the loss on the scaled simplex
729-
return float(
730-
self.loss_per_simplex(vertices, values, self._output_multiplier)
731-
)
729+
loss = self.loss_per_simplex(vertices, values, self._output_multiplier)
730+
if isinstance(loss, np.ndarray):
731+
return float(loss.item())
732+
return float(loss)
732733

733734
# We do need the neighbors
734735
neighbors = self.tri.get_opposing_vertices(simplex)

0 commit comments

Comments
 (0)