def _get_inplace_dtype_with_scalar(scalar, obj1):
"""
Returns the dtype of obj1,
Raise error if
1) obj1 is real and obj2 is complex
2) obj1 is integer and obj2 is floating
Parameters
----------
obj1 : numpy.ndarray like array
obj2 : numpy.ndarray like array
Returns
-------
out : np.dtype
"""
if isrealobj(obj1):
if issubclass(type(scalar), (complex, np.complexfloating)):
raise TypeError("Cannot cast complex dtype to real dtype")
if issubclass(obj1.dtype.type, np.integer):
if issubclass(
type(scalar),
(float, complex, np.floating, np.complexfloating)):
raise TypeError("Cannot cast floating to integer")
return obj1.dtype
评论列表
文章目录