numpy - Python: Assign list to multidimensional array element -


i want assignment multidimensional array each element of array 3 short integers:

a = ndarray([3,3,3], dtype='u2,u2,u2') a[2,2,2] = [1,2,3] 

traceback (most recent call last): file "", line 1, in a[2,2,2] = [1,2,3] typeerror: expected readable buffer object

i going using large array , direct indexing array performance. way in python?

thanks insight how this?

the elements of array of dtype='u2,u2,u2' tuple of 3 shorts, not list of 3 shorts. so:

a[2,2,2] = (1,2,3) 

(the parens of course not necessary, used them make obvious tuple.)

you can pass array if want:

a[2,2,2] = np.array([1,2,3]) 

of course error message here better… it's complaining deeper you'd expect, , doesn't debug problem.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -