summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorseberg <sebastian@sipsolutions.net>2013-12-22 12:39:42 -0800
committerseberg <sebastian@sipsolutions.net>2013-12-22 12:39:42 -0800
commit0856259fde5351d29eeabfc064ef9d625cf27339 (patch)
treee7a796a54315aaa1e6ef1ae9c81ef3d26806a63b /numpy/lib/tests/test_function_base.py
parent86df1b137af94fc5f1af7b9e5f14f30d065ad26e (diff)
parenta8e86abb2d5c9ff0a62cbe4ad846d3b44993f878 (diff)
downloadnumpy-0856259fde5351d29eeabfc064ef9d625cf27339.tar.gz
Merge pull request #4112 from rhewett/meshgrid_single
ENH: Allow meshgrid to take 1D and 0D inputs
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py39
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):