Skip to content

Commit f083af8

Browse files
authored
Fix deprecations and reduce CI tests (#21)
* Fix deprecations * Reduce CI * Fix CI * Update CompatHelper
1 parent 4b7d916 commit f083af8

File tree

5 files changed

+44
-35
lines changed

5 files changed

+44
-35
lines changed

.github/workflows/CI.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,18 @@ jobs:
1919
- 'nightly'
2020
os:
2121
- ubuntu-latest
22-
- macOS-latest
23-
- windows-latest
2422
arch:
25-
- x86
2623
- x64
27-
exclude:
28-
- os: macOS-latest
29-
arch: x86
3024
include:
3125
- version: '1'
3226
os: ubuntu-latest
27+
arch: x86
28+
- version: '1'
29+
os: macOS-latest
30+
arch: x64
31+
- version: '1'
32+
os: windows-latest
3333
arch: x64
34-
coverage: true
3534
steps:
3635
- uses: actions/checkout@v2
3736
- uses: julia-actions/setup-julia@v1
@@ -50,16 +49,18 @@ jobs:
5049
${{ runner.os }}-
5150
- uses: julia-actions/julia-buildpkg@v1
5251
- uses: julia-actions/julia-runtest@v1
52+
with:
53+
coverage: ${{ matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64' }}
5354
env:
5455
JULIA_NUM_THREADS: 2
5556
- uses: julia-actions/julia-processcoverage@v1
56-
if: matrix.coverage
57+
if: matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
5758
- uses: codecov/codecov-action@v1
58-
if: matrix.coverage
59+
if: matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
5960
with:
6061
file: lcov.info
6162
- uses: coverallsapp/github-action@master
62-
if: matrix.coverage
63+
if: matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
6364
with:
6465
github-token: ${{ secrets.GITHUB_TOKEN }}
6566
path-to-lcov: lcov.info

.github/workflows/CompatHelper.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
name: CompatHelper
22
on:
33
schedule:
4-
- cron: '00 00 * * *'
4+
- cron: 0 0 * * *
55
workflow_dispatch:
66
jobs:
77
CompatHelper:
88
runs-on: ubuntu-latest
99
steps:
10-
- name: Pkg.add("CompatHelper")
11-
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
12-
- name: CompatHelper.main()
10+
- name: "Add the General registry via Git"
11+
run: |
12+
import Pkg
13+
ENV["JULIA_PKG_SERVER"] = ""
14+
Pkg.Registry.add("General")
15+
shell: julia --color=yes {0}
16+
- name: "Install CompatHelper"
17+
run: |
18+
import Pkg
19+
name = "CompatHelper"
20+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
21+
version = "3"
22+
Pkg.add(; name, uuid, version)
23+
shell: julia --color=yes {0}
24+
- name: "Run CompatHelper"
25+
run: |
26+
import CompatHelper
27+
CompatHelper.main()
28+
shell: julia --color=yes {0}
1329
env:
1430
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1531
COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
16-
run: julia -e 'using CompatHelper; CompatHelper.main()'

test/regression.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
observations = rand(prior) .+ σ .* randn(N)
2828

2929
# define log likelihood function
30-
(f) =
31-
let observations = observations, σ = σ
32-
logpdf(MvNormal(f, σ), observations)
33-
end
30+
(f) = logpdf(MvNormal(f, σ^2 * I), observations)
3431

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

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

5552
# define log likelihood function
56-
(f) =
57-
let observations = observations, σ = σ
58-
logpdf(MvNormal(f, σ), observations)
59-
end
53+
(f) = logpdf(MvNormal(f, σ^2 * I), observations)
6054

6155
# run elliptical slice sampling for 100 000 time steps
6256
samples = sample(ESSModel(prior, ℓ), ESS(), 100_000; progress=false)

test/runtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ addprocs(2)
1717
@everywhere begin
1818
using EllipticalSliceSampling
1919
using Distributions
20+
21+
using LinearAlgebra
2022
end
2123

2224
@testset "EllipticalSliceSampling" begin
2325
println("Simple tests")
24-
@testset "Simple tests" begin
26+
@time @testset "Simple tests" begin
2527
include("simple.jl")
2628
end
2729

2830
println("GP regression tests")
29-
@testset "GP regression tests" begin
31+
@time @testset "GP regression tests" begin
3032
include("regression.jl")
3133
end
3234
end

test/simple.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
# Load all required packages and define likelihood functions
44
(x) = logpdf(Normal(x, 0.5), 1.0)
5-
ℓvec(x) = logpdf(MvNormal(x, 0.5), [1.0])
5+
ℓvec(x) = logpdf(MvNormal(x, 0.25 * I), [1.0])
66
@everywhere begin
77
(x) = logpdf(Normal(x, 0.5), 1.0)
8-
ℓvec(x) = logpdf(MvNormal(x, 0.5), [1.0])
8+
ℓvec(x) = logpdf(MvNormal(x, 0.25 * I), [1.0])
99
end
1010

1111
@testset "Scalar model" begin
@@ -19,18 +19,15 @@
1919
σ² = 0.2
2020

2121
# regular sampling
22-
model = let prior = prior, ℓ =
23-
ESSModel(prior, ℓ)
24-
end
25-
samples = sample(model, ESS(), 2_000; progress=false)
22+
samples = sample(ESSModel(prior, ℓ), ESS(), 2_000; progress=false)
2623
@test samples isa Vector{Float64}
2724
@test length(samples) == 2_000
2825
@test mean(samples) μ atol = 0.05
2926
@test var(samples) σ² atol = 0.05
3027

3128
# parallel sampling
3229
for alg in (MCMCThreads(), MCMCDistributed(), MCMCSerial())
33-
samples = sample(model, ESS(), alg, 2_000, 5; progress=false)
30+
samples = sample(ESSModel(prior, ℓ), ESS(), alg, 2_000, 5; progress=false)
3431
@test samples isa Vector{Vector{Float64}}
3532
@test length(samples) == 5
3633
@test all(length(x) == 2_000 for x in samples)
@@ -71,7 +68,7 @@
7168
Random.seed!(1)
7269

7370
# model
74-
prior = MvNormal([0.0], 1.0)
71+
prior = MvNormal([0.0], I)
7572

7673
# true posterior
7774
μ = [0.8]
@@ -100,7 +97,7 @@
10097
Random.seed!(1)
10198

10299
# model
103-
prior = MvNormal([0.5], 1.0)
100+
prior = MvNormal([0.5], I)
104101

105102
# true posterior
106103
μ = [0.9]

0 commit comments

Comments
 (0)