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
Kirill Smelkov
cython
Commits
ef636c67
Commit
ef636c67
authored
Apr 14, 2021
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git+ssh://github.com/cython/cython
parents
817672d5
69dfdf91
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
96 deletions
+12
-96
tests/buffers/bufaccess.pyx
tests/buffers/bufaccess.pyx
+1
-4
tests/buffers/buffmt.pyx
tests/buffers/buffmt.pyx
+1
-23
tests/memoryview/memoryviewattrs.pyx
tests/memoryview/memoryviewattrs.pyx
+0
-22
tests/memoryview/numpy_memoryview.pyx
tests/memoryview/numpy_memoryview.pyx
+6
-31
tests/run/numpy_test.pyx
tests/run/numpy_test.pyx
+4
-16
No files found.
tests/buffers/bufaccess.pyx
View file @
ef636c67
...
@@ -13,8 +13,6 @@ from cpython.object cimport PyObject
...
@@ -13,8 +13,6 @@ from cpython.object cimport PyObject
from
cpython.ref
cimport
Py_INCREF
,
Py_DECREF
from
cpython.ref
cimport
Py_INCREF
,
Py_DECREF
cimport
cython
cimport
cython
__test__
=
{}
import
sys
import
sys
#import re
#import re
exclude
=
[]
#re.compile('object').search]
exclude
=
[]
#re.compile('object').search]
...
@@ -27,8 +25,7 @@ if getattr(sys, 'pypy_version_info', None) is not None:
...
@@ -27,8 +25,7 @@ if getattr(sys, 'pypy_version_info', None) is not None:
def
testcase
(
func
):
def
testcase
(
func
):
for
e
in
exclude
:
for
e
in
exclude
:
if
e
(
func
.
__name__
):
if
e
(
func
.
__name__
):
return
func
func
.
__doc__
=
""
# disable the test
__test__
[
func
.
__name__
]
=
func
.
__doc__
return
func
return
func
...
...
tests/buffers/buffmt.pyx
View file @
ef636c67
...
@@ -3,10 +3,6 @@ import struct
...
@@ -3,10 +3,6 @@ import struct
# Tests buffer format string parsing.
# Tests buffer format string parsing.
__test__
=
{}
def
testcase
(
func
):
__test__
[
func
.
__name__
]
=
func
.
__doc__
return
func
from
libc
cimport
stdlib
from
libc
cimport
stdlib
...
@@ -56,7 +52,6 @@ cdef class MockBuffer:
...
@@ -56,7 +52,6 @@ cdef class MockBuffer:
info
.
format
=
self
.
format
info
.
format
=
self
.
format
info
.
itemsize
=
self
.
itemsize
info
.
itemsize
=
self
.
itemsize
@
testcase
def
_int
(
fmt
):
def
_int
(
fmt
):
"""
"""
>>> _int("i")
>>> _int("i")
...
@@ -78,14 +73,12 @@ def _int(fmt):
...
@@ -78,14 +73,12 @@ def _int(fmt):
"""
"""
cdef
object
[
int
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
int
))
cdef
object
[
int
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
int
))
@
testcase
def
_ulong
(
fmt
):
def
_ulong
(
fmt
):
"""
"""
>>> _ulong("L")
>>> _ulong("L")
"""
"""
cdef
object
[
unsigned
long
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
unsigned
long
))
cdef
object
[
unsigned
long
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
unsigned
long
))
@
testcase
def
wrongsize
():
def
wrongsize
():
"""
"""
>>> wrongsize()
>>> wrongsize()
...
@@ -96,7 +89,6 @@ def wrongsize():
...
@@ -96,7 +89,6 @@ def wrongsize():
"""
"""
cdef
object
[
float
]
buf
=
MockBuffer
(
"f"
,
1
)
cdef
object
[
float
]
buf
=
MockBuffer
(
"f"
,
1
)
@
testcase
def
_obj
(
fmt
):
def
_obj
(
fmt
):
"""
"""
>>> _obj("O")
>>> _obj("O")
...
@@ -151,7 +143,6 @@ cdef struct UnpackedStruct4:
...
@@ -151,7 +143,6 @@ cdef struct UnpackedStruct4:
char
d
char
d
int
e
,
f
,
g
int
e
,
f
,
g
@
testcase
def
char3int
(
fmt
):
def
char3int
(
fmt
):
"""
"""
>>> char3int("ciii")
>>> char3int("ciii")
...
@@ -185,7 +176,6 @@ def char3int(fmt):
...
@@ -185,7 +176,6 @@ def char3int(fmt):
cdef
object
[
Char3Int
,
ndim
=
1
]
buf
=
obj
cdef
object
[
Char3Int
,
ndim
=
1
]
buf
=
obj
@
testcase
def
long_string
(
fmt
):
def
long_string
(
fmt
):
"""
"""
>>> long_string("90198s")
>>> long_string("90198s")
...
@@ -194,7 +184,6 @@ def long_string(fmt):
...
@@ -194,7 +184,6 @@ def long_string(fmt):
cdef
object
[
LongString
,
ndim
=
1
]
buf
=
obj
cdef
object
[
LongString
,
ndim
=
1
]
buf
=
obj
@
testcase
def
unpacked_struct
(
fmt
):
def
unpacked_struct
(
fmt
):
"""
"""
Native formats:
Native formats:
...
@@ -218,7 +207,6 @@ def unpacked_struct(fmt):
...
@@ -218,7 +207,6 @@ def unpacked_struct(fmt):
cdef
struct
ComplexTest
:
cdef
struct
ComplexTest
:
ComplexFloat
a
,
b
,
c
ComplexFloat
a
,
b
,
c
@
testcase
def
complex_test
(
fmt
):
def
complex_test
(
fmt
):
"""
"""
>>> complex_test("ZfZfZf")
>>> complex_test("ZfZfZf")
...
@@ -236,7 +224,6 @@ def complex_test(fmt):
...
@@ -236,7 +224,6 @@ def complex_test(fmt):
cdef
object
[
ComplexTest
]
buf1
=
obj
cdef
object
[
ComplexTest
]
buf1
=
obj
@
testcase
def
alignment_string
(
fmt
,
exc
=
None
):
def
alignment_string
(
fmt
,
exc
=
None
):
"""
"""
>>> alignment_string("@i")
>>> alignment_string("@i")
...
@@ -258,7 +245,6 @@ def alignment_string(fmt, exc=None):
...
@@ -258,7 +245,6 @@ def alignment_string(fmt, exc=None):
print
"fail"
print
"fail"
@
testcase
def
int_and_long_are_same
():
def
int_and_long_are_same
():
"""
"""
>>> int_and_long_are_same()
>>> int_and_long_are_same()
...
@@ -273,7 +259,6 @@ cdef struct MixedComplex:
...
@@ -273,7 +259,6 @@ cdef struct MixedComplex:
double
real
double
real
float
imag
float
imag
@
testcase
def
mixed_complex_struct
():
def
mixed_complex_struct
():
"""
"""
Triggering a specific execution path for this case.
Triggering a specific execution path for this case.
...
@@ -311,7 +296,6 @@ cdef packed struct PartiallyPackedStruct2:
...
@@ -311,7 +296,6 @@ cdef packed struct PartiallyPackedStruct2:
char
b
char
b
int
c
int
c
@
testcase
def
packed_struct
(
fmt
):
def
packed_struct
(
fmt
):
"""
"""
Assuming int is four bytes:
Assuming int is four bytes:
...
@@ -334,7 +318,6 @@ def packed_struct(fmt):
...
@@ -334,7 +318,6 @@ def packed_struct(fmt):
"""
"""
cdef
object
[
PackedStruct
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
PackedStruct
))
cdef
object
[
PackedStruct
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
PackedStruct
))
@
testcase
def
partially_packed_struct
(
fmt
):
def
partially_packed_struct
(
fmt
):
"""
"""
Assuming int is four bytes:
Assuming int is four bytes:
...
@@ -362,7 +345,6 @@ def partially_packed_struct(fmt):
...
@@ -362,7 +345,6 @@ def partially_packed_struct(fmt):
cdef
object
[
PartiallyPackedStruct
]
buf
=
MockBuffer
(
cdef
object
[
PartiallyPackedStruct
]
buf
=
MockBuffer
(
fmt
,
sizeof
(
PartiallyPackedStruct
))
fmt
,
sizeof
(
PartiallyPackedStruct
))
@
testcase
def
partially_packed_struct_2
(
fmt
):
def
partially_packed_struct_2
(
fmt
):
"""
"""
Assuming int is four bytes:
Assuming int is four bytes:
...
@@ -398,7 +380,6 @@ cdef packed struct PackedStructWithCharArrays:
...
@@ -398,7 +380,6 @@ cdef packed struct PackedStructWithCharArrays:
char
[
3
]
d
char
[
3
]
d
@
testcase
def
packed_struct_with_strings
(
fmt
):
def
packed_struct_with_strings
(
fmt
):
"""
"""
>>> packed_struct_with_strings("T{f:a:i:b:5s:c:3s:d:}")
>>> packed_struct_with_strings("T{f:a:i:b:5s:c:3s:d:}")
...
@@ -430,7 +411,6 @@ ctypedef struct PackedStructWithNDArrays:
...
@@ -430,7 +411,6 @@ ctypedef struct PackedStructWithNDArrays:
float
d
float
d
@
testcase
def
packed_struct_with_arrays
(
fmt
):
def
packed_struct_with_arrays
(
fmt
):
"""
"""
>>> packed_struct_with_arrays("T{(16)d:a:(16)d:b:d:c:}")
>>> packed_struct_with_arrays("T{(16)d:a:(16)d:b:d:c:}")
...
@@ -440,7 +420,6 @@ def packed_struct_with_arrays(fmt):
...
@@ -440,7 +420,6 @@ def packed_struct_with_arrays(fmt):
fmt
,
sizeof
(
PackedStructWithArrays
))
fmt
,
sizeof
(
PackedStructWithArrays
))
@
testcase
def
unpacked_struct_with_arrays
(
fmt
):
def
unpacked_struct_with_arrays
(
fmt
):
"""
"""
>>> if struct.calcsize('P') == 8: # 64 bit
>>> if struct.calcsize('P') == 8: # 64 bit
...
@@ -453,7 +432,6 @@ def unpacked_struct_with_arrays(fmt):
...
@@ -453,7 +432,6 @@ def unpacked_struct_with_arrays(fmt):
fmt
,
sizeof
(
UnpackedStructWithArrays
))
fmt
,
sizeof
(
UnpackedStructWithArrays
))
@
testcase
def
packed_struct_with_ndarrays
(
fmt
):
def
packed_struct_with_ndarrays
(
fmt
):
"""
"""
>>> packed_struct_with_ndarrays("T{d:a:(2,2)d:b:f:c:f:d:}")
>>> packed_struct_with_ndarrays("T{d:a:(2,2)d:b:f:c:f:d:}")
...
...
tests/memoryview/memoryviewattrs.pyx
View file @
ef636c67
# mode: run
# mode: run
# tag: numpy
# tag: numpy
__test__
=
{}
def
testcase
(
func
):
__test__
[
func
.
__name__
]
=
func
.
__doc__
return
func
cimport
cython
cimport
cython
from
cython.view
cimport
array
from
cython.view
cimport
array
...
@@ -15,7 +8,6 @@ import numpy as np
...
@@ -15,7 +8,6 @@ import numpy as np
cimport
numpy
as
np
cimport
numpy
as
np
@
testcase
def
test_shape_stride_suboffset
():
def
test_shape_stride_suboffset
():
u'''
u'''
>>> test_shape_stride_suboffset()
>>> test_shape_stride_suboffset()
...
@@ -49,7 +41,6 @@ def test_shape_stride_suboffset():
...
@@ -49,7 +41,6 @@ def test_shape_stride_suboffset():
print
c_contig
.
suboffsets
[
0
],
c_contig
.
suboffsets
[
1
],
c_contig
.
suboffsets
[
2
]
print
c_contig
.
suboffsets
[
0
],
c_contig
.
suboffsets
[
1
],
c_contig
.
suboffsets
[
2
]
@
testcase
def
test_copy_to
():
def
test_copy_to
():
u'''
u'''
>>> test_copy_to()
>>> test_copy_to()
...
@@ -72,7 +63,6 @@ def test_copy_to():
...
@@ -72,7 +63,6 @@ def test_copy_to():
print
' '
.
join
(
str
(
to_data
[
i
])
for
i
in
range
(
2
*
2
*
2
))
print
' '
.
join
(
str
(
to_data
[
i
])
for
i
in
range
(
2
*
2
*
2
))
@
testcase
def
test_overlapping_copy
():
def
test_overlapping_copy
():
"""
"""
>>> test_overlapping_copy()
>>> test_overlapping_copy()
...
@@ -88,7 +78,6 @@ def test_overlapping_copy():
...
@@ -88,7 +78,6 @@ def test_overlapping_copy():
assert
slice
[
i
]
==
10
-
1
-
i
assert
slice
[
i
]
==
10
-
1
-
i
@
testcase
def
test_copy_return_type
():
def
test_copy_return_type
():
"""
"""
>>> test_copy_return_type()
>>> test_copy_return_type()
...
@@ -103,7 +92,6 @@ def test_copy_return_type():
...
@@ -103,7 +92,6 @@ def test_copy_return_type():
print
(
f_contig
[
2
,
2
])
print
(
f_contig
[
2
,
2
])
@
testcase
def
test_partly_overlapping
():
def
test_partly_overlapping
():
"""
"""
>>> test_partly_overlapping()
>>> test_partly_overlapping()
...
@@ -119,7 +107,6 @@ def test_partly_overlapping():
...
@@ -119,7 +107,6 @@ def test_partly_overlapping():
for
i
in
range
(
5
):
for
i
in
range
(
5
):
assert
slice2
[
i
]
==
i
+
4
assert
slice2
[
i
]
==
i
+
4
@
testcase
@
cython
.
nonecheck
(
True
)
@
cython
.
nonecheck
(
True
)
def
test_nonecheck1
():
def
test_nonecheck1
():
u'''
u'''
...
@@ -131,7 +118,6 @@ def test_nonecheck1():
...
@@ -131,7 +118,6 @@ def test_nonecheck1():
cdef
int
[:,:,:]
uninitialized
cdef
int
[:,:,:]
uninitialized
print
uninitialized
.
is_c_contig
()
print
uninitialized
.
is_c_contig
()
@
testcase
@
cython
.
nonecheck
(
True
)
@
cython
.
nonecheck
(
True
)
def
test_nonecheck2
():
def
test_nonecheck2
():
u'''
u'''
...
@@ -143,7 +129,6 @@ def test_nonecheck2():
...
@@ -143,7 +129,6 @@ def test_nonecheck2():
cdef
int
[:,:,:]
uninitialized
cdef
int
[:,:,:]
uninitialized
print
uninitialized
.
is_f_contig
()
print
uninitialized
.
is_f_contig
()
@
testcase
@
cython
.
nonecheck
(
True
)
@
cython
.
nonecheck
(
True
)
def
test_nonecheck3
():
def
test_nonecheck3
():
u'''
u'''
...
@@ -155,7 +140,6 @@ def test_nonecheck3():
...
@@ -155,7 +140,6 @@ def test_nonecheck3():
cdef
int
[:,:,:]
uninitialized
cdef
int
[:,:,:]
uninitialized
uninitialized
.
copy
()
uninitialized
.
copy
()
@
testcase
@
cython
.
nonecheck
(
True
)
@
cython
.
nonecheck
(
True
)
def
test_nonecheck4
():
def
test_nonecheck4
():
u'''
u'''
...
@@ -167,7 +151,6 @@ def test_nonecheck4():
...
@@ -167,7 +151,6 @@ def test_nonecheck4():
cdef
int
[:,:,:]
uninitialized
cdef
int
[:,:,:]
uninitialized
uninitialized
.
copy_fortran
()
uninitialized
.
copy_fortran
()
@
testcase
@
cython
.
nonecheck
(
True
)
@
cython
.
nonecheck
(
True
)
def
test_nonecheck5
():
def
test_nonecheck5
():
u'''
u'''
...
@@ -179,7 +162,6 @@ def test_nonecheck5():
...
@@ -179,7 +162,6 @@ def test_nonecheck5():
cdef
int
[:,:,:]
uninitialized
cdef
int
[:,:,:]
uninitialized
uninitialized
.
_data
uninitialized
.
_data
@
testcase
def
test_copy_mismatch
():
def
test_copy_mismatch
():
u'''
u'''
>>> test_copy_mismatch()
>>> test_copy_mismatch()
...
@@ -193,7 +175,6 @@ def test_copy_mismatch():
...
@@ -193,7 +175,6 @@ def test_copy_mismatch():
mv1
[...]
=
mv2
mv1
[...]
=
mv2
@
testcase
def
test_is_contiguous
():
def
test_is_contiguous
():
u"""
u"""
>>> test_is_contiguous()
>>> test_is_contiguous()
...
@@ -222,7 +203,6 @@ def test_is_contiguous():
...
@@ -222,7 +203,6 @@ def test_is_contiguous():
print
'strided'
,
strided
[::
2
].
is_c_contig
()
print
'strided'
,
strided
[::
2
].
is_c_contig
()
@
testcase
def
call
():
def
call
():
u'''
u'''
>>> call()
>>> call()
...
@@ -265,7 +245,6 @@ def call():
...
@@ -265,7 +245,6 @@ def call():
assert
len
(
mv3
)
==
3
assert
len
(
mv3
)
==
3
@
testcase
def
two_dee
():
def
two_dee
():
u'''
u'''
>>> two_dee()
>>> two_dee()
...
@@ -313,7 +292,6 @@ def two_dee():
...
@@ -313,7 +292,6 @@ def two_dee():
print
(
<
long
*>
mv3
.
_data
)[
0
]
,
(
<
long
*>
mv3
.
_data
)[
1
]
,
(
<
long
*>
mv3
.
_data
)[
2
]
,
(
<
long
*>
mv3
.
_data
)[
3
]
print
(
<
long
*>
mv3
.
_data
)[
0
]
,
(
<
long
*>
mv3
.
_data
)[
1
]
,
(
<
long
*>
mv3
.
_data
)[
2
]
,
(
<
long
*>
mv3
.
_data
)[
3
]
@
testcase
def
fort_two_dee
():
def
fort_two_dee
():
u'''
u'''
>>> fort_two_dee()
>>> fort_two_dee()
...
...
tests/memoryview/numpy_memoryview.pyx
View file @
ef636c67
...
@@ -36,18 +36,11 @@ def ae(*args):
...
@@ -36,18 +36,11 @@ def ae(*args):
if
x
!=
args
[
0
]:
if
x
!=
args
[
0
]:
raise
AssertionError
(
args
)
raise
AssertionError
(
args
)
__test__
=
{}
def
testcase_no_pypy
(
f
,
_is_pypy
=
hasattr
(
sys
,
"pypy_version_info"
)):
if
_is_pypy
:
def
testcase
(
f
):
f
.
__doc__
=
""
# disable the tests
__test__
[
f
.
__name__
]
=
f
.
__doc__
return
f
def
testcase_numpy_1_5
(
f
):
if
NUMPY_VERSION
>=
(
1
,
5
)
or
IS_PYPY
:
__test__
[
f
.
__name__
]
=
f
.
__doc__
return
f
return
f
def
gc_collect_if_required
():
def
gc_collect_if_required
():
if
NUMPY_VERSION
>=
(
1
,
14
)
or
IS_PYPY
:
if
NUMPY_VERSION
>=
(
1
,
14
)
or
IS_PYPY
:
import
gc
import
gc
...
@@ -58,7 +51,6 @@ def gc_collect_if_required():
...
@@ -58,7 +51,6 @@ def gc_collect_if_required():
### Test slicing memoryview slices
### Test slicing memoryview slices
#
#
@
testcase
def
test_partial_slicing
(
array
):
def
test_partial_slicing
(
array
):
"""
"""
>>> test_partial_slicing(a)
>>> test_partial_slicing(a)
...
@@ -74,7 +66,6 @@ def test_partial_slicing(array):
...
@@ -74,7 +66,6 @@ def test_partial_slicing(array):
ae
(
b
.
strides
[
0
],
c
.
strides
[
0
],
obj
.
strides
[
0
])
ae
(
b
.
strides
[
0
],
c
.
strides
[
0
],
obj
.
strides
[
0
])
ae
(
b
.
strides
[
1
],
c
.
strides
[
1
],
obj
.
strides
[
1
])
ae
(
b
.
strides
[
1
],
c
.
strides
[
1
],
obj
.
strides
[
1
])
@
testcase
def
test_ellipsis
(
array
):
def
test_ellipsis
(
array
):
"""
"""
>>> test_ellipsis(a)
>>> test_ellipsis(a)
...
@@ -116,7 +107,6 @@ def test_ellipsis(array):
...
@@ -116,7 +107,6 @@ def test_ellipsis(array):
#
#
### Test slicing memoryview objects
### Test slicing memoryview objects
#
#
@
testcase
def
test_partial_slicing_memoryview
(
array
):
def
test_partial_slicing_memoryview
(
array
):
"""
"""
>>> test_partial_slicing_memoryview(a)
>>> test_partial_slicing_memoryview(a)
...
@@ -133,7 +123,6 @@ def test_partial_slicing_memoryview(array):
...
@@ -133,7 +123,6 @@ def test_partial_slicing_memoryview(array):
ae
(
b
.
strides
[
0
],
c
.
strides
[
0
],
obj
.
strides
[
0
])
ae
(
b
.
strides
[
0
],
c
.
strides
[
0
],
obj
.
strides
[
0
])
ae
(
b
.
strides
[
1
],
c
.
strides
[
1
],
obj
.
strides
[
1
])
ae
(
b
.
strides
[
1
],
c
.
strides
[
1
],
obj
.
strides
[
1
])
@
testcase
def
test_ellipsis_memoryview
(
array
):
def
test_ellipsis_memoryview
(
array
):
"""
"""
>>> test_ellipsis_memoryview(a)
>>> test_ellipsis_memoryview(a)
...
@@ -174,7 +163,6 @@ def test_ellipsis_memoryview(array):
...
@@ -174,7 +163,6 @@ def test_ellipsis_memoryview(array):
ae
(
e
.
strides
[
0
],
e_obj
.
strides
[
0
])
ae
(
e
.
strides
[
0
],
e_obj
.
strides
[
0
])
@
testcase
def
test_transpose
():
def
test_transpose
():
"""
"""
>>> test_transpose()
>>> test_transpose()
...
@@ -205,7 +193,6 @@ def test_transpose():
...
@@ -205,7 +193,6 @@ def test_transpose():
print
a
[
3
,
2
],
a
.
T
[
2
,
3
],
a_obj
[
3
,
2
],
a_obj
.
T
[
2
,
3
],
numpy_obj
[
3
,
2
],
numpy_obj
.
T
[
2
,
3
]
print
a
[
3
,
2
],
a
.
T
[
2
,
3
],
a_obj
[
3
,
2
],
a_obj
.
T
[
2
,
3
],
numpy_obj
[
3
,
2
],
numpy_obj
.
T
[
2
,
3
]
@
testcase
def
test_transpose_type
(
a
):
def
test_transpose_type
(
a
):
"""
"""
>>> a = np.zeros((5, 10), dtype=np.float64)
>>> a = np.zeros((5, 10), dtype=np.float64)
...
@@ -218,12 +205,8 @@ def test_transpose_type(a):
...
@@ -218,12 +205,8 @@ def test_transpose_type(a):
print
m_transpose
[
6
,
4
]
print
m_transpose
[
6
,
4
]
@
testcase_numpy_1_5
def
test_numpy_like_attributes
(
cyarray
):
def
test_numpy_like_attributes
(
cyarray
):
"""
"""
For some reason this fails in numpy 1.4, with shape () and strides (40, 8)
instead of 20, 4 on my machine. Investigate this.
>>> cyarray = create_array(shape=(8, 5), mode="c")
>>> cyarray = create_array(shape=(8, 5), mode="c")
>>> test_numpy_like_attributes(cyarray)
>>> test_numpy_like_attributes(cyarray)
>>> test_numpy_like_attributes(cyarray.memview)
>>> test_numpy_like_attributes(cyarray.memview)
...
@@ -239,7 +222,6 @@ def test_numpy_like_attributes(cyarray):
...
@@ -239,7 +222,6 @@ def test_numpy_like_attributes(cyarray):
cdef
int
[:,
:]
mslice
=
numarray
cdef
int
[:,
:]
mslice
=
numarray
assert
(
<
object
>
mslice
).
base
is
numarray
assert
(
<
object
>
mslice
).
base
is
numarray
@
testcase_numpy_1_5
def
test_copy_and_contig_attributes
(
a
):
def
test_copy_and_contig_attributes
(
a
):
"""
"""
>>> a = np.arange(20, dtype=np.int32).reshape(5, 4)
>>> a = np.arange(20, dtype=np.int32).reshape(5, 4)
...
@@ -276,7 +258,7 @@ def build_numarray(array array):
...
@@ -276,7 +258,7 @@ def build_numarray(array array):
def
index
(
array
array
):
def
index
(
array
array
):
print
build_numarray
(
array
)[
3
,
2
]
print
build_numarray
(
array
)[
3
,
2
]
@
testcase_n
umpy_1_5
@
testcase_n
o_pypy
def
test_coerce_to_numpy
():
def
test_coerce_to_numpy
():
"""
"""
Test coercion to NumPy arrays, especially with automatically
Test coercion to NumPy arrays, especially with automatically
...
@@ -357,6 +339,7 @@ def test_coerce_to_numpy():
...
@@ -357,6 +339,7 @@ def test_coerce_to_numpy():
'e'
:
800
,
'e'
:
800
,
}
}
smallstructs
[
idx
]
=
{
'a'
:
600
,
'b'
:
700
}
smallstructs
[
idx
]
=
{
'a'
:
600
,
'b'
:
700
}
nestedstructs
[
idx
]
=
{
nestedstructs
[
idx
]
=
{
...
@@ -414,7 +397,7 @@ def test_coerce_to_numpy():
...
@@ -414,7 +397,7 @@ def test_coerce_to_numpy():
index
(
<
td_h_ushort
[:
4
,
:
5
]
>
<
td_h_ushort
*>
h_ushorts
)
index
(
<
td_h_ushort
[:
4
,
:
5
]
>
<
td_h_ushort
*>
h_ushorts
)
@
testcase_n
umpy_1_5
@
testcase_n
o_pypy
def
test_memslice_getbuffer
():
def
test_memslice_getbuffer
():
"""
"""
>>> test_memslice_getbuffer(); gc_collect_if_required()
>>> test_memslice_getbuffer(); gc_collect_if_required()
...
@@ -453,7 +436,6 @@ cdef packed struct StructArray:
...
@@ -453,7 +436,6 @@ cdef packed struct StructArray:
int
a
[
4
]
int
a
[
4
]
signed
char
b
[
5
]
signed
char
b
[
5
]
@
testcase_numpy_1_5
def
test_memslice_structarray
(
data
,
dtype
):
def
test_memslice_structarray
(
data
,
dtype
):
"""
"""
>>> def b(s): return s.encode('ascii')
>>> def b(s): return s.encode('ascii')
...
@@ -509,7 +491,6 @@ def test_memslice_structarray(data, dtype):
...
@@ -509,7 +491,6 @@ def test_memslice_structarray(data, dtype):
print
myslice
[
i
].
a
[
j
]
print
myslice
[
i
].
a
[
j
]
print
myslice
[
i
].
b
.
decode
(
'ASCII'
)
print
myslice
[
i
].
b
.
decode
(
'ASCII'
)
@
testcase_numpy_1_5
def
test_structarray_errors
(
StructArray
[:]
a
):
def
test_structarray_errors
(
StructArray
[:]
a
):
"""
"""
>>> dtype = np.dtype([('a', '4i'), ('b', '5b')])
>>> dtype = np.dtype([('a', '4i'), ('b', '5b')])
...
@@ -556,7 +537,6 @@ def stringstructtest(StringStruct[:] view):
...
@@ -556,7 +537,6 @@ def stringstructtest(StringStruct[:] view):
def
stringtest
(
String
[:]
view
):
def
stringtest
(
String
[:]
view
):
pass
pass
@
testcase_numpy_1_5
def
test_string_invalid_dims
():
def
test_string_invalid_dims
():
"""
"""
>>> def b(s): return s.encode('ascii')
>>> def b(s): return s.encode('ascii')
...
@@ -577,7 +557,6 @@ ctypedef struct AttributesStruct:
...
@@ -577,7 +557,6 @@ ctypedef struct AttributesStruct:
float
attrib2
float
attrib2
StringStruct
attrib3
StringStruct
attrib3
@
testcase_numpy_1_5
def
test_struct_attributes
():
def
test_struct_attributes
():
"""
"""
>>> test_struct_attributes()
>>> test_struct_attributes()
...
@@ -633,7 +612,6 @@ cdef class SuboffsetsNoStridesBuffer(Buffer):
...
@@ -633,7 +612,6 @@ cdef class SuboffsetsNoStridesBuffer(Buffer):
getbuffer
(
self
,
info
)
getbuffer
(
self
,
info
)
info
.
suboffsets
=
self
.
_shape
info
.
suboffsets
=
self
.
_shape
@
testcase
def
test_null_strides
(
Buffer
buffer_obj
):
def
test_null_strides
(
Buffer
buffer_obj
):
"""
"""
>>> test_null_strides(Buffer())
>>> test_null_strides(Buffer())
...
@@ -653,7 +631,6 @@ def test_null_strides(Buffer buffer_obj):
...
@@ -653,7 +631,6 @@ def test_null_strides(Buffer buffer_obj):
assert
m2
[
i
,
j
]
==
buffer_obj
.
m
[
i
,
j
],
(
i
,
j
,
m2
[
i
,
j
],
buffer_obj
.
m
[
i
,
j
])
assert
m2
[
i
,
j
]
==
buffer_obj
.
m
[
i
,
j
],
(
i
,
j
,
m2
[
i
,
j
],
buffer_obj
.
m
[
i
,
j
])
assert
m3
[
i
,
j
]
==
buffer_obj
.
m
[
i
,
j
]
assert
m3
[
i
,
j
]
==
buffer_obj
.
m
[
i
,
j
]
@
testcase
def
test_null_strides_error
(
buffer_obj
):
def
test_null_strides_error
(
buffer_obj
):
"""
"""
>>> test_null_strides_error(Buffer())
>>> test_null_strides_error(Buffer())
...
@@ -727,7 +704,6 @@ ctypedef struct SameTypeAfterArraysStructSimple:
...
@@ -727,7 +704,6 @@ ctypedef struct SameTypeAfterArraysStructSimple:
double
b
[
16
]
double
b
[
16
]
double
c
double
c
@
testcase
def
same_type_after_arrays_simple
():
def
same_type_after_arrays_simple
():
"""
"""
>>> same_type_after_arrays_simple()
>>> same_type_after_arrays_simple()
...
@@ -749,7 +725,6 @@ ctypedef struct SameTypeAfterArraysStructComposite:
...
@@ -749,7 +725,6 @@ ctypedef struct SameTypeAfterArraysStructComposite:
double
h
[
4
]
double
h
[
4
]
int
i
int
i
@
testcase
def
same_type_after_arrays_composite
():
def
same_type_after_arrays_composite
():
"""
"""
>>> same_type_after_arrays_composite() if sys.version_info[:2] >= (3, 5) else None
>>> same_type_after_arrays_composite() if sys.version_info[:2] >= (3, 5) else None
...
...
tests/run/numpy_test.pyx
View file @
ef636c67
...
@@ -10,16 +10,10 @@ def little_endian():
...
@@ -10,16 +10,10 @@ def little_endian():
cdef
int
endian_detector
=
1
cdef
int
endian_detector
=
1
return
(
<
char
*>&
endian_detector
)[
0
]
!=
0
return
(
<
char
*>&
endian_detector
)[
0
]
!=
0
__test__
=
{}
def
testcase
(
f
):
def
testcase
(
f
):
__test__
[
f
.
__name__
]
=
f
.
__doc__
# testcase decorator now does nothing (following changes to doctest)
return
f
# but is a useful indicator of what functions are designed as tests
def
testcase_have_buffer_interface
(
f
):
major
,
minor
,
*
rest
=
np
.
__version__
.
split
(
'.'
)
if
(
int
(
major
),
int
(
minor
))
>=
(
1
,
5
):
__test__
[
f
.
__name__
]
=
f
.
__doc__
return
f
return
f
if
little_endian
():
if
little_endian
():
...
@@ -267,8 +261,6 @@ try:
...
@@ -267,8 +261,6 @@ try:
except
:
except
:
__doc__
=
u""
__doc__
=
u""
__test__
[
__name__
]
=
__doc__
def
assert_dtype_sizes
():
def
assert_dtype_sizes
():
assert
sizeof
(
np
.
int8_t
)
==
1
assert
sizeof
(
np
.
int8_t
)
==
1
...
@@ -679,7 +671,6 @@ def get_Foo_array():
...
@@ -679,7 +671,6 @@ def get_Foo_array():
data
[
5
].
b
=
9.0
data
[
5
].
b
=
9.0
return
np
.
asarray
(
<
Foo
[:]
>
data
).
copy
()
return
np
.
asarray
(
<
Foo
[:]
>
data
).
copy
()
@
testcase_have_buffer_interface
def
test_fused_ndarray
(
fused_ndarray
a
):
def
test_fused_ndarray
(
fused_ndarray
a
):
"""
"""
>>> import cython
>>> import cython
...
@@ -728,9 +719,6 @@ cpdef test_fused_cpdef_ndarray(fused_ndarray a):
...
@@ -728,9 +719,6 @@ cpdef test_fused_cpdef_ndarray(fused_ndarray a):
else
:
else
:
print
b
[
5
]
print
b
[
5
]
testcase_have_buffer_interface
(
test_fused_cpdef_ndarray
)
@
testcase_have_buffer_interface
def
test_fused_cpdef_ndarray_cdef_call
():
def
test_fused_cpdef_ndarray_cdef_call
():
"""
"""
>>> test_fused_cpdef_ndarray_cdef_call()
>>> test_fused_cpdef_ndarray_cdef_call()
...
...
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