scipy.stats.scoreatpercentile broken for vector `per` #2861

pkgw opened this Issue Sep 13, 2013 · 4 comments


None yet
3 participants

pkgw commented Sep 13, 2013

This issue is an exact analog of numpy 3733, because the code between these this function and np.percentile is mostly duplicated.

scoreatpercentile claims to function with the per argument (the percentiles to calculate) being either a scalar or an array_like. However, the initial lines of code do:

if per == 0:
    return a.min(axis=axis, out=out)
elif per == 100:
    return a.max(axis=axis, out=out)

which of course breaks with a "truth value of array undefined" exception if per is in fact an ndarray. It doesn't break if per is a list, since per isn't coerced to array-ness, but that's just two bugs canceling.

From an initial reading, I think the implementations of these two functions could be merged. np.concatenate could be given an interpolate_method argument like scoreatpercentile, and then scipy.stats.scoreatpercentile could just become an alias for the Numpy function.


josef-pkt commented Sep 13, 2013

clearly a bug

unit tests only use lists for per

pkgw commented Sep 13, 2013

The PR numpy/numpy#3658 solves this problem in Numpy and also takes steps toward potentially unifying the implementations.


josef-pkt commented Sep 13, 2013

scipy will not be able to use this implementation for a while because the underlying partition function is also new in numpy. scipy still is compatible with older versions of numpy.

So, it would still be better to fix this issue until we can use the new numpy function. IMO


rgommers commented Jan 4, 2014

Fixed by gh-3186.

@rgommers rgommers closed this in 07bd6eb Jan 31, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment