@ode_def not defined

I am using DifferentialEquations.jl in a Julia Notebook. The code starts as:

using DifferentalEquations
using ParameterizedFunctions

sir_ode = @ode_def SIRModel begin
     dS = -β*S*I
     dI = β*S*I-γ*I
     dR = γ*I
     end β γ

When executed, I get the error:

UndefVarError: @ode_def not defined

That does not seem possible. What can I do about it? Thanks.

1 Like

That doesn’t seem possible. uhh, what versions?

You are correct, it does not seem possible. Here is a status list of precompiled binaries in Julia 1.4.

Status `~/.julia/environments/v1.4/Project.toml`
  [c52e3926] Atom v0.12.11
  [fbb218c0] BSON v0.2.6
  [aae01518] BandedMatrices v0.15.7
  [6e4b80f9] BenchmarkTools v0.5.0
  [0487d830] Bifurcations v0.0.1 #master (https://github.com/tkf/Bifurcations.jl.git)
  [2b5f629d] DiffEqBase v6.35.1
  [aae7a2af] DiffEqFlux v1.10.3
  [9fdde737] DiffEqOperators v4.10.0
  [0c46a032] DifferentialEquations v6.14.0
  [bbc10e6e] DynamicHMC v2.1.0
  [5789e2e9] FileIO v1.3.0
  [587475ba] Flux v0.10.4
  [7073ff75] IJulia v1.21.2
  [82e4d734] ImageIO v0.1.1
  [916415d5] Images v0.22.2
  [18b7da76] JuliaAcademyData v0.1.0 #master (https://github.com/JuliaComputing/JuliaAcademyData.jl)
  [e5e0dc1b] Juno v0.8.2
  [ee78f7c6] Makie v0.10.0
  [429524aa] Optim v0.21.0
  [65888b18] ParameterizedFunctions v5.3.0
  [d96e819e] Parameters v0.12.1
  [91a5bcdd] Plots v0.29.9
  [92933f4c] ProgressMeter v1.3.0
  [7186c646] PyDSTool v0.6.0
  [d330b81b] PyPlot v2.9.0
  [295af30f] Revise v2.6.7
  [efcf1570] Setfield v0.6.0
  [90137ffa] StaticArrays v0.12.3
  [37b6cedf] Traceur v0.3.1
  [37e2e46d] LinearAlgebra 

I just typed into my notebook (did the same in Atom):

MethodError: no method matching @ode_def(::LineNumberNode, ::Module)
Closest candidates are:
  @ode_def(::LineNumberNode, ::Module, !Matched::Any, !Matched::Any, !Matched::Any...) at /Users/erlebach/.julia/packages/ParameterizedFunctions/xErQf/src/macros.jl:2

which suggests that @ode_def was found. So I will try to use it again. But I am sure that what I reported happened.

I exited Jupyter and started it up again. The problem went away. As usual: “rebooting” solves many issues. Not elegant though.

Did your packages update mid-notebook? If you do that, you need a new Julia session to use the newer versions, so it could be something like that?

1 Like

Hi, I get the same error which doesn’t disappear though. I tried Jupyter, Vscode, Pluto.
It says UndefVarError. Any more help on this? I do not have problem with other functions though.

Did you do using ParameterizedFunctions?

1 Like

Hi Chris, yes, exactly. I am watching your video on YouTube on DifferentialEquations.jl. First really thanks for the package, huge work, really really appreciate it. But in your video because I follow your notebook and I did not see using ParameterizedFunctions (maybe I did not notice it) I got the problem. anyway thanks again for responding and for the excellent work.

Note that ode_def was deprecated in 2020, and thus one needs to do using ParameterizedFunctions (and add that package) in order to use that functionality. This is already the reason why you will no longer find it in the DifferentialEquations.jl documentation. I added a comment to the video to hopefully help the next person who might run into this. Yeah, videos can’t easily be updated :sweat_smile:, but it’s still almost all still relevant.

2 Likes

Yeah, I see. actually there are some other changes (like there is no more A_mul_B! function and instead we have mul! which is part of LinearAlgebra, or A + B + C works exactly like A .+ B .+ C and … ) but as you said it is hard to update videos and these all can be searched.
thanks Chris again for the help