21/34
Part 6 of 8 · BandsLearn and do

A step can run on bands with no overlap only if each output row depends only on its own input row

A step like that is row-local. scale, clip and map change each value on its own, so they are row-local. transpose, sort and head aren't. Here is each of them run per band on T, in bands of 2, with the bands stitched back:

StepWhole tablePer band, stitched
("sort", 1)column 1 reads -40, 18, 19, 20, 21column 1 reads -40, 19, 20, 21, 18
("head", 3)3 rowsall 5 rows, since each band kept its own first 3
("transpose",)3 rows of 59 rows of 2 or 1

The sort only sorted within each band.

The dangerous steps look row-local and aren't. Normalizing divides every value by the table's largest value:

def normalize(table):
    top = max(max(row) for row in table)
    return [[round(value / top, 2) for value in row] for row in table]

It touches each value on its own, but the divisor comes from the whole table. On bands, each band divided by its own largest value. The first row came out [0.84, 0.76, 0.92] instead of [0.21, 0.19, 0.23]. There was no error, just wrong numbers. Before a step goes on bands, ask what else it reads.

In the editor, write same_on_bands(step, table, band_rows): run step on each band of table, stitch, and compare with step on the whole table. To try it, the editor holds three steps as plain functions of a table: clip_step, sort_step and normalize.