예제 #1
0
def test_loggamma_real():
    # For positive real values loggamma dispatches to lgamma, so we
    # don't need to check many points
    mpmath_allclose(sc.loggamma, mpmath.loggamma,
                    [Arg(0, np.inf, inclusive_a=False)], 50, 1e-13)

    assert all(np.isnan(sc.loggamma([0, -0.5])))
예제 #2
0
def test_greater_than_40():
    mpmath_allclose(
        sc.ei,
        mpmath.ei,
        [Arg(40, 720)],  # By 720 Ei has overflowed.
        200,
        rtol=2 * _ε,
    )
예제 #3
0
def test_zeta_between_1_and_56():
    mpmath_allclose(
        sc.zeta,
        mpmath.zeta,
        [Arg(1, 56, inclusive_a=False)],
        100,
        rtol=_ε,
    )
예제 #4
0
def test_zeta_small_arguments():
    mpmath_allclose(
        sc.zeta,
        mpmath.zeta,
        [Arg(-1, 1, inclusive_b=False)],
        50,
        rtol=4 * _ε,
    )
예제 #5
0
def test_between_0_and_1():
    mpmath_allclose(
        sc.e1,
        mpmath.e1,
        [Arg(0, 1, inclusive_a=False)],
        100,
        rtol=2 * _ε,
    )
예제 #6
0
def test_between_1_and_underflow():
    mpmath_allclose(
        sc.e1,
        mpmath.e1,
        [Arg(1, -MINEXP)],
        200,
        rtol=2 * _ε,
    )
예제 #7
0
def test_between_10_and_20():
    mpmath_allclose(
        sc.ei,
        mpmath.ei,
        [Arg(10, 20)],
        50,
        rtol=2 * _ε,
    )
예제 #8
0
def test_between_20_and_40():
    mpmath_allclose(
        sc.ei,
        mpmath.ei,
        [Arg(20, 40)],
        50,
        rtol=2 * _ε,
    )
예제 #9
0
def test_between_6_and_10():
    mpmath_allclose(
        sc.ei,
        mpmath.ei,
        [Arg(6, 10)],
        50,
        rtol=2 * _ε,
    )
예제 #10
0
def test_between_0_and_6():
    mpmath_allclose(
        sc.ei,
        mpmath.ei,
        [Arg(0, 6, inclusive_a=False)],
        50,
        rtol=4 * _ε,
    )
예제 #11
0
def test_zeta_less_than_negative_1():
    mpmath_allclose(
        sc.zeta,
        mpmath.zeta,
        [Arg(-261, -1)],
        300,
        rtol=5e-14,
    )
예제 #12
0
def test_erfcinv():
    mpmath_allclose(
        sc.erfcinv,
        mpmath_erfcinv,
        [Arg(0, 2)],
        200,
        2*_ε,
        dps=42,
    )
예제 #13
0
def test_lgamma():
    def mpmath_lgamma(x):
        try:
            return mpmath.loggamma(x).real
        except ValueError:
            # Hit a pole
            return np.inf

    mpmath_allclose(sc.lgamma, mpmath_lgamma, [Arg()], 1000, 5e-14)
예제 #14
0
def test_loggamma_complex():
    def mpmath_loggamma(x):
        try:
            return mpmath.loggamma(x)
        except ValueError:
            # Hit a pole
            return complex(np.nan, np.nan)

    b = 1e200
    mpmath_allclose(sc.loggamma, mpmath_loggamma,
                    [ComplexArg(complex(-b, -b), complex(b, b))], 1000, 5e-12)
예제 #15
0
def test_gamma():
    def mpmath_gamma(x):
        try:
            return mpmath.gamma(x)
        except ValueError:
            # Gamma pole
            return np.nan

    # Gamma overflows around 170 so there's no point in testing beyond
    # that.
    mpmath_allclose(sc.gamma, mpmath_gamma, [Arg(-np.inf, 180)], 1000, 1e-14)
예제 #16
0
def test_digamma():
    def mpmath_digamma(x):
        try:
            return mpmath.digamma(x)
        except ValueError:
            # Hit a pole.
            if x == 0.0:
                return -np.copysign(np.inf, x)
            else:
                return np.nan

    mpmath_allclose(sc.digamma, mpmath_digamma, [Arg()], 1000, 5e-14, dps=40)
예제 #17
0
def test_erfinv():
    mpmath_allclose(sc.erfinv, mpmath.erfinv, [Arg(-1, 1)], 1000, 2*_ε)
예제 #18
0
def test_cospi_complex():
    rtol = 16*np.finfo(float).eps
    mpmath_allclose(sc.cospi, mpmath.cospi, [ComplexArg()], 1000, rtol)
예제 #19
0
def test_sinpi_real():
    rtol = np.finfo(float).eps
    mpmath_allclose(sc.sinpi, mpmath.sinpi, [Arg()], 1000, rtol)
예제 #20
0
def test_erfc():
    rtol = 64 * np.finfo(float).eps  # ~1.4e-14
    mpmath_allclose(sc.erfc, mpmath.erfc, [Arg(-1e100, 1e100)], 1000, rtol)
예제 #21
0
def test_erf():
    rtol = 2 * np.finfo(float).eps
    mpmath_allclose(sc.erf, mpmath.erf, [Arg()], 1000, rtol)