You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use SurfacePlot to draw a surface and seed color parameter, an error occurs:
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/vispy/visuals/surface_plot.py", line 129, in _prepare_mesh_colors
colors = colors.reshape(num_vertices, 3)
ValueError: cannot reshape array of size 960000 into shape (240000,3)
I note that the _prepare_mesh_colors function in vispy/visuals/surface_plot.py is:
def _prepare_mesh_colors(self, colors):
if colors is None:
return
colors = np.asarray(colors)
if colors.ndim == 3:
# convert (width, height, 4) to (num_verts, 4)
vert_shape = self.__vertices.shape
num_vertices = vert_shape[0] * vert_shape[1]
colors = colors.reshape(num_vertices, 3)
return colors
The comment and document state that I should pass in a matrix of dimensions (width, height, 4), which will then be transformed into a matrix of dimensions (num_verts, 4). However, the code does not follow this approach; instead, it transforms it into a matrix of dimensions (num_verts, 3).
The text was updated successfully, but these errors were encountered:
At first glance this does seem like a bug, but also what colors are you providing? RGB? RGBA?
Skimming through the code it does definitely seem like RGBA (4 elements) is the more performant way of providing the colors. Otherwise, VisPy adds the alpha channel itself which requires a copy of the color array. I'm not really sure how or why this is reshaping to 3 (RGB). If you feel up to it, it would be great if you could make a pull request fixing this.
Hi!
When I use
SurfacePlot
to draw a surface and seedcolor
parameter, an error occurs:I note that the
_prepare_mesh_colors
function invispy/visuals/surface_plot.py
is:The comment and document state that I should pass in a matrix of dimensions
(width, height, 4)
, which will then be transformed into a matrix of dimensions(num_verts, 4)
. However, the code does not follow this approach; instead, it transforms it into a matrix of dimensions(num_verts, 3)
.The text was updated successfully, but these errors were encountered: