Tuple as index of multidimensional array

前端 未结 2 978
我在风中等你
我在风中等你 2020-12-18 03:51

I found a very similar question to mine, but not exactly the same. This one: here However in ntimes\'s case the size of the array matches the number of the dimensions the tu

2条回答
  •  温柔的废话
    2020-12-18 04:15

    Since you're using numpy:

    big_array[tup+(3,2)]
    

    should work. When you call __getitem__ (via the square brackets), the stuff is passed to __getitem__ as a tuple. You just need to construct the tuple explicitly here (adding tuples together concatenates into a new tuple) and numpy will do what you want.

提交回复
热议问题