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
Boxiang Sun
cython
Commits
425ffcd3
Commit
425ffcd3
authored
May 12, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix numpy_test for numpy < 1.5
parent
52735f7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
tests/run/numpy_test.pyx
tests/run/numpy_test.pyx
+28
-0
No files found.
tests/run/numpy_test.pyx
View file @
425ffcd3
...
...
@@ -10,6 +10,18 @@ def little_endian():
cdef
int
endian_detector
=
1
return
(
<
char
*>&
endian_detector
)[
0
]
!=
0
__test__
=
{}
def
testcase
(
f
):
__test__
[
f
.
__name__
]
=
f
.
__doc__
return
f
def
testcase_numpy_1_5
(
f
):
major
,
minor
,
*
rest
=
np
.
__version__
.
split
(
'.'
)
if
(
int
(
major
),
int
(
minor
))
>=
(
1
,
5
):
__test__
[
f
.
__name__
]
=
f
.
__doc__
return
f
if
little_endian
():
my_endian
=
'<'
other_endian
=
'>'
...
...
@@ -254,6 +266,7 @@ try:
except
:
__doc__
=
u""
__test__
[
__name__
]
=
__doc__
def
assert_dtype_sizes
():
assert
sizeof
(
np
.
int8_t
)
==
1
...
...
@@ -506,6 +519,7 @@ def test_point_record():
print
repr
(
test
).
replace
(
'<'
,
'!'
).
replace
(
'>'
,
'!'
)
# Test fused np.ndarray dtypes and runtime dispatch
@
testcase
def
test_fused_ndarray_floating_dtype
(
np
.
ndarray
[
cython
.
floating
,
ndim
=
1
]
a
):
"""
>>> import cython
...
...
@@ -536,6 +550,7 @@ cdef fused fused_external:
np
.
float32_t
np
.
float64_t
@
testcase
def
test_fused_external
(
np
.
ndarray
[
fused_external
,
ndim
=
1
]
a
):
"""
>>> import cython
...
...
@@ -557,6 +572,7 @@ cdef fused fused_buffers:
np
.
ndarray
[
np
.
int32_t
,
ndim
=
1
]
np
.
int64_t
[::
1
]
@
testcase
def
test_fused_buffers
(
fused_buffers
arg
):
"""
>>> sorted(test_fused_buffers.__signatures__)
...
...
@@ -566,6 +582,7 @@ def test_fused_buffers(fused_buffers arg):
cpdef
_fused_cpdef_buffers
(
np
.
ndarray
[
fused_external
]
a
):
print
a
.
dtype
@
testcase
def
test_fused_cpdef_buffers
():
"""
>>> test_fused_cpdef_buffers()
...
...
@@ -577,6 +594,7 @@ def test_fused_cpdef_buffers():
cdef
np
.
ndarray
[
np
.
int32_t
]
typed_array
=
int32_array
_fused_cpdef_buffers
(
typed_array
)
@
testcase
def
test_fused_ndarray_integral_dtype
(
np
.
ndarray
[
cython
.
integral
,
ndim
=
1
]
a
):
"""
>>> import cython
...
...
@@ -601,6 +619,7 @@ cdef fused fused_dtype:
double
complex
object
@
testcase
def
test_fused_ndarray_other_dtypes
(
np
.
ndarray
[
fused_dtype
,
ndim
=
1
]
a
):
"""
>>> import cython
...
...
@@ -635,6 +654,7 @@ def get_Foo_array():
result
[
5
].
b
=
9.0
return
np
.
asarray
(
result
)
@
testcase_numpy_1_5
def
test_fused_ndarray
(
fused_ndarray
a
):
"""
>>> import cython
...
...
@@ -683,6 +703,9 @@ cpdef test_fused_cpdef_ndarray(fused_ndarray a):
else
:
print
b
[
5
]
testcase_numpy_1_5
(
test_fused_cpdef_ndarray
)
@
testcase_numpy_1_5
def
test_fused_cpdef_ndarray_cdef_call
():
"""
>>> test_fused_cpdef_ndarray_cdef_call()
...
...
@@ -701,6 +724,7 @@ float32_array = np.arange(10, dtype=np.float32)
int32_array
=
np
.
arange
(
10
,
dtype
=
np
.
int32
)
int64_array
=
np
.
arange
(
10
,
dtype
=
np
.
int64
)
@
testcase
def
test_dispatch_non_clashing_declarations_repeating_types
(
np
.
ndarray
[
cython
.
floating
]
a1
,
np
.
ndarray
[
int_type
]
a2
,
np
.
ndarray
[
cython
.
floating
]
a3
,
...
...
@@ -724,6 +748,7 @@ cdef fused typedeffed_fused_type:
int
long
@
testcase
def
test_dispatch_typedef
(
np
.
ndarray
[
typedeffed_fused_type
]
a
):
"""
>>> test_dispatch_typedef(int32_array)
...
...
@@ -760,6 +785,7 @@ cdef fused memslice_fused_dtype:
double
complex
object
@
testcase
def
test_fused_memslice_other_dtypes
(
memslice_fused_dtype
[:]
a
):
"""
>>> import cython
...
...
@@ -788,6 +814,7 @@ cdef fused memslice_fused:
double
complex
[:]
object
[:]
@
testcase
def
test_fused_memslice
(
memslice_fused
a
):
"""
>>> import cython
...
...
@@ -807,6 +834,7 @@ def test_fused_memslice(memslice_fused a):
cdef
memslice_fused
b
=
a
print
cython
.
typeof
(
a
),
cython
.
typeof
(
b
),
a
[
5
],
b
[
6
]
@
testcase
def
test_dispatch_memoryview_object
():
"""
>>> test_dispatch_memoryview_object()
...
...
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