Skip to content

Commit 6f73003

Browse files
committed
up
1 parent 3385807 commit 6f73003

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

HISTORY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
@equations D(D(V)) ~ 1
3030
end
3131
```
32-
Please note that this cannot be used at the same time as `D` is used to represent a species, variable, or parameter.
32+
Please note that this cannot be used at the same time as `D` is used to represent a species, variable, or parameter (including is these are implicitly designated as such by e.g. appearing as a reaction reactant).
3333
- Array symbolics support is more consistent with ModelingToolkit v9. Parameter
3434
arrays are no longer scalarized by Catalyst, while species and variables
3535
arrays still are (as in ModelingToolkit). As such, parameter arrays should now

src/dsl.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ function make_reaction_system(ex::Expr; name = :(gensym(:ReactionSystem)))
357357
# Excludes any parameters already extracted (if they also was a variable).
358358
declared_syms = union(declared_syms, species_extracted)
359359
vars_extracted, add_default_diff, equations = read_equations_options(
360-
options, declared_syms; requiredec)
360+
options, declared_syms, parameters_extracted; requiredec)
361361
variables = vcat(variables_declared, vars_extracted)
362362
parameters_extracted = setdiff(parameters_extracted, vars_extracted)
363363

@@ -705,7 +705,7 @@ end
705705
# `vars_extracted`: A vector with extracted variables (lhs in pure differential equations only).
706706
# `dtexpr`: If a differential equation is defined, the default derivative (D ~ Differential(t)) must be defined.
707707
# `equations`: a vector with the equations provided.
708-
function read_equations_options(options, syms_declared; requiredec = false)
708+
function read_equations_options(options, syms_declared, parameters_extracted; requiredec = false)
709709
# Prepares the equations. First, extracts equations from provided option (converting to block form if required).
710710
# Next, uses MTK's `parse_equations!` function to split input into a vector with the equations.
711711
eqs_input = haskey(options, :equations) ? options[:equations].args[3] : :(begin end)
@@ -725,8 +725,7 @@ function read_equations_options(options, syms_declared; requiredec = false)
725725
end
726726

727727
# If the default differential (`D`) is used, record that it should be decalred later on.
728-
729-
if !in(eq, syms_declared) && find_D_call(eq)
728+
if (:D union(syms_declared, parameters_extracted)) && find_D_call(eq)
730729
requiredec && throw(UndeclaredSymbolicError(
731730
"Unrecognized symbol D was used as a differential in an equation: \"$eq\". Since the @require_declaration flag is set, all differentials in equations must be explicitly declared using the @differentials option."))
732731
add_default_diff = true

test/dsl/dsl_options.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,11 @@ let
614614
#@equations D(V) ~ 1 - V
615615
#d, X --> 0
616616
#end
617-
@test_broken false # @test_throws Exception @eval @reaction_network begin
618-
#@parameters D
619-
#@equations D(V) ~ 1 - V
620-
#d, X --> 0
621-
#end
617+
@test_throws Exception @eval @reaction_network begin
618+
@parameters D
619+
@equations D(V) ~ 1 - V
620+
d, X --> 0
621+
end
622622

623623
# Symbol only occurring in events.
624624
@test_throws Exception @eval @reaction_network begin

0 commit comments

Comments
 (0)