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

Method test_choose

numpy/ma/tests/test_core.py:4649–4670  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4647 assert np.may_share_memory(a._data, res._data) != copy
4648
4649 def test_choose(self):
4650 # Test choose
4651 choices = [[0, 1, 2, 3], [10, 11, 12, 13],
4652 [20, 21, 22, 23], [30, 31, 32, 33]]
4653 chosen = choose([2, 3, 1, 0], choices)
4654 assert_equal(chosen, array([20, 31, 12, 3]))
4655 chosen = choose([2, 4, 1, 0], choices, mode='clip')
4656 assert_equal(chosen, array([20, 31, 12, 3]))
4657 chosen = choose([2, 4, 1, 0], choices, mode='wrap')
4658 assert_equal(chosen, array([20, 1, 12, 3]))
4659 # Check with some masked indices
4660 indices_ = array([2, 4, 1, 0], mask=[1, 0, 0, 1])
4661 chosen = choose(indices_, choices, mode='wrap')
4662 assert_equal(chosen, array([99, 1, 12, 99]))
4663 assert_equal(chosen.mask, [1, 0, 0, 1])
4664 # Check with some masked choices
4665 choices = array(choices, mask=[[0, 0, 0, 1], [1, 1, 0, 1],
4666 [1, 0, 0, 0], [0, 0, 0, 0]])
4667 indices_ = [2, 3, 1, 0]
4668 chosen = choose(indices_, choices, mode='wrap')
4669 assert_equal(chosen, array([20, 31, 12, 3]))
4670 assert_equal(chosen.mask, [1, 0, 0, 1])
4671
4672 def test_choose_with_out(self):
4673 # Test choose with an explicit out keyword

Callers

nothing calls this directly

Calls 3

chooseFunction · 0.90
assert_equalFunction · 0.90
arrayFunction · 0.90

Tested by

no test coverage detected