@@ -0,0 +1,3319 @@
+import pandas%0A%0Aclass DynamicTable(object):%0A    %22%22%22%0A    Dynamically sized table.%0A    %22%22%22%0A%0A    def __init__(self, *args, **kwargs):%0A        self._data = pandas.DataFrame(*args, **kwargs)%0A%0A    def __getitem__(self, key):%0A        %22%22%22%0A        Retrieve a value from the table.%0A%0A        Note%0A        ----%0A        The first index in the key specifies the column.%0A        %22%22%22%0A%0A        if len(key) != 2:%0A            raise KeyError('invalid key')%0A%0A        col, row = key%0A        return self._data.__getitem__(col).__getitem__(row)%0A%0A    def __setitem__(self, key, value):%0A        %22%22%22%0A        Set the specified entry in the table.%0A%0A        Notes%0A        -----%0A        The first index in the key specifies the column.%0A%0A        If the specified row or column identifiers do not exist, the%0A        table is expanded to include rows or columns with those%0A        identifiers.%0A%0A        %22%22%22%0A%0A        if len(key) != 2:%0A            raise KeyError('invalid key')%0A        col, row = key%0A        if row not in self.data.index:%0A            new_row = pandas.DataFrame(index=%5Brow%5D,                                       %0A                                       columns=self._data.columns)%0A            self._data = pandas.concat(%5Bself._data, new_row%5D)%0A        if col not in self._data.columns:%0A            new_col = pandas.DataFrame(index=self._data.index,              %0A                                       columns=%5Bcol%5D)%0A            self._data = pandas.concat(%5Bself._data, new_col%5D, axis=1)%0A        self._data%5Bcol%5D%5Brow%5D = value%0A%0A    @property%0A    def table(self):%0A        %22%22%22%0A        Return a view of the current table.%0A        %22%22%22%0A%0A        return self._data%0A%0A    def __repr__(self):%0A        return self._data.__repr__()%0A%0Aclass RoutingTable(DynamicTable):%0A    %22%22%22%0A    Routing table.%0A    %22%22%22%0A%0A    def __init__(self):%0A        DynamicTable.__init__(self)%0A%0A    def __setitem__(self, key, value):%0A        %22%22%22%0A        Set the specified entry in the table.%0A%0A        Notes%0A        -----%0A        The first index in the key specifies the column.%0A%0A        If the specified row or column identifiers do not exist, the%0A        table is expanded to include rows or columns with those%0A        identifiers.%0A%0A        %22%22%22%0A%0A        if len(key) != 2:%0A            raise KeyError('invalid key')%0A        col, row = key%0A%0A        # Since the routing table must describe routes between all%0A        # recognized entities, adding a hitherto unrecognized row or%0A        # column identifier must cause that identifier to be added to%0A        # both the list of rows and columns:%0A        Nc = len(self._data.columns)%0A        Nr = len(self._data.index)%0A        for k in (col, row):%0A            if k not in self._data.index:%0A                new_row = pandas.DataFrame(index=%5Bk%5D,%0A                                           columns=self._data.columns)%0A                self._data = pandas.concat(%5Bself._data, new_row%5D)%0A            if k not in self._data.columns:%0A                new_col = pandas.DataFrame(index=self._data.index,                      %0A                                           columns=%5Bk%5D)%0A                self._data = pandas.concat(%5Bself._data, new_col%5D, axis=1)%0A        self._data%5Bcol%5D%5Brow%5D = value%0A%0A    @property%0A    def ids(self):%0A        %22%22%22%0A        Identifiers of rows and columns in the routing table.%0A        %22%22%22%0A%0A        return self._data.index.tolist()%0A

Add routing table class based on pandas.DataFrame.