Skip to content

Commit d0e195b

Browse files
up compats, reformat
1 parent 0ae65d0 commit d0e195b

31 files changed

+1492
-873
lines changed

Diff for: .JuliaFormatter.toml

+10-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
style = "sciml"
1+
remove_extra_newlines=true
2+
long_to_short_function_def=true
3+
format_docstrings=true
4+
normalize_line_endings="unix"
5+
separate_kwargs_with_semicolon=true
6+
trailing_comma=true
7+
conditional_to_if=true
8+
yas_style_nesting=true
9+
short_to_long_function_def=true
10+
always_use_return=true

Diff for: .github/workflows/CompatHelper.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install Julia, but only if it is not already available in the PATH
1818
uses: julia-actions/setup-julia@v1
1919
with:
20-
version: '1.8'
20+
version: '1.9'
2121
arch: ${{ runner.arch }}
2222
if: steps.julia_in_path.outcome != 'success'
2323
- name: "Add the General registry via Git"

Diff for: .github/workflows/Documenter.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- uses: julia-actions/setup-julia@latest
1616
with:
17-
version: '1.8'
17+
version: '1.9'
1818
- uses: actions/cache@v3
1919
env:
2020
cache-name: cache-artifacts

Diff for: .github/workflows/Tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
julia_version: ['1.8']
14+
julia_version: ['1.9']
1515
os: [ubuntu-latest]
1616
steps:
1717
- uses: actions/checkout@v3

Diff for: Project.toml

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ReactiveDynamics"
22
uuid = "c7456e7d-545a-4b79-91ea-6e93d96dd4d4"
3-
version = "0.2.6"
3+
version = "0.2.7"
44

55
[deps]
66
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
@@ -33,30 +33,31 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
3333
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3434

3535
[compat]
36-
CSV = "0.10"
37-
Catlab = "0.14.13"
38-
ComponentArrays = "0.13"
39-
Crayons = "4.1"
40-
DataFrames = "1.4"
41-
DiffEqBase = "6.114"
42-
DifferentialEquations = "7.6"
43-
Distributions = "0.25"
44-
Documenter = "0.27"
36+
julia = "1.9"
37+
DifferentialEquations = "7.9"
38+
StatsFuns = "1.3"
39+
Catlab = "0.14"
40+
DataFrames = "1.6"
41+
PlutoUI = "0.7"
42+
Statistics = "1.9"
4543
DocumenterMarkdown = "0.2"
46-
GeneratedExpressions = "0.1"
47-
IJulia = "1.24"
44+
ComponentArrays = "0.14"
4845
JLD2 = "0.4"
46+
GeneratedExpressions = "0.1"
47+
DiffEqBase = "6.128"
4948
JSON = "0.21"
50-
MacroTools = "0.5"
51-
NLopt = "0.6"
52-
OrdinaryDiffEq = "6.38"
53-
Plots = "1.38"
54-
Pluto = "0.19"
55-
PlutoUI = "0.7"
49+
NLopt = "1.0"
50+
OrdinaryDiffEq = "6.55"
51+
Symbolics = "5.5"
52+
IJulia = "1.24"
53+
SafeTestsets = "0.1"
54+
CSV = "0.10"
55+
Plots = "1.39"
5656
Reexport = "1.2"
57-
SafeTestsets = "0.0"
58-
StatsFuns = "1.1"
59-
Symbolics = "4.14, 5"
6057
TOML = "1.0"
58+
MacroTools = "0.5"
59+
Crayons = "4.1"
60+
Documenter = "0.27"
6161
Tables = "1.10"
62-
julia = "1.8"
62+
Distributions = "0.25"
63+
Pluto = "0.19"

Diff for: docs/make.jl

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
using Documenter, DocumenterMarkdown
22
using ReactiveDynamics
33

4-
makedocs(format = Documenter.HTML(prettyurls = false, edit_link = "main"),
5-
sitename = "ReactiveDynamics.jl API Documentation", pages = ["index.md"])
4+
makedocs(;
5+
format = Documenter.HTML(; prettyurls = false, edit_link = "main"),
6+
sitename = "ReactiveDynamics.jl API Documentation",
7+
pages = ["index.md"],
8+
)
69

7-
deploydocs(repo = "github.com/Merck/ReactiveDynamics.jl.git")
10+
deploydocs(; repo = "github.com/Merck/ReactiveDynamics.jl.git")

Diff for: src/ReactiveDynamics.jl

+109-60
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ using ComponentArrays
88

99
@reexport using GeneratedExpressions
1010

11-
const SampleableValues = Union{Expr, Symbol, AbstractString, Float64, Int, Function}
12-
const ActionableValues = Union{Function, Symbol, Float64, Int}
13-
14-
const SampleableRange = Union{Float64, Int64, AbstractString, Expr, Symbol,
15-
Tuple{Float64,
16-
Union{Float64, Int64, AbstractString, Expr, Symbol}}}
11+
const SampleableValues = Union{Expr,Symbol,AbstractString,Float64,Int,Function}
12+
const ActionableValues = Union{Function,Symbol,Float64,Int}
13+
14+
const SampleableRange = Union{
15+
Float64,
16+
Int64,
17+
AbstractString,
18+
Expr,
19+
Symbol,
20+
Tuple{Float64,Union{Float64,Int64,AbstractString,Expr,Symbol}},
21+
}
1722

1823
Base.convert(::Type{SampleableRange}, x::Tuple) = (Float64(x[1]), x[2])
1924

@@ -26,8 +31,14 @@ end
2631
@present TheoryReactionNetwork(FreeSchema) begin
2732
(S, T)::Ob # species, transitions
2833

29-
(SymbolicAttributeT, DescriptiveAttributeT, SampleableAttributeT,
30-
ModalityAttributeT, PcsOptT, PrmAttributeT)::AttrType
34+
(
35+
SymbolicAttributeT,
36+
DescriptiveAttributeT,
37+
SampleableAttributeT,
38+
ModalityAttributeT,
39+
PcsOptT,
40+
PrmAttributeT,
41+
)::AttrType
3142

3243
specName::Attr(S, SymbolicAttributeT)
3344
specModality::Attr(S, ModalityAttributeT)
@@ -64,112 +75,150 @@ end
6475

6576
@acset_type FoldedReactionNetworkType(TheoryReactionNetwork)
6677

67-
const ReactionNetwork = FoldedReactionNetworkType{Symbol, Union{String, Symbol, Missing},
68-
SampleableValues, Set{Symbol},
69-
FoldedObservable, Any}
78+
const ReactionNetwork = FoldedReactionNetworkType{
79+
Symbol,
80+
Union{String,Symbol,Missing},
81+
SampleableValues,
82+
Set{Symbol},
83+
FoldedObservable,
84+
Any,
85+
}
7086

7187
Base.convert(::Type{Symbol}, ex::String) = Symbol(ex)
7288

73-
function Base.convert(::Type{Union{String, Symbol, Missing}}, ex::String)
89+
Base.convert(::Type{Union{String,Symbol,Missing}}, ex::String) =
7490
try
7591
Symbol(ex)
7692
catch
7793
string(ex)
7894
end
79-
end
8095

8196
Base.convert(::Type{SampleableValues}, ex::String) = MacroTools.striplines(Meta.parse(ex))
8297
Base.convert(::Type{Set{Symbol}}, ex::String) = eval(Meta.parse(ex))
8398
Base.convert(::Type{FoldedObservable}, ex::String) = eval(Meta.parse(ex))
8499

85-
prettynames = Dict(:transRate => [:rate],
86-
:specInitUncertainty => [:uncertainty, :stoch, :stochasticity],
87-
:transPostAction => [:postAction, :post],
88-
:transName => [:name, :interpretation],
89-
:transPriority => [:priority],
90-
:transProbOfSuccess => [:probability, :prob, :pos],
91-
:transCapacity => [:cap, :capacity],
92-
:transCycleTime => [:ct, :cycletime],
93-
:transMaxLifeTime => [:lifetime, :maxlifetime, :maxtime, :timetolive])
94-
95-
defargs = Dict(:T => Dict{Symbol, Any}(:transPriority => 1, :transProbOfSuccess => 1,
96-
:transCapacity => Inf, :transCycleTime => 0.0,
97-
:transMaxLifeTime => Inf, :transMultiplier => 1,
98-
:transPostAction => :(), :transName => missing),
99-
:S => Dict{Symbol, Any}(:specInitUncertainty => 0.0, :specInitVal => 0.0,
100-
:specCost => 0.0, :specReward => 0.0,
101-
:specValuation => 0.0),
102-
:P => Dict{Symbol, Any}(:prmVal => missing),
103-
:M => Dict{Symbol, Any}(:metaVal => missing))
104-
105-
compilable_attrs = filter(attr -> eltype(attr) == SampleableValues,
106-
propertynames(ReactionNetwork()))
100+
prettynames = Dict(
101+
:transRate => [:rate],
102+
:specInitUncertainty => [:uncertainty, :stoch, :stochasticity],
103+
:transPostAction => [:postAction, :post],
104+
:transName => [:name, :interpretation],
105+
:transPriority => [:priority],
106+
:transProbOfSuccess => [:probability, :prob, :pos],
107+
:transCapacity => [:cap, :capacity],
108+
:transCycleTime => [:ct, :cycletime],
109+
:transMaxLifeTime => [:lifetime, :maxlifetime, :maxtime, :timetolive],
110+
)
111+
112+
defargs = Dict(
113+
:T => Dict{Symbol,Any}(
114+
:transPriority => 1,
115+
:transProbOfSuccess => 1,
116+
:transCapacity => Inf,
117+
:transCycleTime => 0.0,
118+
:transMaxLifeTime => Inf,
119+
:transMultiplier => 1,
120+
:transPostAction => :(),
121+
:transName => missing,
122+
),
123+
:S => Dict{Symbol,Any}(
124+
:specInitUncertainty => 0.0,
125+
:specInitVal => 0.0,
126+
:specCost => 0.0,
127+
:specReward => 0.0,
128+
:specValuation => 0.0,
129+
),
130+
:P => Dict{Symbol,Any}(:prmVal => missing),
131+
:M => Dict{Symbol,Any}(:metaVal => missing),
132+
)
133+
134+
compilable_attrs =
135+
filter(attr -> eltype(attr) == SampleableValues, propertynames(ReactionNetwork()))
107136

108137
species_modalities = [:nonblock, :conserved, :rate]
109138

110139
function assign_defaults!(acs::ReactionNetwork)
111140
for (_, v_) in defargs, (k, v) in v_
112-
for i in 1:length(subpart(acs, k))
141+
for i = 1:length(subpart(acs, k))
113142
isnothing(acs[i, k]) && (subpart(acs, k)[i] = v)
114143
end
115144
end
116145

117-
foreach(i -> !isnothing(acs[i, :specModality]) ||
118-
(subpart(acs, :specModality)[i] = Set{Symbol}()), 1:nparts(acs, :S))
146+
foreach(
147+
i ->
148+
!isnothing(acs[i, :specModality]) ||
149+
(subpart(acs, :specModality)[i] = Set{Symbol}()),
150+
1:nparts(acs, :S),
151+
)
119152
k = [:specCost, :specReward, :specValuation]
120-
foreach(k -> foreach(i -> !isnothing(acs[i, k]) || (subpart(acs, k)[i] = 0.0),
121-
1:nparts(acs, :S)), k)
122-
123-
acs
153+
foreach(
154+
k -> foreach(
155+
i -> !isnothing(acs[i, k]) || (subpart(acs, k)[i] = 0.0),
156+
1:nparts(acs, :S),
157+
),
158+
k,
159+
)
160+
161+
return acs
124162
end
125163

126164
function ReactionNetwork(transitions, reactants, obs, events)
127-
merge_acs!(ReactionNetwork(), transitions, reactants, obs, events)
165+
return merge_acs!(ReactionNetwork(), transitions, reactants, obs, events)
128166
end
129167

130168
function ReactionNetwork(transitions, reactants, obs)
131-
merge_acs!(ReactionNetwork(), transitions, reactants, obs, [])
169+
return merge_acs!(ReactionNetwork(), transitions, reactants, obs, [])
132170
end
133171

134172
function add_obs!(acs, obs)
135173
for p in obs
136174
sym = p.args[3].value
137175
i = incident(acs, sym, :obsName)
138-
i = isempty(incident(acs, sym, :obsName)) ?
139-
add_part!(acs, :obs; obsName = sym, obsOpts = FoldedObservable()) : i[1]
176+
i = if isempty(incident(acs, sym, :obsName))
177+
add_part!(acs, :obs; obsName = sym, obsOpts = FoldedObservable())
178+
else
179+
i[1]
180+
end
140181
for opt in p.args[4:end]
141182
if isexpr(opt, :(=)) && (opt.args[1] fieldnames(FoldedObservable))
142183
opt.args[1] == :every &&
143184
(acs[i, :obsOpts].every = min(acs[i, :obsOpts].every, opt.args[2]))
144185
opt.args[1] == :on && union!(acs[i, :obsOpts].on, [opt.args[2]])
145186
elseif isexpr(opt, :tuple) || opt isa SampleableValues
146-
push!(acs[i, :obsOpts].range,
147-
isexpr(opt, :tuple) ? tuple(opt.args...) : opt)
187+
push!(
188+
acs[i, :obsOpts].range,
189+
isexpr(opt, :tuple) ? tuple(opt.args...) : opt,
190+
)
148191
end
149192
end
150193
end
151194

152-
acs
195+
return acs
153196
end
154197

155198
function merge_acs!(acs::ReactionNetwork, transitions, reactants, obs, events)
156-
foreach(t -> add_part!(acs, :T; trans = t[1][2], transRate = t[1][1], t[2]...),
157-
transitions)
199+
foreach(
200+
t -> add_part!(acs, :T; trans = t[1][2], transRate = t[1][1], t[2]...),
201+
transitions,
202+
)
158203
add_obs!(acs, obs)
159204
unique!(reactants)
160-
foreach(ev -> add_part!(acs, :E; eventTrigger = ev.trigger, eventAction = ev.action),
161-
events)
162-
foreach(r -> isempty(incident(acs, r, :specName)) && add_part!(acs, :S; specName = r),
163-
reactants)
164-
165-
assign_defaults!(acs)
205+
foreach(
206+
ev -> add_part!(acs, :E; eventTrigger = ev.trigger, eventAction = ev.action),
207+
events,
208+
)
209+
foreach(
210+
r -> isempty(incident(acs, r, :specName)) && add_part!(acs, :S; specName = r),
211+
reactants,
212+
)
213+
214+
return assign_defaults!(acs)
166215
end
167216

168217
include("state.jl")
169218
include("compilers.jl")
170-
include.(readdir(joinpath(@__DIR__, "interface"), join = true))
171-
include.(readdir(joinpath(@__DIR__, "utils"), join = true))
172-
include.(readdir(joinpath(@__DIR__, "operators"), join = true))
219+
include.(readdir(joinpath(@__DIR__, "interface"); join = true))
220+
include.(readdir(joinpath(@__DIR__, "utils"); join = true))
221+
include.(readdir(joinpath(@__DIR__, "operators"); join = true))
173222
include("solvers.jl")
174223
include("optim.jl")
175224
include("loadsave.jl")

0 commit comments

Comments
 (0)