flopscope.numpy.mintypecode
fnp.mintypecode(typechars, typeset='GDFgdf', default='d')[flopscope source][numpy source]
Return the character for the minimum-size type to which given types can be safely cast.
Adapted from NumPy docs np.mintypecode
Return minimum data type character that can satisfy all given types.
The returned type character must represent the smallest size dtype such
that an array of the returned type can handle the data from an array of
all types in typechars (or if typechars is an array, then its
dtype.char).
Parameters
- typechars:list of str or array_like
If a list of strings, each string should represent a dtype. If array_like, the character representation of the array dtype is used.
- typeset:str or list of str, optional
The set of characters that the returned character is chosen from. The default set is 'GDFgdf'.
- default:str, optional
The default character, this is returned if none of the characters in
typecharsmatches a character intypeset.
Returns
- typechar:str
The character representing the minimum-size type that was found.
See also
Examples
>>> import flopscope.numpy as fnp
>>> flops.mintypecode(['d', 'f', 'S'])
'd'
>>> x = flops.array([1.1, 2-3.j])
>>> flops.mintypecode(x)
'D'>>> flops.mintypecode('abceh', default='G')
'G'