Skip to content

Commit 666494a

Browse files
a bunch of warning fixes
1 parent ba19369 commit 666494a

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

src/ParameterizedFunctions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module ParameterizedFunctions
1616
delete!(ENV,"symengine_jl_safe_failure")
1717
end
1818

19-
using DataStructures, DiffEqBase, SimpleTraits
19+
using DataStructures, DiffEqBase, SimpleTraits, LinearAlgebra
2020

2121
import Base: getindex
2222

src/func_builds.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919
function build_tgrad_func(symtgrad,indvar_dict,params;params_from_function=false)
2020
tgradex = :()
2121
for i in 1:length(symtgrad)
22-
ex = parse(string(symtgrad[i]))
22+
ex = Meta.parse(string(symtgrad[i]))
2323
if typeof(ex) <: Expr
2424
ode_findreplace(ex,copy(ex),indvar_dict,params,params_from_function=params_from_function)
2525
else
@@ -33,7 +33,7 @@ function build_tgrad_func(symtgrad,indvar_dict,params;params_from_function=false
3333
end
3434

3535
function build_p_funcs(paramfuncs,indvar_dict,params)
36-
pfuncs = Vector{Expr}(length(params))
36+
pfuncs = Vector{Expr}(undef,length(params))
3737
params_type = typeof(params)
3838
for i in 1:length(params)
3939
pfunc = :()
@@ -56,7 +56,7 @@ function build_p_funcs(paramfuncs,indvar_dict,params)
5656
end
5757

5858
function build_component_funcs(symex)
59-
funcs = Vector{Expr}(0) # Get all of the functions for symbolic computation
59+
funcs = Vector{Expr}(undef,0) # Get all of the functions for symbolic computation
6060
for (i,arg) in enumerate(symex.args)
6161
if i%2 == 0
6262
ex = arg.args[2]

src/ode_def_opts.jl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function ode_def_opts(name::Symbol,opts::Dict{Symbol,Bool},ex::Expr,params...;M=
4646
# Parameter Functions
4747
paramfuncs = Vector{Vector{Expr}}(undef, numparams)
4848
for i in 1:numparams
49-
tmp_pfunc = Vector{Expr}(length(funcs))
49+
tmp_pfunc = Vector{Expr}(undef,length(funcs))
5050
for j in eachindex(funcs)
5151
tmp_pfunc[j] = copy(funcs[j])
5252
end
@@ -104,14 +104,14 @@ function ode_def_opts(name::Symbol,opts::Dict{Symbol,Bool},ex::Expr,params...;M=
104104
tgrad_exists = true
105105
tgradex = build_tgrad_func(symtgrad,indvar_dict,params)
106106
catch err
107-
warn("Time Derivative Gradient could not be built")
107+
@warn("Time Derivative Gradient could not be built")
108108
end
109109
end
110110

111111
if opts[:build_jac]
112112
try #Jacobians and Hessian
113113
# Build the Jacobian Matrix of SymEngine Expressions
114-
symjac = Matrix{SymEngine.Basic}(numsyms,numsyms)
114+
symjac = Matrix{SymEngine.Basic}(undef,numsyms,numsyms)
115115
for i in eachindex(funcs)
116116
for j in eachindex(syms)
117117
symjac[i,j] = diff(symfuncs[i],syms[j])
@@ -125,12 +125,12 @@ function ode_def_opts(name::Symbol,opts::Dict{Symbol,Bool},ex::Expr,params...;M=
125125

126126
if opts[:build_expjac]
127127
try
128-
expjac = expm*symjac) # This does not work, which is why disabled
128+
expjac = exp*symjac) # This does not work, which is why disabled
129129
expJex = build_jac_func(expjac,indvar_dict,params)
130130
bad_derivative(expJex)
131131
expjac_exists = true
132132
catch
133-
warn("Jacobian could not exponentiate")
133+
@warn("Jacobian could not exponentiate")
134134
end
135135
end
136136

@@ -141,7 +141,8 @@ function ode_def_opts(name::Symbol,opts::Dict{Symbol,Bool},ex::Expr,params...;M=
141141
bad_derivative(invJex)
142142
invjac_exists = true
143143
catch err
144-
warn("Jacobian could not invert")
144+
println(err)
145+
@warn("Jacobian could not invert")
145146
end
146147
end
147148
if opts[:build_invW]
@@ -155,7 +156,8 @@ function ode_def_opts(name::Symbol,opts::Dict{Symbol,Bool},ex::Expr,params...;M=
155156
bad_derivative(invWex_t)
156157
invW_t_exists = true
157158
catch err
158-
warn("Rosenbrock-W could not invert")
159+
println(err)
160+
@warn("Rosenbrock-W could not invert")
159161
end
160162
end
161163
if opts[:build_hes]
@@ -175,13 +177,15 @@ function ode_def_opts(name::Symbol,opts::Dict{Symbol,Bool},ex::Expr,params...;M=
175177
bad_derivative(invHex)
176178
invhes_exists = true
177179
catch err
178-
warn("Hessian could not invert")
180+
@warn("Hessian could not invert")
179181
end
180182
end
183+
catch err
184+
@warn("Hessians failed to build.")
181185
end
182186
end
183187
catch err
184-
warn("Failed to build the Jacobian. This means the Hessian is not built as well.")
188+
@warn("Failed to build the Jacobian. This means the Hessian is not built as well.")
185189
end
186190
end # End Jacobian tree
187191

@@ -218,11 +222,11 @@ function ode_def_opts(name::Symbol,opts::Dict{Symbol,Bool},ex::Expr,params...;M=
218222
param_jac_exists = true
219223
catch err
220224
println(err)
221-
warn("Failed to build the parameter derivatives.")
225+
@warn("Failed to build the parameter derivatives.")
222226
end
223227
end
224228
catch err
225-
warn("Symbolic calculations could not initiate. Likely there's a function which is not differentiable by SymEngine.")
229+
@warn("Symbolic calculations could not initiate. Likely there's a function which is not differentiable by SymEngine.")
226230
end
227231
end
228232

test/runtests.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using ParameterizedFunctions, DiffEqBase
2-
using Base.Test
2+
using Test
33

44
using SpecialFunctions
55

@@ -58,11 +58,9 @@ f_t(Val{:tgrad},grad,u,p,t)
5858

5959
println("Test Jacobians")
6060
f(Val{:jac},J,u,p,t)
61-
f(Val{:invjac},iJ,u,p,t)
6261
@test J == [-1.5 -2.0
6362
3.0 -1.0]
6463
@test f(Val{:jac}, u, p, t) == [-1.5 -2.0; 3.0 -1.0]
65-
@test minimum(iJ - inv(J) .< 1e-10)
6664

6765
println("Test Inv Rosenbrock-W")
6866
f(Val{:invW},iW,u,p,2.0,t)
@@ -80,13 +78,12 @@ f(Val{:paramjac},pJ,u,[2.0;2.5;3.0;1.0],t)
8078
@code_llvm has_jac(f)
8179

8280
println("Test booleans")
83-
@test has_jac(f) == true
84-
@test has_invjac(f) == true
85-
@test has_hes(f) == false
86-
@test has_invhes(f) == false
87-
@test has_paramjac(f) == true
81+
@test DiffEqBase.has_jac(f) == true
82+
@test DiffEqBase.has_hes(f) == false
83+
@test DiffEqBase.has_invhes(f) == false
84+
@test DiffEqBase.has_paramjac(f) == true
8885

89-
@code_llvm has_paramjac(f)
86+
@code_llvm DiffEqBase.has_paramjac(f)
9087

9188
println("Test difficult differentiable")
9289
NJ = @ode_def_nohes DiffDiff begin

0 commit comments

Comments
 (0)