Re: [Numpy-discussion] numpy.where behavior

2006-11-13 Thread Robert Kern
Tim Hochberg wrote: > Another little tidbit: this is not as general as where, and could > probably be considered a little too clever to be clear, but: > > b = 1 / (a + (a==0.0)) > > is faster than using where in this particular case and sidesteps the > divide by zero issue altogether.

Re: [Numpy-discussion] numpy.where behavior

2006-11-13 Thread Paul Dubois
Unfortunately, where does not have the behavior of not evaluating the second argument where the first one is true. That would be nice (if the speed were ok) but it isn't possible unless where is built into the language, since where doesn't even get called until the arguments have all been calculate

Re: [Numpy-discussion] numpy.where behavior

2006-11-13 Thread Tim Hochberg
[EMAIL PROTECTED] wrote: > Using numpy 1.0, why does > > > > a = numpy.array([0.0,1.0,2.0],'d') > > numpy.where(a > == 0.0,1,1/a) > > > > give the correct result, but with the warning "Warning: divide > by zero encountered in divide"? > > > > ? I thought

Re: [Numpy-discussion] memmap working?

2006-11-13 Thread Charles R Harris
On 11/13/06, Mathew Yeates <[EMAIL PROTECTED]> wrote: Not sure. When I run "top" I see the lineMemory: 6016M real, 2895M free, 4174M swap in use, 2427M swap freeIts the second number that drops like a rock. Plus, it never comes backuntil I quit the program. This is a great way to turn my machine in

Re: [Numpy-discussion] numpy.where behavior

2006-11-13 Thread Robert Kern
[EMAIL PROTECTED] wrote: > ? I thought that the point of where was > that the second expression is never used for the elements where the condition > evaluates true. It is not used, but the expression still gets evaluated. There's really no way around that. > If this is the desired behavior, is t

[Numpy-discussion] numpy.where behavior

2006-11-13 Thread vallis . 35530053
Using numpy 1.0, why does >>> a = numpy.array([0.0,1.0,2.0],'d') >>> numpy.where(a == 0.0,1,1/a) give the correct result, but with the warning "Warning: divide by zero encountered in divide"? ? I thought that the point of where was that the second expression is never used for the elements

Re: [Numpy-discussion] memmap working?

2006-11-13 Thread Mathew Yeates
Not sure. When I run "top" I see the line Memory: 6016M real, 2895M free, 4174M swap in use, 2427M swap free Its the second number that drops like a rock. Plus, it never comes back until I quit the program. This is a great way to turn my machine into a nice desk ornament! Mathew Charles R Har

Re: [Numpy-discussion] memmap working?

2006-11-13 Thread Charles R Harris
On 11/13/06, Mathew Yeates <[EMAIL PROTECTED]> wrote: I have a memory mapped array. When I try and assign data, my mem usagegoes through the roof.Is it cache memory or process memory? I think a memory mapped file will keep pages cached in memory until the space is needed so as to avoid unneeded io.

Re: [Numpy-discussion] array from list of lists

2006-11-13 Thread Stefan van der Walt
On Mon, Nov 13, 2006 at 02:29:11PM -0700, Tim Hochberg wrote: > Erin Sheldon wrote: > > On 11/13/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > > > >> Here's one more approach that's marginally faster than the map based > >> solution and also won't chew up an extra memory since it's based on from

Re: [Numpy-discussion] array from list of lists

2006-11-13 Thread Tim Hochberg
Erin Sheldon wrote: > On 11/13/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > >> Here's one more approach that's marginally faster than the map based >> solution and also won't chew up an extra memory since it's based on from >> iter: >> >> numpy.fromiter(itertools.imap(tuple, results), dtype=myd

[Numpy-discussion] memmap working?

2006-11-13 Thread Mathew Yeates
I have a memory mapped array. When I try and assign data, my mem usage goes through the roof. example: outdat[filenum,:]=outarr where outdat is memory mapped. Anybody know how to avoid this? Mathew - Using Tomcat but need

Re: [Numpy-discussion] array from list of lists

2006-11-13 Thread Erin Sheldon
On 11/13/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: > Here's one more approach that's marginally faster than the map based > solution and also won't chew up an extra memory since it's based on from > iter: > > numpy.fromiter(itertools.imap(tuple, results), dtype=mydescriptor, > count=len(results))

Re: [Numpy-discussion] why the difference between ipython and python shell?

2006-11-13 Thread Charles R Harris
On 11/13/06, Seweryn Kokot <[EMAIL PROTECTED]> wrote: Hello,Why ipython and python interactive shell give two different information?--- ipythonPython 2.4.4 (#2, Oct 20 2006, 00:23:25)Type "copyright", "credits" or "license" for more information. IPython 0.7.2 -- An enhanced Interactive Python.?

Re: [Numpy-discussion] array from list of lists

2006-11-13 Thread Tim Hochberg
Tim Hochberg wrote: > [SNIP] >> >> > > Just for completeness, I benchmarked the fromiter and map(tuple, > results) solutions as well. Map is fastest, followed by fromiter, list > comprehension and then fromrecords. The differences are pretty minor > however, so I'd stick with whatever s

[Numpy-discussion] why the difference between ipython and python shell?

2006-11-13 Thread Seweryn Kokot
Hello, Why ipython and python interactive shell give two different information? --- ipython Python 2.4.4 (#2, Oct 20 2006, 00:23:25) Type "copyright", "credits" or "license" for more information. IPython 0.7.2 -- An enhanced Interactive Python. ? -> Introduction to IPython's features. %m

Re: [Numpy-discussion] array from list of lists

2006-11-13 Thread Erin Sheldon
On 11/13/06, Francesc Altet <[EMAIL PROTECTED]> wrote: > In any case, you can also use rec.fromrecords for build recarrays from > lists of lists. This breaks the aforementioned rule, but Travis allowed > this because rec.* had to mimic numarray behaviour as much as possible. > Here is an example of

Re: [Numpy-discussion] array from list of lists

2006-11-13 Thread Tim Hochberg
Francesc Altet wrote: > El dl 13 de 11 del 2006 a les 02:07 -0500, en/na Erin Sheldon va > escriure: > >> On 11/13/06, Charles R Harris <[EMAIL PROTECTED]> wrote: >> >>> On 11/12/06, Erin Sheldon <[EMAIL PROTECTED]> wrote: >>> Hi all - Thanks to everyone for the sugges

Re: [Numpy-discussion] Could numpy.matlib.nanmax return a matrix?

2006-11-13 Thread Sven Schreiber
Pierre GM schrieb: > On Sunday 12 November 2006 17:08, A. M. Archibald wrote: >> On 12/11/06, Keith Goodman <[EMAIL PROTECTED]> wrote: >>> Is anybody interested in making x.max() and nanmax() behave the same >>> for matrices, except for the NaN part? That is, make >>> numpy.matlib.nanmax return a m

Re: [Numpy-discussion] array from list of lists

2006-11-13 Thread Francesc Altet
El dl 13 de 11 del 2006 a les 02:07 -0500, en/na Erin Sheldon va escriure: > On 11/13/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > > > On 11/12/06, Erin Sheldon <[EMAIL PROTECTED]> wrote: > > > Hi all - > > > > > > Thanks to everyone for the suggestions. > > > I think map(tuple, list) is