def perm2tensor(t, g, canon_bp=False):
    """
    Returns the tensor corresponding to the permutation ``g``

    For further details, see the method in ``TIDS`` with the same name.
    """
    if not isinstance(t, TensExpr):
        return t
    new_tids = get_tids(t).perm2tensor(g, canon_bp)
    coeff = get_coeff(t)
    if g[-1] != 1 - len(g):
        coeff = -coeff
    res = TensMul.from_TIDS(coeff, new_tids, is_canon_bp=canon_bp)
    return res
dataset/ETHPy150Open sympy/sympy/sympy/tensor/tensor.py/perm2tensor/swapped operands of `-`