Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CmdStan 2.36 no longer requires fixed_param hacks #771

Merged
merged 7 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmdstanpy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ def __init__(
self._compiler_options.add_include_path(path)

# try to detect models w/out parameters, needed for sampler
if not cmdstan_version_before(
2, 27
): # unknown end of version range
if (not cmdstan_version_before(2, 27)) and cmdstan_version_before(
2, 36
):
WardBrian marked this conversation as resolved.
Show resolved Hide resolved
try:
model_info = self.src_info()
if 'parameters' in model_info:
Expand Down
23 changes: 13 additions & 10 deletions cmdstanpy/stanfit/mcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def _assemble_draws(self) -> None:
self._step_size[chain] = float(step_size.strip())
if self._metadata.cmdstan_config['metric'] != 'unit_e':
line = fd.readline().strip() # metric type
line = fd.readline().lstrip(' #\t')
line = fd.readline().lstrip(' #\t').rstrip()
num_unconstrained_params = len(line.split(','))
if chain == 0: # can't allocate w/o num params
if self.metric_type == 'diag_e':
Expand All @@ -429,18 +429,21 @@ def _assemble_draws(self) -> None:
),
dtype=float,
)
if self.metric_type == 'diag_e':
xs = line.split(',')
self._metric[chain, :] = [float(x) for x in xs]
else:
xs = line.split(',')
self._metric[chain, 0, :] = [float(x) for x in xs]
for i in range(1, num_unconstrained_params):
line = fd.readline().lstrip(' #\t').strip()
if line:
if self.metric_type == 'diag_e':
xs = line.split(',')
self._metric[chain, i, :] = [
self._metric[chain, :] = [float(x) for x in xs]
else:
xs = line.strip().split(',')
self._metric[chain, 0, :] = [
float(x) for x in xs
]
for i in range(1, num_unconstrained_params):
line = fd.readline().lstrip(' #\t').rstrip()
xs = line.split(',')
self._metric[chain, i, :] = [
float(x) for x in xs
]
else: # unit_e changed in 2.34 to have an extra line
pos = fd.tell()
line = fd.readline().strip()
Expand Down
Loading
Loading