Python “我如何组合numpy”;“高级索引”;有'np.newaxis'?

Python “我如何组合numpy”;“高级索引”;有'np.newaxis'?,python,numpy,Python,Numpy,如何将numpy“高级索引”与np.newaxis相结合 import numpy as np a = np.zeros(10) b = np.zeros(10, dtype=np.bool_) b[4] = True print(a[b]) # [ 0.] print(a[b][:, np.newaxis]) # [[ 0.]] (works, but this is inelegant) print(a[b, np.newaxis]) # TypeError: int() argum

如何将numpy“高级索引”与
np.newaxis
相结合

import numpy as np
a = np.zeros(10)
b = np.zeros(10, dtype=np.bool_)
b[4] = True
print(a[b])  # [ 0.]
print(a[b][:, np.newaxis])  # [[ 0.]]  (works, but this is inelegant)
print(a[b, np.newaxis])  # TypeError: int() argument must be a string or a number, not 'NoneType'

可能是numpy的臭虫?只是不起作用。可能会使用numpy 1.8。只要把操作链。。。首先添加None,然后执行高级索引。@seberg:看起来这个bug不在路线图上:我想他们不知道。请看:@seberg:太棒了!感谢你在这个问题上所做的工作。期待着看到它很快合并。