• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pattern.Interface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neurokernel.pattern.Interface的典型用法代码示例。如果您正苦于以下问题:Python Interface类的具体用法?Python Interface怎么用?Python Interface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Interface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)])
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:34,代码来源:test_pattern.py


示例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)])
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:34,代码来源:test_pattern.py


示例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,)])
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:8,代码来源:test_pattern.py


示例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}
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:8,代码来源:test_pattern.py


示例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)])
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:12,代码来源:test_pattern.py


示例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)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:13,代码来源:test_pattern.py


示例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)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:13,代码来源:test_pattern.py


示例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)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:13,代码来源:test_pattern.py


示例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)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:13,代码来源:test_pattern.py


示例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
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:16,代码来源:test_pattern.py


示例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())
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:16,代码来源:test_pattern.py


示例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)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:8,代码来源:test_pattern.py


示例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)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:9,代码来源:test_pattern.py


示例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)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:10,代码来源:test_pattern.py


示例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)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:12,代码来源:test_pattern.py


示例16: test_from_graph

 def test_from_graph(self):
     i = Interface('/foo[0:3]')
     i['/foo[0]'] = [0, 'in', 'gpot']
     i['/foo[1]'] = [0, 'out', 'gpot']
     i['/foo[2]'] = [0, 'out', 'spike']
     g = nx.Graph()
     g.add_node('/foo[0]', interface=0, io='in', type='gpot')
     g.add_node('/foo[1]', interface=0, io='out', type='gpot')
     g.add_node('/foo[2]', interface=0, io='out', type='spike')
     ig = Interface.from_graph(g)
     assert_index_equal(i.data.index, ig.data.index)
     assert_frame_equal(i.data, ig.data)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:12,代码来源:test_pattern.py


示例17: test_to_selectors

    def test_to_selectors(self):
        # Selector with multiple levels:
        i = Interface('/foo[0:4]')
        i['/foo[0:2]', 'interface'] = 0
        i['/foo[2:4]', 'interface'] = 1
        self.assertSequenceEqual(i.to_selectors(0),
                                 ['/foo[0]',
                                  '/foo[1]'])
        self.assertSequenceEqual(i.to_selectors(),
                                 ['/foo[0]',
                                  '/foo[1]',
                                  '/foo[2]',
                                  '/foo[3]'])

        # Selector with single level:
        i = Interface('/[foo,bar,baz]')
        i['/foo', 'interface'] = 0
        i['/bar', 'interface'] = 0
        i['/baz', 'interface'] = 1
        self.assertSequenceEqual(i.to_selectors(0),
                                 ['/foo', 
                                  '/bar'])
        self.assertSequenceEqual(i.to_selectors(), 
                                 ['/foo', 
                                  '/bar',
                                  '/baz'])
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:26,代码来源:test_pattern.py


示例18: test_interface_ports

    def test_interface_ports(self):
        # Selector with multiple levels:
        i = Interface('/foo[0:4]')
        i['/foo[0:2]', 'interface'] = 0
        i['/foo[2:4]', 'interface'] = 1
        j = Interface('/foo[2:4]')
        j['/foo[2:4]', 'interface'] = 1

        # Test returning result as Interface:
        assert_frame_equal(i.interface_ports(1).data, j.data)

        # Test returning result as list of tuples:
        self.assertItemsEqual(i.interface_ports(1, True), j.data.index.tolist())

        # Selector with single level:
        i = Interface('/[foo,bar,baz]')
        i['/[foo,bar]', 'interface'] = 0
        i['/baz', 'interface'] = 1
        j = Interface('/baz')
        j['/baz', 'interface'] = 1

        # Test returning result as Interface:
        assert_frame_equal(i.interface_ports(1).data, j.data)

        # Test returning result as list of tuples:
        self.assertItemsEqual(i.interface_ports(1, True), j.data.index.tolist())
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:26,代码来源:test_pattern.py


示例19: test_out_ports

    def test_out_ports(self):
        # Selector with multiple levels:
        i = Interface('/foo[0:2]')
        i['/foo[0]'] = [0, 'in', 'spike']
        i['/foo[1]'] = [1, 'out', 'spike']
        df = pd.DataFrame([(1, 'out', 'spike')],
                          pd.MultiIndex.from_tuples([('foo', 1)],
                                                    names=['0', '1']),
                          ['interface', 'io', 'type'],
                          dtype=object)

        # Test returning result as Interface:
        assert_frame_equal(i.out_ports(1).data, df)

        # Test returning result as list of tuples:
        self.assertItemsEqual(i.out_ports(1, True), df.index.tolist())

        # Selector with single level:
        i = Interface('/[foo,bar]')
        i['/foo'] = [0, 'in', 'spike']
        i['/bar'] = [1, 'out', 'spike']
        df = pd.DataFrame([(1, 'out', 'spike')],
                          pd.MultiIndex.from_tuples([('bar',)],
                                                    names=['0']),
                          ['interface', 'io', 'type'],
                          dtype=object)

        # Test returning result as Interface:
        assert_frame_equal(i.out_ports(1).data, df)

        # Test returning result as list of tuples:
        self.assertItemsEqual(i.out_ports(1, True), df.index.tolist())
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:32,代码来源:test_pattern.py


示例20: test_is_compatible_sel_order

    def test_is_compatible_sel_order(self):
        """
        Interfaces with individually compatible ports that are ordered in
        different ways should still be deemed compatible.
        """

        # Selectors with multiple levels:
        i = Interface('/foo[0:2],/bar[0:2]')
        i['/foo[0:2]', 'interface', 'io'] = [0, 'in']
        i['/bar[0:2]', 'interface', 'io'] = [0, 'out']
        j = Interface('/bar[0:2],/foo[0:2]')
        j['/bar[0:2]', 'interface', 'io'] = [1, 'in']
        j['/foo[0:2]', 'interface', 'io'] = [1, 'out']
        assert i.is_compatible(0, j, 1)

        # Selectors with single level:
        i = Interface('/foo,/bar,/baz,/qux')
        i['/[foo,bar]', 'interface', 'io'] = [0, 'in']
        i['/[baz,qux]', 'interface', 'io'] = [0, 'out']
        j = Interface('/bar,/foo,/qux,/baz')
        j['/[baz,qux]', 'interface', 'io'] = [1, 'in']
        j['/[foo,bar]', 'interface', 'io'] = [1, 'out']
        assert i.is_compatible(0, j, 1)
开发者ID:Taaccoo-beta,项目名称:neurokernel,代码行数:23,代码来源:test_pattern.py



注:本文中的neurokernel.pattern.Interface类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pattern.Pattern类代码示例发布时间:2022-05-27
下一篇:
Python neuro_object.NeuroObject类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap