From 4ada386d9f7624b87356bb11646d44e2f58657c9 Mon Sep 17 00:00:00 2001 From: Marco Aurelio da Costa Date: Tue, 8 Jun 2021 13:14:49 -0300 Subject: DOC: NeighborhoodIterator position on creation Document that NeighborhoodIterator will point to the begining of the data instead of the position pointed by iter on creation in the special case where data is contiguous. --- doc/source/reference/c-api/array.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'doc/source/reference/c-api/array.rst') diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst index 1673f1d6b..cb2f4b645 100644 --- a/doc/source/reference/c-api/array.rst +++ b/doc/source/reference/c-api/array.rst @@ -2647,6 +2647,12 @@ cost of a slight overhead. - If the position of iter is changed, any subsequent call to PyArrayNeighborhoodIter_Next is undefined behavior, and PyArrayNeighborhoodIter_Reset must be called. + - If the position of iter is not the beginning of the data and the + underlying data for iter is contiguous, the iterator will point to the + start of the data instead of position pointed by iter. + To avoid this situation, iter should be moved to the required position + only after the creation of iterator, and PyArrayNeighborhoodIter_Reset + must be called. .. code-block:: c @@ -2656,7 +2662,7 @@ cost of a slight overhead. /*For a 3x3 kernel */ bounds = {-1, 1, -1, 1}; - neigh_iter = (PyArrayNeighborhoodIterObject*)PyArrayNeighborhoodIter_New( + neigh_iter = (PyArrayNeighborhoodIterObject*)PyArray_NeighborhoodIterNew( iter, bounds, NPY_NEIGHBORHOOD_ITER_ZERO_PADDING, NULL); for(i = 0; i < iter->size; ++i) { -- cgit v1.2.1