id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
15480,Words.__eq__ returns wrong answers,ncohen,,"Right now equality between sets of words only compares the alphabets:
{{{
sage: Words(3, 10) == Words(3,900)
True
sage: Words(2, finite=False) == Words(2)
True
sage: Words(2) == Words(2,30)
True
sage: Words(10,0) == Words(20,0)
False
sage: WordPaths('abcd') == Words(""abcd"",3)
True
}}}
I am not proud of this patch's code, but I see NO other way to fix all these incorrect answers without rewriting the class hierarchy. The fact that a class of finite words is an instance (i.e. it inherits) from a class of infinite words makes it really hard to implement `O_o`
{{{
sage: isinstance(Words(4,30), type(Words(3)))
True
}}}
You cannot be sure, when implementing the `__eq__` method of `Words_all`, that self really represents an infinite class of words.
Besides, the old code reads:
{{{
if isinstance(other, Words_all):
return self.alphabet() == other.alphabet()
else:
return NotImplemented
}}}
I haven't been able to guess when `not (type(self) is type(other))` does not mean that the two classes should not be reported as equal.
Though the old code seems to imply that this can happen.
If this can happen we need to add a doctest somewhere.
Nathann",defect,closed,major,sage-6.1,combinatorics,fixed,,slabbe vdelecroix sage-combinat saliola,,Nathann Cohen,Andrew Mathas,N/A,,u/andrew.mathas/ticket/15480,ecd32aebf69a5cfc00a9bd4735eb47b100c8b09c,,