-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Long/complex explanation sorry: It explains why converting why generating protocol commands with vec3 always leads to exception.
This is the ndarray to buffer converter. It is used to convert vec3/vec4 to buffer, which is required to generate GSP commands from any visual.
GSP/gsp/matplotlib/__init__.py
Lines 43 to 51 in 6aefaab
| @register("ndarray", "Buffer") | |
| def ndarray_to_Buffer(obj): | |
| # WARN: Do we need to keep track of obj/Buffer such as not create | |
| # several buffers pointing at the same underlying object? | |
| # In the current implementation, Buffer is created each time | |
| # this convertes is called such that if the obj has been | |
| # mofidied, it shoudl be ok | |
| Z = glm.ndarray.tracked(obj) | |
| return Z._tracker.gsp_buffer |
As it is a converter, the obj in there is a numpy.ndarray. It uses glm.ndarray.tracked(obj) which is supposed to be API compatible with np.ndarray (@rougier correct me if im wrong).
It then goes into the __new__ of https://github.com/vispy/GSP/blob/master/gsp/glm/ndarray/tracked.py.
GSP/gsp/glm/ndarray/tracked.py
Lines 36 to 40 in 3fe4d22
| def __new__(cls, *args, **kwargs): | |
| obj = np.ndarray.__new__(cls, *args, **kwargs) | |
| if cls.__tracker_class__ is not None: | |
| obj._tracker = cls.__tracker_class__(obj) | |
| return obj |
And here notice how it call np.ndarray.__new__(cls, *args, **kwargs) which is relatively equivalent to np.ndarray(obj) with the obj from the converter.
Unfortunatly np.ndarray(other_ndarray) is not a valid API. here is the doc https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html which shows that the first argument is a shape . It interprets the other_ndarray as a definition of shape and lead to this error message
Exception has occurred: ValueError
maximum supported dimension for an ndarray is currently 64, found 200000