(self, printer=None)
return outstr
Printing method.
Printing method.
Printing method .
def __str__(self, printer=None):
        """Printing method. """
        from sympy.physics.vector.printing import VectorStrPrinter
        ar = self.args  # just to shorten things
        if len(ar) == 0:
            return str(0)
        ol = []  # output list, to be concatenated to a string
        for i, v in enumerate(ar):
            for j in 0, 1, 2:
                # if the coef of the basis vector is 1, we skip the 1
                if ar[i][0][j] == 1:
                    ol.append(' + ' + ar[i][1].str_vecs[j])
                # if the coef of the basis vector is -1, we skip the 1
                elif ar[i][0][j] == -1:
                    ol.append(' - ' + ar[i][1].str_vecs[j])
                elif ar[i][0][j] != 0:
                    # If the coefficient of the basis vector is not 1 or -1;
                    # also, we might wrap it in parentheses, for readability.
                    arg_str = VectorStrPrinter().doprint(ar[i][0][j])
                    if isinstance(ar[i][0][j], Add):
                        arg_str = "(%s)" % arg_str
                    if arg_str[0] == '-':
                        arg_str = arg_str[1:]
                        str_start = ' - '
                    else:
                        str_start = ' + '
                    ol.append(str_start + arg_str + '*' + ar[i][1].str_vecs[j])
        outstr = ''.join(ol)
        if outstr.startswith(' + '):
            outstr = outstr[3:]
        elif outstr.startswith(' '):
            outstr = outstr[1:]
        return outstr
def __str__ ( self , printer = None ) : from sympy . physics . vector . printing import VectorStrPrinter ar = self . args # just to shorten things if len ( ar ) == 0 : return str ( 0 ) ol = [ ] # output list, to be concatenated to a string for i , v in enumerate ( ar ) : for j in 0 , 1 , 2 : # if the coef of the basis vector is 1, we skip the 1 if ar [ i ] [ 0 ] [ j ] == 1 : ol . append ( ' + ' + ar [ i ] [ 1 ] . str_vecs [ j ] ) # if the coef of the basis vector is -1, we skip the 1 elif ar [ i ] [ 0 ] [ j ] == - 1 : ol . append ( ' - ' + ar [ i ] [ 1 ] . str_vecs [ j ] ) elif ar [ i ] [ 0 ] [ j ] != 0 : # If the coefficient of the basis vector is not 1 or -1; # also, we might wrap it in parentheses, for readability. arg_str = VectorStrPrinter ( ) . doprint ( ar [ i ] [ 0 ] [ j ] ) if isinstance ( ar [ i ] [ 0 ] [ j ] , Add ) : arg_str = "(%s)" % arg_str if arg_str [ 0 ] == '-' : arg_str = arg_str [ 1 : ] str_start = ' - ' else : str_start = ' + ' ol . append ( str_start + arg_str + '*' + ar [ i ] [ 1 ] . str_vecs [ j ] ) outstr = '' . join ( ol ) if outstr . startswith ( ' + ' ) : outstr = outstr [ 3 : ] elif outstr . startswith ( ' ' ) : outstr = outstr [ 1 : ] return outstr