qecx.QECXFile¶
- class qecx.QECXFile(data, *, source='')¶
Bases:
objectLoaded QECX file with structured property access.
Holds the resolved document dict and an optional
sourcelabel. Display methods live onQECXViewer; obtain one viaview().Equality compares the underlying
_datadict;sourceis excluded so two files loaded from different paths but with identical content are equal. The amend-after-import idiom:data = qf.to_dict(); ...mutate...; qf2 = QECXFile(data=data, source=qf.source); qf2.validate().- Parameters:
- Variables:
source (str) – Display name for the source file (e.g. filename).
- to_dict()¶
Return a deep copy of the underlying data dictionary.
Use this for amend-after-import: mutate the returned dict freely and pass it back into
QECXFile(data=...)to construct an independent file.
- validate()¶
Validate this file’s data against schema and semantic rules.
Findings are computed once and memoised; subsequent calls return them without re-running validation. The cache reflects the document as it stood at first validation: mutating the underlying data through the section-property references is unsupported and can leave the cache stale, while the amend-after-import idiom constructs a new
QECXFilethat starts unvalidated.- Returns:
All findings (warnings and errors), as a fresh list per call. An empty list means the document is valid.
- Return type:
- property error_correction_cycle: dict¶
The
error_correction_cyclesection with parametricrepeatreferences resolved to integers.Every
{"ref": "<dot.path>"}value on a cycle-level or step-levelrepeatfield is replaced by the integer the root-anchored dot-path (e.g.code.d) addresses in the document. Returns a derived deep copy, fresh per access.- Raises:
ValueError – If a
repeatreference is not a dot-path string, does not resolve to a field of the document, or resolves to a non-integer. Validation guarantees resolvability, so only documents that skipped or failed validation can raise.
- property decoder_config: dict | None¶
The
decoder_configsection with parametric references resolved, orNoneif the section is absent.Every
{"ref": "<dot.path>"}value is replaced by the value the dot-path, anchored at thecodeorqubit_layoutsection, addresses in the document: a single*projection segment resolves to a list, otherwise to a scalar. Returns a derived deep copy, fresh per access; resolution never mutates the underlying data, soto_dict()preserves the raw references.- Raises:
ValueError – If a reference does not resolve. Validation guarantees resolvability, so only documents that skipped or failed validation can raise.
- property d: Any¶
Code distance (
code.d). An integer for symmetric codes or a dict ({"X": ..., "Z": ...}) for asymmetric-distance codes.
- view(config=None, **overrides)¶
Return a viewer over this file for display methods.
The viewer’s settings start from
configwhen given, otherwise fromDEFAULT_VIEWER_CONFIGas currently set, withoverridesapplied on top. The viewer holds a newViewerConfig: neitherconfignorDEFAULT_VIEWER_CONFIGis modified, and later changes to either do not reach the returned viewer.- Parameters:
config (ViewerConfig | None) – Base settings for the viewer.
None(default) usesDEFAULT_VIEWER_CONFIG.**overrides (Any) – Viewer settings for this call, keyed by
ViewerConfigfield name (for examplecircuit_mode="text").
- Returns:
Viewer over this file.
- Return type:
- Raises:
TypeError – If a key of
overridesis not aViewerConfigfield.