parray.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号