Skip to main content

Module block

Module block 

Expand description

The atune-parity/1 block: its grammar, its parser, and the comparison.

The format is specified in docs/design/11-documentation-plan.md §17.4 and printed by each example itself, in each language, as the last thing it writes:

atune-parity/1
study: rastrigin
seed: 42
trials: 256
sampler: Random
best.number: 151
best.value: 1.8650553405295156
best.param.x: 1.0340826850426426
best.param.y: -0.05372798507453446

Why the comparison is over parsed bits and not over text. Rust’s {}/{:e} and Python’s repr/f"{v:e}" spell the same f64 differently (e0 against e+00, 1 against 1.0), so a text diff would fail on formatting while a bit comparison asserts exactly the claim being made: the two languages computed the same number. Both arms print floats shortest-round-trip ({:?} and repr), so the text recovers the exact bits on parse.

Which fields are floats is decided by the key, not by whether the text happens to parse. trials: 256 parses as an f64 perfectly well, and two best.numbers above 2^53 that differ by one would compare equal as floats — a false pass. Only best.value, best.value.<metric> and best.param.<name> are float-valued (§17.4), and even those fall back to a byte comparison when either side is not a number, because a categorical parameter’s value is a label.

Structs§

Block
One parsed parity block.
Side
One side of a comparison: what it is, and what it printed.

Enums§

Compare
How two blocks are compared.

Constants§

HEADER
The header every block opens with, version included.
HEADER_PREFIX 🔒
The header without its version.
PARAM_PREFIX 🔒
The prefix of the parameter lines, which are sorted and come last.
REQUIRED_KEYS 🔒
The keys every block must carry, whatever the example does.
VALUE_KEY 🔒
The single-objective value key.
VALUE_PREFIX 🔒
The multi-objective value prefix, best.value.<metric-name>.

Functions§

compare
Compares two blocks, failing on the first differing key.
compare_value 🔒
Compares one field’s value under mode.
float_text 🔒
A float value, as {:?} and as its bits.
is_float_key 🔒
true if the field named key holds a float (§17.4).
key_at 🔒
How a missing or unexpected key at some position is rendered.
mismatch 🔒
Builds the mismatch error.
split_field 🔒
Splits one key: value line, rejecting every spelling §17.4 forbids.
tail 🔒
The last few lines of what an arm printed, for a “no block” message.
text 🔒
A string value, as {:?} — quoted, so a stray space is visible.
within 🔒
true when the two values agree to a relative tolerance.