Re: [Numpy-discussion] field names on numpy arrays

2009-06-07 Thread Fernando Perez
On Thu, Jun 4, 2009 at 12:28 PM, Pierre GM wrote: > I foresee serious disturbance in the force... > When I use structured arrays, each field usually represents a > different variable, and I may not be keen on having a same operation > applied to all variables. At least, the current behavior (raise

Re: [Numpy-discussion] field names on numpy arrays

2009-06-04 Thread Pierre GM
On Jun 4, 2009, at 3:12 PM, Fernando Perez wrote: > Howdy, > I was thinking about this yesterday, because I'm dealing with exactly > this same problem in a local project. How hard would it be to allow > structured arrays to support ufuncs/arithmetic for the case where > their dtype is actually

Re: [Numpy-discussion] field names on numpy arrays

2009-06-04 Thread Fernando Perez
Howdy, 2009/6/3 Stéfan van der Walt : >> however i seem to lose simple operations such as multiplication (a_array*2) >> or powers (a_array**2). > > As a workaround, you can have two views on your data: I was thinking about this yesterday, because I'm dealing with exactly this same problem in a l

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 8:25 PM, wrote: > On Wed, Jun 3, 2009 at 7:56 PM,   wrote: >> On Wed, Jun 3, 2009 at 7:33 PM, Pierre GM wrote: >>> >>> On Jun 3, 2009, at 7:23 PM, Robert Kern wrote: >>> On Wed, Jun 3, 2009 at 18:20, Pierre GM wrote: > > > Or, as all fields have the same

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 7:56 PM, wrote: > On Wed, Jun 3, 2009 at 7:33 PM, Pierre GM wrote: >> >> On Jun 3, 2009, at 7:23 PM, Robert Kern wrote: >> >>> On Wed, Jun 3, 2009 at 18:20, Pierre GM wrote: Or, as all fields have the same dtype:  >>> a_array.view(dtype=('f',len(a

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 7:33 PM, Pierre GM wrote: > > On Jun 3, 2009, at 7:23 PM, Robert Kern wrote: > >> On Wed, Jun 3, 2009 at 18:20, Pierre GM wrote: >>> >>> >>> Or, as all fields have the same dtype: >>> >>>  >>> a_array.view(dtype=('f',len(a_array.dtype))) >>> array([[ 0.,  1.,  2.,  3.,  4.]

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread Pierre GM
On Jun 3, 2009, at 7:23 PM, Robert Kern wrote: > On Wed, Jun 3, 2009 at 18:20, Pierre GM wrote: >> >> >> Or, as all fields have the same dtype: >> >> >>> a_array.view(dtype=('f',len(a_array.dtype))) >> array([[ 0., 1., 2., 3., 4.], >>[ 1., 2., 3., 4., 5.]], dtype=float32) >> >>

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 18:20, Pierre GM wrote: > > On Jun 3, 2009, at 5:03 PM, Robert Kern wrote: > >> On Wed, Jun 3, 2009 at 15:26,   wrote: >>> 2009/6/3 Stéfan van der Walt : Hi Jon 2009/6/3 D2Hitman : > I understand record arrays such as: > a_array = > np.array([(0.,1

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread Pierre GM
On Jun 3, 2009, at 5:03 PM, Robert Kern wrote: > On Wed, Jun 3, 2009 at 15:26, wrote: >> 2009/6/3 Stéfan van der Walt : >>> Hi Jon >>> >>> 2009/6/3 D2Hitman : I understand record arrays such as: a_array = np.array([(0.,1.,2.,3.,4.),(1.,2.,3.,4.,5.)],dtype=[('a','f'), ('b','

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 15:26, wrote: > 2009/6/3 Stéfan van der Walt : >> Hi Jon >> >> 2009/6/3 D2Hitman : >>> I understand record arrays such as: >>> a_array = >>> np.array([(0.,1.,2.,3.,4.),(1.,2.,3.,4.,5.)],dtype=[('a','f'),('b','f'),('c','f'),('d','f'),('e','f')]) >>> do this with field names.

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread josef . pktd
2009/6/3 Stéfan van der Walt : > Hi Jon > > 2009/6/3 D2Hitman : >> I understand record arrays such as: >> a_array = >> np.array([(0.,1.,2.,3.,4.),(1.,2.,3.,4.,5.)],dtype=[('a','f'),('b','f'),('c','f'),('d','f'),('e','f')]) >> do this with field names. >> a_array['a'] = array([ 0.,  1.], dtype=float

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread Stéfan van der Walt
Hi Jon 2009/6/3 D2Hitman : > I understand record arrays such as: > a_array = > np.array([(0.,1.,2.,3.,4.),(1.,2.,3.,4.,5.)],dtype=[('a','f'),('b','f'),('c','f'),('d','f'),('e','f')]) > do this with field names. > a_array['a'] = array([ 0.,  1.], dtype=float32) > however i seem to lose simple opera

Re: [Numpy-discussion] field names on numpy arrays

2009-06-03 Thread Pierre GM
On Jun 3, 2009, at 11:06 AM, D2Hitman wrote: > > Hi, > > I would like to have an object/class that acts like array of floats > such as: > a_array = numpy.array([[0.,1.,2.,3.,4.],[1.,2.,3.,4.,5.]]) > but i would like to be able to slice this array by some header > dictionary: > header_dict = {

[Numpy-discussion] field names on numpy arrays

2009-06-03 Thread D2Hitman
Hi, I would like to have an object/class that acts like array of floats such as: a_array = numpy.array([[0.,1.,2.,3.,4.],[1.,2.,3.,4.,5.]]) but i would like to be able to slice this array by some header dictionary: header_dict = {'a':0,'b':1,'c':2,'d':3,'e':4} such that i could use a_array['a'],