Skip to content

Commit

Permalink
Minor quickfixes to avoid another review round :)
Browse files Browse the repository at this point in the history
  • Loading branch information
iago-lito committed Feb 23, 2023
1 parent bdbfb4e commit 7049168
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/inputs/foodwebs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ Generating FoodWeb objects
const AdjacencyMatrix = SparseMatrixCSC{Bool,Int64}
const Label = Union{String,Symbol}

const disconnected_warning = "'A' contains disconnected species \
w.r.t. trophic interactions."

#### Type definition and FoodWeb functions ####
abstract type EcologicalNetwork end
mutable struct FoodWeb <: EcologicalNetwork
Expand Down Expand Up @@ -121,7 +118,7 @@ These behaviours can respectively be changed by setting the keyword arguments
`check_cycle` and `check_disconnected` to `true` or `false`.
By default, we set a tolerance corresponding to 10% of the number of links
given in argument (`L`), or 10% of the connectance if you give a connectane (`C`).
given in argument (`L`), or 10% of the connectance if you give a connectance (`C`).
For instance, if you create a `FoodWeb` with 20 links,
by default we ensure that `FoodWeb` in output will contain between 18 and 22 links.
Expand All @@ -146,7 +143,7 @@ true
`FoodWeb`s are generated randomly and can be rejected if they do not satisfy
one of the properties defined above (number of links not in the tolerance range,
cycles, etc.).
Thus we repeat the generation of the `FoodWeb` until of all criterion are satisfied
Thus we repeat the generation of the `FoodWeb` until all criteria are satisfied
or until the number of maximum iteraction `iter_max` is reached.
If the maximum number of iterations is reached an error is thrown.
That number can be controlled by the `iter_max` keyword argument,
Expand Down Expand Up @@ -269,6 +266,9 @@ function FoodWeb(
FoodWeb(A, species, M, metabolic_class, method)
end

const disconnected_warning = "'A' contains disconnected species \
w.r.t. trophic interactions."

function structural_foodweb_data(uni_net, M, Z, model)
A = uni_net.edges
species = uni_net.S
Expand Down Expand Up @@ -470,8 +470,8 @@ function model_foodweb_from_C(
iter <= iter_max ||
throw(ErrorException("Could not generate adequate network with C=$C \
and tol_C=$ΔC before the maximum number of iterations ($iter_max) was reached. \
Consider either increasing the `tol`erance on the connectance \
or, if `check_cycle = true` to lower the connectance."))
Consider either increasing the tolerance on the connectance \
or, if `check_cycle = true`, to lower the connectance."))
net
end

Expand Down Expand Up @@ -501,7 +501,7 @@ function model_foodweb_from_L(
iter <= iter_max ||
throw(ErrorException("Could not generate adequate network with L=$L \
and tol_L=$ΔL before the maximum number of iterations ($iter_max) was reached. \
Consider either increasing the `tol`erance on the number of links \
Consider either increasing the tolerance on the number of links \
or, if `check_cycle = true` to lower the connectance."))
net
end
Expand Down
8 changes: 4 additions & 4 deletions test/inputs/test-foodwebs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ end
end
end

# Can not provide both number of links (L) and connectance.
# Cannot provide both number of links (L) and connectance.
@test_throws ArgumentError FoodWeb(nichemodel, 10, C = 0.1, L = 10)

# Can not provide both tolerance on number of links (tol_L) and connectance (tol_C).
# Cannot provide both tolerance on number of links (tol_L) and connectance (tol_C).
@test_throws ArgumentError FoodWeb(nichemodel, 10, C = 0.1, tol_L = 1, tol_C = 0.01)
@test_throws ArgumentError FoodWeb(nichemodel, 10, L = 10, tol_L = 1, tol_C = 0.01)

# Can not provide a number of links and a tolerance on the connectance.
# Cannot provide a number of links and a tolerance on the connectance.
@test_throws ArgumentError FoodWeb(nichemodel, 10, L = 10, tol_C = 0.01)

# Can not provide a connectance and a tolerance on the number of links.
# Cannot provide a connectance and a tolerance on the number of links.
@test_throws ArgumentError FoodWeb(nichemodel, 10, C = 0.1, tol_L = 1)
end

Expand Down

0 comments on commit 7049168

Please sign in to comment.