dask 2021.10.0

NotesParametersReturnsBackRef
result_type(*arrays_and_dtypes)

Some inconsistencies with the Dask version may exist.

Returns the type that results from applying the NumPy type promotion rules to the arguments.

Type promotion in NumPy works similarly to the rules in languages like C++, with some slight differences. When both scalars and arrays are used, the array's type takes precedence and the actual value of the scalar is taken into account.

For example, calculating 3*a, where a is an array of 32-bit floats, intuitively should result in a 32-bit float output. If the 3 is a 32-bit integer, the NumPy rules indicate it can't convert losslessly into a 32-bit float, so a 64-bit float should be the result type. By examining the value of the constant, '3', we see that it fits in an 8-bit integer, which can be cast losslessly into the 32-bit float.

Notes

versionadded

The specific algorithm used is as follows.

Categories are determined by first checking which of boolean, integer (int/uint), or floating point (float/complex) the maximum kind of all the arrays and the scalars are.

If there are only scalars or the maximum category of the scalars is higher than the maximum category of the arrays, the data types are combined with promote_types to produce the return value.

Otherwise, :None:None:`min_scalar_type` is called on each array, and the resulting data types are all combined with promote_types to produce the return value.

The set of int values is not a subset of the uint values for types with the same number of bits, something not reflected in min_scalar_type , but handled as a special case in result_type .

Parameters

arrays_and_dtypes : list of arrays and dtypes

The operands of some operation whose result type is needed.

Returns

out : dtype

The result type.

This docstring was copied from numpy.result_type.

See Also

can_cast
dtype
min_scalar_type
promote_types

Examples

This example is valid syntax, but we were not able to check execution
>>> np.result_type(3, np.arange(7, dtype='i1'))  # doctest: +SKIP
dtype('int8')
This example is valid syntax, but we were not able to check execution
>>> np.result_type('i4', 'c8')  # doctest: +SKIP
dtype('complex128')
This example is valid syntax, but we were not able to check execution
>>> np.result_type(3.0, -2)  # doctest: +SKIP
dtype('float64')
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.routines.result_type

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/routines.py#56
type: <class 'function'>
Commit: