跳到内容

isposinf

逐元素测试正无穷大,将结果作为稀疏的 bool 数组返回。

参数

名称 类型 描述 默认值
x

输入

必需
out

输出数组

None
可选

输出数组

None

示例

>>> import sparse
>>> x = sparse.as_coo(np.array([np.inf]))
>>> sparse.isposinf(x).todense()
array([ True])
另请参阅

numpy.isposinf :NumPy 等效函数

源代码位于 sparse/numba_backend/_coo/common.py
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
def isposinf(x, out=None):
    """
    Test element-wise for positive infinity, return result as sparse `bool` array.

    Parameters
    ----------
    x
        Input
    out, optional
        Output array

    Examples
    --------
    >>> import sparse
    >>> x = sparse.as_coo(np.array([np.inf]))
    >>> sparse.isposinf(x).todense()
    array([ True])

    See Also
    --------
    [`numpy.isposinf`][] : The NumPy equivalent
    """
    from sparse import elemwise

    return elemwise(lambda x, out=None, dtype=None: np.isposinf(x, out=out), x, out=out)