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 Sampler.close, assert DeprecationWarning of opflow, and update dependency #1804

Merged
merged 3 commits into from
May 10, 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
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
needs: [docs]
strategy:
matrix:
python-version: [3.7]
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
7 changes: 0 additions & 7 deletions qiskit_aer/primitives/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def __init__(
skip_transpilation: if True, transpilation is skipped.
"""
super().__init__(options=run_options)
self._is_closed = False
self._backend = AerSimulator()
backend_options = {} if backend_options is None else backend_options
self._backend.set_options(**backend_options)
Expand All @@ -82,9 +81,6 @@ def _call(
parameter_values: Sequence[Sequence[float]],
**run_options,
) -> SamplerResult:
if self._is_closed:
raise QiskitError("The primitive has been closed.")

seed = run_options.pop("seed", None)
if seed is not None:
run_options.setdefault("seed_simulator", seed)
Expand Down Expand Up @@ -158,9 +154,6 @@ def _run(
job.submit()
return job

def close(self):
self._is_closed = True

@staticmethod
def _preprocess_circuit(circuit: QuantumCircuit):
circuit = init_circuit(circuit)
Expand Down
19 changes: 10 additions & 9 deletions test/terra/primitives/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ def setUp(self):
def test_estimator(self, abelian_grouping):
"""test for a simple use case"""
lst = [("XX", 1), ("YY", 2), ("ZZ", 3)]
with self.subTest("PauliSumOp"):
observable = PauliSumOp.from_list(lst)
ansatz = RealAmplitudes(num_qubits=2, reps=2)
est = Estimator(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.assertWarns(DeprecationWarning):
with self.subTest("PauliSumOp"):
observable = PauliSumOp.from_list(lst)
ansatz = RealAmplitudes(num_qubits=2, reps=2)
est = Estimator(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)
Expand Down