Skip to content

README: the ndarray axis keyword, and what makes $/ a different setter - #888

Merged
tannevaled merged 1 commit into
mainfrom
readme-ndarray-axis
Nov 4, 2026
Merged

tannevaled merged 1 commit into
mainfrom
readme-ndarray-axis

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Two README sentences had fallen behind the code they describe. Both claims
below come from running the real interpreter, not from reading the binding.

NDArray — the axis keyword (#883)

The line read (axis, keepdims: true), so the positional form was the only
documented way to reduce along an axis, and cumsum was absent from the
sentence. rbgo built at 6eb7e4ad:

a.sum                   => 15.0
a.sum(axis: 0).to_a     => [3.0, 5.0, 7.0]
a.sum(0).to_a           => [3.0, 5.0, 7.0]
a.cumsum(axis: 1).to_a  => [0.0, 1.0, 3.0, 3.0, 7.0, 12.0]
a.argmax(axis: 1).to_a  => [2.0, 2.0]
a.sum(0, axis: 0)       => ArgumentError: axis given both positionally and as a keyword

Predefined globals — $/ is not $, (#886)

The list claims each global gets "the setter MRI's variable table gives it
rather than one untyped slot"
, and then groups $;, $, and $/ as though
one setter covered them. Init_IO wires $, and $\ to rb_str_setter and
$//$-0 to deprecated_rs_setter; #886 made that split real, and $/ now
stores a frozen plain String of the bytes it was handed rather than the object.
That difference is precisely what the sentence promises, so it is now spelled
out.

rubydiff on a program exercising all four, against MRI 4.0.7:

AGREE   exit 0
  A rbgo-main   ruby 4.0.9 [arm64-darwin]
  B ruby@4.0    ruby 4.0.7 (2026-09-15 revision 229531a6cf) +PRISM [arm64-darwin25]

The control: the same program under the system ruby 2.6.10 diverges on
exactly the two $/ lines and agrees on the two $,/$\ lines. The freezing
is 4.0 behaviour that rbgo now matches, not something rbgo invented — a run
that agreed with 4.0.7 and with 2.6.10 alike would have proved nothing.

🤖 Generated with Claude Code

… setter (#886)

Two sentences had fallen behind the code they describe.

**NDArray.** The line read "(axis, keepdims: true)", so the only documented way
to reduce along an axis was the positional one. #883 taught the reductions and
cumsum NumPy's `axis:` spelling, and cumsum was not in the sentence at all.
Verified against rbgo built at 6eb7e4a:

    a.sum                   => 15.0
    a.sum(axis: 0).to_a     => [3.0, 5.0, 7.0]
    a.sum(0).to_a           => [3.0, 5.0, 7.0]
    a.cumsum(axis: 1).to_a  => [0.0, 1.0, 3.0, 3.0, 7.0, 12.0]
    a.argmax(axis: 1).to_a  => [2.0, 2.0]
    a.sum(0, axis: 0)       => ArgumentError: axis given both positionally and
                               as a keyword

**Predefined globals.** The list claims each global gets "the setter MRI's
variable table gives it rather than one untyped slot", then groups `$;`, `$,`
and `$/` as though one setter covered them. Init_IO wires `$,` and `$\` to
rb_str_setter and `$/`/`$-0` to deprecated_rs_setter, and #886 made that split
real: `$/` now stores a frozen plain String of the bytes it was given instead
of the object itself. The README now says so, because that difference is
exactly the claim the sentence makes.

rubydiff against MRI 4.0.7, same program, five lines of output:

    AGREE   exit 0
      A rbgo-main   ruby 4.0.9 [arm64-darwin]
      B ruby@4.0    ruby 4.0.7 (2026-09-15 revision 229531a6cf) +PRISM

The same program under the system ruby 2.6.10 diverges on exactly the two
`$/` lines and agrees on the two `$,`/`$\` lines, which is the control: the
freezing is 4.0 behaviour, not something rbgo invented.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit fdf0939 into main Nov 4, 2026
26 checks passed
@tannevaled
tannevaled deleted the readme-ndarray-axis branch November 4, 2026 14:13
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