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
e45b2904
Commit
e45b2904
authored
Jan 17, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
numpy.h: fixed a leak, added some comments to buffer_info
parent
d33361a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
include/pybind11/common.h
+7
-6
include/pybind11/numpy.h
+5
-3
No files found.
include/pybind11/common.h
View file @
e45b2904
...
...
@@ -143,12 +143,13 @@ PYBIND11_DECL_FMT(float, "f"); PYBIND11_DECL_FMT(double, "d"); PYBIND11_DECL
/// Information record describing a Python buffer object
struct
buffer_info
{
void
*
ptr
;
size_t
itemsize
,
size
;
std
::
string
format
;
// for dense contents, this should be set to format_descriptor<T>::value
int
ndim
;
std
::
vector
<
size_t
>
shape
;
std
::
vector
<
size_t
>
strides
;
void
*
ptr
;
// Pointer to the underlying storage
size_t
itemsize
;
// Size of individual items in bytes
size_t
size
;
// Total number of entries
std
::
string
format
;
// For homogeneous buffers, this should be set to format_descriptor<T>::value
int
ndim
;
// Number of dimensions
std
::
vector
<
size_t
>
shape
;
// Shape of the tensor (1 entry per dimension)
std
::
vector
<
size_t
>
strides
;
// Number of entries between adjacent entries (for each per dimension)
buffer_info
(
void
*
ptr
,
size_t
itemsize
,
const
std
::
string
&
format
,
int
ndim
,
const
std
::
vector
<
size_t
>
&
shape
,
const
std
::
vector
<
size_t
>
&
strides
)
...
...
include/pybind11/numpy.h
View file @
e45b2904
...
...
@@ -128,9 +128,11 @@ public:
return
nullptr
;
API
&
api
=
lookup_api
();
PyObject
*
descr
=
api
.
PyArray_DescrFromType_
(
npy_format_descriptor
<
T
>::
value
);
return
api
.
PyArray_FromAny_
(
ptr
,
descr
,
0
,
0
,
API
::
NPY_C_CONTIGUOUS_
|
API
::
NPY_ENSURE_ARRAY_
|
API
::
NPY_ARRAY_FORCECAST_
,
nullptr
);
PyObject
*
result
=
api
.
PyArray_FromAny_
(
ptr
,
descr
,
0
,
0
,
API
::
NPY_C_CONTIGUOUS_
|
API
::
NPY_ENSURE_ARRAY_
|
API
::
NPY_ARRAY_FORCECAST_
,
nullptr
);
Py_DECREF
(
ptr
);
return
result
;
}
};
...
...
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