From a6e226460dcb7d302ce8f2a348bd3e344f1b834a Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Tue, 26 Oct 2021 00:42:27 +0000 Subject: [PATCH 1/8] CompatHelper: bump compat for Distances to 0.10 for package test, (keep existing compat) --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index ef3a56dc2..173cfe1b3 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -17,7 +17,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [compat] AxisArrays = "0.4.3" -Distances = "= 0.10.0, = 0.10.1, = 0.10.2, = 0.10.3, = 0.10.4" +Distances = "= 0.10.0, = 0.10.1, = 0.10.2, = 0.10.3, = 0.10.4, 0.10" Documenter = "0.25, 0.26, 0.27" FiniteDifferences = "0.10.8, 0.11, 0.12" ForwardDiff = "0.10" From b398577f9df5d47df7ef24479ca244ea2c4db86f Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 11 Jan 2022 18:33:03 +0200 Subject: [PATCH 2/8] try out Theo's fix --- test/chainrules.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/chainrules.jl b/test/chainrules.jl index 51a545ba1..293809c88 100644 --- a/test/chainrules.jl +++ b/test/chainrules.jl @@ -21,7 +21,13 @@ compare_gradient(:Zygote, [x, y]) do xy KernelFunctions.Sinus(r)(xy[1], xy[2]) end - compare_gradient(:Zygote, [Q, x, y]) do xy - SqMahalanobis(xy[1])(xy[2], xy[3]) + if VERSION < v"1.6" + compare_gradient(:Zygote, [Q, x, y]) do xy + SqMahalanobis(xy[1]; skipchecks=true)(xy[2], xy[3]) + end + else + compare_gradient(:Zygote, [Q, x, y]) do xy + SqMahalanobis(xy[1])(xy[2], xy[3]) + end end end From f12481842bceb32ad87a6f45266a1575e23a1dcb Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 11 Jan 2022 18:33:32 +0200 Subject: [PATCH 3/8] fix test compat --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index df4bfc3d5..605a27cc0 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -19,7 +19,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [compat] AxisArrays = "0.4.3" Compat = "3" -Distances = "= 0.10.0, = 0.10.1, = 0.10.2, = 0.10.3, = 0.10.4, 0.10" +Distances = "0.10" Documenter = "0.25, 0.26, 0.27" FiniteDifferences = "0.10.8, 0.11, 0.12" ForwardDiff = "0.10" From 01530b6fa51b43f0ec5a432586247498fa6921f2 Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 12 Jan 2022 15:27:06 +0200 Subject: [PATCH 4/8] use ForwardDiff for chain rule test of SqMahalanobis --- src/chainrules.jl | 2 +- test/chainrules.jl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/chainrules.jl b/src/chainrules.jl index 4b69a827f..dde352f8c 100644 --- a/src/chainrules.jl +++ b/src/chainrules.jl @@ -118,7 +118,7 @@ function ChainRulesCore.rrule(s::Sinus, x::AbstractVector, y::AbstractVector) return val, evaluate_pullback end -## Reverse Rulse SqMahalanobis +## Reverse Rules SqMahalanobis function ChainRulesCore.rrule( dist::Distances.SqMahalanobis, a::AbstractVector, b::AbstractVector diff --git a/test/chainrules.jl b/test/chainrules.jl index 293809c88..292a2d5d9 100644 --- a/test/chainrules.jl +++ b/test/chainrules.jl @@ -22,12 +22,12 @@ KernelFunctions.Sinus(r)(xy[1], xy[2]) end if VERSION < v"1.6" - compare_gradient(:Zygote, [Q, x, y]) do xy - SqMahalanobis(xy[1]; skipchecks=true)(xy[2], xy[3]) + compare_gradient(:ForwardDiff, [Q, x, y]) do Qxy + SqMahalanobis(Qxy[1]; skipchecks=true)(Qxy[2], Qxy[3]) end else - compare_gradient(:Zygote, [Q, x, y]) do xy - SqMahalanobis(xy[1])(xy[2], xy[3]) + compare_gradient(:Zygote, [Q, x, y]) do Qxy + SqMahalanobis(Qxy[1])(Qxy[2], Qxy[3]) end end end From 740dcb553ca56457331658a3da19fd315fa9e14b Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 12 Jan 2022 15:48:20 +0200 Subject: [PATCH 5/8] test on 1.4 instead of 1.3 - see if the chainrules test passes there --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6272e7017..659c302df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: matrix: version: - '1' - - '1.3' + - '1.4' - 'nightly' os: - ubuntu-latest From 733cfccb07565c4c0d71ec805b646d5881069dc2 Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 12 Jan 2022 15:56:18 +0200 Subject: [PATCH 6/8] revert version branch --- test/chainrules.jl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/chainrules.jl b/test/chainrules.jl index 292a2d5d9..4edd532d0 100644 --- a/test/chainrules.jl +++ b/test/chainrules.jl @@ -21,13 +21,7 @@ compare_gradient(:Zygote, [x, y]) do xy KernelFunctions.Sinus(r)(xy[1], xy[2]) end - if VERSION < v"1.6" - compare_gradient(:ForwardDiff, [Q, x, y]) do Qxy - SqMahalanobis(Qxy[1]; skipchecks=true)(Qxy[2], Qxy[3]) - end - else - compare_gradient(:Zygote, [Q, x, y]) do Qxy - SqMahalanobis(Qxy[1])(Qxy[2], Qxy[3]) - end + compare_gradient(:Zygote, [Q, x, y]) do Qxy + SqMahalanobis(Qxy[1])(Qxy[2], Qxy[3]) end end From f692b4d782d9e7ffb17d6fccc3f5fa5371392b8d Mon Sep 17 00:00:00 2001 From: ST John Date: Thu, 13 Jan 2022 09:54:21 +0200 Subject: [PATCH 7/8] revert to 1.3 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 659c302df..6272e7017 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: matrix: version: - '1' - - '1.4' + - '1.3' - 'nightly' os: - ubuntu-latest From ae34ff2d426ec44f28fb1024ff5a75d0ef320e85 Mon Sep 17 00:00:00 2001 From: ST John Date: Thu, 13 Jan 2022 09:56:21 +0200 Subject: [PATCH 8/8] test_broken for older Julia versions --- test/chainrules.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/chainrules.jl b/test/chainrules.jl index 4edd532d0..03c2c3b1f 100644 --- a/test/chainrules.jl +++ b/test/chainrules.jl @@ -21,7 +21,11 @@ compare_gradient(:Zygote, [x, y]) do xy KernelFunctions.Sinus(r)(xy[1], xy[2]) end - compare_gradient(:Zygote, [Q, x, y]) do Qxy - SqMahalanobis(Qxy[1])(Qxy[2], Qxy[3]) + if VERSION < v"1.6" + @test_broken "Chain rule of SqMahalanobis is broken in Julia pre-1.6" + else + compare_gradient(:Zygote, [Q, x, y]) do Qxy + SqMahalanobis(Qxy[1])(Qxy[2], Qxy[3]) + end end end