Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: Add a new flag to nditer to indicate when op uses buffering
Thouis tracked down an intermittently occurring bug in ticket numpy#2144, where a reduction under certain situations would produce wrong results. This occurs when the array data and the nditer's buffer happen to be adjacent in memory. This fixes it by replacing the "clever" trick of checking if the iterator's pointer is in the buffer with an explicit flag to signal buffer usage. The reason this can't be reliably handled via the pointer/buffer check is that the pointer updates are handled by the consumer of the iterator, who may update them in place or may use local variables instead. Thus, the pointer could still point to the beginning of the buffer, or could point at the byte immediately after the buffer. Using a flag avoids all of this and should be reliable.
- Loading branch information