eric-haibin-lin commented on a change in pull request #12749: [MXNET-1029] 
Feature request: randint operator
URL: https://github.com/apache/incubator-mxnet/pull/12749#discussion_r230528550
 
 

 ##########
 File path: tests/python/unittest/test_random.py
 ##########
 @@ -844,6 +844,50 @@ def testLarge(data, repeat):
     testLarge(mx.nd.arange(0, 100000).reshape((10, 10000)), 10)
     testLarge(mx.nd.arange(0, 100000).reshape((10000, 10)), 10)
 
+@with_seed()
+def test_randint():
+    dtypes = ['int32', 'int64']
+    for dtype in dtypes:
+        params = {
+            'low': -1,
+            'high': 3,
+            'shape' : (500, 500),
+            'dtype' : dtype,
+            'ctx' : mx.context.cpu()
+            }
+        mx.random.seed(128)
+        ret1 = mx.nd.random.randint(**params).asnumpy()
+        mx.random.seed(128)
+        ret2 = mx.nd.random.randint(**params).asnumpy()
+        assert same(ret1, ret2), \
+                "ndarray test: `%s` should give the same result with the same 
seed"
+
+@with_seed()
+def test_randint_extremes():
+    a = mx.nd.random.randint(dtype='int64', low=50000000, high=50000010, 
ctx=mx.context.cpu())
+    assert a>=50000000 and a<=50000010
+
+@with_seed()
+def test_randint_generator():
+    ctx = mx.context.cpu()
+    low = 50000000
+    high = 50010000
+    for dtype in ['int64']:
+        print("ctx=%s, dtype=%s, Low=%g, High=%g:" % (ctx, dtype, low, high))
 
 Review comment:
   Can you remove print stmt in the test? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to