Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit 31e55d3

Browse files
committed
Fix schedule length for small number of adaptation steps
1 parent 28444e7 commit 31e55d3

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

aehmc/window_adaptation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def build_schedule(
252252

253253
# Give up on mass matrix adaptation when the number of warmup steps is too small.
254254
if num_steps < 20:
255-
schedule += [(0, False)] * (num_steps - 1)
255+
schedule += [(0, False)] * num_steps
256256
else:
257257
# When the number of warmup steps is smaller that the sum of the provided (or default)
258258
# window sizes we need to resize the different windows.

tests/test_adaptation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@pytest.mark.parametrize(
77
"num_steps, expected_schedule",
88
[
9-
(19, [(0, False)] * 18), # no mass matrix adaptation
9+
(19, [(0, False)] * 19), # no mass matrix adaptation
1010
(
1111
100,
1212
[(0, False)] * 15 + [(1, False)] * 74 + [(1, True)] + [(0, False)] * 10,
@@ -24,4 +24,5 @@
2424
)
2525
def test_adaptation_schedule(num_steps, expected_schedule):
2626
adaptation_schedule = window_adaptation.build_schedule(num_steps)
27+
assert num_steps == len(adaptation_schedule)
2728
assert adaptation_schedule == expected_schedule

0 commit comments

Comments
 (0)