bundles / scipy latest / scipy / special / _ufunc_tools / _UFuncWrapper / resolve_dtypes
function
scipy.special._ufunc_tools:_UFuncWrapper.resolve_dtypes
source: build-install/usr/lib/python3.14/site-packages/scipy/special/_ufunc_tools.py:377
Signature
def resolve_dtypes(dtypes, *, signature = None, casting = None, reduction = False)Summary
Find the dtypes NumPy will use for the operation. Both input and output dtypes are returned and may differ from those provided.
Extended Summary
Parameters
dtypes: tuple of dtypes, None, or literal int, float, complexThe input dtypes for each operand. Output operands can be None, indicating that the dtype must be found.
signature: tuple of DTypes or None, optionalIf given, enforces exact DType (classes) of the specific operand. The ufunc
dtypeargument is equivalent to passing a tuple with only output dtypes set.casting: {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optionalThe casting mode when casting is necessary. This is identical to the ufunc call casting modes.
reduction: booleanIf given, the resolution assumes a reduce operation is happening which slightly changes the promotion and type resolution rules.
dtypesis usually something like(None, np.dtype("i2"), None)for reductions (first input is also the output).
Returns
dtypes: tuple of dtypesThe dtypes which NumPy would use for the calculation. Note that dtypes may not match the passed in ones (casting is necessary).
Examples
This API requires passing dtypes, define them for convenience:import numpy as np int32 = np.dtype(np.int32) float32 = np.dtype(np.float32)✓
np.add.resolve_dtypes((int32, float32, None))
✓(dtype('float64'), dtype('float64'), dtype('float64'))
The loop found uses "float64" for all operands (including the output), the
first input would be cast.
``resolve_dtypes`` supports "weak" handling for Python scalars by passing
``int``, ``float``, or ``complex``:
np.add.resolve_dtypes((float32, float, None))
✓(dtype('float32'), dtype('float32'), dtype('float32'))
Where the Python ``float`` behaves similar to a Python value ``0.0``
in a ufunc call. (See :ref:`NEP 50 <NEP50>` for details.)Aliases
scipy.special._ufunc_tools._UFuncWrapper.resolve_dtypes