Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Sturla Molden
Den 13.06.2010 05:47, skrev David Cournapeau: > > This only works in simple cases. What do you do when you don't know > the output size ? First: If you don't know, you don't know. Then you're screwed and C is not going to help. Second: If we cannot figure out how much to allocate before starting

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread David Cournapeau
On Sun, Jun 13, 2010 at 11:39 AM, Sturla Molden wrote: > If NumPy does not allocate memory on it's own, there will be no leaks > due to errors in NumPy. > > There is still work to do in the core, i.e. the computational loops in > array operators, broadcasting, ufuncs, copying data between buffers

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Sturla Molden
Den 13.06.2010 02:39, skrev David Cournapeau: > > But the point is to get rid of the python dependency, and if you don't > allow any api call to allocate memory, there is not much left to > implement in the core. > > Memory allocation is platform dependent. A CPython version could use bytearr

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread David Cournapeau
On Sun, Jun 13, 2010 at 2:00 AM, Sturla Molden wrote: > Den 12.06.2010 15:57, skrev David Cournapeau: >> Anything non trivial will require memory allocation and object >> ownership conventions. If the goal is interoperation with other >> languages and vm, you may want to use something else than pl

[Numpy-discussion] PyArray_Scalar() and Unicode

2010-06-12 Thread Dan Roberts
I apologize ahead of time for anything I might be totally missing, but in order to make PyArray_Scalar() work on non-CPython interpreters, it's necessary for me to significantly refactor that function. I've made (untested but correct looking) changes to the function to handle all of the data types

Re: [Numpy-discussion] Tensor contraction

2010-06-12 Thread Pauli Virtanen
Sat, 12 Jun 2010 16:30:14 -0400, Alan Bromborsky wrote: > If I have a single numpy array, for example with 3 indices T_{ijk} and I > want to sum over two them in the sense of tensor contraction - > > T_{k} = \sum_{i=0}^{n-1} T_{iik}. Is there an easy way to do this with > numpy? HTH, (not really

Re: [Numpy-discussion] Tensor contraction

2010-06-12 Thread Pauli Virtanen
Sat, 12 Jun 2010 23:15:16 +0200, Friedrich Romstedt wrote: [clip] > But note that for: > T[:, I, I] > the shape is reversed with respect to that of: > T[I, :, I] and T[I, I, :] . > > I think it should be written in the docs how the shape is derived. It's explained there in detail (although mayb

Re: [Numpy-discussion] Tensor contraction

2010-06-12 Thread Alan Bromborsky
Friedrich Romstedt wrote: > 2010/6/12 Alan Bromborsky : > >> If I have a single numpy array, for example with 3 indices T_{ijk} and I >> want to sum over two them in the sense of tensor contraction - >> >> T_{k} = \sum_{i=0}^{n-1} T_{iik}. Is there an easy way to do this with >> numpy? >>

Re: [Numpy-discussion] Tensor contraction

2010-06-12 Thread Friedrich Romstedt
2010/6/12 Alan Bromborsky : > If I have a single numpy array, for example with 3 indices T_{ijk} and I > want to sum over two them in the sense of tensor contraction - > > T_{k} = \sum_{i=0}^{n-1} T_{iik}.  Is there an easy way to do this with > numpy? Also you can give: T[I, I, :].sum(axis=0) a

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Charles R Harris
On Sat, Jun 12, 2010 at 2:56 PM, Dag Sverre Seljebotn < da...@student.matnat.uio.no> wrote: > Charles Harris wrote: > > On Sat, Jun 12, 2010 at 11:38 AM, Dag Sverre Seljebotn < > > da...@student.matnat.uio.no> wrote: > > > >> Christopher Barker wrote: > >> > David Cournapeau wrote: > >> >>> In the

Re: [Numpy-discussion] Tensor contraction

2010-06-12 Thread josef . pktd
On Sat, Jun 12, 2010 at 4:30 PM, Alan Bromborsky wrote: > If I have a single numpy array, for example with 3 indices T_{ijk} and I > want to sum over two them in the sense of tensor contraction - > > T_{k} = \sum_{i=0}^{n-1} T_{iik}.  Is there an easy way to do this with > numpy? looking at numpy

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Dag Sverre Seljebotn
Charles Harris wrote: > On Sat, Jun 12, 2010 at 11:38 AM, Dag Sverre Seljebotn < > da...@student.matnat.uio.no> wrote: > >> Christopher Barker wrote: >> > David Cournapeau wrote: >> >>> In the core C numpy library there would be new "numpy_array" struct >> >>> with attributes >> >>> >> >>> numpy_

[Numpy-discussion] Tensor contraction

2010-06-12 Thread Alan Bromborsky
If I have a single numpy array, for example with 3 indices T_{ijk} and I want to sum over two them in the sense of tensor contraction - T_{k} = \sum_{i=0}^{n-1} T_{iik}. Is there an easy way to do this with numpy? ___ NumPy-Discussion mailing list Num

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Sebastian Walter
On Sat, Jun 12, 2010 at 3:57 PM, David Cournapeau wrote: > On Sat, Jun 12, 2010 at 10:27 PM, Sebastian Walter > wrote: >> On Thu, Jun 10, 2010 at 6:48 PM, Sturla Molden wrote: >>> >>> I have a few radical suggestions: >>> >>> 1. Use ctypes as glue to the core DLL, so we can completely forget abo

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Benjamin Root
If I could, I would like to throw out another possible feature that might need to be taken into consideration for designing the implementation of numpy arrays. One thing I found somewhat lacking -- if that is the right term -- is a way to convolve a numpy array with an arbitrary windowing element.

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Francesc Alted
2010/6/12 Charles R Harris > > This is more the way I see things, except I would divide the bottom layer > into two parts, views and memory. The memory can come from many places -- > memmaps, user supplied buffers, etc. -- but we should provide a simple > reference counted allocator for the defau

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Charles R Harris
On Sat, Jun 12, 2010 at 1:35 PM, Charles R Harris wrote: > > > On Sat, Jun 12, 2010 at 11:38 AM, Dag Sverre Seljebotn < > da...@student.matnat.uio.no> wrote: > >> Christopher Barker wrote: >> > David Cournapeau wrote: >> >>> In the core C numpy library there would be new "numpy_array" struct >>

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Charles R Harris
On Sat, Jun 12, 2010 at 11:38 AM, Dag Sverre Seljebotn < da...@student.matnat.uio.no> wrote: > Christopher Barker wrote: > > David Cournapeau wrote: > >>> In the core C numpy library there would be new "numpy_array" struct > >>> with attributes > >>> > >>> numpy_array->buffer > > > >> Anything n

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Dag Sverre Seljebotn
Christopher Barker wrote: > David Cournapeau wrote: >>> In the core C numpy library there would be new "numpy_array" struct >>> with attributes >>> >>> numpy_array->buffer > >> Anything non trivial will require memory allocation and object >> ownership conventions. > > I totally agree -- I've bee

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Christopher Barker
David Cournapeau wrote: >> In the core C numpy library there would be new "numpy_array" struct >> with attributes >> >> numpy_array->buffer > Anything non trivial will require memory allocation and object > ownership conventions. I totally agree -- I've been thinking for a while about a core ar

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Sturla Molden
Den 12.06.2010 15:57, skrev David Cournapeau: > Anything non trivial will require memory allocation and object > ownership conventions. If the goal is interoperation with other > languages and vm, you may want to use something else than plain > malloc, to interact better with the allocation strateg

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread David Cournapeau
On Sat, Jun 12, 2010 at 10:27 PM, Sebastian Walter wrote: > On Thu, Jun 10, 2010 at 6:48 PM, Sturla Molden wrote: >> >> I have a few radical suggestions: >> >> 1. Use ctypes as glue to the core DLL, so we can completely forget about >> refcounts and similar mess. Why put manual reference counting

Re: [Numpy-discussion] NumPy re-factoring project

2010-06-12 Thread Sebastian Walter
On Thu, Jun 10, 2010 at 6:48 PM, Sturla Molden wrote: > > I have a few radical suggestions: > > 1. Use ctypes as glue to the core DLL, so we can completely forget about > refcounts and similar mess. Why put manual reference counting and error > handling in the core? It's stupid. I totally agree,