本文整理汇总了Python中neurokernel.pattern.Pattern.from_graph方法的典型用法代码示例。如果您正苦于以下问题:Python Pattern.from_graph方法的具体用法?Python Pattern.from_graph怎么用?Python Pattern.from_graph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neurokernel.pattern.Pattern
的用法示例。
在下文中一共展示了Pattern.from_graph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_graph
# 需要导入模块: from neurokernel.pattern import Pattern [as 别名]
# 或者: from neurokernel.pattern.Pattern import from_graph [as 别名]
def test_from_graph(self):
p = Pattern('/foo[0:4]', '/bar[0:4]')
p['/foo[0]', '/bar[0]'] = 1
p['/foo[0]', '/bar[1]'] = 1
p['/foo[1]', '/bar[2]'] = 1
p['/bar[3]', '/foo[2]'] = 1
p['/bar[3]', '/foo[3]'] = 1
g = nx.DiGraph()
g.add_node('/bar[0]', interface=1, io='out')
g.add_node('/bar[1]', interface=1, io='out')
g.add_node('/bar[2]', interface=1, io='out')
g.add_node('/bar[3]', interface=1, io='in')
g.add_node('/foo[0]', interface=0, io='in')
g.add_node('/foo[1]', interface=0, io='in')
g.add_node('/foo[2]', interface=0, io='out')
g.add_node('/foo[3]', interface=0, io='out')
g.add_edge('/foo[0]', '/bar[0]')
g.add_edge('/foo[0]', '/bar[1]')
g.add_edge('/foo[1]', '/bar[2]')
g.add_edge('/bar[3]', '/foo[2]')
g.add_edge('/bar[3]', '/foo[3]')
pg = Pattern.from_graph(g)
assert_frame_equal(pg.data.sort_index(), p.data.sort_index())
assert_frame_equal(pg.interface.data.sort_index(),
p.interface.data.sort_index())
p.interface['/foo[0]', 'type'] = 'gpot'
p.interface['/bar[0]', 'type'] = 'gpot'
p.interface['/bar[1]', 'type'] = 'gpot'
p.interface['/foo[1]', 'type'] = 'gpot'
p.interface['/bar[2]', 'type'] = 'gpot'
p.interface['/bar[3]', 'type'] = 'spike'
p.interface['/foo[2]', 'type'] = 'spike'
p.interface['/bar[3]', 'type'] = 'spike'
p.interface['/foo[3]', 'type'] = 'spike'
g = nx.DiGraph()
g.add_node('/bar[0]', interface=1, io='out', type='gpot')
g.add_node('/bar[1]', interface=1, io='out', type='gpot')
g.add_node('/bar[2]', interface=1, io='out', type='gpot')
g.add_node('/bar[3]', interface=1, io='in', type='spike')
g.add_node('/foo[0]', interface=0, io='in', type='gpot')
g.add_node('/foo[1]', interface=0, io='in', type='gpot')
g.add_node('/foo[2]', interface=0, io='out', type='spike')
g.add_node('/foo[3]', interface=0, io='out', type='spike')
g.add_edge('/foo[0]', '/bar[0]')
g.add_edge('/foo[0]', '/bar[1]')
g.add_edge('/foo[1]', '/bar[2]')
g.add_edge('/bar[3]', '/foo[2]')
g.add_edge('/bar[3]', '/foo[3]')
pg = Pattern.from_graph(g)
assert_frame_equal(pg.data.sort_index(), p.data.sort_index())
assert_frame_equal(pg.interface.data.sort_index(),
p.interface.data.sort_index())