Using numpy mgrid with a variable number of indices
numpy, python
Solution
This seems to work:
np.mgrid[[slice(i,j) for i,j in [(1,10)]*10]]
though with `*10` it is too large
It's derived from that fact
np.mgrid[slice(1,10),slice(1,10)] # same as
np.mgrid[1:10,1:10]
Problem
How do you use numpy.mgrid with a variable number of indices? I can't find any examples on github of anyone using this with anything but hardcoded values. ``` import numpy as np np.mgrid[1:10, 1:10] # this works fine x = (1, 10) np.mgrid[x[0]:x[1], x[0]:x[1]] # hardcoded xs = [(1,10)] * 10 np.mgrid[*xs????] # I can't get anything to work here ```