Skip to content

Commit

Permalink
Merge branch 'main' into restore_arm64_macos
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj authored Aug 13, 2024
2 parents d111297 + 2825e1f commit 7b6d69e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ jobs:
- name: Run Tests
run: |
set -e
pip check
rm -rf qiskit_aer
stestr run --slowest
shell: bash
Expand Down
6 changes: 4 additions & 2 deletions qiskit_aer/backends/aer_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def _inline_initialize(self, circ, optype):
if isinstance(optype, set) and Initialize not in optype:
return circ

for inst, _, _ in circ.data:
for datum in circ.data:
inst = datum.operation
if isinstance(inst, Initialize) and (
(not isinstance(inst.params[0], complex)) or (len(inst.params) == 1)
):
Expand All @@ -133,7 +134,8 @@ def _inline_initialize(self, circ, optype):

new_circ = circ.copy()
new_circ.data = []
for inst, qargs, cargs in circ.data:
for datum in circ.data:
inst, qargs, cargs = datum.operation, datum.qubits, datum.clbits
if isinstance(inst, Initialize) and (
(not isinstance(inst.params[0], complex)) or (len(inst.params) == 1)
):
Expand Down
3 changes: 2 additions & 1 deletion qiskit_aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ def _assemble_noise_model(self, circuits, optypes, **run_options):
):
updated_circ = False
new_data = []
for inst, qargs, cargs in circ.data:
for datum in circ.data:
inst, qargs, cargs = datum.operation, datum.qubits, datum.clbits
if isinstance(inst, QuantumChannelInstruction):
updated_circ = True
if not updated_noise:
Expand Down
4 changes: 2 additions & 2 deletions qiskit_aer/primitives/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
from qiskit.circuit import ParameterExpression, QuantumCircuit
from qiskit.compiler import transpile
from qiskit.exceptions import QiskitError
from qiskit.primitives import BaseSampler, SamplerResult
from qiskit.primitives import BaseSamplerV1, SamplerResult
from qiskit.primitives.utils import final_measurement_mapping, init_circuit
from qiskit.result import QuasiDistribution

from .. import AerSimulator


class Sampler(BaseSampler):
class Sampler(BaseSamplerV1):
"""
Aer implementation of Sampler class.
Expand Down
3 changes: 3 additions & 0 deletions test/terra/backends/test_parameterized_qobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from test.terra import common

import qiskit
from qiskit.compiler import assemble, transpile
from qiskit.circuit import QuantumCircuit, Parameter
from test.terra.reference.ref_save_expval import (
Expand Down Expand Up @@ -72,6 +73,7 @@ def parameterized_qobj(
qobj = assemble(circuits, backend=backend, shots=shots, parameterizations=params)
return qobj

@unittest.skipIf(qiskit.__version__.startswith("1.2"), "skip Qiskit 1.2 tentatively")
def test_parameterized_qobj_qasm_save_expval(self):
"""Test parameterized qobj with Expectation Value snapshot and qasm simulator."""
shots = 1000
Expand All @@ -95,6 +97,7 @@ def test_parameterized_qobj_qasm_save_expval(self):
for label in labels:
self.assertAlmostEqual(data[label], target[label], delta=1e-7)

@unittest.skipIf(qiskit.__version__.startswith("1.2"), "skip Qiskit 1.2 tentatively")
def test_parameterized_qobj_statevector(self):
"""Test parameterized qobj with Expectation Value snapshot and qasm simulator."""
statevec_targets = save_expval_final_statevecs() * 3
Expand Down
3 changes: 3 additions & 0 deletions test/terra/backends/test_runtime_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from test.terra import common

import qiskit
from qiskit.compiler import assemble, transpile
from qiskit.circuit import QuantumCircuit, Parameter
from test.terra.reference.ref_save_expval import (
Expand Down Expand Up @@ -89,6 +90,7 @@ def runtime_parameterization(
qobj = assemble(circuits, backend=backend, shots=shots, parameterizations=params)
return qobj

@unittest.skipIf(qiskit.__version__.startswith("1.2"), "skip Qiskit 1.2 tentatively")
def test_runtime_parameterization_qasm_save_expval(self):
"""Test parameterized qobj with Expectation Value snapshot and qasm simulator."""
shots = 1000
Expand All @@ -114,6 +116,7 @@ def test_runtime_parameterization_qasm_save_expval(self):
for label in labels:
self.assertAlmostEqual(data[label], target[label], delta=1e-7)

@unittest.skipIf(qiskit.__version__.startswith("1.2"), "skip Qiskit 1.2 tentatively")
def test_runtime_parameterization_statevector(self):
"""Test parameterized qobj with Expectation Value snapshot and qasm simulator."""
statevec_targets = save_expval_final_statevecs() * 3
Expand Down

0 comments on commit 7b6d69e

Please sign in to comment.