Skip to content

Fix deprecation warning introduced by DiffRules v1.4 #553

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

Merged
merged 4 commits into from
Nov 9, 2021
Merged

Fix deprecation warning introduced by DiffRules v1.4 #553

merged 4 commits into from
Nov 9, 2021

Conversation

odow
Copy link
Contributor

@odow odow commented Nov 4, 2021

DiffRules 1.4.0 introduced a new deprecation warning: JuliaDiff/DiffRules.jl#69

This caused the JuMP tests to fail since we run with --depwarn=error:
https://github.com/jump-dev/JuMP.jl/runs/4110519060?check_suite_focus=true#step:6:26

x-ref: jump-dev/JuMP.jl#2790

src/dual.jl Outdated
@@ -392,7 +392,7 @@ Base.float(d::Dual) = convert(float(typeof(d)), d)
# General Mathematical Operations #
###################################

for (M, f, arity) in DiffRules.diffrules()
for (M, f, arity) in DiffRules.diffrules(filter_modules = (:Base, :SpecialFunctions, :NaNMath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess one could use the opportunity and already prepare this code for future releases of DiffRules. As stated in the deprecation warning it will change to filter_modules=nothing, ie. it will load all rules defined in DiffRules. We only had to introduce this keyword argument because many downstream packages, including ForwardDiff, did not actually check if a module M with a function f was defined when they tried to load the rules.

So an alternative approach here that would also add derivative definitions for functions in LogExpFunctions would be to:

  • add LogExpFunctions >= 0.3 as explicit dependency (it's already an indirect dependency via DiffRules and SpecialFunctions)
  • use DiffRules.diffrules(; filter_modules=nothing) and load all rules, including the ones for LogExpFunctions
  • check if M and M.f are defined before trying to eval the rule definitions

for (M, f, arity) in DiffRules.diffrules(filter_modules = nothing)
if (M, f) in ((:Base, :^), (:NaNMath, :pow), (:Base, :/), (:Base, :+), (:Base, :-))
continue # Skip methods which we define elsewhere.
elseif !(isdefined(@__MODULE__, M) && isdefined(getfield(@__MODULE__, M), f))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a reasonable way to check if M and f are defined? Seems a bit clunky.

@odow
Copy link
Contributor Author

odow commented Nov 5, 2021

Why are the tests non-deterministic? Failure on 1.0 isn't caused by this: https://github.com/JuliaDiff/ForwardDiff.jl/runs/4111622597?check_suite_focus=true#step:6:293

@odow
Copy link
Contributor Author

odow commented Nov 9, 2021

Tests are passing now thanks to #554.

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! 🙂

@odow
Copy link
Contributor Author

odow commented Nov 9, 2021

Any chance we could get this merged and a new release tagged?

@devmotion devmotion merged commit 0af523a into JuliaDiff:master Nov 9, 2021
@odow odow deleted the od/fix-deprecation branch November 9, 2021 23:59
@odow
Copy link
Contributor Author

odow commented Nov 10, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants