Ascii printer: several small fixes and improvements#591
Merged
Conversation
- Remove the unsupported 'print_debug_data' option from the example YAML (yaml_files/spartan.yaml). It was advertised but never read. - Implement the 'delete_file_on_restart' YAML option (default false). Previously the option was advertised in several example YAMLs but silently ignored, and the printer unconditionally truncated any pre-existing output_file/info_file. The option now mirrors the behaviour of the hdf5 printers: by default GAMBIT refuses to overwrite a pre-existing file and raises a printer_error with an informative message. - Use a single column width in dump_buffer so all rows align vertically. Previously numeric values used setw(colwidth+5) but 'none' placeholders and Suspicious/Invalidation-Code defaults used setw(colwidth), so any row containing a missing cell broke vertical alignment. - Let only MPI rank 0 write the metadata file. Previously all MPI ranks were appending unsynchronised to the same file. The setup metadata is identical across ranks anyway, and the per-rank lastPointID is only relevant for resume support (which the ascii printer does not have yet). - Stop double-appending the MPI rank to auxiliary printer file names. - Expose 'precision' as a YAML option (default 10). Previously the number of digits used by std::setprecision was hard-coded. - Add a 'write_header' YAML option (default false). When enabled, dump_buffer writes a single '#'-prefixed line at the top of the data file containing a shorthand name for each column. The shorthand is the substring of the full label after the last '::' (or the whole label if no '::'), with internal whitespace replaced by '_' and prefixed with the 1-based column number used in the info file (e.g. '5_mu', '6_sigma'). This makes it easier to read the data file directly and parse it with e.g. numpy.loadtxt or pandas.read_csv. The full labels remain in the _info file.
carlmfe
approved these changes
May 7, 2026
Contributor
carlmfe
left a comment
There was a problem hiding this comment.
Yes, it all looks sound.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We typically don't use the ascii printer for large GAMBIT runs, but it's useful for smaller projects, tutorials and quick tests. So this PR has a bunch of small fixes that aim to improve the usability of the ascii printer:
Remove the unsupported 'print_debug_data' option from the example YAML (yaml_files/spartan.yaml). It was advertised but never read.
Implement the 'delete_file_on_restart' YAML option (default false). Previously the option was advertised in several example YAMLs but silently ignored, and the printer unconditionally truncated any pre-existing output_file/info_file. The option now mirrors the behaviour of the hdf5 printers: by default GAMBIT refuses to overwrite a pre-existing file and raises a printer_error with an informative message.
Use a single column width in dump_buffer so all rows align vertically. Previously numeric values used setw(colwidth+5) but 'none' placeholders and Suspicious/Invalidation-Code defaults used setw(colwidth), so any row containing a missing cell broke vertical alignment.
Let only MPI rank 0 write the metadata file. Previously all MPI ranks were appending unsynchronised to the same file. The setup metadata is identical across ranks anyway, and the per-rank lastPointID is only relevant for resume support (which the ascii printer does not have yet).
Stop double-appending the MPI rank to auxiliary printer file names.
Expose 'precision' as a YAML option (default 10). Previously the number of digits used by std::setprecision was hard-coded.
Add a 'write_header' YAML option (default false). When enabled, dump_buffer writes a single '#'-prefixed line at the top of the data file containing a shorthand name for each column. The shorthand is the substring of the full label after the last '::' (or the whole label if no '::'), with internal whitespace replaced by '_' and prefixed with the 1-based column number used in the info file (e.g. '5_mu', '6_sigma'). This makes it easier to read the data file directly and parse it with e.g. numpy.loadtxt or pandas.read_csv. The full labels remain in the _info file.