(self, index=None, example=None)
return self
Discard element either by index or example.

        Must provide one of them.

        Parameters
        ----------
        index: int or tuple, optional (default=None)
            Index to discard.

        example: object, optional (default=None)
            Example to discard, must be one of the instance in data repository.
Discard element either by index or example.
Discard element either by index or example .
def discard(self, index=None, example=None):
        """Discard element either by index or example.

        Must provide one of them.

        Parameters
        ----------
        index: int or tuple, optional (default=None)
            Index to discard.

        example: object, optional (default=None)
            Example to discard, must be one of the instance in data repository.
        """
        if index is None and example is None:
            raise Exception("Must provide one of index or example.")
        if index is not None:
            if index not in self._indexes:
                warnings.warn("Index %s is not in the repository, skipped." % str(index),
                              category=ValidityWarning,
                              stacklevel=3)
                return self
            self._indexes.remove(index)
            self._ind2label.pop(index)
            if self._instance_flag:
                self._exa2ind.pop(self._ind2exa.pop(index))

        if example is not None:
            if not self._instance_flag:
                raise Exception("This data base is not initialized with examples, discard by example is illegal.")
            else:
                example = tuple(example)
                if example not in self._exa2ind:
                    warnings.warn("example %s is not in the repository, skipped." % str(example),
                                  category=ValidityWarning,
                                  stacklevel=3)
                    return self
                ind = self._exa2ind[example]
                self._indexes.remove(ind)
                self._exa2ind.pop(example)
                self._ind2exa.pop(ind)
                self._ind2label.pop(ind)
        return self
def discard ( self , index = None , example = None ) : if index is None and example is None : raise Exception ( "Must provide one of index or example." ) if index is not None : if index not in self . _indexes : warnings . warn ( "Index %s is not in the repository, skipped." % str ( index ) , category = ValidityWarning , stacklevel = 3 ) return self self . _indexes . remove ( index ) self . _ind2label . pop ( index ) if self . _instance_flag : self . _exa2ind . pop ( self . _ind2exa . pop ( index ) ) if example is not None : if not self . _instance_flag : raise Exception ( "This data base is not initialized with examples, discard by example is illegal." ) else : example = tuple ( example ) if example not in self . _exa2ind : warnings . warn ( "example %s is not in the repository, skipped." % str ( example ) , category = ValidityWarning , stacklevel = 3 ) return self ind = self . _exa2ind [ example ] self . _indexes . remove ( ind ) self . _exa2ind . pop ( example ) self . _ind2exa . pop ( ind ) self . _ind2label . pop ( ind ) return self