Exemple #1
0
def gisinf(x):
    """like isinf, but always raise an error if type not supported instead of
    returning a TypeError object.

    Notes
    -----
    isinf and other ufunc sometimes return a NotImplementedType object instead
    of raising any exception. This function is a wrapper to make sure an
    exception is always raised.

    This should be removed once this problem is solved at the Ufunc level."""
    from numpy.core import isinf, seterr
    err = seterr(invalid='ignore')
    try:
        st = isinf(x)
        if isinstance(st, types.NotImplementedType):
            raise TypeError("isinf not supported for this type")
    finally:
        seterr(**err)
    return st
Exemple #2
0
def gisinf(x):
    """like isinf, but always raise an error if type not supported instead of
    returning a TypeError object.

    Notes
    -----
    isinf and other ufunc sometimes return a NotImplementedType object instead
    of raising any exception. This function is a wrapper to make sure an
    exception is always raised.

    This should be removed once this problem is solved at the Ufunc level."""
    from numpy.core import isinf, seterr
    err = seterr(invalid='ignore')
    try:
        st = isinf(x)
        if isinstance(st, types.NotImplementedType):
            raise TypeError("isinf not supported for this type")
    finally:
        seterr(**err)
    return st