Skip to content

Commit

Permalink
Fix deprecations and reduce CI tests (#21)
Browse files Browse the repository at this point in the history
* Fix deprecations

* Reduce CI

* Fix CI

* Update CompatHelper
  • Loading branch information
devmotion authored Aug 27, 2021
1 parent 4b7d916 commit f083af8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ jobs:
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x86
- x64
exclude:
- os: macOS-latest
arch: x86
include:
- version: '1'
os: ubuntu-latest
arch: x86
- version: '1'
os: macOS-latest
arch: x64
- version: '1'
os: windows-latest
arch: x64
coverage: true
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand All @@ -50,16 +49,18 @@ jobs:
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
coverage: ${{ matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64' }}
env:
JULIA_NUM_THREADS: 2
- uses: julia-actions/julia-processcoverage@v1
if: matrix.coverage
if: matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
- uses: codecov/codecov-action@v1
if: matrix.coverage
if: matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
with:
file: lcov.info
- uses: coverallsapp/github-action@master
if: matrix.coverage
if: matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: lcov.info
25 changes: 20 additions & 5 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
name: CompatHelper
on:
schedule:
- cron: '00 00 * * *'
- cron: 0 0 * * *
workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
12 changes: 3 additions & 9 deletions test/regression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
observations = rand(prior) .+ σ .* randn(N)

# define log likelihood function
(f) =
let observations = observations, σ = σ
logpdf(MvNormal(f, σ), observations)
end
(f) = logpdf(MvNormal(f, σ^2 * I), observations)

# run elliptical slice sampler for 100 000 time steps
samples = sample(ESSModel(prior, ℓ), ESS(), 100_000; progress=false)
Expand All @@ -47,16 +44,13 @@
# extreme case with independent observations
@testset "Independent components" begin
# define distribution of latent variables
prior = MvNormal(N, 1)
prior = MvNormal(Zeros(N), I)

# sample noisy observations
observations = rand(prior) .+ σ .* randn(N)

# define log likelihood function
(f) =
let observations = observations, σ = σ
logpdf(MvNormal(f, σ), observations)
end
(f) = logpdf(MvNormal(f, σ^2 * I), observations)

# run elliptical slice sampling for 100 000 time steps
samples = sample(ESSModel(prior, ℓ), ESS(), 100_000; progress=false)
Expand Down
6 changes: 4 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ addprocs(2)
@everywhere begin
using EllipticalSliceSampling
using Distributions

using LinearAlgebra
end

@testset "EllipticalSliceSampling" begin
println("Simple tests")
@testset "Simple tests" begin
@time @testset "Simple tests" begin
include("simple.jl")
end

println("GP regression tests")
@testset "GP regression tests" begin
@time @testset "GP regression tests" begin
include("regression.jl")
end
end
15 changes: 6 additions & 9 deletions test/simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

# Load all required packages and define likelihood functions
(x) = logpdf(Normal(x, 0.5), 1.0)
ℓvec(x) = logpdf(MvNormal(x, 0.5), [1.0])
ℓvec(x) = logpdf(MvNormal(x, 0.25 * I), [1.0])
@everywhere begin
(x) = logpdf(Normal(x, 0.5), 1.0)
ℓvec(x) = logpdf(MvNormal(x, 0.5), [1.0])
ℓvec(x) = logpdf(MvNormal(x, 0.25 * I), [1.0])
end

@testset "Scalar model" begin
Expand All @@ -19,18 +19,15 @@
σ² = 0.2

# regular sampling
model = let prior = prior, ℓ =
ESSModel(prior, ℓ)
end
samples = sample(model, ESS(), 2_000; progress=false)
samples = sample(ESSModel(prior, ℓ), ESS(), 2_000; progress=false)
@test samples isa Vector{Float64}
@test length(samples) == 2_000
@test mean(samples) μ atol = 0.05
@test var(samples) σ² atol = 0.05

# parallel sampling
for alg in (MCMCThreads(), MCMCDistributed(), MCMCSerial())
samples = sample(model, ESS(), alg, 2_000, 5; progress=false)
samples = sample(ESSModel(prior, ℓ), ESS(), alg, 2_000, 5; progress=false)
@test samples isa Vector{Vector{Float64}}
@test length(samples) == 5
@test all(length(x) == 2_000 for x in samples)
Expand Down Expand Up @@ -71,7 +68,7 @@
Random.seed!(1)

# model
prior = MvNormal([0.0], 1.0)
prior = MvNormal([0.0], I)

# true posterior
μ = [0.8]
Expand Down Expand Up @@ -100,7 +97,7 @@
Random.seed!(1)

# model
prior = MvNormal([0.5], 1.0)
prior = MvNormal([0.5], I)

# true posterior
μ = [0.9]
Expand Down

0 comments on commit f083af8

Please sign in to comment.