Re: [Numpy-discussion] setting element

2008-11-12 Thread Charles سمير Doutriaux
Nope this one wouldn't have worked for me, it's basically axis=-1 but there might be additional dimensions after index C. On Nov 12, 2008, at 10:43 AM, Roberto De Almeida wrote: On Wed, Nov 12, 2008 at 4:36 PM, Gabriel Gellner <[EMAIL PROTECTED]> wrote: On Wed, Nov 12, 2008 at 12:34:51PM -060

Re: [Numpy-discussion] setting element

2008-11-12 Thread Ryan May
Charles سمير Doutriaux wrote: > Hello, > > I'm wondering if there's aquick way to do the following: > > s[:,5]=value > > in a "general" function > def setval(array,index,value,axis=0): > ## code here Assuming that axis specifies where the index goes, that would be: def setval(array, inde

Re: [Numpy-discussion] setting element

2008-11-12 Thread Roberto De Almeida
On Wed, Nov 12, 2008 at 4:36 PM, Gabriel Gellner <[EMAIL PROTECTED]>wrote: > On Wed, Nov 12, 2008 at 12:34:51PM -0600, Ryan May wrote: > > Charles سمير Doutriaux wrote: > > > Hello, > > > > > > I'm wondering if there's aquick way to do the following: > > > > > > s[:,5]=value > > > > > > in a "gene

Re: [Numpy-discussion] setting element

2008-11-12 Thread Charles سمير Doutriaux
Thx! On Nov 12, 2008, at 10:36 AM, Gabriel Gellner wrote: > On Wed, Nov 12, 2008 at 12:34:51PM -0600, Ryan May wrote: >> Charles سمير Doutriaux wrote: >>> Hello, >>> >>> I'm wondering if there's aquick way to do the following: >>> >>> s[:,5]=value >>> >>> in a "general" function >>> def setval(arr

Re: [Numpy-discussion] setting element

2008-11-12 Thread Gabriel Gellner
On Wed, Nov 12, 2008 at 12:34:51PM -0600, Ryan May wrote: > Charles سمير Doutriaux wrote: > > Hello, > > > > I'm wondering if there's aquick way to do the following: > > > > s[:,5]=value > > > > in a "general" function > > def setval(array,index,value,axis=0): > > ## code here > > Assuming

Re: [Numpy-discussion] setting element

2008-11-12 Thread Gabriel Gellner
On Wed, Nov 12, 2008 at 09:43:34AM -0800, Charles سمير Doutriaux wrote: > Hello, > > I'm wondering if there's aquick way to do the following: > > s[:,5]=value > > in a "general" function > def setval(array,index,value,axis=0): > ## code here > > The issue is to put enough ":" before the i

[Numpy-discussion] setting element

2008-11-12 Thread Charles سمير Doutriaux
Hello, I'm wondering if there's aquick way to do the following: s[:,5]=value in a "general" function def setval(array,index,value,axis=0): ## code here The issue is to put enough ":" before the index value inside the square bracket of the assignement. Thanks, C. ___

Re: [Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Pierre GM
On Monday 25 June 2007 10:14:21 Jesper Larsen wrote: > Hi Pierre and others, > I was not aware that the way to use masked arrays was as you describe. I > thought you had to somehow modify the mask (but the method you describe is > of course much more elegant). Thanks for answering my very basic qu

Re: [Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Jesper Larsen
Hi Pierre and others, On Monday 25 June 2007 15:37, Pierre GM wrote: > On Monday 25 June 2007 05:12:01 Jesper Larsen wrote: > > myarray.mask[i] = True > > Mmh. Experience shows that directly accessing the mask can lead to bad > surprises. To mask a series of values in an array, the easiest (and >

Re: [Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Pierre GM
On Monday 25 June 2007 05:12:01 Jesper Larsen wrote: > Hi numpy users, > > I have a masked array. I am looping over the elements of this array and > sometimes want to set a value to missing. Normally this can be done by: > > myarray.mask[i] = True Mmh. Experience shows that directly accessing the

[Numpy-discussion] Setting element to masked in a masked array previously containing no masked values

2007-06-25 Thread Jesper Larsen
Hi numpy users, I have a masked array. I am looping over the elements of this array and sometimes want to set a value to missing. Normally this can be done by: myarray.mask[i] = True However the mask attribute is not indexable when there are no existing missing values in the array (it is simpl