Skip to content

Commit

Permalink
Cleanup tests and doc generation..
Browse files Browse the repository at this point in the history
- Code chunks in `docs/` no longer fail silently: `@repl` → `@example`.

- Code chunks in `docs/` expected to fail are now `jldoctest` blocs.
  - This introduces code setup duplication until some limitation is lifted?
    JuliaDocs/Documenter.jl#452

- Fix broken DOI url.

- Docstring for helper macros are now plain comments for they are not in doc.
  • Loading branch information
iago-lito committed Mar 12, 2024
1 parent 06e27a4 commit c0ab8b0
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 82 deletions.
4 changes: 2 additions & 2 deletions docs/src/example/paradox_enrichment.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and check that our simulations fit with analytical predictions.

We consider a 2-species system with one resource (``R``) and one consumer (``C``).

```@repl befwm2
```@example befwm2
foodweb = FoodWeb([0 0; 1 0]); # 2 eats 1
```

Expand All @@ -29,7 +29,7 @@ Here we choose the [`ClassicResponse`](@ref)
with a handling time (`hₜ`), an attack rate (`aᵣ`), and a hill exponent (`h`) equal to one
to simplify analytical derivations.

```@repl befwm2
```@example befwm2
response = ClassicResponse(foodweb, aᵣ=1, hₜ=1, h=1);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ but can also be easily customized if wanted.
Simulations of biomass dynamics in community food webs
- [Miele et al., 2019, PLOS](https://doi.org/10.1371/journal.pcbi.1007269) -
Effect of non-trophic interactions on diversity-productivity relationship
- [Kefi et al. 2018, Ecology Letters]( https://doi.org/10.1111/j.1461-0248.2011.01732.x) -
- [Kefi et al. 2018, Ecology Letters](https://doi.org/10.1111/j.1461-0248.2011.01732.x) -
More than a meal... integrating non-feeding interactions into food webs

!!! note "Todo"
Expand Down
20 changes: 10 additions & 10 deletions docs/src/man/foodwebs.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,40 @@ that will return you the corresponding `FoodWeb` object.
using BEFWM2
```

```@repl befwm2
```@example befwm2
A = [0 0 0; 1 0 0; 0 1 0] # 1 producer ⋅ 2 eats 1 ⋅ 3 eats 2
foodweb = FoodWeb(A)
```

We can check that adjacency matrix stored in `foodweb` corresponds to the one we provided.

```@repl befwm2
```@example befwm2
foodweb.A
```

As we did not use a method (e.g. the `nichemodel`) to create the foodweb,
the method is said to be `unspecified`.

```@repl befwm2
```@example befwm2
foodweb.method
```

Moreover, by default:
- the consumers are assumed to be inverterbrates

```@repl befwm2
```@example befwm2
foodweb.metabolic_class
```

- all body-mass are set to 1

```@repl befwm2
```@example befwm2
foodweb.M
```

- the `species` vector stores only species indexes as no identities were provided.

```@repl befwm2
```@example befwm2
foodweb.species
```

Expand All @@ -76,7 +76,7 @@ it is more suited to create the foodweb using structural models.
implements various structural models to build foodwebs.
You can pass any of those models, with the adequate arguments, to generate foodwebs.

```@repl befwm2
```@example befwm2
using EcologicalNetworks
S = 20; # number of species
C = 0.2; # connectance
Expand All @@ -100,7 +100,7 @@ so you can directly give a `UnipartiteNetwork` object to the [`FoodWeb`](@ref) m
This function is not yet able to attribute metabolic classes or a mass to species,
it just pass the adjacency matrix.

```@repl befwm2
```@example befwm2
unipartite_network = EcologicalNetworks.nz_stream_foodweb()[1] # load network
foodweb = FoodWeb(unipartite_network, method="NZ stream")
```
Expand All @@ -110,7 +110,7 @@ foodweb = FoodWeb(unipartite_network, method="NZ stream")
By default all species mass are set to 1.
However, you cange that either by giving your own body-mass vector (`M`).

```@repl befwm2
```@example befwm2
A = [0 0 0; 1 0 0; 0 1 0]; # define adjacency matrix
M = rand(3) # body-mass are drawn randomly in [0,1]
foodweb = FoodWeb(A, M=M)
Expand All @@ -121,7 +121,7 @@ Or by using a consumer-resource mass ratio `Z`,
then mass will be computed using species trophic levels (``t_l``)
such that: ``M = Z^{t_l - 1}``.

```@repl befwm2
```@example befwm2
A = [0 0 0; 1 0 0; 0 1 0]; # trophic levels are respectively 1, 2 and 3
foodweb = FoodWeb(A, Z=10)
foodweb.M
Expand Down
18 changes: 9 additions & 9 deletions docs/src/man/functionalresponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The linear response and its parameters
can be accessed by calling the [`LinearResponse`](@ref) method
with the [`FoodWeb`](@ref) as a mandatory argument.

```@repl befwm2
```@example befwm2
foodweb = FoodWeb([0 0 0; 1 0 0; 0 1 0]); # 1 producer ⋅ 2 eats 1 ⋅ 3 eats 2
f = LinearResponse(foodweb);
f.ω # preferency
Expand All @@ -51,7 +51,7 @@ f.α # consumption rate
Above parameters take default values, but you can specify custom values.
For instance if you want to double the attack rate of predator 3, you can do:

```@repl befwm2
```@example befwm2
f = LinearResponse(foodweb, α=[0.0,1.0,2.0]);
f.α # custom attack rates
```
Expand All @@ -62,7 +62,7 @@ corresponding to the linear functional response.
To do so, you just need to provide the species biomass vector (`B`),
where `B[i]` is the biomass of species ``i``.

```@repl befwm2
```@example befwm2
f = LinearResponse(foodweb);
B = [1, 1, 1]; # defining species biomass
f(B) # F matrix, F[i,j] = Fᵢⱼ
Expand Down Expand Up @@ -118,7 +118,7 @@ The bioenergetic response and its parameters
can be accessed by calling the [`BioenergeticResponse`](@ref) method
with the [`FoodWeb`](@ref) as a mandatory argument.

```@repl befwm2
```@example befwm2
foodweb = FoodWeb([0 0 0; 1 0 0; 0 1 0]); # 1 producer ⋅ 2 eats 1 ⋅ 3 eats 2
f = BioenergeticResponse(foodweb);
f.ω # preferency
Expand All @@ -130,7 +130,7 @@ f.h # hill exponent
Above parameters take default values, but you can specify custom values.
For instance if you want to set the hill exponent (`h`) to 1 instead of 2, you can do:

```@repl befwm2
```@example befwm2
f = BioenergeticResponse(foodweb, h=1);
f.h # custom hill exponent
```
Expand All @@ -141,7 +141,7 @@ corresponding to the bioenergetic functional response.
To do so, you just need to provide the species biomass vector (`B`),
where `B[i]` is the biomass of species ``i``.

```@repl befwm2
```@example befwm2
f = BioenergeticResponse(foodweb);
B = [1, 1, 1]; # defining species biomass
f(B) # F matrix, F[i,j] = Fᵢⱼ
Expand Down Expand Up @@ -192,7 +192,7 @@ The classic response and its parameters
can be accessed by calling the [`ClassicResponse`](@ref) method
with the [`FoodWeb`](@ref) as a mandatory argument.

```@repl befwm2
```@example befwm2
foodweb = FoodWeb([0 0 0; 1 0 0; 0 1 0]); # 1 producer ⋅ 2 eats 1 ⋅ 3 eats 2
f = ClassicResponse(foodweb);
f.ω # preferency
Expand All @@ -205,7 +205,7 @@ f.hₜ # handling time
Above parameters take default values, but you can specify custom values.
For instance if you want to set the handling time (`h`) to 0.1 instead of 1, you can do:

```@repl befwm2
```@example befwm2
f = ClassicResponse(foodweb, hₜ=0.1);
f.hₜ # custom handling time
```
Expand All @@ -216,7 +216,7 @@ corresponding to the classic functional response.
To do so, you just need to provide the species biomass vector (`B`),
where `B[i]` is the biomass of species ``i``.

```@repl befwm2
```@example befwm2
f = ClassicResponse(foodweb);
B = [1, 1, 1]; # defining species biomass
f(B) # F matrix, F[i,j] = Fᵢⱼ
Expand Down
32 changes: 16 additions & 16 deletions docs/src/man/modelparameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ By default, the model parameters can be simply generated by providing only the f
using BEFWM2
```

```@repl befwm2
```@example befwm2
foodweb = FoodWeb([0 0 0; 1 0 0; 0 1 0]);
params = ModelParameters(foodweb)
```
Expand All @@ -34,7 +34,7 @@ We explain how to do so for each of the 3 containers in the following sections.
[`BioRates`](@ref) contains the species metabolic demand (`x`)
and the species intrinsic growth rates (`r`).

```@repl befwm2
```@example befwm2
foodweb = FoodWeb([0 0 0; 1 0 0; 0 1 0], Z=10);
biorates = BioRates(foodweb)
biorates.x # metabolic demand
Expand All @@ -43,7 +43,7 @@ biorates.r # intrinsic growth rate

If you want to change the default rate values you can specify your own rate vector.

```@repl befwm2
```@example befwm2
x_custom = [1,2,3];
r_custom = [4,5,6];
biorates = BioRates(foodweb, x=x_custom, r=r_custom);
Expand All @@ -55,7 +55,7 @@ In case you want to attribute the same rate value for every species,
instead of giving a vector filled with a constant,
you can directly pass the constant.

```@repl befwm2
```@example befwm2
biorates = BioRates(foodweb, x=1, r=2);
biorates.x
biorates.r
Expand All @@ -75,14 +75,14 @@ are stored in [`AllometricParams`](@ref) objects.
You can access allometric parameters values taken from literature
for the intrinsic growth rate and the metabolic demand.

```@repl befwm2
```@example befwm2
DefaultGrowthParams() # default a, b for intrinsic growth rate
DefaultMetabolismParams() # default a, b for intrinsic metabolic demand
```

But you can also define your own allometric parameters.

```@repl befwm2
```@example befwm2
my_allometric_params = AllometricParams(1,2,3,4,5,6)
```

Expand All @@ -92,7 +92,7 @@ which will compute the vector of the species rates:
!!! note
The foodweb is provided to get the species trophic levels.

```@repl befwm2
```@example befwm2
foodweb = FoodWeb([0 0 0; 1 0 0; 0 1 0], Z=10)
rate = allometric_rate(foodweb, my_allometric_params) # 1 value per species
```
Expand All @@ -113,7 +113,7 @@ rate = allometric_rate(foodweb, my_allometric_params) # 1 value per species
Then the `rate` vector computed with your custom allometric parameters
can be given to [`BioRates`](@ref) as seen previously.

```@repl befwm2
```@example befwm2
biorates = BioRates(foodweb, x=rate) # custom metabolic demand
```

Expand All @@ -125,7 +125,7 @@ As for the biological rates,
environmental variables can be generated by only providing the foodweb,
in which case the parameters take default values.

```@repl befwm2
```@example befwm2
foodweb = FoodWeb([0 0 0; 0 0 0; 0 1 0], Z=10)
environment = Environment(foodweb)
```
Expand All @@ -134,13 +134,13 @@ By default carrying capacities (K) are set to 1 for producers and 0 for consumer
as their growth term is assumed to be null.


```@repl befwm2
```@example befwm2
environment.K
```

And the temperature is set to 293.15 K.

```@repl befwm2
```@example befwm2
environment.K
```

Expand All @@ -149,7 +149,7 @@ by providing custom values to the [`Environment`](@ref) method.
For the temperature
you just have to provide the scalar corresponding the the wanted temperature.

```@repl befwm2
```@example befwm2
environment = Environment(foodweb, T=273.15);
environment.T
```
Expand All @@ -159,7 +159,7 @@ And to change the carrying capacities you can either provide:
- a scalar if you want to set all the producer carrying capacities to the
same value

```@repl befwm2
```@example befwm2
environment = Environment(foodweb, K=[1,2,0]); # using a vector
environment.K
Expand All @@ -173,22 +173,22 @@ You can choose between 3 functional responses:
[Linear response](@ref), [Bioenergetic response](@ref) and [Classic response](@ref).
By default the [Bioenergetic response](@ref) response is selected.

```@repl befwm2
```@example befwm2
params = ModelParameters(foodweb);
params.functional_response
```

However, if you want you can choose another functional response by giving it as an argument.
For the classic response, do:

```@repl befwm2
```@example befwm2
classic_response = ClassicResponse(foodweb); # define your response
params = ModelParameters(foodweb, functional_response = classic_response);
params.functional_response
```

And for the linear response, do:
```@repl befwm2
```@example befwm2
linear_response = LinearResponse(foodweb); # define your response
params = ModelParameters(foodweb, functional_response = linear_response);
params.functional_response
Expand Down
Loading

0 comments on commit c0ab8b0

Please sign in to comment.