Skip to content

Commit

Permalink
Replace deprecated numpy aliases (#458)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
eendebakpt and basnijholt authored May 29, 2024
1 parent 05dbdbb commit 190b57b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions adaptive/learner/learner2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def deviations(ip: LinearNDInterpolator) -> list[np.ndarray]:
deviations : list
The deviation per triangle.
"""
values = ip.values / (ip.values.ptp(axis=0).max() or 1)
values = ip.values / (np.ptp(ip.values, axis=0).max() or 1)
gradients = interpolate.interpnd.estimate_gradients_2d_global(
ip.tri, values, tol=1e-6
)
Expand Down Expand Up @@ -195,7 +195,7 @@ def minimize_triangle_surface_loss(ip: LinearNDInterpolator) -> np.ndarray:
tri = ip.tri
points = tri.points[tri.simplices]
values = ip.values[tri.simplices]
values = values / (ip.values.ptp(axis=0).max() or 1)
values = values / (np.ptp(ip.values, axis=0).max() or 1)

def _get_vectors(points):
delta = points - points[:, -1, :][:, None, :]
Expand Down
3 changes: 2 additions & 1 deletion adaptive/learner/learnerND.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import functools
import itertools
import math
import random
from collections import OrderedDict
from collections.abc import Iterable
Expand Down Expand Up @@ -50,7 +51,7 @@ def volume(simplex, ys=None):

# See https://www.jstor.org/stable/2315353
dim = len(simplex) - 1
vol = np.abs(fast_det(matrix)) / np.math.factorial(dim)
vol = np.abs(fast_det(matrix)) / math.factorial(dim)
return vol


Expand Down
2 changes: 1 addition & 1 deletion adaptive/tests/test_learner1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def test_NaN_loss():
def f(x):
a = 0.01
if random.random() < 0.2:
return np.NaN
return np.nan
return x + a**2 / (a**2 + x**2)

learner = Learner1D(f, bounds=(-1, 1))
Expand Down
2 changes: 1 addition & 1 deletion adaptive/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
else:
from typing_extensions import TypeAlias

Float: TypeAlias = Union[float, np.float_]
Float: TypeAlias = Union[float, np.float64]
Bool: TypeAlias = Union[bool, np.bool_]
Int: TypeAlias = Union[int, np.int_]
Real: TypeAlias = Union[Float, Int]
Expand Down
2 changes: 1 addition & 1 deletion docs/source/CHANGELOG.md

0 comments on commit 190b57b

Please sign in to comment.