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 and qi in tests #35

Merged
merged 1 commit into from
Nov 9, 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
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 @@ -13,10 +13,13 @@
"""Tests for quantum neural networks classifier."""
import numpy as np
from ddt import ddt, data
from qiskit_algorithms.optimizers import COBYLA
from qiskit_algorithms.utils import algorithm_globals

from qiskit.primitives import Sampler as ReferenceSampler
from qiskit_aer.primitives import Sampler as AerSampler

from qiskit_algorithms.optimizers import COBYLA
from qiskit_algorithms.utils import algorithm_globals

from qiskit_machine_learning.algorithms.classifiers import VQC

from qiskit_neko import decorators
Expand Down
64 changes: 0 additions & 64 deletions qiskit_neko/tests/machine_learning/test_neural_networks.py

This file was deleted.

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 @@ -18,6 +18,7 @@
from qiskit.circuit import Parameter
from qiskit.primitives import Sampler as ReferenceSampler, Estimator as ReferenceEstimator
from qiskit.quantum_info import SparsePauliOp

from qiskit_aer.primitives import Sampler as AerSampler, Estimator as AerEstimator
from qiskit_machine_learning.neural_networks import SamplerQNN, EstimatorQNN

Expand Down

This file was deleted.

19 changes: 10 additions & 9 deletions qiskit_neko/tests/primitives/test_vqe.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 @@ -12,13 +12,14 @@

"""Test primitives with vqe."""

from qiskit_algorithms import VQE, SamplingVQE
from qiskit_algorithms.optimizers import SPSA
from qiskit.circuit.library import TwoLocal
from qiskit.opflow import PauliSumOp
from qiskit.primitives import BackendEstimator, BackendSampler
from qiskit.quantum_info import SparsePauliOp
from qiskit.utils import algorithm_globals

from qiskit_algorithms import VQE, SamplingVQE
from qiskit_algorithms.optimizers import SPSA
from qiskit_algorithms.utils import algorithm_globals

from qiskit_aer.primitives import Estimator, Sampler

from qiskit_neko import decorators
Expand All @@ -38,7 +39,7 @@ def setUp(self):
def test_sampling_vqe(self):
"""Test the execution of SamplingVQE with BackendSampler."""
sampler = BackendSampler(self.backend)
operator = PauliSumOp(SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12]))
operator = SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12])
ansatz = TwoLocal(rotation_blocks=["ry", "rz"], entanglement_blocks="cz")
optimizer = SPSA()
sampling_vqe = SamplingVQE(sampler, ansatz, optimizer)
Expand All @@ -51,7 +52,7 @@ def test_sampling_vqe(self):
def test_aer_sampling_vqe(self):
"""Test the aer sampler with SamplingVQE."""
sampler = Sampler(backend_options={"seed_simulator": 42})
operator = PauliSumOp(SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12]))
operator = SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12])
ansatz = TwoLocal(rotation_blocks=["ry", "rz"], entanglement_blocks="cz")
optimizer = SPSA()
sampling_vqe = SamplingVQE(sampler, ansatz, optimizer)
Expand All @@ -64,7 +65,7 @@ def test_aer_sampling_vqe(self):
def test_vqe(self):
"""Test the execution of VQE with BackendEstimator."""
estimator = BackendEstimator(self.backend)
operator = PauliSumOp(SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12]))
operator = SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12])
ansatz = TwoLocal(rotation_blocks=["ry", "rz"], entanglement_blocks="cz")
optimizer = SPSA()
sampling_vqe = VQE(estimator, ansatz, optimizer)
Expand All @@ -77,7 +78,7 @@ def test_vqe(self):
def test_aer_vqe(self):
"""Test the execution of VQE with Aer Estimator."""
estimator = Estimator(backend_options={"seed_simulator": 42})
operator = PauliSumOp(SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12]))
operator = SparsePauliOp(["ZZ", "IZ", "II"], coeffs=[1, -0.5, 0.12])
ansatz = TwoLocal(rotation_blocks=["ry", "rz"], entanglement_blocks="cz")
optimizer = SPSA()
sampling_vqe = VQE(estimator, ansatz, optimizer)
Expand Down
Loading