Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: John Reid <j.reid <at> mail.cryst.bbk.ac.uk>
Subject: _construct_default_doc extradoc=None bug in latest svn of scipy.stats.distributions
Newsgroups: gmane.comp.python.scientific.user
Date: Tuesday 19th October 2010 11:13:14 UTC (over 6 years ago)
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/ in ()

/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.
 
CD: 19ms