summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorTravis E. Oliphant <teoliphant@gmail.com>2012-07-17 19:25:56 -0700
committerTravis E. Oliphant <teoliphant@gmail.com>2012-07-17 19:25:56 -0700
commit0b2bfa9c13070b08b3632f15a3aa327146994cc4 (patch)
treeeda0cbf90d61473d4611cefbcb6064a926adae80 /numpy/lib/tests
parentc83e5b691513f235c7f1deb398943bf9cd4b35bb (diff)
parentd48b756b232c99b6624d76db3188090052e0db60 (diff)
downloadnumpy-0b2bfa9c13070b08b3632f15a3aa327146994cc4.tar.gz
Merge pull request #192 from rgommers/meshgrid3d
Meshgrid enhancements (>2-D, sparse grids, matrix indexing)
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_function_base.py28
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):