Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
8502f542
Commit
8502f542
authored
Jun 19, 2016
by
Ivan Smirnov
Browse files
Add packed recarray tests
parent
2e1565e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
example/example20.py
example/example20.py
+14
-13
No files found.
example/example20.py
View file @
8502f542
...
@@ -2,23 +2,24 @@
...
@@ -2,23 +2,24 @@
from
__future__
import
print_function
from
__future__
import
print_function
import
numpy
as
np
import
numpy
as
np
from
example
import
create_rec_simple
from
example
import
create_rec_simple
,
create_rec_packed
def
check_eq
(
arr
,
data
,
dtype
):
def
check_eq
(
arr
,
data
,
dtype
):
np
.
testing
.
assert_equal
(
arr
,
np
.
array
(
data
,
dtype
=
dtype
))
np
.
testing
.
assert_equal
(
arr
,
np
.
array
(
data
,
dtype
=
dtype
))
dtype
=
np
.
dtype
({
'names'
:
[
'x'
,
'y'
,
'z'
],
simple_
dtype
=
np
.
dtype
({
'names'
:
[
'x'
,
'y'
,
'z'
],
'formats'
:
[
'?'
,
'u4'
,
'f4'
],
'formats'
:
[
'?'
,
'u4'
,
'f4'
],
'offsets'
:
[
0
,
4
,
8
]})
'offsets'
:
[
0
,
4
,
8
]})
base
_dtype
=
np
.
dtype
([(
'x'
,
'?'
),
(
'y'
,
'u4'
),
(
'z'
,
'f4'
)])
packed
_dtype
=
np
.
dtype
([(
'x'
,
'?'
),
(
'y'
,
'u4'
),
(
'z'
,
'f4'
)])
arr
=
create_rec_simple
(
3
)
for
func
,
dtype
in
[(
create_rec_simple
,
simple_dtype
),
(
create_rec_packed
,
packed_dtype
)]:
assert
arr
.
dtype
==
dtype
arr
=
func
(
3
)
check_eq
(
arr
,
[(
False
,
0
,
0.0
),
(
True
,
1
,
1.5
),
(
False
,
2
,
3.0
)],
dtype
)
assert
arr
.
dtype
==
dtype
check_eq
(
arr
,
[(
False
,
0
,
0.0
),
(
True
,
1
,
1.5
),
(
False
,
2
,
3.0
)],
base_dtype
)
check_eq
(
arr
,
[(
False
,
0
,
0.0
),
(
True
,
1
,
1.5
),
(
False
,
2
,
3.0
)],
simple_dtype
)
check_eq
(
arr
,
[(
False
,
0
,
0.0
),
(
True
,
1
,
1.5
),
(
False
,
2
,
3.0
)],
packed_dtype
)
arr
=
create_rec_simple
(
0
)
arr
=
func
(
0
)
assert
arr
.
dtype
==
dtype
assert
arr
.
dtype
==
dtype
check_eq
(
arr
,
[],
dtype
)
check_eq
(
arr
,
[],
simple_
dtype
)
check_eq
(
arr
,
[],
base
_dtype
)
check_eq
(
arr
,
[],
packed
_dtype
)
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