Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test cases for Qiskit 0.45.2 #2035

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
fixes:
- |
Fixes test cases failed due to upgrade of Qiskit.

Removed importing Aer from qiskit.

QuantumCircuit.diagonal was deprecated, using circuit.library.Diagonal instead
4 changes: 2 additions & 2 deletions test/benchmark/vqe_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import numpy as np
import multiprocessing
from time import time
from qiskit import Aer
from qiskit.aqua.algorithms import VQE
from qiskit.aqua.components.optimizers import SLSQP
from qiskit.chemistry.applications import MolecularGroundStateEnergy
from qiskit.chemistry.components.initial_states import HartreeFock
from qiskit.chemistry.components.variational_forms import UCCSD
from qiskit.chemistry.drivers import PySCFDriver, UnitsType
from qiskit_aer import AerProvider


class UCCSDBenchmarkSuite:
Expand Down Expand Up @@ -67,7 +67,7 @@ def cb_create_solver(
optimizer=SLSQP(maxiter=5000),
max_evals_grouped=256,
)
vqe.quantum_instance = Aer.get_backend("qasm_simulator")
vqe.quantum_instance = AerProvider.get_backend("qasm_simulator")
vqe.quantum_instance.backend_options["backend_options"] = {
"max_parallel_experiments": threads,
"method": method,
Expand Down
2 changes: 1 addition & 1 deletion test/terra/backends/aer_simulator/test_truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
AerSimulator Integration Tests
"""
from ddt import ddt
from qiskit import transpile, QuantumCircuit, Aer
from qiskit import transpile, QuantumCircuit
from qiskit.providers.fake_provider import FakeQuito
from qiskit_aer.noise import NoiseModel
from test.terra.backends.simulator_test_case import SimulatorTestCase, supported_methods
Expand Down
11 changes: 4 additions & 7 deletions test/terra/reference/ref_diagonal_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

import numpy as np
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister

# Backwards compatibility for Terra <= 0.13
if not hasattr(QuantumCircuit, "diagonal"):
QuantumCircuit.diagonal = QuantumCircuit.diag_gate
from qiskit.circuit.library import Diagonal


def diagonal_gate_circuits_deterministic(final_measure=True):
Expand All @@ -41,7 +38,7 @@ def diagonal_gate_circuits_deterministic(final_measure=True):
for diag in [arg, np.array(arg), np.array(arg, dtype=float), np.array(arg, dtype=complex)]:
circuit = QuantumCircuit(*regs)
circuit.h(qubit)
circuit.diagonal(list(diag), [qubit])
circuit.append(Diagonal(diag), [qubit])
circuit.h(qubit)
if final_measure:
circuit.barrier(qr)
Expand All @@ -53,7 +50,7 @@ def diagonal_gate_circuits_deterministic(final_measure=True):
for diag in [arg, np.array(arg), np.array(arg, dtype=float), np.array(arg, dtype=complex)]:
circuit = QuantumCircuit(*regs)
circuit.h(qr)
circuit.diagonal(list(diag), qr)
circuit.append(Diagonal(diag), qr)
circuit.h(qr)
if final_measure:
circuit.barrier(qr)
Expand All @@ -64,7 +61,7 @@ def diagonal_gate_circuits_deterministic(final_measure=True):
for diag in [np.array([1, 1, 1, np.exp(-1j * np.pi / k)]) for k in [10, 100, 1000, 10000]]:
circuit = QuantumCircuit(*regs)
circuit.x(qr)
circuit.diagonal(list(diag), qr)
circuit.append(Diagonal(diag), qr)
if final_measure:
circuit.barrier(qr)
circuit.measure(qr, cr)
Expand Down
Loading