def testDestroySegment(self): cell1 = Cell() segment1 = cell1.createSegment() self.assertEqual(segment1.cell, cell1) segment2 = cell1.createSegment() self.assertEqual(segment2.cell, cell1) cell2 = Cell() synapse1 = segment1.createSynapse(presynapticCell=cell2, permanence=0.1173) self.assertEqual(synapse1.presynapticCell, cell2) self.assertEqual(synapse1.permanence, 0.1173) cell3 = Cell() synapse2 = segment1.createSynapse(presynapticCell=cell3, permanence=0.3253) self.assertEqual(synapse2.presynapticCell, cell3) self.assertEqual(synapse2.permanence, 0.3253) cell4 = Cell() synapse3 = segment2.createSynapse(presynapticCell=cell4, permanence=0.1284) self.assertEqual(synapse3.presynapticCell, cell4) self.assertEqual(synapse3.permanence, 0.1284) cell1.destroySegment(segment1) # TODO: self.assertFalse('segment1' in locals()) # TODO: self.assertFalse('synapse1' in locals()) # TODO: self.assertFalse('synapse2' in locals()) self.assertEqual(cell2.postsynapticCellsSynapses, set([])) self.assertEqual(cell3.postsynapticCellsSynapses, set([])) self.assertEqual(cell4.postsynapticCellsSynapses, set([synapse3])) self.assertEqual(cell1.segments, set([segment2]))
def testCreateSegment(self): cell1 = Cell() self.assertEqual(cell1.segments, set()) segment1 = cell1.createSegment() self.assertEqual(segment1.cell, cell1) segment2 = cell1.createSegment() self.assertEqual(segment2.cell, cell1) self.assertEqual(cell1.segments, set([segment1, segment2]))
def testCreateSynapseInvalidParams(self): cell1 = Cell() segment1 = cell1.createSegment() # Invalid permanence args = [cell1, None, 1.124] self.assertRaises(ValueError, segment1.createSynapse, *args) args = [cell1, None, -0.124] self.assertRaises(ValueError, segment1.createSynapse, *args)
def testSynapseSetPermanence(self): cell1 = Cell() segment1 = cell1.createSegment() synapse = segment1.createSynapse(presynapticCell=Cell(), permanence=0.1284) # Invalid permanence args = [1.4374] self.assertRaises(ValueError, setattr, synapse, "permanence", *args) args = [-0.4374] self.assertRaises(ValueError, setattr, synapse, "permanence", *args)
def testCreateSynapse(self): cell1 = Cell() segment1 = cell1.createSegment() self.assertEqual(segment1.synapses, set()) cell2 = Cell() synapse1 = segment1.createSynapse(presynapticCell=cell2, permanence=0.1173) self.assertEqual(synapse1.presynapticCell, cell2) self.assertEqual(synapse1.permanence, 0.1173) cell3 = Cell() synapse2 = segment1.createSynapse(presynapticCell=cell3, permanence=0.3253) self.assertEqual(synapse2.presynapticCell, cell3) self.assertEqual(synapse2.permanence, 0.3253) self.assertEqual(segment1.synapses, set([synapse1, synapse2])) self.assertEqual(cell2.postsynapticCellsSynapses, set([synapse1])) self.assertEqual(cell3.postsynapticCellsSynapses, set([synapse2]))