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

OverflowError: Python integer 65536 out of bounds for uint8 #1224

Open
orena1 opened this issue Feb 14, 2025 · 1 comment
Open

OverflowError: Python integer 65536 out of bounds for uint8 #1224

orena1 opened this issue Feb 14, 2025 · 1 comment
Labels

Comments

@orena1
Copy link

orena1 commented Feb 14, 2025

Hi,
I get this error:

C:\Users\oamsalem\anaconda3\envs\brainrender\Lib\site-packages\traittypes\traittypes.py:97: UserWarning: Given trait value dtype "float64" does not match required type "float32". A coerced copy has been created.
  warnings.warn(
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ Z:\Projects\merfish_registration\Show_FoV_Rachel.py:95 in <module>                               │
│                                                                                                  │
│   92 print("---- Saving rander to html ---- ")                                                   │
│   93                                                                                             │
│   94 # scene.render()                                                                            │
│ ❱ 95 scene.export(f"Rachel_FoV_new_5_{mask_name}.html")                                          │
│   96 #                                                                                           │
│   97 print("---- Done ---- ")                                                                    │
│   98                                                                                             │
│                                                                                                  │
│ C:\Users\oamsalem\anaconda3\envs\brainrender\Lib\site-packages\brainrender\render.py:319 in      │
│ export                                                                                           │
│                                                                                                  │
│   316 │   │   # Create new plotter and save to file                                              │
│   317 │   │   plt = Plotter()                                                                    │
│   318 │   │   plt.add(self.clean_renderables).render()                                           │
│ ❱ 319 │   │   plt = plt.show(interactive=False)                                                  │
│   320 │   │                                                                                      │
│   321 │   │   with open(path, "w") as fp:                                                        │
│   322 │   │   │   fp.write(plt.get_snapshot())                                                   │
│                                                                                                  │
│ C:\Users\oamsalem\anaconda3\envs\brainrender\Lib\site-packages\vedo\plotter.py:3337 in show      │
│                                                                                                  │
│   3334 │   │                                                                                     │
│   3335 │   │   # Backend ###############################################################         │
│   3336 │   │   if vedo.settings.default_backend in ["k3d", "panel"]:                             │
│ ❱ 3337 │   │   │   return backends.get_notebook_backend(self.objects)                            │
│   3338 │   │   #########################################################################         │
│   3339 │   │                                                                                     │
│   3340 │   │   for ia in utils.flatten(objects):                                                 │
│                                                                                                  │
│ C:\Users\oamsalem\anaconda3\envs\brainrender\Lib\site-packages\vedo\backends.py:31 in            │
│ get_notebook_backend                                                                             │
│                                                                                                  │
│    28 │                                                                                          │
│    29 │   #########################################                                              │
│    30 │   if settings.default_backend == "k3d":                                                  │
│ ❱  31 │   │   return start_k3d(actors2show)                                                      │
│    32 │                                                                                          │
│    33 │   #########################################                                              │
│    34 │   if settings.default_backend.startswith("trame"):                                       │
│                                                                                                  │
│ C:\Users\oamsalem\anaconda3\envs\brainrender\Lib\site-packages\vedo\backends.py:300 in start_k3d │
│                                                                                                  │
│   297 │   │   │   │   vcols = ia.dataset.GetPointData().GetScalars()                             │
│   298 │   │   │   │   if vcols and vcols.GetNumberOfComponents() == 3:                           │
│   299 │   │   │   │   │   cols = utils.vtk2numpy(vcols)                                          │
│ ❱ 300 │   │   │   │   │   cols = 65536 * cols[:, 0] + 256 * cols[:, 1] + cols[:, 2]              │
│   301 │   │   │   │   # print("GetColor",iap.GetColor(), _rgb2int(iap.GetColor()) )              │
│   302 │   │   │   │   # print("colors", len(cols))                                               │
│   303 │   │   │   │   # print("color_attribute", color_attribute)                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OverflowError: Python integer 65536 out of bounds for uint8

When tryin to use brainrender and vedo, any idea ?

@IgorTatarnikov

@marcomusy marcomusy added the bug label Feb 17, 2025
marcomusy added a commit that referenced this issue Feb 18, 2025
@marcomusy
Copy link
Owner

Thanks @orena1 for reporting the issue and sorry for the late reply. I think it is indeed a bug. I hope this can fix it:

pip install -U git+https://github.com/marcomusy/vedo.git

Test:

import numpy as np
from vedo import Sphere, settings

settings.default_backend = "k3d"

s = Sphere()

rgb = []
for i in range(s.npoints):
    r = 255 * i / s.npoints
    g = 1 - r/2
    b = 1 - r
    rgb.append([r, g, b])
s.pointcolors = rgb

# rgb = []
# for i in range(s.ncells):
#     r = 255 * i / s.ncells
#     g = 1 - r/2
#     b = 1 - r
#     rgb.append([r, g, b])
# s.cellcolors = rgb

print(s)
s.show(axes=1)

Image

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

No branches or pull requests

2 participants