(self, value)
return self
Add element.

        It will warn if the value to add is existent. Raise if
        invalid type of value is given.

        Parameters
        ----------
        value: tuple
            Index for adding. Raise if index is out of bound.

        Returns
        -------
        self: object
            return self.
Add element.
Add element .
def add(self, value):
        """Add element.

        It will warn if the value to add is existent. Raise if
        invalid type of value is given.

        Parameters
        ----------
        value: tuple
            Index for adding. Raise if index is out of bound.

        Returns
        -------
        self: object
            return self.
        """
        # check validation
        assert (isinstance(value, tuple))
        if len(value) == 1:
            value = [(value[0], i) for i in range(self._label_size)]
            return self.update(value)
        elif len(value) == 2:
            if isinstance(value[1], collections.Iterable):
                for item in value[1]:
                    if item >= self._label_size:
                        raise ValueError("Index %s is out of bound %s" % (str(item), str(self._label_size)))
            else:
                if value[1] >= self._label_size:
                    raise ValueError("Index %s is out of bound %s" % (str(value[1]), str(self._label_size)))
        else:
            raise ValueError("A tuple with 1 or 2 elements is expected, but received: %s" % str(value))
        if value in self._innercontainer:
            warnings.warn("Adding element %s has already in the collection, skip." % (value.__str__()),
                          category=RepeatElementWarning,
                          stacklevel=3)
        else:
            self._innercontainer.add(value)
        return self
def add ( self , value ) : # check validation assert ( isinstance ( value , tuple ) ) if len ( value ) == 1 : value = [ ( value [ 0 ] , i ) for i in range ( self . _label_size ) ] return self . update ( value ) elif len ( value ) == 2 : if isinstance ( value [ 1 ] , collections . Iterable ) : for item in value [ 1 ] : if item >= self . _label_size : raise ValueError ( "Index %s is out of bound %s" % ( str ( item ) , str ( self . _label_size ) ) ) else : if value [ 1 ] >= self . _label_size : raise ValueError ( "Index %s is out of bound %s" % ( str ( value [ 1 ] ) , str ( self . _label_size ) ) ) else : raise ValueError ( "A tuple with 1 or 2 elements is expected, but received: %s" % str ( value ) ) if value in self . _innercontainer : warnings . warn ( "Adding element %s has already in the collection, skip." % ( value . __str__ ( ) ) , category = RepeatElementWarning , stacklevel = 3 ) else : self . _innercontainer . add ( value ) return self