Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

StateTomographyFitter only accept results for a state_tomography_circuits execution #560

Open
alejomonbar opened this issue Mar 10, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@alejomonbar
Copy link

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)
@alejomonbar alejomonbar added the enhancement New feature or request label Mar 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant