Quantcast
Channel: Python: using dictionary value as an index into numpy array - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Python: using dictionary value as an index into numpy array

$
0
0

I have a 3 dimensional numpy array, for example:

x = np.zeros((10, 10, 10))

Now, I have a dictionary as follows, which keeps a 1-D to 3-D mapping as follows:

d = {}d[0] = (1, 1, 1)

Now, I want to access the element referred to by the key, so I tried something like:

print x[d[0]] 

This results in a typeerror as:

TypeError: 'type' object has no attribute '__getitem__'

I am guessing the tuple is not a good idea to store the 3D coordinates. How can I resolve this?


Viewing all articles
Browse latest Browse all 2

Trending Articles