<br><br><div class="gmail_quote">On Wed, Sep 30, 2009 at 2:45 PM, Robert Kern <span dir="ltr"><<a href="mailto:robert.kern@gmail.com">robert.kern@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wed, Sep 30, 2009 at 14:40, Gökhan Sever <<a href="mailto:gokhansever@gmail.com">gokhansever@gmail.com</a>> wrote:<br>
> Thanks this works.<br>
><br>
> My second question how to access a second array using this condition?<br>
><br>
> I am trying slice another array using a compound condition on the reference<br>
> array.<br>
><br>
> say:<br>
><br>
> a = 1,2,3,4,5,<br>
> b = 20,30,40,50,60<br>
><br>
> I want to get elements of a only when a = 3,4. I know I need indices but how<br>
> ?<br>
<br>
</div>Did you mean "elements of b only where a = 3,4"?<br>
<br>
b[(a==3) | (a==4)]<br>
<font color="#888888"><br>
--<br>
Robert Kern<br>
<br>
"I have come to believe that the whole world is an enigma, a harmless<br>
enigma that is made terrible by our own mad attempt to interpret it as<br>
though it had an underlying truth."<br>
  -- Umberto Eco<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br><br>Ok, ok got it. Thanks Robert :)<br><br>Following is what I have been looking for exactly.<br><br>I[1]: a = arange(5)<br><br>I[2]: b = arange(5)*10<br><br>I[3]: a<br>O[3]: array([0, 1, 2, 3, 4])<br>
<br>I[4]: b<br>O[4]: array([ 0, 10, 20, 30, 40])<br><br>I[5]: b[(a>1) & (a<3)]<br>O[5]: array([20])<br><br>I was forgetting the parenthesis, and consequently I was being bitten by <br><br>ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()<br>
<br>I am glad that it is not my understanding of logic but the usage of NumPy.<br clear="all"><br>-- <br>Gökhan<br>