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?

1 Answer 1

1

The code you've shown us is fine. You have an error somewhere else, probably reusing the x or d variables or forgetting function call parentheses.

Sign up to request clarification or add additional context in comments.

1 Comment

try: import numpy ; numpy.test('full') here : stackoverflow.com/questions/9200727/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.