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

K3D backend: Line/Point plotting with numpy version greater equal 2.1 #1197

Open
clemens-fricke opened this issue Nov 5, 2024 · 1 comment

Comments

@clemens-fricke
Copy link

clemens-fricke commented Nov 5, 2024

If you are using numpy>=2.1 and use the k3d backend I get the following error:
Code:

import vedo

vedo.settings.default_backend = "k3d"

ln1 = vedo.Line([1,1,1], [2,2,2])
vedo.show(ln1, axes=1, viewup='z')

Error:

Cell In[1], [line 6](vscode-notebook-cell:?execution_count=1&line=6)
      [3](vscode-notebook-cell:?execution_count=1&line=3) vedo.settings.default_backend = "k3d"
      [5](vscode-notebook-cell:?execution_count=1&line=5) ln1 = vedo.Line([1,1,1], [2,2,2])
----> [6](vscode-notebook-cell:?execution_count=1&line=6) vedo.show(ln1, axes=1, viewup='z')

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:345, in show(at, shape, N, pos, size, screensize, title, bg, bg2, axes, interactive, offscreen, sharecam, resetcam, zoom, viewup, azimuth, elevation, roll, camera, mode, screenshot, new, *objects)
    [341](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:341)                 plt.camera = None
    [343](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:343) else:
--> [345](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:345)     _plt_to_return = plt.show(
    [346](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:346)         objects,
    [347](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:347)         at=at,
    [348](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:348)         zoom=zoom,
    [349](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:349)         resetcam=resetcam,
    [350](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:350)         viewup=viewup,
    [351](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:351)         azimuth=azimuth,
    [352](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:352)         elevation=elevation,
    [353](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:353)         roll=roll,
    [354](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:354)         camera=camera,
    [355](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:355)         interactive=interactive,
    [356](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:356)         mode=mode,
    [357](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:357)         screenshot=screenshot,
    [358](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:358)         bg=bg,
    [359](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:359)         bg2=bg2,
    [360](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:360)         axes=axes,
    [361](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:361)     )
    [363](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:363) return _plt_to_return

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:3317, in Plotter.show(self, at, axes, resetcam, zoom, interactive, viewup, azimuth, elevation, roll, camera, mode, rate, bg, bg2, size, title, screenshot, *objects)
   [3315](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:3315) # Backend ###############################################################
   [3316](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:3316) if vedo.settings.default_backend in ["k3d"]:
-> [3317](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:3317)     return backends.get_notebook_backend(self.objects)
   [3318](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:3318) #########################################################################
   [3320](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/plotter.py:3320) for ia in utils.flatten(objects):

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:31, in get_notebook_backend(actors2show)
     [29](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:29) #########################################
     [30](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:30) if settings.default_backend == "k3d":
---> [31](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:31)     return start_k3d(actors2show)
     [33](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:33) #########################################
     [34](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:34) if settings.default_backend.startswith("trame"):

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:245, in start_k3d(actors2show)
    [241](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:241)         pts = ia.vertices[ln_idx]
    [243](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:243)         aves = ia.diagonal_size() * iap.GetLineWidth() / 100
--> [245](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:245)         kobj = k3d.line(
    [246](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:246)             pts.astype(np.float32),
    [247](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:247)             color=_rgb2int(iap.GetColor()),
    [248](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:248)             opacity=iap.GetOpacity(),
    [249](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:249)             shader=settings.k3d_line_shader,
    [250](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:250)             width=aves,
    [251](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:251)             name=name,
    [252](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:252)         )
    [253](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:253)         vedo.notebook_plotter += kobj
    [255](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/vedo/backends.py:255) ################################################################## Mesh

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:244, in line(vertices, color, colors, attribute, color_map, color_range, width, opacity, shader, radial_segments, name, group, custom_data, compression_level, **kwargs)
    [237](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:237) attribute = (
    [238](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:238)     np.array(attribute, np.float32) if type(
    [239](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:239)         attribute) is not dict else attribute
    [240](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:240) )
    [241](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:241) color_range = check_attribute_color_range(attribute, color_range)
    [243](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:243) return process_transform_arguments(
--> [244](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:244)     Line(
    [245](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:245)         vertices=vertices,
    [246](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:246)         color=color,
    [247](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:247)         width=width,
    [248](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:248)         shader=shader,
    [249](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:249)         radial_segments=radial_segments,
    [250](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:250)         colors=colors,
    [251](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:251)         attribute=attribute,
    [252](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:252)         color_map=color_map,
    [253](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:253)         color_range=color_range,
    [254](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:254)         opacity=opacity,
    [255](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:255)         name=name,
    [256](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:256)         group=group,
    [257](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:257)         custom_data=custom_data,
    [258](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:258)         compression_level=compression_level,
    [259](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:259)     ),
    [260](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:260)     **kwargs
    [261](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/factory.py:261) )

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/objects.py:310, in Line.__init__(self, **kwargs)
    [309](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/objects.py:309) def __init__(self, **kwargs):
--> [310](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/objects.py:310)     super(Line, self).__init__(**kwargs)
    [312](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/objects.py:312)     self.set_trait("type", "Line")

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/objects.py:108, in Drawable.__init__(self, **kwargs)
    [105](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/objects.py:105) def __init__(self, **kwargs):
    [106](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/objects.py:106)     self.id = id(self)
--> [108](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/k3d/objects.py:108)     super(Drawable, self).__init__(**kwargs)

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:503, in Widget.__init__(self, **kwargs)
    [501](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:501) """Public constructor"""
    [502](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:502) self._model_id = kwargs.pop('model_id', None)
--> [503](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:503) super().__init__(**kwargs)
    [505](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:505) Widget._call_widget_constructed(self)
    [506](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:506) self.open()

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1355, in HasTraits.__init__(self, *args, **kwargs)
   [1353](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1353) for key, value in kwargs.items():
   [1354](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1354)     if self.has_trait(key):
-> [1355](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1355)         setattr(self, key, value)
   [1356](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1356)         changes[key] = Bunch(
   [1357](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1357)             name=key,
   [1358](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1358)             old=None,
   (...)
   [1361](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1361)             type="change",
   [1362](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1362)         )
   [1363](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1363)     else:
   [1364](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:1364)         # passthrough args that don't set traits to super

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:716, in TraitType.__set__(self, obj, value)
    [714](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:714) if self.read_only:
    [715](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:715)     raise TraitError('The "%s" trait is read-only.' % self.name)
--> [716](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:716) self.set(obj, value)

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:690, in TraitType.set(self, obj, value)
    [689](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:689) def set(self, obj: HasTraits, value: S) -> None:
--> [690](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:690)     new_value = self._validate(obj, value)
    [691](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:691)     assert self.name is not None
    [692](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:692)     try:

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:722, in TraitType._validate(self, obj, value)
    [720](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:720)     return value
    [721](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:721) if hasattr(self, "validate"):
--> [722](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:722)     value = self.validate(obj, value)
    [723](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:723) if obj._cross_validation_lock is False:
    [724](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:724)     value = self._cross_validate(obj, value)

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:2460, in Union.validate(self, obj, value)
   [2458](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:2458)         except TraitError:
   [2459](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:2459)             continue
-> [2460](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:2460) self.error(obj, value)

File ~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:831, in TraitType.error(self, obj, value, error, info)
    [825](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:825) else:
    [826](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:826)     e = "The '{}' trait expected {}, not {}.".format(
    [827](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:827)         self.name,
    [828](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:828)         info or self.info(),
    [829](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:829)         describe("the", value),
    [830](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:830)     )
--> [831](https://file+.vscode-resource.vscode-cdn.net/home/some_path~/conda_stuff/envs/gustafenv/lib/python3.11/site-packages/traitlets/traitlets.py:831) raise TraitError(e)

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

I have traced the issue to the vedo.backends file. If I change the following lines, the issue is not present anymore.

line 316 onward to:

            aves = float(ia.average_size() * iap.GetPointSize() / 200)

            kobj = k3d.points(
                ia.vertices.astype(float),
                color=_rgb2int(iap.GetColor()),
                colors=kcols,
                opacity=iap.GetOpacity(),
                shader=settings.k3d_point_shader,
                point_size=aves,
                name=name,
            )

and lines from 243 onward:

                aves = float(ia.diagonal_size() * iap.GetLineWidth() / 100)

                kobj = k3d.line(
                    pts.astype(float),
                    color=_rgb2int(iap.GetColor()),
                    opacity=iap.GetOpacity(),
                    shader=settings.k3d_line_shader,
                    width=aves,
                    name=name,
                )

I am casting the width/pts_size into a float (instead of the np.float32 it would have been) and converting the vertices/points into an array of floats (instead of np.float32). My guess is that traitlets or numpy default conversion/type checking has changed. (I have checked, and you can also change the type to np.float64, and I am not getting any errors anymore.)

@marcomusy
Copy link
Owner

@clemens-fricke thanks for reporting and for the fixing! I just pushed it.

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