Getting the correct dimensions after using np.nonzero on array
<p>When using the the np.nonzero on a 1d array: </p>

<pre><code>l = np.array([0, 1, 2, 3, 0])
np.nonzero(l)
array([1,2,3], dtype=int64)
</code></pre>

<p>How do I get the index information as a 1d array and not as a tuple in the most effecient way? </p>

<p>Just index the tuple</p>

<pre><code>Idn = np.nonzero(l)[0]
</code></pre>

<p>Code of <code>flatnonzero</code> does</p>

<pre><code>return a.ravel().nonzero()[0]
</code></pre>

python arrays numpy shape zero