Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Francesc Alted
A Wednesday 22 December 2010 01:53:55 Mark Wiebe escrigué: Hello NumPy-ers, After some performance analysis, I've designed and implemented a new iterator designed to speed up ufuncs and allow for easier multi-dimensional iteration. The new code is fairly large, but works quite well

Re: [Numpy-discussion] Giving numpy the ability to multi-iterate excluding an axis

2010-12-22 Thread John Salvatier
This now makes sense to me, and I think it should work :D. This is all very cool. This is going to do big things for cython and numpy. Some hopefully constructive criticism: When first reading through the API description, the way oa_ndim and oa_axes work is not clear. I think your description

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Mark Wiebe
On Wed, Dec 22, 2010 at 12:21 AM, Francesc Alted fal...@pytables.orgwrote: snip Wow, really nice work! It would be great if that could make into NumPy :-) Regarding your comment on numexpr being faster, I'm not sure (your new_iterator branch does not work for me; it gives me an error like:

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Francesc Alted
A Wednesday 22 December 2010 09:48:03 Mark Wiebe escrigué: On Wed, Dec 22, 2010 at 12:21 AM, Francesc Alted fal...@pytables.orgwrote: snip Wow, really nice work! It would be great if that could make into NumPy :-) Regarding your comment on numexpr being faster, I'm not sure :(your

[Numpy-discussion] use of the PyArray_SETITEM numpy method

2010-12-22 Thread Michel Dupront
Hello, Please somebody help me ! I am really confused with all these void that I see everywhere. The documentation says: PyObject * PyArray_SETITEM(PyObject * arr, void* itemptr, PyObject* obj) I created a 1D array of doubles with PyArray_SimpleNew. Now I am in a loop of index i to feed

Re: [Numpy-discussion] use of the PyArray_SETITEM numpy method

2010-12-22 Thread Francesc Alted
A Wednesday 22 December 2010 10:55:30 Michel Dupront escrigué: Hello, Please somebody help me ! I am really confused with all these void that I see everywhere. The documentation says: PyObject * PyArray_SETITEM(PyObject * arr, void* itemptr, PyObject* obj) I created a 1D array of

[Numpy-discussion] savetxt to a string?

2010-12-22 Thread Neal Becker
Is the formatting of savetxt available with a string as the destination? If not, shouldn't this functionality be factored out of savetxt? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] savetxt to a string?

2010-12-22 Thread Peter
On Wed, Dec 22, 2010 at 1:08 PM, Neal Becker ndbeck...@gmail.com wrote: Is the formatting of savetxt available with a string as the destination? If not, shouldn't this functionality be factored out of savetxt? Have you tried using a StringIO handle? Peter

Re: [Numpy-discussion] savetxt to a string?

2010-12-22 Thread Neal Becker
Peter wrote: On Wed, Dec 22, 2010 at 1:08 PM, Neal Becker ndbeck...@gmail.com wrote: Is the formatting of savetxt available with a string as the destination? If not, shouldn't this functionality be factored out of savetxt? Have you tried using a StringIO handle? Peter Yup. But

[Numpy-discussion] counting non-zero entries in an ndarray

2010-12-22 Thread Ian Stokes-Rees
What is the most efficient way to do the Matlab equivalent of nnz(M) (nnz = number-of-non-zeros function)? I've tried Google, but no luck. My assumption is that something like a != 0 will be used, but I'm not sure then how to count the number of True entries. TIA. Ian attachment:

Re: [Numpy-discussion] counting non-zero entries in an ndarray

2010-12-22 Thread Alan G Isaac
On 12/22/2010 9:16 AM, Ian Stokes-Rees wrote: a != 0 will be used, but I'm not sure then how to count the number of True entries. (a != 0).sum() hth, Alan Isaac ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Mark Wiebe
On Tue, Dec 21, 2010 at 10:05 PM, Charles R Harris charlesr.har...@gmail.com wrote: snip Wow, that's a really nice design and write up. Small typo: /* Only allow exactly equivalent types */ NPY_NO_CASTING=0, /* Allow casts between equivalent types of different byte

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Mark Wiebe
On Wed, Dec 22, 2010 at 12:54 AM, Francesc Alted fal...@pytables.orgwrote: A Wednesday 22 December 2010 09:48:03 Mark Wiebe escrigué: On Wed, Dec 22, 2010 at 12:21 AM, Francesc Alted fal...@pytables.orgwrote: snip new_iterator branch does not work for me; it gives me an error like:

Re: [Numpy-discussion] Giving numpy the ability to multi-iterate excluding an axis

2010-12-22 Thread Mark Wiebe
On Wed, Dec 22, 2010 at 12:44 AM, John Salvatier jsalv...@u.washington.eduwrote: This now makes sense to me, and I think it should work :D. This is all very cool. This is going to do big things for cython and numpy. Some hopefully constructive criticism: When first reading through the API

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Francesc Alted
A Wednesday 22 December 2010 17:25:13 Mark Wiebe escrigué: Can you print out your np.__version__, and try running the tests? If newiter didn't build for some reason, its tests should be throwing a bunch of exceptions. I'm a bit swamped now. Let's see if I can do that later on. I see :-)

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Mark Wiebe
On Wed, Dec 22, 2010 at 9:07 AM, Francesc Alted fal...@pytables.org wrote: A Wednesday 22 December 2010 17:25:13 Mark Wiebe escrigué: Can you print out your np.__version__, and try running the tests? If newiter didn't build for some reason, its tests should be throwing a bunch of

Re: [Numpy-discussion] counting non-zero entries in an ndarray

2010-12-22 Thread Thomas K Gamble
On Wednesday, December 22, 2010 07:16:17 am Ian Stokes-Rees wrote: What is the most efficient way to do the Matlab equivalent of nnz(M) (nnz = number-of-non-zeros function)? I've tried Google, but no luck. My assumption is that something like a != 0 will be used, but I'm not sure

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Francesc Alted
A Wednesday 22 December 2010 18:21:28 Mark Wiebe escrigué: On Wed, Dec 22, 2010 at 9:07 AM, Francesc Alted fal...@pytables.org wrote: A Wednesday 22 December 2010 17:25:13 Mark Wiebe escrigué: Can you print out your np.__version__, and try running the tests? If newiter didn't build for

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Mark Wiebe
On Wed, Dec 22, 2010 at 10:41 AM, Francesc Alted fal...@pytables.orgwrote: NumPy version 2.0.0.dev-147f817 There's your problem, it looks like the PYTHONPATH isn't seeing your new build for some reason. That build is off of this commit in the NumPy master branch:

[Numpy-discussion] ANN: carray 0.3 released

2010-12-22 Thread Francesc Alted
= Announcing carray 0.3 = What's new == A lot of stuff. The most outstanding feature in this version is the introduction of a `ctable` object. A `ctable` is similar to a structured array in NumPy, but instead of storing the data row-wise, it uses

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Francesc Alted
A Wednesday 22 December 2010 19:52:45 Mark Wiebe escrigué: On Wed, Dec 22, 2010 at 10:41 AM, Francesc Alted fal...@pytables.orgwrote: NumPy version 2.0.0.dev-147f817 There's your problem, it looks like the PYTHONPATH isn't seeing your new build for some reason. That build is off of this

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Mark Wiebe
On Wed, Dec 22, 2010 at 11:16 AM, Francesc Alted fal...@pytables.orgwrote: A Wednesday 22 December 2010 19:52:45 Mark Wiebe escrigué: On Wed, Dec 22, 2010 at 10:41 AM, Francesc Alted fal...@pytables.orgwrote: NumPy version 2.0.0.dev-147f817 There's your problem, it looks like the

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Francesc Alted
A Wednesday 22 December 2010 20:42:54 Mark Wiebe escrigué: On Wed, Dec 22, 2010 at 11:16 AM, Francesc Alted fal...@pytables.orgwrote: A Wednesday 22 December 2010 19:52:45 Mark Wiebe escrigué: On Wed, Dec 22, 2010 at 10:41 AM, Francesc Alted fal...@pytables.orgwrote: NumPy version

Re: [Numpy-discussion] counting non-zero entries in an ndarray

2010-12-22 Thread Jonathan Rocher
To answer the part about the most efficient way to do that, In [1]: a = array([0,1,4,76,3,0,4,67,9,5,3,9,0,5,23,3,0,5,3,3,0,5,0]) In [8]: %timeit len(where(a!=0)[0]) 10 loops, best of 3: 6.54 us per loop In [9]: %timeit (a!=0).sum() 10 loops, best of 3: 9.81 us per loop Seems like the

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Mark Wiebe
On Wed, Dec 22, 2010 at 12:05 PM, Francesc Alted fal...@pytables.orgwrote: snip Ah, things go well now: timeit 3*a+b-(a/c) 10 loops, best of 3: 67.7 ms per loop timeit luf(lambda a,b,c:3*a+b-(a/c), a, b, c) 10 loops, best of 3: 27.8 ms per loop timeit ne.evaluate(3*a+b-(a/c)) 10

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Mark Wiebe
On Wed, Dec 22, 2010 at 12:42 PM, Mark Wiebe mwwi...@gmail.com wrote: snip I think numexpr could get a nice boost from using the new iterator internally though There's actually a trivial way to do this with very minimal changes to numexpr - the 'itview' mechanism. Create the new iterator,

Re: [Numpy-discussion] counting non-zero entries in an ndarray

2010-12-22 Thread Ian Stokes-Rees
On 12/22/10 9:16 AM, Ian Stokes-Rees wrote: What is the most efficient way to do the Matlab equivalent of nnz(M) (nnz = number-of-non-zeros function)? Thanks to all the various responses. I should have mentioned that I'm using scipy.sparse, and lil_matrix objects have a method getnnz() which

Re: [Numpy-discussion] NEP for faster ufuncs

2010-12-22 Thread Francesc Alted
A Wednesday 22 December 2010 22:02:03 Mark Wiebe escrigué: On Wed, Dec 22, 2010 at 12:42 PM, Mark Wiebe mwwi...@gmail.com wrote: snip I think numexpr could get a nice boost from using the new iterator internally though There's actually a trivial way to do this with very minimal changes

[Numpy-discussion] How to control column for pretty print line wrap of ndarrays

2010-12-22 Thread Ian Stokes-Rees
Like most people these days, I have multiple 24 monitors. I don't need print of ndarrays to wrap after 72 columns. Is there some way to change this? TIA Ian CURRENT: [NaN NaN NaN NaN NaN 5.1882094 1.19646584]] DESIRED: [NaN NaN

Re: [Numpy-discussion] How to control column for pretty print line wrap of ndarrays

2010-12-22 Thread Robert Kern
On Wed, Dec 22, 2010 at 16:32, Ian Stokes-Rees ijsto...@hkl.hms.harvard.edu wrote: Like most people these days, I have multiple 24 monitors.  I don't need print of ndarrays to wrap after 72 columns.  Is there some way to change this? np.set_printoptions(linewidth=100) -- Robert Kern I have