qiskit-community / qiskit-ignis

Ignis (deprecated) provides tools for quantum hardware verification, noise characterization, and error correction.
Apache License 2.0
168 stars 162 forks source link

StateTomographyFitter only accept results for a state_tomography_circuits execution #560

Open alejomonbar opened 3 years ago

alejomonbar commented 3 years ago

What is the expected behavior?

The StateTomographyFitter function only accept results from state_tomography_circuits execution. It is a good idea to allow arrays passed to this function. Because, as part of my project I need to extract the density state for different conditions. Therefore, it is easier to transform my results into an array and pass them to this function than execute a circuit for each time

import qiskit
from qiskit.ignis.verification.tomography import state_tomography_circuits, StateTomographyFitter

q2 = QuantumRegister(2)
bell = QuantumCircuit(q2)
bell.h(q2[0])
bell.cx(q2[0], q2[1])

# Generate the state tomography circuits.
qst_bell = state_tomography_circuits(bell, [q2[3], q2[5]])

# Execute
job = qiskit.execute(qst_bell, Aer.get_backend('qasm_simulator'), shots=5000)
# Fit result
tomo_fitter_bell = StateTomographyFitter(job.result(), qst_bell)

But what about if I have a sequence of circuits

import qiskit
import numpy as np
from qiskit.ignis.verification.tomography import state_tomography_circuits, StateTomographyFitter

q2 = QuantumRegister(2)

thetas = np.linspace(0, np.pi, 10)
circuits = []
for theta in thetas:
  bell = QuantumCircuit(q2)
  bell.rx(theta, q2[0])
  bell.cx(q2[0], q2[1])
  qst_bell = state_tomography_circuits(bell, [q2[0], q2[1]])
  circuits += qst_bell

# Execute
job = qiskit.execute(circuits, Aer.get_backend('qasm_simulator'), shots=5000)
# Fit result
tomo_fitter_bell = StateTomographyFitter(job.result(), qst_bell)