Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scipy/stats/tests/test_continuous_basic.py::test_cont_basic[500-200-ncf-arg74] test fails with IntegrationWarning #14519

Closed
mgorny opened this issue Aug 2, 2021 · 10 comments
Milestone

Comments

@mgorny
Copy link
Contributor

mgorny commented Aug 2, 2021

scipy/stats/tests/test_continuous_basic.py::test_cont_basic[500-200-ncf-arg74] test fails in 1.7.1.

Error message:

_________________________________________________ test_cont_basic[500-200-ncf-arg74] __________________________________________________
scipy/stats/tests/test_continuous_basic.py:189: in test_cont_basic
    check_entropy(distfn, arg, distname)
        alpha      = 0.01
        arg        = (27, 27, 0.41578441799226107)
        distfn     = <scipy.stats._continuous_distns.ncf_gen object at 0x7f8939255910>
        distname   = 'ncf'
        locscale_defaults = (0, 1)
        m          = array(1.09663138)
        meths      = [<bound method rv_continuous.pdf of <scipy.stats._continuous_distns.ncf_gen object at 0x7f8939255910>>, <bound method ...f8939255910>>, <bound method rv_continuous.logsf of <scipy.stats._continuous_distns.ncf_gen object at 0x7f8939255910>>]
        n_fit_samples = 200
        rng        = RandomState(MT19937) at 0x7F88CEEBDB40
        rvs        = array([0.90888841, 0.87523216, 0.73228753, 1.33584017, 0.93548576,
       1.09504212, 1.15670442, 0.36786914, 0.791225...03, 1.73540023, 0.87035866, 0.73702581, 0.81477748,
       0.87362182, 1.58673099, 1.88455316, 0.61564337, 1.09912842])
        sm         = 1.0740685247899555
        sn         = 500
        spec_x     = {'levy_l': -0.5, 'pareto': 1.5, 'rv_histogram_instance': 5.0, 'tukeylambda': 0.3, ...}
        sv         = 0.1911827409537913
        v          = array(0.2013794)
        x          = 0.5
scipy/stats/tests/common_tests.py:93: in check_entropy
    ent = distfn.entropy(*arg)
        arg        = (27, 27, 0.41578441799226107)
        distfn     = <scipy.stats._continuous_distns.ncf_gen object at 0x7f8939255910>
        msg        = 'ncf'
scipy/stats/_distn_infrastructure.py:1254: in entropy
    place(output, cond0, self.vecentropy(*goodargs) + log(goodscale))
        args       = (array(27), array(27), array(0.41578442))
        cond0      = True
        goodargs   = [array([27]), array([27]), array([0.41578442])]
        goodscale  = array([1])
        kwds       = {}
        loc        = array(0)
        output     = array(0.)
        scale      = array(1)
        self       = <scipy.stats._continuous_distns.ncf_gen object at 0x7f8939255910>
/usr/lib/python3.8/site-packages/numpy/lib/function_base.py:2163: in __call__
    return self._vectorize_call(func=func, args=vargs)
        args       = (array([27]), array([27]), array([0.41578442]))
        excluded   = set()
        func       = <bound method rv_continuous._entropy of <scipy.stats._continuous_distns.ncf_gen object at 0x7f8939255910>>
        kwargs     = {}
        self       = <numpy.vectorize object at 0x7f8939255c10>
        vargs      = (array([27]), array([27]), array([0.41578442]))
/usr/lib/python3.8/site-packages/numpy/lib/function_base.py:2246: in _vectorize_call
    outputs = ufunc(*inputs)
        args       = (array([27]), array([27]), array([0.41578442]))
        func       = <bound method rv_continuous._entropy of <scipy.stats._continuous_distns.ncf_gen object at 0x7f8939255910>>
        inputs     = [array([27], dtype=object), array([27], dtype=object), array([0.41578441799226107], dtype=object)]
        otypes     = 'd'
        self       = <numpy.vectorize object at 0x7f8939255c10>
        ufunc      = <ufunc '_entropy (vectorized)'>
scipy/stats/_distn_infrastructure.py:2621: in _entropy
    h = integrate.quad(integ, _a, _b)[0]
        _a         = 0.0
        _b         = inf
        args       = (27, 27, 0.41578441799226107)
        integ      = <function rv_continuous._entropy.<locals>.integ at 0x7f88cba75550>
        self       = <scipy.stats._continuous_distns.ncf_gen object at 0x7f8939255910>
scipy/integrate/quadpack.py:400: in quad
    warnings.warn(msg, IntegrationWarning, stacklevel=2)
E   scipy.integrate.quadpack.IntegrationWarning: The occurrence of roundoff error is detected, which prevents 
E     the requested tolerance from being achieved.  The error may be 
E     underestimated.
        a          = 0.0
        args       = ()
        b          = inf
        epsabs     = 1.49e-08
        epsrel     = 1.49e-08
        flip       = False
        full_output = 0
        func       = <function rv_continuous._entropy.<locals>.integ at 0x7f88cba75550>
        ier        = 2
        limit      = 50
        limlst     = 50
        maxp1      = 50
        msg        = 'The occurrence of roundoff error is detected, which prevents \n  the requested tolerance from being achieved.  The error may be \n  underestimated.'
        msgs       = {80: 'A Python error occurred possibly while calling the function.', 1: 'The maximum number of subdivisions (50) has b...\n  underestimated.', 3: 'Extremely bad integrand behavior occurs at some points of the\n  integration interval.', ...}
        points     = None
        retval     = (nan, nan, 2)
        weight     = None
        wopts      = None
        wvar       = None

Scipy/Numpy/Python version information:

$  python3.8 -c 'import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)'
1.7.1 1.21.1 sys.version_info(major=3, minor=8, micro=11, releaselevel='final', serial=0)
@tupui
Copy link
Member

tupui commented Aug 2, 2021

Same... passes on master. Can you verify all three with master on your system?

@tupui
Copy link
Member

tupui commented Aug 3, 2021

Closing as probably related to #14517 We can reopen if you have contradicting elements later on.

@tupui tupui closed this as completed Aug 3, 2021
@drew-parsons
Copy link
Contributor

I've just seen this error in scipy 1.8.1, rebuilding on a Debian (unstable) system. It previously passed fine. The main difference is that previously the tests were run with

python3 -c "import scipy; exit( not scipy.test() )"

Now I'm trying to run them using

python3 runtests.py -n -v

(in order to get more control of which tests are run).
I can reproduce the error directly with

python3 runtests.py -n -v -- -k "test_cont_basic[500-200-ncf-arg74]"

Patch #16822 that closed #14517) only changed Schur tests. Should this Issue #14519 be reopened?

Building with gcc 12.1.0 and pythran 0.11.0.
System info:

python3.10 -c 'import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)'
1.8.1 1.21.5 sys.version_info(major=3, minor=10, micro=6, releaselevel='final', serial=0)

@WarrenWeckesser
Copy link
Member

@drew-parsons, you are right, this issue is not related to #14157.

@WarrenWeckesser
Copy link
Member

I reopened the issue, but it is still possible that the problem has been fixed (directly or indirectly) in the main development branch. For example, #15763 made significant changes to the ncf distribution. @drew-parsons, are you able to rerun the tests on your system with SciPy 1.9.0?

@drew-parsons
Copy link
Contributor

Our watch script got stuck on 1.8, I hadn't seen that 1.9 is already released. I'll prepare a 1.9 build and report back.

@mdhaber
Copy link
Contributor

mdhaber commented Sep 15, 2022

@drew-parsons any luck here?

@drew-parsons
Copy link
Contributor

drew-parsons commented Sep 18, 2022

I've had to put the 1.9 build on hold since it requires pymeson to build. Debian doesn't have pymeson packaged yet, but the packaging process has started, tracked at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1017959

@mdhaber
Copy link
Contributor

mdhaber commented Feb 2, 2023

@drew-parsons it looks like that issue was resolved. Does the test pass now?

@drew-parsons
Copy link
Contributor

drew-parsons commented Feb 2, 2023

debian finally got mesonpy packaged, and we now have scipy 1.10 built.
test_cont_basic[500-200-ncf-arg74] is indeed passing now.

$ python3 runtests.py -v -n -s stats -- -k "test_cont_basic[500-200-ncf-arg74]"
Running tests for scipy version:1.10.0, installed at:/usr/lib/python3/dist-packages/scipy
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.11.1, pytest-7.2.1, pluggy-1.0.0+repack -- /usr/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/projects/python/build/scipy/build/test/.hypothesis/examples')
rootdir: /projects/python/build/scipy, configfile: pytest.ini
plugins: xvfb-2.0.0, remotedata-0.4.0, asyncio-0.20.3, arraydiff-0.5.0, filter-subpackage-0.1.2, flaky-3.7.0, hypothesis-6.64.0, cov-4.0.0, mpi-0.6, astropy-header-0.2.2, openfiles-0.5.0, mock-3.8.2, doctestplus-0.12.1, astropy-0.10.0
asyncio: mode=Mode.STRICT
collected 8512 items / 8511 deselected / 1 selected                                                                                                                                                               

../../tests/test_continuous_basic.py::test_cont_basic[500-200-ncf-arg74] PASSED                                                                                                                             [100%]

======================================================================================= 1 passed, 8511 deselected in 2.71s ========================================================================================

@tupui tupui closed this as completed Feb 2, 2023
@mdhaber mdhaber added this to the 1.11.0 milestone Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants