Skip to content

Commit

Permalink
refactor: Reduce code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Oct 22, 2024
1 parent c5b70fe commit edb558f
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/qibocal/protocols/ramsey/ramsey_zz.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,11 @@ def _acquisition(

for qubit in targets:
probs = results[qubit].probability(state=1)
# The probability errors are the standard errors of the binomial distribution
errors = [np.sqrt(prob * (1 - prob) / params.nshots) for prob in probs]
data.register_qubit(
RamseyType,
(qubit, setup),
dict(
wait=waits,
prob=probs,
errors=errors,
),
)

else:
sequences, all_ro_pulses = [], []
probs, errors = [], []
for wait in waits:
sequence = PulseSequence()
for qubit in targets:
Expand All @@ -149,18 +140,20 @@ def _acquisition(

for wait, ro_pulses in zip(waits, all_ro_pulses):
for qubit in targets:
result = results[ro_pulses[qubit].serial][0]
prob = result.probability()
error = np.sqrt(prob * (1 - prob) / params.nshots)
data.register_qubit(
RamseyType,
(qubit, setup),
dict(
wait=np.array([wait]),
prob=np.array([prob]),
errors=np.array([error]),
),
)
prob = results[ro_pulses[qubit].serial][0].probability(state=1)
probs.append(prob)
errors.append(np.sqrt(prob * (1 - prob) / params.nshots))

for qubit in targets:
data.register_qubit(
RamseyType,
(qubit, setup),
dict(
wait=waits,
prob=probs,
errors=errors,
),
)

return data

Expand Down

0 comments on commit edb558f

Please sign in to comment.