Re: [Numpy-discussion] problem with assigning to recarrays

2009-03-02 Thread Robert Kern
On Mon, Mar 2, 2009 at 19:20, Brian Gerke wrote: > > Many thanks for your willingness to help out with this.  Not to > belabor the point, but I notice that the rules you lay out below don't > quite explain why the following syntax works as I originally expected: > > r[0].field1 = 1 > > I'm guessin

Re: [Numpy-discussion] problem with assigning to recarrays

2009-03-02 Thread Brian Gerke
Many thanks for your willingness to help out with this. Not to belabor the point, but I notice that the rules you lay out below don't quite explain why the following syntax works as I originally expected: r[0].field1 = 1 I'm guessing this is because r[0].field1 is already an existing scalar

Re: [Numpy-discussion] problem with assigning to recarrays

2009-02-27 Thread Robert Kern
On Fri, Feb 27, 2009 at 19:06, Brian Gerke wrote: > > On Feb 27, 2009, at 4:30 PM, Robert Kern wrote: >>> >> r[where(r.field1 == 1.)] make a copy. There is no way for us to >> construct a view onto the original memory for this circumstance given >> numpy's memory model. > > Many thanks for the qui

Re: [Numpy-discussion] problem with assigning to recarrays

2009-02-27 Thread Brian Gerke
On Feb 27, 2009, at 4:30 PM, Robert Kern wrote: >> > r[where(r.field1 == 1.)] make a copy. There is no way for us to > construct a view onto the original memory for this circumstance given > numpy's memory model. Many thanks for the quick reply. I assume that this is true only for record array

Re: [Numpy-discussion] problem with assigning to recarrays

2009-02-27 Thread Pierre GM
As a follow-up to Robert's answer: >>> r[r.field1 == 1].field2 = 1 doesn't work, but >>>r.field2[r.field1==1] = 1 does. > So far, so good. > Now I want to change the value of field2 for those same elements: > > In [128]: r[where(r.field1 == 1.)].field2 = 1 > > Ok, so now the value

Re: [Numpy-discussion] problem with assigning to recarrays

2009-02-27 Thread Robert Kern
On Fri, Feb 27, 2009 at 18:26, Brian Gerke wrote: > > Hi- > > I'm quite new to numpy and to python in general, so I apologize if I'm > missing something obvious, but I've come across some seemingly nasty > behavior when trying to assign values to the fields of an indexed > subarray of a numpy reco

[Numpy-discussion] problem with assigning to recarrays

2009-02-27 Thread Brian Gerke
Hi- I'm quite new to numpy and to python in general, so I apologize if I'm missing something obvious, but I've come across some seemingly nasty behavior when trying to assign values to the fields of an indexed subarray of a numpy record array. Perhaps an example would explain it best.