Skip to content

ValueError: could not convert string to float: 'F' #86

@moi90

Description

@moi90

Dot2tex version 2.11.3

This is a duplicate of #78, but that issue was closed without resolving the problem.

dot2tex flow.dot
ERROR    Failed to process input
Traceback (most recent call last):
  File "/home/moi/.local/lib/python3.8/site-packages/dot2tex/dot2tex.py", line 332, in parse_drawstring
    didx, cmd = doeE(c, s[idx + 1:])
  File "/home/moi/.local/lib/python3.8/site-packages/dot2tex/dot2tex.py", line 262, in doeE
    points = [float(t) for t in tokens]
  File "/home/moi/.local/lib/python3.8/site-packages/dot2tex/dot2tex.py", line 262, in <listcomp>
    points = [float(t) for t in tokens]
ValueError: could not convert string to float: 'F'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/moi/.local/lib/python3.8/site-packages/dot2tex/dot2tex.py", line 3075, in main
    s = conv.convert(dotdata)
  File "/home/moi/.local/lib/python3.8/site-packages/dot2tex/dot2tex.py", line 829, in convert
    self.do_nodes()
  File "/home/moi/.local/lib/python3.8/site-packages/dot2tex/dot2tex.py", line 649, in do_nodes
    s += self.do_drawstring(drawstring, node)
  File "/home/moi/.local/lib/python3.8/site-packages/dot2tex/dot2tex.py", line 536, in do_drawstring
    drawoperations, stat = parse_drawstring(drawstring)
  File "/home/moi/.local/lib/python3.8/site-packages/dot2tex/dot2tex.py", line 347, in parse_drawstring
    log.debug("Failed to parse drawstring %s\n%s", s, err.message)
AttributeError: 'ValueError' object has no attribute 'message'

The second exception should be resolved by using str(err) instead of err.message.

digraph G {
    rankdir=LR
    node [shape=box];
    graph [nodesep="0.5" padding="0" margin="0"];

    train -> cluster;
    cluster -> annotate;
    annotate -> cluster;
    annotate -> name;
    annotate -> train [constraint=false, style=dashed];
    
    cluster [label="Cluster"];
    # This line seems to be the problem. I suspect dot2tex chokes on the \n:
    annotate [label="Validate\nGrow"];
    train [label="Train", style=rounded];
    name [label="Name",style=rounded];
}

The key to rendering newlines in nodes is the align option:
The above line should be rendered as \draw (241.5bp,39.735bp) node [align=center] {Validate\\Grow};.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions