Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
scipy-gitbot opened this Issue · 3 comments

1 participant

@scipy-gitbot

Original ticket http://projects.scipy.org/scipy/ticket/1316 on 2010-10-19 by trac user JohnReid, assigned to unknown.

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,

See the thread:
http://permalink.gmane.org/gmane.comp.python.scientific.user/26578

@scipy-gitbot

@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.

@scipy-gitbot

@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.)

@scipy-gitbot

Title changed from j.reid@mail.cryst.bbk.ac.uk 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.
c4b390b
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.