From 233dbcac3349afb4cee4e8fade43940f3495165e Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Mon, 11 Aug 2025 05:56:06 +0530 Subject: [PATCH 1/3] build: add SymbolicIndexingInterface dependency --- Project.toml | 2 ++ src/Catalyst.jl | 1 + 2 files changed, 3 insertions(+) diff --git a/Project.toml b/Project.toml index b831249319..c5eba2b902 100644 --- a/Project.toml +++ b/Project.toml @@ -24,6 +24,7 @@ RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5" SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" @@ -71,6 +72,7 @@ RuntimeGeneratedFunctions = "0.5.12" SciMLBase = "2.84" Setfield = "1" StructuralIdentifiability = "0.5.11" +SymbolicIndexingInterface = "0.3.42" SymbolicUtils = "3.20" Symbolics = "6.31.1" Unitful = "1.12.4" diff --git a/src/Catalyst.jl b/src/Catalyst.jl index a079816d87..e6f2f0dd47 100644 --- a/src/Catalyst.jl +++ b/src/Catalyst.jl @@ -48,6 +48,7 @@ import Parameters: @with_kw_noshow import Symbolics: occursin, wrap import Symbolics.RewriteHelpers: hasnode, replacenode import SymbolicUtils: getmetadata, hasmetadata, setmetadata +import SymbolicIndexingInterface as SII # globals for the modulate function default_time_deriv() From f80b053e9ff1b319aca4aa0dc696241941ef0af2 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Mon, 11 Aug 2025 05:56:26 +0530 Subject: [PATCH 2/3] refactor: do not use Symbolics/SymbolicUtils internals to detect array variables --- src/spatial_reaction_systems/lattice_reaction_systems.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/spatial_reaction_systems/lattice_reaction_systems.jl b/src/spatial_reaction_systems/lattice_reaction_systems.jl index e95c902176..ad16cabf6a 100644 --- a/src/spatial_reaction_systems/lattice_reaction_systems.jl +++ b/src/spatial_reaction_systems/lattice_reaction_systems.jl @@ -154,9 +154,10 @@ struct LatticeReactionSystem{Q, R, S, T} <: MT.AbstractTimeDependentSystem spatial_reactions) # Additional error checks. - if any(haskey(Symbolics.unwrap(symvar).metadata, Symbolics.ArrayShapeCtx) + if any(SII.symbolic_type(symvar) === SII.ArraySymbolic() for symvar in [ps; species(rs)]) - throw(ArgumentError("Some species and/or parameters used to create the `LatticeReactionSystem` are array variables ($(filter(symvar -> haskey(Symbolics.unwrap(symvar).metadata, Symbolics.ArrayShapeCtx), [ps; species(rs)]))). This is currently not supported.")) + arrvars = filter(x -> SII.symbolic_type(x) === SII.ArraySymbolic(), [ps; species(rs)]) + throw(ArgumentError("Some species and/or parameters used to create the `LatticeReactionSystem` are array variables ($(arrvars). This is currently not supported.")) end return new{Q, R, S, T}( From 4a264228e1657502e29cca50334173c02d4bd781 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Mon, 11 Aug 2025 05:58:55 +0530 Subject: [PATCH 3/3] refactor: import BasicSymbolic from SymbolicUtils instead of Symbolics --- src/Catalyst.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Catalyst.jl b/src/Catalyst.jl index e6f2f0dd47..169fd391b5 100644 --- a/src/Catalyst.jl +++ b/src/Catalyst.jl @@ -22,7 +22,6 @@ using LinearAlgebra using RuntimeGeneratedFunctions RuntimeGeneratedFunctions.init(@__MODULE__) -import Symbolics: BasicSymbolic using Symbolics: iscall, sorted_arguments using ModelingToolkit: Symbolic, value, get_unknowns, get_ps, get_iv, get_systems, get_eqs, get_defaults, toparam, get_var_to_name, get_observed, @@ -47,7 +46,7 @@ import DataStructures: OrderedDict, OrderedSet import Parameters: @with_kw_noshow import Symbolics: occursin, wrap import Symbolics.RewriteHelpers: hasnode, replacenode -import SymbolicUtils: getmetadata, hasmetadata, setmetadata +import SymbolicUtils: BasicSymbolic, getmetadata, hasmetadata, setmetadata import SymbolicIndexingInterface as SII # globals for the modulate