[SciPy-User] How to feed np.mgrid a variable number of 'arguments'
Mon Mar 5 12:36:53 CST 2012
On Mon, Mar 5, 2012 at 18:27, Collin Day <firstname.lastname@example.org> wrote:
> Hi all,
> I am guessing there is an easy way to do this, but I am just not seeing it.
> I have a function where I can have a variable number of input dimensions.
> In the function, I need to use np.mgrid to generate the data I need. How
> would I create a line of code that would feed np.mgrid a variable number of
> inputs? For example:
> 3d, with 17 nodes
> a = np.mgrid[0:17,0:17,0:17]
> a = np.mgrid[0:17,0:17,0:17,0:17]
> Is there a way I can do
> inDims = a_number
> a = np.mgrid[0:17,0:17...a_number of times]
ix = (slice(0, nodes),) * inDims
a = np.mgrid[idx]
More information about the SciPy-User