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