[SciPy-Dev] 3D Meshgrid

Ralf Gommers ralf.gommers@googlemail....
Mon Nov 14 14:04:28 CST 2011


On Mon, Nov 14, 2011 at 1:42 PM, <Per.Brodtkorb@ffi.no> wrote:

> Hi, ****
>
> ** **
>
> I have added a new patch that incorporates the suggestions from Ralf as
> well as tests for the sparse=True and indexing=ij cases at
> http://projects.scipy.org/numpy/ticket/966.****
>
> ** **
>
> If someone could have look at it, that would be great.
>

Looks good based on a quick browse. I'd remove the ndgrid function though,
it doesn't add anything extra and the numpy namespace is large enough.

I have no time to test/merge this for a couple of weeks, so if someone
wants to do so please go ahead.

Last suggestion for a change: mention this enhancement in the release notes
for 2.0.0 (found under doc/release/) and add yourself to the list of
contributors in THANKS.txt.

Cheers,
Ralf


****
>
> ** **
>
> Per A. Brodtkorb****
>
> ** **
>
> *Fra:* scipy-dev-bounces@scipy.org [mailto:scipy-dev-bounces@scipy.org] *På
> vegne av* Ralf Gommers
> *Sendt:* 11. november 2011 20:50
>
> *Til:* SciPy Developers List
> *Emne:* Re: [SciPy-Dev] 3D Meshgrid****
>
> ** **
>
> ** **
>
> On Wed, Nov 9, 2011 at 8:39 AM, <Per.Brodtkorb@ffi.no> wrote:****
>
> Ø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*****
>
>
> That looks good. The benchmark for larger arrays is more important I
> think.
>
> +1 on merging this. If you or someone else could add some tests that cover
> the new functionality and send a pull request, that would be helpful. There
> are some other small things in the patch that need to be fixed, I'll add
> those to the ticket.
>
> Cheers,
> Ralf****
>
>  ****
>
> *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****
>
> ** **
>
> _______________________________________________
> 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/20111114/09f1f036/attachment.html 


More information about the SciPy-Dev mailing list