Exemplo n.º 1
0
    def testPathsNotInvalidatedByOtherDestroys(self):
        """ Creates segments and synapses, then destroys segments and synapses on
        either side of them and verifies that existing Segment and Synapse
        instances still point to the same segment / synapse as before.
    """
        connections = Connections(1024)
        segment1 = connections.createSegment(11)
        connections.createSegment(12)
        segment3 = connections.createSegment(13)
        connections.createSegment(14)
        segment5 = connections.createSegment(15)

        synapse1 = connections.createSynapse(segment3, 201, .85)
        synapse2 = connections.createSynapse(segment3, 202, .85)
        synapse3 = connections.createSynapse(segment3, 203, .85)
        synapse4 = connections.createSynapse(segment3, 204, .85)
        synapse5 = connections.createSynapse(segment3, 205, .85)

        self.assertEqual(203, synapse3.presynapticCell)
        connections.destroySynapse(synapse1)
        self.assertEqual(203, synapse3.presynapticCell)
        connections.destroySynapse(synapse5)
        self.assertEqual(203, synapse3.presynapticCell)

        connections.destroySegment(segment1)
        self.assertEqual(set([synapse2, synapse3, synapse4]),
                         connections.synapsesForSegment(segment3))
        connections.destroySegment(segment5)
        self.assertEqual(set([synapse2, synapse3, synapse4]),
                         connections.synapsesForSegment(segment3))
        self.assertEqual(203, synapse3.presynapticCell)
Exemplo n.º 2
0
  def testPathsNotInvalidatedByOtherDestroys(self):
    """ Creates segments and synapses, then destroys segments and synapses on
        either side of them and verifies that existing Segment and Synapse
        instances still point to the same segment / synapse as before.
    """
    connections = Connections(1024)
    segment1 = connections.createSegment(11)
    connections.createSegment(12)
    segment3 = connections.createSegment(13)
    connections.createSegment(14)
    segment5 = connections.createSegment(15)

    synapse1 = connections.createSynapse(segment3, 201, .85)
    synapse2 = connections.createSynapse(segment3, 202, .85)
    synapse3 = connections.createSynapse(segment3, 203, .85)
    synapse4 = connections.createSynapse(segment3, 204, .85)
    synapse5 = connections.createSynapse(segment3, 205, .85)

    self.assertEqual(203, synapse3.presynapticCell)
    connections.destroySynapse(synapse1)
    self.assertEqual(203, synapse3.presynapticCell)
    connections.destroySynapse(synapse5)
    self.assertEqual(203, synapse3.presynapticCell)

    connections.destroySegment(segment1)
    self.assertEqual(set([synapse2, synapse3, synapse4]),
                     connections.synapsesForSegment(segment3))
    connections.destroySegment(segment5)
    self.assertEqual(set([synapse2, synapse3, synapse4]),
                     connections.synapsesForSegment(segment3))
    self.assertEqual(203, synapse3.presynapticCell)
Exemplo n.º 3
0
  def testReuseSegmentWithDestroyedSynapses(self):
    """ Destroy a segment that has a destroyed synapse and a non-destroyed
        synapse. Create a new segment in the same place. Make sure its synapse
        count is correct.
    """
    connections = Connections(1024)

    segment = connections.createSegment(11)

    synapse1 = connections.createSynapse(segment, 201, .85)
    connections.createSynapse(segment, 202, .85)

    connections.destroySynapse(synapse1)

    self.assertEqual(1, connections.numSynapses(segment))

    connections.destroySegment(segment)

    reincarnated = connections.createSegment(11)

    self.assertEqual(0, connections.numSynapses(reincarnated))
    self.assertEqual(0, len(connections.synapsesForSegment(reincarnated)))
Exemplo n.º 4
0
    def testReuseSegmentWithDestroyedSynapses(self):
        """ Destroy a segment that has a destroyed synapse and a non-destroyed
        synapse. Create a new segment in the same place. Make sure its synapse
        count is correct.
    """
        connections = Connections(1024)

        segment = connections.createSegment(11)

        synapse1 = connections.createSynapse(segment, 201, .85)
        connections.createSynapse(segment, 202, .85)

        connections.destroySynapse(synapse1)

        self.assertEqual(1, connections.numSynapses(segment))

        connections.destroySegment(segment)

        reincarnated = connections.createSegment(11)

        self.assertEqual(0, connections.numSynapses(reincarnated))
        self.assertEqual(0, len(connections.synapsesForSegment(reincarnated)))
Exemplo n.º 5
0
  def testDestroySynapsesThenReachLimit(self):
    """ Destroy some synapses then verify that the maxSynapsesPerSegment is
        still correctly applied.
    """
    connections = Connections(1024, 2, 2)

    segment = connections.createSegment(10)

    synapse1 = connections.createSynapse(segment, 201, .85)
    synapse2 = connections.createSynapse(segment, 202, .85)

    self.assertEqual(2, connections.numSynapses())
    connections.destroySynapse(synapse1)
    connections.destroySynapse(synapse2)
    self.assertEqual(0, connections.numSynapses())

    connections.createSynapse(segment, 201, .85)
    self.assertEqual(1, connections.numSynapses())
    connections.createSynapse(segment, 202, .90)
    self.assertEqual(2, connections.numSynapses())
    synapse3 = connections.createSynapse(segment, 203, .8)
    self.assertEqual(2, connections.numSynapses())
Exemplo n.º 6
0
    def testDestroySynapsesThenReachLimit(self):
        """ Destroy some synapses then verify that the maxSynapsesPerSegment is
        still correctly applied.
    """
        connections = Connections(1024, 2, 2)

        segment = connections.createSegment(10)

        synapse1 = connections.createSynapse(segment, 201, .85)
        synapse2 = connections.createSynapse(segment, 202, .85)

        self.assertEqual(2, connections.numSynapses())
        connections.destroySynapse(synapse1)
        connections.destroySynapse(synapse2)
        self.assertEqual(0, connections.numSynapses())

        connections.createSynapse(segment, 201, .85)
        self.assertEqual(1, connections.numSynapses())
        connections.createSynapse(segment, 202, .90)
        self.assertEqual(2, connections.numSynapses())
        synapse3 = connections.createSynapse(segment, 203, .8)
        self.assertEqual(2, connections.numSynapses())
Exemplo n.º 7
0
  def testDestroySynapse(self):
    """ Creates a segment, creates a number of synapses on it, destroys a
        synapse, and makes sure it got destroyed.
    """
    connections = Connections(1024)

    segment = connections.createSegment(20)
    synapse1 = connections.createSynapse(segment, 80, .85)
    synapse2 = connections.createSynapse(segment, 81, .85)
    synapse3 = connections.createSynapse(segment, 82, .15)

    self.assertEqual(3, connections.numSynapses())

    connections.destroySynapse(synapse2)

    self.assertEqual(2, connections.numSynapses())
    self.assertEqual(set([synapse1, synapse3]),
                     connections.synapsesForSegment(segment))
    (numActiveConnected,
     numActivePotential) = connections.computeActivity([80, 81, 82], .5)

    self.assertEqual(1, numActiveConnected[segment.flatIdx])
    self.assertEqual(2, numActivePotential[segment.flatIdx])
Exemplo n.º 8
0
    def testDestroySynapse(self):
        """ Creates a segment, creates a number of synapses on it, destroys a
        synapse, and makes sure it got destroyed.
    """
        connections = Connections(1024)

        segment = connections.createSegment(20)
        synapse1 = connections.createSynapse(segment, 80, .85)
        synapse2 = connections.createSynapse(segment, 81, .85)
        synapse3 = connections.createSynapse(segment, 82, .15)

        self.assertEqual(3, connections.numSynapses())

        connections.destroySynapse(synapse2)

        self.assertEqual(2, connections.numSynapses())
        self.assertEqual(set([synapse1, synapse3]),
                         connections.synapsesForSegment(segment))
        (numActiveConnected,
         numActivePotential) = connections.computeActivity([80, 81, 82], .5)

        self.assertEqual(1, numActiveConnected[segment.flatIdx])
        self.assertEqual(2, numActivePotential[segment.flatIdx])
Exemplo n.º 9
0
  def testDestroySegmentWithDestroyedSynapses(self):
    """ Destroy a segment that has a destroyed synapse and a non-destroyed
        synapse. Make sure nothing gets double-destroyed.
    """
    connections = Connections(1024)

    segment1 = connections.createSegment(11)
    segment2 = connections.createSegment(12)

    connections.createSynapse(segment1, 101, .85)
    synapse2a = connections.createSynapse(segment2, 201, .85)
    connections.createSynapse(segment2, 202, .85)

    self.assertEqual(3, connections.numSynapses())

    connections.destroySynapse(synapse2a)

    self.assertEqual(2, connections.numSegments())
    self.assertEqual(2, connections.numSynapses())

    connections.destroySegment(segment2)

    self.assertEqual(1, connections.numSegments())
    self.assertEqual(1, connections.numSynapses())
Exemplo n.º 10
0
    def testDestroySegmentWithDestroyedSynapses(self):
        """ Destroy a segment that has a destroyed synapse and a non-destroyed
        synapse. Make sure nothing gets double-destroyed.
    """
        connections = Connections(1024)

        segment1 = connections.createSegment(11)
        segment2 = connections.createSegment(12)

        connections.createSynapse(segment1, 101, .85)
        synapse2a = connections.createSynapse(segment2, 201, .85)
        connections.createSynapse(segment2, 202, .85)

        self.assertEqual(3, connections.numSynapses())

        connections.destroySynapse(synapse2a)

        self.assertEqual(2, connections.numSegments())
        self.assertEqual(2, connections.numSynapses())

        connections.destroySegment(segment2)

        self.assertEqual(1, connections.numSegments())
        self.assertEqual(1, connections.numSynapses())