xiezhq-hermann commented on a change in pull request #15906: [Numpy] Numpy 
operator diff
URL: https://github.com/apache/incubator-mxnet/pull/15906#discussion_r323559384
 
 

 ##########
 File path: tests/python/unittest/test_numpy_op.py
 ##########
 @@ -1519,6 +1519,58 @@ def hybrid_forward(self, F, a):
                         assert_almost_equal(mx_out.asnumpy(), np_out, 
rtol=1e-3, atol=1e-5)
 
 
+@with_seed()
+@use_np
+def test_np_diff():
+    def np_diff_backward(ograd, n, axis):
+        res = ograd
+        for i in range(n):
+            res = _np.negative(_np.diff(res, n=1, axis=axis, prepend=0, 
append=0))
+        return res
+
+    class TestDiff(HybridBlock):
+        def __init__(self, n=1, axis=-1):
+            super(TestDiff, self).__init__()
+            self._n = n
+            self._axis = axis
+
+        def hybrid_forward(self, F, a):
+            return F.np.diff(a, n=self._n, axis=self._axis)
+
+    shapes = [tuple(random.randrange(10) for i in range(random.randrange(6))) 
for j in range(5)]
 
 Review comment:
   I agreed your opinions and that's what I did before, but the present random 
cases generator should be concise and easy to understand. 
   The tests are switched to random cases mainly for the balance of time cost 
and test coverage, which is advised by @haojin2 , could you reach an agreement?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to