flopscope.

flopscope.numpy.common_type

fnp.common_type(*arrays)[flopscope source][numpy source]

Return a scalar type which is common to the input arrays.

Adapted from NumPy docs np.common_type

Areacore
Typefree
Cost
0
Flopscope Context

Return scalar type common to all input arrays.

The return type will always be an inexact (i.e. floating point) scalar type, even if all the arrays are integer arrays. If one of the inputs is an integer array, the minimum precision type that is returned is a 64-bit floating point dtype.

All input arrays except int64 and uint64 can be safely cast to the returned dtype without loss of information.

Parameters

array1, array2, ...:ndarrays

Input arrays.

Returns

out:data type code

Data type code.

See also

Examples

>>> flops.common_type(flops.arange(2, dtype=flops.float32))
<class 'flops.float32'>
>>> flops.common_type(flops.arange(2, dtype=flops.float32), flops.arange(2))
<class 'flops.float64'>
>>> flops.common_type(flops.arange(4), flops.array([45, 6.j]), flops.array([45.0]))
<class 'flops.complex128'>