(expression)
return new_expr, residual_expr
Extract from a ``TensExpr`` all elements of this type.

        Returns two tensor expressions:

        * the first contains all ``TensorHead`` of this type.
        * the second contains all remaining.
Extract from a ``TensExpr`` all elements of this type.
Extract from a TensExpr all elements of this type .
def extract_type_tens(expression):
        """
        Extract from a ``TensExpr`` all elements of this type.

        Returns two tensor expressions:

        * the first contains all ``TensorHead`` of this type.
        * the second contains all remaining.


        """
        sp = expression.split()

        # Collect all gamma matrices of the same dimension
        new_expr = S.One
        residual_expr = S.One
        for i in sp:
            if isinstance(i.args[1][0], GammaMatrixHead):
                new_expr *= i
            else:
                residual_expr *= i
        return new_expr, residual_expr
def extract_type_tens ( expression ) : sp = expression . split ( ) # Collect all gamma matrices of the same dimension new_expr = S . One residual_expr = S . One for i in sp : if isinstance ( i . args [ 1 ] [ 0 ] , GammaMatrixHead ) : new_expr *= i else : residual_expr *= i return new_expr , residual_expr