You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/03/31 05:40:28 UTC

[GitHub] szha closed pull request #10313: [MXNET-258] Improve flaky test_random.test_shuffle

szha closed pull request #10313: [MXNET-258] Improve flaky test_random.test_shuffle
URL: https://github.com/apache/incubator-mxnet/pull/10313
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/tests/python/unittest/test_random.py b/tests/python/unittest/test_random.py
index c8dc3c97a81..5138728bfe6 100644
--- a/tests/python/unittest/test_random.py
+++ b/tests/python/unittest/test_random.py
@@ -554,6 +554,7 @@ def compute_expected_prob():
     mx.test_utils.assert_almost_equal(exp_cnt_sampled.asnumpy(), exp_cnt[sampled_classes].asnumpy(), rtol=1e-1, atol=1e-2)
     mx.test_utils.assert_almost_equal(exp_cnt_true.asnumpy(), exp_cnt[true_classes].asnumpy(), rtol=1e-1, atol=1e-2)
 
+# Issue #10277 (https://github.com/apache/incubator-mxnet/issues/10277) discusses this test.
 @with_seed()
 def test_shuffle():
     def check_first_axis_shuffle(arr):
@@ -596,7 +597,8 @@ def testSmall(data, repeat1, repeat2):
         # The outcomes must be uniformly distributed.
         # If `repeat2` is not large enough, this could fail with high probability.
         for p in itertools.permutations(range(0, data.size - stride + 1, stride)):
-            assert abs(1. * count[str(mx.nd.array(p))] / repeat2 - 1. / math.factorial(data.shape[0])) < 0.01
+            err = abs(1. * count[str(mx.nd.array(p))] / repeat2 - 1. / math.factorial(data.shape[0]))
+            assert err < 0.01, "The absolute error {} is larger than the tolerance.".format(err)
         # Check symbol interface
         a = mx.sym.Variable('a')
         b = mx.sym.random.shuffle(a)
@@ -622,9 +624,9 @@ def testLarge(data, repeat):
         assert len(count) == repeat
 
     # Test small arrays with different shapes
-    testSmall(mx.nd.arange(0, 3), 100, 20000)
-    testSmall(mx.nd.arange(0, 9).reshape((3, 3)), 100, 20000)
-    testSmall(mx.nd.arange(0, 18).reshape((3, 2, 3)), 100, 20000)
+    testSmall(mx.nd.arange(0, 3), 100, 40000)
+    testSmall(mx.nd.arange(0, 9).reshape((3, 3)), 100, 40000)
+    testSmall(mx.nd.arange(0, 18).reshape((3, 2, 3)), 100, 40000)
     # Test larger arrays
     testLarge(mx.nd.arange(0, 100000).reshape((10, 10000)), 10)
     testLarge(mx.nd.arange(0, 100000).reshape((10000, 10)), 10)


 

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


With regards,
Apache Git Services