in the thinkstats.py module, the Trim function creates a (documented) side
effect of sorting the sequence that is passed in as a parameter. Instead of
using the sort() method on the list, use the sorted builtin to sort the values
into another array.
Existing code --
def Trim(t, p=0.01):
t.sort()
n = int(p * len(t))
t = t[n:-n]
return t
Proposed code --
def Trim(t, p=0.01):
sorted_t = sorted(t)
n = int(p * len(sorted_t))
return sorted_t[n:-n]
Of course, the comments and documentation would have to be updated as well.
Original issue reported on code.google.com by gbre...@gmail.com on 7 Sep 2012 at 2:47
Original issue reported on code.google.com by
gbre...@gmail.com
on 7 Sep 2012 at 2:47