Ticket #13735: trac_13735-fix_bug_in_coef_repr-cs.patch

File trac_13735-fix_bug_in_coef_repr-cs.patch, 2.1 KB (added by stumpc5, 9 years ago)
  • sage/algebras/free_algebra_element.py

    # HG changeset patch
    # User Christian Stump <christian.stump at gmail.com>
    # Date 1353496186 -3600
    # Node ID 4e0e81603c8f02f21c17674a433e6ab12a1eda2b
    # Parent  c9f90caab48ca72303f214267162311a1e72170f
    trac 13735: fix a bug in sage.misc.misc.coeff_repr
    
    diff --git a/sage/algebras/free_algebra_element.py b/sage/algebras/free_algebra_element.py
    a b class FreeAlgebraElement(AlgebraElement) 
    105105        EXAMPLES::
    106106       
    107107            sage: A.<x,y,z>=FreeAlgebra(ZZ,3)
    108             sage: latex(-x+3*y^20*z)   # indirect doctest
    109             \left(-1\right)x + 3y^{20}z
     108            sage: latex(-x+3*y^20*z) # indirect doctest
     109            -x + 3y^{20}z
    110110            sage: alpha,beta,gamma=FreeAlgebra(ZZ,3,'alpha,beta,gamma').gens()
    111             sage: latex(alpha-beta)
    112             \alpha + \left(-1\right)\beta
     111            sage: latex(alpha-beta) # indirect doctest
     112            \alpha - \beta
    113113        """
    114114        v = sorted(self.__monomial_coefficients.items())
    115115        return repr_lincomb(v, strip_one=True, is_latex=True)
  • sage/algebras/free_algebra_quotient_element.py

    diff --git a/sage/algebras/free_algebra_quotient_element.py b/sage/algebras/free_algebra_quotient_element.py
    a b class FreeAlgebraQuotientElement(Algebra 
    137137
    138138            sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(QQ)
    139139            sage: ((2/3)*i - j)._latex_()
    140             '\\frac{2}{3}i + \\left(-1\\right)j'
     140            '\\frac{2}{3}i - j'
    141141        """
    142142        Q = self.parent()
    143143        M = Q.monoid()
  • sage/misc/misc.py

    diff --git a/sage/misc/misc.py b/sage/misc/misc.py
    a b def coeff_repr(c, is_latex=False): 
    705705        s = c._latex_()
    706706    else:
    707707        s = str(c).replace(' ','')
    708     if s.find("+") != -1 or s.find("-") != -1:
     708    if s.find("+") != -1 or ( s.find("-") != -1 and s != "-1" ):
    709709        if is_latex:
    710710            return "\\left(%s\\right)"%s
    711711        else: