Skip to content

Commit 2fbe8d9

Browse files
iblislinlanking520
authored andcommitted
julia/ndarray: fix flaky test cases for clamp (#14776)
ref: #14757
1 parent 24d4b70 commit 2fbe8d9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

test/unittest/ndarray.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -886,18 +886,20 @@ function test_saveload()
886886
end
887887

888888
function test_clamp()
889-
dims = rand_dims()
890-
@info("NDArray::clamp::dims = $dims")
891-
892-
j_array, nd_array = rand_tensors(dims)
893-
clip_up = maximum(abs.(j_array)) / 2
894-
clip_down = 0
895-
clipped = clamp(nd_array, clip_down, clip_up)
889+
@info("NDArray::clamp::dims")
890+
891+
A = [1 2 3;
892+
4 5 6;
893+
7 8 9.]
894+
B = [3 3 3;
895+
4 5 6;
896+
7 8 8.]
897+
x = NDArray(A)
898+
y = clamp(x, 3., 8.)
896899

897900
# make sure the original array is not modified
898-
@test copy(nd_array) j_array
899-
900-
@test all(clip_down .<= copy(clipped) .<= clip_up)
901+
@test copy(x) A
902+
@test copy(y) B
901903

902904
@info("NDArray::clamp!")
903905
let

0 commit comments

Comments
 (0)