I have 2d numpy arrays On Wed, Dec 7, 2011 at 1:05 PM, Olivier Delalleau <sh...@keba.be> wrote:
> 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). > > > -=- Olivier > > 2011/12/6 questions anon <questions.a...@gmail.com> > >> Hi Olivier, >> No that does not seem to do anything >> am I missing another step whereever b is greater than a replace b with a? >> thanks >> >> >> On Wed, Dec 7, 2011 at 11:55 AM, Olivier Delalleau <sh...@keba.be> wrote: >> >>> It may not be the most efficient way to do this, but you can do: >>> mask = b > a >>> a[mask] = b[mask] >>> >>> -=- Olivier >>> >>> 2011/12/6 questions anon <questions.a...@gmail.com> >>> >>>> I would like to produce an array with the maximum values out of many >>>> (10000s) of arrays. >>>> 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. >>>> >>>> e.g. >>>> a=[1,1,2,2 >>>> 11,2,2 >>>> 1,1,2,2] >>>> b=[1,1,3,2 >>>> 2,1,0,0 >>>> 1,1,2,0] >>>> >>>> where b>a replace with value in b, so the new a should be : >>>> >>>> a=[1,1,3,2] >>>> 2,1,2,2 >>>> 1,1,2,2] >>>> >>>> and then keep looping through many arrays and replace whenever value is >>>> larger. >>>> >>>> I have tried numpy.putmask but that results in >>>> TypeError: putmask() argument 1 must be numpy.ndarray, not list >>>> Any other ideas? Thanks >>>> >>>> _______________________________________________ >>>> NumPy-Discussion mailing list >>>> NumPy-Discussion@scipy.org >>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion >>>> >>>> >>> >>> _______________________________________________ >>> NumPy-Discussion mailing list >>> NumPy-Discussion@scipy.org >>> http://mail.scipy.org/mailman/listinfo/numpy-discussion >>> >>> >> >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@scipy.org >> http://mail.scipy.org/mailman/listinfo/numpy-discussion >> >> > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion