diff --git a/diffsims/generators/diffraction_generator.py b/diffsims/generators/diffraction_generator.py index 3f3a1519..d0a7347a 100644 --- a/diffsims/generators/diffraction_generator.py +++ b/diffsims/generators/diffraction_generator.py @@ -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], diff --git a/diffsims/simulations/simulation2d.py b/diffsims/simulations/simulation2d.py index 9852c5c4..1ca57d1c 100644 --- a/diffsims/simulations/simulation2d.py +++ b/diffsims/simulations/simulation2d.py @@ -253,6 +253,7 @@ def current_size(self): return self.rotations.size def deepcopy(self): + return copy.deepcopy(self) def _get_transformed_coordinates( diff --git a/diffsims/tests/utils/test_fourier_transform.py b/diffsims/tests/utils/test_fourier_transform.py index aa0c00aa..52d52874 100644 --- a/diffsims/tests/utils/test_fourier_transform.py +++ b/diffsims/tests/utils/test_fourier_transform.py @@ -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 diff --git a/diffsims/utils/discretise_utils.py b/diffsims/utils/discretise_utils.py index 3864cf4d..725542cb 100644 --- a/diffsims/utils/discretise_utils.py +++ b/diffsims/utils/discretise_utils.py @@ -44,6 +44,7 @@ exp, prod, ) +import numpy as np from psutil import virtual_memory import numba @@ -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")