-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run extension tests in separate workflow (#317)
* Use correct imports in helpers * Define extension tests * Delete old tests * Remove weakdeps from extras * Define workflow for testing extensions * Run extension tests on older Julia versions * Run MCMCChains tests separately * Create Project for MCMCChains tests * Run ArviZMCMCChainsExt tests * Remove unused test deps * Add missing DimensionalData compats * Don't include helpers if unneeded * Update extension test deps with CompatHelper * Add back weak deps to extras
- Loading branch information
Showing
11 changed files
with
125 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: ExtensionTest | ||
on: | ||
push: | ||
branches: [main] | ||
tags: [v*] | ||
pull_request: | ||
jobs: | ||
test: | ||
name: ${{ matrix.extension }} - Julia ${{ matrix.julia-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
julia-version: [1.6, 1] | ||
extension: | ||
- ArviZMCMCChainsExt | ||
- ArviZSampleChainsExt | ||
- ArviZSampleChainsDynamicHMCExt | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: ${{ matrix.julia-version }} | ||
arch: x64 | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- run: | | ||
julia --code-coverage=user -e ' | ||
using Pkg | ||
test_path = joinpath(pwd(), "test", "ext", "${{ matrix.extension }}") | ||
Pkg.activate(test_path) | ||
Pkg.develop(PackageSpec(path=pwd())) | ||
include(joinpath(test_path, "runtests.jl"))' | ||
- uses: julia-actions/julia-processcoverage@v1 | ||
- uses: codecov/codecov-action@v2 | ||
with: | ||
files: lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[deps] | ||
ArviZ = "131c737c-5715-5e2e-ad31-c244f01c1dc7" | ||
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0" | ||
MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" | ||
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[compat] | ||
ArviZ = "0.10.3" | ||
DimensionalData = "0.24, 0.25" | ||
MCMCChains = "6" | ||
OrderedCollections = "1" | ||
Random = "1.6" | ||
Test = "1.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[deps] | ||
ArviZ = "131c737c-5715-5e2e-ad31-c244f01c1dc7" | ||
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
SampleChains = "754583d1-7fc4-4dab-93b5-5eaca5c9622e" | ||
SampleChainsDynamicHMC = "6d9fd711-e8b2-4778-9c70-c1dfb499d4c4" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[compat] | ||
ArviZ = "0.10.3" | ||
DimensionalData = "0.24, 0.25" | ||
Random = "1.6" | ||
SampleChains = "0.5" | ||
SampleChainsDynamicHMC = "0.3" | ||
Test = "1.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using ArviZ | ||
using SampleChains: SampleChains | ||
using SampleChains.TupleVectors: TupleVectors | ||
using SampleChainsDynamicHMC: SampleChainsDynamicHMC | ||
using SampleChainsDynamicHMC.TransformVariables | ||
using Test | ||
|
||
include("../../helpers.jl") | ||
|
||
function samplechains_dynamichmc_sample(nchains, ndraws) | ||
# μ ~ Normal(0, 1) |> iid(2, 3), σ ~ HalfNormal(0, 1), y[i] ~ Normal(μ[i], σ) | ||
y = [0.74 0.15 -1.08; -0.42 1.08 -0.52] | ||
function ℓ(nt) | ||
μ = nt.μ | ||
σ = nt.σ | ||
return -(sum(abs2, μ) + σ^2 + sum((y .- μ) .^ 2) / σ^2) / 2 - length(y) * log(σ) | ||
end | ||
t = as((μ=as(Array, 2, 3), σ=asℝ₊)) | ||
chain = SampleChains.newchain(nchains, SampleChainsDynamicHMC.dynamichmc(), ℓ, t) | ||
return SampleChains.sample!(chain, ndraws - 1) | ||
end | ||
|
||
@testset "SampleChainsDynamicHMC" begin | ||
expected_stats_vars = ( | ||
:acceptance_rate, :n_steps, :diverging, :energy, :tree_depth, :turning | ||
) | ||
|
||
multichain = samplechains_dynamichmc_sample(4, 10) | ||
idata = convert_to_inference_data(multichain) | ||
@test InferenceObjects.groupnames(idata) === (:posterior, :sample_stats) | ||
@test issubset(expected_stats_vars, keys(idata.sample_stats)) | ||
@test size(idata.posterior.μ) == (10, 4, 2, 3) | ||
@test size(idata.posterior.σ) == (10, 4) | ||
|
||
idata = convert_to_inference_data(multichain; group=:prior) | ||
@test InferenceObjects.groupnames(idata) === (:prior, :sample_stats_prior) | ||
@test issubset(expected_stats_vars, keys(idata.sample_stats_prior)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[deps] | ||
ArviZ = "131c737c-5715-5e2e-ad31-c244f01c1dc7" | ||
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
SampleChains = "754583d1-7fc4-4dab-93b5-5eaca5c9622e" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[compat] | ||
ArviZ = "0.10.3" | ||
DimensionalData = "0.24, 0.25" | ||
Random = "1.6" | ||
SampleChains = "0.5" | ||
Test = "1.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters