Skip to content

Commit 1950b27

Browse files
committed
Merge branch 'develop' into bro-fix-variational-args
2 parents c34dc84 + baad6ce commit 1950b27

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

cmdstanpy/cmdstan_args.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,12 @@ def validate(self) -> None:
597597
self._logger.info(
598598
'created output directory: %s', self.output_dir
599599
)
600-
except (RuntimeError, PermissionError):
600+
except (RuntimeError, PermissionError) as exc:
601601
raise ValueError(
602602
'invalid path for output files, no such dir: {}'.format(
603603
self.output_dir
604604
)
605-
)
605+
) from exc
606606
if not os.path.isdir(self.output_dir):
607607
raise ValueError(
608608
'specified output_dir not a directory: {}'.format(
@@ -614,11 +614,11 @@ def validate(self) -> None:
614614
with open(testpath, 'w+'):
615615
pass
616616
os.remove(testpath) # cleanup
617-
except Exception:
617+
except Exception as exc:
618618
raise ValueError(
619619
'invalid path for output files,'
620620
' cannot write to dir: {}'.format(self.output_dir)
621-
)
621+
) from exc
622622

623623
if self.seed is None:
624624
rng = RandomState()

cmdstanpy/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,13 +850,13 @@ def generate_quantities(
850850
runset._csv_files = sample_csv_files
851851
sample_fit = CmdStanMCMC(runset)
852852
sample_drawset = sample_fit.draws_as_dataframe()
853-
except ValueError as e:
853+
except ValueError as exc:
854854
raise ValueError(
855855
'Invalid mcmc_sample, error:\n\t{}\n\t'
856856
' while processing files\n\t{}'.format(
857-
repr(e), '\n\t'.join(sample_csv_files)
857+
repr(exc), '\n\t'.join(sample_csv_files)
858858
)
859-
)
859+
) from exc
860860

861861
generate_quantities_args = GenerateQuantitiesArgs(
862862
csv_files=sample_csv_files

cmdstanpy/stanfit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ def save_csvfiles(self, dir: str = None) -> None:
261261
with open(test_path, 'w'):
262262
pass
263263
os.remove(test_path) # cleanup
264-
except (IOError, OSError, PermissionError):
265-
raise Exception('cannot save to path: {}'.format(dir))
264+
except (IOError, OSError, PermissionError) as exc:
265+
raise Exception('cannot save to path: {}'.format(dir)) from exc
266266

267267
for i in range(self.chains):
268268
if not os.path.exists(self._csv_files[i]):

cmdstanpy/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ def parse_rdump_value(rhs: str) -> Union[int, float, np.array]:
444444
val = float(rhs)
445445
else:
446446
val = int(rhs)
447-
except TypeError:
448-
raise ValueError('bad value in Rdump file: {}'.format(rhs))
447+
except TypeError as exc:
448+
raise ValueError('bad value in Rdump file: {}'.format(rhs)) from exc
449449
return val
450450

451451

@@ -686,10 +686,10 @@ def scan_metric(fd: TextIO, config_dict: Dict, lineno: int) -> int:
686686
)
687687
try:
688688
float(stepsize.strip())
689-
except ValueError:
689+
except ValueError as exc:
690690
raise ValueError(
691691
'line {}: invalid stepsize: {}'.format(lineno, stepsize)
692-
)
692+
) from exc
693693
line = fd.readline().strip()
694694
lineno += 1
695695
if not (

0 commit comments

Comments
 (0)