本文整理汇总了Python中neurokernel.pattern.Interface.port_select方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.port_select方法的具体用法?Python Interface.port_select怎么用?Python Interface.port_select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neurokernel.pattern.Interface
的用法示例。
在下文中一共展示了Interface.port_select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_interface
# 需要导入模块: from neurokernel.pattern import Interface [as 别名]
# 或者: from neurokernel.pattern.Interface import port_select [as 别名]
#.........这里部分代码省略.........
i = Interface('/foo[0:6]')
i['/foo[0]'] = [0, 'in', 'spike']
i['/foo[1:3]'] = [0, 'out', 'spike']
i['/foo[3]'] = [0, 'in', 'gpot']
i['/foo[4:6]'] = [0, 'out', 'gpot']
j = Interface('/foo[3:6]')
j['/foo[3]'] = [0, 'in', 'gpot']
j['/foo[4:6]'] = [0, 'out', 'gpot']
# Test returning result as Interface:
assert_frame_equal(i.gpot_ports(0).data, j.data)
# Test returning result as list of tuples:
self.assertItemsEqual(i.gpot_ports(0, True),
j.data.index.tolist())
def test_spike_ports(self):
i = Interface('/foo[0:6]')
i['/foo[0]'] = [0, 'in', 'spike']
i['/foo[1:3]'] = [0, 'out', 'spike']
i['/foo[3]'] = [0, 'in', 'gpot']
i['/foo[4:6]'] = [0, 'out', 'gpot']
j = Interface('/foo[0:3]')
j['/foo[0]'] = [0, 'in', 'spike']
j['/foo[1:3]'] = [0, 'out', 'spike']
# Return result as Interface:
assert_frame_equal(i.spike_ports(0).data, j.data)
# Test returning result as list of tuples:
self.assertItemsEqual(i.spike_ports(0, True),
j.data.index.tolist())
def test_port_select(self):
i = self.interface.port_select(lambda x: x[1] >= 1)
assert_index_equal(i.data.index,
pd.MultiIndex.from_tuples([('foo', 1),
('foo', 2)]))
def test_index(self):
assert_index_equal(self.interface.index,
pd.MultiIndex(levels=[['foo'], [0, 1, 2]],
labels=[[0, 0, 0], [0, 1, 2]],
names=['0', '1']))
def test_interface_ids(self):
i = Interface('/foo[0:4]')
i['/foo[0:2]', 'interface', 'io'] = [0, 'out']
i['/foo[2:4]', 'interface', 'io'] = [1, 'in']
assert i.interface_ids == set([0, 1])
def test_io_inv(self):
i = Interface('/foo[0:4]')
i['/foo[0:2]', 'interface', 'io'] = [0, 'out']
i['/foo[2:4]', 'interface', 'io'] = [1, 'in']
j = Interface('/foo[0:4]')
j['/foo[0:2]', 'interface', 'io'] = [0, 'in']
j['/foo[2:4]', 'interface', 'io'] = [1, 'out']
assert_frame_equal(i.data, j.io_inv.data)
def test_is_compatible_sel_order(self):
"""
Interfaces with individually compatible ports that are ordered in
different ways should still be deemed compatible.
"""