• 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/example.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
"""Basic example with the Qiskit AQT provider. Creates a 4-qubit GHZ state."""
4✔
14

15
import qiskit
4✔
16
from qiskit import QuantumCircuit
4✔
17

18
from qiskit_aqt_provider.aqt_provider import AQTProvider
4✔
19

20
if __name__ == "__main__":
4✔
21
    # Ways to specify an access token (in precedence order):
22
    # - as argument to the AQTProvider initializer
23
    # - in the AQT_TOKEN environment variable
24
    # - if none of the above exists, default to an empty string, which restricts access
25
    #   to the default workspace only.
26
    provider = AQTProvider("token")
4✔
27

28
    # The backends() method lists all available computing backends. Printing it
29
    # renders it as a table that shows each backend's containing workspace.
30
    print(provider.backends())
4✔
31

32
    # Retrieve a backend by providing search criteria. The search must have a single
33
    # match. For example:
34
    backend = provider.get_backend("offline_simulator_no_noise", workspace="default")
4✔
35

36
    # Define a quantum circuit that produces a 4-qubit GHZ state.
37
    qc = QuantumCircuit(4)
4✔
38
    qc.h(0)
4✔
39
    qc.cx(0, 1)
4✔
40
    qc.cx(0, 2)
4✔
41
    qc.cx(0, 3)
4✔
42
    qc.measure_all()
4✔
43

44
    # Transpile for the target backend.
45
    qc = qiskit.transpile(qc, backend)
4✔
46

47
    # Execute on the target backend.
48
    result = backend.run(qc, shots=200).result()
4✔
49

50
    if result.success:
4✔
51
        print(result.get_counts())
4✔
52
    else:  # pragma: no cover
53
        print(result.to_dict()["error"])
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