#13624: KeyError raised by GraphLatex.dot2tex_picture when edge_labels=True
------------------------------------------+---------------------------------
       Reporter:  slabbe                  |         Owner:  tbd       
           Type:  defect                  |        Status:  needs_work
       Priority:  major                   |     Milestone:  sage-5.9  
      Component:  packages: optional      |    Resolution:            
       Keywords:  dot2tex, graph drawing  |   Work issues:            
Report Upstream:  N/A                     |     Reviewers:            
        Authors:  Nicolas M. ThiƩry       |     Merged in:            
   Dependencies:                          |      Stopgaps:            
------------------------------------------+---------------------------------
Changes (by ncohen):

  * status:  needs_review => needs_work


Old description:

> The following is ok :
>
> {{{
> sage: G = DiGraph()
> sage: G.add_edge(3333, 88, 'my_label')
> sage: G.set_latex_options(format='dot2tex')
> sage: view(G)
> }}}
>
> but with `edges_labels=True` a !KeyError is raised :
>
> {{{
> sage: G.set_latex_options(edge_labels=True)
> sage: view(G)
> ERROR    Failed to process input
> Traceback (most recent call last):
>   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
> packages/dot2tex/dot2tex.py", line 2939, in main
>     s =  conv.convert(dotdata)
>   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
> packages/dot2tex/dot2tex.py", line 794, in convert
>     return self.do_preview_preproc()
>   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
> packages/dot2tex/dot2tex.py", line 1167, in do_preview_preproc
>     hp,dp,wt = pp.texdims[name]
> KeyError: '3333880'
> }}}
>
> The error is also raised by `dot2tex_picture` method:
>
> {{{
> sage: G = DiGraph()
> sage: G.add_edge(0, 1, 'p0')
> sage: G.latex_options().dot2tex_picture()
> '\n\\begin{tikzpicture}[>=latex,line join=bevel,]\n%%\n\\node (1) at
> (6bp,7bp) [draw,draw=none] {$1$};\n  \\node (0) at (6bp,57bp)
> [draw,draw=none] {$0$};\n  \\draw [black,->] (0) ..controls
> (6bp,44.053bp) and (6bp,33.103bp)  .. (1);\n%\n\\end{tikzpicture}\n'
> .dot2tex_picture()
> sage: G.set_latex_options(edge_labels=True)
> sage: G.latex_options().dot2tex_picture()
> ERROR    Failed to process input
> Traceback (most recent call last):
>   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
> packages/dot2tex/dot2tex.py", line 2939, in main
>     s =  conv.convert(dotdata)
>   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
> packages/dot2tex/dot2tex.py", line 794, in convert
>     return self.do_preview_preproc()
>   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
> packages/dot2tex/dot2tex.py", line 1167, in do_preview_preproc
>     hp,dp,wt = pp.texdims[name]
> KeyError: '010'
> ''
> }}}
>
> This is due to dot2tex currently not supporting '\verb' properly.
>
> The attached patch works around this by replacing \verb by \text, and
> stripping out tricky characters like ^ and _.

New description:

 The following is ok :

 {{{
 sage: G = DiGraph()
 sage: G.add_edge(3333, 88, 'my_label')
 sage: G.set_latex_options(format='dot2tex')
 sage: view(G)
 }}}

 but with `edges_labels=True` a !KeyError is raised :

 {{{
 sage: G.set_latex_options(edge_labels=True)
 sage: view(G)
 ERROR    Failed to process input
 Traceback (most recent call last):
   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
 packages/dot2tex/dot2tex.py", line 2939, in main
     s =  conv.convert(dotdata)
   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
 packages/dot2tex/dot2tex.py", line 794, in convert
     return self.do_preview_preproc()
   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
 packages/dot2tex/dot2tex.py", line 1167, in do_preview_preproc
     hp,dp,wt = pp.texdims[name]
 KeyError: '3333880'
 }}}

 The error is also raised by `dot2tex_picture` method:

 {{{
 sage: G = DiGraph()
 sage: G.add_edge(0, 1, 'p0')
 sage: G.latex_options().dot2tex_picture()
 '\n\\begin{tikzpicture}[>=latex,line join=bevel,]\n%%\n\\node (1) at
 (6bp,7bp) [draw,draw=none] {$1$};\n  \\node (0) at (6bp,57bp)
 [draw,draw=none] {$0$};\n  \\draw [black,->] (0) ..controls (6bp,44.053bp)
 and (6bp,33.103bp)  .. (1);\n%\n\\end{tikzpicture}\n'
 .dot2tex_picture()
 sage: G.set_latex_options(edge_labels=True)
 sage: G.latex_options().dot2tex_picture()
 ERROR    Failed to process input
 Traceback (most recent call last):
   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
 packages/dot2tex/dot2tex.py", line 2939, in main
     s =  conv.convert(dotdata)
   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
 packages/dot2tex/dot2tex.py", line 794, in convert
     return self.do_preview_preproc()
   File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-
 packages/dot2tex/dot2tex.py", line 1167, in do_preview_preproc
     hp,dp,wt = pp.texdims[name]
 KeyError: '010'
 ''
 }}}

 This is due to dot2tex currently not supporting '\verb' properly.

 The attached patch works around this by replacing \verb by \text, and
 stripping out tricky characters like `^` and `_`.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13624#comment:34>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to