def relabel(self, label_map):
        """Returns a copy of the catalogue with the labels remapped according
        to `label_map`.

        `label_map` is a dictionary mapping existing labels to new
        labels. Any existing label that is not given a mapping is
        deleted from the resulting catalogue.

        :param label_map: mapping of labels to new labels
        :type label_map: `dict`
        :rtype: `tacl.Catalogue`

        """
        catalogue = copy.deepcopy(self)
        to_delete = set()
        for work, old_label in catalogue.items():
            if old_label in label_map:
                catalogue[work] = label_map[old_label]
            else:
                to_delete.add(catalogue[work])
        for label in to_delete:
            catalogue.remove_label(label)
        return catalogue
def relabel ( self , label_map ) : catalogue = copy . deepcopy ( self ) to_delete = set ( ) for work , old_label in catalogue . items ( ) : if old_label in label_map : catalogue [ work ] = label_map [ old_label ] else : to_delete . add ( catalogue [ work ] ) for label in to_delete : catalogue . remove_label ( label ) return catalogue
Returns a copy of the catalogue with the labels remapped according
        to `label_map`.

        `label_map` is a dictionary mapping existing labels to new
        labels. Any existing label that is not given a mapping is
        deleted from the resulting catalogue.

        :param label_map: mapping of labels to new labels
        :type label_map: `dict`
        :rtype: `tacl.Catalogue`