svgpathtools icon indicating copy to clipboard operation
svgpathtools copied to clipboard

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'

Open yaqwsx opened this issue 3 years ago • 0 comments

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

yaqwsx avatar Sep 22 '22 08:09 yaqwsx