mathandy / svgpathtools

A collection of tools for manipulating and analyzing SVG Path objects and Bezier curves.
MIT License
532 stars 134 forks source link

TypeError: ufunc 'degrees' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe' #187

Open yaqwsx opened 1 year ago

yaqwsx commented 1 year ago

Hi, when I try to extract path using this piece of code:

paths = svgpathtools.document.flattened_paths(xmlParse(svgString))

I get the following error for the document attached below:

File "/home/xmrazek7/.local/lib/python3.8/site-packages/svgpathtools/document.py", line 148, in flattened_paths
    path = transform(parse_path(converter(path_elem)), path_tf)
  File "/home/xmrazek7/.local/lib/python3.8/site-packages/svgpathtools/path.py", line 312, in transform
    return transform_segments_together(curve, transformation)
  File "/home/xmrazek7/.local/lib/python3.8/site-packages/svgpathtools/path.py", line 191, in transform_segments_together
    transformed_segs = [transformation(seg) for seg in path]
  File "/home/xmrazek7/.local/lib/python3.8/site-packages/svgpathtools/path.py", line 191, in <listcomp>
    transformed_segs = [transformation(seg) for seg in path]
  File "/home/xmrazek7/.local/lib/python3.8/site-packages/svgpathtools/path.py", line 311, in <lambda>
    transformation = lambda seg: transform(seg, tf)
  File "/home/xmrazek7/.local/lib/python3.8/site-packages/svgpathtools/path.py", line 338, in transform
    rot = np.degrees(np.arccos(xeigvec[0]))
TypeError: ufunc 'degrees' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

The error is caused by the fact that np.arccos is evaluated to a complex number: (1.5707963267948966+0.3850858480697339j)

test test.zip