numpy / numpy/numpy

nditer usage with index and buffered flags

Open
#14,168 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

00 - Bug component: numpy._core
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

When using a nditer with any kind of index flag like 'c_index', 'f_index' or 'multi_index', the index will always be zero if the 'buffered' flag is used as well. If this is intended behavior, it does not seem to be documented though.

Reproducing code example:
a = np.arange(4*4*3).reshape(4,4,3)
it = np.nditer(a, flags=['multi_index', 'buffered'])
while not it.finished:
    print(it.multi_index)
    it.iternext()
Numpy/Python version information:

numpy version: 1.17.0
python version: 3.7.4 (default, Jul 9 2019, 18:13:23) [Clang 10.0.1 (clang-1001.0.46.4)]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided nditer example with the reported NumPy and Python versions, then trace the nditer handling for the multi_index, c_index, f_index, and buffered flags. Determine whether the zero indices are intended or incorrect, and finish by documenting the behavior or adding a regression test and fix based on that decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.