Re: a numarray question

2006-02-15 Thread avharut
thanks guys! import timeit first_way = "the_array[the_array == 0] = 5.0" second_way = "another_array = numarray.choose(the_array == 0, (the_array, 5.0))" some_third_way = """\ indx = numarray.where(the_array == 0)[0] another_array = numarray.put(the_array, indx, len(indx) * [5.0,]) ""

Re: a numarray question

2006-02-15 Thread Bas
I believe it is something like a[a==0] = 5 Note that numarray will eventually be replaced by Scipy/Numpy at some time, but this wouldn't change the basic stuff. Cheers, Bas -- http://mail.python.org/mailman/listinfo/python-list

Re: a numarray question

2006-02-15 Thread Juho Schultz
[EMAIL PROTECTED] wrote: > hello everyone > > would anyone please tell me what is the best (fastest) way of replacing > values in numarray arrays? > > lets say i have an array that may contain 0s, and i just want to get > rid of those 0s by replacing them with another number. what would be > the

a numarray question

2006-02-15 Thread avharut
hello everyone would anyone please tell me what is the best (fastest) way of replacing values in numarray arrays? lets say i have an array that may contain 0s, and i just want to get rid of those 0s by replacing them with another number. what would be the most efficient way to do that? many than

Re: Numarray question

2005-05-13 Thread Robert Kern
Matt Feinstein wrote: > If I try > > 2 < array([1,2,3]) > > > I get: > > array([0, 0, 1], type=Bool) > > which is pretty slick, However if I set > > q = 2 < array([1,2,3]) q and q > > > I get a runtime error: "An array doesn't make sense as a truth value." > > So.. why not?

Numarray question

2005-05-13 Thread Matt Feinstein
If I try >>> 2 < array([1,2,3]) I get: array([0, 0, 1], type=Bool) which is pretty slick, However if I set >>> q = 2 < array([1,2,3]) >>> q and q I get a runtime error: "An array doesn't make sense as a truth value." So.. why not? It seems to me that if I could vectorize logical expressions