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

Method test_choose_with_out

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

Source from the content-addressed store, hash-verified

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
4901 choices = [[0, 1, 2, 3], [10, 11, 12, 13],
4902 [20, 21, 22, 23], [30, 31, 32, 33]]
4903 store = empty(4, dtype=int)
4904 chosen = choose([2, 3, 1, 0], choices, out=store)
4905 assert_equal(store, array([20, 31, 12, 3]))
4906 assert_(store is chosen)
4907 # Check with some masked indices + out
4908 store = empty(4, dtype=int)
4909 indices_ = array([2, 3, 1, 0], mask=[1, 0, 0, 1])
4910 chosen = choose(indices_, choices, mode='wrap', out=store)
4911 assert_equal(store, array([99, 31, 12, 99]))
4912 assert_equal(store.mask, [1, 0, 0, 1])
4913 # Check with some masked choices + out ina ndarray !
4914 choices = array(choices, mask=[[0, 0, 0, 1], [1, 1, 0, 1],
4915 [1, 0, 0, 0], [0, 0, 0, 0]])
4916 indices_ = [2, 3, 1, 0]
4917 store = empty(4, dtype=int).view(ndarray)
4918 chosen = choose(indices_, choices, mode='wrap', out=store)
4919 assert_equal(store, array([999999, 31, 12, 999999]))
4920
4921 def test_reshape(self):
4922 a = arange(10)

Callers

nothing calls this directly

Calls 6

chooseFunction · 0.90
assert_equalFunction · 0.90
arrayFunction · 0.90
emptyFunction · 0.85
assert_Function · 0.85
viewMethod · 0.45

Tested by

no test coverage detected