Re: A question about numpy

2015-04-14 Thread Paulo da Silva
On 14-04-2015 23:49, Rob Gaddi wrote: > On Tue, 14 Apr 2015 23:41:56 +0100, Paulo da Silva wrote: > >> Supposing I have 2 vectors v1 and v2 and a value (constant) k. >> I want to build a vector r with all values of v1 greater than k and the >> others from v2. >> > > You're looking for numpy.where

Re: A question about numpy

2015-04-14 Thread Rob Gaddi
On Tue, 14 Apr 2015 23:41:56 +0100, Paulo da Silva wrote: > Supposing I have 2 vectors v1 and v2 and a value (constant) k. > I want to build a vector r with all values of v1 greater than k and the > others from v2. > You're looking for numpy.where() . -- Rob Gaddi, Highland Technology -- www.h

A question about numpy

2015-04-14 Thread Paulo da Silva
I am new to numpy ... Supposing I have 2 vectors v1 and v2 and a value (constant) k. I want to build a vector r with all values of v1 greater than k and the others from v2. I found 2 ways, but not sure if they are the best solution: 1. r1=v1.copy() r2=v2.copy() r1[r1=k]=0 r=r1+r2 2. r=v1*(v1>=k

Re: a question about numpy

2009-09-10 Thread Robert Kern
On 2009-09-09 20:46 PM, rechard wrote: Robert Kern wrote: On 2009-09-08 20:45 PM, hi_roger wrote: hello, i want to ask a question about numpy. i know how to select a submatrix using the slice object in numpy. But how can i select a submatrix A[i1,i2,i3;j1,j2,j3] (elements in A on line i1,i2

Re: a question about numpy

2009-09-09 Thread rechard
Robert Kern wrote: On 2009-09-08 20:45 PM, hi_roger wrote: hello, i want to ask a question about numpy. i know how to select a submatrix using the slice object in numpy. But how can i select a submatrix A[i1,i2,i3;j1,j2,j3] (elements in A on line i1,i2,i3 and column j1,j2,j3 , and i1,i2,i3,j1

Re: a question about numpy

2009-09-09 Thread Robert Kern
On 2009-09-08 22:03 PM, sturlamolden wrote: On 9 Sep, 03:45, hi_roger wrote: i know how to select a submatrix using the slice object in numpy. But how can i select a submatrix A[i1,i2,i3;j1,j2,j3] (elements in A on line i1,i2,i3 and column j1,j2,j3 , and i1,i2,i3,j1,j2,j3 are all arbitrary nu

Re: a question about numpy

2009-09-09 Thread Robert Kern
On 2009-09-08 20:45 PM, hi_roger wrote: hello, i want to ask a question about numpy. i know how to select a submatrix using the slice object in numpy. But how can i select a submatrix A[i1,i2,i3;j1,j2,j3] (elements in A on line i1,i2,i3 and column j1,j2,j3 , and i1,i2,i3,j1,j2,j3 are all

Re: a question about numpy

2009-09-08 Thread sturlamolden
On 9 Sep, 03:45, hi_roger wrote: > hello, i want to ask a question about numpy. > > i know how to select a submatrix using the slice object in numpy. But > how can i select a submatrix > A[i1,i2,i3;j1,j2,j3] (elements in A on line i1,i2,i3 and column > j1,j2,j3 ,  and i1,i2,i

Re: a question about numpy

2009-09-08 Thread sturlamolden
On 9 Sep, 03:45, hi_roger wrote: > i know how to select a submatrix using the slice object in numpy. But > how can i select a submatrix > A[i1,i2,i3;j1,j2,j3] (elements in A on line i1,i2,i3 and column > j1,j2,j3 ,  and i1,i2,i3,j1,j2,j3 are all arbitrary numbers ) You just pass an array of ints

a question about numpy

2009-09-08 Thread hi_roger
hello, i want to ask a question about numpy. i know how to select a submatrix using the slice object in numpy. But how can i select a submatrix A[i1,i2,i3;j1,j2,j3] (elements in A on line i1,i2,i3 and column j1,j2,j3 , and i1,i2,i3,j1,j2,j3 are all arbitrary numbers ) The submatrix must share