diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-10-17 23:42:12 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-10-17 23:42:12 -0700 |
commit | 39a7681bfe3fb78f549d5893333eecb7fd41fe29 (patch) | |
tree | 872c14a8bcc54269a4bef741f14fb7e243851904 /numpy/lib/tests/test_index_tricks.py | |
parent | 1d67d8896de9242248cf2bcaea7ed8308756dff0 (diff) | |
download | numpy-39a7681bfe3fb78f549d5893333eecb7fd41fe29.tar.gz |
BUG: Allow `unravel_index(0, ())` to return ()
Fixes gh-580
Diffstat (limited to 'numpy/lib/tests/test_index_tricks.py')
-rw-r--r-- | numpy/lib/tests/test_index_tricks.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py index 452b3d6a2..1d5efef86 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -3,7 +3,8 @@ from __future__ import division, absolute_import, print_function import numpy as np from numpy.testing import ( run_module_suite, assert_, assert_equal, assert_array_equal, - assert_almost_equal, assert_array_almost_equal, assert_raises + assert_almost_equal, assert_array_almost_equal, assert_raises, + assert_raises_regex ) from numpy.lib.index_tricks import ( mgrid, ndenumerate, fill_diagonal, diag_indices, diag_indices_from, @@ -114,6 +115,16 @@ class TestRavelUnravelIndex(object): assert_(y.flags.writeable) + def test_0d(self): + # gh-580 + x = np.unravel_index(0, ()) + assert_equal(x, ()) + + assert_raises_regex(ValueError, "0d array", np.unravel_index, [0], ()) + assert_raises_regex( + ValueError, "out of bounds", np.unravel_index, [1], ()) + + class TestGrid(object): def test_basic(self): a = mgrid[-1:1:10j] |