Skip to content

Ascii printer: several small fixes and improvements#591

Merged
anderkve merged 1 commit intomasterfrom
ascii_printer_improvements
May 7, 2026
Merged

Ascii printer: several small fixes and improvements#591
anderkve merged 1 commit intomasterfrom
ascii_printer_improvements

Conversation

@anderkve
Copy link
Copy Markdown
Collaborator

@anderkve anderkve commented May 6, 2026

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.

- 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.
@anderkve anderkve requested a review from carlmfe May 6, 2026 16:44
@anderkve anderkve added Core Core group task Printers labels May 6, 2026
Copy link
Copy Markdown
Contributor

@carlmfe carlmfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it all looks sound.

@anderkve anderkve merged commit 75fa93a into master May 7, 2026
2 of 4 checks passed
@anderkve anderkve deleted the ascii_printer_improvements branch May 7, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core Core group task Printers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants