A pipeline runs a list of steps in order, and each step returns a new table
Start with the small version: a table of sensor readings, with two glitches in it.
READINGS = [ [21, 19, 23], # -40 is a sensor glitch [25, -40, 24], [22, 20, 99], # so is 99 [24, 21, 22],]
A table in this lesson is a list of rows. Each row is a list of numbers, every row has the same length, and there's at least one row. Think of sensor readings: one row per hour, one column per sensor.
Predict
Clip every value into 0 to 40. What do the glitches -40 and 99 become?
The cleanup: clip every value into 0 to 40, sort the rows by sensor 1, scale to tenths of a degree, and keep the first two rows. Here is the path the table takes through apply, the function this lesson builds. 4 x 3 means 4 rows by 3 columns.
apply(READINGS, steps)Interactive
→
→
→
→
→
→
READINGS = 4 x 3. Two glitches, -40 and 99
Each step gets a table and returns a new one, and the next step works on that one. No step runs until the whole list has been checked.
This shape comes up in Anthropic's coding rounds as an image pipeline. Six reports name it: five from software engineer candidates and one from a prep site's question list.
Given images and a list of functions, apply the functions in order: rotate, grayscale and the like (1 report).
One candidate used PIL for grayscale, scale and resize, and sped it up with a process pool (1 report).
Another was asked why processes rather than threads, and how many workers the pool needs (1 report).
A staff candidate had to build it over real image files in a project (1 report).
Two more reports name only the topic (2 sources).
The practice problem's four levelsInteractive
→
→
→
one image. Through a list of steps
This lesson builds every piece on tables of numbers instead of images. Then the practice problem is assembly: the same pieces, with image steps.
In the editor, write the first two steps of the cleanup as functions: clip(table, low, high) and scale(table, factor). Each takes a table and returns a new one, and READINGS is there to try them on.
Pick an answer above to see the rest
Instructions
1
Write clip(table, low, high): every value moved into the range from low to high.
2
Write scale(table, factor): every value times factor. Both return a new table.