#11692: Creating a multiedged graph gives wrong error
-----------------------------+----------------------------------------------
   Reporter:  iandrus        |          Owner:  iandrus        
       Type:  defect         |         Status:  positive_review
   Priority:  trivial        |      Milestone:  sage-4.7.2     
  Component:  graph theory   |       Keywords:                 
Work_issues:                 |       Upstream:  N/A            
   Reviewer:  Nathann Cohen  |         Author:  Ivan Andrus    
     Merged:                 |   Dependencies:                 
-----------------------------+----------------------------------------------
Description changed by leif:

Old description:

> When creating a multiedged graph with multiedges=False it fails when
> trying to create an exception thereby leading to an unhelpful error
> message.  We merely have to import choice for it to function correctly.
>
> {{{
> sage: Graph([[1,2],[1,2]],multiedges=False)
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call
> last)
>
> /Users/gvol/<ipython console> in <module>()
>
> /Users/gvol/vcs/cur-sage/local/lib/python2.6/site-
> packages/sage/graphs/graph.py in __init__(self, data, pos, loops, format,
> boundary, weighted, implementation, sparse, vertex_labels, **kwds)
>    1127                 if len(uniq(data[u])) != len(data[u]):
>    1128                     if multiedges is False:
> -> 1129                         raise ValueError("Non-multigraph input
> dict has multiple edges (%s,%s)"%(u, choice([v for v in data[u] if
> data[u].count(v) > 1])))
>    1130                     if multiedges is None: multiedges = True
>    1131             if multiedges is None: multiedges = False
>
> NameError: global name 'choice' is not defined
> }}}

New description:

 When creating a multiedged graph with multiedges=False it fails when
 trying to create an exception thereby leading to an unhelpful error
 message.  We merely have to import choice for it to function correctly.

 {{{
 sage: Graph([[1,2],[1,2]],multiedges=False)
 ---------------------------------------------------------------------------
 NameError                                 Traceback (most recent call
 last)

 /Users/gvol/<ipython console> in <module>()

 /Users/gvol/vcs/cur-sage/local/lib/python2.6/site-
 packages/sage/graphs/graph.py in __init__(self, data, pos, loops, format,
 boundary, weighted, implementation, sparse, vertex_labels, **kwds)
    1127                 if len(uniq(data[u])) != len(data[u]):
    1128                     if multiedges is False:
 -> 1129                         raise ValueError("Non-multigraph input
 dict has multiple edges (%s,%s)"%(u, choice([v for v in data[u] if
 data[u].count(v) > 1])))
    1130                     if multiedges is None: multiedges = True
    1131             if multiedges is None: multiedges = False

 NameError: global name 'choice' is not defined
 }}}

 ----

 Apply [attachment:trac_11692_import_choice.patch] to the Sage library.

--

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