improve error message of 𝔽 in 𝔽⌾(a⊸⊏) returning an atom

This commit is contained in:
dzaima 2025-05-09 00:27:16 +03:00
parent d2c27fd880
commit 8d757363e9
2 changed files with 11 additions and 6 deletions

View File

@ -981,6 +981,7 @@ B select_ucw(B t, B o, B w, B x) {
if (!elNum(we)) goto def; if (!elNum(we)) goto def;
} }
} }
usz wia = IA(w); usz wia = IA(w);
B rep; B rep;
if (isArr(o) && RNK(x)>0) { if (isArr(o) && RNK(x)>0) {
@ -994,10 +995,13 @@ B select_ucw(B t, B o, B w, B x) {
} else { } else {
rep = c1(o, C2(select, incG(w), incG(x))); rep = c1(o, C2(select, incG(w), incG(x)));
} }
ur xr = RNK(x); ur xr = RNK(x);
ur wr = RNK(w); ur wr = RNK(w);
bool ok = isArr(rep) && xr+wr == RNK(rep)+1 && eqShPart(SH(w),SH(rep),wr) && eqShPart(SH(x)+1,SH(rep)+wr,xr-1); if (isAtm(rep)) thrF("𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected %2H, got atom)", xr-1, SH(x)+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); bool ok = xr+wr == 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 (expected %2H, got %H)", xr-1, SH(x)+1, rep);
usz csz = arr_csz(x); usz csz = arr_csz(x);
if (csz == 0) { decG(rep); decG(w); return x; } if (csz == 0) { decG(rep); decG(w); return x; }
return select_replace(U'', w, x, rep, wia, *SH(x), csz); return select_replace(U'', w, x, rep, wia, *SH(x), csz);

View File

@ -82,10 +82,11 @@ n←500 ⋄ a←↕n ⋄ i←(-n)+↕2×n ⋄ r←⌽(2×n)⥊a ⋄ ! (⌽a) ≡
100+(12¯4) 10 %% 0101102345106789 100+(12¯4) 10 %% 0101102345106789
10+(12) 0a4, a %% 011123,0123 10+(12) 0a4, a %% 011123,0123
%USE eqvar 0011 {𝕨(1245) 𝕩} _eqvar 101010110 %% 100011110 %USE eqvar 0011 {𝕨(1245) 𝕩} _eqvar 101010110 %% 100011110
!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (⟨2⟩ ≡ shape of a, ⟨⟩ ≡ shape of ⊏𝕩, ⟨3⟩ ≡ shape of result of 𝔽)" % 102030(23) 10 !"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨⟩, got ⟨3⟩)" % 102030(23) 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(23) 10 !"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨⟩, got ⟨3⟩)" % 1(23) 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(234)_evar 10100 !"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨10⟩, got 2‿10)" % %USE evar 1(234)_evar 10100
!"𝔽⌾(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⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨⟩, got atom)" % %USE evar 0 {1(𝕨)𝕩}_evar 0
!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected 3‿4, got atom)" % %USE evar 0 {1(𝕨)𝕩}_evar 2343
!"𝔽⌾(a⊸⊏): Incompatible result elements" % 34(11) 10 !"𝔽⌾(a⊸⊏): Incompatible result elements" % 34(11) 10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % 34(1¯9) 10 !"𝔽⌾(a⊸⊏): Incompatible result elements" % 34(1¯9) 10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % %USE evar 34 {𝕨(1¯9) 𝕩}_evar 10 !"𝔽⌾(a⊸⊏): Incompatible result elements" % %USE evar 34 {𝕨(1¯9) 𝕩}_evar 10