haojin2 commented on a change in pull request #17904: [Numpy] add: numpy op
trilindices
URL: https://github.com/apache/incubator-mxnet/pull/17904#discussion_r400586071
##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -6693,6 +6693,35 @@ def test_np_builtin_op_signature():
assert op is not None
assert str(op.__signature__) == str(inspect.signature(_op_from_doc))
+@with_seed()
+@use_np
+def test_np_tril_indices():
+ class TestTrilindices(HybridBlock):
+ def __init__(self, n, k=0, m=None):
+ super(TestTrilindices, self).__init__()
+ self._n = n;
+ self._k = k;
+ if m is None:
+ m = n
+ self._m = m
+
+ def hybrid_forward(self, F, x, *args, **kwargs):
+ return x, F.np.tril_indices(n=self._n, k=self._k, m=self._m)
+
+ for n in _np.random.random_integers(-10, 50, 10):
+ for k in _np.random.random_integers(-50, 50, 4):
+ for m in _np.random.random_integers(-10, 50, 4):
+ np_out = _np.tril_indices(n, k, m)
+ for hybridize in [True, False]:
+ # dummy nparray for hybridize
+ x = mx.nd.ones((1,1)).as_np_ndarray()
+ test_trilindices = TestTrilindices(n, k, m)
+ if hybridize:
+ test_trilindices.hybridize()
+ mx_out = test_trilindices(x)[1]
+ assert len(mx_out) == 2
+ assert same(mx_out[0], np_out[0])
+ assert same(mx_out[1], np_out[1])
Review comment:
an extra blank line 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:
[email protected]
With regards,
Apache Git Services