diff options
Diffstat (limited to 'numpy/lib')
| -rw-r--r-- | numpy/lib/function_base.py | 10 | ||||
| -rw-r--r-- | numpy/lib/tests/test_function_base.py | 7 |
2 files changed, 14 insertions, 3 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index df5876715..9a4c47289 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -3370,9 +3370,13 @@ def meshgrid(*xi, **kwargs): """ ndim = len(xi) - copy_ = kwargs.get('copy', True) - sparse = kwargs.get('sparse', False) - indexing = kwargs.get('indexing', 'xy') + copy_ = kwargs.pop('copy', True) + sparse = kwargs.pop('sparse', False) + indexing = kwargs.pop('indexing', 'xy') + + if kwargs: + raise TypeError("meshgrid() got an unexpected keyword argument '%s'" + % (list(kwargs)[0],)) if not indexing in ['xy', 'ij']: raise ValueError( diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 59db23a83..cb4d6626d 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1454,6 +1454,13 @@ class TestMeshgrid(TestCase): assert_array_equal(X, np.array([[1, 2, 3]])) assert_array_equal(Y, np.array([[4], [5], [6], [7]])) + def test_invalid_arguments(self): + # Test that meshgrid complains about invalid arguments + # Regression test for issue #4755: + # https://github.com/numpy/numpy/issues/4755 + assert_raises(TypeError, meshgrid, + [1, 2, 3], [4, 5, 6, 7], indices='ij') + class TestPiecewise(TestCase): def test_simple(self): |
