Re: [Numpy-discussion] Use-case for np.choose

2009-11-09 Thread josef . pktd
On Mon, Nov 9, 2009 at 7:59 PM, wrote: > On Mon, Nov 9, 2009 at 7:54 PM, David Goldsmith > wrote: >> May I infer from the sudden silence that I finally have it? > > I think so, > I assume that the result of broadcasting is unique, I haven't seen an > example yet where broadcasting would depend

Re: [Numpy-discussion] Use-case for np.choose

2009-11-09 Thread josef . pktd
On Mon, Nov 9, 2009 at 7:54 PM, David Goldsmith wrote: > May I infer from the sudden silence that I finally have it? I think so, I assume that the result of broadcasting is unique, I haven't seen an example yet where broadcasting would depend on the sequence in which it is done. Josef > > DG >

Re: [Numpy-discussion] Use-case for np.choose

2009-11-09 Thread David Goldsmith
May I infer from the sudden silence that I finally have it? DG On Sun, Nov 8, 2009 at 8:50 PM, David Goldsmith wrote: > OK, let me see if I'm interpreting this example correctly: > > >>> c1=np.arange(2).reshape(2,1,1); c1 > array([[[0]], > >[[1]]]) > >>> c2=2+np.arange(2).reshape(1,1,2);

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread David Goldsmith
OK, let me see if I'm interpreting this example correctly: >>> c1=np.arange(2).reshape(2,1,1); c1 array([[[0]], [[1]]]) >>> c2=2+np.arange(2).reshape(1,1,2); c2 array([[[2, 3]]]) >>> a=np.eye(2,dtype=int) >>> np.choose(a, [c1, c2]) array([[[2, 0], [0, 3]], [[2, 1],

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread Anne Archibald
2009/11/8 David Goldsmith : > On Sun, Nov 8, 2009 at 7:40 PM, Anne Archibald > wrote: >> >> As Josef said, this is not correct. I think the key point of confusion is >> this: >> >> Do not pass choose two arrays. >> >> Pass it one array and a *list* of arrays. The fact that choices can be >> an arr

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread josef . pktd
On Sun, Nov 8, 2009 at 10:57 PM, David Goldsmith wrote: > On Sun, Nov 8, 2009 at 7:23 PM, wrote: >> >> On Sun, Nov 8, 2009 at 10:03 PM, David Goldsmith >> wrote: >> > OK, now I'm trying to wrap my brain around broadcasting in choose when >> > both >> > `a` *and* `choices` need to be (non-trivial

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread David Goldsmith
On Sun, Nov 8, 2009 at 8:08 PM, David Goldsmith wrote: > On Sun, Nov 8, 2009 at 7:40 PM, Anne Archibald > wrote: > >> As Josef said, this is not correct. I think the key point of confusion is >> this: >> >> Do not pass choose two arrays. >> >> Pass it one array and a *list* of arrays. The fact th

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread David Goldsmith
On Sun, Nov 8, 2009 at 7:40 PM, Anne Archibald wrote: > As Josef said, this is not correct. I think the key point of confusion is > this: > > Do not pass choose two arrays. > > Pass it one array and a *list* of arrays. The fact that choices can be > an array is a quirk we can't change, but you sho

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread David Goldsmith
On Sun, Nov 8, 2009 at 7:23 PM, wrote: > On Sun, Nov 8, 2009 at 10:03 PM, David Goldsmith > wrote: > > OK, now I'm trying to wrap my brain around broadcasting in choose when > both > > `a` *and* `choices` need to be (non-trivially) broadcast in order to > arrive > > at a common shape, e.g.: > >

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread josef . pktd
On Sun, Nov 8, 2009 at 10:40 PM, Anne Archibald wrote: > As Josef said, this is not correct. I think the key point of confusion is > this: > > Do not pass choose two arrays. > > Pass it one array and a *list* of arrays. The fact that choices can be > an array is a quirk we can't change, but you s

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread Anne Archibald
As Josef said, this is not correct. I think the key point of confusion is this: Do not pass choose two arrays. Pass it one array and a *list* of arrays. The fact that choices can be an array is a quirk we can't change, but you should think of the second argument as a list of arrays, possibly of d

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread josef . pktd
On Sun, Nov 8, 2009 at 10:03 PM, David Goldsmith wrote: > OK, now I'm trying to wrap my brain around broadcasting in choose when both > `a` *and* `choices` need to be (non-trivially) broadcast in order to arrive > at a common shape, e.g.: > c=np.arange(4).reshape((2,1,2)) # shape is (2,1,2) >

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread David Goldsmith
OK, now I'm trying to wrap my brain around broadcasting in choose when both `a` *and* `choices` need to be (non-trivially) broadcast in order to arrive at a common shape, e.g.: >>> c=np.arange(4).reshape((2,1,2)) # shape is (2,1,2) >>> a=np.eye(2, dtype=int) # shape is (2,2) >>> np.choose(a,c) arr

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread josef . pktd
On Sun, Nov 8, 2009 at 5:00 AM, David Goldsmith wrote: > On Sun, Nov 8, 2009 at 12:57 AM, Anne Archibald > wrote: >> >> 2009/11/8 David Goldsmith : >> > On Sat, Nov 7, 2009 at 11:59 PM, Anne Archibald >> > >> > wrote: >> >> >> >> 2009/11/7 David Goldsmith : >> >> > So in essence, at least as it

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread David Goldsmith
On Sun, Nov 8, 2009 at 12:57 AM, Anne Archibald wrote: > 2009/11/8 David Goldsmith : > > On Sat, Nov 7, 2009 at 11:59 PM, Anne Archibald < > peridot.face...@gmail.com> > > wrote: > >> > >> 2009/11/7 David Goldsmith : > >> > So in essence, at least as it presently functions, the shape of 'a' > >> >

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread Anne Archibald
2009/11/8 David Goldsmith : > On Sat, Nov 7, 2009 at 11:59 PM, Anne Archibald > wrote: >> >> 2009/11/7 David Goldsmith : >> > So in essence, at least as it presently functions, the shape of 'a' >> > *defines* what the individual choices are within 'choices`, and if >> > 'choices' >> > can't be par

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread David Goldsmith
On Sat, Nov 7, 2009 at 11:59 PM, Anne Archibald wrote: > 2009/11/7 David Goldsmith : > > So in essence, at least as it presently functions, the shape of 'a' > > *defines* what the individual choices are within 'choices`, and if > 'choices' > > can't be parsed into an integer number of such individ

Re: [Numpy-discussion] Use-case for np.choose

2009-11-08 Thread Anne Archibald
2009/11/8 : > On Sat, Nov 7, 2009 at 7:53 PM, David Goldsmith > wrote: >> Thanks, Anne. >> >> On Sat, Nov 7, 2009 at 1:32 PM, Anne Archibald >> wrote: >>> >>> 2009/11/7 David Goldsmith : >> >> >> >>> >>> > Also, my experimenting suggests that the index array ('a', the first >>> > argument in t

Re: [Numpy-discussion] Use-case for np.choose

2009-11-07 Thread Anne Archibald
2009/11/7 David Goldsmith : > Thanks, Anne. > > On Sat, Nov 7, 2009 at 1:32 PM, Anne Archibald > wrote: >> >> 2009/11/7 David Goldsmith : > > > >> >> > Also, my experimenting suggests that the index array ('a', the first >> > argument in the func. sig.) *must* have shape (choices.shape[-1],) - >>

Re: [Numpy-discussion] Use-case for np.choose

2009-11-07 Thread josef . pktd
On Sat, Nov 7, 2009 at 7:53 PM, David Goldsmith wrote: > Thanks, Anne. > > On Sat, Nov 7, 2009 at 1:32 PM, Anne Archibald > wrote: >> >> 2009/11/7 David Goldsmith : > > > >> >> > Also, my experimenting suggests that the index array ('a', the first >> > argument in the func. sig.) *must* have sha

Re: [Numpy-discussion] Use-case for np.choose

2009-11-07 Thread David Goldsmith
Thanks, Anne. On Sat, Nov 7, 2009 at 1:32 PM, Anne Archibald wrote: > 2009/11/7 David Goldsmith : > > Also, my experimenting suggests that the index array ('a', the first > > argument in the func. sig.) *must* have shape (choices.shape[-1],) - > someone > > please let me know ASAP if this is

Re: [Numpy-discussion] Use-case for np.choose

2009-11-07 Thread Anne Archibald
2009/11/7 David Goldsmith : > Hi, all!  I'm working to clarify the docstring for np.choose (Stefan pointed > out to me that it is pretty unclear, and I agreed), and, now that (I'm > pretty sure that) I've figured out what it does in its full generality > (e.g., when the 'choices' array is greater t

[Numpy-discussion] Use-case for np.choose

2009-11-07 Thread David Goldsmith
Hi, all! I'm working to clarify the docstring for np.choose (Stefan pointed out to me that it is pretty unclear, and I agreed), and, now that (I'm pretty sure that) I've figured out what it does in its full generality (e.g., when the 'choices' array is greater than 2-D), I'm curious as to use-case