MCPcopy Create free account
hub / github.com/numpy/numpy / test_indexing

Method test_indexing

numpy/lib/tests/test_function_base.py:2532–2550  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2530 assert_array_equal([], meshgrid(*args, copy=False))
2531
2532 def test_indexing(self):
2533 x = [1, 2, 3]
2534 y = [4, 5, 6, 7]
2535 [X, Y] = meshgrid(x, y, indexing='ij')
2536 assert_array_equal(X, np.array([[1, 1, 1, 1],
2537 [2, 2, 2, 2],
2538 [3, 3, 3, 3]]))
2539 assert_array_equal(Y, np.array([[4, 5, 6, 7],
2540 [4, 5, 6, 7],
2541 [4, 5, 6, 7]]))
2542
2543 # Test expected shapes:
2544 z = [8, 9]
2545 assert_(meshgrid(x, y)[0].shape == (4, 3))
2546 assert_(meshgrid(x, y, indexing='ij')[0].shape == (3, 4))
2547 assert_(meshgrid(x, y, z)[0].shape == (4, 3, 2))
2548 assert_(meshgrid(x, y, z, indexing='ij')[0].shape == (3, 4, 2))
2549
2550 assert_raises(ValueError, meshgrid, x, y, indexing='notvalid')
2551
2552 def test_sparse(self):
2553 [X, Y] = meshgrid([1, 2, 3], [4, 5, 6, 7], sparse=True)

Callers

nothing calls this directly

Calls 4

meshgridFunction · 0.90
assert_array_equalFunction · 0.90
assert_Function · 0.90
assert_raisesFunction · 0.90

Tested by

no test coverage detected