Re: [Numpy-discussion] argmin & min on ndarrays

2008-03-04 Thread Pierre GM
Anne, > I should have provided the link before, but this is very useful for > answering this kind of question: > http://www.scipy.org/Numpy_Functions_by_Category Great link indeed, that complements well the example list: http://www.scipy.org/Numpy_Example_List Thanks again !

Re: [Numpy-discussion] argmin & min on ndarrays

2008-03-04 Thread Anne Archibald
On 04/03/2008, Pierre GM <[EMAIL PROTECTED]> wrote: > Anne, > > Thanks a lot for your suggestion. Something like > > >>>if axis is None: > >>>return b.flat[a.argmin()] > >>>else: > >>> return numpy.choose(a.argmin(axis),numpy.rollaxis(b,axis,0)) > > seems to do the trick fairly nicely i

Re: [Numpy-discussion] argmin & min on ndarrays

2008-03-04 Thread Pierre GM
Anne, Thanks a lot for your suggestion. Something like >>>if axis is None: >>>return b.flat[a.argmin()] >>>else: >>> return numpy.choose(a.argmin(axis),numpy.rollaxis(b,axis,0)) seems to do the trick fairly nicely indeed. The other solutions you suggested would require too much ad hoc ad

Re: [Numpy-discussion] argmin & min on ndarrays

2008-03-04 Thread Anne Archibald
On 04/03/2008, Pierre GM <[EMAIL PROTECTED]> wrote: > All, > Let a & b be two ndarrays of the same shape. I'm trying to find the elements > of b that correspond to the minima of a along an arbitrary axis. > The problem is trivial when axis=None or when a.ndim=2, but I'm getting > confused with

[Numpy-discussion] argmin & min on ndarrays

2008-03-04 Thread Pierre GM
All, Let a & b be two ndarrays of the same shape. I'm trying to find the elements of b that correspond to the minima of a along an arbitrary axis. The problem is trivial when axis=None or when a.ndim=2, but I'm getting confused with higher dimensions: I came to the following solution that looks

Re: [Numpy-discussion] numpy.correlate with phase offset 1D data series

2008-03-04 Thread Ray Schumacher
At 03:28 PM 3/3/2008, Ann wrote: > >Sounds familiar. If you have a good signal-to-noise ratio, you can get > >subpixel accuracy by oversampling the irfft, or better but slower, by > >using numerical optimization to refine the peak you found with argmax. the S/N here is poor, and high data rates wo

Re: [Numpy-discussion] numpy.correlate with phase offset 1D data series

2008-03-04 Thread Ray Schumacher
Thank you for the input! It sounds like Fourier methods will be fastest, by design, for sample counts of hundreds to thousands. I currently do steps like: Im1 = get_stream_array_data() Im2 = load_template_array_data(fh2) ##note: len(im1)==len(im2) Ffft_im1=fftpack.rfft(Im1) Ffft_im2=fftpack.rfft(

Re: [Numpy-discussion] numpy and roundoff(?)

2008-03-04 Thread Christopher Barker
Lisandro Dalcin wrote: > And yes, in > my case the cummulative differences leaded to different iteration > counts in a matrix-free Newton-Krylov method. Of course, the final > answer was as as accurate as the tolerances for the nonlinear solver. OK, so significant differences in iteration counts,

Re: [Numpy-discussion] numpy and roundoff(?)

2008-03-04 Thread Lisandro Dalcin
Damian Eads wrote: > One used -mfpmath=sse, and the other, -mfpmath=387. > Keeping them both > the same cleared the discrepancy. Oh yes! I think you got it... On 3/3/08, Christopher Barker <[EMAIL PROTECTED]> wrote: > > Was it really a "significant" difference, or just noticeable? I hope > not,

Re: [Numpy-discussion] preparing to tag NumPy 1.0.5 on Wednesday

2008-03-04 Thread Alan G Isaac
> Alan G Isaac wrote: >> I never got a response to this: >> http://projects.scipy.org/pipermail/scipy-dev/2008-February/008424.html> >> >> (Two different types claim to be numpy.int32.) On Mon, 03 Mar 2008, "Travis E. Oliphant" apparently wrote: > It's not a bug :-) There are two c-level types

Re: [Numpy-discussion] Question about mrecarray

2008-03-04 Thread Pierre GM
Jeff, > Is there a better way to tell if the individual fields are masked than > accessing ._fieldmask? That depends. If you need to access you mrecarray record by record (by rows), yes you have to check the corresponding ._fieldmask. If instead you can process your array field by field (by col

[Numpy-discussion] Question about mrecarray

2008-03-04 Thread Jeff Garrett
Hi, I'm using an mrecarray in a situation where I need to replace the masked values with default values which are not necessarily the same as the fill value... Something like: for field, mask in zip(row, row._fieldmask): value = field if not mask else ... ... Is there a better way to t

Re: [Numpy-discussion] numpy, "H", and struct: numpy bug?

2008-03-04 Thread Emanuele Olivetti
Just tried on a 32bit workstation (both CPU and OS): I get an error, as before, using python2.5: --- a.py:5: DeprecationWarning: struct integer overflow masking is deprecated b=struct.pack("<10H",*a) Traceback (most recent call last): File "a.py", line 5, in b=struct.pack("<10H",*a) File

[Numpy-discussion] numpy, "H", and struct: numpy bug?

2008-03-04 Thread Emanuele Olivetti
Hi, this snippet is causing troubles: --- import struct import numpy a=numpy.arange(10).astype('H') b=struct.pack("<10H",*a) --- (The module struct simply packs and unpacks data in byte-blobs). It works OK with python2.4, but gives problems with python2.5. On my laptop (linux x86_64 on intel cor