【发布时间】:2014-06-12 16:51:49
【问题描述】:
我正在尝试为 PyMC 2.3 复制documentations 中给出的示例:
@pm2.stochastic(dtype=int)
def switchpoint(value=1900, t_l=1851, t_h=1962):
"""The switchpoint for the rate of disaster occurrence."""
if value > t_h or value < t_l:
# Invalid values
return -np.inf
else:
# Uniform log-likelihood
return -np.log(t_h - t_l + 1)
当试图分配这个时:
test = switchpoint()
我收到了错误信息(完整的错误信息在本文末尾):
TypeError: 'numpy.ndarray' 对象不可调用
我猜这是兼容性问题;我正在使用 Enthought Canopy Python 2.7.6(64 位)发行版。 Numpy 版本 1.8.0 和 Scipy 0.13.3。
谁能帮我找出问题所在?
注意:我在 google 群组上发现了一个相对较小的 old thread,显然存在同样的问题。但是该线程没有关于问题状态的更新。
这是完整的错误信息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/arash/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/CommonDeterministics.py", line 975, in __call__
plot=False)
File "/Users/arash/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/PyMCObjects.py", line 435, in __init__
verbose=verbose)
File "/Users/arash/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/Node.py", line 216, in __init__
Node.__init__(self, doc, name, parents, cache_depth, verbose=verbose)
File "/Users/arash/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/Node.py", line 127, in __init__
self.parents = parents
File "/Users/arash/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/Node.py", line 150, in _set_parents
self.gen_lazy_function()
File "/Users/arash/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/PyMCObjects.py", line 446, in gen_lazy_function
self._value.force_compute()
File "LazyFunction.pyx", line 257, in pymc.LazyFunction.LazyFunction.force_compute (pymc/LazyFunction.c:2409)
File "/Users/arash/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/CommonDeterministics.py", line 967, in eval_fun
return self(*args, **kwargs)
TypeError: 'numpy.ndarray' object is not callable
【问题讨论】: