avatarzhang / python-statlib

Automatically exported from code.google.com/p/python-statlib
Other
0 stars 0 forks source link

stats.median fails on some specific inputs #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

from statlib import stats
stats.median([1,2,3,3,3])

What is the expected output? What do you see instead?
I expect "3", but get this exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/statlib-1.1-py2.6.egg/statlib/stats.py", line 288, in __call__
    return apply(self._dispatch[type(arg1)], (arg1,) + args, kw)
  File "/usr/local/lib/python2.6/dist-packages/statlib-1.1-py2.6.egg/statlib/stats.py", line 355, in lmedian
    LRL = smallest + binsize*cfbin        # get lower read limit of that bin
UnboundLocalError: local variable 'cfbin' referenced before assignment

What version of the product are you using? On what operating system?
version 1.1 on Ubuntu 10.10

Please provide any additional information below.

It seems to fail whenever the median value is also the largest?

Original issue reported on code.google.com by thejohnn...@gmail.com on 12 Jan 2011 at 7:26

GoogleCodeExporter commented 8 years ago
The bug still persists on Ubuntu 14.04

Original comment by luis.lei...@gmail.com on 30 Jan 2015 at 12:37