def create_tomo_blocks(qubits, numPulses, alignment='parallel'):
'''
Helper function to create the tomography pulse block in either parallel or serial.
'''
#Tomography pulse sets
if numPulses == 4:
tomoSet = [Id, X90, Y90, X]
elif numPulses == 6:
tomoSet = [Id, X90, X90m, Y90, Y90m, X]
else:
raise ValueError("Only able to handle numPulses=4 or 6")
#Create all combinations of pulses for the number of qubits
if alignment == 'parallel':
return [reduce(operator.mul, [p(q) for p, q in zip(pulseSet, qubits)])
for pulseSet in product(tomoSet, repeat=len(qubits))]
elif alignment == 'serial':
return [[p(q) for p, q in zip(pulseSet, qubits)]
for pulseSet in product(tomoSet, repeat=len(qubits))]
else:
raise ValueError("Alignment must be either serial or parallel")
评论列表
文章目录