8000 Python nditer should reinsert removed axes into its iteration results · Issue #9808 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Python nditer should reinsert removed axes into its iteration results #9808
Open
@eric-wieser

Description

@eric-wieser

When iterating using C, all that's returned is a pointer to the start of the array, and it's the users job to index it with their own memory of its strides and dimensions (like what happens in the gufunc inner loops).

However, the python nditer[i] API always returns 0d arrays, and does not produce a view over the axes that were removed.

My feeling is that this:

a = np.array([[1, 2], [3, 4]])
b = np.array([[10, 20], [30, 40]])

it = np.nditer((a, b), op_axes=[[0], [0]])

while not it.finished:
    print(i.value)
    it.iternext()

should output

(array([1, 2]), array([10, 20]))
(array([3, 4]), array([30, 40]))

whereas it outputs at the moment

(array(1), array(10))
(array(3), array(30))

Can someone with a better understanding of NdIter confirm that my intuition is correct here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0