Skip to content

Commit e3cfab7

Browse files
authored
Merge pull request #401 from JuliaDiff/ox/nodep
Remove Deprecations
2 parents d71c79f + 4a15974 commit e3cfab7

File tree

6 files changed

+8
-126
lines changed

6 files changed

+8
-126
lines changed

docs/Manifest.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
1313
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
1414
path = ".."
1515
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
16-
version = "0.10.11"
16+
version = "1.0.0-DEV"
1717

1818
[[Compat]]
1919
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
@@ -41,9 +41,9 @@ version = "0.8.5"
4141

4242
[[DocThemeIndigo]]
4343
deps = ["Sass"]
44-
git-tree-sha1 = "7b15d5e64ae6e27f8cc9eaff280c305199c6bfc7"
44+
git-tree-sha1 = "9f722e4ab9fe188f04c7bbe7b5d21ebd3fe0d0a1"
4545
uuid = "8bac0ac5-51bf-41f9-885e-2bf1ac2bec5f"
46-
version = "0.1.0"
46+
version = "0.1.1"
4747

4848
[[Documenter]]
4949
deps = ["Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]

docs/src/api.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,4 @@ ProjectTo
5050
```@docs
5151
ChainRulesCore.AbstractTangent
5252
ChainRulesCore.debug_mode
53-
```
54-
55-
## Deprecated
56-
```@docs
57-
ChainRulesCore.extern
58-
```
53+
```

src/ChainRulesCore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export RuleConfig, HasReverseMode, NoReverseMode, HasForwardsMode, NoForwardsMod
1010
export frule_via_ad, rrule_via_ad
1111
# definition helper macros
1212
export @non_differentiable, @scalar_rule, @thunk, @not_implemented
13-
export ProjectTo, canonicalize, extern, unthunk # differential operations
13+
export ProjectTo, canonicalize, unthunk # differential operations
1414
export add!! # gradient accumulation operations
1515
# differentials
1616
export Tangent, NoTangent, InplaceableThunk, Thunk, ZeroTangent, AbstractZero, AbstractThunk

src/deprecated.jl

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +0,0 @@
1-
import Base: convert
2-
3-
Base.@deprecate_binding NO_FIELDS NoTangent()
4-
5-
const EXTERN_DEPRECATION = "`extern` is deprecated, use `unthunk` or `backing` instead, " *
6-
"depending on the use case."
7-
8-
"""
9-
extern(x)
10-
11-
Makes a best effort attempt to convert a differential into a primal value.
12-
This is not always a well-defined operation.
13-
For two reasons:
14-
- It may not be possible to determine the primal type for a given differential.
15-
For example, `Zero` is a valid differential for any primal.
16-
- The primal type might not be a vector space, thus might not be a valid differential type.
17-
For example, if the primal type is `DateTime`, it's not a valid differential type as two
18-
`DateTime` can not be added (fun fact: `Milisecond` is a differential for `DateTime`).
19-
20-
Where it is defined the operation of `extern` for a primal type `P` should be
21-
`extern(x) = zero(P) + x`.
22-
23-
!!! note
24-
Because of its limitations, `extern` should only really be used for testing.
25-
It can be useful, if you know what you are getting out, as it recursively removes
26-
thunks, and otherwise makes outputs more consistent with finite differencing.
27-
28-
The more useful action in general is to call `+`, or in the case of a [`Thunk`](@ref)
29-
to call [`unthunk`](@ref).
30-
31-
!!! warning
32-
`extern` may return an alias (not necessarily a copy) to data
33-
wrapped by `x`, such that mutating `extern(x)` might mutate `x` itself.
34-
"""
35-
@inline function extern(x)
36-
Base.depwarn(EXTERN_DEPRECATION, :extern)
37-
return x
38-
end
39-
40-
extern(x::ZeroTangent) = (Base.depwarn(EXTERN_DEPRECATION, :extern); return false) # false is a strong 0. E.g. `false * NaN = 0.0`
41-
42-
function extern(x::NoTangent)
43-
Base.depwarn(EXTERN_DEPRECATION, :extern)
44-
throw(ArgumentError("Derivative does not exit. Cannot be converted to an external type."))
45-
end
46-
47-
extern(comp::Tangent) = (Base.depwarn(EXTERN_DEPRECATION, :extern); return backing(map(extern, comp))) # gives a NamedTuple or Tuple
48-
49-
extern(x::NotImplemented) = (Base.depwarn(EXTERN_DEPRECATION, :extern); throw(NotImplementedException(x)))
50-
51-
@inline extern(x::AbstractThunk) = (Base.depwarn(EXTERN_DEPRECATION, :extern); return extern(unthunk(x)))
52-
53-
for T in (:Thunk, :InplaceableThunk)
54-
@eval function (x::$T)()
55-
Base.depwarn("`(x::" * string($T) * ")()` is deprecated, use `unthunk(x)`", Symbol(:call_, $(T)))
56-
return unthunk(x)
57-
end
58-
end
59-
60-
61-
Base.@deprecate InplaceableThunk(t::Thunk, add!) InplaceableThunk(add!, t)
62-
63-
Base.@deprecate convert(::Type{<:Tuple}, t::Tangent{<:Any, <:Tuple}) backing(t)
64-
Base.@deprecate convert(::Type{<:NamedTuple}, t::Tangent{<:Any, <:NamedTuple}) backing(t)
65-
Base.@deprecate convert(::Type{<:Dict}, t::Tangent{<:Dict, <:Dict}) backing(t)

src/differentials/thunks.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,10 @@ To evaluate the wrapped closure, call [`unthunk`](@ref) which is a no-op when th
155155
argument is not a `Thunk`.
156156
157157
```jldoctest
158-
julia> t = @thunk(@thunk(3))
159-
Thunk(var"#4#6"())
158+
julia> t = @thunk(3)
159+
Thunk(var"#4#5"())
160160
161-
julia> t()
162-
Thunk(var"#5#7"())
163-
164-
julia> unthunk(t())
161+
julia> unthunk(t)
165162
3
166163
```
167164

test/deprecated.jl

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +0,0 @@
1-
@testset "NO_FIELDS" begin
2-
# Following doesn't work because of some deprecate_binding weirdness with not printing
3-
# @test (@test_deprecated NO_FIELDS) isa NoTangent
4-
# So just test it gives the old behavour
5-
@test NO_FIELDS isa NoTangent
6-
end
7-
8-
@testset "extern" begin
9-
@test (@test_deprecated extern(@thunk(3))) == 3
10-
@test (@test_deprecated extern(@thunk(@thunk(3)))) == 3
11-
12-
@test (@test_deprecated extern(Tangent{Foo}(x=2.0))) == (;x=2.0)
13-
@test (@test_deprecated extern(Tangent{Tuple{Float64,}}(2.0))) == (2.0,)
14-
@test (@test_deprecated extern(Tangent{Dict}(Dict(4 => 3)))) == Dict(4 => 3)
15-
16-
# with differentials on the inside
17-
@test (@test_deprecated extern(Tangent{Foo}(x=@thunk(0+2.0)))) == (;x=2.0)
18-
@test (@test_deprecated extern(Tangent{Tuple{Float64,}}(@thunk(0+2.0)))) == (2.0,)
19-
@test (@test_deprecated extern(Tangent{Dict}(Dict(4 => @thunk(3))))) == Dict(4 => 3)
20-
21-
z = ZeroTangent()
22-
@test (@test_deprecated extern(z)) === false
23-
24-
# @test_throws doesn't play nice with `@test_deprecated` so have to be loud
25-
dne = NoTangent()
26-
@test_throws Exception extern(dne)
27-
ni = @not_implemented("no")
28-
@test_throws ChainRulesCore.NotImplementedException extern(ni)
29-
end
30-
31-
32-
@testset "Deprecated: calling thunks should call inner function" begin
33-
@test (@test_deprecated (@thunk(3))()) == 3
34-
@test (@test_deprecated (@thunk(@thunk(3)))()) isa Thunk
35-
end
36-
37-
@testset "Deprecated: Inplacable Thunk argument order" begin
38-
@test (@test_deprecated InplaceableThunk(@thunk([1]), x->x.+=1)) isa InplaceableThunk
39-
end
40-
41-
@testset "Deprecated: convert from Tangent" begin
42-
@test (@test_deprecated convert(NamedTuple, Tangent{Foo}(x=2.5))) == (; x=2.5)
43-
@test (@test_deprecated convert(Tuple, Tangent{Tuple{Float64,}}(2.0))) == (2.0,)
44-
@test (@test_deprecated convert(Dict, Tangent{Dict}(Dict(4 => 3)))) == Dict(4 => 3)
45-
end

0 commit comments

Comments
 (0)