跳到内容

isneginf

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

参数

名称 类型 描述 默认值
x

输入

必需
out

输出数组

None
可选

输出数组

None

示例

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

numpy.isneginf :等效的 NumPy 函数

源代码位于 sparse/numba_backend/_coo/common.py
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
def isneginf(x, out=None):
    """
    Test element-wise for negative 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.isneginf(x).todense()
    array([ True])

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

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