Skip to content

Commit

Permalink
Add sort(x; rev=true) tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Jan 3, 2024
1 parent 4de0cf2 commit 03a8ef7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/gradcheck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,17 @@ end
[2,3,1],
[1, 2, 3],
[1,2,3],
[2,1,3]
[2,1,3],
[1,3,2],
[3,2,1]
]
for i = 1:3
@test gradient(v->sort(v)[i], [3.,1,2])[1][correct[1][i]] == 1
@test gradient(v->sort(v)[i], [1.,2,3])[1][correct[2][i]] == 1
@test gradient(v->sort(v,by=x->x%10)[i], [11,2,99])[1][correct[3][i]] == 1
@test gradient(v->sort(v,by=x->x%10)[i], [2,11,99])[1][correct[4][i]] == 1
@test gradient(v->sort(v,rev=true)[i], [3.,1,2])[1][correct[5][i]] == 1
@test gradient(v->sort(v,rev=true)[i], [1.,2,3])[1][correct[6][i]] == 1
end
end

Expand Down

0 comments on commit 03a8ef7

Please sign in to comment.