larray.Array.iflat

Array.iflat

Access the array by index as if it was flat (one dimensional) and all its axes were combined.

Notes

In general arr.iflat[key] should be equivalent to (but much faster than) arr.combine_axes().i[key]

Examples

>>> arr = ndtest((2, 3)) * 10
>>> arr
a\b  b0  b1  b2
 a0   0  10  20
 a1  30  40  50

To select the first, second, fourth and fifth values across all axes:

>>> arr.combine_axes().i[[0, 1, 3, 4]]
a_b  a0_b0  a0_b1  a1_b0  a1_b1
         0     10     30     40
>>> arr.iflat[[0, 1, 3, 4]]
a_b  a0_b0  a0_b1  a1_b0  a1_b1
         0     10     30     40

Set the first and sixth values to 42

>>> arr.iflat[[0, 5]] = 42
>>> arr
a\b  b0  b1  b2
 a0  42  10  20
 a1  30  40  42

When the key is an Array, the result will have the axes of the key

>>> key = Array([0, 3], 'c=c0,c1')
>>> key
c  c0  c1
    0   3
>>> arr.iflat[key]
c  c0  c1
   42  30