Skip to main content

package containing utility methods for qiskit like result parsing and instruction insertion for circuits

Project description

qiskit-utils

qiskit-utils is a library containing utility, quality of life methods for qiskit.

current methods

  • parsing results
  • inserting instructions and gates into circuit (in any location not just append the gate to the circuit)

Inserting instructions

from qiskit_utils import insert_instruction

instruction = Measure()
insert_instruction(circuit, instruction, (circuit.qubits[0],), (circuit.clbits[1], ), index)

QuantumCircuitEnhanced

from qiskit.circuit.library import iSwapGate
from qiskit_utils import QuantumCircuitEnhanced

qc = QuantumCircuitEnhanced(2)
qc.insert(iSwapGate(), (0, 1), (,), index)

Result parsing

parse_result method allows to find the counts for each specific qubit individually (and allows for easy access to check counts for that one specific qubit, independent of the other qubit states)

qc = QuantumCircuit(1, 1)
qc.x(0)
qc.measure(0, 0)
backend = Aer.get_backend("aer_simulator")
transpiled_circuit = transpile(circuit, backend)
result = backend.run(transpiled_circuit).result()

parsed_counts = parse_result(result, qc)
# parsed_counts = {0: {'0': 0, '1': 1024}} 

2 return types are possible, with using the flag indexed_results=True resulting directory keys (the most upper level) will be indexes of qubits (indexes will be same as in qc.qubits), with the flag set to false qubits will be returned indexed by the qubit object itself (can be received either from qc.qubits[i] or QuantumRegister()[i])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qiskit_utils-1.1.1.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file qiskit_utils-1.1.1.tar.gz.

File metadata

  • Download URL: qiskit_utils-1.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.0

File hashes

Hashes for qiskit_utils-1.1.1.tar.gz
Algorithm Hash digest
SHA256 2b9f51a26b88b6cfb793afc9949eba7ba5aaa8d507bb8a3ef890ffcdc84a730f
MD5 2b30ed746932ab0076433b232475342c
BLAKE2b-256 d45716d334df51bf41e4624d7e339e65374a8e3cf739da63d4624d7e76d2ef5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page