Introduction à EcologicalNetworks

"$VERSION"
0.7s
import Pkg
0.2s
Pkg.activate(".")
0.7s
Pkg.add("EcologicalNetworks")
83.7s
using EcologicalNetworks
29.5s
N = nz_stream_foodweb()[1]
2.9s
typeof(N)
0.6s
richness(N)
0.2s
links(N)
0.2s
fieldnames(typeof(N))
1.5s
typeof(N.A)
0.2s
species(N)
0.3s
interactions(N)
1.2s
Ns = nz_stream_foodweb()
#=
Long commentaire
=#
1.2s
# façon 1: boucle
Ns_richness = zeros(Int64, length(Ns))
for i in 1:length(Ns)
  Ns_richness[i] = richness(Ns[i])
end
Ns_richness
0.2s
# façon 2: meilleure boucle
for i in eachindex(Ns)
  Ns_richness[i] = richness(Ns[i])
end
0.2s
# façon 3: aussi bonne boucle
for (i,N) in enumerate(Ns)
  Ns_richness[i] = richness(N)
end
0.2s
# façon 4: boucle compacte 
Ns_richness = [richness(N) for N in Ns]
0.2s
# façon 5: broadcast
sp_richness = richness.(Ns)
0.3s
# façon 6: map
sp_richness = map(richness, Ns)
0.2s
# façon 7: macro (bof)
@. sp_richness = richness(Ns)
0.2s
nb_of_species = richness.(Ns)
nb_of_links = links.(Ns)
0.3s
using Plots
111.5s
scatter(nb_of_species, nb_of_links)
xaxis!("Nb of species")
yaxis!("Nb of links")
3.4s
Runtimes (1)