Skip to content

Commit

Permalink
Deprecation: Fix ptp --> np.ptp for numpy 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CSSFrancis committed Oct 9, 2024
1 parent decf198 commit 77aaa31
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion diffsims/generators/diffraction_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def calculate_ed_data(

# Add z-coordinate
z_range = max(
z_range, coordinates[:, -1].ptp()
z_range, np.ptp(coordinates[:, -1])
) # enforce minimal resolution in reciprocal space
x = [
self.detector[0],
Expand Down
1 change: 1 addition & 0 deletions diffsims/simulations/simulation2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def current_size(self):
return self.rotations.size

def deepcopy(self):

return copy.deepcopy(self)

def _get_transformed_coordinates(
Expand Down
4 changes: 2 additions & 2 deletions diffsims/tests/utils/test_fourier_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def test_freq(shape, dX, rX, dY, rY):
if dX[i] is not None:
assert abs(x[i].item(1) - x[i].item(0)) <= dX[i] + 1e-8
if rY[i] is not None:
assert y[i].ptp() >= rY[i] - 1e-8
assert np.ptp(y[i]) >= rY[i] - 1e-8
if rX[i] is not None:
assert x[i].ptp() >= rX[i] - 1e-8
assert np.ptp(x[i]) >= rX[i] - 1e-8
if dY[i] is not None:
assert abs(y[i].item(1) - y[i].item(0)) <= dY[i] + 1e-8

Expand Down
3 changes: 2 additions & 1 deletion diffsims/utils/discretise_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
exp,
prod,
)
import numpy as np
from psutil import virtual_memory
import numba

Expand Down Expand Up @@ -321,7 +322,7 @@ def rebin(x, loc, r, k, mem):
else:
r = r.copy()
xmin = array([X.item(0) if X.size > 1 else -1e5 for X in x], dtype=x[0].dtype)
nbins = [int(ceil(x[i].ptp() / r[i])) + 1 for i in range(3)]
nbins = [int(ceil(np.ptp(x[i]) / r[i])) + 1 for i in range(3)]
if prod(nbins) * 32 * 10 > mem:
raise MemoryError
Len = zeros(nbins, dtype="i4")
Expand Down

0 comments on commit 77aaa31

Please sign in to comment.