Skip to content

doc: rewrite slice basic-indexing docs, accept 1-tuple indexers - #117

Merged
ajz34 merged 2 commits into
RESTGroup:mainfrom
ajz34:261006/doc-slice-basic-indexing
Oct 6, 2026
Merged

ajz34 merged 2 commits into
RESTGroup:mainfrom
ajz34:261006/doc-slice-basic-indexing

Conversation

@ajz34

@ajz34 ajz34 commented Oct 6, 2026

Copy link
Copy Markdown
Member

Changes

New features

  • AxesIndex conversions accept one-element tuples: a.i((1..4,)) indexes like
    a.i(1..4), and (3,) works as a 1-D shape/axes list, matching arities 2-10.

Enhancement

  • Rewrite the slice basic-indexing documentation around the preferred
    tensor.i() + tuple call forms, as a standalone src/docs/basic_indexing.md
    attached to the anchor by include_str! (first crate docs page authored this
    way).

Details

  • All examples are byte-verified through the doc_draft twins
    (tests/doc_draft/indexing), including NumPy-parity of newaxis/ellipsis
    placement against the pinned NumPy 2.5.2.
  • Documented intentional surface differences are recorded in
    tests/tracking/numpy_differences.md: no inclusive (..=) bounds, and
    Some(n) as an indexer always panics. The previously missing
    one-element-tuple form is resolved by the rstsr-common commit here (a
    single TryFrom<(F1,)> macro arm; no coherence conflicts).
  • Compile-error tips (..=, &Vec, += on i_mut, chained temporaries) use
    compile_fail fences with pasted real diagnostics.

PR summarized by Claude Code noreply@anthropic.com, glm-5.3 service@zhipuai.cn

ajz34 and others added 2 commits October 6, 2026 20:21
Add TryFrom<(F1,)> to impl_from_tuple_to_axes_index!, mirroring the
arity 2-10 arms, so `(1..4,)` indexes like `1..4` for AxesIndex<Indexer>
and `(3,)` works as a 1-D shape/axes list for AxesIndex<isize>/<usize>.
Unit test test_one_tuple_index covers both paths through dim_slice.

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: glm-5.3 <service@zhipuai.cn>
…g.md

Move the slice anchor docstring into a standalone markdown attached by
include_str!, rewritten around the preferred tensor.i() + tuple call
forms: overloads table (per-axis indexers, whole-index forms), easy
first steps then elaborated sections (ranges/clamping, stepped slices
and reversal, integer selection, None/NewAxis placement, Ellipsis,
view/layout semantics, contiguity and to_contig, into_slice, chaining,
mutable writes incl. the *&mut place idiom, runtime values), an
ownership table, and compile-error tips (..=, &Vec, += on i_mut,
chained temporaries) with compile_fail + pasted diagnostics.

All examples are byte-verified through the doc_draft twins
(doc_slice* in tests/doc_draft/indexing), incl. NumPy 2.5.2 parity of
newaxis/ellipsis placement. Semantics documented in the registry:
no ..= bounds, Some(n) always panics (intentional); the missing
one-element-tuple form is resolved by the rstsr-common companion
commit.

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: glm-5.3 <service@zhipuai.cn>
@ajz34
ajz34 merged commit e7cdc6a into RESTGroup:main Oct 6, 2026
13 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