Skip to content

Commit 190b57b

Browse files
Replace deprecated numpy aliases (#458)
* Replace deprecated numpy aliases * more fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Bas Nijholt <[email protected]>
1 parent 05dbdbb commit 190b57b

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

adaptive/learner/learner2D.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def deviations(ip: LinearNDInterpolator) -> list[np.ndarray]:
4848
deviations : list
4949
The deviation per triangle.
5050
"""
51-
values = ip.values / (ip.values.ptp(axis=0).max() or 1)
51+
values = ip.values / (np.ptp(ip.values, axis=0).max() or 1)
5252
gradients = interpolate.interpnd.estimate_gradients_2d_global(
5353
ip.tri, values, tol=1e-6
5454
)
@@ -195,7 +195,7 @@ def minimize_triangle_surface_loss(ip: LinearNDInterpolator) -> np.ndarray:
195195
tri = ip.tri
196196
points = tri.points[tri.simplices]
197197
values = ip.values[tri.simplices]
198-
values = values / (ip.values.ptp(axis=0).max() or 1)
198+
values = values / (np.ptp(ip.values, axis=0).max() or 1)
199199

200200
def _get_vectors(points):
201201
delta = points - points[:, -1, :][:, None, :]

adaptive/learner/learnerND.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import functools
44
import itertools
5+
import math
56
import random
67
from collections import OrderedDict
78
from collections.abc import Iterable
@@ -50,7 +51,7 @@ def volume(simplex, ys=None):
5051

5152
# See https://www.jstor.org/stable/2315353
5253
dim = len(simplex) - 1
53-
vol = np.abs(fast_det(matrix)) / np.math.factorial(dim)
54+
vol = np.abs(fast_det(matrix)) / math.factorial(dim)
5455
return vol
5556

5657

adaptive/tests/test_learner1d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def test_NaN_loss():
399399
def f(x):
400400
a = 0.01
401401
if random.random() < 0.2:
402-
return np.NaN
402+
return np.nan
403403
return x + a**2 / (a**2 + x**2)
404404

405405
learner = Learner1D(f, bounds=(-1, 1))

adaptive/types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
else:
99
from typing_extensions import TypeAlias
1010

11-
Float: TypeAlias = Union[float, np.float_]
11+
Float: TypeAlias = Union[float, np.float64]
1212
Bool: TypeAlias = Union[bool, np.bool_]
1313
Int: TypeAlias = Union[int, np.int_]
1414
Real: TypeAlias = Union[Float, Int]

docs/source/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../CHANGELOG.md
1+
../../CHANGELOG.md

0 commit comments

Comments
 (0)