def __iadd__(self, other):
        """Implement ``self += other``."""
        if self.space.field is None:
            return NotImplemented
        elif other in self.space:
            return self.space.lincomb(1, self, 1, other, out=self)
        elif isinstance(other, LinearSpaceElement):
            # We do not `return NotImplemented` here since we don't want a
            # fallback for in-place. Otherwise python attempts
            # `self = self + other` which does not modify self.
            raise TypeError('cannot add {!r} and {!r} in-place'
                            ''.format(self, other))
        elif other in self.space.field:
            one = getattr(self.space, 'one', None)
            if one is None:
                raise TypeError('cannot add {!r} and {!r} in-place'
                                ''.format(self, other))
            else:
                # other --> other * space.one()
                return self.space.lincomb(1, self, other, one(), out=self)
        else:
            try:
                other = self.space.element(other)
            except (TypeError, ValueError):
                raise TypeError('cannot add {!r} and {!r} in-place'
                                ''.format(self, other))
            else:
                return self.__iadd__(other)
def __iadd__ ( self , other ) : if self . space . field is None : return NotImplemented elif other in self . space : return self . space . lincomb ( 1 , self , 1 , other , out = self ) elif isinstance ( other , LinearSpaceElement ) : raise TypeError ( 'cannot add {!r} and {!r} in-place' '' . format ( self , other ) ) elif other in self . space . field : one = getattr ( self . space , 'one' , None ) if one is None : raise TypeError ( 'cannot add {!r} and {!r} in-place' '' . format ( self , other ) ) else : return self . space . lincomb ( 1 , self , other , one ( ) , out = self ) else : try : other = self . space . element ( other ) except ( TypeError , ValueError ) : raise TypeError ( 'cannot add {!r} and {!r} in-place' '' . format ( self , other ) ) else : return self . __iadd__ ( other )
Implement ``self += other``.