summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-04-05 15:39:36 -0600
committerGitHub <noreply@github.com>2021-04-05 15:39:36 -0600
commitada694a9c028d78862b90468bd08f92a59229fd8 (patch)
tree380142f495ad04dab23171b6a5cdd12f7ea1edbb
parenta47ecdea856986cd60eabbd53265c2ca5916ad5d (diff)
parent9f339758e3faeb447a629d600f7640c8735a6c4a (diff)
downloadnumpy-ada694a9c028d78862b90468bd08f92a59229fd8.tar.gz
Merge pull request #18708 from DCtheTall/meshgrid-test
TST: add tests for using np.meshgrid for higher dimensional grids.
-rw-r--r--numpy/lib/tests/test_function_base.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index afcb81eff..761ea83a3 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2307,6 +2307,27 @@ class TestMeshgrid:
assert_equal(x[0, :], 0)
assert_equal(x[1, :], X)
+ def test_nd_shape(self):
+ a, b, c, d, e = np.meshgrid(*([0] * i for i in range(1, 6)))
+ expected_shape = (2, 1, 3, 4, 5)
+ assert_equal(a.shape, expected_shape)
+ assert_equal(b.shape, expected_shape)
+ assert_equal(c.shape, expected_shape)
+ assert_equal(d.shape, expected_shape)
+ assert_equal(e.shape, expected_shape)
+
+ def test_nd_values(self):
+ a, b, c = np.meshgrid([0], [1, 2], [3, 4, 5])
+ assert_equal(a, [[[0, 0, 0]], [[0, 0, 0]]])
+ assert_equal(b, [[[1, 1, 1]], [[2, 2, 2]]])
+ assert_equal(c, [[[3, 4, 5]], [[3, 4, 5]]])
+
+ def test_nd_indexing(self):
+ a, b, c = np.meshgrid([0], [1, 2], [3, 4, 5], indexing='ij')
+ assert_equal(a, [[[0, 0, 0], [0, 0, 0]]])
+ assert_equal(b, [[[1, 1, 1], [2, 2, 2]]])
+ assert_equal(c, [[[3, 4, 5], [3, 4, 5]]])
+
class TestPiecewise: