Пример #1
0
 def setUp(self):
     self.connections_orig = [('a', 'b'), ('b', 'c')]
     self.ids_orig = set([i[0] for i in self.connections_orig]+\
                         [i[1] for i in self.connections_orig])
     self.t = RoutingTable()
     for c in self.connections_orig:
         self.t[c[0], c[1]] = 1
Пример #2
0
 def test_subtable(self):
     t = RoutingTable()
     t['a', 'b'] = 1
     t['b', 'c'] = 1
     t['c', 'd'] = 1
     t['d', 'a'] = 1
     s = t.subtable(['a', 'b', 'c'])
     assert set(s.ids) == set(['a', 'b', 'c'])
     assert set(s.connections) == set([('a', 'b'), ('b', 'c')])
Пример #3
0
 def test_subtable(self):
     t = RoutingTable()
     t['a', 'b'] = 1
     t['b', 'c'] = 1
     t['c', 'd'] = 1
     t['d', 'a'] = 1
     s = t.subtable(['a', 'b', 'c'])
     assert set(s.ids) == set(['a', 'b', 'c'])
     assert set(s.connections) == set([('a', 'b'), ('b', 'c')])
Пример #4
0
 def setUp(self):
     self.connections_orig = [('a', 'b'), ('b', 'c')]
     self.ids_orig = set([i[0] for i in self.connections_orig]+\
                         [i[1] for i in self.connections_orig])
     self.t = RoutingTable()
     for c in self.connections_orig:
         self.t[c[0], c[1]] = 1
Пример #5
0
 def test_getitem_non_dict(self):
     t = RoutingTable()
     t.data.add_node('a')
     t.data.add_node('b')
     t.data.add_edge('a', 'b', **{'data': [1, 2]})
     assert t['a', 'b'] == [1, 2]
     assert t['a', 'b', 'data'] == [1, 2]
Пример #6
0
 def test_getitem_dict(self):
     t = RoutingTable()
     t.data.add_node('a')
     t.data.add_node('b')
     t.data.add_edge('a', 'b', **{'x': 1, 'y': 2})
     assert t['a', 'b'] == {'x': 1, 'y': 2}
     assert t['a', 'b', 'x'] == 1
Пример #7
0
 def test_getitem_scalar(self):
     t = RoutingTable()
     t.data.add_node('a')
     t.data.add_node('b')
     t.data.add_edge('a', 'b', **{'data': 1})
     assert t['a', 'b'] == 1
     assert t['a', 'b', 'data'] == 1
Пример #8
0
class test_routingtable(TestCase):
    def setUp(self):
        self.connections_orig = [('a', 'b'), ('b', 'c')]
        self.ids_orig = set([i[0] for i in self.connections_orig]+\
                            [i[1] for i in self.connections_orig])
        self.t = RoutingTable()
        for c in self.connections_orig:
            self.t[c[0], c[1]] = 1

    def test_ids(self):
        assert set(self.t.ids) == self.ids_orig

    def test_connections(self):
        assert set(self.t.connections) == set(self.connections_orig)

    def test_setitem(self):
        t = RoutingTable()
        t['a', 'b'] = 1
        assert t.data.has_node('a')
        assert t.data.has_node('b')
        assert t.data.has_edge('a', 'b')

    def test_getitem(self):
        t = RoutingTable()
        t.data.add_node('a')
        t.data.add_node('b')
        t.data.add_edge('a', 'b', {'data': 1})
        assert t['a', 'b'] == 1

    def test_src_ids(self):
        for i in self.connections_orig:
            assert i[0] in self.t.src_ids(i[1])

    def test_dest_ids(self):
        for i in self.connections_orig:
            assert i[1] in self.t.dest_ids(i[0])
Пример #9
0
class test_routingtable(TestCase):
    def setUp(self):
        self.connections_orig = [('a', 'b'), ('b', 'c')]
        self.ids_orig = set([i[0] for i in self.connections_orig]+\
                            [i[1] for i in self.connections_orig])
        self.t = RoutingTable()
        for c in self.connections_orig:
            self.t[c[0], c[1]] = 1

    def test_ids(self):
        assert set(self.t.ids) == self.ids_orig

    def test_connections(self):
        assert set(self.t.connections) == set(self.connections_orig)

    def test_setitem(self):
        t = RoutingTable()
        t['a', 'b'] = 1
        assert t.data.has_node('a')
        assert t.data.has_node('b')
        assert t.data.has_edge('a', 'b')

    def test_getitem(self):
        t = RoutingTable()
        t.data.add_node('a')
        t.data.add_node('b')
        t.data.add_edge('a', 'b', {'data':1})
        assert t['a', 'b'] == 1

    def test_src_ids(self):
        for i in self.connections_orig:
            assert i[0] in self.t.src_ids(i[1])

    def test_dest_ids(self):
        for i in self.connections_orig:
            assert i[1] in self.t.dest_ids(i[0])
Пример #10
0
    def __init__(self, required_args=['sel', 'sel_in', 'sel_out',
                                      'sel_gpot', 'sel_spike'],
                 ctrl_tag=CTRL_TAG):
        super(Manager, self).__init__(ctrl_tag)

        # Required constructor args:
        self.required_args = required_args

        # One-to-one mapping between MPI rank and module ID:
        self.rank_to_id = bidict.bidict()

        # Unique object ID:
        self.id = uid()

        # Set up a dynamic table to contain the routing table:
        self.routing_table = RoutingTable()

        # Number of emulation steps to run:
        self.steps = np.inf

        # Variables for timing run loop:
        self.start_time = 0.0
        self.stop_time = 0.0

        # Variables for computing throughput:
        self.counter = 0
        self.total_sync_time = 0.0
        self.total_sync_nbytes = 0.0
        self.received_data = {}

        # Average step synchronization time:
        self._average_step_sync_time = 0.0

        # Computed throughput (only updated after an emulation run):
        self._average_throughput = 0.0
        self._total_throughput = 0.0
        self.log_info('manager instantiated')
Пример #11
0
class test_routingtable(TestCase):
    def setUp(self):
        self.connections_orig = [('a', 'b'), ('b', 'c')]
        self.ids_orig = set([i[0] for i in self.connections_orig]+\
                            [i[1] for i in self.connections_orig])
        self.t = RoutingTable()
        for c in self.connections_orig:
            self.t[c[0], c[1]] = 1

    def test_ids(self):
        assert set(self.t.ids) == self.ids_orig

    def test_connections(self):
        assert set(self.t.connections) == set(self.connections_orig)

    def test_setitem(self):
        t = RoutingTable()
        t['a', 'b'] = 1
        assert t.data.has_node('a')
        assert t.data.has_node('b')
        assert t.data.has_edge('a', 'b')

    def test_getitem_scalar(self):
        t = RoutingTable()
        t.data.add_node('a')
        t.data.add_node('b')
        t.data.add_edge('a', 'b', {'data': 1})
        assert t['a', 'b'] == 1
        assert t['a', 'b', 'data'] == 1

    def test_getitem_non_dict(self):
        t = RoutingTable()
        t.data.add_node('a')
        t.data.add_node('b')
        t.data.add_edge('a', 'b', {'data': [1, 2]})
        assert t['a', 'b'] == [1, 2]
        assert t['a', 'b', 'data'] == [1, 2]

    def test_getitem_dict(self):
        t = RoutingTable()
        t.data.add_node('a')
        t.data.add_node('b')
        t.data.add_edge('a', 'b', {'x': 1, 'y': 2})
        assert t['a', 'b'] == {'x': 1, 'y': 2}
        assert t['a', 'b', 'x'] == 1

    def test_src_ids(self):
        for i in self.connections_orig:
            assert i[0] in self.t.src_ids(i[1])
        assert self.t.src_ids('d') == []

    def test_dest_ids(self):
        for i in self.connections_orig:
            assert i[1] in self.t.dest_ids(i[0])
        assert self.t.src_ids('d') == []

    def test_subtable(self):
        t = RoutingTable()
        t['a', 'b'] = 1
        t['b', 'c'] = 1
        t['c', 'd'] = 1
        t['d', 'a'] = 1
        s = t.subtable(['a', 'b', 'c'])
        assert set(s.ids) == set(['a', 'b', 'c'])
        assert set(s.connections) == set([('a', 'b'), ('b', 'c')])
Пример #12
0
class test_routingtable(TestCase):
    def setUp(self):
        self.connections_orig = [('a', 'b'), ('b', 'c')]
        self.ids_orig = set([i[0] for i in self.connections_orig]+\
                            [i[1] for i in self.connections_orig])
        self.t = RoutingTable()
        for c in self.connections_orig:
            self.t[c[0], c[1]] = 1

    def test_ids(self):
        assert set(self.t.ids) == self.ids_orig

    def test_connections(self):
        assert set(self.t.connections) == set(self.connections_orig)

    def test_setitem(self):
        t = RoutingTable()
        t['a', 'b'] = 1
        assert t.data.has_node('a')
        assert t.data.has_node('b')
        assert t.data.has_edge('a', 'b')

    def test_getitem_scalar(self):
        t = RoutingTable()
        t.data.add_node('a')
        t.data.add_node('b')
        t.data.add_edge('a', 'b', **{'data': 1})
        assert t['a', 'b'] == 1
        assert t['a', 'b', 'data'] == 1

    def test_getitem_non_dict(self):
        t = RoutingTable()
        t.data.add_node('a')
        t.data.add_node('b')
        t.data.add_edge('a', 'b', **{'data': [1, 2]})
        assert t['a', 'b'] == [1, 2]
        assert t['a', 'b', 'data'] == [1, 2]

    def test_getitem_dict(self):
        t = RoutingTable()
        t.data.add_node('a')
        t.data.add_node('b')
        t.data.add_edge('a', 'b', **{'x': 1, 'y': 2})
        assert t['a', 'b'] == {'x': 1, 'y': 2}
        assert t['a', 'b', 'x'] == 1

    def test_src_ids(self):
        for i in self.connections_orig:
            assert i[0] in self.t.src_ids(i[1])
        assert self.t.src_ids('d') == []

    def test_dest_ids(self):
        for i in self.connections_orig:
            assert i[1] in self.t.dest_ids(i[0])
        assert self.t.src_ids('d') == []

    def test_subtable(self):
        t = RoutingTable()
        t['a', 'b'] = 1
        t['b', 'c'] = 1
        t['c', 'd'] = 1
        t['d', 'a'] = 1
        s = t.subtable(['a', 'b', 'c'])
        assert set(s.ids) == set(['a', 'b', 'c'])
        assert set(s.connections) == set([('a', 'b'), ('b', 'c')])
Пример #13
0
 def test_setitem(self):
     t = RoutingTable()
     t['a', 'b'] = 1
     assert t.data.has_node('a')
     assert t.data.has_node('b')
     assert t.data.has_edge('a', 'b')