pyarray

template<class T, layout_type L>
class pyarray : public xt::pycontainer<pyarray<T, L>>, public xcontainer_semantic<pyarray<T, L>>

Multidimensional container providing the xtensor container semantics to a numpy array.

pyarray is similar to the xarray container in that it has a dynamic dimensionality. Reshapes of a pyarray container are reflected in the underlying numpy array.

See also

pytensor

Template Parameters:
  • T – The type of the element stored in the pyarray.

  • L – Static layout of the pyarray

Constructors

inline pyarray(const value_type &t)

Allocates a pyarray with nested initializer lists.

inline explicit pyarray(const shape_type &shape, layout_type l = layout_type::row_major)

Allocates an uninitialized pyarray with the specified shape and layout.

Parameters:
  • shape – the shape of the pyarray

  • l – the layout of the pyarray

inline explicit pyarray(const shape_type &shape, const_reference value, layout_type l = layout_type::row_major)

Allocates a pyarray with the specified shape and layout.

Elements are initialized to the specified value.

Parameters:
  • shape – the shape of the pyarray

  • value – the value of the elements

  • l – the layout of the pyarray

inline explicit pyarray(const shape_type &shape, const strides_type &strides, const_reference value)

Allocates an uninitialized pyarray with the specified shape and strides.

Elements are initialized to the specified value.

Parameters:
  • shape – the shape of the pyarray

  • strides – the strides of the pyarray

  • value – the value of the elements

inline explicit pyarray(const shape_type &shape, const strides_type &strides)

Allocates an uninitialized pyarray with the specified shape and strides.

Parameters:
  • shape – the shape of the pyarray

  • strides – the strides of the pyarray

template<class S>
inline pyarray<T, L> from_shape(S &&shape)

Allocates and returns an pyarray with the specified shape.

Parameters:

shape – the shape of the pyarray

Copy semantic

inline pyarray(const self_type &rhs)

The copy constructor.

inline self_type &operator=(const self_type &rhs)

The assignment operator.

Extended copy semantic

template<class E>
inline pyarray(const xexpression<E> &e)

The extended copy constructor.

template<class E>
inline auto operator=(const xexpression<E> &e) -> self_type&

The extended assignment operator.