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
2e1565e4
Commit
2e1565e4
authored
Jun 19, 2016
by
Ivan Smirnov
Browse files
Add empty recarray test, check for calloc fail
parent
f10c84eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
example/example20.py
example/example20.py
+5
-0
include/pybind11/numpy.h
include/pybind11/numpy.h
+2
-0
No files found.
example/example20.py
View file @
2e1565e4
...
@@ -17,3 +17,8 @@ arr = create_rec_simple(3)
...
@@ -17,3 +17,8 @@ arr = create_rec_simple(3)
assert
arr
.
dtype
==
dtype
assert
arr
.
dtype
==
dtype
check_eq
(
arr
,
[(
False
,
0
,
0.0
),
(
True
,
1
,
1.5
),
(
False
,
2
,
3.0
)],
dtype
)
check_eq
(
arr
,
[(
False
,
0
,
0.0
),
(
True
,
1
,
1.5
),
(
False
,
2
,
3.0
)],
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
)],
base_dtype
)
arr
=
create_rec_simple
(
0
)
assert
arr
.
dtype
==
dtype
check_eq
(
arr
,
[],
dtype
)
check_eq
(
arr
,
[],
base_dtype
)
include/pybind11/numpy.h
View file @
2e1565e4
...
@@ -116,6 +116,8 @@ public:
...
@@ -116,6 +116,8 @@ public:
auto
buf_info
=
info
;
auto
buf_info
=
info
;
if
(
!
buf_info
.
ptr
)
if
(
!
buf_info
.
ptr
)
buf_info
.
ptr
=
std
::
calloc
(
info
.
size
,
info
.
itemsize
);
buf_info
.
ptr
=
std
::
calloc
(
info
.
size
,
info
.
itemsize
);
if
(
!
buf_info
.
ptr
)
pybind11_fail
(
"NumPy: failed to allocate memory for buffer"
);
auto
view
=
py
::
memoryview
(
buf_info
);
auto
view
=
py
::
memoryview
(
buf_info
);
API
&
api
=
lookup_api
();
API
&
api
=
lookup_api
();
...
...
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