jackscott / python-statlib

Exported from google.code, needed to get this crusty code working in a modern world
https://archive.org/web/
Other
0 stars 0 forks source link

stats.median() can't handle 0- or 1-item arrays #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
>>> from statlib import stats
>>> stats.median([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.7-i386/egg/statlib/stats.py", line 288, in __call__
  File "build/bdist.macosx-10.7-i386/egg/statlib/stats.py", line 349, in lmedian
ValueError: min() arg is an empty sequence
>>> stats.median([1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.7-i386/egg/statlib/stats.py", line 288, in __call__
  File "build/bdist.macosx-10.7-i386/egg/statlib/stats.py", line 355, in lmedian
UnboundLocalError: local variable 'cfbin' referenced before assignment
>>>

Original issue reported on code.google.com by fro...@gmail.com on 29 Jan 2010 at 12:02

GoogleCodeExporter commented 8 years ago
It is not obvious what it should return so maybe it is best if it fails rather 
then
return something unexpected.

Original comment by istvan.a...@gmail.com on 29 Jan 2010 at 1:34