Re: [Numpy-discussion] Broadcasting question

2008-05-01 Thread Anne Archibald
2008/5/2 Chris.Barker <[EMAIL PROTECTED]>: > Hi all, > > I have a n X m X 3 array, and I a n X M array. I want to assign the > values in the n X m to all three of the slices in the bigger array: > > A1 = np.zeros((5,4,3)) > A2 = np.ones((5,4)) > A1[:,:,0] = A2 > A1[:,:,1] = A2 > A1[:,:,2] =

Re: [Numpy-discussion] Broadcasting question

2008-05-01 Thread Charles R Harris
On Thu, May 1, 2008 at 10:58 PM, Chris.Barker <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a n X m X 3 array, and I a n X M array. I want to assign the > values in the n X m to all three of the slices in the bigger array: > > A1 = np.zeros((5,4,3)) > A2 = np.ones((5,4)) > A1[:,:,0] = A2 > A1[:,

[Numpy-discussion] Broadcasting question

2008-05-01 Thread Chris.Barker
Hi all, I have a n X m X 3 array, and I a n X M array. I want to assign the values in the n X m to all three of the slices in the bigger array: A1 = np.zeros((5,4,3)) A2 = np.ones((5,4)) A1[:,:,0] = A2 A1[:,:,1] = A2 A1[:,:,2] = A2 However,it seems I should be able to broadcast that, so I don't

Re: [Numpy-discussion] types as functions convert 1 elm arrays to scalars

2008-05-01 Thread Hoyt Koepke
Okay, thanks! I didn't check. --Hoyt On Thu, May 1, 2008 at 7:00 PM, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > On Thu, May 1, 2008 at 7:49 PM, Hoyt Koepke <[EMAIL PROTECTED]> wrote: > > To be honest, this doesn't seem justifiable. > > > > Where it got me is interfacing with c-code that

Re: [Numpy-discussion] types as functions convert 1 elm arrays to scalars

2008-05-01 Thread Charles R Harris
On Thu, May 1, 2008 at 7:49 PM, Hoyt Koepke <[EMAIL PROTECTED]> wrote: > To be honest, this doesn't seem justifiable. > > Where it got me is interfacing with c-code that expected a 1d array, > and I was calling it with arrays of varying length. I was using this > to ensure the proper typing; howe

Re: [Numpy-discussion] types as functions convert 1 elm arrays to scalars

2008-05-01 Thread Hoyt Koepke
To be honest, this doesn't seem justifiable. Where it got me is interfacing with c-code that expected a 1d array, and I was calling it with arrays of varying length. I was using this to ensure the proper typing; however, when the array was length 1, the program crashed... Should I file a bug rep

Re: [Numpy-discussion] recarray fun

2008-05-01 Thread Stéfan van der Walt
2008/5/1 Travis E. Oliphant <[EMAIL PROTECTED]>: > Stéfan van der Walt wrote: > > > > 2008/5/1 Travis E. Oliphant <[EMAIL PROTECTED]>: > > > >> > OK, I see your point. I'm working on a patch that does the following: > >> > > >> > def view(type_or_dtype=None, dtype=None, type=None): > >> >

Re: [Numpy-discussion] recarray fun

2008-05-01 Thread Travis E. Oliphant
Stéfan van der Walt wrote: > 2008/5/1 Travis E. Oliphant <[EMAIL PROTECTED]>: > >> > OK, I see your point. I'm working on a patch that does the following: >> > >> > def view(type_or_dtype=None, dtype=None, type=None): >> > if type_or_dtype: >> > if dtype: >> > ra

Re: [Numpy-discussion] recarray fun

2008-05-01 Thread Alan G Isaac
On Thu, 01 May 2008, Christopher Barker apparently wrote: > Maybe we should have a Wiki page for "stuff we'd like to change, but > won't until major API breakage is otherwise occurring" Perhaps http://www.scipy.org/ProposedEnhancements> would suffice? Cheers, Alan _

Re: [Numpy-discussion] recarray fun

2008-05-01 Thread Travis E. Oliphant
> Please review http://projects.scipy.org/scipy/numpy/changeset/5117. > Stefan, I don't think we really need the dtype_or_type keyword.It seems that we could just check the first argument (dtype) to see if it is a subtype of the ndarray and assume that it is type= in that case. -Travi

Re: [Numpy-discussion] very simple iteration question.

2008-05-01 Thread Alexander Michael
On Wed, Apr 30, 2008 at 3:09 PM, Gael Varoquaux <[EMAIL PROTECTED]> wrote: > On Wed, Apr 30, 2008 at 11:57:44AM -0700, Christopher Barker wrote: > > I think I still like the idea of an iterator (or maybe making rollaxis a > > method?), but this works pretty well. > > Generally, in object oriente

Re: [Numpy-discussion] recarray fun

2008-05-01 Thread Stéfan van der Walt
2008/5/1 Travis E. Oliphant <[EMAIL PROTECTED]>: > > OK, I see your point. I'm working on a patch that does the following: > > > > def view(type_or_dtype=None, dtype=None, type=None): > > if type_or_dtype: > > if dtype: > > raise ValueError("Cannot specify dtype twi

Re: [Numpy-discussion] recarray fun

2008-05-01 Thread Christopher Barker
Travis E. Oliphant wrote: >> def view(type_or_dtype=None, dtype=None, type=None): > Yes, I think that would work. Is there a way to deprecate this for future API-incompatible versions? It's better than non keywords, but a bit ugly. Maybe we should have a Wiki page for "stuff we'd like to chang

Re: [Numpy-discussion] recarray fun

2008-05-01 Thread Travis E. Oliphant
Stéfan van der Walt wrote: > 2008/5/1 Travis E. Oliphant <[EMAIL PROTECTED]>: > >> Stéfan van der Walt wrote: >> > 2008/4/30 Christopher Barker <[EMAIL PROTECTED]>: >> > >> >> Stéfan van der Walt wrote: >> >> > That's the way, or just rgba_image.view(numpy.int32). >> >> >> >> ah -- inter

Re: [Numpy-discussion] recarray fun

2008-05-01 Thread Stéfan van der Walt
2008/5/1 Travis E. Oliphant <[EMAIL PROTECTED]>: > Stéfan van der Walt wrote: > > 2008/4/30 Christopher Barker <[EMAIL PROTECTED]>: > > > >> Stéfan van der Walt wrote: > >> > That's the way, or just rgba_image.view(numpy.int32). > >> > >> ah -- interestingly, I tried: > >> > >> rgba_imag