A library of noise processes for stochastic systems like stochastic differential equations (SDEs) and other systems that are present in scientific machine learning (SciML)
Hi,
I'm writing about a documentation issue similar to the one I wrote about a month ago. This time I'm labelling it as bug instead of question, it's still not clear to me which of the two is best.
Describe the bug 🐞
I was reading DiffEqNoiseProcess.NoiseFunction and tried to implement the first example. But it gives an error. I then tried the second example, and it also gives an error. Error messages are included below.
Expected behavior
The examples in the documentation work.
Minimal Reproducible Example 👇
This is what happens when I launch a fresh Julia session from my terminal. In the following I try both the examples mentioned above. I manually deleted the three ticks from the output generated by the error message because it was messing up the display of the code as a code (btw I would be interested in knowing if there is a better way to do this).
julia> f(t) = exp(t)
f (generic function with 1 method)
julia> W = NoiseFunction(0.0, f)
ERROR: All methods for the model function `f` had too few arguments. For example,
an ODEProblem `f` must define either `f(u,p,t)` or `f(du,u,p,t)`. This error
can be thrown if you define an ODE model for example as `f(u,t)`. The parameters
`p` are not optional in the definition of `f`! For more information on the required
number of arguments for the function you were defining, consult the documentation
for the `SciMLProblem` or `SciMLFunction` type that was being constructed.
For example, here is the no parameter Lorenz equation. The two valid versions
are out of place:
julia
function lorenz(u,p,t)
du1 = 10.0*(u[2]-u[1])
du2 = u[1]*(28.0-u[3]) - u[2]
du3 = u[1]*u[2] - 8/3*u[3]
[du1,du2,du3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz,u0,tspan)
and in-place:
julia
function lorenz!(du,u,p,t)
du[1] = 10.0*(u[2]-u[1])
du[2] = u[1]*(28.0-u[3]) - u[2]
du[3] = u[1]*u[2] - 8/3*u[3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz!,u0,tspan)
Offending function: f
Methods:
# 1 method for generic function "f" from Main:
[1] f(t)
@ REPL[2]:1
Stacktrace:
[1]
@ SciMLBase ~/.julia/packages/SciMLBase/SiUHW/src/utils.jl:275
[2] isinplace
@ ~/.julia/packages/SciMLBase/SiUHW/src/utils.jl:242 [inlined]
[3] isinplace(f::Function, inplace_param_number::Int64)
@ SciMLBase ~/.julia/packages/SciMLBase/SiUHW/src/utils.jl:242
[4] NoiseFunction(t0::Float64, W::Function, Z::Nothing; kwargs::@Kwargs{})
@ DiffEqNoiseProcess ~/.julia/packages/DiffEqNoiseProcess/XNdp2/src/types.jl:669
[5] NoiseFunction
@ ~/.julia/packages/DiffEqNoiseProcess/XNdp2/src/types.jl:668 [inlined]
[6] NoiseFunction(t0::Float64, W::Function)
@ DiffEqNoiseProcess ~/.julia/packages/DiffEqNoiseProcess/XNdp2/src/types.jl:668
[7] top-level scope
@ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types.
julia> g(out, t) = (out .= exp(t))
g (generic function with 1 method)
julia> W = NoiseFunction(0.0, g, noise_prototype = rand(4))
ERROR: All methods for the model function `f` had too few arguments. For example,
an ODEProblem `f` must define either `f(u,p,t)` or `f(du,u,p,t)`. This error
can be thrown if you define an ODE model for example as `f(u,t)`. The parameters
`p` are not optional in the definition of `f`! For more information on the required
number of arguments for the function you were defining, consult the documentation
for the `SciMLProblem` or `SciMLFunction` type that was being constructed.
For example, here is the no parameter Lorenz equation. The two valid versions
are out of place:
julia
function lorenz(u,p,t)
du1 = 10.0*(u[2]-u[1])
du2 = u[1]*(28.0-u[3]) - u[2]
du3 = u[1]*u[2] - 8/3*u[3]
[du1,du2,du3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz,u0,tspan)
and in-place:
julia
function lorenz!(du,u,p,t)
du[1] = 10.0*(u[2]-u[1])
du[2] = u[1]*(28.0-u[3]) - u[2]
du[3] = u[1]*u[2] - 8/3*u[3]
end
u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)
prob = ODEProblem(lorenz!,u0,tspan)
Offending function: f
Methods:
# 1 method for generic function "g" from Main:
[1] g(out, t)
@ REPL[8]:1
Stacktrace:
[1]
@ SciMLBase ~/.julia/packages/SciMLBase/SiUHW/src/utils.jl:275
[2] isinplace
@ ~/.julia/packages/SciMLBase/SiUHW/src/utils.jl:242 [inlined]
[3] isinplace(f::Function, inplace_param_number::Int64)
@ SciMLBase ~/.julia/packages/SciMLBase/SiUHW/src/utils.jl:242
[4] NoiseFunction(t0::Float64, W::Function, Z::Nothing; kwargs::@Kwargs{noise_prototype::Vector{Float64}})
@ DiffEqNoiseProcess ~/.julia/packages/DiffEqNoiseProcess/XNdp2/src/types.jl:669
[5] NoiseFunction
@ ~/.julia/packages/DiffEqNoiseProcess/XNdp2/src/types.jl:668 [inlined]
[6] top-level scope
@ REPL[9]:1
Some type information was truncated. Use `show(err)` to see complete types.
julia>
Environment (please complete the following information):
Output of using Pkg; Pkg.status()
julia> Pkg.status()
Status `~/.julia/environments/v1.10/Project.toml`
[0c46a032] DifferentialEquations v7.12.0
⌃ [c3e4b0f8] Pluto v0.19.38
⌃ [295af30f] Revise v3.5.13
Info Packages marked with ⌃ have new versions available and may be upgradable.
julia>
Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Hi, I'm writing about a documentation issue similar to the one I wrote about a month ago. This time I'm labelling it as bug instead of question, it's still not clear to me which of the two is best.
Describe the bug 🐞 I was reading DiffEqNoiseProcess.NoiseFunction and tried to implement the first example. But it gives an error. I then tried the second example, and it also gives an error. Error messages are included below.
Expected behavior The examples in the documentation work.
Minimal Reproducible Example 👇 This is what happens when I launch a fresh Julia session from my terminal. In the following I try both the examples mentioned above. I manually deleted the three ticks from the output generated by the error message because it was messing up the display of the code as a code (btw I would be interested in knowing if there is a better way to do this).
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
Add any other context about the problem here.