tataratat / splinepy

Library for prototyping spline geometries of arbitrary dimensions and degrees, and IGA
https://tataratat.github.io/splinepy
Other
45 stars 13 forks source link

Visualizing 1D geometry with 'k3d' #451

Open cme147 opened 4 weeks ago

cme147 commented 4 weeks ago

When attempting to visualize a 1D geometry using the 'k3d' backend in 'vedo' a TraitError occurs. Below is a code example that reproduces the error:

from splinepy.helpme.create import line
from vedo import settings

settings.default_backend = 'k3d'
curve = line(([0.0, 0.0], [1.0, 1.0]))
curve.show()

Error Message: TraitError: The 'width' trait of a Line instance expected a float or a dict, not the float32 np.float32(0.11313708).

j042 commented 4 weeks ago

If you don't mind switching numpy version, a quick fix is to use numpy 1.

pip install --force-reinstall numpy==1.26

You could also just uninstall and install. Afterwards, you can check the version using splinepy -v.

I think this has something to do with NEP 50. So, an alternative quick fix is to set the promotion state to legacy:

np._set_promotion_state("legacy")
...
spline.show()
...
np._set_promotion_state("weak")  # set back to default

Ideally, as suggested in numpy migration guide, we should explicitly cast it to float. The nearest dependency that we can work on is vedo. I can also create a PR for it