Changeset 410
- Timestamp:
- 07/14/08 16:08:37 (1 month ago)
- Files:
-
- trunk/src/common.py (modified) (6 diffs)
- trunk/test/unittests/nest2tests.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/common.py
r408 r410 125 125 def set_parameters(self, **parameters): 126 126 """Set cell parameters, given as a sequence of parameter=value arguments.""" 127 # all_parameters = self.get_parameters()128 # all_parameters.update(parameters)127 # if some of the parameters are computed from the values of other 128 # parameters, need to get and translate all parameters 129 129 if self.is_standard_cell(): 130 computed_parameters = self.cellclass.computed_parameters() 131 have_computed_parameters = any([p_name in computed_parameters for p_name in parameters]) 132 if have_computed_parameters: 133 all_parameters = self.get_parameters() 134 all_parameters.update(parameters) 135 parameters = all_parameters 130 136 parameters = self.cellclass.translate(parameters) 131 137 self.set_native_parameters(parameters) … … 315 321 parameters = cls.checkParameters(parameters, with_defaults=False) 316 322 native_parameters = {} 317 for name,value in parameters.items(): 318 D = cls.translations[name] 319 #for name,D in cls.translations.items(): 323 for name in parameters: 324 D = cls.translations[name] 320 325 pname = D['translated_name'] 321 326 try: 322 327 pval = eval(D['forward_transform'], globals(), parameters) 323 except NameError :324 raise Exception(" %s in %s. Transform: %s. Parameters: %s." \325 % (pname, cls.__name__, D['forward_transform'], parameters ))328 except NameError, errmsg: 329 raise Exception("Problem translating %s in %s. Transform: %s. Parameters: %s. %s" \ 330 % (pname, cls.__name__, D['forward_transform'], parameters, errmsg)) 326 331 except ZeroDivisionError: 327 332 pval = 1e30 # this is about the highest value hoc can deal with … … 1293 1298 class FromListConnector(Connector): 1294 1299 """ 1295 Connects all cells in the presynaptic population to all cells in the 1296 postsynaptic population. 1300 Make connections according to a list. 1297 1301 """ 1298 1302 … … 1304 1308 class FromFileConnector(Connector): 1305 1309 """ 1306 Connects all cells in the presynaptic population to all cells in the 1307 postsynaptic population. 1310 Make connections according to a list contained in a file. 1308 1311 """ 1309 1312 … … 1316 1319 class FixedNumberPostConnector(Connector): 1317 1320 """ 1318 Each p ostsynaptic cell receives a fixed number of connections, chosen1319 randomly from the presynaptic cells.1321 Each pre-synaptic neuron is connected to exactly n post-synaptic neurons 1322 chosen at random. 1320 1323 """ 1321 1324 … … 1337 1340 class FixedNumberPreConnector(Connector): 1338 1341 """ 1339 Connects all cells in the postsynaptic population to fixed number of1340 c ells in the presynaptic population, randomly choosen.1342 Each post-synaptic neuron is connected to exactly n pre-synaptic neurons 1343 chosen at random. 1341 1344 """ 1342 1345 def __init__(self, n, allow_self_connections=True, weights=0.0, delays=None): trunk/test/unittests/nest2tests.py
r396 r410 610 610 self.pop1 = nest.Population((5,),nest.IF_curr_alpha,{'tau_m':10.0}) 611 611 self.pop2 = nest.Population((5,4),nest.IF_curr_exp,{'v_reset':-60.0}) 612 self.pop3 = nest.Population((10,), nest.IF_cond_alpha) 612 613 613 614 def testIDSetAndGet(self): 614 615 self.pop1[3].tau_m = 20.0 615 616 self.pop2[3,2].v_reset = -70.0 617 self.pop3[5].tau_m = -55.0 616 618 ifcell_params = nest.nest.GetStatus([self.pop1[3]])[0] 617 619 self.assertEqual(20.0, ifcell_params['tau_m']) … … 620 622 self.assertEqual(-70.0, self.pop2[3,2].v_reset) 621 623 self.assertEqual(-60.0, self.pop2[0,0].v_reset) 624 self.assertAlmostEqual(-55.0, self.pop3[5].tau_m, 9) 622 625 623 626 def testGetCellClass(self):
