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

Use qiskit_algorithms instead of deprecated qiskit.algorithms #110

Merged
merged 4 commits 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
3 changes: 3 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ ignore_missing_imports = True
[mypy-qiskit_aer.*]
ignore_missing_imports = True

[mypy-qiskit_algorithms.*]
ignore_missing_imports = True

[mypy-qiskit_experiments.*]
ignore_missing_imports = True

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* Set minimal required `qiskit` version to 0.45.0 (#108)
* Use `qiskit-algorithms` package instead of deprecated `qiskit.algorithms` in examples (#110)

## qiskit-aqt-provider v0.19.0

Expand Down
2 changes: 1 addition & 1 deletion examples/grover-3-sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import textwrap
from typing import Final, Set, Tuple

from qiskit.algorithms import AmplificationProblem, Grover
from qiskit.circuit.library.phase_oracle import PhaseOracle
from qiskit_algorithms import AmplificationProblem, Grover

from qiskit_aqt_provider import AQTProvider
from qiskit_aqt_provider.primitives import AQTSampler
Expand Down
8 changes: 4 additions & 4 deletions examples/number_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
from dataclasses import dataclass
from typing import Final, List, Set, Union

from qiskit.algorithms.minimum_eigensolvers import QAOA
from qiskit.algorithms.optimizers import COBYLA
from qiskit.utils import algorithm_globals
import qiskit_algorithms
from qiskit_algorithms.minimum_eigensolvers import QAOA
from qiskit_algorithms.optimizers import COBYLA
from qiskit_optimization.algorithms import MinimumEigenOptimizer, OptimizationResultStatus
from qiskit_optimization.applications import NumberPartition

Expand Down Expand Up @@ -81,7 +81,7 @@ def solve_partition_problem(num_set: Set[int]) -> Union[Success, Infeasible]:
backend = AQTProvider("token").get_backend("offline_simulator_no_noise")

# fix the random seeds such that the example is reproducible
algorithm_globals.random_seed = RANDOM_SEED
qiskit_algorithms.utils.algorithm_globals.random_seed = RANDOM_SEED
backend.simulator.options.seed_simulator = RANDOM_SEED

num_set = {1, 3, 4}
Expand Down
8 changes: 4 additions & 4 deletions examples/qaoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

from typing import Final

from qiskit.algorithms.minimum_eigensolvers import QAOA
from qiskit.algorithms.optimizers import COBYLA
import qiskit_algorithms
from qiskit.quantum_info import SparsePauliOp
from qiskit.utils import algorithm_globals
from qiskit_algorithms.minimum_eigensolvers import QAOA
from qiskit_algorithms.optimizers import COBYLA

from qiskit_aqt_provider import AQTProvider
from qiskit_aqt_provider.primitives import AQTSampler
Expand All @@ -32,7 +32,7 @@
sampler = AQTSampler(backend)

# fix the random seeds such that the example is reproducible
algorithm_globals.random_seed = RANDOM_SEED
qiskit_algorithms.utils.algorithm_globals.random_seed = RANDOM_SEED
backend.simulator.options.seed_simulator = RANDOM_SEED

# Hamiltonian: Ising model on two spin 1/2 without external field
Expand Down
8 changes: 4 additions & 4 deletions examples/vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from typing import Final

from qiskit.algorithms.minimum_eigensolvers import VQE
from qiskit.algorithms.optimizers import COBYLA
import qiskit_algorithms
from qiskit.circuit.library import TwoLocal
from qiskit.quantum_info import SparsePauliOp
from qiskit.utils import algorithm_globals
from qiskit_algorithms.minimum_eigensolvers import VQE
from qiskit_algorithms.optimizers import COBYLA

from qiskit_aqt_provider import AQTProvider
from qiskit_aqt_provider.aqt_resource import OfflineSimulatorResource
Expand All @@ -32,7 +32,7 @@
estimator = AQTEstimator(backend)

# fix the random seeds such that the example is reproducible
algorithm_globals.random_seed = RANDOM_SEED
qiskit_algorithms.utils.algorithm_globals.random_seed = RANDOM_SEED
backend.simulator.options.seed_simulator = RANDOM_SEED

# Hamiltonian: Ising model on two spin 1/2 without external field
Expand Down
39 changes: 28 additions & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ pydantic = ">=1.10.8,<2"
python-dotenv = ">=1"
qiskit = ">=0.45.0"
qiskit-aer = ">=0.11"
qiskit-optimization = { version = ">=0.5.0", optional = true }
qiskit-algorithms = { version = ">=0.2.1", optional = true }
qiskit-optimization = { version = ">=0.6.0", optional = true }
tabulate = ">=0.9.0"
tqdm = ">=4"
tweedledum = { version = ">=1", optional = true }
Expand Down Expand Up @@ -94,7 +95,8 @@ examples-problematic = [
"tweedledum"
]
examples = [
"qiskit-optimization"
"qiskit-algorithms",
"qiskit-optimization",
]

[build-system]
Expand Down