colour.utilities.trace_array_namespace#

class colour.utilities.trace_array_namespace[source]#

Bases: object

Define a context manager to trace array_namespace() calls and array type flow through Colour functions using sys.settrace().

When active, every function call under colour/ is logged with the types of all array arguments (positional and keyword). Return values are logged with their types. Calls where multiple array backends coexist in the same argument list are flagged as MIXED.

The trace output is indented to reflect the call stack depth.

Examples

>>> import torch
>>> with array_api_enable(True), trace_array_namespace():
...     pass
__init__() → None[source]#
Return type:

None

__enter__() → Self[source]#

Enter the context and install the trace hook.

Return type:

Self

__exit__(*args: Any) → None[source]#

Exit the context and restore the previous trace hook.

Parameters:

args (Any)

Return type:

None

__weakref__#

list of weak references to the object