<br><br>On Sat, Jun 13, 2009 at 7:46 AM, David Cournapeau <<a href="mailto:david@ar.media.kyoto-u.ac.jp">david@ar.media.kyoto-u.ac.jp</a>> wrote:<br>><br>> Hi,<br>><br>>    I have cleaned up a bit the code, and would like to suggest the<br>
> inclusion of a neighborhood iterator for numpy. Stéfan took a look at it<br>> already, but it needs more eyeballs. It is a "subclass" of<br>> PyArrayIterObject, and can be used to iterate over a neighborhood of a<br>
> point (handling boundaries with 0 padding for the time being).<br>><br>> <a href="http://codereview.appspot.com/75055/show">http://codereview.appspot.com/75055/show</a><br>><br>> I have used it to replace the current for code correlateND in<br>
> scipy.signal, where it works quite well (I think it makes the code more<br>> readable in that case).<br><br>Some nitpicks:<br><br>1) The name neigh sounds like a horse. Maybe region,  neighborhood, or something similar would be better.<br>
<br>2) Is PyObject_Init NULL safe?<br><br><span style="font-family: courier new,monospace;">ret = PyArray_malloc(sizeof(*ret));</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">+    PyObject_Init((PyObject*)ret,&PyArrayNeighIter_Type);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">+    if (ret == NULL) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">+        return NULL;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">+    }</span><br style="font-family: courier new,monospace;"><br>3) Documentation is needed. In particular, I think it worth mentioning that the number of bounds is taken from the PyArrayIterObject, which isn't the most transparent thing.<br>
<br>Otherwise, looks good.<br><br>Chuck<br><br>