def load(self, name):
            '''
            This method will load the matrix from the
            database.
            '''
            if not probability_table_exists():
                raise AssertionError

            self._bibmap, self._matrix = load_bibmap_and_matrix_from_db(name)
        def store(self, name):
            '''
            This method will store the matrix to the
            database.
            '''
            if not probability_table_exists():
                raise AssertionError

            save_bibmap_and_matrix_to_db(name, self._bibmap, self._matrix)
        def load(self, name):
            '''
            This method will load the matrix from the
            database.
            '''
            if not probability_table_exists():
                raise AssertionError

            self._bibmap, self._matrix = load_bibmap_and_matrix_from_db(name)
        def store(self, name):
            '''
            This method will store the matrix to the
            database.
            '''
            if not probability_table_exists():
                raise AssertionError

            save_bibmap_and_matrix_to_db(name, self._bibmap, self._matrix)
    def __init__(self,
                 cluster_set,
                 last_name="",
                 cached=[],
                 use_cache=False,
                 save_cache=False):
        '''
        Constructs probability matrix. If use_cache is true, it will
        try to load old computations from the database. If save cache
        is true it will save the current results into the database.
        @param cluster_set: A cluster set object, used to initialize
        the matrix.
        @param last_name: A string which defines the current cluster
        of names. It is used only if use_cache or save_cache is true.
        @param cached: A list with the bibs, which are not touched
        since last save.
        '''
        self._bib_matrix = self.bib_matrix(cluster_set)

        old_matrix = self.bib_matrix()
        if use_cache and probability_table_exists():
            old_matrix.load(last_name)
        elif cached:
            raise AssertionError("You cannot have cached"
                                 "results and empty table!")

        for cl1 in cluster_set.clusters:
            for cl2 in cluster_set.clusters:
                if id(cl1) != id(cl2) and cl1.hates(cl2) == False:
                    for bib1 in cl1.bibs:
                        for bib2 in cl2.bibs:
                            if bib1 in cached and bib2 in cached:
                                val = old_matrix[bib1, bib2]
                                if val == None:
                                    val = compare_bibrefrecs(bib1, bib2)
                            else:
                                val = compare_bibrefrecs(bib1, bib2)
                            self._bib_matrix[bib1, bib2] = val

        if save_cache:
            if not probability_table_exists():
                create_probability_table()
            self._bib_matrix.store(last_name)
    def __init__(self, cluster_set, last_name="", cached = [],
                 use_cache = False, save_cache = False):
        '''
        Constructs probability matrix. If use_cache is true, it will
        try to load old computations from the database. If save cache
        is true it will save the current results into the database.
        @param cluster_set: A cluster set object, used to initialize
        the matrix.
        @param last_name: A string which defines the current cluster
        of names. It is used only if use_cache or save_cache is true.
        @param cached: A list with the bibs, which are not touched
        since last save.
        '''
        self._bib_matrix = self.bib_matrix(cluster_set)

        old_matrix = self.bib_matrix()
        if use_cache and probability_table_exists():
            old_matrix.load(last_name)
        elif cached:
            raise AssertionError("You cannot have cached"
                                  "results and empty table!")

        for cl1 in cluster_set.clusters:
            for cl2 in cluster_set.clusters:
                if id(cl1) != id(cl2) and cl1.hates(cl2) == False:
                    for bib1 in cl1.bibs:
                        for bib2 in cl2.bibs:
                            if bib1 in cached and bib2 in cached:
                                val = old_matrix[bib1, bib2]
                                if val == None:
                                    val = compare_bibrefrecs(bib1, bib2)
                            else:
                                val = compare_bibrefrecs(bib1, bib2)
                            self._bib_matrix[bib1, bib2] = val

        if save_cache:
            if not probability_table_exists():
                create_probability_table()
            self._bib_matrix.store(last_name)