def testConnectTwoCells(self): """connect(): The first connection created should have id 0.""" neuron.hoc_comment("=== ConnectionTest.testConnectTwoCells ===") conn = neuron.connect(self.precells[0], self.postcells[0]) # conn will be an empty list if it does not exist on that node assert conn == [ 0 ] or conn == [], 'Error creating connection, conn=%s' % conn
def testCreateStandardCellsWithNegative_n(self): """create(): n must be positive definite""" neuron.hoc_comment( '=== CreationTest.testCreateStandardCellsWithNegative_n ===') self.assertRaises(AssertionError, neuron.create, neuron.IF_curr_alpha, n=-1)
def tearDown(self): neuron.hoc_comment("=== ConnectionTest.tearDown() ===") hoc_commands = ['objref cell%d\n' % i for i in neuron.gidlist] hoc_commands += ['netconlist = new List()'] neuron.hoc_execute(hoc_commands, '=== ConnectionTest.tearDown() ===') neuron.gid = 0 neuron.ncid = 0 neuron.gidlist = []
def testCreateNEURONCell(self): """create(): First cell created should have index 0.""" neuron.hoc_comment('=== CreationTest.testCreateNEURONCell ===') ifcell = neuron.create('StandardIF', { 'syn_type': 'current', 'syn_shape': 'exp' }) assert ifcell == 0, 'Failed to create NEURON-specific cell'
def testSetFloat(self): neuron.hoc_comment("=== SetValueTest.testSetFloat() ===") neuron.set(self.cells, 'tau_m', 35.7) for cell in self.cells: try: assert getattr(h, 'cell%d' % cell).tau_m == 35.7 except AttributeError: # if cell is not on this node pass
def testConnectTwoCellsWithWeight(self): """connect(): Weight set should match weight retrieved.""" neuron.hoc_comment( "=== ConnectionTest.testConnectTwoCellsWithWeight() ===") conn_id = neuron.connect(self.precells[0], self.postcells[0], weight=0.1234) if conn_id: weight = h.netconlist.object(conn_id[0]).weight[0] assert weight == 0.1234, "Weight set (0.1234) does not match weight retrieved (%s)" % weight
def testCreateStandardCellWithParams(self): """create(): Parameters set on creation should be the same as retrieved with the top-level HocObject""" neuron.hoc_comment( '=== CreationTest.testCreateStandardCellWithParams ===') ifcell = neuron.create(neuron.IF_curr_alpha, {'tau_syn_E': 3.141592654}) #self.assertAlmostEqual(HocToPy.get('cell%d.esyn.tau' % ifcell, 'float'), 3.141592654, places=5) try: self.assertAlmostEqual(getattr(h, 'cell%d' % ifcell).esyn.tau, 3.141592654, places=5) except AttributeError: # if the cell is not on that node pass
def setUp(self): neuron.hoc_comment("=== ConnectionTest.setUp() ===") self.postcells = neuron.create(neuron.IF_curr_alpha, n=3) self.precells = neuron.create(neuron.SpikeSourcePoisson, n=5)
def testCreateStandardCells(self): """create(): Creating multiple cells should return a list of integers""" neuron.hoc_comment('=== CreationTest.testCreateStandardCells ===') ifcells = neuron.create(neuron.IF_curr_alpha, n=10) assert ifcells == range(0, 10), 'Failed to create 10 standard cells'
def testCreateStandardCell(self): """create(): First cell created should have index 0.""" neuron.hoc_comment('=== CreationTest.testCreateStandardCell() ===') ifcell = neuron.create(neuron.IF_curr_alpha) assert ifcell == 0, 'Failed to create standard cell'