Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
222334c0
Commit
222334c0
authored
Aug 21, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid using deprecated NumPy APIs where possible.
See #2559.
parent
387c5032
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
5 deletions
+37
-5
Cython/Includes/numpy/__init__.pxd
Cython/Includes/numpy/__init__.pxd
+37
-5
No files found.
Cython/Includes/numpy/__init__.pxd
View file @
222334c0
...
@@ -123,6 +123,7 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -123,6 +123,7 @@ cdef extern from "numpy/arrayobject.h":
NPY_SEARCHRIGHT
NPY_SEARCHRIGHT
enum
:
enum
:
# DEPRECATED since NumPy 1.7 ! Do not use in new code!
NPY_C_CONTIGUOUS
NPY_C_CONTIGUOUS
NPY_F_CONTIGUOUS
NPY_F_CONTIGUOUS
NPY_CONTIGUOUS
NPY_CONTIGUOUS
...
@@ -155,6 +156,37 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -155,6 +156,37 @@ cdef extern from "numpy/arrayobject.h":
NPY_UPDATE_ALL
NPY_UPDATE_ALL
enum
:
# Added in NumPy 1.7 to replace the deprecated enums above.
NPY_ARRAY_C_CONTIGUOUS
NPY_ARRAY_F_CONTIGUOUS
NPY_ARRAY_OWNDATA
NPY_ARRAY_FORCECAST
NPY_ARRAY_ENSURECOPY
NPY_ARRAY_ENSUREARRAY
NPY_ARRAY_ELEMENTSTRIDES
NPY_ARRAY_ALIGNED
NPY_ARRAY_NOTSWAPPED
NPY_ARRAY_WRITEABLE
NPY_ARRAY_UPDATEIFCOPY
NPY_ARRAY_BEHAVED
NPY_ARRAY_BEHAVED_NS
NPY_ARRAY_CARRAY
NPY_ARRAY_CARRAY_RO
NPY_ARRAY_FARRAY
NPY_ARRAY_FARRAY_RO
NPY_ARRAY_DEFAULT
NPY_ARRAY_IN_ARRAY
NPY_ARRAY_OUT_ARRAY
NPY_ARRAY_INOUT_ARRAY
NPY_ARRAY_IN_FARRAY
NPY_ARRAY_OUT_FARRAY
NPY_ARRAY_INOUT_FARRAY
NPY_ARRAY_UPDATE_ALL
cdef
enum
:
cdef
enum
:
NPY_MAXDIMS
NPY_MAXDIMS
...
@@ -214,7 +246,7 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -214,7 +246,7 @@ cdef extern from "numpy/arrayobject.h":
int
ndim
"nd"
int
ndim
"nd"
npy_intp
*
shape
"dimensions"
npy_intp
*
shape
"dimensions"
npy_intp
*
strides
npy_intp
*
strides
dtype
descr
dtype
descr
# deprecated since NumPy 1.7 !
PyObject
*
base
PyObject
*
base
# Note: This syntax (function definition in pxd files) is an
# Note: This syntax (function definition in pxd files) is an
...
@@ -233,11 +265,11 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -233,11 +265,11 @@ cdef extern from "numpy/arrayobject.h":
ndim
=
PyArray_NDIM
(
self
)
ndim
=
PyArray_NDIM
(
self
)
if
((
flags
&
pybuf
.
PyBUF_C_CONTIGUOUS
==
pybuf
.
PyBUF_C_CONTIGUOUS
)
if
((
flags
&
pybuf
.
PyBUF_C_CONTIGUOUS
==
pybuf
.
PyBUF_C_CONTIGUOUS
)
and
not
PyArray_CHKFLAGS
(
self
,
NPY_C_CONTIGUOUS
)):
and
not
PyArray_CHKFLAGS
(
self
,
NPY_
ARRAY_
C_CONTIGUOUS
)):
raise
ValueError
(
u"ndarray is not C contiguous"
)
raise
ValueError
(
u"ndarray is not C contiguous"
)
if
((
flags
&
pybuf
.
PyBUF_F_CONTIGUOUS
==
pybuf
.
PyBUF_F_CONTIGUOUS
)
if
((
flags
&
pybuf
.
PyBUF_F_CONTIGUOUS
==
pybuf
.
PyBUF_F_CONTIGUOUS
)
and
not
PyArray_CHKFLAGS
(
self
,
NPY_F_CONTIGUOUS
)):
and
not
PyArray_CHKFLAGS
(
self
,
NPY_
ARRAY_
F_CONTIGUOUS
)):
raise
ValueError
(
u"ndarray is not Fortran contiguous"
)
raise
ValueError
(
u"ndarray is not Fortran contiguous"
)
info
.
buf
=
PyArray_DATA
(
self
)
info
.
buf
=
PyArray_DATA
(
self
)
...
@@ -259,7 +291,7 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -259,7 +291,7 @@ cdef extern from "numpy/arrayobject.h":
cdef
int
t
cdef
int
t
cdef
char
*
f
=
NULL
cdef
char
*
f
=
NULL
cdef
dtype
descr
=
self
.
descr
cdef
dtype
descr
=
<
dtype
>
PyArray_DESCR
(
self
)
cdef
int
offset
cdef
int
offset
info
.
obj
=
self
info
.
obj
=
self
...
@@ -404,7 +436,7 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -404,7 +436,7 @@ cdef extern from "numpy/arrayobject.h":
npy_intp
PyArray_STRIDE
(
ndarray
,
size_t
)
npy_intp
PyArray_STRIDE
(
ndarray
,
size_t
)
PyObject
*
PyArray_BASE
(
ndarray
)
# returns borrowed reference!
PyObject
*
PyArray_BASE
(
ndarray
)
# returns borrowed reference!
# dtype PyArray_DESCR(ndarray) wrong refcount semantics
PyObject
*
PyArray_DESCR
(
ndarray
)
# returns borrowed reference to dtype!
int
PyArray_FLAGS
(
ndarray
)
int
PyArray_FLAGS
(
ndarray
)
npy_intp
PyArray_ITEMSIZE
(
ndarray
)
npy_intp
PyArray_ITEMSIZE
(
ndarray
)
int
PyArray_TYPE
(
ndarray
arr
)
int
PyArray_TYPE
(
ndarray
arr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment