<p>是否有一种有效的Numpy机制来检索数组中基于条件的位置的整数索引是真的,而不是布尔掩码数组?</p>
<p>例如:</p>
<pre><code>x=np.array([range(100,1,-1)])
#generate a mask to find all values that are a power of 2
mask=x&(x-1)==0
#This will tell me those values
print x[mask]
</code></pre>
<p>在这种情况下,我想知道<code>mask</code>的索引<code>i</code>,其中<code>mask[i]==True</code>。不需要循环就可以生成它们吗?</p>