From de65c8e583208b36550e62f807b79a38350e9f12 Mon Sep 17 00:00:00 2001 From: Frames White Date: Tue, 25 Jul 2023 14:42:08 -0400 Subject: [PATCH] Make tests work (many marked broken) --- Project.toml | 10 ++++++++++ test/AbstractDifferentiationTests.jl | 18 +++++++++++++----- test/Project.toml | 22 ---------------------- 3 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 test/Project.toml diff --git a/Project.toml b/Project.toml index 35d27fd5..52f043f4 100644 --- a/Project.toml +++ b/Project.toml @@ -16,6 +16,13 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" +[extras] +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + [compat] ChainRules = "1.44.6" ChainRulesCore = "1.15.3" @@ -27,3 +34,6 @@ StaticArrays = "1" StatsBase = "0.33" StructArrays = "0.6" julia = "1.10" + +[targets] +test = ["ForwardDiff", "LinearAlgebra", "Random", "Symbolics", "Test"] diff --git a/test/AbstractDifferentiationTests.jl b/test/AbstractDifferentiationTests.jl index 02f6d317..a73934dd 100644 --- a/test/AbstractDifferentiationTests.jl +++ b/test/AbstractDifferentiationTests.jl @@ -1,8 +1,16 @@ -using AbstractDifferentiation, Diffractor, Test -include(joinpath(pathof(AbstractDifferentiation), "..", "..", "test", "test_utils.jl")) +using AbstractDifferentiation, Diffractor, Test, LinearAlgebra import AbstractDifferentiation as AD - backend = Diffractor.DiffractorForwardBackend() + +@testset "basics" begin + @test AD.derivative(backend, +, 1.5, 10.0) == (1.0, 1.0) + @test AD.derivative(backend, *, 1.5, 10.0) == (10.0, 1.5) + @test only(AD.jacobian(backend, prod, [1.5, 2.5, 10.0])) == [25.0 15.0 3.75] + @test only(AD.jacobian(backend, identity, [1.5, 2.5, 10.0])) == Matrix(I, 3, 3) +end + +# standard tests from AbstractDifferentiation.test_utils +include(joinpath(pathof(AbstractDifferentiation), "..", "..", "test", "test_utils.jl")) @testset "ForwardDiffBackend" begin backends = [ @inferred(Diffractor.DiffractorForwardBackend()) @@ -34,8 +42,8 @@ backend = Diffractor.DiffractorForwardBackend() @testset "Lazy Gradient" begin #Diffractor.TangentBundle{1, Float64, Diffractor.TaylorTangent{Tuple{Float64}}}(::Float64, ::Tuple{Float64}) @test_broken test_lazy_gradients(backend) end - @testset "Lazy Jacobian" begin - test_lazy_jacobians(backend; vaugmented=true) + @testset "Lazy Jacobian" begin #MethodError: no method matching *(::Diffractor.PrimeDerivativeBack{1, Diagonal{Bool, Vector{Bool}}}, ::Vector{Float64}) + @test_broken test_lazy_jacobians(backend; vaugmented=true) end @testset "Lazy Hessian" begin # everything everywhere all at once is broken @test_broken test_lazy_hessians(backend) diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 6135bbbb..00000000 --- a/test/Project.toml +++ /dev/null @@ -1,22 +0,0 @@ -[deps] -ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" -ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" -ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" -InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" -StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" -Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[compat] -ChainRules = "1.44.5" -ChainRulesCore = "1.15.3" -Combinatorics = "1" -StaticArrays = "1" -StatsBase = "0.33" -StructArrays = "0.6.12" -julia = "1.7"