From ef5a38044c515a744b4e8a9f7f697f945f558efe Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Sat, 22 Oct 2016 10:51:04 +0100 Subject: [PATCH] A few dtype method docstrings --- include/pybind11/numpy.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index 588cc1519..b35426460 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -185,26 +185,30 @@ public: 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) { - // This is essentially the same as calling np.dtype() constructor in Python PyObject *ptr = nullptr; if (!detail::npy_api::get().PyArray_DescrConverter_(args.release().ptr(), &ptr) || !ptr) pybind11_fail("NumPy: failed to create structured dtype"); return object(ptr, false); } + /// Return dtype associated with a C++ type. template static dtype of() { return detail::npy_format_descriptor::type>::dtype(); } + /// Size of the data type in bytes. size_t itemsize() const { return (size_t) PyArrayDescr_GET_(m_ptr, elsize); } + /// Returns true for structured data types. bool has_fields() const { return PyArrayDescr_GET_(m_ptr, names) != nullptr; } + /// Single-character type code. char kind() const { return PyArrayDescr_GET_(m_ptr, kind); }