numpy中切片和数组索引的组合

时间:2020-10-11 15:00:53

标签: numpy numpy-ndarray numpy-slicing

查看以下问题的答案:How to understand numpy's combined slicing and indexing example

我仍然无法理解切片和两个1d数组的组合的索引结果,如下所示:

import SwiftUI

struct TestList: View {
  var body: some View {
    NavigationView{
      List {
        Text("hello world")
        Text("hello world")
        Text("hello world")
      }
      .listStyle(PlainListStyle())
      .navigationBarTitle(Text("Test List"), displayMode:.inline)
      .navigationBarItems(leading:
                            Image(systemName: "bell")
      )
    }
  }
}

struct TestList_Previews: PreviewProvider {
  static var previews: some View {
    TestList()
  }
}

为什么结果等于这个?

>>> m = np.arange(36).reshape(3,3,4)
>>> m
array([[[ 0,  1,  2,  3],
        [ 4,  5,  6,  7],
        [ 8,  9, 10, 11]],

       [[12, 13, 14, 15],
        [16, 17, 18, 19],
        [20, 21, 22, 23]],

       [[24, 25, 26, 27],
        [28, 29, 30, 31],
        [32, 33, 34, 35]]])

>>> m[1:3, [2,1],[2,1]]
array([[22, 17],
       [34, 29]])

0 个答案:

没有答案