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
ef5a3804
Commit
ef5a3804
authored
Oct 22, 2016
by
Ivan Smirnov
Committed by
Wenzel Jakob
Oct 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few dtype method docstrings
parent
f70cc112
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletions
+5
-1
include/pybind11/numpy.h
+5
-1
No files found.
include/pybind11/numpy.h
View file @
ef5a3804
...
@@ -185,26 +185,30 @@ public:
...
@@ -185,26 +185,30 @@ public:
m_ptr
=
from_args
(
args
).
release
().
ptr
();
m_ptr
=
from_args
(
args
).
release
().
ptr
();
}
}
/// This is essentially the same as calling numpy.dtype(args) in Python.
static
dtype
from_args
(
object
args
)
{
static
dtype
from_args
(
object
args
)
{
// This is essentially the same as calling np.dtype() constructor in Python
PyObject
*
ptr
=
nullptr
;
PyObject
*
ptr
=
nullptr
;
if
(
!
detail
::
npy_api
::
get
().
PyArray_DescrConverter_
(
args
.
release
().
ptr
(),
&
ptr
)
||
!
ptr
)
if
(
!
detail
::
npy_api
::
get
().
PyArray_DescrConverter_
(
args
.
release
().
ptr
(),
&
ptr
)
||
!
ptr
)
pybind11_fail
(
"NumPy: failed to create structured dtype"
);
pybind11_fail
(
"NumPy: failed to create structured dtype"
);
return
object
(
ptr
,
false
);
return
object
(
ptr
,
false
);
}
}
/// Return dtype associated with a C++ type.
template
<
typename
T
>
static
dtype
of
()
{
template
<
typename
T
>
static
dtype
of
()
{
return
detail
::
npy_format_descriptor
<
typename
std
::
remove_cv
<
T
>::
type
>::
dtype
();
return
detail
::
npy_format_descriptor
<
typename
std
::
remove_cv
<
T
>::
type
>::
dtype
();
}
}
/// Size of the data type in bytes.
size_t
itemsize
()
const
{
size_t
itemsize
()
const
{
return
(
size_t
)
PyArrayDescr_GET_
(
m_ptr
,
elsize
);
return
(
size_t
)
PyArrayDescr_GET_
(
m_ptr
,
elsize
);
}
}
/// Returns true for structured data types.
bool
has_fields
()
const
{
bool
has_fields
()
const
{
return
PyArrayDescr_GET_
(
m_ptr
,
names
)
!=
nullptr
;
return
PyArrayDescr_GET_
(
m_ptr
,
names
)
!=
nullptr
;
}
}
/// Single-character type code.
char
kind
()
const
{
char
kind
()
const
{
return
PyArrayDescr_GET_
(
m_ptr
,
kind
);
return
PyArrayDescr_GET_
(
m_ptr
,
kind
);
}
}
...
...
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