-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
ENH: stats: Add binomtest
to replace binom_test
.
#12603
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
Conversation
Instead of trying to modify the return value of Alternatively, we could do what I've implemented in this PR, which is to change the return value of I'm not sure about this API. Ultimately, it might be better to create the new function |
There is no real code sharing between binom test and confint. Alternative is to add confint as separate function (that's what I'm doing in statsmodels for now. All in one functions and classes are currently only for a few special cases.) |
Making a new function to avoid tip-toeing around the old API makes sense to me. |
cc77ea9
to
2a06a31
Compare
The new function, binomtest, returns an object with more information, and with a method to compute the confidence interval for the estimated proportion. The old version, binom_test, is deprecated.
2a06a31
to
62936b7
Compare
I didn't comment when I updated this a couple weeks ago. I followed @mdhaber's suggestion to create a new function called The new function returns an object with more information, and with a method to compute the confidence interval for the estimated proportion. The old version, E.g.
The API probably needs a few tweaks, e.g. @mdhaber suggested using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good to me, I'll merge tomorrow unless @mdhaber merges beforehand.
scipy/stats/morestats.py
Outdated
@@ -2441,6 +2441,8 @@ def levene(*args, center='median', proportiontocut=0.05): | |||
return LeveneResult(W, pval) | |||
|
|||
|
|||
@np.deprecate(new_name='binomtest', | |||
message='`binom_test` will be removed from SciPy 1.8.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rlucas7 @WarrenWeckesser Should this still be 1.8, given that this didn't make it into 1.6?
Also, did we send a message to the mailing list? I'm just thinking that we should do that before putting this in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mdhaber, I'll change that to 1.9. And I agree that this should be brought up on the mailing list before we merge this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I'll hold off merging then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code was updated to say 1.9, and I just sent an email about this to the mailing list.
* Add `versionadded` markup to the Notes section of `binomtest`. * Bump removal version of `binom_test`. * Copyedit `_validate_int` docstring.
@mdhaber I put a 1.7.0 milestone on this so that we don't forget |
|
As I noted in the mailing list, over in gh-12323, Ralf suggested that we just "doc-deprecate" |
binomtest
to replace binom_test
.
scipy/_lib/tests/test__util.py
Outdated
def test_validate_int(self): | ||
n = _validate_int(4, 'n') | ||
assert n == 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pseudo expected operator.index(Fraction(2, 1))
to work maybe also test operator.index(np.array(1))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test looks at the type of the object, not the value. In general, not all Fraction
objects are integers, just like not all float
objects are integers. I added a few more tests, including one to test that a scalar array is acceptable, and another that a Fraction
is not (even if the value of the Fraction
is actually an integer).
assert n == 4 | ||
|
||
def test_validate_int_bad1(self): | ||
@pytest.mark.parametrize('n', [4.0, np.array([4]), Fraction(4, 1)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I didn't notice that it was this strict. Some SciPy functions accept everything under the sun; this seems like a bit of a departure from the norm. Thoughts on why converting to an int
internally and checking for equality with the original is not good enough? (This is Python, right?)
@WarrenWeckesser Time to merge this, no? |
I've moved this from "draft" to "ready to review". The one test failure on TravisCI is the old I sent an email to the mailing list about this PR on Dec. 13, which triggered no discussion (and therefore no objections!). So I think this is ready. |
Thanks @WarrenWeckesser, @rlucas7! |
Thanks all. I added a note to the SciPy 1.7.0 release notes on the wiki. |
Add a new function,
binomtest
, similar tobinom_test
but that returns an object with both the estimated proportion and the p-value as attributes, and that has a method to compute the confidence interval of the estimated proportion.Also "doc-deprecate"
binom_test
.