[Scipy-tickets] [SciPy] #1508: Bug that causes None to be accessed if a distribution is not named

SciPy Trac scipy-tickets@scipy....
Fri Sep 2 14:46:11 CDT 2011


#1508: Bug that causes None to be accessed if a distribution is not named
-------------------------+--------------------------------------------------
 Reporter:  bestephe     |       Owner:  somebody   
     Type:  defect       |      Status:  new        
 Priority:  normal       |   Milestone:  Unscheduled
Component:  scipy.stats  |     Version:  0.9.0      
 Keywords:               |  
-------------------------+--------------------------------------------------
 It is not possible to create unnamed distributions.  Consider the
 following code:

     import scipy.stats

     dist = scipy.stats.rv_discrete(values=([0.25, 0.75], [0.5, 0.5]))

 This code produces the following error:

 > Traceback (most recent call last):
 >   File "<stdin>", line 1, in <module>
 >   File "/usr/lib64/python2.6/site-
 packages/scipy/stats/distributions.py", line 3779, in __init__
 >     if name[0] in ['aeiouAEIOU']: hstr = "An "
 > TypeError: 'NoneType' object is unsubscriptable

 The bugfix is simple.  Simply add in the necessary checks for `name is not
 None`.  Note: I have not tested the attached patch.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1508>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list