diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2013-10-27 22:24:17 +0100 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2014-02-06 17:51:59 +0100 |
commit | 628f60db43282e87a56e98561211ad04cf55eed7 (patch) | |
tree | b9bc81d51761dbcafe19ee00e009769cc282fae7 | |
parent | 52b4a94b8d01854246bdb6cd53337d043d635251 (diff) | |
download | numpy-628f60db43282e87a56e98561211ad04cf55eed7.tar.gz |
TST: Just one more small test
-rw-r--r-- | numpy/core/tests/test_indexing.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py index 892a85811..09be557c9 100644 --- a/numpy/core/tests/test_indexing.py +++ b/numpy/core/tests/test_indexing.py @@ -116,6 +116,7 @@ class TestIndexing(TestCase): a[b] = 1. assert_equal(a, [[1., 1., 1.]]) + def test_boolean_assignment_value_mismatch(self): # A boolean assignment should fail when the shape of the values # cannot be broadcasted to the subscription. (see also gh-3458) @@ -127,6 +128,7 @@ class TestIndexing(TestCase): assert_raises(ValueError, f, a, [1, 2, 3]) assert_raises(ValueError, f, a[:1], [1, 2, 3]) + def test_boolean_indexing_twodim(self): # Indexing a 2-dimensional array with # 2-dimensional boolean array @@ -194,6 +196,24 @@ class TestIndexing(TestCase): assert_(a is not a[:]) + def test_broaderrors_indexing(self): + a = np.zeros((5, 5)) + assert_raises(IndexError, a.__getitem__, ([0, 1], [0, 1, 2])) + assert_raises(IndexError, a.__setitem__, ([0, 1], [0, 1, 2]), 0) + + + def test_trivial_fancy_out_of_bounds(self): + a = np.zeros(5) + ind = np.ones(20, dtype=np.intp) + ind[-1] = 10 + assert_raises(IndexError, a.__getitem__, ind) + assert_raises(IndexError, a.__setitem__, ind, 0) + ind = np.ones(20, dtype=np.intp) + ind[0] = 11 + assert_raises(IndexError, a.__getitem__, ind) + assert_raises(IndexError, a.__setitem__, ind, 0) + + class TestBroadcastedAssignments(TestCase): def assign(self, a, ind, val): a[ind] = val |