Esempio n. 1
0
 def test_src_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.src_idx(0, 1, dest_type='spike'), 
                           [('aaa', 0)])
     self.assertItemsEqual(p.src_idx(0, 1, dest_type='gpot'), [])
Esempio n. 2
0
    def test_src_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.src_idx(0, 1), [('aaa', 0), ('aaa', 1),
                                                ('aaa', 2)])

        q = Pattern('/[aaa,bbb]', '/[www,xxx,yyy]')
        q['/aaa', '/www'] = 1
        q['/aaa', '/xxx'] = 1
        q['/bbb', '/yyy'] = 1
        self.assertItemsEqual(q.src_idx(0, 1), [('aaa', ), ('bbb', )])
Esempio n. 3
0
    def test_src_idx_dest_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.src_idx(0, 1, dest_ports='/yyy[0]'),
                              [('aaa', 0)])

        q = Pattern('/[aaa,bbb]', '/[www,xxx,yyy]')
        q['/aaa','/www'] = 1
        q['/aaa','/xxx'] = 1
        q['/bbb','/yyy'] = 1
        self.assertItemsEqual(q.src_idx(0, 1, dest_ports='/[www,xxx]'),
                              [('aaa',)])
Esempio n. 4
0
 def test_src_idx_dest_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.src_idx(0, 1, dest_ports='/yyy[0]'),
                           [('aaa', 0)])
Esempio n. 5
0
    def test_src_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.src_idx(0, 1, dest_type='spike'), [('aaa', 0)])
        self.assertItemsEqual(p.src_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.src_idx(0, 1, dest_type='spike'), [('aaa', )])
        self.assertItemsEqual(q.src_idx(0, 1, dest_type='gpot'), [])
Esempio n. 6
0
    def test_src_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.src_idx(0, 1, dest_type='spike'), 
                              [('aaa', 0)])
        self.assertItemsEqual(p.src_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.src_idx(0, 1, dest_type='spike'), 
                              [('aaa',)])
        self.assertItemsEqual(q.src_idx(0, 1, dest_type='gpot'), [])
Esempio n. 7
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.src_idx(0, 1, src_type='gpot'), [])