| 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 |
| 4674 | choices = [[0, 1, 2, 3], [10, 11, 12, 13], |
| 4675 | [20, 21, 22, 23], [30, 31, 32, 33]] |
| 4676 | store = empty(4, dtype=int) |
| 4677 | chosen = choose([2, 3, 1, 0], choices, out=store) |
| 4678 | assert_equal(store, array([20, 31, 12, 3])) |
| 4679 | assert_(store is chosen) |
| 4680 | # Check with some masked indices + out |
| 4681 | store = empty(4, dtype=int) |
| 4682 | indices_ = array([2, 3, 1, 0], mask=[1, 0, 0, 1]) |
| 4683 | chosen = choose(indices_, choices, mode='wrap', out=store) |
| 4684 | assert_equal(store, array([99, 31, 12, 99])) |
| 4685 | assert_equal(store.mask, [1, 0, 0, 1]) |
| 4686 | # Check with some masked choices + out ina ndarray ! |
| 4687 | choices = array(choices, mask=[[0, 0, 0, 1], [1, 1, 0, 1], |
| 4688 | [1, 0, 0, 0], [0, 0, 0, 0]]) |
| 4689 | indices_ = [2, 3, 1, 0] |
| 4690 | store = empty(4, dtype=int).view(ndarray) |
| 4691 | chosen = choose(indices_, choices, mode='wrap', out=store) |
| 4692 | assert_equal(store, array([999999, 31, 12, 999999])) |
| 4693 | |
| 4694 | def test_reshape(self): |
| 4695 | a = arange(10) |