From 5ecd1858eff497ab8ebd8114860f9a2bb0d39d93 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sat, 7 Dec 2024 06:54:07 +0200 Subject: [PATCH] =?UTF-8?q?fix=201=E2=8C=BE(=E2=9F=A80=E2=9F=A9=E2=8A=B8?= =?UTF-8?q?=E2=8A=8F)=E2=9F=A80=E2=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/select.c | 4 ++-- test/cases/under.bqn | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/builtins/select.c b/src/builtins/select.c index 69eb4581..3c199695 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -953,8 +953,8 @@ B select_ucw(B t, B o, B w, B x) { } usz xr = RNK(x); usz wr = RNK(w); - usz rr = RNK(rep); - bool ok = !isAtm(rep) && xr+wr==rr+1 && eqShPart(SH(w),SH(rep),wr) && eqShPart(SH(x)+1,SH(rep)+wr,xr-1); + usz rr; + bool ok = isArr(rep) && xr+wr==(rr=RNK(rep))+1 && eqShPart(SH(w),SH(rep),wr) && eqShPart(SH(x)+1,SH(rep)+wr,xr-1); if (!ok) thrF("π”½βŒΎ(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (%H ≑ shape of a, %2H ≑ shape of βŠπ•©, %H ≑ shape of result of 𝔽)", w, xr-1, SH(x)+1, rep); usz csz = arr_csz(x); if (csz == 0) { decG(rep); decG(w); return x; } diff --git a/test/cases/under.bqn b/test/cases/under.bqn index b926a858..95b6cafb 100644 --- a/test/cases/under.bqn +++ b/test/cases/under.bqn @@ -46,6 +46,7 @@ n←500 β‹„ a←↕n β‹„ i←(-n)+↕2Γ—n β‹„ rβ†βŒ½(2Γ—n)β₯Ša β‹„ ! (⌽a) ≑ !"π”½βŒΎ(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (⟨2⟩ ≑ shape of a, ⟨⟩ ≑ shape of βŠπ•©, ⟨3⟩ ≑ shape of result of 𝔽)" % 10β€Ώ20β€Ώ30⌾(2β€Ώ3⊸⊏) ↕10 !"π”½βŒΎ(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (⟨2⟩ ≑ shape of a, ⟨⟩ ≑ shape of βŠπ•©, ⟨3⟩ ≑ shape of result of 𝔽)" % 1⊸∾⌾(2β€Ώ3⊸⊏) ↕10 !"π”½βŒΎ(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (⟨3⟩ ≑ shape of a, ⟨10⟩ ≑ shape of βŠπ•©, 2β€Ώ10 ≑ shape of result of 𝔽)" % %USE evar β‹„ 1βŠΈβ†“βŒΎ(2β€Ώ3β€Ώ4⊸⊏)_evar 10β€Ώ10β₯Š0 +!"π”½βŒΎ(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (⟨1⟩ ≑ shape of a, ⟨⟩ ≑ shape of βŠπ•©, ⟨⟩ ≑ shape of result of 𝔽)" % %USE evar β‹„ ⟨0⟩ {1⌾(π•¨βŠΈβŠ)𝕩}_evar ⟨0⟩ !"π”½βŒΎ(a⊸⊏): Incompatible result elements" % 3β€Ώ4⌾(1β€Ώ1⊸⊏) ↕10 !"π”½βŒΎ(a⊸⊏): Incompatible result elements" % 3β€Ώ4⌾(1β€ΏΒ―9⊸⊏) ↕10 !"π”½βŒΎ(a⊸⊏): Incompatible result elements" % %USE evar β‹„ 3β€Ώ4 {π•¨βŒΎ(1β€ΏΒ―9⊸⊏) 𝕩}_evar ↕10