Skip to content

Commit

Permalink
chore(z_order_nnps): settle deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nauaneed committed Sep 22, 2024
1 parent d30cda3 commit b2c0900
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions pysph/base/z_order_nnps.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ cdef extern from "math.h":
cdef extern from "z_order.h":
ctypedef unsigned long long uint64_t
ctypedef unsigned int uint32_t
inline uint64_t get_key(uint64_t i, uint64_t j, uint64_t k) nogil
uint64_t get_key(uint64_t i, uint64_t j, uint64_t k) nogil

cdef cppclass CompareSortWrapper:
CompareSortWrapper() nogil except +
CompareSortWrapper() except + nogil
CompareSortWrapper(uint32_t* current_pids, uint64_t* current_keys,
int length) nogil except +
int length) except + nogil
inline void compare_sort() nogil

ctypedef map[uint64_t, pair[uint32_t, uint32_t]] key_to_idx_t
Expand Down
88 changes: 44 additions & 44 deletions pysph/base/z_order_nnps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ cdef class ZOrderNNPS(NNPS):
self.key_to_idx = <int**> malloc(narrays*sizeof(int*))

cdef int i
for i from 0<=i<narrays:
for i in range(narrays):
self.pids[i] = NULL
self.keys[i] = NULL
self.cids[i] = NULL
Expand All @@ -84,7 +84,7 @@ cdef class ZOrderNNPS(NNPS):

def __dealloc__(self):
cdef int i
for i from 0<=i<self.narrays:
for i in range(self.narrays):
if self.pids[i] != NULL:
free(self.pids[i])
if self.keys[i] != NULL:
Expand Down Expand Up @@ -179,7 +179,7 @@ cdef class ZOrderNNPS(NNPS):
cdef uint64_t key
cdef int length

for i from 0<=i<self.mask_len:
for i in range(self.mask_len):
start_idx = self.current_nbr_boxes[self.mask_len * cid + i]

if start_idx < 0:
Expand All @@ -190,7 +190,7 @@ cdef class ZOrderNNPS(NNPS):
cid_nbr = self.current_cids_src[idx]
length = self.current_lengths[cid_nbr]

for j from 0<=j<length:
for j in range(length):
idx = self.current_pids[start_idx + j]

hj2 = self.radius_scale2*src_h_ptr[idx]*src_h_ptr[idx]
Expand Down Expand Up @@ -245,7 +245,7 @@ cdef class ZOrderNNPS(NNPS):
cdef uint32_t* current_pids = self.pids[pa_index]

cdef int j
for j from 0<=j<num_particles:
for j in range(num_particles):
indices.c_append(<long>current_pids[j])

cdef int fill_array(self, NNPSParticleArrayWrapper pa_wrapper, int pa_index,
Expand All @@ -263,7 +263,7 @@ cdef class ZOrderNNPS(NNPS):
cdef int c_x, c_y, c_z

cdef int i, n
for i from 0<=i<curr_num_particles:
for i in range(curr_num_particles):
find_cell_id_raw(
x_ptr[i] - xmin[0],
y_ptr[i] - xmin[1],
Expand All @@ -286,7 +286,7 @@ cdef class ZOrderNNPS(NNPS):
key = current_keys[0]
current_key_to_idx[key] = 0;

for i from 0<i<curr_num_particles:
for i in range(1, curr_num_particles):
key = current_keys[i]
if key != current_keys[i-1]:
current_key_to_idx[key] = i;
Expand All @@ -305,7 +305,7 @@ cdef class ZOrderNNPS(NNPS):
cdef int* iter_key_to_idx

cdef uint32_t curr_pid = current_pids[0]
for j from 0<=j<pa_index:
for j in range(pa_index):
iter_cids = self.cids[j]
iter_keys = self.keys[j]
iter_key_to_idx = self.key_to_idx[j]
Expand All @@ -325,13 +325,13 @@ cdef class ZOrderNNPS(NNPS):

current_cids[curr_pid] = found_cid

for i from 0<i<curr_num_particles:
for i in range(1, curr_num_particles):
curr_pid = current_pids[i]
if(current_keys[i] != current_keys[i-1]):
found_ptr = NULL
found_cid = UINT_MAX

for j from 0<=j<pa_index:
for j in range(pa_index):
iter_cids = self.cids[j]
iter_keys = self.keys[j]
iter_key_to_idx = self.key_to_idx[j]
Expand Down Expand Up @@ -365,7 +365,7 @@ cdef class ZOrderNNPS(NNPS):
cdef int num_particles = (<NNPSParticleArrayWrapper> \
self.pa_wrappers[pa_index]).get_number_of_particles()
keys = np.empty(num_particles)
for i from 0<=i<num_particles:
for i in range(num_particles):
keys[i] = current_keys[i]
return keys

Expand Down Expand Up @@ -410,7 +410,7 @@ cdef class ZOrderNNPS(NNPS):

cdef uint64_t key

for i from 0<=i<self.narrays:
for i in range(self.narrays):
n = 0
pa_wrapper = self.pa_wrappers[i]
num_particles = pa_wrapper.get_number_of_particles()
Expand All @@ -428,10 +428,10 @@ cdef class ZOrderNNPS(NNPS):
current_lengths = self.lengths[i]

# init self.nbr_boxes to -1
for j from 0<=j<self.mask_len * self.max_cid:
for j in range(self.mask_len * self.max_cid):
current_nbr_boxes[j] = -1

for j from 0<=j<self.max_cid:
for j in range(self.max_cid):
current_lengths[j] = 1

pid = current_pids[0]
Expand All @@ -448,13 +448,13 @@ cdef class ZOrderNNPS(NNPS):
num_boxes = self._neighbor_boxes(c_x, c_y, c_z, current_key_to_idx,
num_particles, found_indices)

for k from 0<=k<num_boxes:
for k in range(num_boxes):
found_idx = found_indices[k]
current_nbr_boxes[self.mask_len*cid + n] = found_idx
n += 1

# nbrs of all cids in particle array i
for j from 0<j<num_particles:
for j in range(1, num_particles):
key = current_keys[j]
pid = current_pids[j]
cid = current_cids[pid]
Expand All @@ -472,7 +472,7 @@ cdef class ZOrderNNPS(NNPS):
num_boxes = self._neighbor_boxes(c_x, c_y, c_z, current_key_to_idx,
num_particles, found_indices)

for k from 0<=k<num_boxes:
for k in range(num_boxes):
found_idx = found_indices[k]
current_nbr_boxes[self.mask_len*cid + n] = found_idx
n += 1
Expand All @@ -489,9 +489,9 @@ cdef class ZOrderNNPS(NNPS):
cdef int p, q, r
cdef uint64_t key
cdef int found_idx
for p from -1<=p<2:
for q from -1<=q<2:
for r from -1<=r<2:
for p in range(-1, 2):
for q in range(-1, 2):
for r in range(-1, 2):
if i+r>=0 and j+q>=0 and k+p>=0:
key = get_key(i+r, j+q, k+p)
found_idx = self.get_idx(key, current_key_to_idx)
Expand Down Expand Up @@ -530,7 +530,7 @@ cdef class ZOrderNNPS(NNPS):
cdef uint64_t max_key = 1 + get_key(c_x, c_y, c_z)
self.max_key = max_key

for i from 0<=i<self.narrays:
for i in range(self.narrays):
if self.pids[i] != NULL:
free(self.pids[i])
if self.keys[i] != NULL:
Expand All @@ -553,13 +553,13 @@ cdef class ZOrderNNPS(NNPS):
current_keys = self.keys[i]
current_key_to_idx = self.key_to_idx[i]

for j from 0<=j<max_key:
for j in range(max_key):
current_key_to_idx[j] = -1

max_cid = self.fill_array(pa_wrapper, i, current_pids,
current_keys, current_cids, max_cid)

for i from 0<=i<self.narrays:
for i in range(self.narrays):
if self.nbr_boxes[i] != NULL:
free(self.nbr_boxes[i])
if self.lengths[i] != NULL:
Expand Down Expand Up @@ -599,12 +599,12 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):
self.current_hmax = NULL

cdef int i
for i from 0<=i<narrays:
for i in range(narrays):
self.hmax[i] = NULL

def __dealloc__(self):
cdef int i
for i from 0<=i<self.narrays:
for i in range(self.narrays):
if self.hmax[i] != NULL:
free(self.hmax[i])
free(self.hmax)
Expand All @@ -613,9 +613,9 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):
cdef int length = 0
cdef int s, t, u

for s from -self.H<=s<=self.H:
for t from -self.H<=t<=self.H:
for u from -self.H<=u<=self.H:
for s in range(-self.H, self.H+1):
for t in range(-self.H, self.H+1):
for u in range(-self.H, self.H+1):

x[length] = s
y[length] = t
Expand Down Expand Up @@ -650,9 +650,9 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):

cdef int s, t, u

for s from -self.H<=s<=self.H:
for t from -self.H<=t<=self.H:
for u from -self.H<=u<=self.H:
for s in range(-self.H, self.H+1):
for t in range(-self.H, self.H+1):
for u in range(-self.H, self.H+1):

x_temp = i + u
y_temp = j + t
Expand Down Expand Up @@ -686,9 +686,9 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):

cdef int s, t, u

for s from -self.H<=s<=self.H:
for t from -self.H<=t<=self.H:
for u from -self.H<=u<=self.H:
for s in range(-self.H, self.H+1):
for t in range(-self.H, self.H+1):
for u in range(-self.H, self.H+1):

x_temp = i + u
y_temp = j + t
Expand Down Expand Up @@ -740,7 +740,7 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):
sizeof(int))
cdef uint64_t key

for i from 0<=i<self.narrays:
for i in range(self.narrays):
n = 0
pa_wrapper = self.pa_wrappers[i]
num_particles = pa_wrapper.get_number_of_particles()
Expand All @@ -759,10 +759,10 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):
current_hmax = self.hmax[i]

# init self.nbr_boxes to -1
for j from 0<=j<self.mask_len * self.max_cid:
for j in range(self.mask_len * self.max_cid):
current_nbr_boxes[j] = -1

for j from 0<=j<self.max_cid:
for j in range(self.max_cid):
current_lengths[j] = 1
current_hmax[j] = 0

Expand All @@ -771,7 +771,7 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):

current_hmax[cid] = h_ptr[pid]

for j from 0<j<num_particles:
for j in range(1, num_particles):
key = current_keys[j]
pid = current_pids[j]
cid = current_cids[pid]
Expand All @@ -796,13 +796,13 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):
current_key_to_idx, current_cids, current_hmax,
num_particles, found_indices, current_hmax[cid])

for k from 0<=k<num_boxes:
for k in range(num_boxes):
found_idx = found_indices[k]
current_nbr_boxes[self.mask_len*cid + n] = found_idx
n += 1

# nbrs of all cids in particle array i
for j from 0<j<num_particles:
for j in range(1, num_particles):
key = current_keys[j]
pid = current_pids[j]
cid = current_cids[pid]
Expand All @@ -821,7 +821,7 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):
current_key_to_idx, current_cids, current_hmax,
num_particles, found_indices, current_hmax[cid])

for k from 0<=k<num_boxes:
for k in range(num_boxes):
found_idx = found_indices[k]
current_nbr_boxes[self.mask_len*cid + n] = found_idx
n += 1
Expand Down Expand Up @@ -860,7 +860,7 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):
cdef uint64_t max_key = 1 + get_key(c_x, c_y, c_z)
self.max_key = max_key

for i from 0<=i<self.narrays:
for i in range(self.narrays):
if self.pids[i] != NULL:
free(self.pids[i])
if self.keys[i] != NULL:
Expand All @@ -883,13 +883,13 @@ cdef class ExtendedZOrderNNPS(ZOrderNNPS):
current_keys = self.keys[i]
current_key_to_idx = self.key_to_idx[i]

for j from 0<=j<max_key:
for j in range(max_key):
current_key_to_idx[j] = -1

max_cid = self.fill_array(pa_wrapper, i, current_pids,
current_keys, current_cids, max_cid)

for i from 0<=i<self.narrays:
for i in range(self.narrays):
if self.nbr_boxes[i] != NULL:
free(self.nbr_boxes[i])
if self.lengths[i] != NULL:
Expand Down

0 comments on commit b2c0900

Please sign in to comment.