[SciPy-user] **kwds in frozen distribution class
joep
josef.pktd at gmail.com
Fri Sep 12 11:17:07 EDT 2008
I was trying to work on an example for the frozen distribution class,
in response to the previous message by Michael.
The change in method signature between frozen and not frozen class got
me
confused:
I looked at the information in
help(stats.norm.stats)
and did not realize that the signature in
help(stats.norm(loc = 10, scale = 10).stats) or help(stats.norm(loc =
10, scale = 10))
is different.
Given the description it does what it says, but I think it would be
easy to
make the keyword arguments consistent between frozen and not frozen
distribution
The frozen distribution class does not take any additional keywords
-------------------------------------------------------------------
e.g.
>>> from scipy import stats
>>> stats.norm.stats(loc = 10, scale = 10, moments='v')
array(100.0)
>>> stats.norm(loc = 10, scale = 10).stats(moments='v')
Traceback (most recent call last):
File "<pyshell#91>", line 1, in ?
stats.norm(loc = 10, scale = 10).stats(moments='v')
TypeError: stats() got an unexpected keyword argument 'moments'
>>> stats.norm(loc = 10, scale = 10, moments='v').stats()
array(100.0)
line numbers from current trunk
(http://projects.scipy.org/scipy/scipy/browser/trunk/scipy/stats/
distributions.py)
101 # Frozen RV class
102 class rv_frozen(object):
121 def stats(self):
122 return self.dist.stats(*self.args,**self.kwds)
I think this change should work to accept additional keywords:
121 def stats(self,**kwds):
kwds.update(self.kwds)
122 return self.dist.stats(*self.args,**kwds)
Josef
More information about the SciPy-User
mailing list