Skip to content

Commit

Permalink
Maint: Tweaked the code so that it also works for 64-bit systems
Browse files Browse the repository at this point in the history
  • Loading branch information
bewithaman committed Jul 7, 2015
1 parent a83b747 commit 0d20cf7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scipy/ndimage/src/_ni_measure.pyx
Expand Up @@ -56,7 +56,7 @@ ctypedef fused data_t:
#####################################################################

ctypedef void (*func_p)(void *data, np.flatiter iti, PyArrayIterObject *iti,
np.ndarray input, np.intp_t max_label, np.intp_t* regions,
np.ndarray input, np.intp_t max_label, int *regions,
int rank) nogil

def get_funcs(np.ndarray[data_t] input):
Expand Down Expand Up @@ -86,7 +86,7 @@ cdef data_t get_misaligned_from_iter(data_t *data, np.flatiter iter, np.ndarray
######################################################################

cdef inline findObjectsPoint(data_t *data, np.flatiter _iti, PyArrayIterObject *iti,
np.ndarray input, np.intp_t max_label, np.intp_t* regions,
np.ndarray input, np.intp_t max_label, int *regions,
int rank):
cdef int kk =0
cdef np.intp_t cc
Expand All @@ -99,8 +99,7 @@ cdef inline findObjectsPoint(data_t *data, np.flatiter _iti, PyArrayIterObject *
deref_p = get_from_iter

# only integer or boolean values are allowed, since s_index is being used in indexing
# cdef np.uintp_t s_index = deref_p(data, _iti, input) - 1
cdef np.intp_t s_index = <np.intp_t>((<data_t *>np.PyArray_ITER_DATA(_iti))[0])
cdef np.intp_t s_index = <np.intp_t> deref_p(data, _iti, input) - 1

if s_index >=0 and s_index < max_label:
if rank > 0:
Expand Down Expand Up @@ -133,7 +132,7 @@ cpdef _findObjects(np.ndarray input, np.intp_t max_label):

int ii, rank, size_regions
int start, jj, idx, end
np.intp_t *regions = NULL
int *regions = NULL

np.flatiter _iti
PyArrayIterObject *iti
Expand Down Expand Up @@ -161,7 +160,7 @@ cpdef _findObjects(np.ndarray input, np.intp_t max_label):
else:
size_regions = max_label

regions = <np.intp_t *> PyDataMem_NEW(size_regions * sizeof(np.intp_t))
regions = <int *> PyDataMem_NEW(size_regions * sizeof(int))
if regions == NULL:
raise MemoryError()

Expand Down Expand Up @@ -203,5 +202,6 @@ cpdef _findObjects(np.ndarray input, np.intp_t max_label):
except:
# clean up and re-raise
PyDataMem_FREE(regions)
raise

return result

0 comments on commit 0d20cf7

Please sign in to comment.