Catalyst.jl icon indicating copy to clipboard operation
Catalyst.jl copied to clipboard

Update `Reaction` constructor

Open TorkelE opened this issue 1 year ago • 2 comments

  • Permits [] and nothing to be used interchangeably (previously there were some cases which unintentionally would not work).
  • Ensures that the Reaction structure is concretely typed.

TorkelE avatar May 21 '24 01:05 TorkelE

Actually, now I think this is a bad idea. Someone has made the confusing choice to define get_variables(e::Equation) completely inconsistently with get_variables! in Symbolics, where the latter gets dependent variables (so rhs only).

I think if we want such a function for Reactions we should come up with a different name to avoid confusion (since we already have get_variables! defined on it).

isaacsas avatar May 21 '24 12:05 isaacsas

Do you mean this definition:

# determine which unknowns a reaction depends on
function MT.get_variables!(deps::Set, rx::Reaction, variables)
    (rx.rate isa Symbolic) && get_variables!(deps, rx.rate, variables)
    for s in rx.substrates
        # parametric stoichiometry means may have a parameter as a substrate
        any(isequal(s), variables) && push!(deps, s)
    end
    deps
end

and this PR https://github.com/SciML/Catalyst.jl/pull/855?

To do get_variables(x) where you return a vector of all the symbolic variables in x (whatever it is) is (to me) the established way to use the function, so get_variables(rx::Reaction) makes sense. Practically, I think we should have some function that does this, as it seems like something genuinely useful.

TorkelE avatar May 21 '24 14:05 TorkelE