numpy.promote_types()
function is a symmetric function which returns the data type with the smallest size and smallest scalar kind to which both type1 and type2 may be safely cast. The returned data type is always in native byte order.
Syntax : numpy.promote_types(type1, type2)
Parameters :
type1 : [dtype or dtype specifier] First data type.
type2 : [dtype or dtype specifier] Second data type.
Return : [dtype] Return the promoted data type.
Code #1 :
# Python program explaining # numpy.promote_types() function # importing numpy as geek import numpy as geek gfg = geek.promote_types( 'f4' , 'i8' ) print (gfg) |
Output :
float64
Code #2 :
# Python program explaining # numpy.promote_types() function # importing numpy as geek import numpy as geek gfg = geek.promote_types( '>i8' , '<c8' ) print (gfg) |
Output :
complex128