Yes, Mike, you are certainly right in saying that this is a hash
problem.

Here are the types of my objects

sage: type(kiki[0])
<class
'sage.combinat.free_module.modules_sur_P_with_category.element_class'>
sage: type(kiki[0].support()[0])
<class 'sage.combinat.posets.elements.PosetElement'>
sage: type(kiki[0].support()[0].element)
<type 'str'>

I suspect that there may be some kind of conflict between the
CombinatorialFreeModule setting and the Poset setting (which I do not
find very easy to use, by the way)

Frederic

On 2 fév, 13:11, Mike Hansen <mhan...@gmail.com> wrote:
> Hello,
>
> 2011/2/2 Frédéric Chapoton <fchapot...@gmail.com>:
>
>
>
> > Here is a little more detail, a reduced example, coming from the
> > problem above.
>
> > sage: kiki
> > {B[[1, 0, 1, 1, 0, 1, 0, 1, 0, 0]] + B[[1, 0, 1, 1, 1, 0, 0, 1, 0, 0]]
> > + B[[1, 0, 1, 1, 0, 1, 1, 0, 0, 0]] + B[[1, 0, 1, 1, 1, 0, 1, 0, 0,
> > 0]] + B[[1, 0, 1, 1, 1, 1, 0, 0, 0, 0]], B[[1, 0, 1, 1, 0, 1, 0, 1, 0,
> > 0]] + B[[1, 0, 1, 1, 0, 1, 1, 0, 0, 0]] + B[[1, 0, 1, 1, 1, 0, 0, 1,
> > 0, 0]] + B[[1, 0, 1, 1, 1, 0, 1, 0, 0, 0]] + B[[1, 0, 1, 1, 1, 1, 0,
> > 0, 0, 0]]}
> > sage: kiki.cardinality()
> > 2
> > sage: kiki[0]==kiki[1]
> > True
> > sage: kiki[0]-kiki[1]
> > 0
>
> > so these 2 linear combinations differ only by their order.
>
> My guess is that it is an issue with the hashing of the elements of
> "kiki" -- perhaps the hash is based on an ordering?  What types of
> objects are they?  Here's a way to reproduce similar behavior:
>
> class Foo(object):
>     def __init__(self, value):
>         self.value = value
>     def __eq__(self, other):
>         return isinstance(other, Foo) and self.value == other.value
>     def __hash__(self):
>         import random
>         return random.randint(0,10000)
>     def __repr__(self):
>         return repr(self.value)
>
> sage: a = Foo(1)
> sage: b = Foo(1)
> sage: a == b
> True
> sage: Set([a,b])
> {1, 1}
> sage: mySet = Set([a,b])
> sage: Set([len([v for v in mySet if v==u]) for u in mySet])
> {2}
>
> --Mike

-- 
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