Beispiel #1
0
 def testOneToOne(self):
     """For all connections created with "OneToOne" it should be possible to obtain the weight using pyneuron.getWeight()"""
     prj1 = nest.Projection(self.source33, self.target33, 'oneToOne')
     prj2 = nest.Projection(self.source33, self.target33,
                            nest.OneToOneConnector())
     assert len(prj1) == self.source33.size
     assert len(prj2) == self.source33.size
Beispiel #2
0
 def testFixedProbability(self):
     """For all connections created with "fixedProbability" it should be possible to obtain the weight using pynest.getWeight()"""
     for srcP in [self.source5, self.source22]:
         for tgtP in [self.target6, self.target33]:
             prj1 = nest.Projection(srcP, tgtP, "fixedProbability", 0.5)
             prj2 = nest.Projection(srcP, tgtP,
                                    nest.FixedProbabilityConnector(0.5))
             for prj in prj1, prj2:
                 assert len(prj._sources) == len(prj._targets)
                 weights = []
                 for src, tgt in prj.connections():
                     weights.append(nest.pynest.getWeight(src, tgt))
                 assert weights == [0.0] * len(prj._sources), weights
Beispiel #3
0
 def testAllToAll(self):
     """For all connections created with "allToAll" it should be possible to obtain the weight using pynest.getWeight()"""
     for srcP in [self.source5, self.source22]:
         for tgtP in [self.target6, self.target33]:
             prj1 = nest.Projection(srcP, tgtP, "allToAll")
             prj2 = nest.Projection(srcP, tgtP, nest.AllToAllConnector())
             for prj in prj1, prj2:
                 assert len(prj._sources) == len(prj._targets)
                 weights = []
                 for src, tgt in prj.connections():
                     weights.append(nest.pynest.getWeight(src, tgt))
                 assert weights == [0.0] * len(
                     prj._sources)  # default weight is zero
Beispiel #4
0
 def testSaveAndLoad(self):
     prj1 = nest.Projection(self.source22, self.target33, 'allToAll')
     prj1.setDelays(0.2)
     prj1.setWeights(1.234)
     prj1.saveConnections("connections.tmp")
     connector = nest.FromFileConnector("connections.tmp")
     prj2 = nest.Projection(self.source22, self.target33, connector)
     w1 = []
     w2 = []
     d1 = []
     d2 = []
     # For a connections scheme saved and reloaded, we test if the connections, their weights and their delays
     # are equal.
     for src, tgt in prj1.connections():
         w1.append(nest.pynest.getWeight(src, tgt))
         d1.append(nest.pynest.getDelay(src, tgt))
     for src, tgt in prj2.connections():
         w2.append(nest.pynest.getWeight(src, tgt))
         d2.append(nest.pynest.getDelay(src, tgt))
     assert (w1 == w2) and (d1 == d2)
Beispiel #5
0
 def testrandomizeDelays(self):
     # The probability of having two consecutive weights vector that are equal should be 0
     prj1 = nest.Projection(self.source5, self.target33, 'allToAll')
     prj1.randomizeDelays(self.distrib_Numpy)
     d1 = []
     d2 = []
     for src, tgt in prj1.connections():
         d1.append(nest.pynest.getDelay(src, tgt))
     prj1.randomizeDelays(self.distrib_Numpy)
     for src, tgt in prj1.connections():
         d2.append(nest.pynest.getDelay(src, tgt))
     self.assertNotEqual(d1, d2)
Beispiel #6
0
    def testDistantDependentProbability(self):
        """For all connections created with "distanceDependentProbability"..."""
        # Test should be improved..."

        for rngclass in (nest.NumpyRNG, nest.NativeRNG):
            for expr in ('exp(-d)', 'd < 0.5'):
                prj1 = nest.Projection(self.source33,
                                       self.target33,
                                       'distanceDependentProbability',
                                       {'d_expression': expr},
                                       rng=rngclass(12345))
                prj2 = nest.Projection(
                    self.source33,
                    self.target33,
                    nest.DistanceDependentProbabilityConnector(
                        d_expression=expr),
                    rng=rngclass(12345))
                assert (0 < len(prj1) < len(self.source33)*len(self.target33)) \
                   and (0 < len(prj2) < len(self.source33)*len(self.target33))
                if rngclass == nest.NumpyRNG:
                    assert prj1._sources == prj2._sources, "%s %s" % (rngclass,
                                                                      expr)
                    assert prj1._targets == prj2._targets, "%s %s" % (rngclass,
                                                                      expr)
Beispiel #7
0
 def setUp(self):
     nest.setup(max_delay=0.5)
     nest.Population.nPop = 0
     self.target33 = nest.Population((3, 3), nest.IF_curr_alpha)
     self.target6 = nest.Population((6, ), nest.IF_curr_alpha)
     self.source5 = nest.Population((5, ), nest.SpikeSourcePoisson)
     self.source22 = nest.Population((2, 2), nest.SpikeSourcePoisson)
     self.prjlist = []
     self.distrib_Numpy = random.RandomDistribution(
         rng=random.NumpyRNG(12345),
         distribution='uniform',
         parameters=(0.1, 0.5))
     for tgtP in [self.target6, self.target33]:
         for srcP in [self.source5, self.source22]:
             for method in ('allToAll', 'fixedProbability'):
                 self.prjlist.append(
                     nest.Projection(srcP, tgtP, method,
                                     {'p_connect': 0.5}))