Skip to content


Subversion checkout URL

You can clone with
Download ZIP


stats.distributions.gamma_gen constructor does not work (Trac #1316) #1842

scipy-gitbot opened this Issue · 3 comments

1 participant


Original ticket on 2010-10-19 by trac user JohnReid, assigned to unknown.

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

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,
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
--> 974 if extradoc.startswith('\n\n'):
975 extradoc = extradoc[2:]
976 self.__doc
= ''.join(['%s continuous random

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

The following patch fixes it:

Index: scipy/stats/

--- scipy/stats/ (revision 6845)
+++ scipy/stats/ (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,

See the thread:


@WarrenWeckesser wrote on 2010-10-19

Fixed in 44ca4c1. Thanks for reporting the problem!

Be aware that gamma_gen is not in distributions.__all__, so apparently it is not intended to be part of a public API.


@josef-pkt wrote on 2010-10-19

The distribution classes are not designed for direct usage. But they can still be part of a useful API for developers.

(The fact that they don't have an init method with the additional required information, e.g. bounds a, b, is a design mistake, in my opinion.)


Title changed from to stats.distributions.gamma_gen constructor does not work by @pv on 2010-11-28

@patvarilly patvarilly referenced this issue from a commit in patvarilly/scipy
@pbrod pbrod Fix for Ticket #1842 : wrong value returned by scipy.stats.binom prob…
…ability mass function when true probability is 1

+ a test for it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.