Re: [Numpy-discussion] Solving a memory leak in a numpy extension; PyArray_ContiguousFromObject

2009-04-20 Thread Dan S
Thanks all for responses. Continuation below: 2009/4/18 Charles R Harris charlesr.har...@gmail.com: On Fri, Apr 17, 2009 at 9:25 AM, Dan S dan.s.towell+nu...@gmail.com wrote: Hi - I have written a numpy extension which works fine but has a memory leak. It takes a single array argument and

Re: [Numpy-discussion] Solving a memory leak in a numpy extension; PyArray_ContiguousFromObject

2009-04-20 Thread V. Armando Solé
Dan S wrote: But as you can see, my C code doesn't perform any malloc() or suchlike, so I'm stumped. I'd be grateful for any further thoughts Could it be your memory leak is in: return PyFloat_FromDouble(3.1415927); // temporary You are creating a python float object from something. What if

Re: [Numpy-discussion] Solving a memory leak in a numpy extension; PyArray_ContiguousFromObject

2009-04-20 Thread Dan S
2009/4/20 V. Armando Solé s...@esrf.fr: Dan S wrote: But as you can see, my C code doesn't perform any malloc() or suchlike, so I'm stumped. I'd be grateful for any further thoughts Could it be your memory leak is in: return PyFloat_FromDouble(3.1415927); // temporary You are creating a

[Numpy-discussion] Linker script, smaller source files and symbol visibility

2009-04-20 Thread David Cournapeau
Hi, For quite a long time I have been bothered by the very large files needed for python extensions. In particular for numpy.core, which consists in a few files which are ~ 1 Mb, I find this a pretty high barrier of entry for newcomers, and it has quite a big impact on the code organization.

[Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread Ruben Salvador
Hi everybody! First of all I should say I am a newbie with Python/Scipy. Have been searching a little bit (google and lists) and haven't found a helpful answer...so I'm posting. I'm using Scipy/Numpy to do image wavelet transforms via the lifting scheme. I grabbed some code implementing the

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread David Cournapeau
Hi Ruben, Ruben Salvador wrote: Hi everybody! First of all I should say I am a newbie with Python/Scipy. Have been searching a little bit (google and lists) and haven't found a helpful answer...so I'm posting. I'm using Scipy/Numpy to do image wavelet transforms via the lifting scheme. I

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread David Cournapeau
David Cournapeau wrote: Hi Ruben, Ruben Salvador wrote: Hi everybody! First of all I should say I am a newbie with Python/Scipy. Have been searching a little bit (google and lists) and haven't found a helpful answer...so I'm posting. I'm using Scipy/Numpy to do image wavelet

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread Rob Clewley
David, I'm confused about your reply. I don't think Ruben was only asking why you'd ever get non-zero error after the forward and inverse transform, but why his implementation using lists gives zero error but using arrays he gets something of order 1e-15. On Mon, Apr 20, 2009 at 9:47 AM, David

[Numpy-discussion] NaN as dictionary key?

2009-04-20 Thread Wes McKinney
I assume that, because NaN != NaN, even though both have the same hash value (hash(NaN) == -32768), that Python treats any NaN double as a distinct key in a dictionary. In [76]: a = np.repeat(nan, 10) In [77]: d = {} In [78]: for i, v in enumerate(a): : d[v] = i : : In

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread David Cournapeau
Rob Clewley wrote: David, I'm confused about your reply. I don't think Ruben was only asking why you'd ever get non-zero error after the forward and inverse transform, but why his implementation using lists gives zero error but using arrays he gets something of order 1e-15. That's more

Re: [Numpy-discussion] Linker script, smaller source files and symbol visibility

2009-04-20 Thread Charles R Harris
Hi David On Mon, Apr 20, 2009 at 6:51 AM, David Cournapeau da...@ar.media.kyoto-u.ac.jp wrote: Hi, For quite a long time I have been bothered by the very large files needed for python extensions. In particular for numpy.core, which consists in a few files which are ~ 1 Mb, I find this a

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread Rob Clewley
On Mon, Apr 20, 2009 at 10:48 AM, David Cournapeau da...@ar.media.kyoto-u.ac.jp wrote: Rob Clewley wrote: David, I'm confused about your reply. I don't think Ruben was only asking why you'd ever get non-zero error after the forward and inverse transform, but why his implementation using

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread Charles R Harris
On Mon, Apr 20, 2009 at 9:49 AM, Rob Clewley rob.clew...@gmail.com wrote: On Mon, Apr 20, 2009 at 10:48 AM, David Cournapeau da...@ar.media.kyoto-u.ac.jp wrote: Rob Clewley wrote: David, I'm confused about your reply. I don't think Ruben was only asking why you'd ever get non-zero

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread David Cournapeau
On Tue, Apr 21, 2009 at 12:49 AM, Rob Clewley rob.clew...@gmail.com wrote: On Mon, Apr 20, 2009 at 10:48 AM, David Cournapeau da...@ar.media.kyoto-u.ac.jp wrote: Rob Clewley wrote: David, I'm confused about your reply. I don't think Ruben was only asking why you'd ever get non-zero error

Re: [Numpy-discussion] NaN as dictionary key?

2009-04-20 Thread David Cournapeau
On Mon, Apr 20, 2009 at 11:42 PM, Wes McKinney wesmck...@gmail.com wrote: I assume that, because NaN != NaN, even though both have the same hash value (hash(NaN) == -32768), that Python treats any NaN double as a distinct key in a dictionary. I think that strictly speaking, nan should not be

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread josef . pktd
On Mon, Apr 20, 2009 at 12:04 PM, David Cournapeau courn...@gmail.comwrote: On Tue, Apr 21, 2009 at 12:49 AM, Rob Clewley rob.clew...@gmail.com wrote: On Mon, Apr 20, 2009 at 10:48 AM, David Cournapeau da...@ar.media.kyoto-u.ac.jp wrote: Rob Clewley wrote: David, I'm confused about

[Numpy-discussion] Getting the only object in a zero dimensional array

2009-04-20 Thread Fadhley Salim
I have a 0d array that looks like this: myarray = array( 0.1234 ) This generates a TypeError: myarray[0] I can get it's number using a hack like this... but it looks kind of wrong: myval = myarray + 0.0 There must be a better way to do it, right? All I want is the correct way to return the

Re: [Numpy-discussion] Getting the only object in a zero dimensional array

2009-04-20 Thread Robert Kern
On Mon, Apr 20, 2009 at 12:39, Fadhley Salim fadhley.sa...@uk.calyon.com wrote: I have a 0d array that looks like this: myarray = array( 0.1234 ) This generates a TypeError: myarray[0] myarray[()] or myarray.item() -- Robert Kern I have come to believe that the whole world is an enigma,

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread Matthieu Brucher
I understand the numerical mathematics behind this very well but my point is that his two algorithms appear to be identical (same operations, same order), he simply uses lists in one and arrays in the other. It's not like he used vectorization or other array-related operations - he uses for

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread josef . pktd
On Mon, Apr 20, 2009 at 1:47 PM, Matthieu Brucher matthieu.bruc...@gmail.com wrote: I understand the numerical mathematics behind this very well but my point is that his two algorithms appear to be identical (same operations, same order), he simply uses lists in one and arrays in the

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread John Gleeson
On 2009-04-20, at 10:04 AM, David Cournapeau wrote: Yes, it is legitimate and healthy to worry about the difference - but the surprising thing really is the list behavior when you are used to numerical computation :) And I maintain that the algorithms are not the same in both operations.

Re: [Numpy-discussion] Linker script, smaller source files and symbol visibility

2009-04-20 Thread Charles R Harris
On Mon, Apr 20, 2009 at 9:48 AM, Charles R Harris charlesr.har...@gmail.com wrote: Hi David On Mon, Apr 20, 2009 at 6:51 AM, David Cournapeau da...@ar.media.kyoto-u.ac.jp wrote: Hi, For quite a long time I have been bothered by the very large files needed for python extensions. In

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread Ruben Salvador
Well, thanks everybody for such a quick help!! I just couldn't imagine what could arise this difference. 1e-15 is enough precision for what I will be doing, but was just curious. Anyway, this 'deepcopy' really surprised me. I have now looked for it and I think I get an idea of it, though I

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread Christopher Barker
Ruben Salvador wrote: Anyway, this 'deepcopy' really surprised me. I have now looked for it and I think I get an idea of it, though I wouldn't expect this difference in behavior to happen. From my logical point of view a copy is a copy, and if I find a method called copy() I can only expect

Re: [Numpy-discussion] numpy Mac binary for Python 2.6

2009-04-20 Thread Christopher Barker
Russell E. Owen wrote: http://www.pymvpa.org/devguide.html The patch at the end of this document worked. Has anyone submitted these patches so they'll get into bdist_mpkg? I'm guessing Ronald Oussoren would be the person to accept them, but you can post to the MacPython list to be sure.

Re: [Numpy-discussion] help getting started

2009-04-20 Thread Christopher Barker
David Cournapeau wrote: Christopher, would you mind trying the following binary ? http://www.ar.media.kyoto-u.ac.jp/members/david/archives/numpy/scipy-0.7.0-py2.5-macosx10.5.mpkg.tar That binary seems to be working OK on my PPC 10.4 mac, with no gfortran installed. Is it up on the main

Re: [Numpy-discussion] Numpy float precision vs Python list float issue

2009-04-20 Thread David Cournapeau
Ruben Salvador wrote: Anyway, this 'deepcopy' really surprised me. I have now looked for it and I think I get an idea of it, though I wouldn't expect this difference in behavior to happen. From my logical point of view a copy is a copy, and if I find a method called copy() I can only expect

Re: [Numpy-discussion] Linker script, smaller source files and symbol visibility

2009-04-20 Thread David Cournapeau
Charles R Harris wrote: Here is a link to the start of the old discussion http://article.gmane.org/gmane.comp.python.numeric.general/12974/match=exported+symbols+code+reorganization. You took part in it also. Thanks, I remembered we had the discussion, but could not find it. The different

Re: [Numpy-discussion] Linker script, smaller source files and symbol visibility

2009-04-20 Thread Charles R Harris
On Mon, Apr 20, 2009 at 10:13 PM, David Cournapeau da...@ar.media.kyoto-u.ac.jp wrote: Charles R Harris wrote: Here is a link to the start of the old discussion http://article.gmane.org/gmane.comp.python.numeric.general/12974/match=exported+symbols+code+reorganization . You took