Skip to content

Commit 0ed8811

Browse files
authored
Merge pull request #771 from stan-dev/fixes/2.36
CmdStan 2.36 no longer requires fixed_param hacks
2 parents c5bcfb3 + f53ab34 commit 0ed8811

File tree

5 files changed

+209
-45
lines changed

5 files changed

+209
-45
lines changed

cmdstanpy/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def __init__(
205205
self._compiler_options.add_include_path(path)
206206

207207
# try to detect models w/out parameters, needed for sampler
208-
if not cmdstan_version_before(
209-
2, 27
210-
): # unknown end of version range
208+
if (not cmdstan_version_before(2, 27)) and cmdstan_version_before(
209+
2, 36
210+
):
211211
try:
212212
model_info = self.src_info()
213213
if 'parameters' in model_info:

cmdstanpy/stanfit/mcmc.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def _assemble_draws(self) -> None:
412412
self._step_size[chain] = float(step_size.strip())
413413
if self._metadata.cmdstan_config['metric'] != 'unit_e':
414414
line = fd.readline().strip() # metric type
415-
line = fd.readline().lstrip(' #\t')
415+
line = fd.readline().lstrip(' #\t').rstrip()
416416
num_unconstrained_params = len(line.split(','))
417417
if chain == 0: # can't allocate w/o num params
418418
if self.metric_type == 'diag_e':
@@ -429,18 +429,21 @@ def _assemble_draws(self) -> None:
429429
),
430430
dtype=float,
431431
)
432-
if self.metric_type == 'diag_e':
433-
xs = line.split(',')
434-
self._metric[chain, :] = [float(x) for x in xs]
435-
else:
436-
xs = line.split(',')
437-
self._metric[chain, 0, :] = [float(x) for x in xs]
438-
for i in range(1, num_unconstrained_params):
439-
line = fd.readline().lstrip(' #\t').strip()
432+
if line:
433+
if self.metric_type == 'diag_e':
440434
xs = line.split(',')
441-
self._metric[chain, i, :] = [
435+
self._metric[chain, :] = [float(x) for x in xs]
436+
else:
437+
xs = line.strip().split(',')
438+
self._metric[chain, 0, :] = [
442439
float(x) for x in xs
443440
]
441+
for i in range(1, num_unconstrained_params):
442+
line = fd.readline().lstrip(' #\t').rstrip()
443+
xs = line.split(',')
444+
self._metric[chain, i, :] = [
445+
float(x) for x in xs
446+
]
444447
else: # unit_e changed in 2.34 to have an extra line
445448
pos = fd.tell()
446449
line = fd.readline().strip()

0 commit comments

Comments
 (0)