From ddd064073beb69c3ce416f9b0814b9d001dbfbfc Mon Sep 17 00:00:00 2001 From: tannevaled Date: Sat, 17 Oct 2026 21:21:51 +0200 Subject: [PATCH] NDArray: go-ndarray v0.12.0, whose Repr prints exactly what NumPy prints go-ndarray v0.12.0 ports NumPy 2.5.3's arrayprint.py and is checked against NumPy's own test strings (ndarray#49), so `p`/`inspect` of an NDArray now print what NumPy's repr prints, character for character. One expectation encoded the old output: an empty array prints its dtype in NumPy (array([], dtype=float64)), as _array_repr_implementation adds dtype= whenever arr.size == 0. The other literal reprs in the tests were already NumPy's. The node smoke passes on the rbgo_core build. Co-Authored-By: Claude Opus 5.5 --- go.mod | 2 +- go.sum | 4 ++-- internal/vm/ndarray_test.go | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index d5b633ca..d070afcb 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/go-kramdown/kramdown v0.2.0 github.com/go-liquid/liquid v0.1.1 github.com/go-mustache/mustache v0.1.0 - github.com/go-ndarray/ndarray v0.11.0 + github.com/go-ndarray/ndarray v0.12.0 github.com/go-nokogiri/nokogiri v0.1.0 github.com/go-rouge/rouge v0.3.0 github.com/go-ruby-aasm/aasm v0.0.0-20260717061120-cec0976ec205 diff --git a/go.sum b/go.sum index fe581391..58c4a2dd 100644 --- a/go.sum +++ b/go.sum @@ -291,8 +291,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-mustache/mustache v0.1.0 h1:WvnpPlBn8/v1dwVzp7XvzF5dDC1agYMzPyCl1MdPVzY= github.com/go-mustache/mustache v0.1.0/go.mod h1:jXns/eIBKrnaFbE8BXX44VrTLp92732R0oXBiZC+v/Q= -github.com/go-ndarray/ndarray v0.11.0 h1:HMW7rAI25wSNNgVxOFTYCz48vW/wIBRT8IN17DNZHQ8= -github.com/go-ndarray/ndarray v0.11.0/go.mod h1:ZcgNCBVLXt1FxeZjQWI5Z+k0SSWAT0/wR8slfat/gRA= +github.com/go-ndarray/ndarray v0.12.0 h1:4xfl9ZQo1m0UXopo06KypELg1wUYgQb5kdKaJPZAZus= +github.com/go-ndarray/ndarray v0.12.0/go.mod h1:ZcgNCBVLXt1FxeZjQWI5Z+k0SSWAT0/wR8slfat/gRA= github.com/go-nokogiri/nokogiri v0.1.0 h1:3Q3BewGHK16Bt34ggJeyf9xeIMJyA3dmfbIxARPgR9U= github.com/go-nokogiri/nokogiri v0.1.0/go.mod h1:zjghooYIK8Xfg+fL4/OUhROslx51xGsM3JKtB2TI0tg= github.com/go-opentype/fonts v0.10.0 h1:9f7ik795SlBEJjz6iqBE/ZV2PaTauAj537MMWw9t4OQ= diff --git a/internal/vm/ndarray_test.go b/internal/vm/ndarray_test.go index c70231ce..56098f02 100644 --- a/internal/vm/ndarray_test.go +++ b/internal/vm/ndarray_test.go @@ -213,7 +213,9 @@ func TestNDArrayContract(t *testing.T) { {m + `p m`, "array([[0., 1., 2.],\n [3., 4., 5.]])\n"}, // repr(np.arange(6.).reshape(2, 3)) {m + `puts m.to_s`, "array([[0., 1., 2.],\n [3., 4., 5.]])\n"}, {`p NDArray.arange(3)`, "array([0., 1., 2.])\n"}, - {`p NDArray.zeros(0)`, "array([])\n"}, + // NumPy always prints the dtype of an empty array (arrayprint.py, + // _array_repr_implementation: dtype= when arr.size == 0). + {`p NDArray.zeros(0)`, "array([], dtype=float64)\n"}, {m + `p [m.shape, m.ndim, m.size]`, "[[2, 3], 2, 6]\n"}, } for _, c := range cases {