A Python generator (and tests) to produce tuples that iterate over a set of dimensions