[Numpy-discussion] patch for new mgrid / ogrid functionality

Stéfan van der Walt stefan@sun.ac...
Sat Sep 13 01:34:33 CDT 2008


Hey all,

David Kaplan implemented a generalised ogrid/mgrid, and would like to
have some feedback.  See

http://projects.scipy.org/pipermail/numpy-discussion/2008-August/036691.html

for his original email and attachment.

If no one objects to such functionality, I shall review the patch and apply it.

Cheers
Stéfan

2008/8/15 David M. Kaplan <David.Kaplan@ird.fr>:
> Hi,
>
> A while back, I sent some changes to index_tricks.py that would allow
> mgrid and ogrid to mesh things other than slices.  For example:
>
>>>> mgrid[['a','b'],[float,int],:3]
> [array([[['a', 'a', 'a'],
>        ['a', 'a', 'a']],
>
>       [['b', 'b', 'b'],
>        ['b', 'b', 'b']]],
>      dtype='|S1'), array([[[<type 'float'>, <type 'float'>, <type 'float'>],
>        [<type 'int'>, <type 'int'>, <type 'int'>]],
>
>       [[<type 'float'>, <type 'float'>, <type 'float'>],
>        [<type 'int'>, <type 'int'>, <type 'int'>]]], dtype=object), array([[[0, 1, 2],
>        [0, 1, 2]],
>
>       [[0, 1, 2],
>        [0, 1, 2]]])]
>
> At the time, there wasn't much follow-up, but I am hoping that there is
> still interest in this functionality, as I have gone ahead and finished
> the patch including documentation changes and updates to
> test_index_tricks.py.  Attached is a patch set to the latest subversion
> of the numpy trunk.  I don't think I am allowed to commit the changes
> myself - correct me if I am wrong.
>
> This functionality seems like a nice addition to me as it allows one to
> mesh things that are not uniformly spaced and potentially not even
> numbers.  The changes don't affect functionality that existed previously
> except for one minor change - instead of returning a numpy array of
> arrays, mgrid/ogrid now return a list of arrays.  However, this is
> unlikely to be a problem as the majority of users generally unpack the
> results of mgrid/ogrid so that each matrix can be used individually.
>
> Comments welcome.
>
> Cheers,
> David
>
> --
> **********************************
> David M. Kaplan
> Charge de Recherche 1
> Institut de Recherche pour le Developpement
> Centre de Recherche Halieutique Mediterraneenne et Tropicale
> av. Jean Monnet
> B.P. 171
> 34203 Sete cedex
> France
>
> Phone: +33 (0)4 99 57 32 27
> Fax: +33 (0)4 99 57 32 95
> http://www.ur097.ird.fr/team/dkaplan/index.html
> **********************************


More information about the Numpy-discussion mailing list