On Fri, Apr 2, 2010 at 11:45 PM, Chris Colbert wrote:
>
>
> On Fri, Apr 2, 2010 at 3:03 PM, Erik Tollerud
> wrote:
> you could try something like this (untested):
> if __name__ == '__main__':
> try:
> import numpy
> except ImportError:
> import subprocess
> subproc
On Fri, Apr 2, 2010 at 3:03 PM, Erik Tollerud wrote:
you could try something like this (untested):
if __name__ == '__main__':
try:
import numpy
except ImportError:
import subprocess
subprocess.check_call(['easy_install', 'numpy']) # will except if
call fails
_
Thanks Warren!
On Fri, Apr 2, 2010 at 2:46 PM, Warren Weckesser <
warren.weckes...@enthought.com> wrote:
> Vishal Rana wrote:
> > Hi,
> >
> > I know its easy, but I am not just getting it...
> >
> > How do I get last element on axis=1 for:
> >
> > a = array([[ 0, 1, 2, 3, 4],
> >[ 5,
Vishal Rana wrote:
> Hi,
>
> I know its easy, but I am not just getting it...
>
> How do I get last element on axis=1 for:
>
> a = array([[ 0, 1, 2, 3, 4],
>[ 5, 6, 7, 8, 9],
>[10, 11, 12, 13, 14],
>[15, 16, 17, 18, 19],
>[20, 21, 22, 23, 24]])
>
> Expected:
Hi,
I know its easy, but I am not just getting it...
How do I get last element on axis=1 for:
a = array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]])
Expected: array([4, 9, 14, 19, 24])
Thanks
Vishal
Shailendra gmail.com> writes:
>
> Well, this is just a toy problem. argmax represent a method which will
> give me a index in x[cond] . And for the case of multiple value my
> requirement is fine with getting any "max" index.
OK. My concern seems to be needless then.
BTW, does this current th
Well, this is just a toy problem. argmax represent a method which will
give me a index in x[cond] . And for the case of multiple value my
requirement is fine with getting any "max" index.
Thanks,
Shailendra
On Fri, Apr 2, 2010 at 3:00 PM, eat wrote:
> Shailendra gmail.com> writes:
>
>>
>> I fo
I get AttributeError: 'NoneType' object has no attribute 'accumulate' for
the call
vecfun.ufunc.accumulate(np.array([0, 1, 2, 3]))
It works fine if I make a dummy call to vecfun before! Any idea for
this behavior?
Thanks
Vishal Rana
On Mon, Mar 29, 2010 at 4:07 AM, Nadav Horesh wrote:
> The ge
On Fri, Apr 2, 2010 at 13:03, Erik Tollerud wrote:
> I am writing a setup.py file for a package that will use cython with
> numpy integration. This of course requires the numpy header files,
> which I am including by using numpy.get_includes in the setup.py file
> below. The problem is for users
I am writing a setup.py file for a package that will use cython with
numpy integration. This of course requires the numpy header files,
which I am including by using numpy.get_includes in the setup.py file
below. The problem is for users that have not installed numpy before
installing this packag
Shailendra gmail.com> writes:
>
> I forgot to mention that i wanted this to work for general shape. So i
> modified it little bit
>
> >>> x = array([[1,2,3,4,5], [6,7,8,7,6], [1,2,3,4,5]])
> >>> cond = (x > 5)
> >>> loc= where(cond)
> >>> arg_max=argmax(x[cond])
> >>> x[tuple([e[arg_max] for e
On Fri, Apr 2, 2010 at 10:46 AM, Charles R Harris wrote:
> On Fri, Apr 2, 2010 at 11:27 AM, David Goldsmith
> wrote:
>
>> Also:
>>
>> >>> c.deriv(0)
>> Chebyshev([ 1.], [-1., 1.])
>> >>> c.integ(0)
>>
>> Traceback (most recent call last):
>> File "", line 1, in
>> File "", line 441, in int
On Fri, Apr 2, 2010 at 10:42 AM, Charles R Harris wrote:
>
> On Thu, Apr 1, 2010 at 7:42 PM, David Goldsmith
> wrote:
>
>> >>> np.version.version
>> '1.4.0'
>> >>> c = np.polynomial.chebyshev.Chebyshev(1)
>> >>> c.deriv(1.0)
>> Chebyshev([ 0.], [-1., 1.])
>> >>> c.integ(1.0)
>> Traceback (most
On Fri, Apr 2, 2010 at 11:27 AM, David Goldsmith wrote:
> On Thu, Apr 1, 2010 at 6:42 PM, David Goldsmith
> wrote:
>
>> >>> np.version.version
>> '1.4.0'
>> >>> c = np.polynomial.chebyshev.Chebyshev(1)
>> >>> c.deriv(1.0)
>> Chebyshev([ 0.], [-1., 1.])
>> >>> c.integ(1.0)
>> Traceback (most rece
On Thu, Apr 1, 2010 at 7:42 PM, David Goldsmith wrote:
> >>> np.version.version
> '1.4.0'
> >>> c = np.polynomial.chebyshev.Chebyshev(1)
> >>> c.deriv(1.0)
> Chebyshev([ 0.], [-1., 1.])
> >>> c.integ(1.0)
> Traceback (most recent call last):
> File "", line 1, in
> File "", line 441, in inte
On Thu, Apr 1, 2010 at 6:42 PM, David Goldsmith wrote:
> >>> np.version.version
> '1.4.0'
> >>> c = np.polynomial.chebyshev.Chebyshev(1)
> >>> c.deriv(1.0)
> Chebyshev([ 0.], [-1., 1.])
> >>> c.integ(1.0)
> Traceback (most recent call last):
> File "", line 1, in
> File "", line 441, in inte
Hi All,
>>> x=arange(10)
>>> indices=[(1,),(2,)]
>>> x[indices]
Traceback (most recent call last):
File "", line 1, in
IndexError: unsupported iterator index
But following works.
>>> x=x.reshape(5,2)
>>> x
array([[0, 1],
[2, 3],
[4, 5],
[6, 7],
[8, 9]])
>>> indices
I forgot to mention that i wanted this to work for general shape. So i
modified it little bit
>>> x = array([[1,2,3,4,5], [6,7,8,7,6], [1,2,3,4,5]])
>>> cond = (x > 5)
>>> loc= where(cond)
>>> arg_max=argmax(x[cond])
>>> x[tuple([e[arg_max] for e in loc])]
8
Thanks for your solution.
Shailendra
With A and X being arrays:
B=numpy.zeros(A.shape, A.dtype)
B[A>0] = X
Armando
Quoting gerardob :
>
> Let A be a square matrix of 0's and 1's, and let X be a one dimesional
> vector.
> The length of X is equal to the number of 1's that A has.
> I would like to produce a new matrix B by traversi
On Fri, Apr 2, 2010 at 09:31, Shailendra wrote:
> Hi All,
> I have a following model problem. Let i have a array
x
> array([[1, 2, 3, 4, 5],
> [6, 7, 8, 7, 6],
> [1, 2, 3, 4, 5]])
>
> suppose i apply some cond on it.
cond= x>5
x[cond]
> array([6, 7, 8, 7, 6])
>
> Now, i
Hi All,
I have a following model problem. Let i have a array
>>> x
array([[1, 2, 3, 4, 5],
[6, 7, 8, 7, 6],
[1, 2, 3, 4, 5]])
suppose i apply some cond on it.
>>> cond= x>5
>>> x[cond]
array([6, 7, 8, 7, 6])
Now, i want to argmax on this
>>> max=argmax(x[cond])
>>> max
2
>>> x[cond]
On Fri, Apr 2, 2010 at 8:31 AM, Robert Kern wrote:
> On Fri, Apr 2, 2010 at 08:28, Ryan May wrote:
>> On Thu, Apr 1, 2010 at 10:07 PM, Shailendra
>> wrote:
>>> Hi All,
>>> Below is some array behaviour which i think is odd
>> a=arange(10)
>> a
>>> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>
>>> A=[[1,1,0],
... [1,0,0],
... [0,0,1]]
>>> X=[2,9,10,3]
>>> import numpy
>>> A=numpy.asarray(A)
>>> X=numpy.asarray(X)
>>> A
array([[1, 1, 0],
[1, 0, 0],
[0, 0, 1]])
>>> X
array([ 2, 9, 10, 3])
>>> non_zero=numpy.nonzero(A)
>>> non_zero
(array([0, 0, 1, 2]), array([0, 1, 0, 2]))
Thanks everyone for replies/suggestion. It is simple to avoid this
problem. But my point that given the behavior of python this behavior
seems inconsistent. There could other method provided which could
evaluate bool value depending on values stored in the array.
Thanks,
Shailendra
On Fri, Apr 2,
Let A be a square matrix of 0's and 1's, and let X be a one dimesional
vector.
The length of X is equal to the number of 1's that A has.
I would like to produce a new matrix B by traversing the matrix A row by row
and:
1- whenever i find a 0, set B in that position to zero.
2- whenever i find a 1,
On Fri, Apr 2, 2010 at 08:28, Ryan May wrote:
> On Thu, Apr 1, 2010 at 10:07 PM, Shailendra
> wrote:
>> Hi All,
>> Below is some array behaviour which i think is odd
> a=arange(10)
> a
>> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
> b=nonzero(a<0)
> b
>> (array([], dtype=int32),)
On Thu, Apr 1, 2010 at 10:07 PM, Shailendra wrote:
> Hi All,
> Below is some array behaviour which i think is odd
a=arange(10)
a
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
b=nonzero(a<0)
b
> (array([], dtype=int32),)
if not b[0]:
> ... print 'b[0] is false'
> ...
> b[0] i
On Fri, Apr 2, 2010 at 10:11 AM, Robert Kern wrote:
> On Thu, Apr 1, 2010 at 22:07, Shailendra wrote:
>> Hi All,
>> Below is some array behaviour which i think is odd
> a=arange(10)
> a
>> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
> b=nonzero(a<0)
> b
>> (array([], dtype=int32),)
On Thu, Apr 1, 2010 at 22:07, Shailendra wrote:
> Hi All,
> Below is some array behaviour which i think is odd
a=arange(10)
a
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
b=nonzero(a<0)
b
> (array([], dtype=int32),)
if not b[0]:
> ... print 'b[0] is false'
> ...
> b[0] is f
On 4/2/2010 8:29 AM, Nadav Horesh wrote:
> In python empty sequences are always equivalent to False, and non-empty to
> True.
I think that was why the OP objected to this behavior:
>>> bool(np.array([0]))
False
Alan Isaac
___
NumPy
In python empty sequences are always equivalent to False, and non-empty to
True. You can use this property or:
if len(b) > 0:
.
Nadav
-Original Message-
From: numpy-discussion-boun...@scipy.org on behalf of Shailendra
Sent: Fri 02-Apr-10 06:07
To: numpy-discussion@scipy.org
S
31 matches
Mail list logo