#10776: poset top() function breaks when top element has boolean value False
-----------------------------+----------------------------------------------
   Reporter:  niles          |       Owner:  sage-combinat       
       Type:  defect         |      Status:  new                 
   Priority:  major          |   Milestone:                      
  Component:  combinatorics  |    Keywords:  beginner, poset, top
     Author:                 |    Upstream:  N/A                 
   Reviewer:                 |      Merged:                      
Work_issues:                 |  
-----------------------------+----------------------------------------------
 Posets determine whether there is a top element by converting the element
 returned by `._hasse_diagram.top()` to a boolean.  Instead, the function
 should check whether the returned value is `None`.

 Here is the current definition of `.top()`:
 {{{
     def top(self):
         """
         Returns the top element of the poset, if it exists.

         EXAMPLES::

             sage: P = Poset({0:[3],1:[3],2:[3],3:[4,5],4:[],5:[]})
             sage: P.top() is None
             True
             sage: Q = Poset({0:[1],1:[]})
             sage: Q.top()
             1
         """
         hasse_top = self._hasse_diagram.top()
         if hasse_top:
             return self._vertex_to_element(hasse_top)
         else:
             return None
 }}}

 And here is an example showing how it fails:

 {{{
 sage: p = Poset([[0],[]]); p
 Finite poset containing 1 elements
 sage: p.list()
 [0]
 sage: p.top()
 sage: p.top() is None
 True
 sage: p._hasse_diagram.top()
 0
 sage: p._hasse_diagram.top() is None
 False
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10776>
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