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

Englishing docstrings ✏️ #125

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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
44 changes: 22 additions & 22 deletions src/measures/functioning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ over the `last` timesteps. `kwargs...` are optional arguments passed to

- `solution`: output of `simulate()` or `solve()`
- `threshold`: biomass threshold below which a species is considered extinct. Set to 0 by
debault and it is recommended to let as this. It is recommended to change the threshold
default and it is recommended to leave as this. It is recommended to change the threshold
using [`ExtinctionCallback`](@ref) in [`simulate`](@ref).

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 0; 1 0]);
Expand Down Expand Up @@ -48,9 +48,9 @@ end
"""
richness(n::AbstractVector; threshold = 0)

When applied to a vector of biomass, returns the number of biomass above `threshold`
When applied to a vector of biomass, returns the number of biomasses above `threshold`

# Examples
# Examples:

```jldoctest
julia> richness([0, 1])
Expand All @@ -65,7 +65,7 @@ richness(n::AbstractVector; threshold = 0) = sum(n .> threshold)
"""
species_persistence(solution; kwargs...)

Returns the average proportion of species having a biomass superior or equal to threshold
Returns the average proportion of species having a biomass greater than or equal to threshold
over the `last` timesteps.

`kwargs...` arguments are forwarded to [`extract_last_timesteps`](@ref). See
Expand All @@ -75,7 +75,7 @@ When applied to a vector of biomass, e.g.
`species_persistence(n::Vector; threshold = 0)`, it returns the proportion of
species which biomass is above `threshold`.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 0; 0 0]; quiet = true);
Expand Down Expand Up @@ -111,15 +111,15 @@ species_persistence(n::AbstractVector; threshold = 0) = richness(n; threshold) /

Returns a named tuple of total and species biomass, averaged over the `last` timesteps.

# Arguments
# Arguments:

`kwargs...` arguments are forwarded to [`extract_last_timesteps`](@ref). See
[`extract_last_timesteps`](@ref) for the argument details.

Can also handle a species x time biomass matrix, e.g. `biomass(mat::AbstractMatrix;)` or a
vector, e.g. `biomass(vec::AbstractVector;)`.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 0; 1 0]);
Expand Down Expand Up @@ -160,7 +160,7 @@ over the `last` timesteps.

Can also handle a vector, e.g. shannon_diversity(n::AbstractVector; threshold = 0)

# Reference
# Reference:

https://en.wikipedia.org/wiki/Diversity_index#Shannon_index
"""
Expand Down Expand Up @@ -194,7 +194,7 @@ over the `last` timesteps.

Can also handle a vector, e.g. simpson(n::AbstractVector; threshold = 0)

# Reference
# Reference:

https://en.wikipedia.org/wiki/Diversity_index#Simpson_index
"""
Expand All @@ -219,14 +219,14 @@ end
"""
evenness(solution; threshold = 0, kwargs...)

Computes the average Pielou evenness, over the `last` timesteps.
Computes the average Pielou evenness over the `last` timesteps.

`kwargs...` arguments are forwarded to [`extract_last_timesteps`](@ref). See
[`extract_last_timesteps`](@ref) for the argument details.

Can also handle a vector, e.g. `evenness(n::AbstractVector; threshold = 0)`

# Reference
# Reference:

https://en.wikipedia.org/wiki/Species_evenness
"""
Expand All @@ -250,13 +250,13 @@ end
producer_growth(solution; kwargs...)

Returns the average growth rates of producers over the `last` timesteps as as well as the
average (`mean`) and the standard deviation (`std`). It also returns by all the growth
average (`mean`) and the standard deviation (`std`). It also returns all the growth
rates (`all`) as a species x timestep matrix (as the solution matrix).

kwargs... arguments are forwarded to [`extract_last_timesteps`](@ref). See
[`extract_last_timesteps`](@ref) for the argument details.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 1 1; 0 0 0; 0 0 0]);
Expand Down Expand Up @@ -332,13 +332,13 @@ get_parameters(sol) = sol.prob.p.params
trophic_structure(solution; threshold = 0, idxs = nothing, kwargs...)

Returns the maximum, mean and weighted mean trophic level averaged over the `last`
timesteps. It also returns the adjacency matrix containing only the living species and the
vector of the living species at the last timestep.
timesteps. It also returns the adjacency matrix containing only the living species and a
vector of the living species' identities at the last timestep.

kwargs... arguments are forwarded to [`extract_last_timesteps`](@ref). See
[`extract_last_timesteps`](@ref) for the argument details.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 0 0; 0 0 0; 1 1 0]);
Expand Down Expand Up @@ -447,7 +447,7 @@ kwargs... arguments are forwarded to [`extract_last_timesteps`](@ref). See
These functions also handle biomass vectors associated with a network, as well as
a vector of trophic levels (See examples).

# Examples
# Examples:

```jldoctest
julia> A = [0 0; 1 0];
Expand Down Expand Up @@ -565,15 +565,15 @@ end
"""
living_species(solution::Solution; threshold = 0, idxs = nothing, 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
Returns vectors of living species names and their indices within the original network.
Living species are those with an average biomass above `threshold` over
the `last` timesteps. `kwargs...` are optional arguments passed to
[`extract_last_timesteps`](@ref).

`kwargs...` arguments are forwarded to [`extract_last_timesteps`](@ref). See
[`extract_last_timesteps`](@ref) for the argument details.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 1 1; 0 0 0; 0 0 0]);
Expand Down Expand Up @@ -616,7 +616,7 @@ timesteps.
`kwargs...` arguments are forwarded to [`extract_last_timesteps`](@ref). See
[`extract_last_timesteps`](@ref) for the argument details.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 0; 1 0]);
Expand Down
8 changes: 4 additions & 4 deletions src/measures/stability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Various measures of stability.
"""
species_cv(solution::Solution; threshold = 0, last = "10%", kwargs...)

Computes the temporal coefficient of variation of species biomass and its average.
Computes the temporal coefficient of variation of species biomass and calculates the mean.

See [`coefficient_of_variation`](@ref) for the details.
"""
Expand Down Expand Up @@ -52,7 +52,7 @@ Loreau & de Mazancourt (2008).

See [`coefficient_of_variation`](@ref) for the argument details.

# Reference
# Reference:

Loreau, M., & de Mazancourt, C. (2008). Species Synchrony and Its Drivers :
Neutral and Nonneutral Community Dynamics in Fluctuating Environments. The
Expand Down Expand Up @@ -151,13 +151,13 @@ unbiaised estimator of the variance.

See [`richness`](@ref) for the argument details.

# Reference
# Reference:

Thibaut, L. M., & Connolly, S. R. (2013). Understanding diversity–stability
relationships : Towards a unified model of portfolio effects. Ecology Letters,
16(2), 140‑150. https://doi.org/10.1111/ele.12019

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 1 1; 0 0 0; 0 0 0]); # Two producers and one consumer
Expand Down
18 changes: 9 additions & 9 deletions src/measures/structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ richness(net::EcologicalNetwork) = richness(get_trophic_adjacency(net))
richness(A::AbstractMatrix) = size(A, 1)

"""
Connectance of network: number of links / (number of species)^2
Connectance of network: number of links / (number of species)²
"""
connectance(A::AbstractMatrix) = sum(A) / richness(A)^2
connectance(foodweb::FoodWeb) = connectance(foodweb.A)
Expand All @@ -34,7 +34,7 @@ isproducer(i, net::FoodWeb) = isproducer(i, net.A)
isproducer(i, net::MultiplexNetwork) = isproducer(i, net.layers[:trophic].A)

"""
Return indexes of the producers of the given `network`.
Return indices of the producers of the given `network`.
"""
producers(net) = filter(isproducer, net)
producers(A::AbstractMatrix) = (1:richness(A))[all(A .== 0; dims = 2)|>vec]
Expand All @@ -44,9 +44,9 @@ producers(A::AbstractMatrix) = (1:richness(A))[all(A .== 0; dims = 2)|>vec]
"""
predators_of(i, network)

Return indexes of the predators of species `i` for the given `network`.
Return indices of the predators of species `i` for the given `network`.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 0 0; 1 0 0; 1 1 0]);
Expand Down Expand Up @@ -78,7 +78,7 @@ ispredator(i, net::FoodWeb) = ispredator(i, net.A)
ispredator(i, net::MultiplexNetwork) = ispredator(i, net.layers[:trophic].A)

"""
Return indexes of the predators of the given `network`.
Return indices of the predators of the given `network`.
"""
predators(net::EcologicalNetwork) = filter(ispredator, net)
#### end ####
Expand All @@ -87,9 +87,9 @@ predators(net::EcologicalNetwork) = filter(ispredator, net)
"""
preys_of(i, network)

Return indexes of the preys of species `i` for the given `network`.
Return indices of the preys of species `i` for the given `network`.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 0 0; 0 0 0; 1 1 0]);
Expand Down Expand Up @@ -117,7 +117,7 @@ isprey(i, net::FoodWeb) = isprey(i, net.A)
isprey(i, net::MultiplexNetwork) = isprey(i, net.layers[:trophic].A)

"""
Return indexes of the preys of the network (`net`).
Return indices of the preys of the network (`net`).
"""
preys(net::EcologicalNetwork) = filter(isprey, net)
preys(A::AbstractSparseMatrix) = [i for i in 1:size(A, 1) if !isempty(A[:, i].nzval)]
Expand Down Expand Up @@ -269,7 +269,7 @@ trophic_classes() = (:producers, :intermediate_consumers, :top_predators)

Remove a list of species from a `FoodWeb`, a `MultiplexNetwork` or an adjacency matrix.

# Examples
# Examples:

Adjacency matrix.

Expand Down
6 changes: 3 additions & 3 deletions src/measures/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Utility functions for functions in measures

Returns the biomass matrix of species x time over the `last` timesteps.

# Arguments
# Arguments:

- `last`: the number of last timesteps to consider. A percentage can also be also be
provided as a `String` ending by `%`. Defaulted to 1.
Expand All @@ -17,7 +17,7 @@ Returns the biomass matrix of species x time over the `last` timesteps.
See [`richness`](@ref) for the other arguments. If `idxs` is an integer,
it returns a vector of the species biomass instead of a matrix.

# Examples
# Examples:

```jldoctest
julia> fw = FoodWeb([0 0; 1 0]);
Expand Down Expand Up @@ -179,7 +179,7 @@ end

Returns a tuple with species having a biomass above `threshold` at the end of a simulation.

# Examples
# Examples:

```jldoctest
julia> foodweb = FoodWeb([0 0; 0 0]; quiet = true);
Expand Down