(self, label, index, example=None, cost=None)
Adding entry to the oracle.

        Add new entry to the oracle for future querying where index is the queried elements,
        label is the returned data. Index should not be in the oracle. Example and cost should
        accord with the initializing (If exists in initializing, then must be provided.)

        The data provided must have the same type with the initializing data. If different, a
        transform is attempted.

        Parameters
        ----------
        label:  array-like
            Label matrix.

        index: object
            Index of examples, should not in the oracle.

        example: array-like, optional (default=None)
            Array of examples, initialize with this parameter to turn
            "query by instance" on.

        cost: array_like, optional (default=None)
            Cost of each queried instance, should have the same length
            and is one-to-one correspondence of y, default is 1.
Adding entry to the oracle.
Adding entry to the oracle .
def _add_one_entry(self, label, index, example=None, cost=None):
        """Adding entry to the oracle.

        Add new entry to the oracle for future querying where index is the queried elements,
        label is the returned data. Index should not be in the oracle. Example and cost should
        accord with the initializing (If exists in initializing, then must be provided.)

        The data provided must have the same type with the initializing data. If different, a
        transform is attempted.

        Parameters
        ----------
        label:  array-like
            Label matrix.

        index: object
            Index of examples, should not in the oracle.

        example: array-like, optional (default=None)
            Array of examples, initialize with this parameter to turn
            "query by instance" on.

        cost: array_like, optional (default=None)
            Cost of each queried instance, should have the same length
            and is one-to-one correspondence of y, default is 1.
        """
        if isinstance(label, np.generic):
            # label = np.asscalar(label)    # deprecated in numpy v1.16
            label = label.item()
        if isinstance(label, list):
            label = np.array(label)
        if not isinstance(label, self._label_type):
            raise TypeError("Different types of _labels found when adding entries: %s is expected but received: %s" %
                            (str(self._label_type), str(type(label))))
        if self._instance_flag:
            if example is None:
                raise Exception("This oracle has the instance information,"
                                "must provide example parameter when adding entry")
            example = tuple(example)
            self._exa2ind[example] = index
        if self._cost_flag:
            if cost is None:
                raise Exception("This oracle has the cost information,"
                                "must provide cost parameter when adding entry")
            self._ind2all[index] = (label, cost)
        else:
            self._ind2all[index] = label
def _add_one_entry ( self , label , index , example = None , cost = None ) : if isinstance ( label , np . generic ) : # label = np.asscalar(label)    # deprecated in numpy v1.16 label = label . item ( ) if isinstance ( label , list ) : label = np . array ( label ) if not isinstance ( label , self . _label_type ) : raise TypeError ( "Different types of _labels found when adding entries: %s is expected but received: %s" % ( str ( self . _label_type ) , str ( type ( label ) ) ) ) if self . _instance_flag : if example is None : raise Exception ( "This oracle has the instance information," "must provide example parameter when adding entry" ) example = tuple ( example ) self . _exa2ind [ example ] = index if self . _cost_flag : if cost is None : raise Exception ( "This oracle has the cost information," "must provide cost parameter when adding entry" ) self . _ind2all [ index ] = ( label , cost ) else : self . _ind2all [ index ] = label