From 42ac0a10572bfddab2dbbd64c9c5f4b01db139db Mon Sep 17 00:00:00 2001
From: navaneet <navaneet@acni>
Date: Mon, 17 Aug 2026 23:49:00 +0530
Subject: [PATCH] fix: more implicit types issues with numpy 2.0

explicitly using .item(), or index with [0] before passing to int() or
Cython C-type casts (unsigned int, unsigned long long)
---
 pysph/base/device_helper.py            | 4 ++--
 pysph/base/stratified_sfc_gpu_nnps.pyx | 2 +-
 pysph/base/z_order_gpu_nnps.pyx        | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pysph/base/device_helper.py b/pysph/base/device_helper.py
index e30af81b7..b5882dd9f 100644
--- a/pysph/base/device_helper.py
+++ b/pysph/base/device_helper.py
@@ -319,7 +319,7 @@ def align_particles(self):
 
         self.align(indices)
 
-        self.num_real_particles = int(num_real_particles.get())
+        self.num_real_particles = int(num_real_particles.get()[0])
 
     def _build_indices_with_strides(self, tag_arr, stride):
         num_particles = len(tag_arr.dev)
@@ -387,7 +387,7 @@ def _remove_particles_bool(self, if_remove, align=True):
                    num_removed_particles=num_removed_particles,
                    num_particles=num_particles)
 
-        new_num_particles = num_particles - int(num_removed_particles.get())
+        new_num_particles = num_particles - int(num_removed_particles.get()[0])
 
         strides = set(self._particle_array.stride.values())
         s_indices = {1: new_indices}
diff --git a/pysph/base/stratified_sfc_gpu_nnps.pyx b/pysph/base/stratified_sfc_gpu_nnps.pyx
index 022b76667..ce360c494 100644
--- a/pysph/base/stratified_sfc_gpu_nnps.pyx
+++ b/pysph/base/stratified_sfc_gpu_nnps.pyx
@@ -130,7 +130,7 @@ cdef class StratifiedSFCGPUNNPS(GPUNNPS):
         self.pid_keys[pa_index].set_data(sorted_keys)
 
         #FIXME: This will only work on OpenCL and CUDA backends
-        cdef unsigned long long key = <unsigned long long> (sorted_keys[0].get())
+        cdef unsigned long long key = <unsigned long long> (sorted_keys[0].get().item())
 
         self.start_idx_levels[pa_index][key >> self.max_num_bits] = 0
 
diff --git a/pysph/base/z_order_gpu_nnps.pyx b/pysph/base/z_order_gpu_nnps.pyx
index 5076729bf..b0e3133f9 100644
--- a/pysph/base/z_order_gpu_nnps.pyx
+++ b/pysph/base/z_order_gpu_nnps.pyx
@@ -224,7 +224,7 @@ cdef class ZOrderGPUNNPS(GPUNNPS):
                     self.pid_keys[src_index], self.cids[src_index],
                     self.src.get_number_of_particles(), self.max_cid_src)
 
-            overflow_size = <unsigned int>(self.max_cid_src.get()) - \
+            overflow_size = <unsigned int>(self.max_cid_src.get()[0]) - \
                     self.max_cid[src_index]
 
             self.overflow_cid_to_idx.resize(max(1, 27 * overflow_size))
