Filter one array according to data in another array
<p>I have two arrays of random numbers, <code>X</code> and <code>Y</code>. X represents x-coordinates and <code>Y</code> represents y-coordinates. I want to filter <code>X</code> such that I only keep indices <code>i</code> of <code>X</code> where:</p>

<pre><code>X[i]^2 + Y[i]^2 &lt; 1
</code></pre>

<p>I know how to filter with values in 1 array but since I need to use 2, I am not sure what to do. I am not allowed to use loops of any kind.</p>

<p>This will do:</p>

<pre><code>X_filtered = X[X**2 + Y**2 &lt; 1]
</code></pre>

<p><code>X**2 + Y**2 &lt; 1</code> returns a boolean array and accessing <code>X</code> on this array returns <code>X</code> only at the indices equal to <code>True</code>.</p>

python arrays numpy