#16264: Rotate error on childless binay trees
-------------------------+-------------------------------------------------
   Reporter:             |            Owner:
  VivianePons            |           Status:  new
       Type:  defect     |        Milestone:  sage-6.2
   Priority:  major      |         Keywords:  combinat, Tamari, binary
  Component:             |  trees
  combinatorics          |          Authors:  Viviane Pons
  Merged in:             |  Report Upstream:  N/A
  Reviewers:             |           Branch:
Work issues:             |     Dependencies:
     Commit:             |
   Stopgaps:             |
-------------------------+-------------------------------------------------
 When one tries to apply a "right_rotate" (resp. "left_rotate") method on a
 binary tree which does not have a left (resp. right) subtree, one gets a
 "Index Error".


 {{{
 sage: bt = BinaryTree([])
 sage: bt.right_rotate()
 ---------------------------------------------------------------------------
 IndexError                                Traceback (most recent call
 last)
 ...
 IndexError: list index out of range
 }}}

 This does not look like a neat error... The rotation is not defined in
 this case, so I'm not sure what the behavior should be:

 1- return the same object

 2- return None (seems like a bad idea)

 3- raise a ValueError exception that says the rotation is not defined in
 this case

 I would be up for 1 or 2 and I'm not sure which one is best, please tell
 me what you think!

--
Ticket URL: <http://trac.sagemath.org/ticket/16264>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to