Other functionality

Types and Type Variables for Arrays and Containers

arraycontext.ScalarLike

alias of int | integer | float | complex | inexact | bool | bool

class arraycontext.Array(*args, **kwargs)[source]

A Protocol for the array type supported by ArrayContext.

This is meant to aid in typing annotations. For a explicit list of supported types see ArrayContext.array_types.

shape
size
dtype
__getitem__[source]

In addition, arrays are expected to support basic arithmetic.

class arraycontext.ArrayT

alias of TypeVar(‘ArrayT’, bound=Array)

See also ArrayContainer and ArrayOrContainerT.

arraycontext.ArrayOrScalar

alias of Array | int | integer | float | complex | inexact | bool | bool

class arraycontext.ArrayOrScalarT

alias of TypeVar(‘ArrayOrScalarT’, bound=Array | int | integer | float | complex | inexact | bool | bool)

arraycontext.ArrayOrContainer

alias of Array | ObjectArray[tuple[int, …], ArrayOrContainerOrScalar] | _UserDefinedArrayContainer

class arraycontext.ArrayOrContainerT

alias of TypeVar(‘ArrayOrContainerT’, bound=Array | ObjectArray[tuple[int, …], ArrayOrContainerOrScalar] | _UserDefinedArrayContainer)

arraycontext.ArrayOrArithContainer

alias of Array | ObjectArray[tuple[int, …], ArrayOrArithContainerOrScalar] | _UserDefinedArithArrayContainer

class arraycontext.ArrayOrArithContainerT

alias of TypeVar(‘ArrayOrArithContainerT’, bound=Array | ObjectArray[tuple[int, …], ArrayOrArithContainerOrScalar] | _UserDefinedArithArrayContainer)

class arraycontext.ContainerOrScalarT

alias of TypeVar(‘ContainerOrScalarT’, bound=ArrayContainer | ScalarLike)

arraycontext.ArrayOrArithContainerOrScalar

alias of Array | ObjectArray[tuple[int, …], ArrayOrArithContainerOrScalar] | _UserDefinedArithArrayContainer | int | integer | float | complex | inexact | bool | bool

class arraycontext.ArrayOrArithContainerOrScalarT

alias of TypeVar(‘ArrayOrArithContainerOrScalarT’, bound=Array | ObjectArray[tuple[int, …], ArrayOrArithContainerOrScalar] | _UserDefinedArithArrayContainer | int | integer | float | complex | inexact | bool | bool)

arraycontext.ArrayOrContainerOrScalar

alias of Array | ObjectArray[tuple[int, …], ArrayOrContainerOrScalar] | _UserDefinedArrayContainer | int | integer | float | complex | inexact | bool | bool

class arraycontext.ArrayOrContainerOrScalarT

alias of TypeVar(‘ArrayOrContainerOrScalarT’, bound=Array | ObjectArray[tuple[int, …], ArrayOrContainerOrScalar] | _UserDefinedArrayContainer | int | integer | float | complex | inexact | bool | bool)

Other locations

class arraycontext.typing.ArrayContainerT
Canonical:

arraycontext.ArrayContainerT.

Metadata (“tags”) for Arrays and Array Axes

class arraycontext.metadata.NameHint(name: str)[source]

A tag acting on arrays or array axes. Express that name is a useful starting point in forming an identifier for the tagged object.

name

A string. Must be a valid Python identifier. Not necessarily unique.

ArrayContext-generating fixture for pytest

class arraycontext.PytestArrayContextFactory[source]
class arraycontext.PytestPyOpenCLArrayContextFactory(device)[source]
__init__(device)[source]
Parameters:

device – a pyopencl.Device.

__call__() ArrayContext[source]

Call self as a function.

arraycontext.pytest_generate_tests_for_array_contexts(factories: Sequence[str | type[PytestArrayContextFactory]], *, factory_arg_name: str = 'actx_factory') Callable[[Any], None][source]

Parametrize tests for pytest to use an ArrayContext.

Using this function in pytest test scripts allows you to use the argument factory_arg_name, which is a callable that returns a ArrayContext. All test functions will automatically be run once for each implemented array context. To select specific array context implementations explicitly define, for example,

pytest_generate_tests = pytest_generate_tests_for_array_context([
    "pyopencl",
    ])

to use the pyopencl-based array context.

The environment variable ARRAYCONTEXT_TEST can also be used to overwrite any chosen implementations through factories. This is a comma-separated list of known array contexts.

Current supported implementations include:

Parameters:

factories – a list of identifiers or PytestPyOpenCLArrayContextFactory classes (not instances) for which to generate test fixtures.

Program creation for loopy

arraycontext.make_loopy_program(domains: str | Sequence[str | isl.BasicSet], statements: str | Sequence[InstructionBase | SubstitutionRule | str], kernel_data: Sequence[ValueArg | ArrayArg | TemporaryVariable | EllipsisType | str] | None = None, name: str = 'mm_actx_kernel', tags: ToTagSetConvertible = None)[source]

Return a loopy.LoopKernel suitable for use with ArrayContext.call_loopy().

References

class arraycontext.InstructionBase

See loopy.InstructionBase.

class arraycontext.SubstitutionRule

See loopy.SubstitutionRule.

class arraycontext.ValueArg

See loopy.ValueArg.

class arraycontext.ArrayArg

See loopy.ArrayArg.

class arraycontext.TemporaryVariable

See loopy.TemporaryVariable.

class arraycontext.EllipsisType

See types.EllipsisType.

References

class cl_array.Allocator

See pyopencl.array.Allocator.

class np.ndarray

See numpy.ndarray.

class dummy_refs.ToTagSetConvertible

See pytools.tag.

class dummy_refs.ArrayOrNames

A type alias in pytato allowing pytato.Array and pytato.AbstractResultWithNamedArrays.

class dummy_refs.Integer

A type alias allowing integers.

class dummy_refs.ScalarLike

See arraycontext.ScalarLike.

class dummy_refs.ArrayOrContainerOrScalar

See arraycontext.ArrayOrContainerOrScalar.