format_params_for_logging#

lumopt2.utils.common.format_params_for_logging(params: ndarray, *, precision: int = 8, max_line_width: int = 88, indent: str = '  ') str#

Format an optimization-parameter array for end-of-run logging.

Renders every value in scientific notation with a uniform width so columns line up, wraps at max_line_width characters, and never elides values via NumPy’s ... truncation – so the output can be copied back as a starting point for a follow-up run even when there are thousands of parameters.

For 5-50 parameters this produces a small block (a few lines). For a few thousand parameters it produces a longer block, but still readable: each line typically holds 4-5 values.

Parameters:
paramsnp.ndarray

1-D parameter array (or any array_like that can be flattened).

precisionint, optional

Significant digits per value. Default 8 covers IEEE-754 single-precision round-trip and is enough to reproduce the starting point of a follow-up run.

max_line_widthint, optional

Soft target for line width in characters (default: 88). NumPy may exceed this slightly when a single value plus its trailing comma is wider than the budget.

indentstr, optional

String prepended to every line of the output (default: two spaces). Matches the indentation of nested log messages.

Returns:
str

Multi-line string with bracketed list representation, indented per indent. Returns "(empty parameter array)" when params has zero elements and "(no parameters available)" when params is None.

Examples

>>> format_params_for_logging(np.array([1e-7, 2e-7, 3e-7]))
'  [ 1.00000000e-07,  2.00000000e-07,  3.00000000e-07]'