SegmentNameGenerator

timelines.SegmentNameGenerator(alphabet=None, volta_suffix=True)

Assign display labels to a run of atomic sections.

The generator turns a sequence of per-section volta flags into a list of labels, one per section. Two policies are configurable:

Alphabet

Base sections walk alphabet (default _SECTION_ALPHABET — Latin upper, Latin lower, Greek upper, Greek lower). Once the alphabet is exhausted it repeats with a numeric suffix (A2, B2, …) so labels stay unique and printable for arbitrarily long scores. A caller may pass any sequence of symbols.

Volta suffix

When volta_suffix is True (the default), a section that opens a volta bracket inherits the preceding non-volta section’s label plus a positional numeric suffix (1, 2, …). A section B followed by two alternative endings is therefore labelled B, B1, B2 rather than consuming the next three letters. The suffix is positional — the first volta after a base is 1, the second 2 — and is independent of the volta’s own ending number. A non-volta section resets the counter, so two independent volta groups read B, B1, B2 then C, C1, C2 (never C3, C4). A leading volta with no preceding base falls back to a base letter.

When volta_suffix is False every section consumes the next base label in sequence (B, C, D), the historical behaviour.

Examples

>>> SegmentNameGenerator().generate([False, True, True])
['A', 'A1', 'A2']
>>> SegmentNameGenerator(volta_suffix=False).generate([False, True, True])
['A', 'B', 'C']

Methods

Name Description
generate Return one label per section, honouring the volta-suffix policy.

generate

timelines.SegmentNameGenerator.generate(volta_flags)

Return one label per section, honouring the volta-suffix policy.

Parameters

Name Type Description Default
volta_flags Sequence[bool] volta_flags[i] is True when atomic section i opens a volta bracket. required

Returns

Name Type Description
list[str] A list of labels the same length as volta_flags.