DifferentialEquations.jl
DifferentialEquations.jl copied to clipboard
Add checking for unsupported keyword arguments
I can run a function with wrong keyword arguments:
sol = solve(prob, undefined_keyword=4.0)
It is hard to find potential spelling mistakes in keyword arguments like this.
Per default this should be checked, shouldn't it?
Best
@kanav99 has looked into this a bit. https://github.com/SciML/OrdinaryDiffEq.jl/pull/783 . I think it's a good time to finish this though. We should just clean up the major upstream libraries that we know have issues here and finally make the last of the kwarg handling not splat.
@YingboMa @devmotion @frankschae @isaacsas @kanav99 @Vaibhavdixit02 let's just do this. We should remove the kwargs...
of every integrator. In many repos it will warn already if an argument is allowed in the common interface but not used by a given integrator, i.e. passing Jacobians to lsoda, and I think we want to do a similar filter and warn. Though I think that should be a separate verbose_interfacecheck = true
.
I don't actually like that. It's very handy to write
function foo(args...; kwargs...)
something_else(;kwargs...)
prob = ODEProblem(...; kwargs...)
solve(prob; kwargs...)
...
and leave which kwarg to apply to Julia. I think we should add verbose_interfacecheck = false
as the default, so that users can enable the check when it's necessary.
If it's a kwarg, no one will ever do it. I can't tell you how many kwarg typos I've seen recently. I think people need to start using named tuples to hold different sets of splatted kwargs.
Or default verbose_interfacecheck = true
Do you have an example of what you intend by using named tuples in place of kwarg spatting?
function foo(args...; diffeq_kwargs = (saveat=0.1, alg=Tsit5()), other_kwargs...)
something_else(;other_kwargs...)
prob = ODEProblem(...; diffeq_kwargs...)
solve(prob)
...