本文整理汇总了Python中topo.base.simulation.Simulation.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.connect方法的具体用法?Python Simulation.connect怎么用?Python Simulation.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类topo.base.simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.connect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_state_stack
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import connect [as 别名]
def test_state_stack(self):
s = Simulation()
s['pulse1'] = PulseGenerator(period = 1)
s['pulse2'] = PulseGenerator(period = 3)
s['sum_unit'] = SumUnit()
s.connect('pulse1','sum_unit',delay=1)
s.connect('pulse2','sum_unit',delay=1)
s.run(1.0)
s.state_push()
self.assertEqual(len(s._events_stack),1)
s.state_pop()
self.assertEqual(len(s._events_stack),0)
示例2: test_state_stack
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import connect [as 别名]
def test_state_stack(self):
s = Simulation()
s["pulse1"] = PulseGenerator(period=1)
s["pulse2"] = PulseGenerator(period=3)
s["sum_unit"] = SumUnit()
s.connect("pulse1", "sum_unit", delay=1)
s.connect("pulse2", "sum_unit", delay=1)
s.run(1.0)
s.state_push()
self.assertEqual(len(s._events_stack), 1)
s.state_pop()
self.assertEqual(len(s._events_stack), 0)
示例3: test_get_objects
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import connect [as 别名]
def test_get_objects(self):
s = Simulation()
s['pulse1'] = PulseGenerator(period = 1)
s['pulse2'] = PulseGenerator(period = 3)
s['sum_unit'] = SumUnit()
n1 = s['pulse1'].name
n2 = s['pulse2'].name
s.connect('pulse1','sum_unit',delay=1)
s.connect('pulse2','sum_unit',delay=1)
t1 = s.objects()
e1 = [ep for ep in t1.values() if isinstance(ep,PulseGenerator) and ep.name == n1]
t2 = s.objects()
e2 = [ep for ep in t2.values() if isinstance(ep,PulseGenerator) and ep.name == n2]
assert e1.pop().name == n1, 'Object names do not match'
assert e2.pop().name == n2, 'Object names do not match'
示例4: test_get_objects
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import connect [as 别名]
def test_get_objects(self):
s = Simulation()
s["pulse1"] = PulseGenerator(period=1)
s["pulse2"] = PulseGenerator(period=3)
s["sum_unit"] = SumUnit()
n1 = s["pulse1"].name
n2 = s["pulse2"].name
s.connect("pulse1", "sum_unit", delay=1)
s.connect("pulse2", "sum_unit", delay=1)
t1 = s.objects()
e1 = [ep for ep in t1.values() if isinstance(ep, PulseGenerator) and ep.name == n1]
t2 = s.objects()
e2 = [ep for ep in t2.values() if isinstance(ep, PulseGenerator) and ep.name == n2]
assert e1.pop().name == n1, "Object names do not match"
assert e2.pop().name == n2, "Object names do not match"
示例5: TestPlotGroupSaverBase
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import connect [as 别名]
class TestPlotGroupSaverBase(unittest.TestCase):
def exists(self,name):
target = os.path.join(normalize_path.prefix,name)
files = glob.glob(os.path.join(normalize_path.prefix,"*"))
self.assert_(os.path.exists(target),
"'%s' not among '%s'"%(os.path.basename(target),
[os.path.basename(f) for f in files]))
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 tearDown(self):
shutil.rmtree(normalize_path.prefix)
normalize_path.prefix = self.original_output_path
示例6: _initialize
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import connect [as 别名]
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)
示例7: new_simulation
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import connect [as 别名]
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
示例8: TestCFIter
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import connect [as 别名]
class TestCFIter(unittest.TestCase):
iter_type = CFIter
def setUp(self):
self.sim = Simulation()
self.sim['Dest'] = CFSheet(nominal_density=10,nominal_bounds=BoundingBox(radius=0.5))
self.sim['Src'] = CFSheet(nominal_density=10,nominal_bounds=BoundingBox(radius=0.5))
self.sim.connect('Src','Dest',
connection_type = ResizableCFProjection,
)
def test_iterate_all(self):
"""
Test to make sure the iterator hits every CF
"""
total = 0
dest = self.sim['Dest']
proj = dest.projections()['SrcToDest']
rows,cols = dest.shape
iterator = self.iter_type(proj)
for cf,i in iterator():
total += 1
self.failUnless(0 <= i < 100, "CFIter generated bogus CF index")
cfxy = (proj.X_cf.flat[i],proj.Y_cf.flat[i])
r,c = i/cols,i%cols
self.failUnlessEqual(cfxy,dest.matrixidx2sheet(r,c))
self.failUnlessEqual(total,100)
def test_iterate_some_nil(self):
"""
Test to make sure iterator skips nil CFs (i.e cf == None)
"""
dest = self.sim['Dest']
proj = dest.projections()['SrcToDest']
total = 0
proj.flatcfs[24] = None
for cf,i in self.iter_type(proj)():
total += 1
self.failIfEqual(i,24)
self.failUnlessEqual(total,99)
def test_iterate_masked(self):
"""
Test if iterator skips masked CFs
"""
total = 0
dest = self.sim['Dest']
proj = dest.projections()['SrcToDest']
dest.mask.data = numpy.zeros(dest.activity.shape)
dest.mask.data.flat[24] = 1
for cf,i in self.iter_type(proj)():
total += 1
self.failUnlessEqual(i,24)
self.failUnless(cf is proj.flatcfs[24])
self.failUnlessEqual(total,1)