[Python-checkins] python/nondist/sandbox/statistics statistics.py,
1.3, 1.4
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Feb 15 03:25:22 EST 2004
Update of /cvsroot/python/python/nondist/sandbox/statistics
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6713
Modified Files:
statistics.py
Log Message:
More small improvements
Index: statistics.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/statistics/statistics.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** statistics.py 15 Feb 2004 07:22:33 -0000 1.3
--- statistics.py 15 Feb 2004 08:25:20 -0000 1.4
***************
*** 97,101 ****
ua, nua = under.append, notunder.append
it = iter(iterable)
! pivot = it.next() # must have at least one element
for elem in it:
if elem < pivot:
--- 97,101 ----
ua, nua = under.append, notunder.append
it = iter(iterable)
! pivot = it.next() # must have at least one element
for elem in it:
if elem < pivot:
***************
*** 107,113 ****
def select(data, n):
"""Find the nth rank ordered element (the least value has rank 0)."""
! if len(data) <= n:
raise ValueError('not enough elements for the given rank')
! while 1:
p, pivot, q = _partition(data)
if n < len(p):
--- 107,118 ----
def select(data, n):
"""Find the nth rank ordered element (the least value has rank 0)."""
! try:
! size = len(data)
! except TypeError:
! data = tuple(data)
! size = len(data)
! if size <= n:
raise ValueError('not enough elements for the given rank')
! while True:
p, pivot, q = _partition(data)
if n < len(p):
***************
*** 126,130 ****
n = len(data)
except TypeError:
! data = list(data)
n = len(data)
if n == 0:
--- 131,135 ----
n = len(data)
except TypeError:
! data = tuple(data)
n = len(data)
if n == 0:
***************
*** 138,142 ****
return reduce(operator.mul, iterable, 1)
! def nlargest(iterable, n=1): # XXX key= or cmp= argument
"""Find the n largest elements in the dataset"""
## When collections.fibheap is available, use it instead of heapq
--- 143,147 ----
return reduce(operator.mul, iterable, 1)
! def nlargest(iterable, n=1): # XXX implement key=
"""Find the n largest elements in the dataset"""
## When collections.fibheap is available, use it instead of heapq
More information about the Python-checkins
mailing list