Пример #1
0
def _create_overloaded_functions(spinnaker_simulator):
    """ Creates functions that the main PyNN interface supports\
        (given from PyNN)

    :param spinnaker_simulator: the simulator object we use underneath
    :rtype: None
    """

    # overload the failed ones with now valid ones, now that we're in setup
    # phase.
    __pynn["run"], __pynn["run_until"] = pynn_common.build_run(
        spinnaker_simulator)

    __pynn["get_current_time"], __pynn["get_time_step"], \
        __pynn["get_min_delay"], __pynn["get_max_delay"], \
        __pynn["num_processes"], __pynn["rank"] = \
        pynn_common.build_state_queries(spinnaker_simulator)

    __pynn["reset"] = pynn_common.build_reset(spinnaker_simulator)
    __pynn["create"] = pynn_common.build_create(Population)

    __pynn["connect"] = pynn_common.build_connect(Projection,
                                                  FixedProbabilityConnector,
                                                  StaticSynapse)

    __pynn["record"] = pynn_common.build_record(spinnaker_simulator)
Пример #2
0
def test_build_record():
    simulator = Mock()
    simulator.state.write_on_end = []
    record_function = common.build_record(simulator)
    assert isfunction(record_function)

    source = BasePopulation()
    source.record = Mock()
    record_function(('v', 'spikes'), source, "filename")
    source.record.assert_called_with(('v', 'spikes'), to_file="filename", sampling_interval=None)
Пример #3
0
def test_build_record():
    simulator = Mock()
    simulator.state.write_on_end = []
    record_function = common.build_record(simulator)
    assert isfunction(record_function)

    source = BasePopulation()
    source.record = Mock()
    record_function(("v", "spikes"), source, "filename")
    source.record.assert_called_with(("v", "spikes"), to_file="filename")
    assert_equal(simulator.state.write_on_end, [(source, ("v", "spikes"), "filename")])
Пример #4
0
def test_build_record():
    simulator = Mock()
    simulator.state.write_on_end = []
    record_function = common.build_record(simulator)
    assert isfunction(record_function)

    source = BasePopulation()
    source.record = Mock()
    record_function(('v', 'spikes'), source, "filename")
    source.record.assert_called_with(('v', 'spikes'),
                                     to_file="filename",
                                     sampling_interval=None)
Пример #5
0
def test_build_record():
    simulator = Mock()
    simulator.recorder_list = []
    record_function = common.build_record("foo", simulator)
    assert isfunction(record_function)
    
    source = BasePopulation()
    source._record = Mock()
    source.recorders = {'foo': Mock()}
    record_function(source, "filename")
    source._record.assert_called_with("foo", to_file="filename")
    assert_equal(simulator.recorder_list, [source.recorders['foo']])
Пример #6
0
def test_build_record_with_assembly():
    simulator = Mock()
    simulator.state.write_on_end = []
    record_function = common.build_record(simulator)
    assert isfunction(record_function)

    p1 = BasePopulation()
    p2 = BasePopulation()
    common.Assembly._simulator = None
    source = common.Assembly(p1, p2)
    source.record = Mock()
    record_function('foo', source, "filename")
    source.record.assert_called_with('foo', to_file="filename", sampling_interval=None)
Пример #7
0
def test_build_record_with_assembly():
    simulator = Mock()
    simulator.state.write_on_end = []
    record_function = common.build_record(simulator)
    assert isfunction(record_function)

    p1 = BasePopulation()
    p2 = BasePopulation()
    source = common.Assembly(p1, p2)
    source.record = Mock()
    record_function('foo', source, "filename")
    source.record.assert_called_with('foo', to_file="filename", sampling_interval=None)
    assert_equal(simulator.state.write_on_end, [(source, 'foo', "filename")]) # not sure this is what we want - won't file get over-written?
Пример #8
0
def test_build_record_with_assembly():
    simulator = Mock()
    simulator.state.write_on_end = []
    record_function = common.build_record(simulator)
    assert isfunction(record_function)

    p1 = BasePopulation()
    p2 = BasePopulation()
    common.Assembly._simulator = None
    source = common.Assembly(p1, p2)
    source.record = Mock()
    record_function('foo', source, "filename")
    source.record.assert_called_with('foo',
                                     to_file="filename",
                                     sampling_interval=None)
Пример #9
0
def test_build_record_with_assembly():
    simulator = Mock()
    simulator.state.write_on_end = []
    record_function = common.build_record(simulator)
    assert isfunction(record_function)

    p1 = BasePopulation()
    p2 = BasePopulation()
    source = common.Assembly(p1, p2)
    source.record = Mock()
    record_function('foo', source, "filename")
    source.record.assert_called_with('foo', to_file="filename")
    assert_equal(simulator.state.write_on_end, [
        (source, 'foo', "filename")
    ])  # not sure this is what we want - won't file get over-written?
Пример #10
0
def test_build_record_with_assembly():
    simulator = Mock()
    simulator.recorder_list = []
    record_function = common.build_record("foo", simulator)
    assert isfunction(record_function)
    
    p1 = BasePopulation()
    p2 = BasePopulation()
    source = common.Assembly(p1, p2)
    source._record = Mock()
    for p in p1, p2:
        p.recorders = {'foo': Mock()}
    record_function(source, "filename")
    source._record.assert_called_with("foo", to_file="filename")
    assert_equal(simulator.recorder_list, [p1.recorders['foo'], p2.recorders['foo']])
Пример #11
0

def end(compatible_output=True):
    """Do any necessary cleaning up before exiting."""
    for (population, variables, filename) in simulator.state.write_on_end:
        io = get_io(filename)
        population.write_data(io, variables)
    simulator.state.write_on_end = []
    # should have common implementation of end()

run, run_until = common.build_run(simulator)
run_for = run

reset = common.build_reset(simulator)

initialize = common.initialize

get_current_time, get_time_step, get_min_delay, get_max_delay, \
                    num_processes, rank = common.build_state_queries(simulator)

create = common.build_create(Population)

connect = common.build_connect(Projection, FixedProbabilityConnector, StaticSynapse)


record = common.build_record(simulator)

record_v = lambda source, filename: record(['v'], source, filename)

record_gsyn = lambda source, filename: record(['gsyn_exc', 'gsyn_inh'], source, filename)
Пример #12
0
                    synapse_object = target._cell.esyn
                elif self.synapse_type == "inhibitory":
                    synapse_object = target._cell.isyn
                else:
                    synapse_object = getattr(target._cell, self.synapse_type)
                source._cell.source.connect('event', synapse_object, 'synapse')
                synapse_object.n_incoming_connections += 1
                index = synapse_object.n_incoming_connections - 1
                synapse_object.setWeight(index, weight)
                synapse_object.setDelay(index, delay)
                self.connections.append((source, target, index))
                
# ==============================================================================
#   Low-level API for creating, connecting and recording from individual neurons
# ==============================================================================

create = common.build_create(Population)

connect = common.build_connect(Projection, FixedProbabilityConnector)

set = common.set

record = common.build_record('spikes', simulator)

record_v = common.build_record('v', simulator)

record_gsyn = common.build_record('gsyn', simulator)

# ==============================================================================

Пример #13
0
def end(compatible_output=True):
    """Do any necessary cleaning up before exiting."""
    for (population, variables, filename) in simulator.state.write_on_end:
        io = get_io(filename)
        population.write_data(io, variables)
    simulator.state.write_on_end = []
    # should have common implementation of end()


run, run_until = common.build_run(simulator)
run_for = run

reset = common.build_reset(simulator)

initialize = common.initialize

get_current_time, get_time_step, get_min_delay, get_max_delay, \
                    num_processes, rank = common.build_state_queries(simulator)

create = common.build_create(Population)

connect = common.build_connect(Projection, FixedProbabilityConnector,
                               StaticSynapse)

record = common.build_record(simulator)

record_v = lambda source, filename: record(['v'], source, filename)

record_gsyn = lambda source, filename: record(['gsyn_exc', 'gsyn_inh'], source,
                                              filename)
Пример #14
0
    ##        pre_id, post_id = self.pcsim_projection.prePostPair(i)
    ##        pre_id = list(self.pre.pcsim_population.idVector()).index(pre_id.packed()) # surely there is an easier/faster way?
    ##        post_id = list(self.post.pcsim_population.idVector()).index(post_id.packed())
    ##        pre_addr = self.pre.locate(ID(pre_id))
    ##        post_addr = self.post.locate(ID(post_id))
    ##        w = self.reverse_convertWeight(self.pcsim_projection.object(i).W, self.is_conductance)
    ##        d = 1e3*self.pcsim_projection.object(i).delay
    ##        f.write("%s\t%s\t%g\t%g\n" % (map(int, pre_addr), map(int, post_addr), w, d))
    ##    f.close()


Space = space.Space

# ==============================================================================
#   Low-level API for creating, connecting and recording from individual neurons
# ==============================================================================

create = common.build_create(Population)

connect = common.build_connect(Projection, FixedProbabilityConnector)

set = common.set

record = common.build_record("spikes", simulator)

record_v = common.build_record("v", simulator)

record_gsyn = common.build_record("gsyn", simulator)

# ==============================================================================