From 0f95712493dd2cc92db26b4c82abec6a75b259ef Mon Sep 17 00:00:00 2001 From: Sepand KASHANI Date: Tue, 12 Mar 2024 13:03:01 +0100 Subject: [PATCH] [SWE] Fix NumPy 2.0 compliance. Pyxu does not yet support v2.0, but we fix these issues now in anticipation of the release. info: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#numpy-2-0-migration-guide --- dev/todo.txt | 5 +++++ src/pyxu/math/cluster.py | 2 +- src/pyxu/operator/linop/fft/nufft.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dev/todo.txt b/dev/todo.txt index cbae44100..f4a2dba09 100644 --- a/dev/todo.txt +++ b/dev/todo.txt @@ -1,3 +1,8 @@ +NumPy 2.0 Migration + To be done when min supported version becomes 2.0: + pyxu.operator.interop.jax.py + xp.byte_bounds() -> xp.lib.array_utils.byte_bounds() + doc/ api/ has/is-being updated to ND API interactively. diff --git a/src/pyxu/math/cluster.py b/src/pyxu/math/cluster.py index c3d606af7..2b2f9ff06 100644 --- a/src/pyxu/math/cluster.py +++ b/src/pyxu/math/cluster.py @@ -97,7 +97,7 @@ def bisect_cluster( def _bisect(x_idx: np.ndarray) -> ClusterMapping: # Split point cloud _x = x[x_idx] - bbox_dim = _x.ptp(axis=0) / 2 + bbox_dim = np.ptp(_x, axis=0) / 2 _clusters = grid_cluster(_x, bbox_dim) # re-label output indices diff --git a/src/pyxu/operator/linop/fft/nufft.py b/src/pyxu/operator/linop/fft/nufft.py index 10ab3ff29..d00151567 100644 --- a/src/pyxu/operator/linop/fft/nufft.py +++ b/src/pyxu/operator/linop/fft/nufft.py @@ -1164,8 +1164,8 @@ def _partition_domain( N, v_cl = len(v), {0: slice(None)} if chunked and (M > 1) and (N > 1): x_bbox_dim, v_bbox_dim = NUFFT3._infer_bbox_dims( - x_ptp=x.ptp(axis=0), - v_ptp=v.ptp(axis=0), + x_ptp=np.ptp(x, axis=0), + v_ptp=np.ptp(v, axis=0), upsampfac=upsampfac, domain=domain, max_fft_mem=max_fft_mem,