This is an automated email from the ASF dual-hosted git repository.

iblis pushed a commit to branch ib/jl-fix-clamp-test
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 9f2159b200cdf54a2bb37ee7c0a2c30008f4764f
Author: Iblis Lin <ib...@hs.ntnu.edu.tw>
AuthorDate: Tue Apr 23 09:53:29 2019 +0000

    julia/ndarray: fix flaky test cases for `clamp`
    
    ref: #14757
---
 julia/test/unittest/ndarray.jl | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/julia/test/unittest/ndarray.jl b/julia/test/unittest/ndarray.jl
index 26695e8..638963f 100644
--- a/julia/test/unittest/ndarray.jl
+++ b/julia/test/unittest/ndarray.jl
@@ -886,18 +886,20 @@ function test_saveload()
 end
 
 function test_clamp()
-  dims = rand_dims()
-  @info("NDArray::clamp::dims = $dims")
-
-  j_array, nd_array = rand_tensors(dims)
-  clip_up   = maximum(abs.(j_array)) / 2
-  clip_down = 0
-  clipped   = clamp(nd_array, clip_down, clip_up)
+  @info("NDArray::clamp::dims")
+
+  A = [1 2 3;
+       4 5 6;
+       7 8 9.]
+  B = [3 3 3;
+       4 5 6;
+       7 8 8.]
+  x = NDArray(A)
+  y = clamp(x, 3., 8.)
 
   # make sure the original array is not modified
-  @test copy(nd_array) ≈ j_array
-
-  @test all(clip_down .<= copy(clipped) .<= clip_up)
+  @test copy(x) ≈ A
+  @test copy(y) ≈ B
 
   @info("NDArray::clamp!")
   let

Reply via email to