parray.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:neurodriver 作者: neurokernel 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号