summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_index_tricks.py
diff options
context:
space:
mode:
authorShota Kawabuchi <shota.kawabuchi+Github@gmail.com>2016-10-02 15:39:24 +0900
committerShota Kawabuchi <shota.kawabuchi+Github@gmail.com>2016-10-03 00:05:04 +0900
commit364382b375ad547110530acc06f8590d8404e88c (patch)
treef65b42d9184a9da218679dff5edd49d68f7a7615 /numpy/lib/tests/test_index_tricks.py
parent90c166542f39221f68a154a8406b961f5971bff3 (diff)
downloadnumpy-364382b375ad547110530acc06f8590d8404e88c.tar.gz
BUG: add array size overflow check in arr_ravel_multi_index
Diffstat (limited to 'numpy/lib/tests/test_index_tricks.py')
-rw-r--r--numpy/lib/tests/test_index_tricks.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py
index f685528e7..d6b821895 100644
--- a/numpy/lib/tests/test_index_tricks.py
+++ b/numpy/lib/tests/test_index_tricks.py
@@ -47,12 +47,25 @@ class TestRavelUnravelIndex(TestCase):
[[3, 6, 6], [4, 5, 1]])
assert_equal(np.unravel_index(1621, (6, 7, 8, 9)), [3, 1, 4, 1])
- # ravel_multi_index for big indices (issue#7546)
+ def test_big_indices(self):
+ # ravel_multi_index for big indices (issue #7546)
arr = ([1, 29], [3, 5], [3, 117], [19, 2], [2379, 1284], [2, 2], [0, 1])
assert_equal(
np.ravel_multi_index(arr, (41, 7, 120, 36, 2706, 8, 6)),
[5627771580, 117259570957])
+ # test overflow checking for too big array (issue #7546)
+ dummy_arr = ([0],[0])
+ half_max = np.iinfo(np.intp).max // 2
+ assert_equal(
+ np.ravel_multi_index(dummy_arr, (half_max, 2)), [0])
+ assert_raises(ValueError,
+ np.ravel_multi_index, dummy_arr, (half_max+1, 2))
+ assert_equal(
+ np.ravel_multi_index(dummy_arr, (half_max, 2), order='F'), [0])
+ assert_raises(ValueError,
+ np.ravel_multi_index, dummy_arr, (half_max+1, 2), order='F')
+
def test_dtypes(self):
# Test with different data types
for dtype in [np.int16, np.uint16, np.int32,