MCPcopy Index your code
hub / github.com/numpy/numpy / test_choose

Method test_choose

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

Source from the content-addressed store, hash-verified

4874 assert np.may_share_memory(a._data, res._data) != copy
4875
4876 def test_choose(self):
4877 # Test choose
4878 choices = [[0, 1, 2, 3], [10, 11, 12, 13],
4879 [20, 21, 22, 23], [30, 31, 32, 33]]
4880 chosen = choose([2, 3, 1, 0], choices)
4881 assert_equal(chosen, array([20, 31, 12, 3]))
4882 chosen = choose([2, 4, 1, 0], choices, mode='clip')
4883 assert_equal(chosen, array([20, 31, 12, 3]))
4884 chosen = choose([2, 4, 1, 0], choices, mode='wrap')
4885 assert_equal(chosen, array([20, 1, 12, 3]))
4886 # Check with some masked indices
4887 indices_ = array([2, 4, 1, 0], mask=[1, 0, 0, 1])
4888 chosen = choose(indices_, choices, mode='wrap')
4889 assert_equal(chosen, array([99, 1, 12, 99]))
4890 assert_equal(chosen.mask, [1, 0, 0, 1])
4891 # Check with some masked choices
4892 choices = array(choices, mask=[[0, 0, 0, 1], [1, 1, 0, 1],
4893 [1, 0, 0, 0], [0, 0, 0, 0]])
4894 indices_ = [2, 3, 1, 0]
4895 chosen = choose(indices_, choices, mode='wrap')
4896 assert_equal(chosen, array([20, 31, 12, 3]))
4897 assert_equal(chosen.mask, [1, 0, 0, 1])
4898
4899 def test_choose_with_out(self):
4900 # 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