Re: [Numpy-discussion] Problem with correlate

2009-06-03 Thread rob steed
I wonder if xcorrelate would be a better name than acorrelate? I think it would. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[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'],

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 =

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

2009-06-03 Thread Stéfan van der Walt
Hi Jon 2009/6/3 D2Hitman j.m.gir...@warwick.ac.uk: 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

[Numpy-discussion] setmember1d_nu

2009-06-03 Thread Neil Crighton
Hi all, I posted this message couple of days ago, but gmane grouped it with an old thread and it hasn't shown up on the front page. So here it is again... I'd really like to see the setmember1d_nu function in ticket 1036 get into numpy. There's a patch waiting for review that including tests:

[Numpy-discussion] [RFR] NpzFile tweaks (Re: Making NpzFiles behave more like dictionaries.)

2009-06-03 Thread David Warde-Farley
On 2-Jun-09, at 3:06 PM, Pauli Virtanen wrote: +0 I don't see any drawbacks, and the implementation looks good. Thanks Pauli. I realized I was missing values() and itervalues() (though I can't conceive of a scenario where I'd use them myself, I guess some code might expect them). Also I

[Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
import numpy as np x = np.array([(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)], dtype=[('a', 'f4'), ('b', 'f4'), ('c', 'f4'), ('d', 'f4'), ('e', 'f4')]) xvm = x.view(np.matrix) xvm matrix([[(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)]], dtype=[('a', 'f4'), ('b',

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

2009-06-03 Thread josef . pktd
2009/6/3 Stéfan van der Walt ste...@sun.ac.za: Hi Jon 2009/6/3 D2Hitman j.m.gir...@warwick.ac.uk: 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'] =

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Christopher Barker
josef.p...@gmail.com wrote: import numpy as np x = np.array([(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)], dtype=[('a', 'f4'), ('b', 'f4'), ('c', 'f4'), ('d', 'f4'), ('e', 'f4')]) xvm = x.view(np.matrix) xvm matrix([[(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)]],

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 15:23, josef.p...@gmail.com wrote: import numpy as np x = np.array([(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)],     dtype=[('a', 'f4'), ('b', 'f4'), ('c', 'f4'), ('d', 'f4'), ('e', 'f4')]) xvm = x.view(np.matrix) xvm matrix([[(0.0, 1.0, 2.0, 3.0, 4.0),

Re: [Numpy-discussion] [RFR] NpzFile tweaks (Re: Making NpzFiles behave more like dictionaries.)

2009-06-03 Thread Pauli Virtanen
Wed, 03 Jun 2009 16:05:51 -0400, David Warde-Farley wrote: On 2-Jun-09, at 3:06 PM, Pauli Virtanen wrote: +0 I don't see any drawbacks, and the implementation looks good. Thanks Pauli. I realized I was missing values() and itervalues() (though I can't conceive of a scenario where I'd

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

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 15:26, josef.p...@gmail.com wrote: 2009/6/3 Stéfan van der Walt ste...@sun.ac.za: Hi Jon 2009/6/3 D2Hitman j.m.gir...@warwick.ac.uk: I understand record arrays such as: a_array =

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 4:58 PM, Robert Kern robert.k...@gmail.com wrote: On Wed, Jun 3, 2009 at 15:23,  josef.p...@gmail.com wrote: import numpy as np x = np.array([(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)],     dtype=[('a', 'f4'), ('b', 'f4'), ('c', 'f4'), ('d', 'f4'), ('e',

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 16:06, josef.p...@gmail.com wrote: On Wed, Jun 3, 2009 at 4:58 PM, Robert Kern robert.k...@gmail.com wrote: On Wed, Jun 3, 2009 at 15:23,  josef.p...@gmail.com wrote: import numpy as np x = np.array([(0.0, 1.0, 2.0, 3.0, 4.0), (1.0, 2.0, 3.0, 4.0, 5.0)],    

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Christopher Barker
josef.p...@gmail.com wrote: Ok, I didn't know numpy can have structured matrices, well, matrices are a subclass of nd-arrays, so they support it, but it's probably not the least bit useful. See my earlier post to see how to do what I think you want. You may not want a matrix anyway -- a 2-d

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 5:18 PM, Christopher Barker chris.bar...@noaa.gov wrote: josef.p...@gmail.com wrote: Ok, I didn't know numpy can have structured matrices, well, matrices are a subclass of nd-arrays, so they support it, but it's probably not the least bit useful. See my earlier post

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Christopher Barker
josef.p...@gmail.com wrote: I'm very happy with plain numpy arrays, but to handle different data types in scipy.stats, I'm still trying to figure out how views and structured arrays work. And I'm still confused. OK, I'd stay away from matrix then, no need to add that confusion From the use

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 16:31, josef.p...@gmail.com wrote: On Wed, Jun 3, 2009 at 5:18 PM, Christopher Barker chris.bar...@noaa.gov wrote: josef.p...@gmail.com wrote: Ok, I didn't know numpy can have structured matrices, well, matrices are a subclass of nd-arrays, so they support it, but

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 5:57 PM, Christopher Barker chris.bar...@noaa.gov wrote: josef.p...@gmail.com wrote: I'm very happy with plain numpy arrays, but to handle different data types in scipy.stats, I'm still trying to figure out how views and structured arrays work. And I'm still confused.

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Stéfan van der Walt
2009/6/3 Robert Kern robert.k...@gmail.com: On Wed, Jun 3, 2009 at 16:31,  josef.p...@gmail.com wrote: I'm very happy with plain numpy arrays, but to handle different data types in scipy.stats, I'm still trying to figure out how views and structured arrays work. And I'm still confused.

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 17:53, josef.p...@gmail.com wrote: Is len(z.dtype) 0   the best way to find out whether an array has a structured dtype? (z.dtype.names is not None) is better. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 5:55 PM, Robert Kern robert.k...@gmail.com wrote: On Wed, Jun 3, 2009 at 16:31,  josef.p...@gmail.com wrote: On Wed, Jun 3, 2009 at 5:18 PM, Christopher Barker chris.bar...@noaa.gov wrote: josef.p...@gmail.com wrote: Ok, I didn't know numpy can have structured matrices,

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 17:58, josef.p...@gmail.com wrote: Do you have an opinion about whether  .view(ndarray_subclass) or __array_wrap__ is the more appropriate return wrapper for function such as the ones in stats? __array_wrap__ would be more appropriate. It's what ufuncs use. -- Robert

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, josef.p...@gmail.com wrote: 2009/6/3 Stéfan van der Walt ste...@sun.ac.za: Hi Jon 2009/6/3 D2Hitman j.m.gir...@warwick.ac.uk: I understand record arrays such as: a_array =

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Pierre GM
On Jun 3, 2009, at 7:00 PM, Robert Kern wrote: On Wed, Jun 3, 2009 at 17:58, josef.p...@gmail.com wrote: Do you have an opinion about whether .view(ndarray_subclass) or __array_wrap__ is the more appropriate return wrapper for function such as the ones in stats? __array_wrap__ would be

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

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 18:20, Pierre GM pgmdevl...@gmail.com wrote: On Jun 3, 2009, at 5:03 PM, Robert Kern wrote: On Wed, Jun 3, 2009 at 15:26,  josef.p...@gmail.com wrote: 2009/6/3 Stéfan van der Walt ste...@sun.ac.za: Hi Jon 2009/6/3 D2Hitman j.m.gir...@warwick.ac.uk: I understand

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 7:21 PM, Pierre GM pgmdevl...@gmail.com wrote: On Jun 3, 2009, at 7:00 PM, Robert Kern wrote: On Wed, Jun 3, 2009 at 17:58,  josef.p...@gmail.com wrote: Do you have an opinion about whether  .view(ndarray_subclass) or __array_wrap__ is the more appropriate return

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 pgmdevl...@gmail.com 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 josef . pktd
On Wed, Jun 3, 2009 at 7:33 PM, Pierre GM pgmdevl...@gmail.com wrote: On Jun 3, 2009, at 7:23 PM, Robert Kern wrote: On Wed, Jun 3, 2009 at 18:20, Pierre GM pgmdevl...@gmail.com wrote: Or, as all fields have the same dtype:   a_array.view(dtype=('f',len(a_array.dtype))) array([[ 0.,  1.,

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

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 7:56 PM, josef.p...@gmail.com wrote: On Wed, Jun 3, 2009 at 7:33 PM, Pierre GM pgmdevl...@gmail.com wrote: On Jun 3, 2009, at 7:23 PM, Robert Kern wrote: On Wed, Jun 3, 2009 at 18:20, Pierre GM pgmdevl...@gmail.com wrote: Or, as all fields have the same dtype:  

[Numpy-discussion] extract elements of an array that are contained in another array?

2009-06-03 Thread Ning Sean
Hi, I want to extract elements of an array (say, a) that are contained in another array (say, b). That is, if a=array([1,1,2,3,3,4]), b=array([1,4]), then I want array([1,1,4]). I did the following but the speed is very slow (maybe because a is very long): c=array([]) for x in b:

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

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 8:25 PM, josef.p...@gmail.com wrote: On Wed, Jun 3, 2009 at 7:56 PM,  josef.p...@gmail.com wrote: On Wed, Jun 3, 2009 at 7:33 PM, Pierre GM pgmdevl...@gmail.com wrote: On Jun 3, 2009, at 7:23 PM, Robert Kern wrote: On Wed, Jun 3, 2009 at 18:20, Pierre GM

Re: [Numpy-discussion] extract elements of an array that are contained in another array?

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 8:29 PM, Ning Sean nings...@gmail.com wrote: Hi, I want to extract elements of an array (say, a) that are contained in another array (say, b). That is, if a=array([1,1,2,3,3,4]), b=array([1,4]), then I want array([1,1,4]). I did the following but the speed is very slow

Re: [Numpy-discussion] [RFR] NpzFile tweaks (Re: Making NpzFiles behave more like dictionaries.)

2009-06-03 Thread David Warde-Farley
On 3-Jun-09, at 5:01 PM, Pauli Virtanen wrote: Btw, are you able to change the status of the ticket to needs_review? I think this should be possible for everyone, and not restricted to admins, but I'm not 100% sure... Sorry, yes I am. I had just forgotten. David

Re: [Numpy-discussion] extract elements of an array that are contained in another array?

2009-06-03 Thread Ning Sean
Thanks! Tried it and it is about twice as fast as my approach. -Ning On Wed, Jun 3, 2009 at 7:45 PM, josef.p...@gmail.com wrote: On Wed, Jun 3, 2009 at 8:29 PM, Ning Sean nings...@gmail.com wrote: Hi, I want to extract elements of an array (say, a) that are contained in another array (say,