def _get_inplace_dtype(obj1, obj2):
"""
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 iscomplexobj(obj2):
raise TypeError("Cannot cast complex dtype to real dtype")
if issubclass(obj1.dtype.type, np.integer):
if issubclass(obj2.dtype.type, (np.floating, np.complexfloating)):
raise TypeError("Cannot cast floating to integer")
return obj1.dtype
评论列表
文章目录