Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
bdc99020
Commit
bdc99020
authored
Jun 19, 2016
by
Ivan Smirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add explicit test for recarray format descriptors
parent
7f913aec
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletions
+15
-1
example/example20.cpp
+7
-0
example/example20.py
+5
-1
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