Note: The greater-than-one shape component should go from greatest to lowest numbers since it is more friendly to the CPU cache (so (1, 3, 4) is less optimal than (1, 4, 3). Keyword to this is "memory spatial locality"
Args:
arr (np.ndarray): The array we want to fix
Returns:
tuple (result, swaps): The result is the "fixed" array and a record of what has been done with it.
"Rotates" the array so it gains a shape that the algorithm can work with. An illegal shape is (3, 1, 4), and correct one is (1, 3, 4) or (1, 4, 3). The point is to have all 1s of the shape at the beginning, not in the middle of the shape tuple.
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them