def promote_arrays(self, type1, type2): "Promote two array types in an expression to a new array type" equal_ndim = type1.ndim == type2.ndim return ArrayType( self.promote_types(type1.dtype, type2.dtype), ndim=miniutils.max((type1.ndim, type2.ndim)), is_c_contig=(equal_ndim and type1.is_c_contig and type2.is_c_contig), is_f_contig=(equal_ndim and type1.is_f_contig and type2.is_f_contig), )
def promote_arrays(self, type1, type2): "Promote two array types in an expression to a new array type" equal_ndim = type1.ndim == type2.ndim return ArrayType(self.promote_types(type1.dtype, type2.dtype), ndim=miniutils.max((type1.ndim, type2.ndim)), is_c_contig=(equal_ndim and type1.is_c_contig and type2.is_c_contig), is_f_contig=(equal_ndim and type1.is_f_contig and type2.is_f_contig))
def promote_numeric(self, type1, type2): "Promote two numeric types" type = miniutils.max([type1, type2], key=lambda type: type.rank) if type1.kind != type2.kind: def itemsize(type): return type.itemsize // 2 if type.is_complex else type.itemsize size = max(itemsize(type1), itemsize(type2)) if type.is_complex: type = find_type_of_size(size * 2, complextypes) elif type.is_float: type = find_type_of_size(size, floating) else: assert type.is_int type = find_type_of_size(size, integral) return type
def promote_numeric(self, type1, type2): "Promote two numeric types" return miniutils.max([type1, type2], key=lambda type: type.rank)