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

TST: special: better test for gammainc at large arguments #6152

Merged
merged 1 commit into from
Jun 5, 2016

Conversation

person142
Copy link
Member

This changes the systematic test for gammainc at large arguments to be
based on data precomputed by mpmath. This allows the test to have a
much larger range and run faster. (Note that although the previous
test at large values nominally had an upper bound of 1e100, only about
183 points were actually tested because the others raised exceptions
in mpmath.)

Since the utilities in test_mpmath are also useful in precompute
tests, they have been moved to the new file _mptestutils.py.

@person142
Copy link
Member Author

Nobody merge this until I add tests for gammaincc too.

@pv pv added the needs-work Items that are pending response from the author label May 14, 2016
@person142
Copy link
Member Author

Ok, I think this is ready for review now. I had hoped to have one data file for both gammainc and gammaincc, but it turns out that with mpmath

  • gammainc takes prohibitively long to compute when x > a
  • gammaincc takes prohibitively long to compute when x < a,

so that didn't work out. As a result there is just a test for gammainc when x < a; the hope is that these can be combined with future tests for gammaincc (which is based on the same code) to get reasonable coverage. The tolerance had to be rather large (5e-9) to get the test to pass, so further improvements to the asymptotic regime would be good. (Working on it.)

Finally, the function mpf2float probably deserves extra skepticism and scrutiny.

The previous TestSystematic test for large arguments used the
exception_to_nan wrapper and as a result only checked about 183 points
because of exceptions in mpmath. Unfortunately these points were in
the uninteresting regions where a >> x (gammainc = 1) or a << x
(gammainc = 0). This adds a test to test_data that better checks the
region a ~ x, though it is restricted to a <= x because of prohibitive
precomputation times in mpmath (> 1 day).

Since the utilities in test_mpmath.py are also useful in
test_precompute_*.py tests, they have been moved to a new file
_mptestutils.py.

Finally, a new function mpf2float is added to convert mpfs to floats
because just using float() has incorrect rounding in some cases.
@person142
Copy link
Member Author

Rebased and force-pushed.

@pv pv added scipy.special and removed needs-work Items that are pending response from the author labels Jun 5, 2016
@pv pv merged commit 0edf2ba into scipy:master Jun 5, 2016
@pv
Copy link
Member

pv commented Jun 5, 2016

Thanks, looks good to me

@pv pv added this to the 0.18.0 milestone Jun 5, 2016
@person142 person142 deleted the gammainc branch June 19, 2016 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants