Re: [Numpy-discussion] slices of structured arrays?

2009-12-09 Thread Ernest Adrogué
9/12/09 @ 00:45 (-0500), thus spake josef.p...@gmail.com: > as long as all numbers are of the same type, you can create a view > that behaves (mostly) like a regular array > [...] Thanks Josef. Great explanation. It's all clear now. Ernest ___ NumPy-Di

Re: [Numpy-discussion] slices of structured arrays?

2009-12-08 Thread josef . pktd
2009/12/8 Ernest Adrogué : > Hello, > > Here's a structured array with fields 'a','b' and 'c': > > s=[(i,int) for i in 'abc'] > t=np.zeros(1,s) > > It has the form: array([(0, 0, 0)] > > I was wondering if such an array can be accessed like an > ordinary array (e.g., with a slice) in order to set m

[Numpy-discussion] slices of structured arrays?

2009-12-08 Thread Ernest Adrogué
Hello, Here's a structured array with fields 'a','b' and 'c': s=[(i,int) for i in 'abc'] t=np.zeros(1,s) It has the form: array([(0, 0, 0)] I was wondering if such an array can be accessed like an ordinary array (e.g., with a slice) in order to set multiple values at once. t[0] does not access

Re: [Numpy-discussion] Slices of structured arrays

2009-06-01 Thread Robert Ferrell
On Jun 1, 2009, at 4:41 PM, Robert Kern wrote: > On Mon, Jun 1, 2009 at 17:32, Robert Ferrell > wrote: >> Is there a way to get slices of a structured array and keep the field >> names? For instance, I've got dtype=[('x','f4'),('y','f4'), >> ('z','f4')] and I want to get just the x & y slices

Re: [Numpy-discussion] Slices of structured arrays

2009-06-01 Thread Robert Kern
On Mon, Jun 1, 2009 at 17:32, Robert Ferrell wrote: > Is there a way to get slices of a structured array and keep the field > names?  For instance, I've got dtype=[('x','f4'),('y','f4'), > ('z','f4')] and I want to get just the x & y slices into a new array > with dtype=[('x','f4'),('y','f4')]. >

[Numpy-discussion] Slices of structured arrays

2009-06-01 Thread Robert Ferrell
Is there a way to get slices of a structured array and keep the field names? For instance, I've got dtype=[('x','f4'),('y','f4'), ('z','f4')] and I want to get just the x & y slices into a new array with dtype=[('x','f4'),('y','f4')]. I can just make a new dtype, and extract what I need, but