Skip to content

Commit 1a78cf7

Browse files
authored
Update to 2.37 (#64)
* Updates for Pathfinder changes * Update cache version * Actually bump submodule
1 parent 50d0b1a commit 1a78cf7

File tree

14 files changed

+76
-36
lines changed

14 files changed

+76
-36
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch: {}
99

1010
env:
11-
CACHE_VERSION: 2
11+
CACHE_VERSION: 3
1212

1313
# only run one copy per PR
1414
concurrency:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ print-% : ; @echo $* = $($*) ;
160160
STANC_DL_RETRY = 5
161161
STANC_DL_DELAY = 10
162162
STANC3_TEST_BIN_URL ?=
163-
STANC3_VERSION ?= v2.36.0
163+
STANC3_VERSION ?= v2.37.0
164164

165165
ifeq ($(OS),Windows_NT)
166166
OS_TAG := windows

clients/R/R/zzz.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
HMC_SAMPLER_VARIABLES = c("lp__", "accept_stat__", "stepsize__", "treedepth__", "n_leapfrog__",
22
"divergent__", "energy__")
33

4-
PATHFINDER_VARIABLES = c("lp_approx__", "lp__")
4+
PATHFINDER_VARIABLES = c("lp_approx__", "lp__", "path__")
55

66
OPTIMIZATION_VARIABLES = c("lp__")
77

clients/R/tests/testthat/test_pathfinder.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ test_that("seed works", {
5050
out1 <- pathfinder(bernoulli_model, BERNOULLI_DATA, seed = 123)
5151
out2 <- pathfinder(bernoulli_model, BERNOULLI_DATA, seed = 123)
5252

53-
expect_equal(out1$draws$theta, out2$draws$theta)
53+
expect_equal(sort(posterior::draws_of(out1$draws$theta)), sort(posterior::draws_of(out2$draws$theta)))
5454

5555
out3 <- pathfinder(bernoulli_model, BERNOULLI_DATA, seed = 456)
56-
expect_error(expect_equal(out1$draws$theta, out3$draws$theta))
56+
expect_error(expect_equal(sort(posterior::draws_of(out1$draws$theta)), sort(posterior::draws_of(out3$draws$theta))))
5757

5858
})
5959
test_that("inits work", {

clients/julia/src/model.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const HMC_SAMPLER_VARIABLES = [
3232
"energy__",
3333
]
3434

35-
const PATHFINDER_VARIABLES = ["lp_approx__", "lp__"]
35+
const PATHFINDER_VARIABLES = ["lp_approx__", "lp__", "path__"]
3636

3737
const OPTIMIZE_VARIABLES = ["lp__"]
3838

clients/julia/test/test_pathfinder.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979
@testset "Seed" begin
8080
out1 = pathfinder(bernoulli_model, BERNOULLI_DATA; seed = UInt32(123))
8181
out2 = pathfinder(bernoulli_model, BERNOULLI_DATA; seed = UInt32(123))
82-
@test out1.draws == out2.draws
82+
@test sortslices(out1.draws, dims=1) == sortslices(out2.draws, dims=1)
8383

8484
out3 = pathfinder(bernoulli_model, BERNOULLI_DATA; seed = UInt32(456))
85-
@test out1.draws != out3.draws
85+
@test sortslices(out1.draws, dims=1) != sortslices(out3.draws, dims=1)
8686
end
8787

8888
@testset "Inits" begin

clients/python/tests/test_laplace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_seed(bernoulli_model):
7777
seed=123,
7878
)
7979

80-
np.testing.assert_equal(out1["theta"], out2["theta"])
80+
np.testing.assert_equal(out1.data, out2.data)
8181

8282
out3 = bernoulli_model.laplace_sample(
8383
BERNOULLI_MODE,
@@ -114,7 +114,7 @@ def test_bad_mode_stanoutput(bernoulli_model):
114114

115115

116116
def test_bad_mode_array(bernoulli_model):
117-
mode1 = np.array([2.0])
117+
mode1 = np.array([2.0, 1.0])
118118
with pytest.raises(RuntimeError, match="Bounded variable is 2"):
119119
bernoulli_model.laplace_sample(mode1, BERNOULLI_DATA)
120120

clients/python/tests/test_optimize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_seed(bernoulli_model):
5656
seed=123,
5757
)
5858

59-
np.testing.assert_equal(out1["theta"], out2["theta"])
59+
np.testing.assert_equal(out1.data, out2.data)
6060

6161
out3 = bernoulli_model.optimize(
6262
BERNOULLI_DATA,

clients/python/tests/test_pathfinder.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,33 @@ def test_data(bernoulli_model):
2525
assert 0.2 < out2["theta"].mean() < 0.3
2626

2727

28-
def test_seed(bernoulli_model):
29-
out1 = bernoulli_model.pathfinder(BERNOULLI_DATA, seed=123)
30-
out2 = bernoulli_model.pathfinder(BERNOULLI_DATA, seed=123)
31-
32-
np.testing.assert_equal(out1["theta"], out2["theta"])
28+
@pytest.mark.parametrize("num_paths", [1, 4])
29+
@pytest.mark.parametrize("psis_resample", [True, False])
30+
def test_seed(bernoulli_model, num_paths, psis_resample):
31+
out1 = bernoulli_model.pathfinder(
32+
BERNOULLI_DATA,
33+
seed=123,
34+
num_paths=num_paths,
35+
psis_resample=psis_resample,
36+
)
37+
out2 = bernoulli_model.pathfinder(
38+
BERNOULLI_DATA,
39+
seed=123,
40+
num_paths=num_paths,
41+
psis_resample=psis_resample,
42+
)
43+
assert out1.data.shape[1] == 5
44+
np.testing.assert_equal(np.sort(out1.data, axis=0), np.sort(out2.data, axis=0))
3345

34-
out3 = bernoulli_model.pathfinder(BERNOULLI_DATA, seed=456)
46+
out3 = bernoulli_model.pathfinder(
47+
BERNOULLI_DATA,
48+
seed=456,
49+
num_paths=num_paths,
50+
psis_resample=psis_resample,
51+
)
3552

3653
with pytest.raises(AssertionError):
37-
np.testing.assert_equal(out1["theta"], out3["theta"])
54+
np.testing.assert_equal(np.sort(out1["theta"]), np.sort(out3["theta"]))
3855

3956

4057
def test_output_sizes(bernoulli_model):
@@ -133,20 +150,18 @@ def test_inits(multimodal_model, temp_json):
133150
assert np.all(out3["mu"] < 0)
134151

135152

136-
def test_inits_mode(multimodal_model):
153+
@pytest.mark.parametrize("num_paths", [1, 4])
154+
@pytest.mark.parametrize("psis_resample", [True, False])
155+
def test_inits_mode(multimodal_model, num_paths, psis_resample):
137156
# initializing at mode means theres nowhere to go
138157
init1 = {"mu": -100}
139158

140159
with pytest.raises(
141160
RuntimeError, match="None of the LBFGS iterations completed successfully"
142161
):
143-
multimodal_model.pathfinder(inits=init1)
144-
145-
# also for single path
146-
with pytest.raises(
147-
RuntimeError, match="None of the LBFGS iterations completed successfully"
148-
):
149-
multimodal_model.pathfinder(inits=init1, num_paths=1, psis_resample=False)
162+
multimodal_model.pathfinder(
163+
inits=init1, num_paths=num_paths, psis_resample=psis_resample
164+
)
150165

151166

152167
def test_bad_data(bernoulli_model):

clients/python/tests/test_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_seed(bernoulli_model):
4646
BERNOULLI_DATA, seed=123, num_warmup=100, num_samples=100
4747
)
4848

49-
np.testing.assert_equal(out1["theta"], out2["theta"])
49+
np.testing.assert_equal(out1.data, out2.data)
5050

5151
out3 = bernoulli_model.sample(
5252
BERNOULLI_DATA, seed=456, num_warmup=100, num_samples=100

0 commit comments

Comments
 (0)