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

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
reminisce committed Feb 7, 2020
1 parent d71f23b commit 1faf352
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion python/mxnet/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from .symbol.numpy import _Symbol as np_symbol
from .util import use_np # pylint: disable=unused-import
from .runtime import Features
from .numpy_extension import get_cuda_compute_capability


def default_context():
Expand Down
13 changes: 11 additions & 2 deletions tests/python/unittest/test_numpy_interoperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
_INT_DTYPES = [np.int8, np.int32, np.int64, np.uint8]
_FLOAT_DTYPES = [np.float16, np.float32, np.float64]
_DTYPES = _INT_DTYPES + _FLOAT_DTYPES
_SKIP_ASSERT_EQUAL_LIST = [
'empty_like',
]


class OpArgMngr(object):
Expand Down Expand Up @@ -1941,11 +1944,17 @@ def _check_interoperability_helper(op_name, *args, **kwargs):
assert type(out) == type(expected_out)
for arr, expected_arr in zip(out, expected_out):
if isinstance(arr, np.ndarray):
assert_almost_equal(arr.asnumpy(), expected_arr, rtol=1e-3, atol=1e-4, use_broadcast=False, equal_nan=True)
if op_name in _SKIP_ASSERT_EQUAL_LIST:
assert arr.shape == expected_arr.shape
else:
assert_almost_equal(arr.asnumpy(), expected_arr, rtol=1e-3, atol=1e-4, use_broadcast=False, equal_nan=True)
else:
_np.testing.assert_equal(arr, expected_arr)
elif isinstance(out, np.ndarray):
assert_almost_equal(out.asnumpy(), expected_out, rtol=1e-3, atol=1e-4, use_broadcast=False, equal_nan=True)
if op_name in _SKIP_ASSERT_EQUAL_LIST:
assert out.shape == expected_out.shape
else:
assert_almost_equal(out.asnumpy(), expected_out, rtol=1e-3, atol=1e-4, use_broadcast=False, equal_nan=True)
else:
_np.testing.assert_almost_equal(out, expected_out)

Expand Down

0 comments on commit 1faf352

Please sign in to comment.