Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-14 Thread Stefan Otte
Hey, I just created a pull request: https://github.com/numpy/numpy/pull/5874 Best, Stefan On Tue, May 12, 2015 at 3:29 PM Stefan Otte stefan.o...@gmail.com wrote: Hey, here is an ipython notebook with benchmarks of all implementations (scroll to the bottom for plots):

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-12 Thread Stefan Otte
Hello, indeed I was looking for the cartesian product. I timed the two stackoverflow answers and the winner is not quite as clear: n_elements:10 cartesian 0.00427 cartesian2 0.00172 n_elements: 100 cartesian 0.02758 cartesian2 0.01044 n_elements: 1000 cartesian 0.97628 cartesian2

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-12 Thread Johannes Kulick
I'm totally in favor of the 'gridspace(linspaces)' version, as you probably end up wanting to create grids of other things than linspaces (e.g. a logspace grid, or a grid of random points etc.). It should be called somewhat different though. Maybe 'cartesian(arrays)'? Best, Johannes Quoting

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-12 Thread Jaime Fernández del Río
On Tue, May 12, 2015 at 1:17 AM, Stefan Otte stefan.o...@gmail.com wrote: Hello, indeed I was looking for the cartesian product. I timed the two stackoverflow answers and the winner is not quite as clear: n_elements:10 cartesian 0.00427 cartesian2 0.00172 n_elements: 100

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-12 Thread Stefan Otte
Hey, here is an ipython notebook with benchmarks of all implementations (scroll to the bottom for plots): https://github.com/sotte/ipynb_snippets/blob/master/2015-05%20gridspace%20-%20cartesian.ipynb Overall, Jaime's version is the fastest. On Tue, May 12, 2015 at 2:01 PM Jaime Fernández

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-10 Thread Nathaniel Smith
On Sun, May 10, 2015 at 4:40 AM, Stefan Otte stefan.o...@gmail.com wrote: Hey, quite often I want to evaluate a function on a grid in a n-D space. What I end up doing (and what I really dislike) looks something like this: x = np.linspace(0, 5, 20) M1, M2 = np.meshgrid(x, x) X =

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-10 Thread Jaime Fernández del Río
On Sun, May 10, 2015 at 4:40 AM, Stefan Otte stefan.o...@gmail.com wrote: Hey, quite often I want to evaluate a function on a grid in a n-D space. What I end up doing (and what I really dislike) looks something like this: x = np.linspace(0, 5, 20) M1, M2 = np.meshgrid(x, x) X =

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-10 Thread Stefan van der Walt
On 2015-05-10 14:46:12, Jaime Fernández del Río jaime.f...@gmail.com wrote: Isn't what you are trying to build a cartesian product function? There is a neat, efficient implementation of such a function in StackOverflow, by our own pv.:

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-10 Thread Stefan Otte
I just drafted different versions of the `gridspace` function: https://tmp23.tmpnb.org/user/1waoqQ8PJBJ7/notebooks/2015-05%20gridspace.ipynb Beste Grüße, Stefan On Sun, May 10, 2015 at 1:40 PM, Stefan Otte stefan.o...@gmail.com wrote: Hey, quite often I want to evaluate a function on a

Re: [Numpy-discussion] Create a n-D grid; meshgrid alternative

2015-05-10 Thread Jaime Fernández del Río
On Sun, May 10, 2015 at 7:05 AM, Stefan Otte stefan.o...@gmail.com wrote: I just drafted different versions of the `gridspace` function: https://tmp23.tmpnb.org/user/1waoqQ8PJBJ7/notebooks/2015-05%20gridspace.ipynb The link seems to be broken... Jaime -- (\__/) ( O.o) ( ) Este es Conejo.