wkcn commented on a change in pull request #17975:
URL: https://github.com/apache/incubator-mxnet/pull/17975#discussion_r428987267
##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -9557,3 +9557,67 @@ def hybrid_forward(self, F, a):
elif grad_req == 'add':
assert_almost_equal(new_grad, old_grad + 1)
+
+@with_seed()
+@use_np
+def test_np_reduce():
+ from numpy.testing import assert_array_equal, assert_array_almost_equal
+ # a list of (dtype, decimal)
+ # The decimal of an integer is 0
+ dtypes = [('float16', 1),
+ ('float32', 4),
+ (np.int8, 0),
+ (np.uint8, 0),
+ (np.int32, 0),
+ (np.int64, 0),
+ (np.float16, 1),
+ (np.float32, 4),
+ (np.float64, 6)]
+ shapes = [
+ (),
+ (1,),
+ (5,),
+ (4, 3),
+ (3, 5),
+ (4, 4),
+ (4, 5),
+ (5, 5),
+ (5, 6),
+ (6, 6),
+ (6, 5, 6),
+ (2, 3, 3, 4),
+ (4, 2, 1, 2),
+ ]
+
+ def _get_data(case, dtype, shape):
+ data = _np.random.uniform(-1.0, 1.0, shape).astype(dtype)
+ assert data.size > 0
+ for v in case:
+ i = _np.random.randint(0, data.size)
+ data.ravel()[i] = v
+ return data
+
+ def _get_cases(decimal):
+ if decimal == 0:
+ # integer
+ return [()]
+ options = [_np.inf, -_np.inf, np.nan]
Review comment:
options = [_np.inf, -_np.inf, _np.nan]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]