Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #153 from PoisotLab/develop
Browse files Browse the repository at this point in the history
Prepare for new release
tpoisot authored Mar 31, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents da8d377 + 00afce8 commit e03b6fc
Showing 15 changed files with 153 additions and 445 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1.3'
- '1.4'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: ./lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV }}
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1.4'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CompatHelper

on:
schedule:
- cron: '00 * * * *'

jobs:
CompatHelper:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.4.0]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name = "EcologicalNetworks"
uuid = "f03a62fe-f8ab-5b77-a061-bb599b765229"
authors = ["Timothée Poisot <timothee.poisot@umontreal.ca>"]
repo = "https://github.com/PoisotLab/EcologicalNetworks.jl"
version = "0.2.2"
version = "0.3.0"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
@@ -16,7 +16,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
julia = "1"
julia = "1.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -39,12 +39,14 @@ That's it. Now head over to the

### On `master`

[![Build Status](https://travis-ci.org/PoisotLab/EcologicalNetworks.jl.svg?branch=master)](https://travis-ci.org/PoisotLab/EcologicalNetworks.jl)
[![Coverage Status](https://coveralls.io/repos/PoisotLab/EcologicalNetworks.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/PoisotLab/EcologicalNetworks.jl?branch=master)
![CI](https://github.com/PoisotLab/EcologicalNetworks.jl/workflows/CI/badge.svg?branch=master)
![CI](https://github.com/PoisotLab/EcologicalNetworks.jl/workflows/TagBot/badge.svg?branch=master)
![CI](https://github.com/PoisotLab/EcologicalNetworks.jl/workflows/CompatHelper/badge.svg?branch=master)
[![codecov.io](http://codecov.io/github/PoisotLab/EcologicalNetworks.jl/coverage.svg?branch=master)](http://codecov.io/github/PoisotLab/EcologicalNetworks.jl?branch=master)

### On `develop`

[![Build Status](https://travis-ci.org/PoisotLab/EcologicalNetworks.jl.svg?branch=develop)](https://travis-ci.org/PoisotLab/EcologicalNetworks.jl)
[![Coverage Status](https://coveralls.io/repos/github/PoisotLab/EcologicalNetworks.jl/badge.svg?branch=develop)](https://coveralls.io/github/PoisotLab/EcologicalNetworks.jl?branch=develop)
![CI](https://github.com/PoisotLab/EcologicalNetworks.jl/workflows/CI/badge.svg?branch=develop)
![CI](https://github.com/PoisotLab/EcologicalNetworks.jl/workflows/TagBot/badge.svg?branch=develop)
![CI](https://github.com/PoisotLab/EcologicalNetworks.jl/workflows/CompatHelper/badge.svg?branch=develop)
[![codecov.io](http://codecov.io/github/PoisotLab/EcologicalNetworks.jl/coverage.svg?branch=develop)](http://codecov.io/github/PoisotLab/EcologicalNetworks.jl?branch=develop)
6 changes: 6 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
Documenter = "0.24"
21 changes: 5 additions & 16 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
using Pkg

tmp_packages = ["EcologicalNetworksPlots", "Plots", "Documenter"]

push!(LOAD_PATH,"../src/")

Pkg.activate(".")

Pkg.add.(tmp_packages) # IMPORTANT

using Documenter
using EcologicalNetworks
using EcologicalNetworksPlots
using Random

makedocs(
sitename = "EcologicalNetworks",
authors = "Timothée Poisot",
modules = [EcologicalNetworks, EcologicalNetworksPlots],
modules = [EcologicalNetworks],
pages = [
"Index" => "index.md",
"Interface" => [
"Types" => "interface/types.md",
"Conversions" => "interface/conversions.md",
"Core functions" => "interface/highlevel.md",
"Plotting" => "var/plots.md"
"Core functions" => "interface/highlevel.md"
],
"Network measures" => [
"Links" => "properties/links.md",
@@ -39,14 +29,13 @@ makedocs(
"Random networks" => [
"Null models" => "random/null.md",
"Structural models" => "random/structure.md"
]
]
]
)

deploydocs(
deps = Deps.pip("pygments", "python-markdown-math"),
repo = "github.com/PoisotLab/EcologicalNetworks.jl.git",
devbranch = "master"
devbranch = "master",
push_preview = true
)

Pkg.rm.(tmp_packages) # IMPORTANT
232 changes: 0 additions & 232 deletions docs/src/assets/documenter.css

This file was deleted.

7 changes: 4 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -52,10 +52,11 @@ speaking a tool for analysis, it is not part of this package.

Second, it helps to keep software dependency small. Most of our work using this
package is done on clusters of one sort of the other, and having fewer
dependencies means that installation is easier.
dependencies means that installation is easier. `EcologicalNetworksPlots` can be
installed like any other Julia package. It is also documented on [its own
website][ENP].

`EcologicalNetworksPlots` can be installed as with any other Julia package. It
is also documented on this website.
[ENP]: https://poisotlab.github.io/EcologicalNetworksPlots.jl/stable/

### And worse, you forgot my favorite method!

8 changes: 5 additions & 3 deletions docs/src/interface/types.md
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ AbstractEcologicalNetwork
```

The type of nodes that are allowed is determined by the *non-exported*
`EcologicalNetworks.is_valid_species` function. To allow an additional type of
`EcologicalNetworks.check_species_validity` function. To allow an additional type of
node, you can write the following:

~~~ julia
@@ -83,11 +83,13 @@ struct Foo
end

import EcologicalNetworks
EcologicalNetworks.is_valid_species(::Type{Foo}) = true
function EcologicalNetworks.check_species_validity(::Type{Foo})
end
~~~

Note that **integers are never valid species identifiers**. By default, `String`
and `Symbol` are used.
and `Symbol` are used. The function `check_species_validity` should do *nothing*
for an accepted type (and it will throw an error for any other type).

### By partiteness

158 changes: 0 additions & 158 deletions docs/src/var/plots.md

This file was deleted.

16 changes: 13 additions & 3 deletions src/EcologicalNetworks.jl
Original file line number Diff line number Diff line change
@@ -38,9 +38,16 @@ include(joinpath(".", "misc/data.jl"))
export web_of_life, nz_stream_foodweb, pajek

function __init__()
@require Mangal="b8b640a6-63d9-51e6-b784-5033db27bef2" is_valid_species(::Mangal.MangalNode) = true
@require Mangal="b8b640a6-63d9-51e6-b784-5033db27bef2" is_valid_species(::Mangal.MangalReferenceTaxon) = true
@require GBIF="ee291a33-5a6c-5552-a3c8-0f29a1181037" is_valid_species(::GBIF.GBIFTaxon) = true
@require Mangal="b8b640a6-63d9-51e6-b784-5033db27bef2" begin
function check_species_validity(::Mangal.MangalReferenceTaxon)
end
function check_species_validity(::Mangal.MangalNode)
end
end
@require GBIF="ee291a33-5a6c-5552-a3c8-0f29a1181037" begin
function check_species_validity(::GBIF.GBIFTaxon)
end
end
end

# General useful manipulations
@@ -147,6 +154,9 @@ export KGL01, KGL02, KGL03, KGL04, KGL05, KGL06, KGL07, KGL08, KGL09, KGL10,
include(joinpath(".", "foodwebs/trophiclevels.jl"))
export fractional_trophic_level, trophic_level

include(joinpath(".", "foodwebs/omnivory.jl"))
export omnivory

include(joinpath(".", "information/entropy.jl"))
export entropy, make_joint_distribution, mutual_information, conditional_entropy,
variation_information, diff_entropy_uniform, information_decomposition,
24 changes: 24 additions & 0 deletions src/foodwebs/omnivory.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function omnivory(N::T) where {T <: UnipartiteNetwork}
OI = Dict([s => 0.0 for s in species(N)])

TL = fractional_trophic_level(N)
k = degree(N; dims=1)

for sp_i in species(N)

# Species with no interaction have an omnivory index of 0
k[sp_i] > 0 || continue

# For every species, we set its initial omnivory to 0
oi = 0.0
for (j, sp_j) in enumerate(species(N))
# Then for every species it consumes, we ha
tl_diff = (TL[sp_j] - (TL[sp_i]-1.0)).^2.0
corr = N[sp_i,sp_j]/k[sp_i]
oi += tl_diff * corr
end
OI[sp_i] = oi
end

return OI
end
12 changes: 6 additions & 6 deletions src/types/constructors.jl
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ function UnipartiteNetwork(A::M) where {M<:AbstractMatrix{Bool}}
end

function UnipartiteNetwork(A::M, S::Vector{NT}) where {M<:AbstractMatrix{Bool}, NT}
is_valid_species(NT) || throw(ArgumentError("Not allowed"))
check_species_validity(NT)
check_unipartiteness(A, S)
UnipartiteNetwork{Bool,NT}(A, S)
end
@@ -18,7 +18,7 @@ function BipartiteNetwork(A::M) where {M<:AbstractMatrix{Bool}}
end

function BipartiteNetwork(A::M, T::Vector{NT}, B::Vector{NT}) where {M<:AbstractMatrix{Bool}, NT}
is_valid_species(NT) || throw(ArgumentError("Not allowed"))
check_species_validity(NT)
check_bipartiteness(A, T, B)
BipartiteNetwork{Bool,eltype(T)}(A, T, B)
end
@@ -32,7 +32,7 @@ function BipartiteProbabilisticNetwork(A::Matrix{IT}) where {IT<:AbstractFloat}
end

function BipartiteProbabilisticNetwork(A::Matrix{IT}, T::Vector{NT}, B::Vector{NT}) where {IT<:AbstractFloat, NT}
is_valid_species(NT) || throw(ArgumentError("Not allowed"))
check_species_validity(NT)
check_bipartiteness(A, T, B)
check_probability_values(A)
BipartiteProbabilisticNetwork{IT,NT}(A, T, B)
@@ -46,7 +46,7 @@ function BipartiteQuantitativeNetwork(A::Matrix{IT}) where {IT <: Number}
end

function BipartiteQuantitativeNetwork(A::Matrix{IT}, T::Vector{NT}, B::Vector{NT}) where {IT<:Number,NT}
is_valid_species(NT) || throw(ArgumentError("Not allowed"))
check_species_validity(NT)
check_bipartiteness(A, T, B)
BipartiteQuantitativeNetwork{IT,NT}(A, T, B)
end
@@ -58,7 +58,7 @@ function UnipartiteQuantitativeNetwork(A::Matrix{IT}) where {IT<:Number}
end

function UnipartiteQuantitativeNetwork(A::Matrix{IT}, S::Vector{NT}) where {IT<:Number,NT}
is_valid_species(NT) || throw(ArgumentError("Not allowed"))
check_species_validity(NT)
check_unipartiteness(A, S)
UnipartiteQuantitativeNetwork{IT,NT}(A, S)
end
@@ -73,7 +73,7 @@ function UnipartiteProbabilisticNetwork(A::Matrix{IT}) where {IT<:AbstractFloat}
end

function UnipartiteProbabilisticNetwork(A::Matrix{IT}, S::Vector{NT}) where {IT<:AbstractFloat,NT}
is_valid_species(NT) || throw(ArgumentError("Not allowed"))
check_species_validity(NT)
check_unipartiteness(A, S)
check_probability_values(A)
UnipartiteProbabilisticNetwork{IT,NT}(A, S)
9 changes: 6 additions & 3 deletions src/types/utilities.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Base: getindex, setindex!, permutedims, permutedims!, size, copy, !, show, +, inv, similar

is_valid_species(::Type{T}) where {T <: Any} = false
function check_species_validity(::Type{T}) where {T <: Any}
throw(ArgumentError("The type $(T) is not an allowed species type"))
end

is_valid_species(::Type{T}) where {T <: Union{Symbol,String}} = true
function check_species_validity(::Type{T}) where {T <: Union{Symbol,String}}
end

"""
show(io::IO, N::AbstractEcologicalNetwork)
@@ -70,7 +73,7 @@ for the presence of an interaction.
Use `N[i,j]` if you need to get the value of the interaction.
"""
function has_interaction(N::AbstractEcologicalNetwork, i::NT, j::NT) where {NT}
@assert is_valid_species(NT)
check_species_validity(NT)
@assert i species(N; dims=1)
@assert j species(N; dims=2)
i_pos = something(findfirst(isequal(i), species(N; dims=1)),0)

2 comments on commit e03b6fc

@tpoisot
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/11855

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.0 -m "<description of version>" e03b6fcda145c9b0426eaaed23a4c88752c10d80
git push origin v0.3.0

Please sign in to comment.