[Numpy-discussion] Arguments silently ignored (kwargs) in meshgrid etc.

Michael McNeil Forbes michael.forbes+python at gmail.com
Thu May 29 18:16:41 EDT 2014


On May 29, 2014, at 1:41 AM, Ralf Gommers <ralf.gommers at gmail.com> wrote:
> On Thu, May 29, 2014 at 5:35 AM, Michael McNeil Forbes <michael.forbes+python at gmail.com> wrote:
>> I just noticed that meshgrid() silently ignore extra arguments.  It just burned me (I forgot that it is meshgrid(indexing='ij') and tried meshgrid(indices='ij') which subtly broke my code.)
> 
> That's not very user-friendly, a check should be added. Do you want to send a PR for that?

Okay.  Working on it.

Question: Would be be okay to implement this in terms of a private (or public) function, something like:

def _sparsegrid(xi, sparse=True, indexing='ij', copy=True):
   ...

def meshgrid(*xi, **kwargs):
    defaults = dict(sparse=False, indexing='xy', copy=False),
    return _sparsegrid(xi, **dict(defaults, **kwargs))

This also addresses issue #2164 and a personal pet peeve that there is no analogue of ogrid for meshgrid.  (Not sure what the best name would be, maybe meshogrid?)  I see that you removed the original ndgrid implementation that did something similar.  Is there a reason for not providing an analogue?

Michael.








More information about the NumPy-Discussion mailing list