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

Remove use of opflow in Estimator #1996

Merged
merged 1 commit into from
Nov 14, 2023
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
5 changes: 2 additions & 3 deletions qiskit_aer/primitives/estimator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
# (C) Copyright IBM 2022, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -23,7 +23,6 @@
import numpy as np
from qiskit.circuit import ParameterExpression, QuantumCircuit
from qiskit.compiler import transpile
from qiskit.opflow import PauliSumOp
from qiskit.primitives import BaseEstimator, EstimatorResult
from qiskit.primitives.primitive_job import PrimitiveJob
from qiskit.primitives.utils import _circuit_key, _observable_key, init_observable
Expand Down Expand Up @@ -174,7 +173,7 @@ def _call(
def _run(
self,
circuits: Sequence[QuantumCircuit],
observables: Sequence[BaseOperator | PauliSumOp],
observables: Sequence[BaseOperator],
parameter_values: Sequence[Sequence[float]],
**run_options,
) -> PrimitiveJob:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
upgrade:
- |
The :meth:`qiskit_aer.primitives.Estimator.run` method no longer supports
``observables`` input arguments of type ``PauliSumOp``. The ``PauliSumOp``
class was deprecated in Qiskit 0.44 and will be removed in Qiskit 1.0.
Alternative types that you can use instead of ``PauliSumOp`` are
:class:`qiskit.quantum_info.SparsePauliOp` or :class:`qiskit.quantum_info.Pauli`.
16 changes: 1 addition & 15 deletions test/terra/primitives/test_estimator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
# (C) Copyright IBM 2022, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -23,7 +23,6 @@
from qiskit.circuit import Parameter, QuantumCircuit
from qiskit.circuit.library import RealAmplitudes
from qiskit.exceptions import QiskitError
from qiskit.opflow import PauliSumOp
from qiskit.primitives import EstimatorResult
from qiskit.quantum_info import Operator, SparsePauliOp

Expand Down Expand Up @@ -53,19 +52,6 @@ def setUp(self):
def test_estimator(self, abelian_grouping):
"""test for a simple use case"""
lst = [("XX", 1), ("YY", 2), ("ZZ", 3)]
with self.assertWarns(DeprecationWarning):
with self.subTest("PauliSumOp"):
observable = PauliSumOp.from_list(lst)
ansatz = RealAmplitudes(num_qubits=2, reps=2)
est = Estimator(
backend_options={"method": "statevector"}, abelian_grouping=abelian_grouping
)
result = est.run(
ansatz, observable, parameter_values=[[0, 1, 1, 2, 3, 5]], seed=15
).result()
self.assertIsInstance(result, EstimatorResult)
np.testing.assert_allclose(result.values, [1.728515625])

with self.subTest("SparsePauliOp"):
observable = SparsePauliOp.from_list(lst)
ansatz = RealAmplitudes(num_qubits=2, reps=2)
Expand Down