Skip to content

Commit b25f218

Browse files
github-actions[bot]CompatHelper Juliastoropolipenelopeysm
authored
CompatHelper: bump compat for Turing to 0.40, (keep existing compat) (#173)
This pull request changes the compat entry for the `Turing` package from `0.20 - 0.39` to `0.20 - 0.39, 0.40`. This keeps the compat entries for earlier versions. Note: I have not tested your package with this new compat entry. It is your responsibility to make sure that your package tests pass before you merge this pull request. --------- Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Jose Storopoli <[email protected]> Co-authored-by: Penelope Yong <[email protected]>
1 parent 948df59 commit b25f218

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

.github/workflows/CI.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,14 @@ jobs:
4949
with:
5050
github-token: ${{ secrets.GITHUB_TOKEN }}
5151
path-to-lcov: lcov.info
52+
parallel: true
53+
54+
finish:
55+
needs: test
56+
if: ${{ always() }}
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Coveralls Finished
60+
uses: coverallsapp/github-action@v2
61+
with:
62+
parallel-finished: true

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ StatsBase = "0.33 - 0.34"
2929
StatsModels = "0.6.28 - 0.7"
3030
TableOperations = "1.2"
3131
Tables = "1.6"
32-
Turing = "0.20 - 0.39"
32+
Turing = "0.20 - 0.40"
3333
julia = "1"

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
66
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
77
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
88
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
9+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
910
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1011
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1112
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ using CategoricalArrays: CategoricalValue
66
using CategoricalArrays: categorical, levels
77
using Statistics: mean, std
88
using TimerOutputs: TimerOutputs, @timeit
9-
using Random: seed!
109

1110
const T = TuringGLM
1211

test/turing_model.jl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using StableRNGs: StableRNG
2+
13
@timed_testset "turing_model" begin
24
DATA_DIR = joinpath("..", "data")
35
kidiq = CSV.read(joinpath(DATA_DIR, "kidiq.csv"), DataFrame)
@@ -8,15 +10,15 @@
810
f = @formula(kid_score ~ mom_iq * mom_hs)
911
@testset "standardize=false" begin
1012
m = turing_model(f, kidiq)
11-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
13+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
1214
@test summarystats(chn)[, :mean] 31.80 atol = 2.0
1315
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.507 atol = 0.2
1416
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] 0.22 atol = 0.2
1517
end
1618

1719
@testset "standardize=true" begin
1820
m = turing_model(f, kidiq; standardize=true)
19-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
21+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
2022
@test summarystats(chn)[, :mean] 0.000 atol = 0.2
2123
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.648 atol = 0.2
2224
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] 0.849 atol = 0.2
@@ -25,14 +27,14 @@
2527
@testset "custom_priors" begin
2628
priors = CustomPrior(Normal(), Normal(28, 5), nothing)
2729
m = turing_model(f, kidiq; priors)
28-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
30+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
2931
@test summarystats(chn)[, :mean] 28.758 atol = 2.0
3032
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.539 atol = 0.2
3133
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] 0.3863 atol = 0.2
3234
end
3335
@testset "explicit calling Normal" begin
3436
m = turing_model(f, kidiq; model=Normal)
35-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
37+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
3638
@test summarystats(chn)[, :mean] 31.80 atol = 2.0
3739
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.507 atol = 0.2
3840
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] 0.22 atol = 0.2
@@ -42,7 +44,7 @@
4244
f = @formula(kid_score ~ mom_iq * mom_hs)
4345
@testset "standardize=false" begin
4446
m = turing_model(f, kidiq; model=TDist)
45-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
47+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
4648
@test summarystats(chn)[, :mean] 33.31 atol = 2.0
4749
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.519 atol = 0.2
4850
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] 0.340 atol = 0.2
@@ -52,7 +54,7 @@
5254
@testset "custom_priors" begin
5355
priors = CustomPrior(Normal(), Normal(28, 5), Exponential(2))
5456
m = turing_model(f, kidiq; model=TDist, priors)
55-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
57+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
5658
@test summarystats(chn)[, :mean] 28.565 atol = 2.0
5759
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.551 atol = 0.2
5860
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] 0.255 atol = 0.2
@@ -63,7 +65,7 @@
6365
f = @formula(switch ~ arsenic + dist + assoc + educ)
6466
@testset "standardize=false" begin
6567
m = turing_model(f, wells; model=Bernoulli)
66-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
68+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
6769
@test summarystats(chn)[, :mean] -0.153 atol = 0.2
6870
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.467 atol = 0.2
6971
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] -0.009 atol = 0.2
@@ -72,7 +74,7 @@
7274
@testset "custom_priors" begin
7375
priors = CustomPrior(Normal(), Normal(), nothing)
7476
m = turing_model(f, wells; model=Bernoulli, priors)
75-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
77+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
7678
@test summarystats(chn)[, :mean] -0.155 atol = 0.2
7779
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.468 atol = 0.2
7880
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] -0.009 atol = 0.2
@@ -82,7 +84,8 @@
8284
f = @formula(y ~ roach1 + treatment + senior + exposure2)
8385
@testset "standardize=false" begin
8486
m = turing_model(f, roaches; model=Poisson)
85-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
87+
# seed of 123 gives bad results
88+
chn = sample(StableRNG(124), m, NUTS(), MCMCThreads(), 2_000, 2)
8689
@test summarystats(chn)[, :mean] 2.969 atol = 0.5
8790
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.006 atol = 0.2
8891
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] -0.5145 atol = 0.2
@@ -91,7 +94,7 @@
9194
@testset "custom_priors" begin
9295
priors = CustomPrior(Normal(2, 5), Normal(), nothing)
9396
m = turing_model(f, roaches; model=Poisson, priors)
94-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
97+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
9598
@test summarystats(chn)[, :mean] 2.963 atol = 0.5
9699
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.006 atol = 0.2
97100
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] -0.5145 atol = 0.2
@@ -101,7 +104,7 @@
101104
f = @formula(y ~ roach1 + treatment + senior + exposure2)
102105
@testset "standardize=false" begin
103106
m = turing_model(f, roaches; model=NegativeBinomial)
104-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
107+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
105108
@test summarystats(chn)[, :mean] 2.448 atol = 0.5
106109
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.013 atol = 0.2
107110
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] -0.734 atol = 0.2
@@ -111,7 +114,7 @@
111114
@testset "custom_priors" begin
112115
priors = CustomPrior(Normal(), Normal(2, 5), Exponential(0.5))
113116
m = turing_model(f, roaches; model=NegativeBinomial, priors)
114-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
117+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
115118
@test summarystats(chn)[, :mean] 2.401 atol = 0.5
116119
@test summarystats(chn)[Symbol("β[1]"), :mean] 0.013 atol = 0.2
117120
@test quantile(chn)[Symbol("β[2]"), Symbol("50.0%")] -0.723 atol = 0.2
@@ -121,7 +124,7 @@
121124
@timed_testset "Hierarchical Model" begin
122125
f = @formula(y ~ (1 | cheese) + background)
123126
m = turing_model(f, cheese)
124-
chn = sample(seed!(123), m, NUTS(), MCMCThreads(), 2_000, 2)
127+
chn = sample(StableRNG(123), m, NUTS(), MCMCThreads(), 2_000, 2)
125128
@test summarystats(chn)[, :mean] 68.07 atol = 2.0
126129
@test summarystats(chn)[Symbol("β[1]"), :mean] 6.60 atol = 0.2
127130
@test summarystats(chn)[Symbol("zⱼ[1]"), :mean] 0.348 atol = 0.2

0 commit comments

Comments
 (0)