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

Error in bezier.Curve due to verify argument #5

Open
Izzy-Newsham opened this issue Oct 26, 2022 · 1 comment
Open

Error in bezier.Curve due to verify argument #5

Izzy-Newsham opened this issue Oct 26, 2022 · 1 comment

Comments

@Izzy-Newsham
Copy link

Hi,

Thanks for publishing this useful code!

The issue

When I run this code, I get the following error:

Traceback (most recent call last):
  File "bezier-curved-edges-networkx/run.py", line 14, in <module>
    curves = curved_edges(G, positions)
  File "bezier-curved-edges-networkx/curved_edges.py", line 58, in curved_edges
    curveplots.append(bezier.Curve(nodes, degree=2).evaluate_multi(np.linspace(0,1,bezier_precision)).T)
  File "/lib/python3.9/site-packages/bezier/curve.py", line 101, in __init__
    self._verify_degree(verify)
  File "/lib/python3.9/site-packages/bezier/curve.py", line 161, in _verify_degree
    raise ValueError(msg)
ValueError: A degree 2 curve should have 3 nodes, not 4.

The potential fix

It looks like this is due to a release of the bezier package adding the verify argument to the Curve constructor (this release: https://bezier.readthedocs.io/en/stable/releases/0.11.0.html).

So when I set verify=False in line 58:
curveplots.append(bezier.Curve(nodes, degree=2, verify=False).evaluate_multi(np.linspace(0,1,bezier_precision)).T)
it works!

Or instead, I can change the degree:
curveplots.append(bezier.Curve(nodes, degree=3).evaluate_multi(np.linspace(0,1,bezier_precision)).T)
and this works too.

@PorcupineAndrew
Copy link

@Izzy-Newsham Apart from your solutions, we can now use from_nodes to not bother with the degrees. The code can thus be changed like this:

curveplots.append(bezier.Curve.from_nodes(nodes).evaluate_multi(np.linspace(0,1,bezier_precision)).T)

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