• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

qiskit-community / qiskit-aqt-provider / 9255177207

27 May 2024 12:52PM UTC coverage: 99.736%. Remained the same
9255177207

push

github

web-flow
Prepare release 1.5.0 (#161)

2267 of 2273 relevant lines covered (99.74%)

3.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/examples/quickstart-sampler.py
1
# This code is part of Qiskit.
2
#
3
# (C) Copyright Alpine Quantum Technologies GmbH 2023
4
#
5
# This code is licensed under the Apache License, Version 2.0. You may
6
# obtain a copy of this license in the LICENSE.txt file in the root directory
7
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
#
9
# Any modifications or derivative works of this code must retain this
10
# copyright notice, and modified files need to carry a notice indicating
11
# that they have been altered from the originals.
12

13
"""Quickstart example on using the Sampler primitive.
4✔
14

15
This example samples a 2-qubit Bell state.
16
"""
17

18
from qiskit import QuantumCircuit
4✔
19

20
from qiskit_aqt_provider import AQTProvider
4✔
21
from qiskit_aqt_provider.primitives import AQTSampler
4✔
22

23
# Define a circuit
24
circuit = QuantumCircuit(2)
4✔
25
circuit.h(0)
4✔
26
circuit.cx(0, 1)
4✔
27
circuit.measure_all()
4✔
28

29
# Select an execution backend
30
provider = AQTProvider("ACCESS_TOKEN")
4✔
31
backend = provider.get_backend("offline_simulator_no_noise")
4✔
32

33
# Instantiate a sampler on the execution backend
34
sampler = AQTSampler(backend)
4✔
35

36
# Set the transpiler's optimization level
37
sampler.set_transpile_options(optimization_level=3)
4✔
38

39
# Sample the circuit on the execution backend
40
result = sampler.run(circuit).result()
4✔
41

42
quasi_dist = result.quasi_dists[0]
4✔
43
print(quasi_dist)
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc