#12510: Add consistency tests for __nonzero__ in TestSuite.
---------------------------+------------------------------------------------
   Reporter:  hivert       |          Owner:  hivert        
       Type:  enhancement  |         Status:  needs_review  
   Priority:  major        |      Milestone:  sage-5.0      
  Component:  categories   |       Keywords:                
Work_issues:               |       Upstream:  N/A           
   Reviewer:               |         Author:  Florent Hivert
     Merged:               |   Dependencies:                
---------------------------+------------------------------------------------
Description changed by hivert:

Old 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

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. Finally, I left to #12526 the question of
 removing {{{__nonzero__}}} from element and writing tuned implantation for
 all data structures.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12510#comment:4>
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.

Reply via email to