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
30a1dbe7
Commit
30a1dbe7
authored
May 15, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update numpy.pxd with complex types and approximate type sizes
parent
0ef612d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
34 deletions
+51
-34
Cython/Includes/numpy.pxd
Cython/Includes/numpy.pxd
+41
-31
tests/run/numpy_test.pyx
tests/run/numpy_test.pyx
+10
-3
No files found.
Cython/Includes/numpy.pxd
View file @
30a1dbe7
...
...
@@ -173,41 +173,47 @@ cdef extern from "numpy/arrayobject.h":
cdef
int
PyDataType_HASFIELDS
(
dtype
obj
)
ctypedef
signed
int
npy_byte
ctypedef
signed
int
npy_short
ctypedef
signed
int
npy_int
ctypedef
signed
int
npy_long
ctypedef
signed
int
npy_longlong
ctypedef
unsigned
int
npy_ubyte
ctypedef
unsigned
int
npy_ushort
ctypedef
unsigned
int
npy_uint
ctypedef
unsigned
int
npy_ulong
ctypedef
unsigned
int
npy_ulonglong
ctypedef
signed
char
npy_byte
ctypedef
signed
short
npy_short
ctypedef
signed
int
npy_int
ctypedef
signed
long
npy_long
ctypedef
signed
long
long
npy_longlong
ctypedef
unsigned
char
npy_ubyte
ctypedef
unsigned
short
npy_ushort
ctypedef
unsigned
int
npy_uint
ctypedef
unsigned
long
npy_ulong
ctypedef
unsigned
long
long
npy_ulonglong
ctypedef
float
npy_float
ctypedef
float
npy_double
ctypedef
float
npy_longdouble
ctypedef
signed
int
npy_int8
ctypedef
signed
int
npy_int16
ctypedef
signed
int
npy_int32
ctypedef
signed
int
npy_int64
ctypedef
signed
int
npy_int96
ctypedef
signed
int
npy_int128
ctypedef
unsigned
int
npy_uint8
ctypedef
unsigned
int
npy_uint16
ctypedef
unsigned
int
npy_uint32
ctypedef
unsigned
int
npy_uint64
ctypedef
unsigned
int
npy_uint96
ctypedef
unsigned
int
npy_uint128
ctypedef
double
npy_double
ctypedef
long
double
npy_longdouble
ctypedef
signed
char
npy_int8
ctypedef
signed
short
npy_int16
ctypedef
signed
int
npy_int32
ctypedef
signed
long
long
npy_int64
ctypedef
signed
long
long
npy_int96
ctypedef
signed
long
long
npy_int128
ctypedef
unsigned
char
npy_uint8
ctypedef
unsigned
short
npy_uint16
ctypedef
unsigned
int
npy_uint32
ctypedef
unsigned
long
long
npy_uint64
ctypedef
unsigned
long
long
npy_uint96
ctypedef
unsigned
long
long
npy_uint128
ctypedef
float
npy_float32
ctypedef
float
npy_float64
ctypedef
float
npy_float80
ctypedef
float
npy_float96
ctypedef
float
npy_float128
ctypedef
double
npy_float64
ctypedef
long
double
npy_float80
ctypedef
long
double
npy_float96
ctypedef
long
double
npy_float128
ctypedef
float
complex
npy_complex64
ctypedef
double
complex
npy_complex128
ctypedef
long
double
complex
npy_complex120
ctypedef
long
double
complex
npy_complex192
ctypedef
long
double
complex
npy_complex256
ctypedef
struct
npy_cfloat
:
float
real
...
...
@@ -246,6 +252,9 @@ ctypedef npy_float64 float64_t
#ctypedef npy_float80 float80_t
#ctypedef npy_float128 float128_t
ctypedef
npy_complex64
complex64_t
ctypedef
npy_complex128
complex128_t
# The int types are mapped a bit surprising --
# numpy.int corresponds to 'l' and numpy.long to 'q'
ctypedef
npy_long
int_t
...
...
@@ -263,6 +272,7 @@ ctypedef npy_cfloat cfloat_t
ctypedef
npy_cdouble
cdouble_t
ctypedef
npy_clongdouble
clongdouble_t
ctypedef
npy_cdouble
complex_t
cdef
inline
char
*
_util_dtypestring
(
dtype
descr
,
char
*
f
,
char
*
end
,
int
*
offset
)
except
NULL
:
# Recursive utility function used in __getbuffer__ to get format
...
...
tests/run/numpy_test.pyx
View file @
30a1dbe7
...
...
@@ -130,6 +130,9 @@ try:
>>> test_dtype('F', inc1_cfloat) # numpy format codes differ from buffer ones here
>>> test_dtype('D', inc1_cdouble)
>>> test_dtype('G', inc1_clongdouble)
>>> test_dtype('F', inc1_cfloat_struct)
>>> test_dtype('D', inc1_cdouble_struct)
>>> test_dtype('G', inc1_clongdouble_struct)
>>> test_dtype(np.int, inc1_int_t)
>>> test_dtype(np.long, inc1_long_t)
...
...
@@ -258,15 +261,19 @@ def inc1_float(np.ndarray[float] arr): arr[1] += 1
def
inc1_double
(
np
.
ndarray
[
double
]
arr
):
arr
[
1
]
+=
1
def
inc1_longdouble
(
np
.
ndarray
[
long
double
]
arr
):
arr
[
1
]
+=
1
def
inc1_cfloat
(
np
.
ndarray
[
np
.
cfloat_t
]
arr
):
def
inc1_cfloat
(
np
.
ndarray
[
float
complex
]
arr
):
arr
[
1
]
=
arr
[
1
]
+
1
+
1j
def
inc1_cdouble
(
np
.
ndarray
[
double
complex
]
arr
):
arr
[
1
]
=
(
arr
[
1
]
+
1
)
+
1j
def
inc1_clongdouble
(
np
.
ndarray
[
long
double
complex
]
arr
):
arr
[
1
]
=
arr
[
1
]
+
(
1
+
1j
)
def
inc1_cfloat_struct
(
np
.
ndarray
[
np
.
cfloat_t
]
arr
):
arr
[
1
].
real
+=
1
arr
[
1
].
imag
+=
1
def
inc1_cdouble
(
np
.
ndarray
[
np
.
cdouble_t
]
arr
):
def
inc1_cdouble
_struct
(
np
.
ndarray
[
np
.
cdouble_t
]
arr
):
arr
[
1
].
real
+=
1
arr
[
1
].
imag
+=
1
def
inc1_clongdouble
(
np
.
ndarray
[
np
.
clongdouble_t
]
arr
):
def
inc1_clongdouble
_struct
(
np
.
ndarray
[
np
.
clongdouble_t
]
arr
):
cdef
long
double
x
x
=
arr
[
1
].
real
+
1
arr
[
1
].
real
=
x
...
...
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