[SciPy-User] [SciPy-user] Looping over one variable keeping the others constant

Zachary Pincus zachary.pincus@yale....
Fri Apr 13 14:21:46 CDT 2012


> x,y
> 1,1
> 2,1
> 3,1
> 1,2
> 2,2
> 3,2
> 

If you just want integer increments like a counter (as in the above), you could use numpy.ndindex, e.g.:

In [20]: numpy.array(list(numpy.ndindex(2,3)))+1
Out[20]: 
array([[1, 1],
       [1, 2],
       [1, 3],
       [2, 1],
       [2, 2],
       [2, 3]])




More information about the SciPy-User mailing list