[SciPy-Dev] 3D Meshgrid
Per.Brodtkorb@f...
Per.Brodtkorb@f...
Wed Nov 9 01:39:48 CST 2011
Øverst i skjemaet
The timings for the original version:
In [10]: x = np.arange(10)
In [11]: %timeit X,Y = np.meshgrid(x,x)
100000 loops, best of 3: 9.79 us per loop
compared to the new proposal:
In [12]: %timeit X,Y = meshgrid(x,x)
10000 loops, best of 3: 33.4 us per loop
In [13]: %timeit X,Y = meshgrid(x,x, sparse=True)
10000 loops, best of 3: 18.3 us per loop
In [14]: %timeit X,Y = meshgrid(x,x, sparse=True, copy=False)
10000 loops, best of 3: 15 us per loop
In [15]: %timeit X,Y = meshgrid(x,x, sparse=True, copy=False, indexing='ij')
100000 loops, best of 3: 12.3 us per loop
Nederst i skjemaet
Øverst i skjemaet
Changed 23 hours <http://projects.scipy.org/numpy/timeline?from=2011-11-08T02%3A13%3A40-0600&precision=second> ago by pbrod
However, the timings for the new version is even better when the size of the input vectors are large. The timings for the original version with size=100:
In [36]: x = np.arange(100)
In [37]: %timeit X,Y = np.meshgrid(x,x)
10000 loops, best of 3: 96.8 us per loop
compared to the new proposal:
In [38]: %timeit X,Y = meshgrid(x,x, sparse=False, copy=True, indexing='xy')
10000 loops, best of 3: 109 us per loop
In [39]: %timeit X,Y = meshgrid(x,x, sparse=True, copy=True, indexing='xy')
100000 loops, best of 3: 18.5 us per loop
In [40]: %timeit X,Y = meshgrid(x,x, sparse=True, copy=True, indexing='ij')
100000 loops, best of 3: 15.5 us per loop
In [41]: %timeit X,Y = meshgrid(x,x, sparse=True, copy=False, indexing='ij')
10000 loops, best of 3: 12 us per loop
In [42]: %timeit X,Y = meshgrid(x,x, sparse=False, copy=False, indexing='ij')
10000 loops, best of 3: 62.2 us per loop
Nederst i skjemaet
Per A. Brodtkorb
Fra: scipy-dev-bounces@scipy.org [mailto:scipy-dev-bounces@scipy.org] På vegne av Ralf Gommers
Sendt: 7. november 2011 22:55
Til: SciPy Developers List
Emne: Re: [SciPy-Dev] 3D Meshgrid
On Thu, Nov 3, 2011 at 1:28 PM, Antoine Levitt <antoine.levitt@gmail.com> wrote:
The version in scitools looks consistent with numpy, compatible with the
current API, and useful (in the common use case of a 3D grid, or a
rectangular grid with irregular spacing, mgrid and ogrid are not enough)
Could someone take a look at it?
Looks like a useful improvement in functionality for little added complexity in the interface. So in principle I'm +1.
The patch does need tests though, and it would be good if someone could check that the 2-D case doesn't get much slower.
Ralf
03/11/11 12:57, Per.Brodtkorb@ffi.no
> There is a ticket for this in numpy:
>
> http://projects.scipy.org/numpy/ticket/966
>
> that needs a decision.
>
> Per A. Brodtkorb
>
> -----Opprinnelig melding-----
> Fra: scipy-dev-bounces@scipy.org [mailto:scipy-dev-bounces@scipy.org] På vegne av Antoine Levitt
> Sendt: 3. november 2011 11:00
> Til: scipy-dev@scipy.org
> Emne: [SciPy-Dev] 3D Meshgrid
>
> Hi,
>
> Could meshgrid be extended to support 3D grids? It's a pretty natural
> use case, and would bring it closer to matlab.
>
> There's some discussion at
> http://stackoverflow.com/questions/1827489/numpy-meshgrid-in-3d
>
> Antoine
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
_______________________________________________
SciPy-Dev mailing list
SciPy-Dev@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20111109/86fd73dd/attachment-0001.html
More information about the SciPy-Dev
mailing list