From b9c6c3b66262c05b4675af33ed701feb174f7eab Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sun, 5 Jan 2025 12:07:20 +0100 Subject: [PATCH 1/3] implement broadcastable() for basic SBML structs closes https://github.com/LCSB-BioCore/SBML.jl/issues/263 --- src/structs.jl | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/structs.jl b/src/structs.jl index 0903af7..9b38846 100644 --- a/src/structs.jl +++ b/src/structs.jl @@ -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/.*\.*/\1,/p' src/structs.jl +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) From ec716501278e7dd535ffe0f095e514be38e79522 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sun, 5 Jan 2025 12:10:22 +0100 Subject: [PATCH 2/3] use the cool new broadcastable stuff --- src/utils.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index cf20733..e87575d 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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 From 81af76f42ddfe1f8a377f4e926565f549f10e8d7 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sun, 5 Jan 2025 12:45:21 +0100 Subject: [PATCH 3/3] bump feature --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 74c3179..28ec7bd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SBML" uuid = "e5567a89-2604-4b09-9718-f5f78e97c3bb" authors = ["Mirek Kratochvil ", "LCSB R3 team "] -version = "1.6" +version = "1.7" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"