Skip to content

Commit

Permalink
Add AutoModelingToolkit to deprecations (#51)
Browse files Browse the repository at this point in the history
* Add AutoModelingToolkit to deprecations

* Add deprecation tests and remove redundent legacy exports

---------

Co-authored-by: Guillaume Dalle <22795598+gdalle@users.noreply.github.com>
  • Loading branch information
Vaibhavdixit02 and gdalle committed May 2, 2024
1 parent d4a014a commit 04203ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
9 changes: 1 addition & 8 deletions src/ADTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ export AutoChainRules,

export AutoSparse

# legacy

export AutoSparseFastDifferentiation,
AutoSparseFiniteDiff,
AutoSparseForwardDiff,
AutoSparsePolyesterForwardDiff,
AutoSparseReverseDiff,
AutoSparseZygote
# legacy exports are taken care of by @deprecated

end
2 changes: 2 additions & 0 deletions src/legacy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
@deprecate AutoSparseReverseDiff(; kwargs...) AutoSparse(AutoReverseDiff(; kwargs...))

@deprecate AutoSparseZygote() AutoSparse(AutoZygote())

@deprecate AutoModelingToolkit(; kwargs...) AutoSparse(AutoSymbolics())
22 changes: 15 additions & 7 deletions test/legacy.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
@testset "AutoModelingToolkig" begin
ad = @test_deprecated AutoModelingToolkit()
@test ad isa AbstractADType
@test ad isa AutoSparse
@test dense_ad(ad) isa AutoSymbolics
end

@testset "AutoSparseFastDifferentiation" begin
ad = AutoSparseFastDifferentiation()
ad = @test_deprecated AutoSparseFastDifferentiation()
@test ad isa AbstractADType
@test dense_ad(ad) isa AutoFastDifferentiation
end

@testset "AutoSparseFiniteDiff" begin
ad = AutoSparseFiniteDiff()
ad = @test_deprecated AutoSparseFiniteDiff()
@test ad isa AbstractADType
@test dense_ad(ad) isa AutoFiniteDiff
@test dense_ad(ad).fdtype === Val(:forward)
Expand All @@ -14,30 +21,31 @@ end
end

@testset "AutoSparseForwardDiff" begin
ad = AutoSparseForwardDiff()
ad = @test_deprecated AutoSparseForwardDiff()
@test ad isa AbstractADType
@test dense_ad(ad) isa AutoForwardDiff{nothing, Nothing}

ad = AutoSparseForwardDiff(; chunksize = 10, tag = CustomTag())
ad = @test_deprecated AutoSparseForwardDiff(; chunksize = 10, tag = CustomTag())
@test ad isa AbstractADType
@test dense_ad(ad) isa AutoForwardDiff{10, CustomTag}
end

@testset "AutoSparsePolyesterForwardDiff" begin
ad = AutoSparsePolyesterForwardDiff(; chunksize = 10, tag = CustomTag())
ad = @test_deprecated AutoSparsePolyesterForwardDiff(;
chunksize = 10, tag = CustomTag())
@test ad isa AbstractADType
@test dense_ad(ad) isa AutoPolyesterForwardDiff{10, CustomTag}
end

@testset "AutoSparseReverseDiff" begin
ad = AutoSparseReverseDiff(; compile = true)
ad = @test_deprecated AutoSparseReverseDiff(; compile = true)
@test ad isa AbstractADType
@test dense_ad(ad) isa AutoReverseDiff
@test dense_ad(ad).compile
end

@testset "AutoSparseZygote" begin
ad = AutoSparseZygote()
ad = @test_deprecated AutoSparseZygote()
@test ad isa AbstractADType
@test dense_ad(ad) isa AutoZygote
end

0 comments on commit 04203ab

Please sign in to comment.