haojin2 commented on a change in pull request #16786: Add OP diag [numpy]
URL: https://github.com/apache/incubator-mxnet/pull/16786#discussion_r346058775
 
 

 ##########
 File path: tests/python/unittest/test_numpy_op.py
 ##########
 @@ -4403,6 +4403,68 @@ def hybrid_forward(self, F, x, *args, **kwargs):
         assert_almost_equal(ret.asnumpy(), expected_ret, atol=1e-5, rtol=1e-5, 
use_broadcast=False)
 
 
+@with_seed()
+@use_np
+def test_np_diag():
+    class TestDiag(HybridBlock):
+        def __init__(self, k=0):
+            super(TestDiag, self).__init__()
+            self._k = k
+            # necessary initializations
+
+        def hybrid_forward(self, F, a):
+            return F.np.diag(a, k=self._k)
+            
+    shapes = [(2,), 5, (1, 5), (2, 2), (2, 5), (3, 3), (4, 3)]
+    dtypes = [np.int8, np.uint8, np.int32, np.int64, np.float16, np.float32, 
np.float64]
+    range_k = 6
+    for hybridize, shape, dtype, in itertools.product([False, True], shapes, 
dtypes):
 
 Review comment:
   ```Python
   for hybridize, shape, dtype, in itertools.product([False, True], shapes, 
dtypes, list(range(-range_k, range_k))):
   ```
   and get rid of the `for k in range(-range_k, range_k)` below

----------------------------------------------------------------
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