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

        Must provide one of them.

        Parameters
        ----------
        index: int, 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, 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
            ind = np.argwhere(self._indexes == index)

        if example is not None:
            if not self._instance_flag:
                raise Exception("This repository is not initialized with examples, discard by example is illegal.")
            else:
                ind = self._find_one_example(example)
            if ind == -1:
                warnings.warn("Example %s for retrieving is not in the repository, skip." % str(example),
                              category=ValidityWarning)
                return self

        mask = np.ones(len(self._indexes), dtype=bool)
        mask[ind] = False
        self._y = self._y[mask]
        self._indexes = self._indexes[mask]
        if self._instance_flag:
            self._X = self._X[mask]
        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 ind = np . argwhere ( self . _indexes == index ) if example is not None : if not self . _instance_flag : raise Exception ( "This repository is not initialized with examples, discard by example is illegal." ) else : ind = self . _find_one_example ( example ) if ind == - 1 : warnings . warn ( "Example %s for retrieving is not in the repository, skip." % str ( example ) , category = ValidityWarning ) return self mask = np . ones ( len ( self . _indexes ) , dtype = bool ) mask [ ind ] = False self . _y = self . _y [ mask ] self . _indexes = self . _indexes [ mask ] if self . _instance_flag : self . _X = self . _X [ mask ] return self