Skip to content

Commit

Permalink
Test compatibility with 2.35
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Dec 2, 2024
1 parent f5cd77d commit 266828c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
name: tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
Expand Down
18 changes: 14 additions & 4 deletions test/test_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,19 +646,29 @@ def test_sample_no_params() -> None:
stan = os.path.join(DATAFILES_PATH, 'datagen_poisson_glm.stan')
datagen_model = CmdStanModel(stan_file=stan)
datagen_fit = datagen_model.sample(iter_sampling=100, show_progress=False)
assert np.isnan(datagen_fit.step_size).all()
summary = datagen_fit.summary()
assert 'lp__' in list(summary.index)

if cmdstan_version_before(2, 36):
assert 'lp__' not in list(summary.index)
assert datagen_fit.step_size is None
else:
assert 'lp__' in list(summary.index)
assert np.isnan(datagen_fit.step_size).all()

exe_only = os.path.join(DATAFILES_PATH, 'exe_only')
shutil.copyfile(datagen_model.exe_file, exe_only)
os.chmod(exe_only, 0o755)
datagen2_model = CmdStanModel(exe_file=exe_only)
datagen2_fit = datagen2_model.sample(iter_sampling=200, show_console=True)
assert datagen2_fit.chains == 4
assert np.isnan(datagen2_fit.step_size).all()
summary = datagen2_fit.summary()
assert 'lp__' in list(summary.index)

if cmdstan_version_before(2, 36):
assert datagen2_fit.step_size is None
assert 'lp__' not in list(summary.index)
else:
assert np.isnan(datagen2_fit.step_size).all()
assert 'lp__' in list(summary.index)


def test_index_bounds_error() -> None:
Expand Down

0 comments on commit 266828c

Please sign in to comment.