Issue
numpy has a beautiful function which generate multidimensional grid. It is easy to work with it when number of dimension is low and is known in advance, but what to do when number of dimension is only known at time of execution or simply big and it takes too long to type. I guess I am looking for something like
import numpy as np
x = np.meshgrid(y)
where y is an array of arrays of evaluation points, for example
y = [array([-3., 0., 3.]) array([-3., 0., 3.]) array([-3., 0., 3.])]
Suggestions?
Solution
Use the *
-operator (i.e. the unpacking operator):
x = np.meshgrid(*y)
See https://docs.python.org/2/tutorial/controlflow.html#unpacking-argument-lists
Answered By - Warren Weckesser
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.