On a second glance I realized that repr_lincomb does not make sense at all. 
Here is a slightly better code:

    all_atomic = True
    for (monomial,c) in terms:
        b = repr_monomial(monomial)
        if c != 0:
            if c == 1:
                coeff = ""
            elif c == -1:
                coeff = "-"
            elif c < 0:
                coeff = " - %s"%coeff_repr(-c, is_latex)
            else:
                coeff = "%s"%coeff_repr(c, is_latex)
            if len(b) > 0:
                if len(coeff) > 0 and b == "1" and strip_one:
                    b = ""
                else:
                    b = scalar_mult + b
            if not first and c > 0:
                    coeff = " + %s"%coeff
            s += "%s%s"%(coeff, b)
            first = False
    if first:
        return "0" # wtf?
    elif s == "":
        return "1" # wtf?
    else:
        return s


Dne středa, 3. dubna 2013 21:40:50 UTC+2 Vít Tuček napsal(a):
>
> Hi!
>
>  The title says it all.
>
> testcase: 
>
> sage: latex(RootSystem("A2").ambient_space().simple_root(1))
>   
> e_{0} + \left(-1\right)e_{1}
>
> expected output:
>
> e_{0} - e_{1}
>
> Of course it should work also for weights and should be capable of 
> producing output like
>
> -3e_{1}+e_{2}
>
> Best regards
>                      Vit
>
> P.S.: I am not familiar with sage and its internals but I've checked 
> misc.py/repr_lincomb and it seemed fine at a first glance. Do the test 
> cover also linear combinantions with negative coefficients? Documentation 
> for repr_lincomb seems to show only terms with positive coefficients.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-combinat-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


824,839c824,834
<             coeff = coeff_repr(c, is_latex)
<             if coeff != "0":
<                 if coeff == "1":
<                     coeff = ""
<                 elif coeff == "-1":
<                     coeff = "-"
<                 elif len(b) > 0:
<                     if len(coeff) > 0 and b == "1" and strip_one:
<                         b = ""
<                     else:
<                         b = scalar_mult + b
<                 if not first:
<                     if len(coeff) > 0 and coeff[0] == "-":
<                         coeff = " - %s"%coeff[1:]
<                     else:
<                         coeff = " + %s"%coeff
---
>             if c == 1:
>                 coeff = ""
>             elif c == -1:
>                 coeff = "-"
>             elif c < 0:
>                 coeff = " - %s"%coeff_repr(-c, is_latex)
>             else:
>                 coeff = "%s"%coeff_repr(c, is_latex)
>             if len(b) > 0:
>                 if len(coeff) > 0 and b == "1" and strip_one:
>                     b = ""
841c836,838
<                     coeff = "%s"%coeff
---
>                     b = scalar_mult + b
>             if not first and c > 0:
>                     coeff = " + %s"%coeff
845c842
<         return "0"
---
>         return "0" # wtf?
847c844
<         return "1"
---
>         return "1" # wtf?

Reply via email to