scipy_namespace_for¶
- scipy_namespace_for(xp: ModuleType) ModuleType | None[source][source]¶
Return the
scipy-like namespace of a non-NumPy backendThat is, return the namespace corresponding with backend
xpthat containsscipysub-namespaces likelinalgandspecial. If no such namespace exists, returnNone. Useful for dispatching.- Parameters:
xp (
module) –- The array API namespace for which to find the corresponding SciPy-like
namespace.
- Returns:
- The SciPy-like namespace for the given array API namespace, or None if
no such namespace exists.
- Return type:
moduleorNone
Examples
>>> import numpy as np >>> import scipy >>> scipy_namespace = scipy_namespace_for(np) >>> scipy_namespace is scipy True
>>> import cupy as cp >>> scipy_namespace = scipy_namespace_for(cp) >>> scipy_namespace is cupyx.scipy True