Skip to content

Allow iteration on 1-D arrays #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2024
Merged

Conversation

asmeurer
Copy link
Member

@asmeurer asmeurer commented Jul 1, 2024

upstream code (see scipy/scipy#21074). The standard does not define iteration, but it does define __getitem__, and the default Python __iter__ implements iteration when getitem is defined as a[0], a[1], ..., implying that iteration ought to work for 1-D arrays. Iteration is still disallowed for higher dimensional arrays, since getitem would not necessarily work with a single integer index (and this is the case that is controversial). In those cases, the new unstack() function would be preferable.

At best it would be good to get upstream clarification from the standard whether iteration should always work or not before disallowing 1-D array iteration.

upstream code (see scipy/scipy#21074). The standard does not define iteration,
but it does define __getitem__, and the default Python __iter__ implements
iteration when getitem is defined as a[0], a[1], ..., implying that iteration
ought to work for 1-D arrays. Iteration is still disallowed for higher
dimensional arrays, since getitem would not necessarily work with a single
integer index (and this is the case that is controversial). In those cases,
the new unstack() function would be preferable.

At best it would be good to get upstream clarification from the standard
whether iteration should always work or not before disallowing 1-D array
iteration.
@asmeurer asmeurer enabled auto-merge July 1, 2024 19:33
@asmeurer asmeurer temporarily deployed to publish-package July 1, 2024 19:34 — with GitHub Actions Inactive
@asmeurer asmeurer merged commit 6b0079b into data-apis:main Jul 1, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant