Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 7:21 PM, Pierre GM wrote: > > On Jun 3, 2009, at 7:00 PM, Robert Kern wrote: > >> On Wed, Jun 3, 2009 at 17:58,   wrote: >>> Do you have an opinion about whether  .view(ndarray_subclass) or >>> __array_wrap__ is the more appropriate return wrapper for function >>> such as th

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, 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 appropri

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 17:58, 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 Kern "I have come

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 5:55 PM, Robert Kern wrote: > On Wed, Jun 3, 2009 at 16:31,   wrote: >> On Wed, Jun 3, 2009 at 5:18 PM, Christopher Barker >> wrote: >>> josef.p...@gmail.com wrote: Ok, I didn't know numpy can have structured matrices, >>> >>> well, matrices are a subclass of nd-arrays

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 17:53, 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 terrible by our own

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Stéfan van der Walt
2009/6/3 Robert Kern : > On Wed, Jun 3, 2009 at 16:31,   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. > > .view() is used two different ways, an

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 5:57 PM, Christopher Barker 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. > > OK, I'd stay

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 16:31, wrote: > On Wed, Jun 3, 2009 at 5:18 PM, Christopher Barker > 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

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 us

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 5:18 PM, Christopher Barker 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 to see how to d

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 a

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 16:06, wrote: > On Wed, Jun 3, 2009 at 4:58 PM, Robert Kern wrote: >> On Wed, Jun 3, 2009 at 15:23,   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', '>> ('e', '>> >> xvm = x.view(np.matr

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread josef . pktd
On Wed, Jun 3, 2009 at 4:58 PM, Robert Kern wrote: > On Wed, Jun 3, 2009 at 15:23,   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', '> ('e', '> > xvm = x.view(np.matrix) > xvm >> matrix([[(0.0, 1.0, 2.0, 3.0, 4

Re: [Numpy-discussion] another view puzzle

2009-06-03 Thread Robert Kern
On Wed, Jun 3, 2009 at 15:23, 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', ' ('e', ' 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', ' ('e',

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', ' ('e', ' 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', ' ('e', 'http:/

[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', '>> 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', '>> xvm*2 matrix([[(0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0,