format_entropy_reason(
frame: TreeFrameState,
qid_label_map: dict[int, int] | None = None,
) -> str | None
Human-readable description of why an entropy bump fired at this frame.
Returns None when the frame does not describe an entropy-bump event.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/visualize/entropy_tree/renderer.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 | def format_entropy_reason(
frame: TreeFrameState,
qid_label_map: dict[int, int] | None = None,
) -> str | None:
"""Human-readable description of why an entropy bump fired at this frame.
Returns ``None`` when the frame does not describe an entropy-bump event.
"""
reason = frame.event_reason
if reason is None:
return None
if reason == "state-seen":
seen_id = frame.event_state_seen_display_id
if seen_id is None:
return "entropy bump reason: encountered previously seen configuration"
return f"entropy bump reason: seen configuration at display node {seen_id}"
if reason == "no-valid-moves":
qid = frame.event_no_valid_moves_qubit
if qid is None:
return "entropy bump reason: no valid moves available"
label = qid_label_map.get(qid, qid) if qid_label_map else qid
return f"entropy bump reason: no valid moves for qubit {label}"
if reason == "entropy":
return "entropy bump reason: reached entropy threshold/reversion condition"
return f"entropy bump reason: {reason}"
|