#12510: Add consistency tests for __nonzero__ in TestSuite.
---------------------------+------------------------------------------------
Reporter: hivert | Owner: nthiery
Type: enhancement | Status: new
Priority: major | Milestone: sage-5.0
Component: categories | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author: Florent Hivert
Merged: | Dependencies:
---------------------------+------------------------------------------------
Changes (by newvalueoldvalue):
* author: => Florent Hivert
Old description:
> See discussion on #12508
New description:
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 in {{{if not e: ...}}}. However, to be
able
to use consistently this idiom, we have to make sure that the return value
of
{{{e == e.parent().zero()}}} agrees with {{{bool(e)}}}. The purpose of
this
patch 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
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12510#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.