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

josef.pktd@gmai... josef.pktd@gmai...
Tue Oct 19 08:55:18 CDT 2010


On Tue, Oct 19, 2010 at 7:13 AM, John Reid <j.reid@mail.cryst.bbk.ac.uk> wrote:
> 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?

It's good to report it here, but you could also open a ticket at
http://projects.scipy.org/scipy

It's clearly a bug, I think, it's also be possible to do

def _construct_default_doc(self, longname=None, extradoc='')

but I haven't looked at the source yet.

Thanks for catching and reporting this. I never tried an example that
didn't have extradoc defined.

Josef


>
> Thanks,
> John.
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list