Skip to content

NDArray: document the axis, positional and axis: - #45

Merged
tannevaled merged 2 commits into
mainfrom
ndarray-axis-docs
Nov 4, 2026
Merged

tannevaled merged 2 commits into
mainfrom
ndarray-axis-docs

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The NDArray section listed the reductions and showed a.sum, so nothing on the
page said they reduce along an axis at all — and nothing said that
go-embedded-ruby/ruby#883 taught them NumPy's axis: spelling. cumsum was
missing from the list entirely.

Every figure in the new example came from a real run of rbgo built at
go-embedded-ruby/ruby@6eb7e4ad, not from reading the binding:

15.0
[3.0, 5.0, 7.0]
[3.0, 5.0, 7.0]        # a.sum(0), the positional form, same array
[0.0, 1.0, 3.0, 3.0, 7.0, 12.0]
[2.0, 2.0]
[3, 2]
"axis given both positionally and as a keyword"

That last line is what a.sum(0, axis: 0) raises, which is the other claim the
prose makes.

numericsurface against the same binary: 258 names over 11 module sections,
0 disagree.

Separate from #44 on purpose: that one moves the conformance figure and this
one documents a method surface. They touch different files and neither needs
the other.

🤖 Generated with Claude Code

tannevaled and others added 2 commits November 4, 2026 12:51
… since ruby#883

The page listed the reductions and showed `a.sum`, so a reader had no way to
learn that `sum`/`prod`/`mean`/`max`/`min`/`argmax`/`argmin` reduce along an
axis at all, let alone that go-embedded-ruby/ruby#883 taught them NumPy's
`axis:` spelling. `cumsum` was missing from the list entirely.

Every figure in the new example was taken from a real run of rbgo built at
go-embedded-ruby/ruby@6eb7e4ad, not from reading the binding:

    p a.sum                      # => 15.0
    p a.sum(axis: 0).to_a        # => [3.0, 5.0, 7.0]
    p a.argmax(axis: 1).to_a     # => [2.0, 2.0]

The same run confirms the two statements the prose makes: `a.sum(0)` and
`a.sum(axis: 0)` return the same array, and `a.sum(0, axis: 0)` raises
ArgumentError("axis given both positionally and as a keyword").

numericsurface against that binary: 258 names over 11 module sections, 0
disagree.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 1e42c28 into main Nov 4, 2026
2 checks passed
@tannevaled
tannevaled deleted the ndarray-axis-docs branch November 4, 2026 12:01
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