New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Words.__eq__ returns wrong answers #15480
Comments
Branch: u/ncohen/15480 |
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. New commits:
|
Commit: |
comment:3
Oh. I see. That's for
Then for this case I will keep the old behaviour. Ready for review ! This is only hacks, but it fixes the wrong results Nathann |
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. New commits:
|
This comment has been minimized.
This comment has been minimized.
comment:5
I was just looking at this and I agree it's a mess. I thought that you might be able to get away with just if self.cardinality()!=other.cardinality():
return False
if self.cardinality()==1:
return True
if self.alphabet() != other.alphabet():
return False
return type(self)==type(other) but this does not catch
As I don't really play with these things it is not clear to me that these two should be equal. Is this really correct? |
comment:6
I did not know the existence of WordPaths either before this patch, but I think this has been done on purpose for there are 4 doctests in the As per the cardinality test I tried to avoid calling Nathann |
comment:7
Personnally, I would delete the file I am not familiar with the git process of reviewing a patch... Is it easy or difficult to learn? Is Sage ready for including git patches? I will have time to learn the git process in January or February. Sébastien |
comment:8
Yooooooo ! Well, I can't put into Sage any code that breaks doctests, and I know absolutely nothing of what WordPaths is meant to do so I cannot really rewrite it The word.py file could very well do with a complete rewrite, to be honest. These class inheritances are hell to work with. Or perhaps we would just need to create additional classes, so that classes exposed to the user can't be Words_all or anything similar. My problem is that there is no class for infinite words which will not ALSO be inherited by classes of finite words. So it's pretty hard to write infinite-specific code. Learning git takes a bit of time, though you can easily master it with a week-end's afternoon or something like that. It's funny, and new but not so complicated after all. And you can ask around if you have questions Aaaaaaand everything should be documented on #14481 as this will be the future dev documentation ! Nathann |
This comment has been minimized.
This comment has been minimized.
comment:9
Replying to @seblabbe:
Unfortunately because of sage's depreciation policy we can't just remove I was going to suggest that we instead remove the doc tests of the form
Without these we could have a more natural looking equality test. Unfortunately, with this "more natural" equiality test there are now multiple doctest failures in finite_word.py and in word_generators.py. So this is not a good solution. I have not drilled down to find out why these doctests fail because this does not happen with Nathann's patch. So, as unnatural as the code looks, it is perhaps the best way to go. Andrew |
comment:10
ps. Git has a bit of a learning curve, but it is quite nice once you get use to it (of course, getting used to it and being able to use it "properly" are not quite the same thing.) I'm happy to review this ticket. |
Changed branch from u/ncohen/15480 to u/andrew.mathas/ticket/15480 |
comment:12
I've pushed a new commit which adds a warning message to the documentation of All doctests pass in sage/combinat so assuming that the patchbot is happy I give this a positive review. A. New commits:
|
comment:13
Works for me ! Thanks Less wrong results in Sage.. Wuuhuuu.. Nathann |
Reviewer: Andrew Mathas |
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:
|
Right now equality between sets of words only compares the alphabets:
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
You cannot be sure, when implementing the
__eq__
method ofWords_all
, that self really represents an infinite class of words.Besides, the old code reads:
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
CC: @seblabbe @videlec @sagetrac-sage-combinat @saliola
Component: combinatorics
Author: Nathann Cohen
Branch/Commit: u/andrew.mathas/ticket/15480 @
ecd32ae
Reviewer: Andrew Mathas
Issue created by migration from https://trac.sagemath.org/ticket/15480
The text was updated successfully, but these errors were encountered: