Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Aug 19, 2021
1 parent 0bae677 commit 6c51745
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/compiler/chainrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ The two-argument `_project(x, dx)` applies this immediately.
# Solve some ambiguity:
(::ProjectTo{ChainRulesCore.NoTangent})(::ChainRulesCore.AbstractZero) = NoTangent()

# some splat?
(project::ProjectTo{AbstractArray})(dx::ChainRulesCore.Tangent{<:Any, <:Tuple}) = project(collect(ChainRulesCore.backing(dx)))

"""
ZBack{F}(back) <: Function
Expand Down
4 changes: 2 additions & 2 deletions test/gradcheck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ end
@test gradient(x -> sum(log, filter(iseven, x)), 1:10) ==
(map(x -> iseven(x) ? 1/x : 0, 1:10),)
@test gradient(x -> sum(abs2, im .+ filter(iseven, x)), 1:10) ==
(map(x -> iseven(x) ? 2x+2im : 0, 1:10),)
(map(x -> iseven(x) ? 2x : 0, 1:10),)
# (map(x -> iseven(x) ? 2x+2im : 0, 1:10),)
end


@testset "mean" begin
@test gradtest(mean, rand(2, 3))

Expand Down

0 comments on commit 6c51745

Please sign in to comment.