I have a pull request for a neighborhood function at https://github.com/numpy/numpy/pull/303 . I think IMHO it handles these problems quite handily. It does rely on my pad routine that is in Numpy 1.7, so you would need to get the 1.7 beta installed or install the development branch.
For your example you would just create a weight array, and a function that returns a scalar value from the collected neighborhood values. Untested, but workflow is something like: >>> inputarr = np.random.random(9*9*9) >>> inputarr = inputarr.reshape((9,9,9)) >>> weight = np.ones((3,3,3)) >>> ans = neighbor(inputarr, weight, np.mean, pad = None) In place of 'np.mean' you can define your own function - game of life function for example. The PR has not had much activity, so if you can review/comment/program that would be appreciated. Kindest regards, Tim
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion