def _get_common_dtype_with_scalar(scalar, obj1):
"""
return the common dtype between a native scalar (int, float, complex)
and the dtype of an ndarray like array.
Parameters
----------
scalar : { int, float, complex }
obj1 : numpy.ndarray like array.
"""
if issubclass(type(scalar), (int, float, np.integer, np.floating)):
return obj1.dtype
elif issubclass(type(scalar), (complex, np.complexfloating)):
if isrealobj(obj1):
return floattocomplex(obj1.dtype)
else:
return obj1.dtype
else:
raise TypeError("scalar type is not supported")
评论列表
文章目录