示例#1
0
    def test_dest_idx_dest_type(self):
        p = Pattern('/[aaa,bbb][0:3]', '/[xxx,yyy][0:3]')
        p['/aaa[0]', '/yyy[0]'] = 1
        p['/aaa[0]', '/yyy[1]'] = 1
        p['/aaa[0]', '/yyy[2]'] = 1
        p['/xxx[0]', '/bbb[0]'] = 1
        p['/xxx[1]', '/bbb[1]'] = 1
        p['/xxx[2]', '/bbb[2]'] = 1
        p.interface['/aaa[0:3]', 'type'] = 'spike'
        p.interface['/yyy[0:3]', 'type'] = 'spike'
        self.assertItemsEqual(p.dest_idx(0, 1, dest_type='spike'), 
                              [('yyy', 0),
                               ('yyy', 1),
                               ('yyy', 2)])
        self.assertItemsEqual(p.dest_idx(0, 1, dest_type='gpot'), [])

        q = Pattern('/[aaa,bbb,ccc]', '/[www,xxx,yyy,zzz]')
        q['/aaa','/www'] = 1
        q['/aaa','/xxx'] = 1
        q['/yyy','/bbb'] = 1
        q['/zzz','/ccc'] = 1
        q.interface['/aaa'] = [0, 'in', 'spike']
        q.interface['/[www,xxx]'] = [1, 'out', 'spike']
        self.assertItemsEqual(q.dest_idx(0, 1, dest_type='spike'), 
                              [('www',),
                               ('xxx',)])
        self.assertItemsEqual(q.dest_idx(0, 1, dest_type='gpot'), [])
示例#2
0
    def test_dest_idx_src_type(self):
        p = Pattern('/[aaa,bbb][0:3]', '/[xxx,yyy][0:3]')
        p['/aaa[0]', '/yyy[0]'] = 1
        p['/aaa[0]', '/yyy[1]'] = 1
        p['/aaa[0]', '/yyy[2]'] = 1
        p['/xxx[0]', '/bbb[0]'] = 1
        p['/xxx[1]', '/bbb[1]'] = 1
        p['/xxx[2]', '/bbb[2]'] = 1
        p.interface['/aaa[0:3]'] = [0, 'in', 'spike']
        p.interface['/yyy[0:3]'] = [1, 'out', 'spike']
        self.assertItemsEqual(p.dest_idx(0, 1, src_type='spike'), [('yyy', 0),
                                                                   ('yyy', 1),
                                                                   ('yyy', 2)])
        self.assertItemsEqual(p.dest_idx(0, 1, src_type='gpot'), [])

        q = Pattern('/[aaa,bbb,ccc]', '/[www,xxx,yyy,zzz]')
        q['/aaa', '/www'] = 1
        q['/aaa', '/xxx'] = 1
        q['/yyy', '/bbb'] = 1
        q['/zzz', '/ccc'] = 1
        q.interface['/aaa'] = [0, 'in', 'spike']
        q.interface['/[www,xxx]'] = [1, 'out', 'spike']
        self.assertItemsEqual(q.dest_idx(0, 1, src_type='spike'), [('www', ),
                                                                   ('xxx', )])
        self.assertItemsEqual(q.dest_idx(0, 1, src_type='gpot'), [])
示例#3
0
 def test_dest_idx_dest_type(self):
     p = Pattern('/[aaa,bbb][0:3]', '/[xxx,yyy][0:3]')
     p['/aaa[0]', '/yyy[0]'] = 1
     p['/aaa[0]', '/yyy[1]'] = 1
     p['/aaa[0]', '/yyy[2]'] = 1
     p['/xxx[0]', '/bbb[0]'] = 1
     p['/xxx[1]', '/bbb[1]'] = 1
     p['/xxx[2]', '/bbb[2]'] = 1
     p.interface['/aaa[0:3]', 'type'] = 'spike'
     p.interface['/yyy[0:3]', 'type'] = 'spike'
     self.assertItemsEqual(p.dest_idx(0, 1, dest_type='spike'), 
                           [('yyy', 0),
                            ('yyy', 1),
                            ('yyy', 2)])
     self.assertItemsEqual(p.dest_idx(0, 1, dest_type='gpot'), [])
示例#4
0
    def test_dest_idx_src_ports(self):
        p = Pattern('/[aaa,bbb][0:3]', '/[xxx,yyy][0:3]')
        p['/aaa[0]', '/yyy[0]'] = 1
        p['/aaa[0]', '/yyy[1]'] = 1
        p['/aaa[0]', '/yyy[2]'] = 1
        p['/xxx[0]', '/bbb[0]'] = 1
        p['/xxx[1]', '/bbb[1]'] = 1
        p['/xxx[2]', '/bbb[2]'] = 1
        self.assertItemsEqual(p.dest_idx(0, 1, src_ports='/aaa[0]'),
                              [('yyy', 0), ('yyy', 1), ('yyy', 2)])

        q = Pattern('/[aaa,bbb]', '/[www,xxx,yyy]')
        q['/aaa', '/www'] = 1
        q['/aaa', '/xxx'] = 1
        q['/bbb', '/yyy'] = 1
        self.assertItemsEqual(q.dest_idx(0, 1, src_ports='/aaa'), [('www', ),
                                                                   ('xxx', )])
示例#5
0
    def test_dest_idx_src_ports(self):
        p = Pattern('/[aaa,bbb][0:3]', '/[xxx,yyy][0:3]')
        p['/aaa[0]', '/yyy[0]'] = 1
        p['/aaa[0]', '/yyy[1]'] = 1
        p['/aaa[0]', '/yyy[2]'] = 1
        p['/xxx[0]', '/bbb[0]'] = 1
        p['/xxx[1]', '/bbb[1]'] = 1
        p['/xxx[2]', '/bbb[2]'] = 1
        self.assertItemsEqual(p.dest_idx(0, 1, src_ports='/aaa[0]'),
                              [('yyy', 0),
                               ('yyy', 1),
                               ('yyy', 2)])

        q = Pattern('/[aaa,bbb]', '/[www,xxx,yyy]')
        q['/aaa','/www'] = 1
        q['/aaa','/xxx'] = 1
        q['/bbb','/yyy'] = 1
        self.assertItemsEqual(q.dest_idx(0, 1, src_ports='/aaa'),
                              [('www',),
                               ('xxx',)])
示例#6
0
 def test_dest_idx(self):
     p = Pattern('/[aaa,bbb][0:3]', '/[xxx,yyy][0:3]')
     p['/aaa[0]', '/yyy[0]'] = 1
     p['/aaa[1]', '/yyy[1]'] = 1
     p['/aaa[2]', '/yyy[2]'] = 1
     p['/xxx[0]', '/bbb[0]'] = 1
     p['/xxx[1]', '/bbb[1]'] = 1
     p['/xxx[2]', '/bbb[2]'] = 1
     self.assertItemsEqual(p.dest_idx(0, 1),
                           [('yyy', 0),
                            ('yyy', 1),
                            ('yyy', 2)])