bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / _lib / _array_api / xp_promote
function
scipy._lib._array_api:xp_promote
source: build-install/usr/lib/python3.14/site-packages/scipy/_lib/_array_api.py:488
Signature
def xp_promote(*args, broadcast = False, force_floating = False, xp)Summary
Promotes elements of *args to result dtype, ignoring None's. Includes options for forcing promotion to floating point and broadcasting the arrays, again ignoring 'None's. Type promotion rules follow 'xp_result_type instead of xp.result_type.
Extended Summary
Typically, this function will be called shortly after array_namespace on a subset of the arguments passed to array_namespace.
This function accepts array-like iterables, which are immediately converted to the namespace's arrays before result type calculation. Consequently, the result dtype may be different when an argument is 1. vs [1.].
Scalars and array-like iterables are converted onto the device of the first array argument (if any), so that e.g. a scalar default promoted alongside a non-default-device array does not land on the default device (see gh-22680). Array arguments always keep their own device.
See also
Aliases
scipy.differentiate.xp_promote