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
bdc99020
"git@developer.sourcefind.cn:gaoqiong/pybind11.git" did not exist on "b063e64b19ee89cbdafc3d2a82c3324e57e8e83f"
Commit
bdc99020
authored
Jun 19, 2016
by
Ivan Smirnov
Browse files
Add explicit test for recarray format descriptors
parent
7f913aec
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletion
+15
-1
example/example20.cpp
example/example20.cpp
+7
-0
example/example20.py
example/example20.py
+5
-1
example/example20.ref
example/example20.ref
+3
-0
No files found.
example/example20.cpp
View file @
bdc99020
...
@@ -57,7 +57,13 @@ py::array_t<NestedStruct> create_nested(size_t n) {
...
@@ -57,7 +57,13 @@ py::array_t<NestedStruct> create_nested(size_t n) {
ptr
[
i
].
b
.
x
=
(
i
+
1
)
%
2
;
ptr
[
i
].
b
.
y
=
(
uint32_t
)
(
i
+
1
);
ptr
[
i
].
b
.
z
=
(
float
)
(
i
+
1
)
*
1.5
f
;
ptr
[
i
].
b
.
x
=
(
i
+
1
)
%
2
;
ptr
[
i
].
b
.
y
=
(
uint32_t
)
(
i
+
1
);
ptr
[
i
].
b
.
z
=
(
float
)
(
i
+
1
)
*
1.5
f
;
}
}
return
arr
;
return
arr
;
}
void
print_format_descriptors
()
{
std
::
cout
<<
py
::
format_descriptor
<
Struct
>::
value
()
<<
std
::
endl
;
std
::
cout
<<
py
::
format_descriptor
<
PackedStruct
>::
value
()
<<
std
::
endl
;
std
::
cout
<<
py
::
format_descriptor
<
NestedStruct
>::
value
()
<<
std
::
endl
;
}
}
void
init_ex20
(
py
::
module
&
m
)
{
void
init_ex20
(
py
::
module
&
m
)
{
...
@@ -68,4 +74,5 @@ void init_ex20(py::module &m) {
...
@@ -68,4 +74,5 @@ void init_ex20(py::module &m) {
m
.
def
(
"create_rec_simple"
,
&
create_recarray
<
Struct
>
);
m
.
def
(
"create_rec_simple"
,
&
create_recarray
<
Struct
>
);
m
.
def
(
"create_rec_packed"
,
&
create_recarray
<
PackedStruct
>
);
m
.
def
(
"create_rec_packed"
,
&
create_recarray
<
PackedStruct
>
);
m
.
def
(
"create_rec_nested"
,
&
create_nested
);
m
.
def
(
"create_rec_nested"
,
&
create_nested
);
m
.
def
(
"print_format_descriptors"
,
&
print_format_descriptors
);
}
}
example/example20.py
View file @
bdc99020
...
@@ -2,12 +2,16 @@
...
@@ -2,12 +2,16 @@
from
__future__
import
print_function
from
__future__
import
print_function
import
numpy
as
np
import
numpy
as
np
from
example
import
create_rec_simple
,
create_rec_packed
,
create_rec_nested
from
example
import
(
create_rec_simple
,
create_rec_packed
,
create_rec_nested
,
print_format_descriptors
)
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
))
print_format_descriptors
()
simple_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
]})
...
...
example/example20.ref
View file @
bdc99020
T{?:x:xxxI:y:f:z:}
T{?:x:=I:y:f:z:}
T{T{?:x:xxxI:y:f:z:}:a:T{?:x:=I:y:f:z:}:b:}
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