得到意外的关键字参数

时间:2017-05-24 22:41:00

标签: python-2.7

我正在尝试从PyNN网站练习示例。代码如下

import pyNN.brian as p
rng = p.NumpyRNG(seed = 4242)
refractory_period = p.RandomDistribution('uniform', [2.0, 3.0], rng)
ctx_parameters = {'cm': 0.25, 'tau_m': 20.0, 'v_rest': -60, 'v_thresh': -50, 'tau_refrac': refractory_period, 'v_reset': -60, 'v_spike': -50.0, 'a': 1.0, 'b': 0.005, 'tau_w': 600, 'delta_T': 2.5,'tau_syn_E': 5.0, 'e_rev_E': 0.0, 'tau_syn_I': 10.0, 'e_rev_I': -80 }
tc_parameters = ctx_parameters.copy()
tc_parameters.update({'a': 20.0, 'b': 0.0})
thalamocortical_type = p.EIF_cond_exp_isfa_ista(**tc_parameters)

此时我收到错误消息:

Traceback (most recent call last):
  File "/home/ruthvik/Desktop/Summer 2017/pynncheck.py", line 7, in <module>
    thalamocortical_type = p.EIF_cond_exp_isfa_ista(**tc_parameters)
TypeError: __init__() got an unexpected keyword argument 'tau_refrac'

我实际检查了pyNN github页面,我意识到实际上有一个名为EIF_cond_exp_isfa_ista的类,它还有参数&#39; tau_refrac&#39;。我对python类和面向对象不太满意。如果有人可以指导这一点,那将是一个很大的帮助 编辑:

我定义了c = p.EIF_cond_exp_isfa_ista。我执行了

c.get_parameter_names()
['tau_refrac', 'a', 'tau_m', 'e_rev_E', 'i_offset', 'cm', 'delta_T', 'e_rev_I', 'v_thresh', 'b', 'tau_syn_E', 'v_reset', 'v_spike', 'tau_syn_I', 'tau_w', 'v_rest'] 

这给出了上述结果。我试着这样做

getattr(c,'cm')

Traceback (most recent call last):
File "<pyshell#55>", line 1, in <module>
getattr(c,'cm')
AttributeError: type object 'EIF_cond_exp_isfa_ista' has no attribute 'cm'

我看到有一个名为&#39; cm&#39;但是getattr(c,&#39; cm&#39;)正在抛出一个错误。我想我在这里遗漏了一些东西。

0 个答案:

没有答案