本文整理汇总了Python中neurokernel.pattern.Interface类的典型用法代码示例。如果您正苦于以下问题:Python Interface类的具体用法?Python Interface怎么用?Python Interface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Interface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_common_ports
def test_get_common_ports(self):
# Without type, single level:
i = Interface('/foo,/bar,/baz')
i['/*', 'interface'] = 0
j = Interface('/bar,/baz,/qux')
j['/*', 'interface'] = 0
assert i.get_common_ports(0, j, 0, 'spike') == []
self.assertItemsEqual(i.get_common_ports(0, j, 0),
[('bar',), ('baz',)])
# Without type, multiple levels:
i = Interface('/foo[0:6]')
i['/*', 'interface'] = 0
j = Interface('/foo[3:9]')
j['/*', 'interface'] = 0
assert i.get_common_ports(0, j, 0, 'spike') == []
self.assertItemsEqual(i.get_common_ports(0, j, 0),
[('foo', 3), ('foo', 4), ('foo', 5)])
# With type, single level:
i = Interface('/foo,/bar,/baz')
i['/foo,/bar', 'interface', 'type'] = [0, 'spike']
j = Interface('/bar,/baz,/qux')
j['/bar,/baz', 'interface', 'type'] = [0, 'spike']
self.assertItemsEqual(i.get_common_ports(0, j, 0, 'spike'),
[('bar',)])
# With type, multiple levels:
i = Interface('/foo[0:6]')
i['/foo[3,4]', 'interface', 'type'] = [0, 'spike']
j = Interface('/foo[3:9]')
j['/foo[3,4]', 'interface', 'type'] = [0, 'spike']
self.assertItemsEqual(i.get_common_ports(0, j, 0, 'spike'),
[('foo', 3), ('foo', 4)])
示例2: test_get_common_ports_unequal_num_levels
def test_get_common_ports_unequal_num_levels(self):
# Without type, some with only one level:
i = Interface('/foo[0:6],/bar')
i['/*', 'interface'] = 0
j = Interface('/bar,/baz')
j['/*', 'interface'] = 0
assert i.get_common_ports(0, j, 0, 'spike') == []
self.assertItemsEqual(i.get_common_ports(0, j, 0),
[('bar',)])
# Without type, more than one level:
i = Interface('/foo[0:6],/bar[0:2]/baz')
i['/*', 'interface'] = 0
j = Interface('/foo[3:9]')
j['/*', 'interface'] = 0
assert i.get_common_ports(0, j, 0, 'spike') == []
self.assertItemsEqual(i.get_common_ports(0, j, 0),
[('foo', 3), ('foo', 4), ('foo', 5)])
# With type, some with only one level:
i = Interface('/foo[0:6],/bar,/baz')
i['/foo[3,4],/bar', 'interface', 'type'] = [0, 'spike']
j = Interface('/bar,/baz,/qux')
j['/bar,/baz', 'interface', 'type'] = [0, 'spike']
self.assertItemsEqual(i.get_common_ports(0, j, 0, 'spike'),
[('bar',)])
# With type, more than one level:
i = Interface('/foo[0:6],/bar[0:2]/baz')
i['/foo[3,4]', 'interface', 'type'] = [0, 'spike']
j = Interface('/foo[3:9]')
j['/foo[3,4]', 'interface', 'type'] = [0, 'spike']
self.assertItemsEqual(i.get_common_ports(0, j, 0, 'spike'),
[('foo', 3), ('foo', 4)])
示例3: test_to_tuples_single_level
def test_to_tuples_single_level(self):
i = Interface('[0:4]')
i['[0:2]', 'interface'] = 0
i['[2:4]', 'interface'] = 1
self.assertSequenceEqual(i.to_tuples(0),
[(0,), (1,)])
self.assertSequenceEqual(i.to_tuples(),
[(0,), (1,), (2,), (3,)])
示例4: test_which_int_set
def test_which_int_set(self):
i = Interface('/foo[0:4]')
i['/foo[0]', 'interface', 'io'] = [0, 'out']
i['/foo[1]', 'interface', 'io'] = [0, 'in']
i['/foo[2]', 'interface', 'io'] = [1, 'in']
i['/foo[3]', 'interface', 'io'] = [1, 'out']
assert i.which_int('/foo[0:2]') == {0}
assert i.which_int('/foo[0:4]') == {0, 1}
示例5: test_to_tuples_multi_levels
def test_to_tuples_multi_levels(self):
i = Interface('/foo[0:4]')
i['/foo[0:2]', 'interface'] = 0
i['/foo[2:4]', 'interface'] = 1
self.assertSequenceEqual(i.to_tuples(0),
[('foo', 0),
('foo', 1)])
self.assertSequenceEqual(i.to_tuples(),
[('foo', 0),
('foo', 1),
('foo', 2),
('foo', 3)])
示例6: test_is_compatible_both_dirs
def test_is_compatible_both_dirs(self):
"""
It should be possible to define compatible interfaces containing both
input and output ports.
"""
i = Interface('/foo[0:4]')
i['/foo[0:2]', 'interface', 'io'] = [0, 'out']
i['/foo[2:4]', 'interface', 'io'] = [0, 'in']
j = Interface('/foo[0:4]')
j['/foo[0:2]', 'interface', 'io'] = [1, 'in']
j['/foo[2:4]', 'interface', 'io'] = [1, 'out']
assert i.is_compatible(0, j, 1)
示例7: test_is_compatible_with_nulls
def test_is_compatible_with_nulls(self):
"""
Interfaces can be compatible even if some of their ports do not have a
set input or output status.
"""
i = Interface('/foo[0:3]')
i['/foo[0:2]', 'interface', 'io'] = [0, 'out']
i['/foo[2]', 'interface'] = 0
j = Interface('/foo[0:3]')
j['/foo[0:2]', 'interface', 'io'] = [1, 'in']
j['/foo[2]', 'interface'] = 1
assert i.is_compatible(0, j, 1)
示例8: test_is_compatible_both_dirs_types
def test_is_compatible_both_dirs_types(self):
"""
It should be possible to define compatible interfaces containing both
input and output ports with specified types.
"""
i = Interface('/foo[0:4]')
i['/foo[0:2]'] = [0, 'out', 'gpot']
i['/foo[2:4]'] = [0, 'in', 'spike']
j = Interface('/foo[0:4]')
j['/foo[0:2]'] = [1, 'in', 'gpot']
j['/foo[2:4]'] = [1, 'out', 'spike']
assert i.is_compatible(0, j, 1)
示例9: test_is_compatible_with_nulls_types
def test_is_compatible_with_nulls_types(self):
"""
Interfaces can be compatible even if some of their ports do not have a
set type.
"""
i = Interface('/foo[0:3]')
i['/foo[0:2]'] = [0, 'out', 'gpot']
i['/foo[2]', 'interface'] = 0
j = Interface('/foo[0:3]')
j['/foo[0:2]'] = [1, 'in', 'gpot']
j['/foo[2]', 'interface'] = 1
assert i.is_compatible(0, j, 1)
示例10: test_is_compatible_subsets_with_null_types
def test_is_compatible_subsets_with_null_types(self):
"""
Interfaces that both share a subset of compatible ports can be deemed
compatible by setting the `allow_subsets` option of the compatibility
test even when the types are null.
"""
i = Interface('/foo[0:6]')
i['/foo[0:3]'] = [0, 'out']
i['/foo[3:6]'] = [0, 'out']
j = Interface('/foo[0:6]')
j['/foo[0:2]'] = [1, 'in']
j['/foo[3:5]'] = [1, 'in']
k = Interface('/foo[0:6]')
assert i.is_compatible(0, j, 1, True)
assert i.is_compatible(0, k, 1, True) == False
示例11: test_spike_ports
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())
示例12: test_from_df_index_empty
def test_from_df_index_empty(self):
idx = pd.Index([])
data = None
columns = ['interface', 'io', 'type']
df = pd.DataFrame(data, index=idx, columns=columns)
i = Interface.from_df(df)
assert_index_equal(i.data.index, idx)
assert_frame_equal(i.data, df)
示例13: test_from_df_multiindex_empty
def test_from_df_multiindex_empty(self):
idx = pd.MultiIndex(levels=[['a', 'b'], [0, 1]],
labels=[[],[]])
data = None
columns = ['interface', 'io', 'type']
df = pd.DataFrame(data, index=idx, columns=columns)
i = Interface.from_df(df)
assert_index_equal(i.data.index, idx)
assert_frame_equal(i.data, df)
示例14: test_from_df_index
def test_from_df_index(self):
idx = pd.Index(['foo', 'bar', 'baz'])
data = [(0, 'in', 'spike'),
(1, 'in', 'gpot'),
(1, 'out', 'gpot')]
columns = ['interface', 'io', 'type']
df = pd.DataFrame(data, index=idx, columns=columns)
i = Interface.from_df(df)
assert_index_equal(i.data.index, idx)
assert_frame_equal(i.data, df)
示例15: test_from_df_multiindex
def test_from_df_multiindex(self):
idx = pd.MultiIndex.from_tuples([('foo', 0),
('foo', 1),
('foo', 2)])
data = [(0, 'in', 'spike'),
(1, 'in', 'gpot'),
(1, 'out', 'gpot')]
columns = ['interface', 'io', 'type']
df = pd.DataFrame(data, index=idx, columns=columns)
i = Interface.from_df(df)
assert_index_equal(i.data.index, idx)
assert_frame_equal(i.data, df)