root/branches/neo_output/test/system/test_nest.py @ 1056

Revision 1056, 2.4 KB (checked in by apdavison, 15 months ago)

Merged changes r1005:1055 from trunk to neo_output branch.

Line 
1from nose.plugins.skip import SkipTest
2from scenarios import scenarios
3from nose.tools import assert_equal
4
5try:
6    import pyNN.nest
7    have_nest = True
8except ImportError:
9    have_nest = False
10
11def test_scenarios():
12    for scenario in scenarios:
13        if "nest" not in scenario.exclude:
14            scenario.description = scenario.__name__
15            if have_nest:
16                yield scenario, pyNN.nest
17            else:
18                raise SkipTest
19       
20       
21def test_record_native_model():
22    nest = pyNN.nest
23    from pyNN.random import RandomDistribution
24    from pyNN.utility import init_logging
25
26    init_logging(logfile=None, debug=True)
27   
28    nest.setup()
29   
30    parameters = {'Tau_m': 17.0}
31    n_cells = 10
32    p1 = nest.Population(n_cells, nest.native_cell_type("ht_neuron"), parameters)
33    p1.initialize('V_m', -70.0)
34    p1.initialize('Theta', -50.0)
35    p1.set('Theta_eq', -51.5)
36    assert_equal(p1.get('Theta_eq'), [-51.5]*10)
37    print p1.get('Tau_m')
38    p1.rset('Tau_m', RandomDistribution('uniform', [15.0, 20.0]))
39    print p1.get('Tau_m')
40   
41    current_source = nest.StepCurrentSource({'times' : [50.0, 110.0, 150.0, 210.0],
42                                            'amplitudes' : [0.01, 0.02, -0.02, 0.01]})
43    p1.inject(current_source)
44   
45    p2 = nest.Population(1, nest.native_cell_type("poisson_generator"), {'rate': 200.0})
46   
47    print "Setting up recording"
48    p2.record()
49    p1._record('V_m')
50   
51    connector = nest.AllToAllConnector(weights=0.001)
52   
53    prj_ampa = nest.Projection(p2, p1, connector, target='AMPA')
54   
55    tstop = 250.0
56    nest.run(tstop)
57   
58    n_points = int(tstop/nest.get_time_step()) + 1
59    assert_equal(p1.recorders['V_m'].get().shape, (n_points*n_cells, 3))
60    id, t, v = p1.recorders['V_m'].get().T
61    assert v.max() > 0.0 # should have some spikes
62
63 
64def test_native_stdp_model():
65    nest = pyNN.nest
66    from pyNN.utility import init_logging
67
68    init_logging(logfile=None, debug=True)
69   
70    nest.setup()
71   
72    p1 = nest.Population(10, nest.IF_cond_exp)
73    p2 = nest.Population(10, nest.SpikeSourcePoisson)
74   
75    stdp_params = {'Wmax': 50.0, 'lambda': 0.015}
76    stdp = nest.NativeSynapseDynamics("stdp_synapse", stdp_params)
77   
78    connector = nest.AllToAllConnector(weights=0.001)
79   
80    prj = nest.Projection(p2, p1, connector, target='excitatory',
81                          synapse_dynamics=stdp)
Note: See TracBrowser for help on using the browser.