arkouda.array_api._typing

This file defines the types for type annotations.

These names aren’t part of the module namespace, but they are used in the annotations in the function signatures. The functions in the module are only valid for inputs that match the given type annotations.

Module Contents

Classes

Array

n-d array object for the array API namespace.

SupportsDLPack

Base class for protocol classes.

Attributes

class arkouda.array_api._typing.Array[source]

n-d array object for the array API namespace.

See the docstring of np.ndarray for more information.

This is a wrapper around numpy.ndarray that restricts the usage to only those things that are required by the array API namespace. Note, attributes on this object that start with a single underscore are not part of the API specification and should only be used internally. This object should not be constructed directly. Rather, use one of the creation functions, such as asarray().

property T: Array
property device: arkouda.array_api._typing.Device
property dtype: arkouda.array_api._typing.Dtype
property mT: Array
property ndim: int
property shape: Tuple[int, Ellipsis]
property size: int
item()[source]

Convert the array to a Python scalar

to_device(device: arkouda.array_api._typing.Device, /, stream: None = None) Array[source]
to_ndarray()[source]

Convert the array to a numpy ndarray

tolist()[source]

Convert the array to a Python list or nested lists

transpose(axes: Tuple[int, Ellipsis] | None = None)[source]

Return a view of the array with the specified axes transposed.

For axes=None, reverse all the dimensions of the array.

arkouda.array_api._typing.Device
arkouda.array_api._typing.Dtype
arkouda.array_api._typing.PyCapsule
arkouda.array_api._typing.SupportsBufferProtocol
class arkouda.array_api._typing.SupportsDLPack[source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...