Fix `rand()` and `rand()` in Python code, which created random number arrays of the wrong size for size-one index arrays.