Skip to content

Commit

Permalink
Define global convenience Solution type alias.
Browse files Browse the repository at this point in the history
  • Loading branch information
iago-lito committed Apr 18, 2023
1 parent 2316c2c commit f413f66
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ EcologicalNetworks = "f03a62fe-f8ab-5b77-a061-bb599b765229"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Mangal = "b8b640a6-63d9-51e6-b784-5033db27bef2"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

3 changes: 3 additions & 0 deletions src/EcologicalNetworksDynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ using OrderedCollections
using SparseArrays
using Statistics
using Decimals
using SciMLBase

# Convenience aliases.
const Solution = SciMLBase.AbstractODESolution

# Include scripts
include(joinpath(".", "macros.jl"))
Expand Down
6 changes: 3 additions & 3 deletions src/measures/functioning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function aggregate_trophic_level(op_name, aggregate_function)
return quote

@doc $docstring function $op_trophic_level(
solution::SciMLBase.ODESolution;
solution::Solution;
threshold = 0,
kwargs...,
)
Expand Down Expand Up @@ -568,7 +568,7 @@ end


"""
living_species(solution; threshold, kwargs...)
living_species(solution::Solution; threshold, kwargs...)
Returns the vectors of alive species and their indices in the original network.
Living species are the ones having, in average, a biomass above `threshold` over
Expand Down Expand Up @@ -596,7 +596,7 @@ julia> B0 = [0, 0.5, 0.5];
```
"""
function living_species(
solution::SciMLBase.ODESolution;
solution::Solution;
threshold = 0,
idxs = nothing,
kwargs...,
Expand Down
11 changes: 5 additions & 6 deletions src/measures/stability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ Various measures of stability
=#

"""
species_cv(solution; threshold, kwargs...)
species_cv(solution::Solution; threshold, kwargs...)
Computes the temporal coefficient of variation of species biomass and its average.
See [`coefficient_of_variation`](@ref) for the details.
"""
function species_cv(solution::SciMLBase.ODESolution; threshold = 0, last = "10%", kwargs...)

function species_cv(solution::Solution; threshold = 0, last = "10%", kwargs...)
measure_on = extract_last_timesteps(solution; last, kwargs...)
# Fetch species that are alive, whose avg biomass is > threshold
living_sp = living_species(measure_on; threshold)
Expand Down Expand Up @@ -54,7 +53,7 @@ Neutral and Nonneutral Community Dynamics in Fluctuating Environments. The
American Naturalist, 172(2), E48‑E66. https://doi.org/10.1086/589746
"""
function synchrony(
solution::SciMLBase.ODESolution;
solution::Solution;
threshold = 0,
last = "10%",
corrected = true,
Expand Down Expand Up @@ -96,7 +95,7 @@ Compute the temporal Coefficient of Variation of community biomass.
See [`coefficient_of_variation`](@ref) for the argument details.
"""
function community_cv(
solution::SciMLBase.ODESolution;
solution::Solution;
threshold = 0,
last = "10%",
corrected = true,
Expand Down Expand Up @@ -164,7 +163,7 @@ julia> B0 = [0, 0.5, 0.5]; # Two producers
```
"""
function coefficient_of_variation(
solution;
solution::Solution;
threshold = 0,
last = "10%",
corrected = true,
Expand Down

0 comments on commit f413f66

Please sign in to comment.