Re: [Numpy-discussion] Fw: array indices and dictionary

2008-09-21 Thread Arnar Flatberg
On Sun, Sep 21, 2008 at 7:51 PM, Dinesh B Vadhia <[EMAIL PROTECTED]>wrote: > Ooops, I should have said that this is easy to do with 2 for loops ie. > > import numpy > from collections import defaultdict > A = > [[1 6 1 2 3] > [4 5 4 7 0] > [2 0 8 0 2] > [0 0 0 3 7] > [0 7 0 3 5] > [8 0 3 0 6

Re: [Numpy-discussion] array indices and dictionary

2008-09-21 Thread Nathan Bell
On Sun, Sep 21, 2008 at 1:28 PM, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > > But, I want to pick up the column index of non-zero elements per row. > http://www.scipy.org/Numpy_Example_List_With_Doc#nonzero -- Nathan Bell [EMAIL PROTECTED] http://graphics.cs.uiuc.edu/~wnbell/ _

[Numpy-discussion] Fw: array indices and dictionary

2008-09-21 Thread Dinesh B Vadhia
Ooops, I should have said that this is easy to do with 2 for loops ie. import numpy from collections import defaultdict A = [[1 6 1 2 3] [4 5 4 7 0] [2 0 8 0 2] [0 0 0 3 7] [0 7 0 3 5] [8 0 3 0 6] [8 0 0 2 2] [3 1 0 4 0] [5 0 8 0 0] [2 1 0 5 6]] dict = defaultdict(list) I = A.shape[0]

[Numpy-discussion] array indices and dictionary

2008-09-21 Thread Dinesh B Vadhia
Hi! Say, I've got a numpy array/matrix of the form: A = [[1 6 1 2 3] [4 5 4 7 0] [2 0 8 0 2] [0 0 0 3 7] [0 7 0 3 5] [8 0 3 0 6] [8 0 0 2 2] [3 1 0 4 0] [5 0 8 0 0] [2 1 0 5 6]] I want to create a dictionary of row indexes (as the keys) mapped to lists of the column indexes of non-zer

Re: [Numpy-discussion] Medians that ignore values

2008-09-21 Thread David Cournapeau
David Cournapeau wrote: > > The isnan thing is surprising, because the whole point to have a isnan > is that you can do it without branching. I checked, and numpy does use > the macro of isnan, not the function (glibc has both). Ok, see my patch #913 for this. The slowdown is actually specific to

Re: [Numpy-discussion] profiling line by line

2008-09-21 Thread Robert Cimrman
Robert Kern wrote: > On Sun, Sep 21, 2008 at 02:26, Robert Cimrman <[EMAIL PROTECTED]> wrote: >> Cool, then I have another one: >> >> $ ./kernprof.py -l pystone.py >> Traceback (most recent call last): >> File "./kernprof.py", line 173, in ? >> sys.exit(main(sys.argv)) >> File "./kernprof.p

Re: [Numpy-discussion] profiling line by line

2008-09-21 Thread Robert Kern
On Sun, Sep 21, 2008 at 02:26, Robert Cimrman <[EMAIL PROTECTED]> wrote: > Cool, then I have another one: > > $ ./kernprof.py -l pystone.py > Traceback (most recent call last): > File "./kernprof.py", line 173, in ? > sys.exit(main(sys.argv)) > File "./kernprof.py", line 138, in main >

Re: [Numpy-discussion] Medians that ignore values

2008-09-21 Thread Charles R Harris
On Sun, Sep 21, 2008 at 12:56 AM, David Cournapeau < [EMAIL PROTECTED]> wrote: > David Cournapeau wrote: > > Anne Archibald wrote: > >> If users are concerned about performance, it's worth noting that on > >> some machines nans force a fallback to software floating-point > >> handling, with a corr

Re: [Numpy-discussion] profiling line by line

2008-09-21 Thread Robert Cimrman
Robert Kern wrote: > On Sun, Sep 21, 2008 at 02:09, Robert Cimrman <[EMAIL PROTECTED]> wrote: >> Robert Kern wrote: >>> On Fri, Sep 19, 2008 at 07:00, Robert Cimrman <[EMAIL PROTECTED]> wrote: Robert Kern wrote: > Ah, found it. T_LONGLONG is a #define from structmember.h which is > use

Re: [Numpy-discussion] profiling line by line

2008-09-21 Thread Robert Kern
On Sun, Sep 21, 2008 at 02:09, Robert Cimrman <[EMAIL PROTECTED]> wrote: > Robert Kern wrote: >> On Fri, Sep 19, 2008 at 07:00, Robert Cimrman <[EMAIL PROTECTED]> wrote: >>> Robert Kern wrote: Ah, found it. T_LONGLONG is a #define from structmember.h which is used to describe the types of

Re: [Numpy-discussion] Medians that ignore values

2008-09-21 Thread David Cournapeau
David Cournapeau wrote: > Anne Archibald wrote: >> If users are concerned about performance, it's worth noting that on >> some machines nans force a fallback to software floating-point >> handling, with a corresponding very large performance hit. This >> includes some but not all x86 (and I think x

Re: [Numpy-discussion] profiling line by line

2008-09-21 Thread Robert Cimrman
Robert Kern wrote: > On Fri, Sep 19, 2008 at 07:00, Robert Cimrman <[EMAIL PROTECTED]> wrote: >> Robert Kern wrote: >>> Ah, found it. T_LONGLONG is a #define from structmember.h which is >>> used to describe the types of attributes. Apparently, this was not >>> added until Python 2.5. That particul

Re: [Numpy-discussion] Medians that ignore values

2008-09-21 Thread David Cournapeau
Anne Archibald wrote: > > If users are concerned about performance, it's worth noting that on > some machines nans force a fallback to software floating-point > handling, with a corresponding very large performance hit. This > includes some but not all x86 (and I think x86-64) CPUs. How this > comp