Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

comparison in CombinatorialFreeModule

I have a free module indexed by partition tuples. I construct twice what it is seemingly the same vector but the comparison fails:

sage: M = CombinatorialFreeModule(QQ, PartitionTuples(level=2))
sage: B = M.basis()
sage: p = Partition([])
sage: B[(p,p)] == M((p,p))
False

If I do this with partitions it's fine:

sage: M = CombinatorialFreeModule(QQ, PartitionTuples(level=1))
sage: B = M.basis()
sage: B[p] == M(p)
True
sage:

comparison in CombinatorialFreeModule

I have a free module indexed by partition tuples. I construct twice what it is seemingly the same vector but the comparison fails:

sage: M = CombinatorialFreeModule(QQ, PartitionTuples(level=2))
sage: B = M.basis()
sage: p = Partition([])
sage: B[(p,p)] == M((p,p))
False

If I do this with partitions it's fine:

sage: M = CombinatorialFreeModule(QQ, PartitionTuples(level=1))
sage: B = M.basis()
sage: B[p] == M(p)
True
sage:

Edit: I think this might be an issue with the coersion model and _richcmp_ or similar in PartitionTuple because this already fails:

sage: P = PartitionTuples(level=2)
sage: P((p,p)) in P
True
sage: (p,p) in P
True
sage: P((p,p)) == (p,p)
False

comparison in CombinatorialFreeModule

I have a free module indexed by partition tuples. I construct twice what it is seemingly the same vector but the comparison fails:

sage: M = CombinatorialFreeModule(QQ, PartitionTuples(level=2))
sage: B = M.basis()
sage: p = Partition([])
sage: B[(p,p)] == M((p,p))
False

If I do this with partitions it's fine:

sage: M = CombinatorialFreeModule(QQ, PartitionTuples(level=1))
sage: B = M.basis()
sage: B[p] == M(p)
True
sage:

Edit: I think this might be an issue with the coersion model and _richcmp_ or similar in PartitionTuple because this already fails:

sage: P = PartitionTuples(level=2)
sage: P((p,p)) in P
True
sage: (p,p) in P
True
sage: P((p,p)) == (p,p)
False

comparison in CombinatorialFreeModuleof PartitionTuples

I have a free module indexed by partition tuples. I construct twice what it is seemingly the same vector but the comparison fails:

sage: M = CombinatorialFreeModule(QQ, PartitionTuples(level=2))
sage: B = M.basis()
sage: p = Partition([])
sage: B[(p,p)] == M((p,p))
False

If I do find this with partitions it's fine:

sage: M = CombinatorialFreeModule(QQ, PartitionTuples(level=1))
sage: B = M.basis()
sage: B[p] == M(p)
True
sage:

Edit: I think this might be an issue with the coersion coercion model and for _richcmp_PartitionTuples or similar in PartitionTuple because this already fails:confusing:

sage: P = PartitionTuples(level=2)
sage: P((p,p)) in P
True
sage: (p,p) in P
True
sage: P((p,p)) == (p,p)
False

However as FrédericC notes below we have

sage: P((p,p)) == [p,p]
True

Implementing _richcmp_ and __richcmp__ both in the element and in the category does not solve this issue as they are never called. Also in the list case if one tries to compare directly using _cmp_ or their rich versions we'd get an exception. So I guess the comparison is happening at the Python level as follows:

sage: S = (p,p,p)
sage: T = P(S)
sage: L = [p,p,p]
sage: T.__eq__(S)
False
sage: T.__eq__(L)
True
click to hide/show revision 5
retagged

comparison of PartitionTuples

I find this issue with the coercion model for PartitionTuples confusing:

sage: P = PartitionTuples(level=2)
sage: P((p,p)) in P
True
sage: (p,p) in P
True
sage: P((p,p)) == (p,p)
False

However as FrédericC notes below we have

sage: P((p,p)) == [p,p]
True

Implementing _richcmp_ and __richcmp__ both in the element and in the category does not solve this issue as they are never called. Also in the list case if one tries to compare directly using _cmp_ or their rich versions we'd get an exception. So I guess the comparison is happening at the Python level as follows:

sage: S = (p,p,p)
sage: T = P(S)
sage: L = [p,p,p]
sage: T.__eq__(S)
False
sage: T.__eq__(L)
True
click to hide/show revision 6
retagged

comparison of PartitionTuples

I find this issue with the coercion model for PartitionTuples confusing:

sage: P = PartitionTuples(level=2)
sage: P((p,p)) in P
True
sage: (p,p) in P
True
sage: P((p,p)) == (p,p)
False

However as FrédericC notes below we have

sage: P((p,p)) == [p,p]
True

Implementing _richcmp_ and __richcmp__ both in the element and in the category does not solve this issue as they are never called. Also in the list case if one tries to compare directly using _cmp_ or their rich versions we'd get an exception. So I guess the comparison is happening at the Python level as follows:

sage: S = (p,p,p)
sage: T = P(S)
sage: L = [p,p,p]
sage: T.__eq__(S)
False
sage: T.__eq__(L)
True