-
Notifications
You must be signed in to change notification settings - Fork 64
deprecate convert #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecate convert #397
Conversation
src/deprecated.jl
Outdated
|
|
||
| const CONVERT_DEPRECATION = "convert(::Type{T}, t::Tangent) is deprecated, use ChainRulesCore.backing(t) instead" | ||
|
|
||
| function Base.convert(::Type{<:NamedTuple}, comp::Tangent{<:Any, <:NamedTuple}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoyingly it's not possible to @deprecate Base.convert..., i.e. adding the Base prefix gives the following error:
ERROR: LoadError: LoadError: LoadError: invalid usage of @deprecate
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] var"@deprecate"(__source__::LineNumberNode, __module__::Module, old::Any, new::Any, ex::Any)
@ Base ./deprecated.jl:62
[3] var"@deprecate"(__source__::LineNumberNode, __module__::Module, old::Any, new::Any)
@ Base ./deprecated.jl:39
[4] include(mod::Module, _path::String)
@ Base ./Base.jl:386
[5] include(x::String)
@ ChainRulesCore ~/JuliaEnvs/ChainRulesCore.jl/src/ChainRulesCore.jl:1
[6] top-level scope
@ ~/JuliaEnvs/ChainRulesCore.jl/src/ChainRulesCore.jl:35
[7] include
@ ./Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base ./loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ ./boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude ./client.jl:446
[12] top-level scope
@ none:1There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To deprecate something from another module you need to do import Base: convert
@deprecate doesn't support qualified names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried this but kept Base.convert 🤦
Codecov Report
@@ Coverage Diff @@
## master #397 +/- ##
==========================================
+ Coverage 91.99% 92.06% +0.07%
==========================================
Files 15 15
Lines 637 643 +6
==========================================
+ Hits 586 592 +6
Misses 51 51
Continue to review full report at Codecov.
|
test/deprecated.jl
Outdated
| @test convert(NamedTuple, Tangent{Foo}(x=2.5)) == (; x=2.5) | ||
| @test convert(Tuple, Tangent{Tuple{Float64,}}(2.0)) == (2.0,) | ||
| @test convert(Dict, Tangent{Dict}(Dict(4 => 3))) == Dict(4 => 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @test convert(NamedTuple, Tangent{Foo}(x=2.5)) == (; x=2.5) | |
| @test convert(Tuple, Tangent{Tuple{Float64,}}(2.0)) == (2.0,) | |
| @test convert(Dict, Tangent{Dict}(Dict(4 => 3))) == Dict(4 => 3) | |
| @test (@test_deprecated convert(NamedTuple, Tangent{Foo}(x=2.5))) == (; x=2.5) | |
| @test (@test_deprecated convert(Tuple, Tangent{Tuple{Float64,}}(2.0))) == (2.0,) | |
| @test (@test_deprecated convert(Dict, Tangent{Dict}(Dict(4 => 3)))) == Dict(4 => 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so as to mute the depwarnings in tests, and also ensure they are there
oxinabox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chang to using import Base: convert + @deprecate.
Then merge when you are happy.
Closes #359