Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
array Class Reference

#include <numpy.h>

Inheritance diagram for array:
Inheritance graph
[legend]

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_ }
 
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())
 
object base () const
 Base object. More...
 
template<typename... Ix>
const void * data (Ix... index) const
 
pybind11::dtype dtype () const
 Array descriptor (dtype) More...
 
int flags () const
 Return the NumPy array flags. More...
 
template<typename... Ix>
ssize_t index_at (Ix... index) const
 
ssize_t itemsize () const
 Byte size of a single element. More...
 
template<typename... Ix>
void * mutable_data (Ix... index)
 
template<typename T , ssize_t Dims = -1>
detail::unchecked_mutable_reference< T, Dimsmutable_unchecked () &
 
ssize_t nbytes () const
 Total number of bytes. More...
 
ssize_t ndim () const
 Number of dimensions. More...
 
template<typename... Ix>
ssize_t offset_at (Ix... index) const
 
ssize_t offset_at () const
 
bool owndata () const
 If set, the array owns the data (will be freed when the array is deleted) More...
 
array reshape (ShapeContainer new_shape)
 Optional order parameter omitted, to be added as needed. More...
 
void resize (ShapeContainer new_shape, bool refcheck=true)
 
const ssize_tshape () const
 Dimensions of the array. More...
 
ssize_t shape (ssize_t dim) const
 Dimension along a given axis. More...
 
ssize_t size () const
 Total number of elements. More...
 
array squeeze ()
 Return a new view with all of the dimensions of length 1 removed. More...
 
const ssize_tstrides () const
 Strides of the array. More...
 
ssize_t strides (ssize_t dim) const
 Stride along a given axis. More...
 
template<typename T , ssize_t Dims = -1>
detail::unchecked_reference< T, Dimsunchecked () const &
 
array view (const std::string &dtype)
 
bool writeable () const
 If set, the array is writeable (otherwise the buffer is read-only) More...
 
- Public Member Functions inherited from buffer
buffer_info request (bool writable=false) const
 
- Public Member Functions inherited from object
template<typename T >
T cast () const &
 
template<typename T >
T cast () &&
 
template<typename T >
T cast () const &
 
template<typename T >
T cast () &&
 
template<>
void cast () const &
 
template<>
void cast () &&
 
 object ()=default
 
 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 (handle h, borrowed_t)
 
 object (handle h, stolen_t)
 
objectoperator= (const object &other)
 
objectoperator= (object &&other) noexcept
 
 PYBIND11_DEPRECATED ("Use reinterpret_borrow<object>() or reinterpret_steal<object>()") object(handle h
 
handle release ()
 
 ~object ()
 Destructor; automatically calls handle::dec_ref() More...
 
- Public Member Functions inherited from handle
template<typename T >
T cast () const
 
template<>
void cast () const
 
bool check () const
 
const handledec_ref () 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)
 
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...
 
const handleinc_ref () const &
 
 operator bool () const
 Return true when the handle wraps a valid Python object. More...
 
bool operator!= (const handle &h) const
 
bool operator== (const handle &h) const
 
PyObject * ptr () const
 Return the underlying PyObject * pointer. More...
 
PyObject *& ptr ()
 

Static Public Member Functions

static array ensure (handle h, int ExtraFlags=0)
 
- Static Public Member Functions inherited from handle
static std::size_t inc_ref_counter ()
 

Protected Member Functions

template<typename... Ix>
ssize_t byte_offset (Ix... index) 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 check_writeable () const
 
void fail_dim_check (ssize_t dim, const std::string &msg) 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...
 

Friends

template<typename , typename >
struct detail::npy_format_descriptor
 

Additional Inherited Members

- Public Attributes inherited from object
bool is_borrowed: handle(h) { if (is_borrowed) { inc_ref()
 
- Protected Attributes inherited from handle
PyObject * m_ptr = nullptr
 

Detailed Description

Definition at line 680 of file numpy.h.

Member Typedef Documentation

◆ ShapeContainer

using array::ShapeContainer = detail::any_container<ssize_t>

Definition at line 692 of file numpy.h.

◆ StridesContainer

using array::StridesContainer = detail::any_container<ssize_t>

Definition at line 693 of file numpy.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
c_style 
f_style 
forcecast 

Definition at line 684 of file numpy.h.

Constructor & Destructor Documentation

◆ array() [1/8]

array::array ( )
inline

Definition at line 690 of file numpy.h.

◆ array() [2/8]

array::array ( const pybind11::dtype &  dt,
ShapeContainer  shape,
StridesContainer  strides,
const void *  ptr = nullptr,
handle  base = handle() 
)
inline

Definition at line 696 of file numpy.h.

◆ array() [3/8]

array::array ( const pybind11::dtype &  dt,
ShapeContainer  shape,
const void *  ptr = nullptr,
handle  base = handle() 
)
inline

Definition at line 749 of file numpy.h.

◆ array() [4/8]

template<typename T , typename = detail::enable_if_t<std::is_integral<T>::value && !std::is_same<bool, T>::value>>
array::array ( const pybind11::dtype &  dt,
T  count,
const void *  ptr = nullptr,
handle  base = handle() 
)
inline

Definition at line 758 of file numpy.h.

◆ array() [5/8]

template<typename T >
array::array ( ShapeContainer  shape,
StridesContainer  strides,
const T ptr,
handle  base = handle() 
)
inline

Definition at line 762 of file numpy.h.

◆ array() [6/8]

template<typename T >
array::array ( ShapeContainer  shape,
const T ptr,
handle  base = handle() 
)
inline

Definition at line 766 of file numpy.h.

◆ array() [7/8]

template<typename T >
array::array ( ssize_t  count,
const T ptr,
handle  base = handle() 
)
inlineexplicit

Definition at line 770 of file numpy.h.

◆ array() [8/8]

array::array ( const buffer_info info,
handle  base = handle() 
)
inlineexplicit

Definition at line 773 of file numpy.h.

Member Function Documentation

◆ base()

object array::base ( ) const
inline

Base object.

Definition at line 798 of file numpy.h.

◆ byte_offset()

template<typename... Ix>
ssize_t array::byte_offset ( Ix...  index) const
inlineprotected

Definition at line 976 of file numpy.h.

◆ check_dimensions()

template<typename... Ix>
void array::check_dimensions ( Ix...  index) const
inlineprotected

Definition at line 988 of file numpy.h.

◆ check_dimensions_impl() [1/2]

void array::check_dimensions_impl ( ssize_t  ,
const ssize_t  
) const
inlineprotected

Definition at line 992 of file numpy.h.

◆ check_dimensions_impl() [2/2]

template<typename... Ix>
void array::check_dimensions_impl ( ssize_t  axis,
const ssize_t shape,
ssize_t  i,
Ix...  index 
) const
inlineprotected

Definition at line 995 of file numpy.h.

◆ check_writeable()

void array::check_writeable ( ) const
inlineprotected

Definition at line 981 of file numpy.h.

◆ data()

template<typename... Ix>
const void* array::data ( Ix...  index) const
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 838 of file numpy.h.

◆ dtype()

pybind11::dtype array::dtype ( ) const
inline

Array descriptor (dtype)

Definition at line 777 of file numpy.h.

◆ ensure()

static array array::ensure ( handle  h,
int  ExtraFlags = 0 
)
inlinestatic

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 958 of file numpy.h.

◆ fail_dim_check()

void array::fail_dim_check ( ssize_t  dim,
const std::string &  msg 
) const
inlineprotected

Definition at line 970 of file numpy.h.

◆ flags()

int array::flags ( ) const
inline

Return the NumPy array flags.

Definition at line 823 of file numpy.h.

◆ index_at()

template<typename... Ix>
ssize_t array::index_at ( Ix...  index) const
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 866 of file numpy.h.

◆ itemsize()

ssize_t array::itemsize ( ) const
inline

Byte size of a single element.

Definition at line 787 of file numpy.h.

◆ mutable_data()

template<typename... Ix>
void* array::mutable_data ( Ix...  index)
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 846 of file numpy.h.

◆ mutable_unchecked()

template<typename T , ssize_t Dims = -1>
detail::unchecked_mutable_reference<T, Dims> array::mutable_unchecked ( ) &
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 877 of file numpy.h.

◆ nbytes()

ssize_t array::nbytes ( ) const
inline

Total number of bytes.

Definition at line 792 of file numpy.h.

◆ ndim()

ssize_t array::ndim ( ) const
inline

Number of dimensions.

Definition at line 795 of file numpy.h.

◆ offset_at() [1/2]

template<typename... Ix>
ssize_t array::offset_at ( Ix...  index) const
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 854 of file numpy.h.

◆ offset_at() [2/2]

ssize_t array::offset_at ( ) const
inline

Definition at line 861 of file numpy.h.

◆ owndata()

bool array::owndata ( ) const
inline

If set, the array owns the data (will be freed when the array is deleted)

Definition at line 831 of file numpy.h.

◆ raw_array()

static PyObject* array::raw_array ( PyObject *  ptr,
int  ExtraFlags = 0 
)
inlinestaticprotected

Create array from any object – always returns a new reference.

Definition at line 1005 of file numpy.h.

◆ reshape()

array array::reshape ( ShapeContainer  new_shape)
inline

Optional order parameter omitted, to be added as needed.

Definition at line 930 of file numpy.h.

◆ resize()

void array::resize ( ShapeContainer  new_shape,
bool  refcheck = true 
)
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 913 of file numpy.h.

◆ shape() [1/2]

const ssize_t* array::shape ( ) const
inline

Dimensions of the array.

Definition at line 801 of file numpy.h.

◆ shape() [2/2]

ssize_t array::shape ( ssize_t  dim) const
inline

Dimension along a given axis.

Definition at line 804 of file numpy.h.

◆ size()

ssize_t array::size ( ) const
inline

Total number of elements.

Definition at line 782 of file numpy.h.

◆ squeeze()

array array::squeeze ( )
inline

Return a new view with all of the dimensions of length 1 removed.

Definition at line 905 of file numpy.h.

◆ strides() [1/2]

const ssize_t* array::strides ( ) const
inline

Strides of the array.

Definition at line 812 of file numpy.h.

◆ strides() [2/2]

ssize_t array::strides ( ssize_t  dim) const
inline

Stride along a given axis.

Definition at line 815 of file numpy.h.

◆ unchecked()

template<typename T , ssize_t Dims = -1>
detail::unchecked_reference<T, Dims> array::unchecked ( ) const &
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 895 of file numpy.h.

◆ view()

array array::view ( const std::string &  dtype)
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 946 of file numpy.h.

◆ writeable()

bool array::writeable ( ) const
inline

If set, the array is writeable (otherwise the buffer is read-only)

Definition at line 826 of file numpy.h.

Friends And Related Function Documentation

◆ detail::npy_format_descriptor

template<typename , typename >
friend struct detail::npy_format_descriptor
friend

Definition at line 968 of file numpy.h.


The documentation for this class was generated from the following file:


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:40:59