Changeset 95
- Timestamp:
- 06/07/07 09:54:45 (1 year ago)
- Files:
-
- branches/improved-ID/common.py (modified) (3 diffs)
- branches/improved-ID/nest.py (modified) (3 diffs)
- branches/improved-ID/test/nesttests.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/improved-ID/common.py
r94 r95 58 58 object.__setattr__(self,name,value) 59 59 else: 60 return _abstractMethod(self)60 return self.set(**{name:value}) 61 61 62 62 def _set_cellclass(self, cellclass): … … 68 68 def _get_cellclass(self): 69 69 if self.parent: 70 return self.parent.celltype 70 return self.parent.celltype.__class__ 71 71 else: 72 72 return self._cellclass … … 96 96 position = property(_get_position, _set_position) 97 97 98 def set(self,**parameters): 99 """Set cell parameters, given as a sequence of parameter=value arguments.""" 100 return _abstractMethod(self) 98 101 99 102 # ============================================================================== branches/improved-ID/nest.py
r94 r95 39 39 return pynest.getDict([int(self)])[0][translated_name] 40 40 41 def set(self, param,val=None):41 def set(self,**parameters): 42 42 # We perform a call to the low-level function set() of the API. 43 43 # If the cellclass is not defined in the ID object : 44 if (self. _cellclass == None):44 if (self.cellclass == None): 45 45 raise Exception("Unknown cellclass") 46 46 else: 47 47 # We use the one given by the user 48 set(self, self._cellclass,param,val)48 set(self, self.cellclass, parameters) 49 49 50 50 … … 294 294 giving the parameter name, in which case val is the parameter value. 295 295 cellclass must be supplied for doing translation of parameter names.""" 296 296 # we should just assume that cellclass has been defined and raise an Exception if it has not 297 297 if val: 298 298 param = {param:val} … … 891 891 population is scaled to the size of the source population.""" 892 892 dist = 0.0 893 src_position = src. getPosition()894 tgt_position = tgt. getPosition()893 src_position = src.position 894 tgt_position = tgt.position 895 895 if (len(src_position) == len(tgt_position)): 896 896 for i in xrange(len(src_position)): branches/improved-ID/test/nesttests.py
r86 r95 482 482 #assert (self.target33[0,2].get('tau_m') == 15.1) 483 483 484 def testSetAndGetPositionID(self):485 # Small test to see if the position of the ID class is working486 self.target33[0,2].setPosition((0.5,1.5))487 assert (self.target33[0,2].getPosition() == (0.5,1.5))488 489 484 def testrandomizeWeights(self): 490 485 # The probability of having two consecutive weights vector that are equal should be 0 … … 517 512 nest.setup(max_delay=0.5) 518 513 nest.Population.nPop = 0 519 self.pop = nest.Population((5,),nest.IF_curr_alpha,{'tau_m':10.0}) 520 521 def testIDSet(self): 522 self.pop[3].set('tau_m',20.0) 523 ifcell_params = nest.pynest.getDict([self.pop[3]])[0] 514 self.pop1 = nest.Population((5,),nest.IF_curr_alpha,{'tau_m':10.0}) 515 self.pop2 = nest.Population((5,4),nest.IF_curr_exp,{'v_reset':-60.0}) 516 517 def testIDSetAndGet(self): 518 self.pop1[3].tau_m = 20.0 519 self.pop2[3,2].v_reset = -70.0 520 ifcell_params = nest.pynest.getDict([self.pop1[3]])[0] 524 521 self.assertEqual(20.0, ifcell_params['Tau']) 525 ifcell_params = nest.pynest.getDict([self.pop[1]])[0] 526 self.assertEqual(10.0, ifcell_params['Tau']) 522 self.assertEqual(20.0, self.pop1[3].tau_m) 523 self.assertEqual(10.0, self.pop1[0].tau_m) 524 self.assertEqual(-70.0, self.pop2[3,2].v_reset) 525 self.assertEqual(-60.0, self.pop2[0,0].v_reset) 526 527 def testGetCellClass(self): 528 self.assertEqual(nest.IF_curr_alpha, self.pop1[0].cellclass) 529 self.assertEqual(nest.IF_curr_exp, self.pop2[4,3].cellclass) 530 531 def testSetAndGetPosition(self): 532 self.assert_((self.pop2[0,2].position == (0.0,2.0,0.0)).all()) 533 new_pos = (0.5,1.5,0.0) 534 self.pop2[0,2].position = new_pos 535 self.assert_((self.pop2[0,2].position == (0.5,1.5,0.0)).all()) 536 new_pos = (-0.6,3.5,-100.0) # check that position is set-by-value from new_pos 537 self.assert_((self.pop2[0,2].position == (0.5,1.5,0.0)).all()) 538 527 539 528 540 if __name__ == "__main__":

