array_namespace

array_namespace(*arrays: Any) ModuleType[source][source]

Get the array API compatible namespace for the arrays xs.

Parameters:

*arrays (sequence of array_like) – Arrays used to infer the common namespace.

Returns:

namespace – Common namespace.

Return type:

module

Notes

Thin wrapper around array_api_compat.array_namespace.

  1. Check for the global switch: SCIPY_ARRAY_API. This can also be accessed dynamically through _GLOBAL_CONFIG['SCIPY_ARRAY_API'].

  2. _compliance_scipy raise exceptions on known-bad subclasses. See its definition for more details.

When the global switch is False, it defaults to the numpy namespace. In that case, there is no compliance check. This is a convenience to ease the adoption. Otherwise, arrays must comply with the new rules.

Examples

>>> import numpy as np
>>> array_namespace(np.array([1, 2, 3]))
<module '...numpy' from ...