Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

scipy.stats.scoreatpercentile backward-incompatible change not in release notes #3329

Closed
danstowell opened this Issue · 5 comments

4 participants

@danstowell

Hi - I was just bitten by a difference between scipy 0.11 and 0.13 in the behaviour of scipy.stats.scoreatpercentile. It seems to be due to 0.12 adding an "axis" argument to the function, which is great but leads to this change in behaviour:

     import numpy as np
     from scipy.stats import scoreatpercentile
     scoreatpercentile(np.eye(5), 50)

On my laptop with scipy 11.0 (and numpy 1.7.1) the answer is:

     array([ 0.,  0.,  0.,  0.,  0.])

On our lab machine with scipy 13.3 (and numpy 1.7.0) the answer is:

     0.0

I don't know the scipy development process but I believe this change should be in the release notes somewhere, though it isn't - I would suggest it should be in the 0.12 backward-incompatible changes. Does the development team update release notes for this kind of omission?

@josef-pkt
Collaborator

This looks like a bug in 0.12, 0.13 to me.
scipy.stats is supposed to have and keep axis=0 as default, and not inherit or switch to the numpy default of raveling.
Data are usually in columns, traditionally in Stats

@rgommers rgommers added this to the 0.14.0 milestone
@rgommers
Owner

Offending commit: 1cdd08b. Kind of painful to go back to axis=0 though, given that the current behavior has been in place for two releases and that the Notes explicitly say that this function will be replaced by np.percentile which has axis=None.

@rgommers
Owner

Hmm, this testcase was made with the right intention:

def test_2D(self):
    x = array([[1, 1, 1],
               [1, 1, 1],
               [4, 4, 3],
               [1, 1, 1],
               [1, 1, 1]])
    assert_array_equal(stats.scoreatpercentile(x, 50), [1, 1, 1])

Unfortunately it still passes because the scalar return broadcasts.

@rgommers rgommers modified the milestone: 0.15.0, 0.14.0
@WarrenWeckesser
Collaborator

Kind of painful to go back to axis=0 though, given that the current behavior has been in place for two releases and that the Notes explicitly say that this function will be replaced by np.percentile which has axis=None.

Agreed. Let's leave it as is, and retroactively add a note about the change to the 0.12 release notes, as @danstowell has suggested. I'll get a PR started.

@WarrenWeckesser WarrenWeckesser referenced this issue from a commit in WarrenWeckesser/scipy
@WarrenWeckesser WarrenWeckesser MAINT: stats: Add note about change to scoreatpercentile in release 0…
….12.0.

Also make a test of scoreatpercentile on a 2D array more explicit
about the expected result.

Closes gh-3329.
b60daa6
@WarrenWeckesser
Collaborator

Pull request is #4058

@pv pv closed this in #4058
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.