-
-
Notifications
You must be signed in to change notification settings - Fork 561
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
Add consistency tests for __nonzero__ in TestSuite. #12510
Comments
This comment has been minimized.
This comment has been minimized.
Author: Florent Hivert |
This comment has been minimized.
This comment has been minimized.
comment:5
Helloooooooo !! Well, as far as I understand this code I think that it is good to go, except for this thing I just told you about : the new content of
If you think that this is not a problem after all, then you can set this ticket to Have fuuuuuuuuuuuuuuuuuuuuuuuunnn !! Nathann |
comment:6
The returned result was wrong so I switched back to raising not implemented. I created #13999 to have the problem fixed. Please review, Florent |
comment:8
Attachment: trac_12510-nonzero_equal_consistency-fh.patch.gz Gooooooooooooooooooooooood to go !!! Le jury apprécie : la qualité des workarounds Nathnan |
comment:9
Thanks Nathan !!! |
Reviewer: Nathann Cohen |
Merged: sage-5.7.beta1 |
With many datastructure for elements, comparison to zero could be faster than
comparison of two elements. The pythonic way to do that is to use indirectly
e.__nonzero__()
for example inif not e: ...
. However, to be ableto use consistently this idiom, we have to make sure that the return value of
e == e.parent().zero()
agrees withbool(e)
. The purpose of thispatch is to add this tests to the standard test suite and to fixe the Sage
library according to this policy.
On the way, I discovered that for a some morphism of modules, pickling can be
broken if the zero morphism is asked. I also fixes this issue.
See also discussion on #12508. Finally, I left to #12526 the question of removing
__nonzero__
from element and writing tuned implantation for all data structures.CC: @stumpc5 @sagetrac-sage-combinat
Component: categories
Author: Florent Hivert
Reviewer: Nathann Cohen
Merged: sage-5.7.beta1
Issue created by migration from https://trac.sagemath.org/ticket/12510
The text was updated successfully, but these errors were encountered: