~/bend-docscommunity

LAWS.bend open laws/TODOs

raw source on the hub · import bend-ndarray@0.1.3.0/LAWS.bend as LAWS

The laws of bend-ndarray. Broadcasting is characterised for every pair of shapes (sound, complete, least: together they pin the result to the least shape both fit, so it is also symmetric); the other shape rules and the arrays' values are pinned at literal inputs (integer dtypes: the checker does not run float arithmetic; float32 results are tested against NumPy by test/compare.py). Gate: ./bend-check PROOF.bend --verdict

6 imports
import Base
import ./shape.bend as S
import ./ndarray.bend as NP
import ./rng.bend as R
import ./npy.bend as NPY
import ./tree.bend as T

Laws

law broadcast_sound provedin PROOF.bendsource · line 42 · raw

@+a:List<&2, Nat> -> @+b:List<&2, Nat> -> @+s:List<&2, Nat> -> @h:{0xcc7fe2a980487676abb11c4601fc801f/shape.broadcast(a, b) == Done{s} : Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, List<&2, Nat>>} -> {Bool.and(0xcc7fe2a980487676abb11c4601fc801f/shape.fits(a, s), 0xcc7fe2a980487676abb11c4601fc801f/shape.fits(b, s)) == True{} : Bool}

Guarantees: when a and b broadcast to s, each of them fits s: aligned at the last dimension, every one of its dimensions is 1 or equal to s's, and it has no more dimensions than s. Why it matters: the data of each operand is then stretched only where it has a 1, so no element is invented or misplaced; a rule that stretched a 3 to a 6 would silently repeat data.

law broadcast_complete provedin PROOF.bendsource · line 52 · raw

@+a:List<&2, Nat> -> @+b:List<&2, Nat> -> @+s:List<&2, Nat> -> @+ha:{0xcc7fe2a980487676abb11c4601fc801f/shape.fits(a, s) == True{} : Bool} -> @+hb:{0xcc7fe2a980487676abb11c4601fc801f/shape.fits(b, s) == True{} : Bool} -> {is_done(0xcc7fe2a980487676abb11c4601fc801f/shape.broadcast(a, b)) == True{} : Bool}

Guarantees: whenever a and b both fit some shape s, broadcasting them succeeds. Why it matters: NumPy accepts every such pair (a (5, 1) and a (3,) both fit (5, 3)); refusing one would break code ported from NumPy with a broadcasting error it never gets there.

law broadcast_least provedin PROOF.bendsource · line 63 · raw

@+a:List<&2, Nat> -> @+b:List<&2, Nat> -> @+s:List<&2, Nat> -> @+t:List<&2, Nat> -> @h:{0xcc7fe2a980487676abb11c4601fc801f/shape.broadcast(a, b) == Done{t} : Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, List<&2, Nat>>} -> @+ha:{0xcc7fe2a980487676abb11c4601fc801f/shape.fits(a, s) == True{} : Bool} -> @+hb:{0xcc7fe2a980487676abb11c4601fc801f/shape.fits(b, s) == True{} : Bool} -> {0xcc7fe2a980487676abb11c4601fc801f/shape.fits(t, s) == True{} : Bool}

Guarantees: the shape a and b broadcast to fits every shape they both fit: it is the smallest common shape. Why it matters: with sound and complete, this pins the result exactly to NumPy's: a rule that answered a larger shape both fit (stretching a 1 that NumPy keeps) would pass the other two laws and give wrongly sized arrays.

law broadcast_examples provedin PROOF.bendsource · line 76 · raw

{[0xcc7fe2a980487676abb11c4601fc801f/shape.broadcast([2n, 3n], [3n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.broadcast([5n, 1n, 4n], [3n, 1n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.broadcast([0n, 4n], [1n, 4n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.broadcast([2n, 3n], [2n])] == [Done{[2n, 3n]}, Done{[5n, 3n, 4n]}, Done{[0n, 4n]}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.NoBroadcast{[2n, 3n], [2n]}}] : List<&2, Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, List<&2, Nat>>>}

Guarantees: (2, 3) with (3,) gives (2, 3); (5, 1, 4) with (3, 1) gives (5, 3, 4); a 0 dimension against a 1 gives 0; (2, 3) with (2,) is refused, naming both shapes. Why it matters: these are NumPy's own documented examples and edge cases, at the public entry point.

law reshape_rules provedin PROOF.bendsource · line 85 · raw

{[0xcc7fe2a980487676abb11c4601fc801f/shape.reshape([2n, 3n, 4n], [6n, 4n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.reshape([2n, 3n, 4n], [24n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.reshape([2n, 3n, 4n], [5n, 5n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.reshape([2n, 3n, 4n], [2n, 3n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.reshape([0n, 3n], [3n, 0n])] == [Done{[6n, 4n]}, Done{[24n]}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.BadReshape{[2n, 3n, 4n], [5n, 5n]}}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.BadReshape{[2n, 3n, 4n], [2n, 3n]}}, Done{[3n, 0n]}] : List<&2, Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, List<&2, Nat>>>}

Guarantees: reshape keeps the number of elements: (2, 3, 4) to (6, 4) and to (24,) succeed; to (5, 5) (more) and to (2, 3) (fewer) are refused naming both shapes; a 0-element shape reshapes to another 0-element shape. Why it matters: a reshape that changed the element count would drop or invent data.

law transpose_rules provedin PROOF.bendsource · line 94 · raw

{[0xcc7fe2a980487676abb11c4601fc801f/shape.transpose([2n, 3n, 4n], [2n, 0n, 1n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.transpose([4n, 2n, 3n], [1n, 2n, 0n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.transpose([2n, 3n], [0n, 0n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.transpose([2n, 3n], [0n, 2n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.transpose([2n, 3n], [0n])] == [Done{[4n, 2n, 3n]}, Done{[2n, 3n, 4n]}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.BadPerm{[0n, 0n], 2n}}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.BadPerm{[0n, 2n], 2n}}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.BadPerm{[0n], 2n}}] : List<&2, Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, List<&2, Nat>>>}

Guarantees: transposing (2, 3, 4) by (2, 0, 1) gives (4, 2, 3), and by its inverse (1, 2, 0) back to (2, 3, 4); a perm that repeats an axis, misses one or has the wrong length is refused. Why it matters: result axis k is input axis perm[k] (NumPy's meaning); the reverse reading silently scrambles axes.

law reduce_rules provedin PROOF.bendsource · line 102 · raw

{[shape_of(Done{0xcc7fe2a980487676abb11c4601fc801f/shape.reduce_keep(False{}, [2n, 3n, 4n], 1n)}), shape_of(Done{0xcc7fe2a980487676abb11c4601fc801f/shape.reduce_keep(True{}, [2n, 3n, 4n], 1n)})] == [Some{[2n, 4n]}, Some{[2n, 1n, 4n]}] : List<&2, Maybe<&2, List<&2, Nat>>>}

Guarantees: reducing (2, 3, 4) along axis 1 gives (2, 4), or (2, 1, 4) keeping the axis; axis 3 is refused. Why it matters: the reduced axis is the one named, counted from 0 (NumPy's axis=1).

law axis_rules provedin PROOF.bendsource · line 106 · raw

{[0xcc7fe2a980487676abb11c4601fc801f/shape.axis_of(2n, 3n), 0xcc7fe2a980487676abb11c4601fc801f/shape.axis_of(3n, 3n)] == [Done{2n}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.BadAxis{3n, 3n}}] : List<&2, Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, Nat>>}

law slice_rules provedin PROOF.bendsource · line 112 · raw

{[0xcc7fe2a980487676abb11c4601fc801f/shape.slice_len(10n, 2n, 8n, 3n), 0xcc7fe2a980487676abb11c4601fc801f/shape.slice_len(10n, 0n, 10n, 1n), 0xcc7fe2a980487676abb11c4601fc801f/shape.slice_len(10n, 8n, 2n, 1n), 0xcc7fe2a980487676abb11c4601fc801f/shape.slice_len(10n, 3n, 100n, 4n), 0xcc7fe2a980487676abb11c4601fc801f/shape.slice_len(10n, 12n, 15n, 1n)] == [2n, 10n, 0n, 2n, 0n] : List<&2, Nat>}

Guarantees: slice lengths follow Python's a[start:stop:step] for positive steps: 10 elements [2:8:3] is 2 (2, 5), [0:10:1] is 10, [8:2:1] is 0, [3:100:4] is 2 (3, 7), [12:15:1] is 0. Why it matters: an off-by-one here drops or adds a row with no error.

law concat_rules provedin PROOF.bendsource · line 119 · raw

{[0xcc7fe2a980487676abb11c4601fc801f/shape.concat(1n, [2n, 3n], [2n, 5n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.concat(0n, [2n, 3n], [4n, 3n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.concat(1n, [2n, 3n], [3n, 3n]), 0xcc7fe2a980487676abb11c4601fc801f/shape.concat(2n, [2n, 3n], [2n, 3n])] == [Done{[2n, 8n]}, Done{[6n, 3n]}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.BadConcat{1n, [2n, 3n], [3n, 3n]}}, Fail{0xcc7fe2a980487676abb11c4601fc801f/shape.BadConcat{2n, [2n, 3n], [2n, 3n]}}] : List<&2, Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, List<&2, Nat>>>}

Guarantees: (2, 3) and (2, 5) join along axis 1 into (2, 8); (2, 3) and (4, 3) along axis 0 into (6, 3); (2, 3) and (3, 3) along axis 1 are refused, and so is an axis past the last. Why it matters: every axis but the joined one must agree, or rows would be glued to rows of another length.

law math_dtypes provedin PROOF.bendsource · line 130 · raw

{[is_fail(0xcc7fe2a980487676abb11c4601fc801f/ndarray.exp(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, 3n))), is_fail(0xcc7fe2a980487676abb11c4601fc801f/ndarray.sqrt(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.u8, 3n))), is_fail(0xcc7fe2a980487676abb11c4601fc801f/ndarray.exp(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.f32, 3n))), is_fail(0xcc7fe2a980487676abb11c4601fc801f/ndarray.square(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, 3n))), is_fail(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arctan2(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.f32, 3n), 0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, 3n))), is_fail(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arctan2(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, 3n), 0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, 3n))), is_fail(0xcc7fe2a980487676abb11c4601fc801f/ndarray.hypot(0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, 3n), 0xcc7fe2a980487676abb11c4601fc801f/ndarray.arange(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, 3n)))] == [True{}, True{}, False{}, False{}, True{}, True{}, True{}] : List<&2, Bool>}

Guarantees: exp of int32 and sqrt of uint8 are refused, arctan2 of mixed dtypes and of int32, and hypot of int32, are refused; exp of float32 and square of int32 are not. Why it matters: decision 2 (one dtype, explicit astype): a float function applied to integer cells would read the integers' bits as floats and give garbage with no error.

law philox_known provedin PROOF.bendsource · line 163 · raw

{0xcc7fe2a980487676abb11c4601fc801f/rng.philox(0xcc7fe2a980487676abb11c4601fc801f/rng.Q4{0, 0, 0, 0}, 0, 0) == 0xcc7fe2a980487676abb11c4601fc801f/rng.Q4{1713891541, 3781805453, 3159862348, 2600524760} : 0xcc7fe2a980487676abb11c4601fc801f/rng.Q4}

Guarantees: Philox4x32-10 gives Random123's published answer for counter 0 and key 0. Why it matters: the generator is the published one, so its tested statistical quality carries over; a wrong round constant or a wrong 64-bit product would still look random while being a different, untested generator.

law sort_keeps provedin PROOF.bendsource · line 170 · raw

@+fuel:Nat -> @+xs:List<&2, 0xcc7fe2a980487676abb11c4601fc801f/rng.KI> -> @+v:Nat -> {count_i(v, 0xcc7fe2a980487676abb11c4601fc801f/rng.msort(fuel, xs)) == count_i(v, xs) : Nat}

Guarantees: for every list of (key, index) pairs and every fuel, sorting keeps each index exactly as many times as the list had it. Why it matters: permutation is this sort applied to random keys; a sort that dropped or repeated an entry would hand out a shuffled dataset with rows lost or duplicated, whatever the keys were.

law keyed_indices provedin PROOF.bendsource · line 178 · raw

@c:Nat -> @+k0:U32 -> @+k1:U32 -> @+n:U32 -> @+s:Nat -> {0xcc7fe2a980487676abb11c4601fc801f/rng.idxs(0xcc7fe2a980487676abb11c4601fc801f/rng.keyed(c, k0, k1, n, s)) == iota(c, s) : List<&2, Nat>}

Guarantees: the pairs permutation sorts carry the indices start, start + 1, ..., start + c - 1, in order. Why it matters: with sort_keeps, permutation(n) holds 0 .. n - 1 once each: a permutation, for every seed.

law f64_rounding provedin PROOF.bendsource · line 211 · raw

{[0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(0, 1072693248), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(2576980378, 1069128089), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(268435456, 1072693248), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(805306368, 1072693248), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(0, 916455424), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(0, 915406848), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(4103883293, 1208451719), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(4026531840, 1206910975), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(0, 2147483648), 0xcc7fe2a980487676abb11c4601fc801f/npy.f64_to_f32(0, 2146959360)] == [1065353216, 1036831949, 1065353216, 1065353218, 1, 0, 2139095040, 2139095040, 2147483648, 2143289344] : List<&2, U32>}

Guarantees: float64 to float32 as NumPy's astype: 1.0 and 0.1 (rounded to nearest), 1 + 2^-24 (a tie, to even: 1.0), 1 + 3 * 2^-24 (a tie, to even: up), 2^-149 (the smallest subnormal), 2^-150 (a tie with 0: 0), 1e39 and the first double that rounds past the largest float (infinity), -0.0, and NaN (a quiet NaN). Why it matters: decision 1 (float64 loads as float32, rounded as astype): a wrong rounding changes data silently.

law f16_exact provedin PROOF.bendsource · line 220 · raw

{[0xcc7fe2a980487676abb11c4601fc801f/npy.f16_to_f32(15360), 0xcc7fe2a980487676abb11c4601fc801f/npy.f16_to_f32(1), 0xcc7fe2a980487676abb11c4601fc801f/npy.f16_to_f32(31743), 0xcc7fe2a980487676abb11c4601fc801f/npy.f16_to_f32(31744), 0xcc7fe2a980487676abb11c4601fc801f/npy.f16_to_f32(64512)] == [1065353216, 864026624, 1199562752, 2139095040, 4286578688] : List<&2, U32>}

Guarantees: float16 to float32 exactly: 1.0, the smallest subnormal 2^-24, the largest half 65504, infinity, -infinity. Why it matters: float16 files (common for model weights) load with every value unchanged.

law npy_round_trip provedin PROOF.bendsource · line 227 · raw

{[loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(0xcc7fe2a980487676abb11c4601fc801f/npy.to_npy(lit(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, [2n, 3n], [0, 1, 2, 3, 4, 5])))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(0xcc7fe2a980487676abb11c4601fc801f/npy.to_npy(lit(0xcc7fe2a980487676abb11c4601fc801f/ndarray.bool, [3n], [1, 0, 1])))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(0xcc7fe2a980487676abb11c4601fc801f/npy.to_npy(lit(0xcc7fe2a980487676abb11c4601fc801f/ndarray.u8, [], [200])))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(0xcc7fe2a980487676abb11c4601fc801f/npy.to_npy(lit(0xcc7fe2a980487676abb11c4601fc801f/ndarray.f32, [2n, 0n], [])))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(0xcc7fe2a980487676abb11c4601fc801f/npy.to_npy(lit(0xcc7fe2a980487676abb11c4601fc801f/ndarray.i32, [4n], [4294967295, 7, 2147483648, 0]))))] == [Done{Sig{"int32", [2n, 3n], [0, 1, 2, 3, 4, 5]}}, Done{Sig{"bool", [3n], [1, 0, 1]}}, Done{Sig{"uint8", [], [200]}}, Done{Sig{"float32", [2n, 0n], []}}, Done{Sig{"int32", [4n], [4294967295, 7, 2147483648, 0]}}] : List<&2, Result<&2, &2, String, Sig>>}

Guarantees: saving then loading gives the same dtype, shape and elements: an int32 (2, 3), a bool (3,), a uint8 0-d array, an empty float32 (2, 0) and an int32 (4,) with negatives. Why it matters: the format must round-trip what bend-ndarray writes, or a save and load would change an array.

law npy_layouts provedin PROOF.bendsource · line 243 · raw

{[loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(hdr16("{'descr': '<i4', 'fortran_order': True, 'shape': (2, 3), }\n", [0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0]))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(hdr16("{'descr': '>i4', 'fortran_order': False, 'shape': (2,), }\n", [0, 0, 1, 2, 255, 255, 255, 254]))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(hdr16("{'descr': '<i2', 'fortran_order': False, 'shape': (2,), }\n", [255, 255, 3, 0]))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(hdr16("{\"shape\": (2L,), \"fortran_order\": False, \"descr\": \"<i4\"}\n", [1, 0, 0, 0, 2, 0, 0, 0]))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(hdr16("{'descr': '<i8', 'fortran_order': False, 'shape': (1,), }\n", [255, 255, 255, 255, 255, 255, 255, 255]))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(hdr16("{'descr': '<i8', 'fortran_order': False, 'shape': (1,), }\n", [0, 0, 0, 128, 0, 0, 0, 0]))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(hdr16("{'descr': '<c8', 'fortran_order': False, 'shape': (1,), }\n", [0, 0, 0, 0, 0, 0, 0, 0]))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy(hdr16("{'descr': '<i4', 'fortran_order': False, 'shape': (3,), }\n", [1, 0, 0, 0]))), loaded(0xcc7fe2a980487676abb11c4601fc801f/npy.from_npy([80, 75, 3, 4]))] == [Done{Sig{"int32", [2n, 3n], [0, 1, 2, 3, 4, 5]}}, Done{Sig{"int32", [2n], [258, 4294967294]}}, Done{Sig{"int32", [2n], [4294967295, 3]}}, Done{Sig{"int32", [2n], [1, 2]}}, Done{Sig{"int32", [1n], [4294967295]}}, Fail{"element 0 (<i8) does not fit a 32-bit integer"}, Fail{"a .npy dtype bend-ndarray cannot hold: <c8"}, Fail{".npy: the file ends before its data does"}, Fail{".npy: not a .npy file (no \\x93NUMPY at the start)"}] : List<&2, Result<&2, &2, String, Sig>>}

Guarantees: files as other writers make them load as np.load reads them: a Fortran-order (2, 3) int32 (transposed into row-major), a big-endian int32, an int16 with a negative value, a Python 2 header ('L' suffixes, double quotes, other key order), and an int64 that fits; an int64 past int32, complex64, a short file and a non-.npy file are refused. Why it matters: decisions 1 and 2: Fortran order and byte order are layouts np.save writes, and reading them as C order or little-endian would scramble or corrupt every value with no error.

Types

type Sig source · line 188 · raw

Data

Definitions

def shape_of source · line 15 · raw

@r:Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, List<&2, Nat>> -> Maybe<&2, List<&2, Nat>>

def is_fail source · line 22 · raw

@r:Result<&1, &1, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, 0xcc7fe2a980487676abb11c4601fc801f/ndarray.ND> -> Bool

def is_done source · line 29 · raw

@r:Result<&2, &2, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, List<&2, Nat>> -> Bool

def b2n source · line 138 · raw

@b:Bool -> Nat

def count_i source · line 146 · raw

@+v:Nat -> @xs:List<&2, 0xcc7fe2a980487676abb11c4601fc801f/rng.KI> -> Nat

how many entries of xs carry index v

def iota source · line 153 · raw

@c:Nat -> @+s:Nat -> List<&2, Nat>

def sig source · line 191 · raw

@a:0xcc7fe2a980487676abb11c4601fc801f/ndarray.ND -> Sig

def loaded source · line 197 · raw

@r:Result<&1, &1, 0xcc7fe2a980487676abb11c4601fc801f/shape.NdErr, 0xcc7fe2a980487676abb11c4601fc801f/ndarray.ND> -> Result<&2, &2, String, Sig>

what a load gives: the array's dtype, shape and cells, or the error in words

def lit source · line 204 · raw

@+dt:0xcc7fe2a980487676abb11c4601fc801f/shape.DType -> @+s:List<&2, Nat> -> @+xs:List<&2, U32> -> 0xcc7fe2a980487676abb11c4601fc801f/ndarray.ND

def hdr16 source · line 234 · raw

@+h:String -> @+data:List<&2, U32> -> List<&2, U32>