Skip to content

Commit

Permalink
Improve docstrings (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSerraPeralta authored Sep 21, 2024
1 parent daf8921 commit 418dc54
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion qec_util/performance/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def sample_failures(
)
if "decode_batch" not in dir(decoder):
raise TypeError("'decoder' does not have a 'decode_batch' method.")

sampler = dem.compile_sampler()
num_failures, num_samples = 0, 0

Expand Down
50 changes: 50 additions & 0 deletions qec_util/util/syndrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@


def get_syndromes(anc_meas: DataArray) -> DataArray:
"""Returns the syndrome outcomes from the ancilla outcomes
for a memory experiment.
Parameters
----------
anc_meas
Ancilla outcomes for the memory experiment.
Expected minimum set of coordinates: ``qec_round`` and ``meas_reset``.
Returns
-------
syndromes
Syndrome outcomes.
Coordinates: same coordinates as ``anc_meas``.
"""
if anc_meas.meas_reset:
return anc_meas

Expand All @@ -13,6 +28,23 @@ def get_syndromes(anc_meas: DataArray) -> DataArray:


def get_defects(syndromes: DataArray, frame: Optional[DataArray] = None) -> DataArray:
"""Returns the defects from the syndrome outcomes for a memory experiment.
Parameters
----------
syndromes
Syndrome outcomes of the memory experiment.
Expected coordinates: ``qec_round`` and ``anc_qubit``.
frame
Initial Pauli frame of the memory experiment.
Expected coordinates: ``anc_qubit``.
Returns
-------
defects
Defects.
Coordinates: ``qec_round`` and ``anc_qubit``.
"""
shifted_syn = syndromes.shift(qec_round=1, fill_value=0)

if frame is not None:
Expand All @@ -23,6 +55,24 @@ def get_defects(syndromes: DataArray, frame: Optional[DataArray] = None) -> Data


def get_final_defects(syndromes: DataArray, proj_syndrome: DataArray) -> DataArray:
"""Returns the defects for the final round build from the ancilla outcomes
and the data qubit outcomes for a memory experiment.
Parameters
----------
syndromes
Syndrome outcomes from the ancilla qubits in the memory experiment.
Expected coordinates: ``qec_round`` and ``anc_qubit``.
proj_syndromes
Syndrome outcomes built from the data qubit outcomes.
Expected coordinates: ``anc_qubit``.
Returns
-------
defects
Defects for the stabilizers in ``proj_syndromes``.
Coordinates: ``anc_qubit``.
"""
last_round = syndromes.qec_round.values[-1]
anc_qubits = proj_syndrome.anc_qubit.values

Expand Down

0 comments on commit 418dc54

Please sign in to comment.