Thanks! Tried it and it is about twice as fast as my approach.
-Ning
On Wed, Jun 3, 2009 at 7:45 PM, wrote:
> On Wed, Jun 3, 2009 at 8:29 PM, Ning Sean 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,
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
___
On Wed, Jun 3, 2009 at 8:29 PM, Ning Sean 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 (maybe because
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
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:
c=append(c,a[
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
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.]
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)
>>
>>
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
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
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
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','
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
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
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
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
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
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
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
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
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
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
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
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.
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 wh
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',
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:/
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
>>> 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,
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
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:
h
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
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 = {
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'],
> 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
35 matches
Mail list logo