[Numpy-discussion] thread safe subclasses of ndarray

2007-02-06 Thread Matt Knox
Sturla Molden brought up a point in an earlier thread ("Please help with subclassing numpy.ndarray") that I think is worth highlighting. A "common" approach to subclassing ndarray in python (http://www.scipy.org/Subclasses) results in code that is not thread safe. This approach involves setting

[Numpy-discussion] importing multiarraymodule.c in Python embedding

2007-02-06 Thread Steele, Greg
I have run into an interesting issue with multiarraymodule.c with regards to embedding Python in a C application on Windows XP. In the application, the following abbreviated sequence was executed 1) Py_Initialize 2) numpy is imported 3) Py_Finalize 4) Py_Initialize 5) attempt to import nump

[Numpy-discussion] bug in numpy.equal?

2007-02-06 Thread Tom Denniston
The behavior below seems strange to me. The string array is type S3 yet it says that comparison with 'abc' is not implemented. The == operator seems to work though. Is there a subtlty I am missing or is it simply a bug? In [1]: import numpy In [2]: numpy.equal(numpy.array(['abc', 'def']), 'a

Re: [Numpy-discussion] memmap on 64bit Linux for > 2 GB files

2007-02-06 Thread Sebastian Haase
Of course ! Now I remember why I didn't test it yet... Thanks, -Sebastian On 2/6/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Sebastian Haase wrote: > > Hi, > > I finally tried to do the test, to memmap a large file > > filesize: 2.8G > > > > a memmap call gives this error: > > > > {{{ > N.m

Re: [Numpy-discussion] memmap on 64bit Linux for > 2 GB files

2007-02-06 Thread Robert Kern
Sebastian Haase wrote: > Hi, > I finally tried to do the test, to memmap a large file > filesize: 2.8G > > a memmap call gives this error: > > {{{ N.memmap('20050622-1648-Y_DEMO-1') > Traceback (most recent call last): > File "", line 1, in ? > File "/jws30/haase/PrLinN64/numpy/core/memm

[Numpy-discussion] memmap on 64bit Linux for > 2 GB files

2007-02-06 Thread Sebastian Haase
Hi, I finally tried to do the test, to memmap a large file filesize: 2.8G a memmap call gives this error: {{{ >>> N.memmap('20050622-1648-Y_DEMO-1') Traceback (most recent call last): File "", line 1, in ? File "/jws30/haase/PrLinN64/numpy/core/memmap.py", line 67, in __new__ mm = mmap.mm

Re: [Numpy-discussion] numpy.matlib.abs

2007-02-06 Thread Keith Goodman
On 2/6/07, Paulo J. S. Silva <[EMAIL PROTECTED]> wrote: > Em Dom, 2007-02-04 às 17:28 -0800, Keith Goodman escreveu: > > > Could numpy.matlib get the same functions as numpy? Would that have to > > be done with a manually maintained import list? > > I always use "import numpy.matlib as M" and then

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-06 Thread Sturla Molden
> I don't pretend to know all the inner workings of subclassing, but I > don't think that would work, given the following output: > In [6]: x+y > This is where __array_finalize__ is called > Out[6]: MyArray([4, 5, 6]) Why is not __new__ called for the return value of x + y? Does it call __new__

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-06 Thread Sturla Molden
> Yes using __init__ to set an instance attribute is the Pythonic way to > do this. However, I calculate/create the data in __new__. The data > is unavailable to __init__. The signatures of __new__ and __init__ is: def __new__(cls, *args, **kwds) def __init__(self, *args, **kwds) If __new__ h

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-06 Thread Jeremy Conlin
On 2/6/07, Sturla Molden <[EMAIL PROTECTED]> wrote: > > > def __new__(cls,...) > > ... > > (H, edges) = numpy.histogramdd(..) > > cls.__defaultedges = edges > > > > def __array_finalize__(self, obj): > > if not hasattr(self, 'edges'): > > self.edges = self.__defaultedges >

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-06 Thread Stefan van der Walt
On Tue, Feb 06, 2007 at 01:06:37PM +0100, Sturla Molden wrote: > > > def __new__(cls,...) > > ... > > (H, edges) = numpy.histogramdd(..) > > cls.__defaultedges = edges > > > > def __array_finalize__(self, obj): > > if not hasattr(self, 'edges'): > > self.edges = self.__de

Re: [Numpy-discussion] Please help with subclassing numpy.ndarray

2007-02-06 Thread Sturla Molden
> def __new__(cls,...) > ... > (H, edges) = numpy.histogramdd(..) > cls.__defaultedges = edges > > def __array_finalize__(self, obj): > if not hasattr(self, 'edges'): > self.edges = self.__defaultedges So in order to get an instance attribute, one has to temporarily defi

Re: [Numpy-discussion] numpy.matlib.abs

2007-02-06 Thread Paulo J. S. Silva
Em Dom, 2007-02-04 às 17:28 -0800, Keith Goodman escreveu: > Could numpy.matlib get the same functions as numpy? Would that have to > be done with a manually maintained import list? > I always use "import numpy.matlib as M" and then search for function > names in ipython (M.a[TAB]). I didn't reali