Skip to content

Commit 54b00fd

Browse files
committed
up
1 parent 1f08118 commit 54b00fd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/reaction_network.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,13 @@ function read_observed_options(options, species_n_vars_declared, ivs_sorted)
705705
isempty(ivs) || error("An observable ($obs_name) was given independent variable(s). These should not be given, as they are inferred automatically.")
706706
isnothing(defaults) || error("An observable ($obs_name) was given a default value. This is forbidden.")
707707
in(obs_name, forbidden_symbols_error) && error("A forbidden symbol ($(obs_eq.args[2])) was used as an observable name.")
708-
if (obs_name in species_n_vars_declared) || is_escaped_expr(obs_eq.args[2])
709-
isnothing(metadata) || error("Metadata was provided to observable $obs_name in the `@observables` macro. However, the obervable was also declared separately (using either @species or @variables). When this is done, metadata should instead be provided within the original @species or @variable declaration.")
708+
709+
# Error checks.
710+
if (obs_name in species_n_vars_declared) && is_escaped_expr(obs_eq.args[2])
711+
error("An interpoalted observable have been used, which has also been explicitly delcared within the system using eitehr @species or @variables. This is not permited.")
712+
end
713+
if ((obs_name in species_n_vars_declared) || is_escaped_expr(obs_eq.args[2])) && !isnothing(metadata)
714+
error("Metadata was provided to observable $obs_name in the `@observables` macro. However, the obervable was also declared separately (using either @species or @variables). When this is done, metadata should instead be provided within the original @species or @variable declaration.")
710715
end
711716

712717
# This bits adds the observables to the @variables vector which is given as output.
@@ -733,7 +738,8 @@ function read_observed_options(options, species_n_vars_declared, ivs_sorted)
733738

734739
# Adds the observable to the list of observable names.
735740
# This is required for filtering away so these are not added to the ReactionSystem's species list.
736-
push!(obs_syms.args, obs_name)
741+
# Again, avoid this check if we have interpoalted teh variable.
742+
is_escaped_expr(obs_eq.args[2]) || push!(obs_syms.args, obs_name)
737743
end
738744

739745
# If nothing was added to `observed_vars`, it has to be modified not to throw an error.

0 commit comments

Comments
 (0)