[Numpy-discussion] [Q]Best way for an array operation?

Janko Hauser jhauser at ifm.uni-kiel.de
Sat Oct 14 14:32:33 EDT 2000


What is the difference of putmask and where? As it seems the only
difference is the inplace behavior. This becomes more and more
complicated as we have this subtle difference at many places (ravel
vs. flat) and in future also the augmented assignment stuff, which
also works for arrays now, although I do not know, if it's really an
inplace assignment. What are the next functions for which a
spacesaving variant is introduced? Would it be better to come to
another convention for this type of optimization? As a side note the
order of arguments is different for putmask and where.

__Janko

Paul F. Dubois writes:
 > There is (in CVS) a new function, putmask:
 > 
 > c = greater(x, 0)
 > putmask(y, c, v)
 > putmask(z, c, u+2)
 > 
 > The documentation is now online. Briefly:
 > putmask(a, m, v) sets a to v where m is true.
 > 
 > a must be a contiguous array
 > m must be the same total size as a (shape ignored)
 > v will be repeated as needed to that size
 > 
 > The underlying work is done in C.
 > 
 > -----Original Message-----
 > From: numpy-discussion-admin at lists.sourceforge.net
 > [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of
 > Daehyok Shin
 > Sent: Friday, October 13, 2000 5:26 PM
 > To: Numpy Discussion
 > Subject: [Numpy-discussion] [Q]Best way for an array operation?
 > 
 > 
 > What is the best Numpy way for the following work?
 > 
 > for i in range(len(x)):
 >     if x[i] > 0:
 >         y[i] = v[i]
 >         z[i] = u[i]+2
 > 
 > Daehyok Shin (Peter)
 > 
 > 
 > _______________________________________________
 > Numpy-discussion mailing list
 > Numpy-discussion at lists.sourceforge.net
 > http://lists.sourceforge.net/mailman/listinfo/numpy-discussion
 > _______________________________________________
 > Numpy-discussion mailing list
 > Numpy-discussion at lists.sourceforge.net
 > http://lists.sourceforge.net/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list