[SciPy-User] How to feed np.mgrid a variable number of 'arguments'

Collin Day dcday137@gmail....
Mon Mar 5 12:27:45 CST 2012


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]

4d

a = np.mgrid[0:17,0:17,0:17,0:17]

Is there a way I can do

nodes=17
inDims = a_number

a = np.mgrid[0:17,0:17...a_number of times]

easily?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120305/40dcf245/attachment.html 


More information about the SciPy-User mailing list