On Sep 5, 2008, at 8:52 AM, Keith Goodman wrote:
> Here's another difference:
>
>>> a = np.random.randn(10)
>>> timeit np.sum(a[np.where(a>0)])
> 100 loops, best of 3: 3.44 ms per loop
>>> timeit a[a > 0].sum()
> 100 loops, best of 3: 2.21 ms per loop
Here is an even faster method (but much m
On Sep 5, 2008, at 8:52 AM, Keith Goodman wrote:
> Here's another difference:
>
>>> a = np.random.randn(10)
>>> timeit np.sum(a[np.where(a>0)])
> 100 loops, best of 3: 3.44 ms per loop
>>> timeit a[a > 0].sum()
> 100 loops, best of 3: 2.21 ms per loop
Here is an even faster method (but much m
thank you very much, deliciously satisfying
On Sep 5, 3:33 pm, Zachary Pincus <[EMAIL PROTECTED]> wrote:
> > Hi, probably a basic question, but I'm looking for a neat way to sum
> > all the positive values in an array of floats. I'm currently doing it
> > the hard way, but am hoping there is some
On Fri, Sep 5, 2008 at 9:08 AM, David Cournapeau <[EMAIL PROTECTED]> wrote:
> On Fri, Sep 5, 2008 at 11:52 PM, Keith Goodman <[EMAIL PROTECTED]> wrote:
>
>> Here's another difference:
>>
a = np.random.randn(10)
timeit np.sum(a[np.where(a>0)])
>> 100 loops, best of 3: 3.44 ms per loop
On Fri, Sep 5, 2008 at 11:52 PM, Keith Goodman <[EMAIL PROTECTED]> wrote:
> Here's another difference:
>
>>> a = np.random.randn(10)
>>> timeit np.sum(a[np.where(a>0)])
> 100 loops, best of 3: 3.44 ms per loop
>>> timeit a[a > 0].sum()
> 100 loops, best of 3: 2.21 ms per loop
But you're not c
On Fri, Sep 5, 2008 at 7:32 AM, David Cournapeau
<[EMAIL PROTECTED]> wrote:
> Ludwig wrote:
>> What are the relative merits of
>>
>> sum(a[where(a>0])
>>
>> to
>>
>> a[a > 0].sum()
>>
>> ?
>> Second one is more OO, takes a few keystrokes less to type. Is there
>> any real difference if it came to v
Ludwig wrote:
> What are the relative merits of
>
> sum(a[where(a>0])
>
> to
>
> a[a > 0].sum()
>
> ?
> Second one is more OO, takes a few keystrokes less to type. Is there
> any real difference if it came to very large arrays? Or is it 'just' a
> style question?
In this case, it is style: sum(
What are the relative merits of
sum(a[where(a>0])
to
a[a > 0].sum()
?
Second one is more OO, takes a few keystrokes less to type. Is there any
real difference if it came to very large arrays? Or is it 'just' a style
question?
Ludwig
2008/9/5 Zachary Pincus <[EMAIL PROTECTED]>
> >
> > Hi, pro
>
> Hi, probably a basic question, but I'm looking for a neat way to sum
> all the positive values in an array of floats. I'm currently doing it
> the hard way, but am hoping there is some cunning and elegant syntax I
> can use instead
Fancy indexing's my favorite cunning and elegant syntax:
a =
Hi, probably a basic question, but I'm looking for a neat way to sum
all the positive values in an array of floats. I'm currently doing it
the hard way, but am hoping there is some cunning and elegant syntax I
can use instead
___
Numpy-discussion mailing
10 matches
Mail list logo