From e8db02018df7ba23a1d7e5bf110150078079a284 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Wed, 25 Oct 2023 12:54:56 +0200 Subject: [PATCH 1/2] Fix tests for ZygoteRule change --- Project.toml | 2 +- test/gradcheck.jl | 4 ++-- test/structures.jl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index eea6cdb90..56179a209 100644 --- a/Project.toml +++ b/Project.toml @@ -46,7 +46,7 @@ Requires = "1.1" PrecompileTools = "1" SpecialFunctions = "1.6, 2" Tracker = "0.2" -ZygoteRules = "0.2.1" +ZygoteRules = "0.2.4" julia = "1.6" [extensions] diff --git a/test/gradcheck.jl b/test/gradcheck.jl index bc22a2016..9ab3bc1e7 100644 --- a/test/gradcheck.jl +++ b/test/gradcheck.jl @@ -114,7 +114,7 @@ end @test gradtest(X -> sum(sum(x -> x^2, X; dims=1)), randn(10)) # issue #681 # Non-differentiable sum of booleans - @test gradient(sum, [true, false, true]) == (nothing,) + @test gradient(sum, [true, false, true]) === nothing @test gradient(x->sum(x .== 0.0), [1.2, 0.2, 0.0, -1.1, 100.0]) == (nothing,) # https://github.com/FluxML/Zygote.jl/issues/314 @@ -178,7 +178,7 @@ end # Ensure that nothings work with non-numeric types. _, back = Zygote.pullback(getindex, [randn(2) for _ in 1:3], [1]) - @test back([nothing]) == (nothing, nothing) + @test back([nothing]) === nothing end @testset "view" begin diff --git a/test/structures.jl b/test/structures.jl index 5a951a621..cdba138c4 100644 --- a/test/structures.jl +++ b/test/structures.jl @@ -64,5 +64,5 @@ end end m, b = Zygote._pullback(Zygote.Context(), nameof, M) - @test b(m) == (nothing, nothing) + @test b(m) === nothing end From 99b79fd66e6b72710b6c2eb397e53b4dcb316cb8 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Thu, 26 Oct 2023 09:02:15 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- test/gradcheck.jl | 2 +- test/structures.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/gradcheck.jl b/test/gradcheck.jl index 9ab3bc1e7..64d5896dd 100644 --- a/test/gradcheck.jl +++ b/test/gradcheck.jl @@ -114,7 +114,7 @@ end @test gradtest(X -> sum(sum(x -> x^2, X; dims=1)), randn(10)) # issue #681 # Non-differentiable sum of booleans - @test gradient(sum, [true, false, true]) === nothing + @test gradient(sum, [true, false, true]) == (nothing,) @test gradient(x->sum(x .== 0.0), [1.2, 0.2, 0.0, -1.1, 100.0]) == (nothing,) # https://github.com/FluxML/Zygote.jl/issues/314 diff --git a/test/structures.jl b/test/structures.jl index cdba138c4..5a951a621 100644 --- a/test/structures.jl +++ b/test/structures.jl @@ -64,5 +64,5 @@ end end m, b = Zygote._pullback(Zygote.Context(), nameof, M) - @test b(m) === nothing + @test b(m) == (nothing, nothing) end