Skip to content

Commit 91687d6

Browse files
warn if independent variable is repeated
1 parent f394295 commit 91687d6

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/dict_build.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
function build_indvar_dict(ex)
1+
function build_indvar_dict(ex,depvar)
22
indvar_dict = OrderedDict{Symbol,Int}()
33
cur_sym = 0
44
for i in 2:2:length(ex.args) #Every odd line is line number
55
arg = ex.args[i].args[1] #Get the first thing, should be dsomething
66
firstarg = Symbol(first(string(arg))) # Check for d
77
if firstarg == :d
88
nodarg = Symbol(join(Base.Iterators.drop(string(arg), 1)))
9+
if nodarg == depvar
10+
warn("$depvar is fixed as the independent variable but is also used as a dependent variable. Results my be incorrect.")
11+
end
912
if !haskey(indvar_dict,nodarg)
1013
cur_sym += 1
1114
indvar_dict[nodarg] = cur_sym

src/fem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ macro fem_def(sig,name,ex,params...)
22

33
origex = ex
44
## Build Symbol dictionary
5-
indvar_dict,syms = build_indvar_dict(ex)
5+
indvar_dict,syms = build_indvar_dict(ex,:t)
66

77
param_dict, inline_dict = build_paramdicts(params)
88
# Run find replace

src/ode_def_opts.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function ode_def_opts(name::Symbol,opts::Dict{Symbol,Bool},ex::Expr,params...;M=
44
origex = copy(ex) # Save the original expression
55

66
## Build independent variable dictionary
7-
indvar_dict,syms = build_indvar_dict(ex)
7+
indvar_dict,syms = build_indvar_dict(ex,depvar)
88
## Build parameter and inline dictionaries
99
param_dict, inline_dict = build_paramdicts(params)
1010
####

0 commit comments

Comments
 (0)