#include </builds/ipbus/ipbus-software/uhal/python/pybind11-python2/include/pybind11/numpy.h>
Public Types | |
enum | { c_style = detail::npy_api::NPY_ARRAY_C_CONTIGUOUS_ , f_style = detail::npy_api::NPY_ARRAY_F_CONTIGUOUS_ , forcecast = detail::npy_api::NPY_ARRAY_FORCECAST_ } |
enum | { c_style = detail::npy_api::NPY_ARRAY_C_CONTIGUOUS_ , f_style = detail::npy_api::NPY_ARRAY_F_CONTIGUOUS_ , forcecast = detail::npy_api::NPY_ARRAY_FORCECAST_ } |
using | ShapeContainer = detail::any_container< ssize_t > |
using | StridesContainer = detail::any_container< ssize_t > |
using | ShapeContainer = detail::any_container< ssize_t > |
using | StridesContainer = detail::any_container< ssize_t > |
Public Member Functions | |
array () | |
array (const pybind11::dtype &dt, ShapeContainer shape, StridesContainer strides, const void *ptr=nullptr, handle base=handle()) | |
array (const pybind11::dtype &dt, ShapeContainer shape, const void *ptr=nullptr, handle base=handle()) | |
template<typename T , typename = detail::enable_if_t<std::is_integral<T>::value && !std::is_same<bool, T>::value>> | |
array (const pybind11::dtype &dt, T count, const void *ptr=nullptr, handle base=handle()) | |
template<typename T > | |
array (ShapeContainer shape, StridesContainer strides, const T *ptr, handle base=handle()) | |
template<typename T > | |
array (ShapeContainer shape, const T *ptr, handle base=handle()) | |
template<typename T > | |
array (ssize_t count, const T *ptr, handle base=handle()) | |
array (const buffer_info &info, handle base=handle()) | |
pybind11::dtype | dtype () const |
Array descriptor (dtype) More... | |
ssize_t | size () const |
Total number of elements. More... | |
ssize_t | itemsize () const |
Byte size of a single element. More... | |
ssize_t | nbytes () const |
Total number of bytes. More... | |
ssize_t | ndim () const |
Number of dimensions. More... | |
object | base () const |
Base object. More... | |
const ssize_t * | shape () const |
Dimensions of the array. More... | |
ssize_t | shape (ssize_t dim) const |
Dimension along a given axis. More... | |
const ssize_t * | strides () const |
Strides of the array. More... | |
ssize_t | strides (ssize_t dim) const |
Stride along a given axis. More... | |
int | flags () const |
Return the NumPy array flags. More... | |
bool | writeable () const |
If set, the array is writeable (otherwise the buffer is read-only) More... | |
bool | owndata () const |
If set, the array owns the data (will be freed when the array is deleted) More... | |
template<typename... Ix> | |
const void * | data (Ix... index) const |
Pointer to the contained data. More... | |
template<typename... Ix> | |
void * | mutable_data (Ix... index) |
Mutable pointer to the contained data. More... | |
template<typename... Ix> | |
ssize_t | offset_at (Ix... index) const |
Byte offset from beginning of the array to a given index (full or partial). More... | |
ssize_t | offset_at () const |
template<typename... Ix> | |
ssize_t | index_at (Ix... index) const |
Item count from beginning of the array to a given index (full or partial). More... | |
template<typename T , ssize_t Dims = -1> | |
detail::unchecked_mutable_reference< T, Dims > | mutable_unchecked () & |
Returns a proxy object that provides access to the array's data without bounds or dimensionality checking. More... | |
template<typename T , ssize_t Dims = -1> | |
detail::unchecked_reference< T, Dims > | unchecked () const & |
Returns a proxy object that provides const access to the array's data without bounds or dimensionality checking. More... | |
array | squeeze () |
Return a new view with all of the dimensions of length 1 removed. More... | |
void | resize (ShapeContainer new_shape, bool refcheck=true) |
Resize array to given shape If refcheck is true and more that one reference exist to this array then resize will succeed only if it makes a reshape, i.e. More... | |
array | reshape (ShapeContainer new_shape) |
Optional order parameter omitted, to be added as needed. More... | |
array | view (const std::string &dtype) |
Create a view of an array in a different data type. More... | |
array () | |
array (const pybind11::dtype &dt, ShapeContainer shape, StridesContainer strides, const void *ptr=nullptr, handle base=handle()) | |
array (const pybind11::dtype &dt, ShapeContainer shape, const void *ptr=nullptr, handle base=handle()) | |
template<typename T , typename = detail::enable_if_t<std::is_integral<T>::value && !std::is_same<bool, T>::value>> | |
array (const pybind11::dtype &dt, T count, const void *ptr=nullptr, handle base=handle()) | |
template<typename T > | |
array (ShapeContainer shape, StridesContainer strides, const T *ptr, handle base=handle()) | |
template<typename T > | |
array (ShapeContainer shape, const T *ptr, handle base=handle()) | |
template<typename T > | |
array (ssize_t count, const T *ptr, handle base=handle()) | |
array (const buffer_info &info, handle base=handle()) | |
pybind11::dtype | dtype () const |
Array descriptor (dtype) More... | |
ssize_t | size () const |
Total number of elements. More... | |
ssize_t | itemsize () const |
Byte size of a single element. More... | |
ssize_t | nbytes () const |
Total number of bytes. More... | |
ssize_t | ndim () const |
Number of dimensions. More... | |
object | base () const |
Base object. More... | |
const ssize_t * | shape () const |
Dimensions of the array. More... | |
ssize_t | shape (ssize_t dim) const |
Dimension along a given axis. More... | |
const ssize_t * | strides () const |
Strides of the array. More... | |
ssize_t | strides (ssize_t dim) const |
Stride along a given axis. More... | |
int | flags () const |
Return the NumPy array flags. More... | |
bool | writeable () const |
If set, the array is writeable (otherwise the buffer is read-only) More... | |
bool | owndata () const |
If set, the array owns the data (will be freed when the array is deleted) More... | |
template<typename... Ix> | |
const void * | data (Ix... index) const |
Pointer to the contained data. More... | |
template<typename... Ix> | |
void * | mutable_data (Ix... index) |
Mutable pointer to the contained data. More... | |
template<typename... Ix> | |
ssize_t | offset_at (Ix... index) const |
Byte offset from beginning of the array to a given index (full or partial). More... | |
ssize_t | offset_at () const |
template<typename... Ix> | |
ssize_t | index_at (Ix... index) const |
Item count from beginning of the array to a given index (full or partial). More... | |
template<typename T , ssize_t Dims = -1> | |
detail::unchecked_mutable_reference< T, Dims > | mutable_unchecked () & |
Returns a proxy object that provides access to the array's data without bounds or dimensionality checking. More... | |
template<typename T , ssize_t Dims = -1> | |
detail::unchecked_reference< T, Dims > | unchecked () const & |
Returns a proxy object that provides const access to the array's data without bounds or dimensionality checking. More... | |
array | squeeze () |
Return a new view with all of the dimensions of length 1 removed. More... | |
void | resize (ShapeContainer new_shape, bool refcheck=true) |
Resize array to given shape If refcheck is true and more that one reference exist to this array then resize will succeed only if it makes a reshape, i.e. More... | |
array | reshape (ShapeContainer new_shape) |
Optional order parameter omitted, to be added as needed. More... | |
array | view (const std::string &dtype) |
Create a view of an array in a different data type. More... | |
![]() | |
buffer_info | request (bool writable=false) const |
buffer_info | request (bool writable=false) const |
![]() | |
object ()=default | |
PYBIND11_DEPRECATED ("Use reinterpret_borrow<object>() or reinterpret_steal<object>()") object(handle h | |
object (const object &o) | |
Copy constructor; always increases the reference count. More... | |
object (object &&other) noexcept | |
Move constructor; steals the object from other and preserves its reference count. More... | |
~object () | |
Destructor; automatically calls handle::dec_ref() More... | |
handle | release () |
\rst Resets the internal pointer to nullptr without decreasing the object's reference count. More... | |
object & | operator= (const object &other) |
object & | operator= (object &&other) noexcept |
template<typename T > | |
T | cast () const & |
template<typename T > | |
T | cast () && |
object (handle h, borrowed_t) | |
object (handle h, stolen_t) | |
object ()=default | |
PYBIND11_DEPRECATED ("Use reinterpret_borrow<object>() or reinterpret_steal<object>()") object(handle h | |
object (const object &o) | |
Copy constructor; always increases the reference count. More... | |
object (object &&other) noexcept | |
Move constructor; steals the object from other and preserves its reference count. More... | |
~object () | |
Destructor; automatically calls handle::dec_ref() More... | |
handle | release () |
\rst Resets the internal pointer to nullptr without decreasing the object's reference count. More... | |
object & | operator= (const object &other) |
object & | operator= (object &&other) noexcept |
template<typename T > | |
T | cast () const & |
template<typename T > | |
T | cast () && |
object (handle h, borrowed_t) | |
object (handle h, stolen_t) | |
template<typename T > | |
T | cast () const & |
template<typename T > | |
T | cast () && |
template<> | |
void | cast () const & |
template<> | |
void | cast () && |
![]() | |
handle ()=default | |
The default constructor creates a handle with a nullptr -valued pointer. More... | |
handle (PyObject *ptr) | |
Creates a handle from the given raw Python object pointer. More... | |
PyObject * | ptr () const |
Return the underlying PyObject * pointer. More... | |
PyObject *& | ptr () |
const handle & | inc_ref () const & |
\rst Manually increase the reference count of the Python object. More... | |
const handle & | dec_ref () const & |
\rst Manually decrease the reference count of the Python object. More... | |
template<typename T > | |
T | cast () const |
\rst Attempt to cast the Python object into the given C++ type. More... | |
operator bool () const | |
Return true when the handle wraps a valid Python object. More... | |
bool | operator== (const handle &h) const |
\rst Deprecated: Check that the underlying pointers are the same. More... | |
bool | operator!= (const handle &h) const |
bool | check () const |
handle ()=default | |
The default constructor creates a handle with a nullptr -valued pointer. More... | |
template<typename T , detail::enable_if_t< detail::is_pyobj_ptr_or_nullptr_t< T >::value, int > = 0> | |
handle (T ptr) | |
Enable implicit conversion from PyObject * and nullptr . More... | |
template<typename T , detail::enable_if_t< detail::all_of< detail::none_of< std::is_base_of< handle, T >, detail::is_pyobj_ptr_or_nullptr_t< T > >, std::is_convertible< T, PyObject * > >::value, int > = 0> | |
handle (T &obj) | |
Enable implicit conversion through T::operator PyObject *() . More... | |
PyObject * | ptr () const |
Return the underlying PyObject * pointer. More... | |
PyObject *& | ptr () |
const handle & | inc_ref () const & |
\rst Manually increase the reference count of the Python object. More... | |
const handle & | dec_ref () const & |
\rst Manually decrease the reference count of the Python object. More... | |
template<typename T > | |
T | cast () const |
\rst Attempt to cast the Python object into the given C++ type. More... | |
operator bool () const | |
Return true when the handle wraps a valid Python object. More... | |
bool | operator== (const handle &h) const |
\rst Deprecated: Check that the underlying pointers are the same. More... | |
bool | operator!= (const handle &h) const |
bool | check () const |
template<> | |
void | cast () const |
Static Public Member Functions | |
static array | ensure (handle h, int ExtraFlags=0) |
Ensure that the argument is a NumPy array In case of an error, nullptr is returned and the Python error is cleared. More... | |
static array | ensure (handle h, int ExtraFlags=0) |
Ensure that the argument is a NumPy array In case of an error, nullptr is returned and the Python error is cleared. More... | |
![]() | |
static std::size_t | inc_ref_counter () |
Protected Member Functions | |
void | fail_dim_check (ssize_t dim, const std::string &msg) const |
template<typename... Ix> | |
ssize_t | byte_offset (Ix... index) const |
void | check_writeable () const |
template<typename... Ix> | |
void | check_dimensions (Ix... index) const |
void | check_dimensions_impl (ssize_t, const ssize_t *) const |
template<typename... Ix> | |
void | check_dimensions_impl (ssize_t axis, const ssize_t *shape, ssize_t i, Ix... index) const |
void | fail_dim_check (ssize_t dim, const std::string &msg) const |
template<typename... Ix> | |
ssize_t | byte_offset (Ix... index) const |
void | check_writeable () const |
template<typename... Ix> | |
void | check_dimensions (Ix... index) const |
void | check_dimensions_impl (ssize_t, const ssize_t *) const |
template<typename... Ix> | |
void | check_dimensions_impl (ssize_t axis, const ssize_t *shape, ssize_t i, Ix... index) const |
Static Protected Member Functions | |
static PyObject * | raw_array (PyObject *ptr, int ExtraFlags=0) |
Create array from any object – always returns a new reference. More... | |
static PyObject * | raw_array (PyObject *ptr, int ExtraFlags=0) |
Create array from any object – always returns a new reference. More... | |
Friends | |
template<typename , typename > | |
struct | detail::npy_format_descriptor |
template<typename , typename > | |
struct | detail::npy_format_descriptor |
Additional Inherited Members | |
![]() | |
bool | is_borrowed: handle(h) { if (is_borrowed) { inc_ref() |
![]() | |
PyObject * | m_ptr = nullptr |
using array::ShapeContainer = detail::any_container<ssize_t> |
using array::ShapeContainer = detail::any_container<ssize_t> |
using array::StridesContainer = detail::any_container<ssize_t> |
using array::StridesContainer = detail::any_container<ssize_t> |
|
inline |
Definition at line 671 of file numpy.h.
References flags(), handle::m_ptr, ndim(), npy_api::NPY_ARRAY_OWNDATA_, handle::ptr(), pybind11_fail(), shape(), and strides().
|
inline |
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
Definition at line 698 of file numpy.h.
References flags(), handle::m_ptr, ndim(), npy_api::NPY_ARRAY_OWNDATA_, handle::ptr(), pybind11_fail(), shape(), and strides().
|
inline |
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inlineprotected |
Definition at line 951 of file numpy.h.
References check_dimensions(), and strides().
Referenced by array_t< T, ExtraFlags >::at(), array_t< T, ExtraFlags >::mutable_at(), and offset_at().
|
inlineprotected |
Definition at line 978 of file numpy.h.
References check_dimensions(), and strides().
|
inlineprotected |
Definition at line 963 of file numpy.h.
References check_dimensions_impl(), and shape().
Referenced by byte_offset().
|
inlineprotected |
Definition at line 990 of file numpy.h.
References check_dimensions_impl(), and shape().
|
inlineprotected |
Definition at line 970 of file numpy.h.
References check_dimensions_impl(), and shape().
|
inlineprotected |
Definition at line 997 of file numpy.h.
References check_dimensions_impl(), and shape().
Definition at line 967 of file numpy.h.
Referenced by check_dimensions(), and check_dimensions_impl().
|
inlineprotected |
|
inlineprotected |
Definition at line 983 of file numpy.h.
References writeable().
|
inline |
Pointer to the contained data.
If index is not provided, points to the beginning of the buffer. May throw if the index would lead to out of bounds access.
Definition at line 813 of file numpy.h.
References handle::m_ptr, and offset_at().
Referenced by array_t< T, ExtraFlags >::at(), array_t< T, ExtraFlags >::data(), and unchecked().
|
inline |
Pointer to the contained data.
If index is not provided, points to the beginning of the buffer. May throw if the index would lead to out of bounds access.
Definition at line 840 of file numpy.h.
References handle::m_ptr, and offset_at().
|
inline |
Array descriptor (dtype)
Definition at line 752 of file numpy.h.
References handle::m_ptr.
Referenced by type_caster< Type, typename eigen_tensor_helper< Type >::ValidType >::load().
|
inline |
Ensure that the argument is a NumPy array In case of an error, nullptr is returned and the Python error is cleared.
Definition at line 933 of file numpy.h.
References handle::ptr(), and raw_array().
Referenced by type_caster< Type, enable_if_t< is_eigen_dense_plain< Type >::value > >::load(), and type_caster< Type, typename eigen_tensor_helper< Type >::ValidType >::load().
Ensure that the argument is a NumPy array In case of an error, nullptr is returned and the Python error is cleared.
Definition at line 960 of file numpy.h.
References handle::ptr(), and raw_array().
|
inlineprotected |
Definition at line 945 of file numpy.h.
References ndim().
Referenced by array_t< T, ExtraFlags >::at(), array_t< T, ExtraFlags >::mutable_at(), offset_at(), shape(), and strides().
|
inlineprotected |
|
inline |
Return the NumPy array flags.
Definition at line 798 of file numpy.h.
References handle::m_ptr.
Referenced by array().
|
inline |
|
inline |
Item count from beginning of the array to a given index (full or partial).
May throw if the index would lead to out of bounds access.
Definition at line 841 of file numpy.h.
References itemsize(), and offset_at().
|
inline |
Item count from beginning of the array to a given index (full or partial).
May throw if the index would lead to out of bounds access.
Definition at line 868 of file numpy.h.
References itemsize(), and offset_at().
|
inline |
Byte size of a single element.
Definition at line 762 of file numpy.h.
References handle::m_ptr.
Referenced by index_at(), and nbytes().
|
inline |
|
inline |
Mutable pointer to the contained data.
If index is not provided, points to the beginning of the buffer. May throw if the index would lead to out of bounds access. May throw if the array is not writeable.
Definition at line 821 of file numpy.h.
References check_writeable(), handle::m_ptr, and offset_at().
Referenced by array_t< T, ExtraFlags >::mutable_at(), array_t< T, ExtraFlags >::mutable_data(), vectorize_returned_array< Func, Return, Args >::mutable_data(), and mutable_unchecked().
|
inline |
Mutable pointer to the contained data.
If index is not provided, points to the beginning of the buffer. May throw if the index would lead to out of bounds access. May throw if the array is not writeable.
Definition at line 848 of file numpy.h.
References check_writeable(), handle::m_ptr, and offset_at().
|
inline |
Returns a proxy object that provides access to the array's data without bounds or dimensionality checking.
Will throw if the array is missing the writeable
flag. Use with care: the array must not be destroyed or reshaped for the duration of the returned object, and the caller must take care not to access invalid dimensions or dimension indices.
Definition at line 852 of file numpy.h.
References mutable_data(), ndim(), PYBIND11_SILENCE_MSVC_C4127, shape(), and strides().
|
inline |
Returns a proxy object that provides access to the array's data without bounds or dimensionality checking.
Will throw if the array is missing the writeable
flag. Use with care: the array must not be destroyed or reshaped for the duration of the returned object, and the caller must take care not to access invalid dimensions or dimension indices.
Definition at line 879 of file numpy.h.
References mutable_data(), ndim(), shape(), and strides().
|
inline |
|
inline |
|
inline |
Number of dimensions.
Definition at line 770 of file numpy.h.
References handle::m_ptr.
Referenced by array(), array_t< T, ExtraFlags >::at(), EigenProps< Type_ >::conformable(), fail_dim_check(), array_t< T, ExtraFlags >::mutable_at(), mutable_unchecked(), offset_at(), shape(), size(), strides(), and unchecked().
|
inline |
|
inline |
Definition at line 836 of file numpy.h.
Referenced by data(), index_at(), array_t< T, ExtraFlags >::index_at(), and mutable_data().
|
inline |
Byte offset from beginning of the array to a given index (full or partial).
May throw if the index would lead to out of bounds access.
Definition at line 829 of file numpy.h.
References byte_offset(), fail_dim_check(), and ndim().
|
inline |
Byte offset from beginning of the array to a given index (full or partial).
May throw if the index would lead to out of bounds access.
Definition at line 856 of file numpy.h.
References byte_offset(), fail_dim_check(), and ndim().
|
inline |
If set, the array owns the data (will be freed when the array is deleted)
Definition at line 806 of file numpy.h.
References handle::m_ptr.
|
inline |
If set, the array owns the data (will be freed when the array is deleted)
Definition at line 833 of file numpy.h.
References handle::m_ptr.
|
inlinestaticprotected |
Create array from any object – always returns a new reference.
Definition at line 980 of file numpy.h.
References handle::ptr().
Referenced by ensure().
|
inlinestaticprotected |
Create array from any object – always returns a new reference.
Definition at line 1007 of file numpy.h.
References handle::ptr().
|
inline |
Optional order
parameter omitted, to be added as needed.
Definition at line 905 of file numpy.h.
References handle::m_ptr.
|
inline |
Optional order
parameter omitted, to be added as needed.
Definition at line 932 of file numpy.h.
References handle::m_ptr.
|
inline |
Resize array to given shape If refcheck is true and more that one reference exist to this array then resize will succeed only if it makes a reshape, i.e.
original size doesn't change
Definition at line 888 of file numpy.h.
References handle::m_ptr.
|
inline |
Resize array to given shape If refcheck is true and more that one reference exist to this array then resize will succeed only if it makes a reshape, i.e.
original size doesn't change
Definition at line 915 of file numpy.h.
References handle::m_ptr.
|
inline |
Dimensions of the array.
Definition at line 776 of file numpy.h.
References handle::m_ptr.
Referenced by array(), check_dimensions(), check_dimensions_impl(), EigenProps< Type_ >::conformable(), mutable_unchecked(), shape(), size(), and unchecked().
|
inline |
Dimension along a given axis.
Definition at line 779 of file numpy.h.
References fail_dim_check(), ndim(), and shape().
Dimension along a given axis.
Definition at line 806 of file numpy.h.
References fail_dim_check(), ndim(), and shape().
|
inline |
|
inline |
|
inline |
Return a new view with all of the dimensions of length 1 removed.
Definition at line 880 of file numpy.h.
References handle::m_ptr.
|
inline |
Return a new view with all of the dimensions of length 1 removed.
Definition at line 907 of file numpy.h.
References handle::m_ptr.
|
inline |
Strides of the array.
Definition at line 787 of file numpy.h.
References handle::m_ptr.
Referenced by array(), byte_offset(), EigenProps< Type_ >::conformable(), mutable_unchecked(), strides(), and unchecked().
|
inline |
Stride along a given axis.
Definition at line 790 of file numpy.h.
References fail_dim_check(), ndim(), and strides().
Stride along a given axis.
Definition at line 817 of file numpy.h.
References fail_dim_check(), ndim(), and strides().
|
inline |
Returns a proxy object that provides const access to the array's data without bounds or dimensionality checking.
Unlike mutable_unchecked()
, this does not require that the underlying array have the writable
flag. Use with care: the array must not be destroyed or reshaped for the duration of the returned object, and the caller must take care not to access invalid dimensions or dimension indices.
Definition at line 870 of file numpy.h.
References data(), ndim(), PYBIND11_SILENCE_MSVC_C4127, shape(), and strides().
|
inline |
Returns a proxy object that provides const access to the array's data without bounds or dimensionality checking.
Unlike mutable_unchecked()
, this does not require that the underlying array have the writable
flag. Use with care: the array must not be destroyed or reshaped for the duration of the returned object, and the caller must take care not to access invalid dimensions or dimension indices.
|
inline |
Create a view of an array in a different data type.
This function may fundamentally reinterpret the data in the array. It is the responsibility of the caller to ensure that this is safe. Only supports the dtype
argument, the type
argument is omitted, to be added as needed.
Definition at line 921 of file numpy.h.
References dtype::from_args(), handle::m_ptr, handle::ptr(), and object::release().
|
inline |
Create a view of an array in a different data type.
This function may fundamentally reinterpret the data in the array. It is the responsibility of the caller to ensure that this is safe. Only supports the dtype
argument, the type
argument is omitted, to be added as needed.
Definition at line 948 of file numpy.h.
References dtype::from_args(), handle::m_ptr, handle::ptr(), and object::release().
|
inline |
If set, the array is writeable (otherwise the buffer is read-only)
Definition at line 801 of file numpy.h.
References handle::m_ptr.
Referenced by check_writeable().
|
inline |
If set, the array is writeable (otherwise the buffer is read-only)
Definition at line 828 of file numpy.h.
References handle::m_ptr.
|
friend |
|
friend |