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

Method test_basic

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

Source from the content-addressed store, hash-verified

492class TestInsert:
493
494 def test_basic(self):
495 a = [1, 2, 3]
496 assert_equal(insert(a, 0, 1), [1, 1, 2, 3])
497 assert_equal(insert(a, 3, 1), [1, 2, 3, 1])
498 assert_equal(insert(a, [1, 1, 1], [1, 2, 3]), [1, 1, 2, 3, 2, 3])
499 assert_equal(insert(a, 1, [1, 2, 3]), [1, 1, 2, 3, 2, 3])
500 assert_equal(insert(a, [1, -1, 3], 9), [1, 9, 2, 9, 3, 9])
501 assert_equal(insert(a, slice(-1, None, -1), 9), [9, 1, 9, 2, 9, 3])
502 assert_equal(insert(a, [-1, 1, 3], [7, 8, 9]), [1, 8, 2, 7, 3, 9])
503 b = np.array([0, 1], dtype=np.float64)
504 assert_equal(insert(b, 0, b[0]), [0., 0., 1.])
505 assert_equal(insert(b, [], []), b)
506 # Bools will be treated differently in the future:
507 # assert_equal(insert(a, np.array([True]*4), 9), [9, 1, 9, 2, 9, 3, 9])
508 with warnings.catch_warnings(record=True) as w:
509 warnings.filterwarnings('always', '', FutureWarning)
510 assert_equal(
511 insert(a, np.array([True] * 4), 9), [1, 9, 9, 9, 9, 2, 3])
512 assert_(w[0].category is FutureWarning)
513
514 def test_multidim(self):
515 a = [[1, 1, 1]]

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
insertFunction · 0.90
assert_Function · 0.90

Tested by

no test coverage detected