iterators are confusing
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- data, developer-experience
Research direction
Start with the ArrayBase documentation and the axis_iter(), par_iter(), indexed_iter(), IndexedIter, and Zip entry points named in the issue. Review how into_par_iter() and enumerate() are currently exposed, then seek maintainer guidance on which iterator APIs or documentation changes are wanted. Done means an agreed scope is implemented and the relevant iterator behavior and documentation are covered.
Written by the indexing model from the issue text.
Description
The current framework for iteration over arrays is confusing. Issue edited because it's even more confusing than at first glance!
Common scenarios for iteration include:
- Iterating over the elements of an array
- Iterating over subviews along an axis of an array
- Iterating mutably
- Indexed iteration
- Iterating over multiple arrays in lockstep
- Parallel iteration with Rayon
Users may expect some consistent idioms with regard to how these different iterators are accessed. The ArrayBase documentation is the starting point for many users. It is currently non-obvious (at least to me) that:
- We can iterate over subviews along an axis in parallel.
Because there isArrayBase::par_iter()but notArrayBase::par_axis_iter(). - We can have indexed iterators over subview along an axis.
Because there isArrayBase::indexed_iter()but notArrayBase::indexed_axis_iter().
I may be missing it, but it appears there is no currently no way to:
- Get a parallel version of
IndexedIterwithout the overhead ofZip::indexed(). - Get a (non-parallel)
IteratorfromZip.
There are good reasons for some of these idiosyncrasies (e.g. expeditious blanket impls), but they still steepen ndarray's learning curve. Ways to address this would include:
- Adding hints about
into_par_iter()andenumerate()to the documentation forArrayBase::axis_iter().
Or adding corresponding convenience methodsArrayBase::indexed_axis_iter(). - Implementing
IntoParallelIteratorforIndexedIter.
Assuming it can be more efficient thanZip::indexed(). - Implementing
IntoIteratorforZip.
What are the maintainers' views on these ideas? I would be happy to contribute pull requests with some guidance.
- Dominant language
- Rust
- Stars
- 4.3k
- Forks
- 391
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-ndarray/ndarray
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-ndarray/ndarray#1612 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
rust-ndarray/ndarray#1617 · 1 comment ·
-
bug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 68/100
rust-ndarray/ndarray#1615 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
rust-ndarray/ndarray#1610 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
rust-ndarray/ndarray#1609 ·
All issues in rust-ndarray/ndarray
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100