Changes between Initial Version and Version 1 of Ticket #15480


Ignore:
Timestamp:
12/03/13 12:06:12 (7 years ago)
Author:
ncohen
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #15480

    • Property Status changed from new to needs_review
    • Property Branch changed from to u/ncohen/15480
  • Ticket #15480 – Description

    initial v1  
    88sage: Words(2) == Words(2,30)           
    99True
     10sage: Words(10,0) == Words(20,0)                                                                                                                                                   
     11False
    1012}}}
     13
     14I am not proud of this patch's code, but I see NO other way to all these wrongs 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`
     15
     16{{{
     17sage: isinstance(Words(4,30), type(Words(3)))
     18True
     19}}}
     20
     21You cannot be sure, when implementing the `__eq__` method of `Words_all`, that self really represents an infinite class of words.
     22
     23Besides, the old code read :
     24
     25{{{
     26        if isinstance(other, Words_all):
     27            return self.alphabet() == other.alphabet()
     28        else:
     29            return NotImplemented
     30}}}
     31
     32I 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.
     33Though the old code seems to imply that this can happen.
     34
     35If this can happen we need to add a doctest somewhere.
     36
     37Nathann