From ffedc9aa946ebda0ebda75090b5e629734a1e0de Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 2 Jun 2021 15:04:03 +0100 Subject: [PATCH 1/3] Add deprecation warnings to isapprox --- src/deprecated.jl | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/deprecated.jl b/src/deprecated.jl index e880aa74..68a856ae 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -2,38 +2,80 @@ # We are silently deprecating them as there is no alternative we are providing function Base.isapprox(a, b::Union{AbstractZero,AbstractThunk}; kwargs...) + Base.depwarn( + "isapprox is deprecated on AbstractTangents and will be removed. " * + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", + :isapprox, + ) return isapprox(b, a; kwargs...) end function Base.isapprox(d_ad::AbstractThunk, d_fd; kwargs...) + Base.depwarn( + "isapprox is deprecated on AbstractTangents and will be removed. " * + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", + :isapprox, + ) return isapprox(extern(d_ad), d_fd; kwargs...) end function Base.isapprox(d_ad::NoTangent, d_fd; kwargs...) + Base.depwarn( + "isapprox is deprecated on AbstractTangents and will be removed. " * + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", + :isapprox, + ) return error("Tried to differentiate w.r.t. a `NoTangent`") end # Call `all` to handle the case where `ZeroTangent` is standing in for a non-scalar zero function Base.isapprox(d_ad::ZeroTangent, d_fd; kwargs...) + Base.depwarn( + "isapprox is deprecated on AbstractTangents and will be removed. " * + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", + :isapprox, + ) return all(isapprox.(extern(d_ad), d_fd; kwargs...)) end isapprox_vec(a, b; kwargs...) = isapprox(first(to_vec(a)), first(to_vec(b)); kwargs...) Base.isapprox(a, b::Tangent; kwargs...) = isapprox(b, a; kwargs...) function Base.isapprox(d_ad::Tangent{<:Tuple}, d_fd::Tuple; kwargs...) + Base.depwarn( + "isapprox is deprecated on AbstractTangents and will be removed. " * + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", + :isapprox, + ) return isapprox_vec(d_ad, d_fd; kwargs...) end function Base.isapprox( d_ad::Tangent{P,<:Tuple}, d_fd::Tangent{P,<:Tuple}; kwargs... ) where {P<:Tuple} + Base.depwarn( + "isapprox is deprecated on AbstractTangents and will be removed. " * + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", + :isapprox, + ) return isapprox_vec(d_ad, d_fd; kwargs...) end function Base.isapprox( d_ad::Tangent{P,<:NamedTuple{T}}, d_fd::Tangent{P,<:NamedTuple{T}}; kwargs... ) where {P,T} + Base.depwarn( + "isapprox is deprecated on AbstractTangents and will be removed. " * + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", + :isapprox, + ) return isapprox_vec(d_ad, d_fd; kwargs...) end # Must be for same primal -Base.isapprox(d_ad::Tangent{P}, d_fd::Tangent{Q}; kwargs...) where {P,Q} = false +function Base.isapprox(d_ad::Tangent{P}, d_fd::Tangent{Q}; kwargs...) where {P,Q} + Base.depwarn( + "isapprox is deprecated on AbstractTangents and will be removed. " * + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", + :isapprox, + ) + return false +end ############################################### From 3ba4178a8044d70ffaeb71e56b86a5958948e0ba Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 2 Jun 2021 15:15:37 +0100 Subject: [PATCH 2/3] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c74cac02..8801fef2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ChainRulesTestUtils" uuid = "cdddcdb0-9152-4a09-a978-84456f9df70a" -version = "0.7.0" +version = "0.7.1" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" From a0cac6f636de1fdb08accd1722005542be93ab49 Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 2 Jun 2021 17:26:45 +0100 Subject: [PATCH 3/3] remove outdated comment Co-authored-by: Nick Robinson --- src/deprecated.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/deprecated.jl b/src/deprecated.jl index 68a856ae..e48c1c74 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -1,5 +1,4 @@ # TODO remove these in version 0.7 -# We are silently deprecating them as there is no alternative we are providing function Base.isapprox(a, b::Union{AbstractZero,AbstractThunk}; kwargs...) Base.depwarn(