Skip to content

Commit 243c7fd

Browse files
committed
✨ Shorten simulate verbosity arguments names.
1 parent 75375e2 commit 243c7fd

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/simulate.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@ function _simulate(raw::Internal, u0, tmax::Real; kwargs...)
1717

1818
# If set, produce an @info message
1919
# to warn user about possible degenerated network topologies.
20-
deg_top_arg = :show_degenerated_biomass_graph_properties
20+
deg_top_arg = :show_degenerated
2121
deg_top = take_or!(deg_top_arg, true)
2222

2323
# Lower threshold.
2424
extinction_threshold = take_or!(:extinction_threshold, 1e-12, Any)
2525
extinction_threshold = @tographdata extinction_threshold {Scalar, Vector}{Float64}
2626

27+
shex_arg = :show_extinctions
28+
if given(:callback) && given(shex_arg)
29+
argerr("There is no need for argument $(repr(shex_arg)) \
30+
if you provide your own callbacks: \
31+
the $(repr(shex_arg)) argument only effects \
32+
the default `extinction_callback`.")
33+
end
34+
2735
# Shoo.
28-
verbose = take_or!(:show_extinction_events, false)
36+
verbose = take_or!(:show_extinctions, false)
2937

3038
# No TerminateSteadyState.
3139
extc = extinction_callback(raw, extinction_threshold; verbose)
3240
callback = take_or!(:callbacks, Internals.CallbackSet(extc))
3341

34-
out = Internals.simulate(
35-
raw,
36-
u0;
37-
tmax,
38-
extinction_threshold,
39-
callback,
40-
verbose,
41-
left()...,
42-
)
42+
out = Internals.simulate(raw, u0; tmax, extinction_threshold, callback, left()...)
4343

4444
deg_top && show_degenerated_biomass_graph_properties(
4545
raw,
@@ -63,7 +63,8 @@ to construct simulated biomasses trajectories.
6363
- `tmax`: Maximum simulation time.
6464
- `t0 = 0`: Starting simulation date.
6565
- `extinction_threshold = 1e-5`: Biomass(es) values for which species are considered extinct.
66-
- `show_extinction_events = false`: Raise to display events during simulation.
66+
- `show_extinctions = false`: Raise to display events during simulation.
67+
- `show_degenerated = true`: Raise to warn about degenerated biomass graph properties.
6768
- `...`: additional arguments are passed to `DifferentialEquations.solve`.
6869
6970
Simulation results in a `Solution` object

test/user/08-post-simulation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ end
5757
@testset "Retrieve extinct species." begin
5858

5959
m = default_model(Foodweb([:a => :b, :b => :c]), Mortality([0, 1, 0]))
60-
sol = simulate(m, 0.5, 600; show_degenerated_biomass_graph_properties = false)
60+
sol = simulate(m, 0.5, 600; show_degenerated = false)
6161
ext = get_extinctions(sol)
6262
check_extinctions(ext, Dict([1 => 256.80, 2 => 484.07]))
6363

@@ -76,7 +76,7 @@ end
7676
This message is meant to attract your attention \
7777
regarding the meaning of downstream analyses \
7878
depending on the simulated biomasses values.
79-
You can silent it with `show_degenerated_biomass_graph_properties=false`.""",
79+
You can silent it with `show_degenerated=false`.""",
8080
) simulate(m, 0.5, 600)
8181
top = get_topology(sol)
8282

@@ -112,7 +112,7 @@ end
112112
This message is meant to attract your attention \
113113
regarding the meaning of downstream analyses \
114114
depending on the simulated biomasses values.
115-
You can silent it with `show_degenerated_biomass_graph_properties=false`.""",
115+
You can silent it with `show_degenerated=false`.""",
116116
) simulate(m, 0.5, 100)
117117
ext = get_extinctions(sol)
118118
check_extinctions(ext, Dict(3 => 22.57, 4 => 23.17, 5 => 61.76))

0 commit comments

Comments
 (0)