Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplification fails in my installation (vpype read -s <svg_file>) #729

Open
nataquinones opened this issue May 16, 2024 · 1 comment
Open

Comments

@nataquinones
Copy link
Contributor

Problem:
The following command fails in my installation:
vpype read -s scale_test.svg

I get the following error:

Traceback (most recent call last):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nquinones/miniforge3/envs/vsketch/lib/python3.12/site-packages/vpype/io.py", line 343, in _process_path
    line = line.view(dtype=complex).reshape(len(line))
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nquinones/miniforge3/envs/vsketch/lib/python3.12/site-packages/numpy/core/_internal.py", line 551, in _view_is_safe
    raise TypeError("Cannot change data-type for object array.")
TypeError: Cannot change data-type for object array.

Solution:
I tried to fix it by modifying the following line:

line = np.array(LineString(line).simplify(tolerance=quantization))

to:

line = LineString(line).simplify(tolerance=quantization)
line = np.array(line.coords, dtype=float)

and that seems to work.

Additional info:
I'm using the following versions on a MacOS Ventura 13.6

numpy=1.26.4
vpype==1.14.0
shapely==2.0.4
@abey79
Copy link
Owner

abey79 commented May 19, 2024

This very much looks like a bug–thanks for reporting. Your fix seems correct to me. Could you open a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants