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'