|
19 | 19 | def parse_comments_header_and_draws( |
20 | 20 | stan_csv: Union[str, os.PathLike, Iterator[bytes]], |
21 | 21 | ) -> Tuple[List[bytes], Optional[str], List[bytes]]: |
22 | | - """Parses lines of a Stan CSV file into comment lines and draws lines, where |
23 | | - a draws line is just a non-commented line. |
| 22 | + """Parses lines of a Stan CSV file into comment lines, the header line, |
| 23 | + and draws lines. |
24 | 24 |
|
25 | | - Returns a (comment_lines, draws_lines) tuple. |
| 25 | + Returns a (comment_lines, header, draws_lines) tuple. |
26 | 26 | """ |
27 | 27 |
|
28 | 28 | def partition_csv( |
@@ -226,8 +226,8 @@ def parse_variational_eta(comment_lines: List[bytes]) -> float: |
226 | 226 | def extract_max_treedepth_and_divergence_counts( |
227 | 227 | header: str, draws_lines: List[bytes], max_treedepth: int, warmup_draws: int |
228 | 228 | ) -> Tuple[int, int]: |
229 | | - """Extracts the max treedepth and divergence counts from the draw lines |
230 | | - of the MCMC stan csv output.""" |
| 229 | + """Extracts the max treedepth and divergence counts from the header |
| 230 | + and draw lines of the MCMC stan csv output.""" |
231 | 231 | if len(draws_lines) <= 1: # Empty draws |
232 | 232 | return 0, 0 |
233 | 233 | column_names = header.split(",") |
@@ -346,6 +346,10 @@ def column_count(ln: bytes) -> int: |
346 | 346 |
|
347 | 347 |
|
348 | 348 | def raise_on_invalid_adaptation_block(comment_lines: List[bytes]) -> None: |
| 349 | + """Throws ValueErrors if the parsed adaptation block is invalid, e.g. |
| 350 | + the metric information is not present, consistent with the rest of |
| 351 | + the file, or the step size info cannot be processed.""" |
| 352 | + |
349 | 353 | def column_count(ln: bytes) -> int: |
350 | 354 | return ln.count(b",") + 1 |
351 | 355 |
|
|
0 commit comments