diff options
author | rhewett <rhewett@mit.edu> | 2013-12-07 15:08:26 -0800 |
---|---|---|
committer | rhewett <rhewett@mit.edu> | 2013-12-18 04:56:34 -0800 |
commit | a8e86abb2d5c9ff0a62cbe4ad846d3b44993f878 (patch) | |
tree | b71c9df2116b2088bc0845fc65973493b0bb9495 /numpy/lib/tests/test_function_base.py | |
parent | 3aa76bac67882f29901640f73cdb1b9d9e0c9029 (diff) | |
download | numpy-a8e86abb2d5c9ff0a62cbe4ad846d3b44993f878.tar.gz |
ENH: Allow meshgrid to work for 1D and 0D cases.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index d1069cf92..2255c0b36 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1311,28 +1311,33 @@ class TestMsort(TestCase): class TestMeshgrid(TestCase): def test_simple(self): [X, Y] = meshgrid([1, 2, 3], [4, 5, 6, 7]) - assert_(np.all(X == np.array([[1, 2, 3], - [1, 2, 3], - [1, 2, 3], - [1, 2, 3]]))) - assert_(np.all(Y == np.array([[4, 4, 4], - [5, 5, 5], - [6, 6, 6], - [7, 7, 7]]))) + assert_array_equal(X, np.array([[1, 2, 3], + [1, 2, 3], + [1, 2, 3], + [1, 2, 3]])) + assert_array_equal(Y, np.array([[4, 4, 4], + [5, 5, 5], + [6, 6, 6], + [7, 7, 7]])) def test_single_input(self): - assert_raises(ValueError, meshgrid, np.arange(5)) + [X] = meshgrid([1, 2, 3, 4]) + assert_array_equal(X, np.array([1, 2, 3, 4])) + + def test_no_input(self): + args = [] + assert_array_equal([], meshgrid(*args)) def test_indexing(self): x = [1, 2, 3] y = [4, 5, 6, 7] [X, Y] = meshgrid(x, y, indexing='ij') - assert_(np.all(X == np.array([[1, 1, 1, 1], - [2, 2, 2, 2], - [3, 3, 3, 3]]))) - assert_(np.all(Y == np.array([[4, 5, 6, 7], - [4, 5, 6, 7], - [4, 5, 6, 7]]))) + assert_array_equal(X, np.array([[1, 1, 1, 1], + [2, 2, 2, 2], + [3, 3, 3, 3]])) + assert_array_equal(Y, np.array([[4, 5, 6, 7], + [4, 5, 6, 7], + [4, 5, 6, 7]])) # Test expected shapes: z = [8, 9] @@ -1345,8 +1350,8 @@ class TestMeshgrid(TestCase): def test_sparse(self): [X, Y] = meshgrid([1, 2, 3], [4, 5, 6, 7], sparse=True) - assert_(np.all(X == np.array([[1, 2, 3]]))) - assert_(np.all(Y == np.array([[4], [5], [6], [7]]))) + assert_array_equal(X, np.array([[1, 2, 3]])) + assert_array_equal(Y, np.array([[4], [5], [6], [7]])) class TestPiecewise(TestCase): |