diff options
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 95b32e47c..81892e634 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1177,6 +1177,34 @@ class TestMeshgrid(TestCase): [6, 6, 6], [7, 7, 7]]))) + def test_single_input(self): + assert_raises(ValueError, meshgrid, np.arange(5)) + + def test_indexing(self): + x = [1, 2, 3] + y = [4, 5, 6, 7] + [X, Y] = meshgrid(x, y, indexing='ij') + assert_(all(X == array([[1, 1, 1, 1], + [2, 2, 2, 2], + [3, 3, 3, 3]]))) + assert_(all(Y == array([[4, 5, 6, 7], + [4, 5, 6, 7], + [4, 5, 6, 7]]))) + + # Test expected shapes: + z = [8, 9] + assert_(meshgrid(x, y)[0].shape == (4, 3)) + assert_(meshgrid(x, y, indexing='ij')[0].shape == (3, 4)) + assert_(meshgrid(x, y, z)[0].shape == (4, 3, 2)) + assert_(meshgrid(x, y, z, indexing='ij')[0].shape == (3, 4, 2)) + + assert_raises(ValueError, meshgrid, x, y, indexing='notvalid') + + def test_sparse(self): + [X, Y] = meshgrid([1, 2, 3], [4, 5, 6, 7], sparse=True) + assert_(all(X == array([[1, 2, 3]]))) + assert_(all(Y == array([[4], [5], [6], [7]]))) + class TestPiecewise(TestCase): def test_simple(self): |