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: Fix mannwhitneyu to be backward compatible #6100
Conversation
01ba5cd
to
8018324
Compare
OK, I eyeballed the It'd be nice to have one other pair of eyeballs on this, since this is the last issue blocking the release of 0.17.1. |
|
||
assert_equal(p1, p2) | ||
assert_equal(u1, 498) | ||
assert_equal(u2, 102) | ||
assert_equal(u2, 498) | ||
assert_equal(u3, 102) | ||
assert_approx_equal(p1, 0.999955905990004, significant=self.significant) | ||
|
||
def test_mannwhitneyu_no_correct_greater(self): |
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.
It looks to me this test and the previous one could be merged because they overlap
(streamlining, minor point)
reading briefly through the changes. For the statistic: returning |
I tend to not use the functions defined in the stats.py file, but I just github-code-searched 'mannwhitneyu' and found BlueBrain/NeuroM#220 (comment). Is that somehow relevant? Also scikit-bio/scikit-bio#1258 (comment). |
BlueBrain wasn't reading the docstring. It's not a bug if it's weird but documented how to interpret it. |
I've updated the code to return Pre- Does that sound appropriate? Note that #4933 currently returns I also merged the I'll rebase once we're settled on this. |
Naively, I'd suggest to keep the invariant of "Nove means whatever scipy 0.16.1 is doing, down to all the minute detail." I've been proven wrong on this one though, so I won't press the point. |
And then make #4933 return the most useful output. |
We can return |
I have both opinions:
just pick one :) (I'm low in making-up-my-mind capacity when I'm 50-50. I'm slow in several PRs in statsmodels because of it. Should we return one large or two small arrays? I have no idea which is better for future enhancments.) |
Whoops, cross-posted with @josef-pkt. I'll go ahead and make it fully backward compatible. |
stick with backwards compatibility I think, smallu can be used as a statistic for permutation or bootstrap tests. I think it's monotonic with respect to the two sided alternative. I just see @tavinathanson comment. Backwards compatibility in the |
actually that sounds good In this case, we could even just deprecate |
@josef-pkt Are you suggesting that we add a deprecation warning for the I'm in favor of deprecating as soon as possible. |
I thought of mentioning it in the docstring as it already is, should be enough for now, given the uncertain future with #4933 However with the None, we have now a deprecation path just for |
@ev-br What are your thoughts on deprecating the |
Defaults to None, which results in a p-value half the size of | ||
the 'two-sided' p-value and a different U statistic. The default | ||
behavior is not the same as using 'less' or 'greater', is not | ||
recommended, and will soon be deprecated. |
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'd recommend to avoid making definite statements about the future like this :-). Maybe better state that it only exists for backwards compatibility and is not recommended for use in any new code.
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.
Ah, yes, that makes sense. Given that I just included a DeprecationWarning
, I needed to change this wording anyway.
I'm more or less on the fence on whether |
@ev-br I agree that it's non-ideal for users to adjust multiple times. However, given the changes in this function between pre- I updated the code with And yeah, I'd be happy to help out with #4933. |
LGTM. |
That'd be superb! |
70bbb67
to
dccd070
Compare
|
||
return MannwhitneyuResult(u2, distributions.norm.sf(z) * fact2) | ||
u = u2 | ||
# This behavior will soon be deprecated. |
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.
Whoops, this line still needs to be updated.
dccd070
to
b9c60fd
Compare
Looks fine to me, no more comments from my side. |
OK, let's put this in. Thank you @tavinathanson, Josef, Alex. |
Per #6062,
mannwhitneyu
is no longer backward compatible as of0.17.0
. This PR is meant as a0.17.1
fix beforemannwhitneyu
eventually gets deprecated in 0.18.In this PR, all changes were meant to revert to pre-
0.17.0
defaults:alternative = None
which revertsmannwhitneyu
's behavior to pre-0.17.0
. Default toNone
.MannwhitneyuResult
to always return the appropriate U statistic; it was returningu2
regardless ofless
orgreater
. (Edit: I'm told it should indeed returnu2
, and I updated it accordingly.)