[SciPy-User] _construct_default_doc extradoc=None bug in latest svn of scipy.stats.distributions

John Reid j.reid@mail.cryst.bbk.ac...
Tue Oct 19 06:13:14 CDT 2010


Hi,

Using the latest scipy svn version (6845) I had the following ipython 
session:

In [1]: import scipy.stats.distributions

In [2]: scipy.stats.distributions.gamma_gen( name = 'gamma' )
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/john/local/src/<ipython console> in <module>()

/usr/local/lib/python2.6/dist-packages/scipy/stats/distributions.pyc in 
__init__(self, momtype, a, b, xa, xb, xtol, badvalue, name, longname, 
shapes, extradoc)
     963         # generate docstring for subclass instances

     964         if self.__doc__ is None:
--> 965             self._construct_default_doc(longname=longname, 
extradoc=extradoc)
     966         else:
     967             self._construct_doc()

/usr/local/lib/python2.6/dist-packages/scipy/stats/distributions.pyc in 
_construct_default_doc(self, longname, extradoc)
     972     def _construct_default_doc(self, longname=None, extradoc=None):
     973         """Construct instance docstring from the default 
template."""
--> 974         if extradoc.startswith('\n\n'):
     975             extradoc = extradoc[2:]
     976         self.__doc__ = ''.join(['%s continuous random 
variable.'%longname,

AttributeError: 'NoneType' object has no attribute 'startswith'


The following patch fixes it:

Index: scipy/stats/distributions.py
===================================================================
--- scipy/stats/distributions.py	(revision 6845)
+++ scipy/stats/distributions.py	(working copy)
@@ -971,6 +971,8 @@

      def _construct_default_doc(self, longname=None, extradoc=None):
          """Construct instance docstring from the default template."""
+        if None == extradoc:
+            extradoc = ""
          if extradoc.startswith('\n\n'):
              extradoc = extradoc[2:]
          self.__doc__ = ''.join(['%s continuous random variable.'%longname,



Is this the best forum to submit a patch to?

Thanks,
John.




More information about the SciPy-User mailing list