|
1 | 1 | # TODO remove these in version 0.7
|
2 |
| -# We are silently deprecating them as there is no alternative we are providing |
3 | 2 |
|
4 | 3 | function Base.isapprox(a, b::Union{AbstractZero,AbstractThunk}; kwargs...)
|
| 4 | + Base.depwarn( |
| 5 | + "isapprox is deprecated on AbstractTangents and will be removed. " * |
| 6 | + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", |
| 7 | + :isapprox, |
| 8 | + ) |
5 | 9 | return isapprox(b, a; kwargs...)
|
6 | 10 | end
|
7 | 11 | function Base.isapprox(d_ad::AbstractThunk, d_fd; kwargs...)
|
| 12 | + Base.depwarn( |
| 13 | + "isapprox is deprecated on AbstractTangents and will be removed. " * |
| 14 | + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", |
| 15 | + :isapprox, |
| 16 | + ) |
8 | 17 | return isapprox(extern(d_ad), d_fd; kwargs...)
|
9 | 18 | end
|
10 | 19 | function Base.isapprox(d_ad::NoTangent, d_fd; kwargs...)
|
| 20 | + Base.depwarn( |
| 21 | + "isapprox is deprecated on AbstractTangents and will be removed. " * |
| 22 | + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", |
| 23 | + :isapprox, |
| 24 | + ) |
11 | 25 | return error("Tried to differentiate w.r.t. a `NoTangent`")
|
12 | 26 | end
|
13 | 27 | # Call `all` to handle the case where `ZeroTangent` is standing in for a non-scalar zero
|
14 | 28 | function Base.isapprox(d_ad::ZeroTangent, d_fd; kwargs...)
|
| 29 | + Base.depwarn( |
| 30 | + "isapprox is deprecated on AbstractTangents and will be removed. " * |
| 31 | + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", |
| 32 | + :isapprox, |
| 33 | + ) |
15 | 34 | return all(isapprox.(extern(d_ad), d_fd; kwargs...))
|
16 | 35 | end
|
17 | 36 |
|
18 | 37 | isapprox_vec(a, b; kwargs...) = isapprox(first(to_vec(a)), first(to_vec(b)); kwargs...)
|
19 | 38 | Base.isapprox(a, b::Tangent; kwargs...) = isapprox(b, a; kwargs...)
|
20 | 39 | function Base.isapprox(d_ad::Tangent{<:Tuple}, d_fd::Tuple; kwargs...)
|
| 40 | + Base.depwarn( |
| 41 | + "isapprox is deprecated on AbstractTangents and will be removed. " * |
| 42 | + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", |
| 43 | + :isapprox, |
| 44 | + ) |
21 | 45 | return isapprox_vec(d_ad, d_fd; kwargs...)
|
22 | 46 | end
|
23 | 47 | function Base.isapprox(
|
24 | 48 | d_ad::Tangent{P,<:Tuple}, d_fd::Tangent{P,<:Tuple}; kwargs...
|
25 | 49 | ) where {P<:Tuple}
|
| 50 | + Base.depwarn( |
| 51 | + "isapprox is deprecated on AbstractTangents and will be removed. " * |
| 52 | + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", |
| 53 | + :isapprox, |
| 54 | + ) |
26 | 55 | return isapprox_vec(d_ad, d_fd; kwargs...)
|
27 | 56 | end
|
28 | 57 |
|
29 | 58 | function Base.isapprox(
|
30 | 59 | d_ad::Tangent{P,<:NamedTuple{T}}, d_fd::Tangent{P,<:NamedTuple{T}}; kwargs...
|
31 | 60 | ) where {P,T}
|
| 61 | + Base.depwarn( |
| 62 | + "isapprox is deprecated on AbstractTangents and will be removed. " * |
| 63 | + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", |
| 64 | + :isapprox, |
| 65 | + ) |
32 | 66 | return isapprox_vec(d_ad, d_fd; kwargs...)
|
33 | 67 | end
|
34 | 68 |
|
35 | 69 | # Must be for same primal
|
36 |
| -Base.isapprox(d_ad::Tangent{P}, d_fd::Tangent{Q}; kwargs...) where {P,Q} = false |
| 70 | +function Base.isapprox(d_ad::Tangent{P}, d_fd::Tangent{Q}; kwargs...) where {P,Q} |
| 71 | + Base.depwarn( |
| 72 | + "isapprox is deprecated on AbstractTangents and will be removed. " * |
| 73 | + "Restructure testing code to use `ChainRulesTestUtils.test_approx` instead.", |
| 74 | + :isapprox, |
| 75 | + ) |
| 76 | + return false |
| 77 | +end |
37 | 78 |
|
38 | 79 | ###############################################
|
39 | 80 |
|
|
0 commit comments