#13624: KeyError raised by GraphLatex.dot2tex_picture when edge_labels=True
-------------------------------------+--------------------------------------
       Reporter:  slabbe             |         Owner:  tbd         
           Type:  defect             |        Status:  needs_review
       Priority:  major              |     Milestone:  sage-5.8    
      Component:  optional packages  |    Resolution:              
       Keywords:  dot2tex            |   Work issues:              
Report Upstream:  N/A                |     Reviewers:              
        Authors:                     |     Merged in:              
   Dependencies:                     |      Stopgaps:              
-------------------------------------+--------------------------------------
Changes (by nthiery):

  * status:  new => needs_review


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'
> ''
> }}}

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 _.

 By the way, this patch also makes ``latex`` use ``\text`` natively instead
 of ``\verb`` in the easy situations as this gives more readable latex
 code. But maybe this should be moved to another ticket.

--

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