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><code>X = [X[i] for i in range(len(X)) if X[i]**2 + Y[i]**2 &lt; 1]</code></p>

<p>this will filter X so that X only contains those that match your filtering criteria. </p>

<p>Note that this does use looping via comprehension, so I am not quite sure how this is to be done without looping. </p>

python arrays numpy