bundles / numpy latest / numpy / mintypecode
function
numpy:mintypecode
source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/lib/_type_check_impl.py :25
Signature
def mintypecode ( typechars , typeset = GDFgdf , default = d ) Summary
Return the character for the minimum-size type to which given types can be safely cast.
Extended Summary
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_likeIf 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, optionalThe set of characters that the returned character is chosen from. The default set is 'GDFgdf'.
default: str, optionalThe default character, this is returned if none of the characters in
typecharsmatches a character intypeset.
Returns
typechar: strThe character representing the minimum-size type that was found.
Examples
import numpy as np np.mintypecode(['d', 'f', 'S']) x = np.array([1.1, 2-3.j]) np.mintypecode(x)✓
np.mintypecode('abceh', default='G')
✓See also
- dtype
Aliases
-
numpy.mintypecode