def _initialize(): """Make a simple simulation.""" from topo.base.simulation import Simulation from topo.base.cf import CFSheet, CFProjection from topo.sheet import GeneratorSheet sim = Simulation(register=True, name="test pattern tester") sim['GS'] = GeneratorSheet(nominal_density=2) sim['GS2'] = GeneratorSheet(nominal_density=2) sim['S'] = CFSheet(nominal_density=2) sim['S2'] = CFSheet(nominal_density=2) sim.connect('GS', 'S', connection_type=CFProjection, delay=0.05) sim.connect('GS', 'S2', connection_type=CFProjection, delay=0.05) sim.connect('GS2', 'S2', connection_type=CFProjection, delay=0.05)
def basic_save_load_snapshot(self): """ Very basic test to check the activity matrix of a GeneratorSheet comes back ok, and that class attributes are pickled. """ assert topo.sim.name == SIM_NAME topo.sim['R'] = GeneratorSheet(input_generator=Gaussian(), nominal_density=2) topo.sim.run(1) R_act = copy.deepcopy(topo.sim['R'].activity) Line.x = 12.0 topo.sim.startup_commands.append("z=99") save_snapshot(SNAPSHOT_NAME) Line.x = 9.0 exec "z=88" in __main__.__dict__ topo.sim['R'].set_input_generator(Line()) topo.sim.run(1) load_snapshot( resolve_path(SNAPSHOT_NAME, search_paths=[normalize_path.prefix])) # CEBALERT: should also test that unpickling order is correct # (i.e. startup_commands, class attributes, simulation) assert_array_equal(R_act, topo.sim['R'].activity) self.assertEqual(Line.x, 12.0) self.assertEqual(__main__.__dict__['z'], 99)
def setUp(self): self.original_output_path = normalize_path.prefix normalize_path.prefix = tempfile.mkdtemp() self.sim = Simulation(register=True,name="testplotfilesaver") self.sim['A'] = GeneratorSheet(nominal_density=2) self.sim['B'] = CFSheet(nominal_density=2) self.sim.connect('A','B',connection_type=CFProjection,name='Afferent')
def new_simulation(name=None, register=True): from topo.base.simulation import Simulation from topo.base.cf import CFSheet, CFProjection from topo.sheet import GeneratorSheet from topo.base.boundingregion import BoundingBox sim = Simulation(register=register, name=name) b = BoundingBox(radius=0.5) sim['GS'] = GeneratorSheet(nominal_density=2, nominal_bounds=b) sim['GS2'] = GeneratorSheet(nominal_density=2, nominal_bounds=b) sim['S'] = CFSheet(nominal_density=2, nominal_bounds=b) sim['S2'] = CFSheet(nominal_density=2, nominal_bounds=b) sim.connect('GS', 'S', connection_type=CFProjection, delay=0.05) sim.connect('GS', 'S2', connection_type=CFProjection, delay=0.05) sim.connect('GS2', 'S2', connection_type=CFProjection, delay=0.05) return sim
def setUp(self): """ Create a CFSheet ('V1') connected to a GeneratorSheet ('Retina'). """ self.s = Simulation() self.s['Retina'] = GeneratorSheet(nominal_density=4.0) self.s['V1'] = CFSheet(nominal_density=4.0) self.s['V2'] = CFSheet(nominal_density=4.0) self.s.connect('Retina', 'V1', delay=0.5, connection_type=CFProjection, name='RtoV1', learning_fn=CFPLF_Hebbian()) self.s.connect('Retina', 'V2', delay=0.5, connection_type=CFProjection, name='RtoV2', learning_fn=CFPLF_Hebbian())