I have 2d numpy arrays<br><br><div class="gmail_quote">On Wed, Dec 7, 2011 at 1:05 PM, Olivier Delalleau <span dir="ltr"><<a href="mailto:shish@keba.be">shish@keba.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Weird, it worked for me (with a and b two 1d numpy arrays). Anyway, Josef's solution is probably much more efficient (especially if you can put all your arrays into a single tensor).<div class="HOEnZb"><div class="h5">
<br><br>-=- Olivier<br><br><div class="gmail_quote">
2011/12/6 questions anon <span dir="ltr"><<a href="mailto:questions.anon@gmail.com" target="_blank">questions.anon@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hi Olivier,<br>No that does not seem to do anything<br>am I missing another step whereever b is greater than a replace b with a?<br>thanks<div><div><br><br><div class="gmail_quote">On Wed, Dec 7, 2011 at 11:55 AM, Olivier Delalleau <span dir="ltr"><<a href="mailto:shish@keba.be" target="_blank">shish@keba.be</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">It may not be the most efficient way to do this, but you can do:<br>mask = b > a<br>a[mask] = b[mask]<br>


<br>-=- Olivier<br><br><div class="gmail_quote">2011/12/6 questions anon <span dir="ltr"><<a href="mailto:questions.anon@gmail.com" target="_blank">questions.anon@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div>I would like to produce an array with the maximum values out of many (10000s) of arrays.<br>


I need to loop through many multidimentional arrays and if a value is larger (in the same place as the previous array) then I would like that value to replace it.<br>

<br>e.g.<br>a=[1,1,2,2<br>11,2,2<br>1,1,2,2]<br>b=[1,1,3,2<br>2,1,0,0<br>1,1,2,0]<br><br>where b>a replace with value in b, so the new a should be :<br><br>a=[1,1,3,2]<br>2,1,2,2<br>1,1,2,2]<br><br>and then keep looping through many arrays and replace whenever value is larger.<br>




<br>I have tried numpy.putmask but that results in <br>TypeError: putmask() argument 1 must be numpy.ndarray, not list<br>Any other ideas? Thanks<br>
<br></div></div>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">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>
<br></blockquote></div><br>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">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>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">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>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<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>
<br></blockquote></div><br>