Ejemplo n.º 1
0
 def testRSetNative2(self):
     """Population.rset(): with native rng."""
     rd1 = random.RandomDistribution(rng=random.NativeRNG(seed=98765),
                                     distribution='uniform',
                                     parameters=[0.9, 1.1])
     rd2 = random.RandomDistribution(rng=random.NativeRNG(seed=98765),
                                     distribution='uniform',
                                     parameters=[0.9, 1.1])
     self.net.rset('cm', rd1)
     output_values_1 = numpy.zeros((3, 3), numpy.float)
     output_values_2 = numpy.zeros((3, 3), numpy.float)
     hoc_net = getattr(h, self.net.label)
     print hoc_net.count()
     for i in 0, 1, 2:
         for j in 0, 1, 2:
             id = 3 * i + j
             if id in self.net.gidlist:
                 list_index = self.net.gidlist.index(id)
                 output_values_1[i, j] = hoc_net.object(list_index).cell(
                     0.5).cm
     self.net.rset('cm', rd2)
     for i in 0, 1, 2:
         for j in 0, 1, 2:
             id = 3 * i + j
             if id in self.net.gidlist:
                 list_index = self.net.gidlist.index(id)
                 output_values_2[i, j] = hoc_net.object(list_index).cell(
                     0.5).cm
     output_values_1 = output_values_1.reshape((9, ))
     output_values_2 = output_values_2.reshape((9, ))
     for i in range(9):
         self.assertAlmostEqual(output_values_1[i],
                                output_values_2[i],
                                places=5)
Ejemplo n.º 2
0
def test_rset_with_native_rng():
    p = MockPopulation()
    p._native_rset = Mock()
    rd = Mock()
    rd.rng = random.NativeRNG()
    p.rset('tau_m', rd)
    p._native_rset.assert_called_with('tau_m', rd)
Ejemplo n.º 3
0
 def testRSetNative2(self):
     """Population.rset(): with native rng."""
     rd1 = random.RandomDistribution(rng=random.NativeRNG(seed=98765),
                                      distribution='uniform',
                                      parameters=[0.9,1.1])
     rd2 = random.RandomDistribution(rng=random.NativeRNG(seed=98765),
                                      distribution='uniform',
                                      parameters=[0.9,1.1])
     self.net.rset('cm', rd1)
     output_values_1 = numpy.zeros((3,3), numpy.float)
     for i in 0,1,2:
         for j in 0,1,2:
             id = self.net[i,j]
             output_values_1[i, j] = id._cell(0.5).cm
     self.net.rset('cm', rd2)
     output_values_2 = self.net.get('cm', as_array=True)
     assert numpy.equal(output_values_1, output_values_2).all()
Ejemplo n.º 4
0
 def testRSetNative1(self):
     """Population.rset(): with native rng. This is difficult to test, so for
     now just require that all values retrieved should be different.
     Later, could calculate distribution and assert that the difference between
     sample and theoretical distribution is less than some threshold."""
     self.net.rset('tau_m',
                   random.RandomDistribution(rng=random.NativeRNG(),
                                             distribution='uniform',
                                             parameters=(10.0,30.0)))
     self.assertNotEqual(self.net[0,0].tau_m,
                         self.net[0,1].tau_m)
Ejemplo n.º 5
0
 def testFixedProbability(self):
     """For all connections created with "fixedProbability"..."""
     for srcP in [self.source5, self.source22]:
         for tgtP in [self.target1, self.target6, self.target33]:
             prj1 = sim.Projection(srcP,
                                   tgtP,
                                   sim.FixedProbabilityConnector(0.5),
                                   rng=random.NumpyRNG(12345))
             prj2 = sim.Projection(srcP,
                                   tgtP,
                                   sim.FixedProbabilityConnector(0.5),
                                   rng=random.NativeRNG(12345))
             for prj in prj1, prj2:
                 assert (0 < len(prj) < len(srcP) * len(tgtP)
                         ), 'len(prj) = %d, len(srcP)*len(tgtP) = %d' % (
                             len(prj), len(srcP) * len(tgtP))
Ejemplo n.º 6
0
 def test_create(self):
     rng = random.NativeRNG(seed=8274528)
     str(rng)
Ejemplo n.º 7
0
 def setUp(self):
     self.target   = neuron.Population((3,3), neuron.IF_curr_alpha)
     self.source   = neuron.Population((3,3), neuron.SpikeSourcePoisson,{'rate': 200})
     self.distrib_Numpy = random.RandomDistribution(rng=random.NumpyRNG(12345), distribution='uniform', parameters=(0.2,1)) 
     self.distrib_Native= random.RandomDistribution(rng=random.NativeRNG(12345), distribution='uniform', parameters=(0.2,1))