Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement broadcastable() for basic SBML structs #264

Merged
merged 3 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SBML"
uuid = "e5567a89-2604-4b09-9718-f5f78e97c3bb"
authors = ["Mirek Kratochvil <[email protected]>", "LCSB R3 team <[email protected]>"]
version = "1.6"
version = "1.7"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
44 changes: 44 additions & 0 deletions src/structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,47 @@ Base.@kwdef struct Model
sbo::Maybe{String} = nothing
cv_terms::Vector{CVTerm} = []
end

# Explicitly make all SBML structs "broadcastable" as scalars.
# (This must be updated if any of the structs are added or removed.)
#
# Use this to regenerate the Union contents moreless automatically:
#
# sed -ne 's/.*\<struct \([A-Z][A-Za-z0-9]*\)\>.*/\1,/p' src/structs.jl
exaexa marked this conversation as resolved.
Show resolved Hide resolved
Base.Broadcast.broadcastable(
x::T,
) where {
T<:Union{
UnitPart,
UnitDefinition,
GPARef,
GPAAnd,
GPAOr,
MathVal,
MathIdent,
MathConst,
MathTime,
MathAvogadro,
MathApply,
MathLambda,
CVTerm,
Parameter,
Compartment,
SpeciesReference,
Reaction,
AlgebraicRule,
AssignmentRule,
RateRule,
Constraint,
Species,
GeneProduct,
FunctionDefinition,
EventAssignment,
Trigger,
Objective,
Event,
Member,
Group,
Model,
},
} = Ref(x)
4 changes: 2 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ function flux_bounds(m::SBML.Model)::NTuple{2,Vector{Tuple{Float64,String}}}
values(m.reactions),
:lower_bound,
"LOWER_BOUND",
Ref(Parameter(value = -Inf)),
Parameter(value = -Inf),
),
get_bound.(
values(m.reactions),
:upper_bound,
"UPPER_BOUND",
Ref(Parameter(value = Inf)),
Parameter(value = Inf),
),
)
end
Expand Down
Loading