Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
add exception check for numpy reshape (#16180)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxjscience authored Sep 18, 2019
1 parent 995b477 commit 1e058a3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/python/unittest/test_exc_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ def check_resize():
assert_raises(MXNetError, check_resize)


@with_seed()
def test_np_reshape_exception():
a = mx.np.ones((10, 10))
a.reshape((-1,)).asnumpy() # Check no-raise
assert_raises(MXNetError, lambda: a.reshape((1,)))
assert_raises(MXNetError, lambda: mx.np.reshape(a, (1,)))
assert_raises(MXNetError, lambda: mx.np.reshape(a, (-1, 3)))


if __name__ == '__main__':
import nose
nose.runmodule()

0 comments on commit 1e058a3

Please sign in to comment.