Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-25 Thread Andrea Gavana
Hi Stefan & All, On Sun, May 25, 2008 at 8:59 PM, Stéfan van der Walt wrote: > Hi Andrea > > 2008/5/25 Andrea Gavana <[EMAIL PROTECTED]>: >>> When you bench the Cython code, you'll have to take out the Python >>> calls (for checking dtype etc.), otherwise you're comparing apples and >>> oranges.

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-25 Thread Stéfan van der Walt
Hi Andrea 2008/5/25 Andrea Gavana <[EMAIL PROTECTED]>: >> When you bench the Cython code, you'll have to take out the Python >> calls (for checking dtype etc.), otherwise you're comparing apples and >> oranges. After I tweaked it, it ran roughly the same time as >> Francesc's version. But like I

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-25 Thread Andrea Gavana
Hi Stefan & All, On Sat, May 24, 2008 at 8:11 PM, Stéfan van der Walt wrote: > Hi Andrea > > 2008/5/24 Andrea Gavana <[EMAIL PROTECTED]>: >> Number Of Cells: 5 >> - >> | Rank | Method Name | Exe

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-24 Thread Stéfan van der Walt
Hi Andrea 2008/5/24 Andrea Gavana <[EMAIL PROTECTED]>: > Number Of Cells: 5 > - > | Rank | Method Name | Execution Time | Relative Slowness | > --

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-24 Thread Andrea Gavana
Hi All, On Fri, May 23, 2008 at 4:50 PM, Andrea Gavana wrote: > Hi Peter & All, > > On Fri, May 23, 2008 at 4:16 PM, Peter Creasey wrote: >> Hi Andrea, >> >> 2008/5/23 "Andrea Gavana" <[EMAIL PROTECTED]>: >>> And so on. The probelm with this approach is that I lose the original >>> indices for wh

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-23 Thread Andrea Gavana
Hi Peter & All, On Fri, May 23, 2008 at 4:16 PM, Peter Creasey wrote: > Hi Andrea, > > 2008/5/23 "Andrea Gavana" <[EMAIL PROTECTED]>: >> And so on. The probelm with this approach is that I lose the original >> indices for which I want all the inequality tests to succeed: > > To have the original

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-23 Thread Peter Creasey
Hi Andrea, 2008/5/23 "Andrea Gavana" <[EMAIL PROTECTED]>: > And so on. The probelm with this approach is that I lose the original > indices for which I want all the inequality tests to succeed: To have the original indices you just need to re-index your indices, as it were idx = flatnonzero(xCe

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-23 Thread Andrea Gavana
Hi Stefan & All, On Fri, May 23, 2008 at 1:02 AM, Stéfan van der Walt wrote: > Hi Andrea > > 2008/5/23 Andrea Gavana <[EMAIL PROTECTED]>: >> Thank you very much for this! I am going to try it and time it, >> comparing it with the other implementations. I think I need to study a >> bit your code as

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Stéfan van der Walt
Hi Andrea 2008/5/23 Andrea Gavana <[EMAIL PROTECTED]>: > Thank you very much for this! I am going to try it and time it, > comparing it with the other implementations. I think I need to study a > bit your code as I know almost nothing about Cython :-D That won't be necessary -- the Fortran-implem

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Andrea Gavana
Hi Stefan, On Thu, May 22, 2008 at 10:23 PM, Stéfan van der Walt wrote: > Hi Andrea > > 2008/5/22 Andrea Gavana <[EMAIL PROTECTED]>: >> By the way, about the solution Francesc posted: >> >> xyzReq = (xCent >= xMin) & (xCent <= xMax) & \ >>(yCent >= yMin) & (yCent <= yMax) & \ >>

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Andrea Gavana
Hi Chris and All, On Thu, May 22, 2008 at 8:40 PM, Christopher Barker wrote: > Andrea Gavana wrote: >> By the way, about the solution Francesc posted: >> >> xyzReq = (xCent >= xMin) & (xCent <= xMax) & \ >> (yCent >= yMin) & (yCent <= yMax) & \ >> (zCent >= zMin) & (zCent

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Christopher Barker
Stéfan van der Walt wrote: > I wrote a quick proof of concept (no guarantees). Thanks for the example -- I like how Cython understands ndarrays! It looks like this code would break if x,y,and z are not C-contiguous -- should there be a check for that? -Chris > here (download using bzr, http:

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Stéfan van der Walt
Hi Andrea 2008/5/22 Andrea Gavana <[EMAIL PROTECTED]>: > By the way, about the solution Francesc posted: > > xyzReq = (xCent >= xMin) & (xCent <= xMax) & \ >(yCent >= yMin) & (yCent <= yMax) & \ >(zCent >= zMin) & (zCent <= zMax) > > xyzReq = numpy.nonzero(xyzReq)[0] > >

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Nathan Bell
On Thu, May 22, 2008 at 2:16 PM, Andrea Gavana <[EMAIL PROTECTED]> wrote: > By the way, about the solution Francesc posted: > > xyzReq = (xCent >= xMin) & (xCent <= xMax) & \ >(yCent >= yMin) & (yCent <= yMax) & \ >(zCent >= zMin) & (zCent <= zMax) > You could implement t

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Christopher Barker
Andrea Gavana wrote: > By the way, about the solution Francesc posted: > > xyzReq = (xCent >= xMin) & (xCent <= xMax) & \ > (yCent >= yMin) & (yCent <= yMax) & \ > (zCent >= zMin) & (zCent <= zMax) > > xyzReq = numpy.nonzero(xyzReq)[0] > > Do you think is there any chan

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Andrea Gavana
Hi All, On Thu, May 22, 2008 at 7:46 PM, Robert Kern wrote: > On Thu, May 22, 2008 at 12:26 PM, Stéfan van der Walt <[EMAIL PROTECTED]> > wrote: >> Just to clarify things in my mind: is VTK *that* slow? I find that >> surprising, since it is written in C or C++. > > Performance can depend more

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Robert Kern
On Thu, May 22, 2008 at 12:26 PM, Stéfan van der Walt <[EMAIL PROTECTED]> wrote: > Just to clarify things in my mind: is VTK *that* slow? I find that > surprising, since it is written in C or C++. Performance can depend more on the design of the code than the implementation language. There are se

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Stéfan van der Walt
Hi Andrea 2008/5/22 Andrea Gavana <[EMAIL PROTECTED]>: >> You clearly have a large dataset, otherwise speed wouldn't have been a >> concern to you. You can do your operation in one pass over the data, >> and I'd suggest you try doing that with Cython or Ctypes. If you need >> an example on how t

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Travis E. Oliphant
Alan G Isaac wrote: > On Thu, 22 May 2008, Andrea Gavana apparently wrote: > >> # Filter cells which do not satisfy Z requirements: >> zReq = zMin <= zCent <= zMax >> > > This seems to raise a question: > should numpy arrays support this standard Python idiom? > It would be nice, but al

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Andrea Gavana
Hi Francesc & All, On Thu, May 22, 2008 at 1:04 PM, Francesc Alted wrote: > I don't know if this is what you want, but you can get the boolean > arrays separately, do the intersection and finally get the interesting > values (by using fancy indexing) or coordinates (by using .nonzero()). > Here it

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Angus McMorland
2008/5/22 Andrea Gavana <[EMAIL PROTECTED]>: > Hi All, > >I am building some 3D grids for visualization starting from a much > bigger grid. I build these grids by satisfying certain conditions on > x, y, z coordinates of their cells: up to now I was using VTK to > perform this operation, but VT

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Alan G Isaac
On Thu, 22 May 2008, Andrea Gavana apparently wrote: > # Filter cells which do not satisfy Z requirements: > zReq = zMin <= zCent <= zMax This seems to raise a question: should numpy arrays support this standard Python idiom? Cheers, Alan Isaac ___

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Francesc Alted
A Thursday 22 May 2008, Andrea Gavana escrigué: > Hi All, > > I am building some 3D grids for visualization starting from a > much bigger grid. I build these grids by satisfying certain > conditions on x, y, z coordinates of their cells: up to now I was > using VTK to perform this operation, bu

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Andrea Gavana
Hi Stefan & All, On Thu, May 22, 2008 at 12:29 PM, Stéfan van der Walt wrote: > Hi Andrea > > 2008/5/22 Andrea Gavana <[EMAIL PROTECTED]>: >>I am building some 3D grids for visualization starting from a much >> bigger grid. I build these grids by satisfying certain conditions on >> x, y, z coo

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Stéfan van der Walt
Hi Andrea 2008/5/22 Andrea Gavana <[EMAIL PROTECTED]>: >I am building some 3D grids for visualization starting from a much > bigger grid. I build these grids by satisfying certain conditions on > x, y, z coordinates of their cells: up to now I was using VTK to > perform this operation, but VTK