Re: [Numpy-discussion] cumsum much slower than simple loop?

2012-02-09 Thread Elliot Saba
numpy 1.6.1, OSX, Core 2 Duo: In [7]: timeit a.cumsum(0) 100 loops, best of 3: 6.67 ms per loop In [8]: timeit a.T.cumsum(-1).T 100 loops, best of 3: 6.75 ms per loop -E On Thu, Feb 9, 2012 at 9:51 PM, Dave Cook wrote: > On Thu, Feb 9, 2012 at 9:41 PM, Dave Cook wrote: > >> >> Interesting.

Re: [Numpy-discussion] cumsum much slower than simple loop?

2012-02-09 Thread Dave Cook
On Thu, Feb 9, 2012 at 9:41 PM, Dave Cook wrote: > > Interesting. I should have mentioned that I'm using numpy 1.5.1 on 64-bit > Ubuntu 10.10. This transpose/compute/transpose trick did not work for me. > > Nor does it work under numpy 1.6.1 built with MKL under Windows 7 on a core i7. Dave Co

Re: [Numpy-discussion] cumsum much slower than simple loop?

2012-02-09 Thread Dave Cook
On Thu, Feb 9, 2012 at 9:21 PM, wrote: > strange (if I didn't make a mistake) > > In [12]: timeit a.cumsum(0) > 100 loops, best of 3: 7.17 ms per loop > > In [13]: timeit a.T.cumsum(-1).T > 1000 loops, best of 3: 1.78 ms per loop > > In [14]: (a.T.cumsum(-1).T == a.cumsum(0)).all() > Out[14]: Tru

Re: [Numpy-discussion] cumsum much slower than simple loop?

2012-02-09 Thread josef . pktd
On Thu, Feb 9, 2012 at 11:39 PM, Dave Cook wrote: > Why is numpy.cumsum (along axis=0) so much slower than a simple loop?  The > same goes for numpy.add.accumulate > > # cumsumtest.py > import numpy as np > > def loopcumsum(a): >     csum = np.empty_like(a) >     s = 0.0 >     for i in range(len(a

[Numpy-discussion] cumsum much slower than simple loop?

2012-02-09 Thread Dave Cook
Why is numpy.cumsum (along axis=0) so much slower than a simple loop? The same goes for numpy.add.accumulate # cumsumtest.py import numpy as np def loopcumsum(a): csum = np.empty_like(a) s = 0.0 for i in range(len(a)): csum[i] = s = s + a[i] return csum npcumsum = lambda

Re: [Numpy-discussion] numpy.arange() error?

2012-02-09 Thread Drew Frank
On Thu, Feb 9, 2012 at 3:40 PM, Benjamin Root wrote: > > > On Thursday, February 9, 2012, Sturla Molden wrote: > > > > > > Den 9. feb. 2012 kl. 22:44 skrev eat : > > > >> > > Maybe this issue is raised also earlier, but wouldn't it be more > consistent to let arange operate only with integers (l

Re: [Numpy-discussion] numpy.arange() error?

2012-02-09 Thread Benjamin Root
On Thursday, February 9, 2012, Sturla Molden wrote: > > > Den 9. feb. 2012 kl. 22:44 skrev eat : > >> > Maybe this issue is raised also earlier, but wouldn't it be more consistent to let arange operate only with integers (like Python's range) and let linspace handle the floats as well? > > > Perha

Re: [Numpy-discussion] numpy.arange() error?

2012-02-09 Thread Sturla Molden
Den 9. feb. 2012 kl. 22:44 skrev eat : > > Maybe this issue is raised also earlier, but wouldn't it be more consistent > to let arange operate only with integers (like Python's range) and let > linspace handle the floats as well? > > Perhaps. Another possibility would be to let arange take

Re: [Numpy-discussion] numpy.arange() error?

2012-02-09 Thread eat
Hi, On Thu, Feb 9, 2012 at 9:47 PM, Eric Firing wrote: > On 02/09/2012 09:20 AM, Drew Frank wrote: > > Eric Firing hawaii.edu> writes: > > > >> > >> On 02/08/2012 09:31 PM, teomat wrote: > >>> > >>> Hi, > >>> > >>> Am I wrong or the numpy.arange() function is not correct 100%? > >>> > >>> Try

Re: [Numpy-discussion] numpy.arange() error?

2012-02-09 Thread Tony Yu
On Thu, Feb 9, 2012 at 2:47 PM, Eric Firing wrote: > On 02/09/2012 09:20 AM, Drew Frank wrote: > > Eric Firing hawaii.edu> writes: > > > >> > >> On 02/08/2012 09:31 PM, teomat wrote: > >>> > >>> Hi, > >>> > >>> Am I wrong or the numpy.arange() function is not correct 100%? > >>> > >>> Try to do

Re: [Numpy-discussion] numpy.arange() error?

2012-02-09 Thread Eric Firing
On 02/09/2012 09:20 AM, Drew Frank wrote: > Eric Firing hawaii.edu> writes: > >> >> On 02/08/2012 09:31 PM, teomat wrote: >>> >>> Hi, >>> >>> Am I wrong or the numpy.arange() function is not correct 100%? >>> >>> Try to do this: >>> >>> In [7]: len(np.arange(3.1, 4.9, 0.1)) >>> Out[7]: 18 >>> >>>

Re: [Numpy-discussion] numpy.arange() error?

2012-02-09 Thread Charles R Harris
On Thu, Feb 9, 2012 at 12:20 PM, Drew Frank wrote: > Eric Firing hawaii.edu> writes: > > > > > On 02/08/2012 09:31 PM, teomat wrote: > > > > > > Hi, > > > > > > Am I wrong or the numpy.arange() function is not correct 100%? > > > > > > Try to do this: > > > > > > In [7]: len(np.arange(3.1, 4.9,

Re: [Numpy-discussion] numpy.arange() error?

2012-02-09 Thread Drew Frank
Eric Firing hawaii.edu> writes: > > On 02/08/2012 09:31 PM, teomat wrote: > > > > Hi, > > > > Am I wrong or the numpy.arange() function is not correct 100%? > > > > Try to do this: > > > > In [7]: len(np.arange(3.1, 4.9, 0.1)) > > Out[7]: 18 > > > > In [8]: len(np.arange(8.1, 9.9, 0.1)) > > Out[

Re: [Numpy-discussion] Moving to gcc 4.* for win32 installers ?

2012-02-09 Thread Sturla Molden
On 07.02.2012 18:38, Sturla Molden wrote: > One potential problem I just discovered is dependency on a DLL called > libpthreadGC2.dll. This is not correct!!! :-D Two threading APIs can be used for OpenBLAS/GotoBLAS2, Win32 threads or OpenMP. driver/others/blas_server_omp.c driver/other

Re: [Numpy-discussion] just the date part of a datetime64[s]?

2012-02-09 Thread John Salvatier
Thanks Mark! John On Wed, Feb 8, 2012 at 6:48 PM, Mark Wiebe wrote: > Converting between date and datetime requires caution, because it depends > on your time zone. Because all datetime64's are internally stored in UTC, > simply casting as in your example treats it in UTC. The 'astype' function

Re: [Numpy-discussion] Cython question

2012-02-09 Thread Charles R Harris
On Thu, Feb 9, 2012 at 8:35 AM, mark florisson wrote: > On 9 February 2012 15:29, Charles R Harris > wrote: > > Hi All, > > > > Does anyone know how to make Cython emit a C macro? I would like to be > able > > to > > > > #define NO_DEPRECATED_API > > > > and can do so by including a header file o

Re: [Numpy-discussion] Cython question

2012-02-09 Thread mark florisson
On 9 February 2012 15:29, Charles R Harris wrote: > Hi All, > > Does anyone know how to make Cython emit a C macro? I would like to be able > to > > #define NO_DEPRECATED_API > > and can do so by including a header file or futzing with the generator > script, but I was wondering if there was an ea

[Numpy-discussion] Cython question

2012-02-09 Thread Charles R Harris
Hi All, Does anyone know how to make Cython emit a C macro? I would like to be able to #define NO_DEPRECATED_API and can do so by including a header file or futzing with the generator script, but I was wondering if there was an easy way to do it in Cython. Chuck

Re: [Numpy-discussion] Numpy array slicing

2012-02-09 Thread Eirik Gjerløw
Ok, that was an enlightening discussion, I guess I signed up for this list a couple of days too late! Thanks, Eirik On 09. feb. 2012 12:55, Olivier Delalleau wrote: This was actually discussed very recently (for more details: http://mail.scipy.org/pipermail/numpy-discussion/2012-February/06023

Re: [Numpy-discussion] Numpy array slicing

2012-02-09 Thread Olivier Delalleau
This was actually discussed very recently (for more details: http://mail.scipy.org/pipermail/numpy-discussion/2012-February/060232.html). It's caused by mixing slicing with advanced indexing. The resulting shape is the concatenation of a first part obtained by broadcasting of the non-slice items (

[Numpy-discussion] Numpy array slicing

2012-02-09 Thread Eirik Gjerløw
Hello, (also sent to Scipy-User, sorry for duplicates). This is (I think) a rather basic question about numpy slicing. I have the following code: In [29]: a.shape Out[29]: (3, 4, 12288, 2) In [30]: mask.shape Out[30]: (3, 12288) In [31]: mask.dtype Out[31]: dtype('bool') In [32]: sum(mask[0]