Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7082)

Issue 7913: percentileofscore - rewrite?

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 5 months ago by arokem
Modified:
9 years, 4 months ago
Reviewers:
stefanv
Base URL:
http://svn.scipy.org/svn/scipy/trunk/
Visibility:
Public.

Description

Following ticket #560: http://projects.scipy.org/scipy/scipy/ticket/560 rewrote percentileofscore without using "histogram". The function now assigns a percentile by the relative location of the input relative to an array, when the array is sorted.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+36 lines, -11 lines) Patch
M scipy/stats/stats.py View 1 chunk +36 lines, -11 lines 8 comments Download

Messages

Total messages: 2
stefanv
Ariel, thanks for your work on this! I hope to see your patch included in ...
15 years, 5 months ago (2008-11-16 14:12:20 UTC) #1
arokem
15 years, 5 months ago (2008-11-22 06:34:29 UTC) #2
Stefan - I have changed the code according to your comments. Can you take a look
at it now? 

Cheers -- Ariel 


On 2008/11/16 14:12:20, Stefan wrote:
> Ariel, thanks for your work on this!  I hope to see your patch included in
0.7.
> 
> http://codereview.appspot.com/7913/diff/1/2
> File scipy/stats/stats.py (right):
> 
> http://codereview.appspot.com/7913/diff/1/2#newcode1017
> Line 1017: def percentileofscore(a, score):
> Thanks for the rewrite.  The new implementation is much cleaner!  Please add
> some tests to verify behaviour.
> 
> http://codereview.appspot.com/7913/diff/1/2#newcode1020
> Line 1020: 
> Let's rephrase this sentence for clarity, and add an extended description as
> well.  Something like (please improve)
> 
> Percentile of a score.
> 
> The percentile of a score is the number of values smaller than or equal to the
> score.  For example, if you score in the 80th percentile, it means that 80% of
> the class had a mark that was the same as or lower than yours.
> 
> http://codereview.appspot.com/7913/diff/1/2#newcode1024
> Line 1024: 
> a : ndarray
> 
> http://codereview.appspot.com/7913/diff/1/2#newcode1026
> Line 1026: 
> score : float or int
> 
> http://codereview.appspot.com/7913/diff/1/2#newcode1033
> Line 1033: 
> Remove blank line.
> 
> Add a simpler example, e.g.:
> 
> >>> percentileofscore([20,80,100],80)
> 
> Woops -- bug!
> 
> http://codereview.appspot.com/7913/diff/1/2#newcode1035
> Line 1035: >>> percentileofscore(a,101.0)
> Spacing, see blow.
> 
> http://codereview.appspot.com/7913/diff/1/2#newcode1051
> Line 1051: idx=[a==score]
> Please refer to PEP8 for spacing guidelines:
> 
> a = np.sort(a)
> a_len = np.array(range(len(a)))
> idx = [a == score]
> 
> http://codereview.appspot.com/7913/diff/1/2#newcode1053
> Line 1053: pct = (np.mean(a_len[idx])/(len(a)-1))*100.
> Bug is in this line:
> 
> len(a)-1 should be used only if `score` was appended!
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b