Skip to content

Commit

Permalink
Remove tests that depend on BackendV1 fake backends
Browse files Browse the repository at this point in the history
2 of the tests added in #6299 depend on the fake backends in
qiskit.test.mock being strict BackendV1 backends (that reject qobj) and
also having other aspects of the interface implemented (mainly run
kwargs). However the change which updated the fake backends to use
BackendV1 (#6286) is not backportable as it's an API change, so these
tests are runnable in stable/0.17. This commit just removes these tests
because even if we could get them running without #6286 we wouldn't be
actually testing the v1 interface (which is their purpose).
  • Loading branch information
mtreinish committed May 3, 2021
1 parent 8097897 commit 6e6bee1
Showing 1 changed file with 0 additions and 56 deletions.
56 changes: 0 additions & 56 deletions test/python/algorithms/test_backendv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,62 +67,6 @@ def test_vqe_qasm(self):
result = vqe.compute_minimum_eigenvalue(operator=h2_op)
self.assertAlmostEqual(result.eigenvalue.real, -1.86, delta=0.05)

def test_run_circuit_oracle(self):
"""Test execution with a quantum circuit oracle"""
oracle = QuantumCircuit(2)
oracle.cz(0, 1)
problem = AmplificationProblem(oracle, is_good_state=['11'])
qi = QuantumInstance(self._provider.get_backend('fake_yorktown'),
seed_simulator=12,
seed_transpiler=32)
grover = Grover(quantum_instance=qi)
result = grover.amplify(problem)
self.assertIn(result.top_measurement, ['11'])

def test_measurement_error_mitigation_with_vqe(self):
""" measurement error mitigation test with vqe """
try:
from qiskit.ignis.mitigation.measurement import CompleteMeasFitter
from qiskit.providers.aer import noise
except ImportError as ex:
self.skipTest("Package doesn't appear to be installed. Error: '{}'".format(str(ex)))
return

algorithm_globals.random_seed = 0

# build noise model
noise_model = noise.NoiseModel()
read_err = noise.errors.readout_error.ReadoutError([[0.9, 0.1], [0.25, 0.75]])
noise_model.add_all_qubit_readout_error(read_err)

backend = self._qasm

quantum_instance = QuantumInstance(
backend=backend,
seed_simulator=167,
seed_transpiler=167,
noise_model=noise_model,
measurement_error_mitigation_cls=CompleteMeasFitter
)

h2_hamiltonian = -1.052373245772859 * (I ^ I) \
+ 0.39793742484318045 * (I ^ Z) \
- 0.39793742484318045 * (Z ^ I) \
- 0.01128010425623538 * (Z ^ Z) \
+ 0.18093119978423156 * (X ^ X)
optimizer = SPSA(maxiter=200)
ansatz = EfficientSU2(2, reps=1)

vqe = VQE(
ansatz=ansatz,
optimizer=optimizer,
quantum_instance=quantum_instance
)
result = vqe.compute_minimum_eigenvalue(operator=h2_hamiltonian)
self.assertGreater(quantum_instance.time_taken, 0.)
quantum_instance.reset_execution_results()
self.assertAlmostEqual(result.eigenvalue.real, -1.86, delta=0.05)


if __name__ == '__main__':
unittest.main()

0 comments on commit 6e6bee1

Please sign in to comment.