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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
d7b5368b
Commit
d7b5368b
authored
Oct 13, 2016
by
Jeroen Demeyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement numpy's import_array and import_ufunc in Cython
parent
0d27e211
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
Cython/Includes/numpy/__init__.pxd
Cython/Includes/numpy/__init__.pxd
+23
-2
No files found.
Cython/Includes/numpy/__init__.pxd
View file @
d7b5368b
...
@@ -369,7 +369,7 @@ cdef extern from "numpy/arrayobject.h":
...
@@ -369,7 +369,7 @@ cdef extern from "numpy/arrayobject.h":
npy_intp
*
ptr
npy_intp
*
ptr
int
len
int
len
void
import_array
()
int
_import_array
()
except
-
1
#
#
# Macros from ndarrayobject.h
# Macros from ndarrayobject.h
...
@@ -960,7 +960,7 @@ cdef extern from "numpy/ufuncobject.h":
...
@@ -960,7 +960,7 @@ cdef extern from "numpy/ufuncobject.h":
(
PyUFuncGenericFunction
*
,
void
**
,
char
*
,
int
,
int
,
int
,
(
PyUFuncGenericFunction
*
,
void
**
,
char
*
,
int
,
int
,
int
,
int
,
char
*
,
char
*
,
int
,
char
*
)
int
,
char
*
,
char
*
,
int
,
char
*
)
void
import_ufunc
()
int
_import_umath
()
except
-
1
cdef
inline
void
set_array_base
(
ndarray
arr
,
object
base
):
cdef
inline
void
set_array_base
(
ndarray
arr
,
object
base
):
...
@@ -978,3 +978,24 @@ cdef inline object get_array_base(ndarray arr):
...
@@ -978,3 +978,24 @@ cdef inline object get_array_base(ndarray arr):
return
None
return
None
else
:
else
:
return
<
object
>
arr
.
base
return
<
object
>
arr
.
base
# Versions of the import_* functions which are more suitable for
# Cython code.
cdef
inline
int
import_array
()
except
-
1
:
try
:
_import_array
()
except
Exception
:
raise
ImportError
(
"numpy.core.multiarray failed to import"
)
cdef
inline
int
import_umath
()
except
-
1
:
try
:
_import_umath
()
except
Exception
:
raise
ImportError
(
"numpy.core.umath failed to import"
)
cdef
inline
int
import_ufunc
()
except
-
1
:
try
:
_import_umath
()
except
Exception
:
raise
ImportError
(
"numpy.core.umath failed to import"
)
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