[Numpy-discussion] Hierarchical vs non-hierarchical ndarray.base and __array_interface__

2012-11-24 Thread Gamblin, Todd
Hi all, I posted on the change in semantics of ndarray.base here: https://github.com/numpy/numpy/commit/6c0ad59#commitcomment-2153047 And some folks asked me to post my question to the numpy mailing list. I've implemented a tool for mapping processes in parallel applications to nodes

[Numpy-discussion] Z-ordering (Morton ordering) for numpy

2012-11-24 Thread Gamblin, Todd
Hi all, In the course of developing a network mapping tool I'm working on, I also developed some python code to do arbitrary-dimensional z-order (morton order) for ndarrays. The code is here: https://github.com/tgamblin/rubik/blob/master/rubik/zorder.py There is a function to put the

Re: [Numpy-discussion] Z-ordering (Morton ordering) for numpy

2012-11-24 Thread Travis Oliphant
This is pretty cool.Something like this would be interesting to play with. There are some algorithms that are faster with z-order arrays.The code is simple enough and small enough that I could see putting it in NumPy. What do others think? -Travis On Nov 24, 2012, at 1:03 PM,

Re: [Numpy-discussion] Z-ordering (Morton ordering) for numpy

2012-11-24 Thread Aron Ahmadia
Todd, I am optimistic and I think it would be a good idea to put this in. A couple previous studies [1] haven't found any useful speedups from in-core applications for Morton-order, and if you have results for real scientific applications using numpy this would not only be great, but the

Re: [Numpy-discussion] Z-ordering (Morton ordering) for numpy

2012-11-24 Thread Gamblin, Todd
So, just FYI, my usage of this is for Rubik, where it's a communication latency optimization for the code being mapped to the network. I haven't tested it as an optimization for particular in-core algorithms. However, there was some work on this at LLNL maybe a couple years ago -- I think it

[Numpy-discussion] numpy where function on different sized arrays

2012-11-24 Thread Siegfried Gonzi
Hi all This must have been answered in the past but my google search capabilities are not the best. Given an array A say of dimension 40x60 and given another array/vector B of dimension 20 (the values in B occur only once). What I would like to do is the following which of course does not

Re: [Numpy-discussion] numpy where function on different size

2012-11-24 Thread Siegfried Gonzi
Message: 6 Date: Sat, 24 Nov 2012 20:36:45 + From: Siegfried Gonzi sgo...@staffmail.ed.ac.uk Subject: [Numpy-discussion] numpy where function on different size Hi all This must have been answered in the past but my google search capabilities are not the best. Given an array A say of

Re: [Numpy-discussion] numpy where function on different sized arrays

2012-11-24 Thread David Warde-Farley
M = A[..., np.newaxis] == B will give you a 40x60x20 boolean 3d-array where M[..., i] gives you a boolean mask for all the occurrences of B[i] in A. If you wanted all the (i, j) pairs for each value in B, you could do something like import numpy as np from itertools import izip, groupby from

Re: [Numpy-discussion] numpy where function on different sized arrays

2012-11-24 Thread Daπid
A pure Python approach could be: for i, x in enumerate(a): for j, y in enumerate(x): if y in b: idx.append((i,j)) Of course, it is slow if the arrays are large, but it is very readable, and probably very fast if cythonised. David. On Sat, Nov

Re: [Numpy-discussion] Z-ordering (Morton ordering) for numpy

2012-11-24 Thread Charles R Harris
On Sat, Nov 24, 2012 at 1:30 PM, Gamblin, Todd gambl...@llnl.gov wrote: So, just FYI, my usage of this is for Rubik, where it's a communication latency optimization for the code being mapped to the network. I haven't tested it as an optimization for particular in-core algorithms. However,

Re: [Numpy-discussion] numpy where function on different sized arrays

2012-11-24 Thread David Warde-Farley
I think that would lose information as to which value in B was at each position. I think you want: On Sat, Nov 24, 2012 at 5:23 PM, Daπid davidmen...@gmail.com wrote: A pure Python approach could be: for i, x in enumerate(a): for j, y in enumerate(x): if y in b:

Re: [Numpy-discussion] numpy where function on different sized arrays

2012-11-24 Thread David Warde-Farley
On Sat, Nov 24, 2012 at 7:08 PM, David Warde-Farley d.warde.far...@gmail.com wrote: I think that would lose information as to which value in B was at each position. I think you want: (premature send, stupid Gmail...) idx = {} for i, x in enumerate(a): for j, y in enumerate(x):