summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-08-24 17:47:24 -0500
committerGitHub <noreply@github.com>2017-08-24 17:47:24 -0500
commit52a7efe1f2d0be6adb75d09babe6f203906ecfcb (patch)
tree8348f6be8d6b988253e3ed3e134f4ee5d7ce65f3
parent707f33f6a55076bc12e25e736d910545377420e8 (diff)
parent18756ad0dd29ebe896ba408efd1a43d7dd24960e (diff)
downloadnumpy-52a7efe1f2d0be6adb75d09babe6f203906ecfcb.tar.gz
Merge pull request #9588 from bashtage/remove-flatiter-mtrand
REF: Remove direct access to flatiter attributes
-rw-r--r--numpy/random/mtrand/mtrand.pyx4
-rw-r--r--numpy/random/mtrand/numpy.pxd1
2 files changed, 3 insertions, 2 deletions
diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/mtrand/mtrand.pyx
index c4b4f7748..f5b741df6 100644
--- a/numpy/random/mtrand/mtrand.pyx
+++ b/numpy/random/mtrand/mtrand.pyx
@@ -211,7 +211,7 @@ cdef object cont1_array(rk_state *state, rk_cont1 func, object size,
itera = <flatiter>PyArray_IterNew(<object>oa)
with lock, nogil:
for i from 0 <= i < length:
- array_data[i] = func(state, (<double *>(itera.dataptr))[0])
+ array_data[i] = func(state, (<double *>PyArray_ITER_DATA(itera))[0])
PyArray_ITER_NEXT(itera)
else:
array = <ndarray>np.empty(size, np.float64)
@@ -536,7 +536,7 @@ cdef object discd_array(rk_state *state, rk_discd func, object size, ndarray oa,
itera = <flatiter>PyArray_IterNew(<object>oa)
with lock, nogil:
for i from 0 <= i < length:
- array_data[i] = func(state, (<double *>(itera.dataptr))[0])
+ array_data[i] = func(state, (<double *>PyArray_ITER_DATA(itera))[0])
PyArray_ITER_NEXT(itera)
else:
array = <ndarray>np.empty(size, int)
diff --git a/numpy/random/mtrand/numpy.pxd b/numpy/random/mtrand/numpy.pxd
index d5b0d74ca..32b19c1ab 100644
--- a/numpy/random/mtrand/numpy.pxd
+++ b/numpy/random/mtrand/numpy.pxd
@@ -130,6 +130,7 @@ cdef extern from "numpy/arrayobject.h":
object PyArray_IterNew(object arr)
void PyArray_ITER_NEXT(flatiter it) nogil
+ void* PyArray_ITER_DATA(flatiter it) nogil
dtype PyArray_DescrFromType(int)