-
Notifications
You must be signed in to change notification settings - Fork 629
Updating collections #1505
Copy link
Copy link
Open
Description
Hello, I don't find how to update basic values of collections.
For example, i can create a points collection:
points = PointCollection("agg", color="shared", size="local")
n = 1000
self.points.append(np.random.normal(0.0, 0.5, (self.n, 3))
color=np.column_stack((np.random.random((self.n, 3)), np.ones(self.n))),
size=8)
But trying to change its vertices coordinates:
points['position'] = np.random.normal(0.0, 0.5, (self.n, 3))
Gives me the error:
File "/AlphaI/test.py", line 36, in change
self.points['position'] = pos
File "/vispy/vispy/visuals/collections/collection.py", line 192, in __setitem__
BaseCollection.__setitem__(self, key, value)
File "/vispy/vispy/visuals/collections/base_collection.py", line 432, in __setitem__
V[key] = data
File "/vispy/vispy/gloo/buffer.py", line 271, in __setitem__
raise ValueError("Cannot set non-contiguous data on buffer")
Besides, I managed to update the colors:
points['color'] = np.column_stack((np.random.random((self.n, 3)), np.ones(self.n)))
canvas.update() # this involves redrawing the points
This was possible only with color="shared" when constructing the PointCollection object, while color="local" resulted in the same error as above when trying to update the color; but i could not guess appropriately what these keywords mean. I tried a similar position="shared" but this was not accepted. In general i am suffering from the lack of documentation!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels