-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
BUG: Test failures due to invalid value encountered in _beta_ppf
on M2 mac
#20208
Comments
Do you get the same errors using the incomplete beta function via special? That one also uses boost under the hood but was wrapped in a different way, might be worth trying out. |
No. Only in stats |
We could try to replace the custom Boost wrappers for the beta distribution by directly calling the functions from That would also reduce duplication between stats and special. special on its own has enough duplication already ;). Would you be able to test it out? I do not have an M2 Mac to test locally. |
I reproduce these failures on my M1 Mac |
Those tests are passing on my M2 with |
Yes, I'm on |
Ah yeah, and I bet you're both using |
I'll test out using the ones for special tomorrow. Let's see if that makes a difference EDIT: I didn't get the time to try out the special version. I'll try fit in some time this week, but I'm pretty time poor at the moment. |
And I can confirm that I just started seeing this in a conda-forge env after recreating one from scratch. That gave me a newer build number of Clang 16.0.6; this code is very fragile, it probably has something to do with the defined boost-math "policies" for floating-point handling. |
I will start looking into it in the afternoon today. |
I think I am able to reproduce the issue, =========================== short test summary info ============================
FAILED scipy/stats/tests/test_distributions.py::TestBeta::test_issue_12635 - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_distributions.py::TestBeta::test_issue_12794 - RuntimeWarning: invalid value encountered in _beta_isf
FAILED scipy/stats/tests/test_distributions.py::TestBeta::test_issue_12796 - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_distributions.py::TestBetaPrime::test_ppf[0.375-0.25-7.0-0.002036820346115211] - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_fast_gen_inversion.py::test_rvs_and_ppf[betaprime-args6] - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_fast_gen_inversion.py::test_non_rvs_methods_with_domain - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_fit.py::TestGoodnessOfFit::test_against_filliben_norm - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_fit.py::TestGoodnessOfFit::test_filliben_property - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_fit.py::TestGoodnessOfFit::test_against_filliben_norm_table[case0] - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_fit.py::TestGoodnessOfFit::test_against_filliben_norm_table[case1] - RuntimeWarning: invalid value encountered in _beta_ppf
FAILED scipy/stats/tests/test_fit.py::TestGoodnessOfFit::test_against_filliben_norm_table[case2] - RuntimeWarning: invalid value encountered in _beta_ppf
= 11 failed, 46989 passed, 2403 skipped, 14574 deselected, 150 xfailed, 13 xpassed in 280.89s (0:04:40) =
python dev.py test 320.14s user 50.77s system 129% cpu 4:46.20 total I am on clang-16. I would like to point out that Clang-16 gives segmentation faults with PyTorch C++-API, however Clang-15 doesn't. I have experienced fragility/buggy nature of Clang-16 on my macOS before as well. However first I will upgrade the |
So as expected, the bug is due to Testing Logs(scipy-dev-clang-15) 15:30:44:~/Quansight/scipy % python dev.py test -s stats
💻 ninja -C /Users/czgdp1807/Quansight/scipy/build -j10
ninja: Entering directory `/Users/czgdp1807/Quansight/scipy/build'
[4/4] Generating scipy/generate-version with a custom command
Build OK
💻 meson install -C build --only-changed
Installing, see meson-install.log...
Installation OK
SciPy from development installed path at: /Users/czgdp1807/Quansight/scipy/build-install/lib/python3.11/site-packages
Running tests for scipy version:1.14.0.dev0+666.9d6aac2, installed at:/Users/czgdp1807/Quansight/scipy/build-install/lib/python3.11/site-packages/scipy
============================= test session starts ==============================
platform darwin -- Python 3.11.8, pytest-8.1.1, pluggy-1.4.0
rootdir: /Users/czgdp1807/Quansight/scipy
configfile: pytest.ini
plugins: cov-5.0.0, timeout-2.2.0, anyio-4.3.0, hypothesis-6.99.13, xdist-3.5.0
collected 13111 items / 3804 deselected / 9307 selected
scipy/stats/tests/test_axis_nan_policy.py .............................. [ 0%]
........................................................................ [ 1%]
........................................................................ [ 1%]
........................................................................ [ 2%]
........................................................................ [ 3%]
........................................................................ [ 4%]
........................................................................ [ 4%]
........................................................................ [ 5%]
........................................................................ [ 6%]
........................................................................ [ 7%]
........................................................................ [ 8%]
........................................................................ [ 8%]
........................................................................ [ 9%]
...............................sss...................................... [ 10%]
.................................................. [ 10%]
scipy/stats/tests/test_binned_statistic.py ............................. [ 11%]
................................ [ 11%]
scipy/stats/tests/test_boost_ufuncs.py ............ [ 11%]
scipy/stats/tests/test_censored_data.py ............ [ 11%]
scipy/stats/tests/test_contingency.py ............. [ 11%]
scipy/stats/tests/test_continuous_basic.py ...........................s. [ 12%]
......................ss..................................s...........s. [ 13%]
..............................s.......................ss................ [ 13%]
..................s...........s................................s........ [ 14%]
.............................................................s.......... [ 15%]
........................................................................ [ 16%]
........................................................................ [ 16%]
........................................................................ [ 17%]
........................................................................ [ 18%]
........................................................................ [ 19%]
........................................................................ [ 20%]
........................................................................ [ 20%]
........................................................................ [ 21%]
........................................................................ [ 22%]
........................................................................ [ 23%]
........................................................................ [ 23%]
........................................................................ [ 24%]
........................................................................ [ 25%]
.....s...................... [ 25%]
scipy/stats/tests/test_continuous_fit_censored.py .................. [ 25%]
scipy/stats/tests/test_crosstab.py ............. [ 26%]
scipy/stats/tests/test_discrete_basic.py ............................... [ 26%]
........................................................................ [ 27%]
........................................................................ [ 27%]
........................................................................ [ 28%]
........................................................................ [ 29%]
.................................................................... [ 30%]
scipy/stats/tests/test_discrete_distns.py .............................. [ 30%]
......................................... [ 30%]
scipy/stats/tests/test_distributions.py ................................ [ 31%]
......ssssssssssssssssssssssss.......................................... [ 32%]
........................................................................ [ 32%]
........................................................................ [ 33%]
........................................................................ [ 34%]
........................................................................ [ 35%]
........................................................................ [ 35%]
........................................................................ [ 36%]
........................................................................ [ 37%]
........................................................................ [ 38%]
........................................................................ [ 39%]
........................................................................ [ 39%]
........................................................................ [ 40%]
........................................................................ [ 41%]
........................................................................ [ 42%]
........................................................................ [ 42%]
........................................................................ [ 43%]
........................................................................ [ 44%]
........................................................................ [ 45%]
........................................................................ [ 46%]
........................................................................ [ 46%]
............................................................xxxx....s.s. [ 47%]
........................xxxxxxxxxx.....................s................ [ 48%]
.............................................s.......................... [ 49%]
..s..................................................................... [ 49%]
........................................................................ [ 50%]
........................................................................ [ 51%]
.......................................................s.....s.......... [ 52%]
........................................................................ [ 52%]
........................................................................ [ 53%]
................................................xxxxxxxxxxxxxxxxxxxxxxxx [ 54%]
xxx..................................................................... [ 55%]
..........................................s...................s......... [ 56%]
................ss......................... [ 56%]
scipy/stats/tests/test_entropy.py .................................... [ 56%]
scipy/stats/tests/test_fast_gen_inversion.py ........................... [ 57%]
.............................................x.......................... [ 57%]
....................................... [ 58%]
scipy/stats/tests/test_fit.py .......................................... [ 58%]
........................................................................ [ 59%]
.s....sss...s.s.ss.ssss.......ss.sssss.........sss....s..s..sss.s.ss...s [ 60%]
ss.ssss..........ss......s.s.ssss...sssssss.......sssss...s.s.sss.ssss.s [ 61%]
sss.ssssss.........s.................. [ 61%]
scipy/stats/tests/test_hypotests.py .................................... [ 61%]
........................................................................ [ 62%]
........................................................................ [ 63%]
........................... [ 63%]
scipy/stats/tests/test_kdeoth.py ..........ss......ss....sssssssssssssss [ 64%]
s..ss......ss........s.s..... [ 64%]
scipy/stats/tests/test_morestats.py .................................... [ 64%]
........................................................................ [ 65%]
........................................................................ [ 66%]
........................................................................ [ 67%]
........................................................................ [ 68%]
............................................................. [ 68%]
scipy/stats/tests/test_mstats_basic.py ......s..s...............s....... [ 69%]
........................................................................ [ 69%]
....................................... [ 70%]
scipy/stats/tests/test_mstats_extras.py .......... [ 70%]
scipy/stats/tests/test_multicomp.py .................................... [ 70%]
............ [ 70%]
scipy/stats/tests/test_multivariate.py ......s.s..ss..ss............ssss [ 71%]
....ssss........ssssssss........ssssssss................................ [ 71%]
........................................................................ [ 72%]
........................................................................ [ 73%]
........................................................................ [ 74%]
.....................ssssssssssssssssssss............................... [ 75%]
........................................................................ [ 75%]
........................................................................ [ 76%]
............ [ 76%]
scipy/stats/tests/test_odds_ratio.py ................................... [ 77%]
...................................................................... [ 77%]
scipy/stats/tests/test_qmc.py ........x................................. [ 78%]
........................sss..........................................s.s [ 79%]
.s.s.s.s.s...ssss............................ [ 79%]
scipy/stats/tests/test_rank.py ......................................... [ 80%]
.... [ 80%]
scipy/stats/tests/test_relative_risk.py ............... [ 80%]
scipy/stats/tests/test_resampling.py ................................... [ 80%]
........................................................................ [ 81%]
........................................................................ [ 82%]
...............ss..........ssss............. [ 82%]
scipy/stats/tests/test_sampling.py ..................................... [ 83%]
........................................................................ [ 83%]
........................................................................ [ 84%]
.................s..ss...ssssssssss..s............................ssssss [ 85%]
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 86%]
sssssssssssssssssssssssssssssssssssss................................... [ 86%]
..................ssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 87%]
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss........... [ 88%]
..................s..ss...ssssssssss..s................................ [ 89%]
scipy/stats/tests/test_sensitivity_analysis.py ........ [ 89%]
scipy/stats/tests/test_stats.py ........................................ [ 89%]
.........sssssssss...................................................... [ 90%]
........................................................................ [ 91%]
........................................................................ [ 92%]
........................................................................ [ 92%]
...............................................ss....................... [ 93%]
..............................................................ss........ [ 94%]
............................................................xxx......... [ 95%]
........................................................................ [ 95%]
........................................................................ [ 96%]
........................................................................ [ 97%]
........................................................................ [ 98%]
.........................................................s.............. [ 99%]
.................................... [ 99%]
scipy/stats/tests/test_survival.py ....................... [ 99%]
scipy/stats/tests/test_tukeylambda_stats.py ... [ 99%]
scipy/stats/tests/test_variation.py .............................. [100%]
== 8762 passed, 499 skipped, 3804 deselected, 46 xfailed in 97.67s (0:01:37) === Here is the environment file which I am using, (scipy-dev-clang-15) 15:32:39:~/Quansight/scipy % git diff
diff --git a/environment.yml b/environment.yml
index 84c31d1c4..1a2dfd4f7 100644
--- a/environment.yml
+++ b/environment.yml
@@ -3,13 +3,13 @@
# $ conda env create -f environment.yml # `mamba` works too for this command
# $ conda activate scipy-dev
#
-name: scipy-dev
+name: scipy-dev-clang-15
channels:
- conda-forge
dependencies:
- python
- cython>=3.0.8
- - compilers # Currently unavailable for Windows. Comment out this line and download Rtools and add <path>\ucrt64\bin\ to your path: https://cran.r-project.org/bin/windows/Rtools/rtools40.html
+ - compilers=1.6.0 # Currently unavailable for Windows. Comment out this line and download Rtools and add <path>\ucrt64\bin\ to your path: https://cran.r-project.org/bin/windows/Rtools/rtools40.html
- meson
- meson-python
- ninja
diff --git a/scipy/_lib/boost_math b/scipy/_lib/boost_math
index 1a7be5d89..15c40fae1 160000
--- a/scipy/_lib/boost_math
+++ b/scipy/_lib/boost_math
@@ -1 +1 @@
-Subproject commit 1a7be5d895d266a870af7a6ed258e5bcf9838277
+Subproject commit 15c40fae1610fd83728d75e96d7377fe55f976f7 Though note that Update - The whole test suite passes with clang-15 and the above diff. |
So overall I'd say there are bugs in From the above comment, it seems like same thing is happening with SciPy AFAICT. So may be for now we should fix Update - As far as I can understand using cc: @rgommers |
We can live with these failures for a little while, since they don't show up in CI. Let's try to resolve it first before pinning. It's not clearcut that it's only a Clang 16 bug; there are fixes in boost-math that we haven't pulled in yet, and there may be another bug (or multiple) hiding in boost-math.
Could you have a go at this? |
Yes I tried this first before switching to clang-15 but the tests still fail with clang-16 (combined with latest
Correct. I just looked above #20208 (comment) and #20208 (comment). Seems like, |
Seems like with the following diff (now available in this branch) alone the failures reduce to 1 only ( diff --git a/scipy/stats/_continuous_distns.py b/scipy/stats/_continuous_distns.py
index 13af05009..ab9ec3ce3 100644
--- a/scipy/stats/_continuous_distns.py
+++ b/scipy/stats/_continuous_distns.py
@@ -692,12 +692,10 @@ class beta_gen(rv_continuous):
return _boost._beta_sf(x, a, b)
def _isf(self, x, a, b):
- with np.errstate(over='ignore'): # see gh-17432
- return _boost._beta_isf(x, a, b)
+ return sc.betaincinv(a, b, 1 - x)
def _ppf(self, q, a, b):
- with np.errstate(over='ignore'): # see gh-17432
- return _boost._beta_ppf(q, a, b)
+ return sc.betaincinv(a, b, q)
def _stats(self, a, b):
return (
@@ -2289,7 +2287,7 @@ class f_gen(rv_continuous):
the distribution of the ratio of two independent chi-squared distributions with
:math:`df_1` and :math:`df_2` degrees of freedom, after rescaling by
:math:`df_2 / df_1`.
-
+
The probability density function for `f` is:
.. math:: FAILURES=================================== FAILURES ===================================
_____________________ TestBeta.test_boost_eval_issue_14606 _____________________
scipy/stats/tests/test_distributions.py:4460: in test_boost_eval_issue_14606
with pytest.warns(RuntimeWarning):
E Failed: DID NOT WARN. No warnings of type (<class 'RuntimeWarning'>,) were emitted.
E Emitted warnings: [].
a = 100000000000.0
b = 10000000000000.0
q = 0.995
self = <scipy.stats.tests.test_distributions.TestBeta object at 0x1606658d0>
=========================== short test summary info ============================
FAILED scipy/stats/tests/test_distributions.py::TestBeta::test_boost_eval_issue_14606 - Failed: DID NOT WARN. No warnings of type (<class 'RuntimeWarning'>,) were ...
= 1 failed, 8761 passed, 499 skipped, 3804 deselected, 46 xfailed in 95.51s (0:01:35) = |
This failure is because of the |
Seems like for this warning, Other than this, I think we should be moving ahead with, #16583 cc: @rgommers |
Avoids bug in Clang 16 (scipygh-20208) [skip circle]
Avoids bug in Clang 16 (scipygh-20208) [skip circle]
Avoids bug in Clang 16 (scipygh-20208) [skip circle]
Describe your issue.
The following tests fail with the warning
invalid value encountered in _beta_ppf
Reproducing Code Example
`python dev.py test`
Error message
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: