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
10af58fa
Commit
10af58fa
authored
Jul 25, 2016
by
Ivan Smirnov
Browse files
Add a few more dtype tests
parent
611e6146
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
example/example-numpy-dtypes.cpp
example/example-numpy-dtypes.cpp
+8
-2
example/example-numpy-dtypes.py
example/example-numpy-dtypes.py
+4
-1
No files found.
example/example-numpy-dtypes.cpp
View file @
10af58fa
...
@@ -218,8 +218,14 @@ py::list test_dtype_ctors() {
...
@@ -218,8 +218,14 @@ py::list test_dtype_ctors() {
return
list
;
return
list
;
}
}
void
test_dtype_methods
()
{
py
::
list
test_dtype_methods
()
{
py
::
list
list
;
auto
dt1
=
py
::
dtype
::
of
<
int32_t
>
();
auto
dt2
=
py
::
dtype
::
of
<
SimpleStruct
>
();
list
.
append
(
dt1
);
list
.
append
(
dt2
);
list
.
append
(
py
::
bool_
(
dt1
.
has_fields
()));
list
.
append
(
py
::
bool_
(
dt2
.
has_fields
()));
list
.
append
(
py
::
int_
(
dt1
.
itemsize
()));
list
.
append
(
py
::
int_
(
dt2
.
itemsize
()));
return
list
;
}
}
void
init_ex_numpy_dtypes
(
py
::
module
&
m
)
{
void
init_ex_numpy_dtypes
(
py
::
module
&
m
)
{
...
...
example/example-numpy-dtypes.py
View file @
10af58fa
...
@@ -7,7 +7,7 @@ from example import (
...
@@ -7,7 +7,7 @@ from example import (
create_rec_simple
,
create_rec_packed
,
create_rec_nested
,
print_format_descriptors
,
create_rec_simple
,
create_rec_packed
,
create_rec_nested
,
print_format_descriptors
,
print_rec_simple
,
print_rec_packed
,
print_rec_nested
,
print_dtypes
,
get_format_unbound
,
print_rec_simple
,
print_rec_packed
,
print_rec_nested
,
print_dtypes
,
get_format_unbound
,
create_rec_partial
,
create_rec_partial_nested
,
create_string_array
,
print_string_array
,
create_rec_partial
,
create_rec_partial_nested
,
create_string_array
,
print_string_array
,
test_array_ctors
,
test_dtype_ctors
test_array_ctors
,
test_dtype_ctors
,
test_dtype_methods
)
)
...
@@ -92,3 +92,6 @@ d1 = np.dtype({'names': ['a', 'b'], 'formats': ['int32', 'float64'],
...
@@ -92,3 +92,6 @@ d1 = np.dtype({'names': ['a', 'b'], 'formats': ['int32', 'float64'],
d2
=
np
.
dtype
([(
'a'
,
'i4'
),
(
'b'
,
'f4'
)])
d2
=
np
.
dtype
([(
'a'
,
'i4'
),
(
'b'
,
'f4'
)])
assert
test_dtype_ctors
()
==
[
np
.
dtype
(
'int32'
),
np
.
dtype
(
'float64'
),
assert
test_dtype_ctors
()
==
[
np
.
dtype
(
'int32'
),
np
.
dtype
(
'float64'
),
np
.
dtype
(
'bool'
),
d1
,
d1
,
np
.
dtype
(
'uint32'
),
d2
]
np
.
dtype
(
'bool'
),
d1
,
d1
,
np
.
dtype
(
'uint32'
),
d2
]
assert
test_dtype_methods
()
==
[
np
.
dtype
(
'int32'
),
simple_dtype
,
False
,
True
,
np
.
dtype
(
'int32'
).
itemsize
,
simple_dtype
.
itemsize
]
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