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

Collin Day dcday137 at gmail.com
Wed Mar 7 12:51:54 EST 2012


Collin Day <dcday137 <at> gmail.com> writes:


> 
> 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 nodesa = np.mgrid[0:17,0:17,0:17]4da =
np.mgrid[0:17,0:17,0:17,0:17]Is there a way I can donodes=17inDims = a_numbera =
np.mgrid[0:17,0:17...a_number of times]easily?Thanks!
> 
> _______________________________________________
> SciPy-User mailing list
> SciPy-User <at> scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
> 

Thanks both of you who answered - this was exactly what I was looking for, but
it would have been forever before I found it!





More information about the SciPy-User mailing list