Hi everyone,

I just came across a big "zero" problem on my patch and I was
wondering where it was coming from.

Here is what I have

sage: A = AbstractPolynomialRing(QQ)
sage: m = A.monomial_basis()
sage: (0 * m[1,2]) == 0
False

By comparing sage versions (because, it was working before), it seems
to come from the dict_linear_combination function in
sage.combinat.dict_addition import

Here is the code that is causing issues :

    if D != {}:
        a = iter(D).next()
        if hasattr(a,'parent') and hasattr(a.parent(),'zero'):
            zero = a.parent().zero()
        else:
            zero = 0
    for_removal = [key for key in D if D[key] == zero]
    for key in for_removal:
        del D[key]

This is the part removing the zeros, it used to be only :

for_removal = [ key for key, value in D.iteritems() if value == 0 ]
for key in for_removal:
    del D[key]

It seems to me that you're not testing the right 0, when I was looking
for the error, my D was as follow :

sage: D
{[1, 2]: 0}
sage: a =iter(D).next()
sage: a
[1, 2]

so the a is the key, not the value, so the test makes zero equals to
the key zero and not the ring zero :

sage: zero = a.parent().zero()
sage: zero
[0, 0]
sage: D[key]
0
sage: D[key] == zero
False

Obviously, there is something wrong, and it's breaking my program ...

Regards

Viviane

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

Reply via email to