{ } Raw JSON

bundles / scipy 1.17.1 / scipy / spatial / transform / _rotation / _promote

function

scipy.spatial.transform._rotation:_promote

source: /scipy/spatial/transform/_rotation.py :40

Signature

def   _promote ( * args : tuple[ArrayLike, ...] xp : ModuleType )  →  Array

Summary

Promote arrays to float64 for numpy, else according to the Array API spec.

Extended Summary

The return array dtype follows the following rules: - If quat is an ArrayLike or NumPy array, we always promote to float64 - If quat is an Array from frameworks other than NumPy, we preserve the precision of the input array dtype.

The first rule is required by the cython backend signatures that expect cython.double views. The second rule is necessary to promote non-floating arrays to the correct type in frameworks that may not support double precision (e.g. jax by default).

Notes

Array API Standard Support

_promote has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

====================  ====================  ====================
Library               CPU                   GPU
====================  ====================  ====================
NumPy                 ✅                     n/a                 
CuPy                  n/a                   ✅                   
PyTorch               ✅                     ✅                   
JAX                   ✅                     ✅                   
Dask                  ✅                     n/a                 
====================  ====================  ====================

See dev-arrayapi for more information.

Aliases

  • scipy.spatial.transform._rigid_transform._promote