[Numpy-discussion] Multidimensional neighbours
Thu Aug 16 14:41:09 CDT 2012
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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion