quchip.utils.labeling¶
Component labels and lookup by object or label.
A component without an explicit label gets "{prefix}_{n}". Each prefix has
a process-wide counter starting at zero. Labels identify components in a chip.
resolve_label() accepts the component or its label. Use
reset_label_counters() to get deterministic labels in tests.
Functions
|
Return the next |
|
Build a bare-state tuple in |
|
Merge object-or-label keys and keyword arguments into a dict with label keys. |
Reset the process-wide label counters, usually in test fixtures. |
|
|
Return a string label from a string or a labeled component. |
|
Return the top |
Classes
Result mapping with label keys that also accepts component objects. |
- quchip.utils.labeling.auto_label(prefix)[source]¶
Return the next
"{prefix}_{n}"label, where each prefix starts at zero.- Parameters:
prefix (str) – Prefix of the component type. Each prefix has its own process-wide counter.
- quchip.utils.labeling.reset_label_counters()[source]¶
Reset the process-wide label counters, usually in test fixtures.
- quchip.utils.labeling.resolve_label(obj)[source]¶
Return a string label from a string or a labeled component.
Raise
TypeErrorif the object has no usable label.
- quchip.utils.labeling.merge_labeled_values(mapping, kwargs)[source]¶
Merge object-or-label keys and keyword arguments into a dict with label keys.
Duplicate labels raise
ValueError, including a label supplied through both inputs. Values pass through unchanged, and callers validate their types and bounds.
- quchip.utils.labeling.bare_label_from_mapping(device_labels, mapping, kwargs)[source]¶
Build a bare-state tuple in
device_labelsorder from a partial mapping.Keys can be devices or labels. Unspecified devices get the default Fock index zero. Unknown or duplicate labels raise
ValueError. Callers validate values.