Skip to main content

Module array_protocol

Module array_protocol 

Source
Expand description

NumPy array protocol (__array__ and __array_interface__) support.

The NumPy array protocol enables Python objects to be converted to NumPy arrays via two mechanisms:

  • __array__(dtype=None) — a method that returns a numpy.ndarray.
  • __array_interface__ — a property returning a Python dict describing the underlying buffer (shape, dtype string, raw pointer, etc.).

The array interface dictionary format follows: https://numpy.org/doc/stable/reference/arrays.interface.html

Structs§

ArrayInterfaceDict
Data for the __array_interface__ protocol dictionary.
NdArrayWrapper
A concrete array type implementing the NumPy __array__ and __array_interface__ protocols.

Enums§

ArrayProtocolError
Errors produced by the array-protocol layer.

Traits§

ArrayProtocol
Mixin trait for types that support the NumPy array interface protocol.

Functions§

parse_typestr
Parse a NumPy type-string into (kind_char, byte_count).
register_array_protocol_module
Register array-protocol classes into a PyO3 module.