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

Add exception check for numpy reshape #16180

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()