parray.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号