I'm trying to loop over an NDArray coordinates, and it seems like iteration needs an overhaul.
f {
x: array([
[
[ 100, 101, 102, 103, 104 ],
[ 105, 106, 107, 108, 109 ],
[ 110, 111, 112, 113, 114 ]
],
[
[ 115, 116, 117, 118, 119 ],
[ 120, 121, 122, 123, 124 ],
[ 125, 126, 127, 128, 129 ]
]
], dtype=float64),
shape: [
2, 3, 5, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
shapem1: [
1, 2, 4, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
strides: [
15, 5, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
backstrides: [
15, 10, 4, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
length: 30,
lengthm1: 29,
nd: 3,
ndm1: 2,
index: 17,
coords: [
1, 0, 2, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
pos: 17,
factors: [
15, 5, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
]
}
I'm trying to loop over an NDArray coordinates, and it seems like iteration needs an overhaul.
NDArrayis not iterable (sofor (x of my_ndarray)andArray.from(myNdArray)throw errors)NDIter's implementation of theiterableprotocol seems to iterate over only the linearized indices (i.e.Array.from(new NDIter(my_ndarray))gives[0,1,...], even if the ndarray is multidimensional)NDIterhas properties that are length 32 (V_MAXDIMS) even when the array it's iterating over has fewer dimensions.NDIterhas extraneous properties which obscure how to use it.NDIter's string representation uses the namef(I think because it is derived from minified code) and is excessively verbose.prints: