repo stringclasses 885
values | file stringclasses 741
values | content stringlengths 4 215k |
|---|---|---|
https://github.com/carstenblank/dc-qiskit-stochastics | carstenblank | # Copyright 2018-2022 Carsten Blank
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... |
https://github.com/AmirhoseynpowAsghari/Qiskit-Tutorials | AmirhoseynpowAsghari |
import random
import matplotlib.pyplot as plt
def generate_n_bit_inputs(n):
"""Generate all possible n-bit inputs."""
return [bin(i)[2:].zfill(n) for i in range(2**n)]
def constant_function(value):
"""Returns a constant function that always returns the given value."""
return lambda x: val... |
https://github.com/shantomborah/Quantum-Algorithms | shantomborah | """Performance Analysis of 3 Qubit Code under Bit Flip Error"""
import noise
import numpy as np
import matplotlib.pyplot as plt
from qiskit import QuantumCircuit, ClassicalRegister
from qiskit import Aer, execute
from qiskit.quantum_info import partial_trace, state_fidelity
from qiskit.quantum_info import De... |
https://github.com/1chooo/Quantum-Oracle | 1chooo | from qiskit import QuantumCircuit, Aer
from qiskit.visualization import array_to_latex
sim = Aer.get_backend("aer_simulator")
qc = QuantumCircuit(2)
qc.cx(0, 1)
display(qc.draw("mpl"))
qc.save_unitary()
unitary = sim.run(qc).result().get_unitary()
display(array_to_latex(unitary, prefix="\\text{CNOT (LSB as Ta... |
https://github.com/rochisha0/quantum-ugly-duckling | rochisha0 | #importing libraries
from qiskit import QuantumCircuit, QuantumRegister, Aer, execute, IBMQ
from qiskit.visualization import plot_histogram
from qiskit.tools.monitor import job_monitor
provider = IBMQ.load_account()
backend = provider.backends.ibmqx2
real_circ = QuantumCircuit(3, 3)
for i in range(200):
... |
https://github.com/hugoecarl/TSP-Problem-Study | hugoecarl | import math
import matplotlib.pyplot as plt
%matplotlib inline
class TSP:
def __init__(self):
self.flat_mat = flat_mat
self.n = 0
self.melhor_dist = 1e11
self.pontos = []
self.melhores_pontos = []
def busca_exaustiva(self, flat_mat, n, ite):
... |
https://github.com/BOBO1997/osp_solutions | BOBO1997 | import numpy as np
import matplotlib.pyplot as plt
import itertools
from pprint import pprint
import pickle
import time
import datetime
# Import qubit states Zero (|0>) and One (|1>), and Pauli operators (X, Y, Z)
from qiskit.opflow import Zero, One, I, X, Y, Z
from qiskit import QuantumCircuit, QuantumRegis... |
https://github.com/Z-928/Bugs4Q | Z-928 | from qiskit import *
qc = QuantumCircuit(2)
qc.h(i)
qc.crz (PI/4, 0, 1)
|
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile, schedule
from qiskit.visualization.pulse_v2 import draw, IQXSimple
from qiskit.providers.fake_provider import FakeBoeblingen
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
qc = transpile(qc, FakeBoeblingen(), layout_method='trivial')
sched = schedule(... |
https://github.com/QuCO-CSAM/Solving-Combinatorial-Optimisation-Problems-Using-Quantum-Algorithms | QuCO-CSAM | # Important libraries and modules
import numpy as np
from itertools import permutations
import gzip
from qiskit import*
import time
from qiskit.aqua.algorithms import VQE
from qiskit.aqua.algorithms import QAOA
from qiskit.aqua.components.optimizers import SPSA
from qiskit.aqua import QuantumInst... |
https://github.com/Z-928/Bugs4Q | Z-928 | from qiskit import Aer, QuantumCircuit
from qiskit.circuit.library import PhaseEstimation
qc= QuantumCircuit(3,3)
# dummy unitary circuit
unitary_circuit = QuantumCircuit(1)
unitary_circuit.h(0)
# QPE
qc.append(PhaseEstimation(2, unitary_circuit), list(range(3)))
qc.measure(list(range(3)), list(range(3)))
back... |
https://github.com/mlvqc/Byskit | mlvqc | from qiskit import IBMQ
IBMQ.load_account()
# provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
#provider = IBMQ.get_provider(hub='ibm-q-oxford', group='on-boarding', project='on-boarding-proj')
from qiskit import BasicAer
backend = BasicAer.get_backend('qasm_simulator')
# Include matplo... |
https://github.com/C2QA/bosonic-qiskit | C2QA | # To use the package locally, add the C2QA repository's root folder to the path prior to importing c2qa.
import os
import sys
module_path = os.path.abspath(os.path.join("../.."))
if module_path not in sys.path:
sys.path.append(module_path)
# Cheat to get MS Visual Studio Code Jupyter server to recognize Pyt... |
https://github.com/DaisukeIto-ynu/KosakaQ | DaisukeIto-ynu | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019, 2020.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from __future__ import annotations
import numpy as np
import networkx as nx
num_nodes = 4
w = np.array([[0., 1., 1., 0.],
[1., 0., 1., 1.],
[1., 1., 0., 1.],
[0., 1., 1., 0.]])
G = nx.from_numpy_array(w)
layout = nx.random_layout(G, seed=10)
colors = ['r', 'g', ... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit.visualization.timeline import draw as timeline_draw
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeBoeblingen
backend = FakeBoeblingen()
ghz = QuantumCircuit(5)
ghz.h(0)
ghz.cx(0,range(1,5))
circ = transpile(ghz, backend, scheduling_method="asap")
... |
https://github.com/qiskit-community/qiskit-alt | qiskit-community | import subprocess
def python_commands(commands):
try:
result = subprocess.run(
['python', '-c', commands], check=True, capture_output=True, encoding='utf8'
)
except subprocess.CalledProcessError as err:
return err
return result
def basic_inits():
all_c... |
https://github.com/alejomonbar/Quantum-Supply-Chain-Manager | alejomonbar | %load_ext autoreload
%autoreload 2
#pip install pennyane
#improt pennylane dependnecies
import pennylane as qml
from pennylane import numpy as np
from pennylane.optimize import NesterovMomentumOptimizer
from sklearn.preprocessing import StandardScaler
# load the csv files
import pandas as pd
# plot ... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile, schedule
from qiskit.visualization.timeline import draw, IQXSimple
from qiskit.providers.fake_provider import FakeBoeblingen
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc = transpile(qc, FakeBoeblingen(), scheduling_method='alap', layout_method='trivial')
draw(qc,... |
https://github.com/nahumsa/volta | nahumsa | import numpy as np
from qiskit.aqua.operators import I, X, Y, Z
import matplotlib.pyplot as plt
%load_ext autoreload
%autoreload 2
def BCS_hamiltonian(epsilons, V):
return ((1/2*epsilons[0]*I^Z) + (1/2*epsilons[1]*Z^I) + V*(1/2*(X^X) + 1/2*(Y^Y)))
EPSILONS = [1,1]
V = 2
hamiltonian = BCS_hamiltonian(EP... |
https://github.com/wyqian1027/Qiskit-Fall-Fest-USC-2022 | wyqian1027 | import numpy as np
from qiskit import QuantumCircuit, Aer, execute
from qiskit.visualization import plot_bloch_multivector, array_to_latex
from grader import *
language(True)
phi_plus = QuantumCircuit(2)
phi_plus.h(0)
phi_plus.cnot(0, 1)
phi_plus.draw('mpl')
# Simulamos para ver su resultado
backend = Aer... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit.library.standard_gates import HGate
qc1 = QuantumCircuit(2)
qc1.x(0)
qc1.h(1)
custom = qc1.to_gate().control(2)
qc2 = QuantumCircuit(4)
qc2.append(custom, [0, 3, 1, 2])
qc2.draw('mpl') |
https://github.com/abbarreto/qiskit4 | abbarreto | from qiskit import *
import numpy as np
import math
from matplotlib import pyplot as plt
import qiskit
nshots = 8192
IBMQ.load_account()
provider = qiskit.IBMQ.get_provider(hub='ibm-q', group='open', project='main')
device = provider.get_backend('ibmq_belem')
simulator = Aer.get_backend('qasm_simulator')
from... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import qiskit
import qiskit_aer
def test_qiskit():
"""Verify we can do a simple QisKit circuit without our custom gates."""
qr = qiskit.QuantumRegister(6)
cr = qiskit.ClassicalRegister(6)
circuit = qiskit.circuit.QuantumCircuit(qr, cr)
circuit.cx(qr[0:1], qr[2])
circuit.save_statevec... |
https://github.com/JessicaJohnBritto/Quantum-Computing-and-Information | JessicaJohnBritto | import pennylane as qml
from pennylane import numpy as np
import matplotlib.pyplot as plt
dev = qml.device("default.qubit", wires=1)
@qml.qnode(dev)
def apply_z_to_plus():
"""Write a circuit that applies PauliZ to the |+> state and returns
the state.
Returns:
array[complex]: The state... |
https://github.com/mcoggins96/Quantum-Computing-UK-Repository | mcoggins96 | from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, IBMQ
IBMQ.enable_account('Insert account token here') # Get this from your IBM Q account
provider = IBMQ.get_provider(hub='ibm-q')
q = QuantumRegister(1,'q') # Initialise quantum register
c = ClassicalRegister(1,'c') # Initialise ... |
https://github.com/PabloMartinezAngerosa/QAOA-uniform-convergence | PabloMartinezAngerosa | from tsp_qaoa import test_solution
from qiskit.visualization import plot_histogram
import networkx as nx
import numpy as np
import json
import csv
# Array of JSON Objects
# Sort the JSON data based on the value of the brand key
UNIFORM_CONVERGENCE_SAMPLE.sort(key=lambda x: x["mean"])
# genera las d... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | # Necessary imports
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import clear_output
from qiskit import QuantumCircuit
from qiskit.algorithms.optimizers import COBYLA
from qiskit.circuit.library import ZFeatureMap, RealAmplitudes
from qiskit.utils import algorithm_globals
from sklearn... |
https://github.com/xtophe388/QISKIT | xtophe388 | #initialization
import sys
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
# importing the QISKit
from qiskit import QuantumProgram
try:
sys.path.append("../../") # go to parent dir
import Qconfig
qx_config = {
"APItoken": Qconfig.APItoken,
"url": Qconfig.... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit_optimization import QuadraticProgram
from qiskit_optimization.translators import from_docplex_mp
# Make a Docplex model
from docplex.mp.model import Model
mdl = Model("docplex model")
x = mdl.binary_var("x")
y = mdl.integer_var(lb=-1, ub=5, name="y")
mdl.minimize(x + 2 * y)
mdl.add_constraint(x ... |
https://github.com/xtophe388/QISKIT | xtophe388 | from qiskit import ClassicalRegister, QuantumRegister
from qiskit import QuantumCircuit, execute
from qiskit.tools.visualization import plot_histogram
#Set up the quantum and classical registers, and combine them into a circuit
qr = QuantumRegister(1)
cr = ClassicalRegister(1)
qc = QuantumCircuit(qr, cr)
qc.... |
https://github.com/ElePT/qiskit-algorithms-test | ElePT | # This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2022.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile
from qiskit.visualization import plot_circuit_layout
from qiskit.providers.fake_provider import FakeVigo
backend = FakeVigo()
ghz = QuantumCircuit(3, 3)
ghz.h(0)
ghz.cx(0,range(1,3))
ghz.barrier()
ghz.measure(range(3), range(3))
ghz.draw(output='mpl') |
https://github.com/JouziP/MQITE | JouziP | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 4 17:53:16 2022
@author: pejmanjouzdani
"""
import logging
from time import time
class TestCirc:
def __init__(self, func, FLAG=False):
self.func = func
self.func.name = func.__name__
self.FLAG... |
https://github.com/hugoecarl/TSP-Problem-Study | hugoecarl | with open('in-exemplo.txt', 'r') as f:
print(f.read())
with open('out-exemplo.txt', 'r') as f:
print(f.read())
import time
import matplotlib.pyplot as plt
import pandas as pd
import os
import subprocess
%matplotlib inline
#Roda entradas
def roda_com_entrada(executavel, arquivo_in, envs = '1', d... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/h-rathee851/Pulse_application_qiskit | h-rathee851 | from calibration import *
IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q-research', group='iserc-1', project='main')
"""
Object to calibrate pulse of backend and qubit of interest.
"""
# Importing required python packages
from warnings import warn
import numpy as np
import matplotlib.pyplot ... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | %matplotlib inline
from qiskit_finance import QiskitFinanceError
from qiskit_finance.data_providers import *
import datetime
import matplotlib.pyplot as plt
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
data = RandomDataProvider(
tickers=["TICKER1", "TICKER2... |
https://github.com/infiniteregrets/QiskitBot | infiniteregrets | LIB_IMPORT = """
from qiskit import QuantumCircuit
from qiskit import execute, Aer
from qiskit.visualization import *"""
CIRCUIT_SCRIPT = """
circuit = build_state()
circuit.measure_all()
figure = circuit.draw('mpl')
output = figure.savefig('circuit.png')"""
PLOT_SCRIPT = """
backend = Aer.get_backend("qa... |
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations | GabrielPontolillo | import warnings
from qiskit import QuantumRegister, ClassicalRegister
from qiskit import QuantumCircuit, Aer, transpile, assemble
from qiskit.tools.monitor import job_monitor
from qiskit.circuit.library import QFT
from qiskit.visualization import plot_histogram, plot_bloch_multivector
warnings.filterwarnings("i... |
https://github.com/ronitd2002/IBM-Quantum-challenge-2024 | ronitd2002 | # qc-grader should be 0.18.11 (or higher)
import qc_grader
qc_grader.__version__
# Imports
import numpy as np
import matplotlib.pyplot as plt
from qiskit import QuantumCircuit
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.visualization import plot_gate_map
fro... |
https://github.com/jonasmaziero/computacao_quantica_qiskit | jonasmaziero | pip install qiskit
import qiskit
qiskit.__qiskit_version__
pip install qiskit-ibm-runtime
from qiskit_ibm_runtime import QiskitRuntimeService
QiskitRuntimeService.save_account(channel="ibm_quantum", token="463bc61b55d82149a7ec719c9e89eeb8bc80a916eac5331f2d98fc35be2b4650af627d457593b0050910aa0bd4a0f1e3a8361... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile, schedule
from qiskit.visualization.pulse_v2 import draw, IQXDebugging
from qiskit.providers.fake_provider import FakeBoeblingen
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
qc = transpile(qc, FakeBoeblingen(), layout_method='trivial')
sched = schedu... |
https://github.com/ionq-samples/qiskit-getting-started | ionq-samples | #import Aer here, before calling qiskit_ionq_provider
from qiskit import Aer
from qiskit_ionq import IonQProvider
#Call provider and set token value
provider = IonQProvider(token='my token')
provider.backends()
from qiskit import QuantumCircuit, QuantumRegister
from math import pi
def get_qc(p):
... |
https://github.com/cjsproject/qiskit_learning | cjsproject | import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn
from sklearn import datasets
from qiskit import QuantumRegister, ClassicalRegister
from qiskit import QuantumRegister
from qiskit import QuantumCircuit
from qiskit import Aer, execute
from math import pi,log
from qiskit im... |
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial | shesha-raghunathan | from qiskit import *
IBMQ.load_accounts(hub=None)
from qiskit.tools.jupyter import *
from qiskit.tools.monitor import job_monitor
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q, c);
from qiskit.providers.ibmq import least_busy
bac... |
https://github.com/menegolli/Quantum_synth | menegolli | #!/usr/bin/env python
# coding: utf-8
# In[1]:
from qiskit import *
import numpy as np
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute
from qiskit import Aer, IBMQ # import the Aer and IBMQ providers
from qiskit.providers.aer import noise # import Aer noise models
from qis... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.quantum_info import DensityMatrix
from qiskit.visualization import plot_state_city
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
# plot using a DensityMatrix
state = DensityMatrix(qc)
plot_state_city(state) |
https://github.com/qiskit-community/qiskit-dell-runtime | qiskit-community | from dell_runtime import DellRuntimeProvider
from qiskit import QuantumCircuit
RUNTIME_PROGRAM = """
# This code is part of qiskit-runtime.
#
# (C) Copyright IBM 2021.
#
# 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 d... |
https://github.com/vm6502q/qiskit-qrack-provider | vm6502q | # This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import matplotlib.pyplot as plt
from scipy.interpolate import griddata
%matplotlib inline
import numpy as np
from qiskit import QuantumRegister, QuantumCircuit, AncillaRegister, transpile
from qiskit.circuit.library import IntegerComparator, WeightedAdder, LinearAmplitudeFunction
from qiskit.algorithms import... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit.utils import algorithm_globals
from qiskit.algorithms.minimum_eigensolvers import QAOA, NumPyMinimumEigensolver
from qiskit.algorithms.optimizers import COBYLA
from qiskit.primitives import Sampler
from qiskit_optimization.algorithms import (
MinimumEigenOptimizer,
RecursiveMinimumEigenOptimiz... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from __future__ import annotations
import numpy as np
import networkx as nx
num_nodes = 4
w = np.array([[0., 1., 1., 0.],
[1., 0., 1., 1.],
[1., 1., 0., 1.],
[0., 1., 1., 0.]])
G = nx.from_numpy_array(w)
layout = nx.random_layout(G, seed=10)
colors = ['r', 'g', ... |
https://github.com/Harcipan/QAI_GroverSim | Harcipan | from qiskit import transpile, QuantumCircuit
import qiskit.quantum_info as qi
from qiskit_aer import AerSimulator
from qiskit_aer.noise import NoiseModel, amplitude_damping_error
from qiskit.visualization import plot_histogram
# CNOT matrix operator with qubit-0 as control and qubit-1 as target
cx_op = qi.O... |
https://github.com/SaashaJoshi/IBM-Qiskit-Summer-School-2020 | SaashaJoshi | from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_bloch_multivector
excited = Statevector.from_int(1, 2)
plot_bloch_multivector(excited.data)
from qiskit.tools.jupyter import *
from qiskit import IBMQ
IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q', group='open',... |
https://github.com/DaisukeIto-ynu/KosakaQ | DaisukeIto-ynu | # This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2019.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/bawejagb/Quantum_Computing | bawejagb | #Import Libraries
from qiskit import QuantumCircuit, transpile, Aer, assemble
from qiskit.providers.aer import QasmSimulator
from qiskit.visualization import plot_bloch_multivector, plot_histogram
from qiskit.visualization import array_to_latex, plot_state_qsphere
#Input State: 01
qc_ha=QuantumCircuit(4,2)
qc_... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import numpy as np
from qiskit_nature.second_q.hamiltonians import QuadraticHamiltonian
# create Hamiltonian
hermitian_part = np.array(
[
[1.0, 2.0, 0.0, 0.0],
[2.0, 1.0, 2.0, 0.0],
[0.0, 2.0, 1.0, 2.0],
[0.0, 0.0, 2.0, 1.0],
]
)
antisymmetric_part = np.array(
[... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/kanavsetia/qiskitcamp | kanavsetia | import numpy as np
from qiskit.chemistry import bksf
from qiskit.chemistry.fermionic_operator import FermionicOperator as FO
import pdb
from collections import OrderedDict
from pyscf import gto, scf, ao2mo
from pyscf.lib import param
from scipy import linalg as scila
from pyscf.lib import logger as pylogger
# ... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | import matplotlib.pyplot as plt
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeAuckland
backend = FakeAuckland()
ghz = QuantumCircuit(15)
ghz.h(0)
ghz.cx(0, range(1, 15))
depths = []
for _ in range(100):
depths.append(
transpile(
ghz,
... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit_optimization import QuadraticProgram
from qiskit_optimization.translators import from_docplex_mp
# Make a Docplex model
from docplex.mp.model import Model
mdl = Model("docplex model")
x = mdl.binary_var("x")
y = mdl.integer_var(lb=-1, ub=5, name="y")
mdl.minimize(x + 2 * y)
mdl.add_constraint(x ... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/qiskit-community/qiskit-quantinuum-provider | qiskit-community | import numpy as np
from qiskit import QuantumCircuit, execute
from qiskit_quantinuum import Quantinuum
from qiskit.visualization import plot_histogram
# Quantinuum.save_account(user_name="first.last@company.com")
Quantinuum.save_account(user_name="megan.l.kohagen@quantinuum.com")
Quantinuum.load_account()
... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile, schedule
from qiskit.visualization.timeline import draw
from qiskit.providers.fake_provider import FakeBoeblingen
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc = transpile(qc, FakeBoeblingen(), scheduling_method='alap', layout_method='trivial')
draw(qc) |
https://github.com/quantum-tokyo/qiskit-handson | quantum-tokyo | # Qiskitライブラリーを導入
from qiskit import *
# 描画のためのライブラリーを導入
import matplotlib.pyplot as plt
%matplotlib inline
# Qiskitバージョンの確認
qiskit.__qiskit_version__
# 1量子ビット回路を用意
q = QuantumCircuit(1)
# 回路を描画
q.draw(output="mpl")
# 量子ゲートで回路を作成
q.x(0) # Xゲートを0番目の量子ビットに操作します。
# 回路を描画
q.draw(output="mpl")
... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_state_qsphere
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
state = Statevector(qc)
plot_state_qsphere(state) |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/luis6156/Shor-s-Quantum-Algorithm | luis6156 | from qiskit import QuantumCircuit, Aer, execute, IBMQ
from qiskit.utils import QuantumInstance
import numpy as np
from qiskit.algorithms import Shor
IBMQ.enable_account('ENTER API TOKEN HERE') # Enter your API token here
provider = IBMQ.get_provider(hub='ibm-q')
backend = Aer.get_backend('qasm_simulator')
qu... |
https://github.com/taalexander/IEEE-Quantum-Week-2021 | taalexander | import sys
import warnings
if not sys.warnoptions:
warnings.simplefilter("ignore")
import qiskit.tools.jupyter
%qiskit_version_table
hub = 'ibm-q-community'
group = 'ieee-session'
project = 'event-2021'
backend_name = 'ibm_perth'
import qiskit
from qiskit import IBMQ
from qiskit.providers.ibmq... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/joshy91/PythonQiskit | joshy91 | import numpy as np
import scipy
from scipy.linalg import expm
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, MinMaxScaler
from sklearn.decomposition import... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
qr = QuantumRegister(2)
cr = ClassicalRegister(2)
qc = QuantumCircuit(qr, cr)
qc.h(range(2))
qc.measure(range(2), range(2))
# apply x gate if the classical register has the value 2 (10 in binary)
qc.x(0).c_if(cr, 2)
# apply y gate if bi... |
https://github.com/C2QA/bosonic-qiskit | C2QA | import scqubits as sc
tmon = sc.Transmon(
EJ = 31,
EC = .8,
ng = 0,
ncut = 110
)
evals = tmon.eigenvals()[:5]
omega = evals[1]-evals[0]
osc = sc.Oscillator(
E_osc = omega
)
import numpy as np
from matplotlib import pyplot as plt
xlist = np.linspace(-np.pi,np.pi,100)
mineng = min... |
https://github.com/mmetcalf14/Hamiltonian_Downfolding_IBM | mmetcalf14 | from qiskit_chemistry import FermionicOperator, QMolecule
from qiskit_chemistry.aqua_extensions.components.initial_states import HartreeFock
from qiskit_chemistry.aqua_extensions.components.variational_forms import UCCSD
from qiskit_chemistry import QMolecule as qm
from qiskit_aqua.components.optimizers import CO... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2020.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriva... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import pulse
d0 = pulse.DriveChannel(0)
d1 = pulse.DriveChannel(1)
with pulse.build() as pulse_prog:
with pulse.align_right():
# this pulse will start at t=0
pulse.play(pulse.Constant(100, 1.0), d0)
# this pulse will start at t=80
pulse.play(pulse.Constant(20,... |
https://github.com/tomtuamnuq/compare-qiskit-ocean | tomtuamnuq | import dwavebinarycsp
import dimod
import neal
import numpy as np
from dwavebinarycsp.core.constraint import Constraint
from dwave.system import DWaveSampler, EmbeddingComposite
A = np.array([[1,1,1,1,1],
[2,2,2,2,2],
[0,1,2,3,4],
[2,1,4,1,0],
[0,1,0,1... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/swe-bench/Qiskit__qiskit | swe-bench | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2020.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile
from qiskit.visualization import plot_circuit_layout
from qiskit.providers.fake_provider import FakeVigo
backend = FakeVigo()
ghz = QuantumCircuit(3, 3)
ghz.h(0)
ghz.cx(0,range(1,3))
ghz.barrier()
ghz.measure(range(3), range(3))
ghz.draw(output='mpl') |
https://github.com/qiskit-community/community.qiskit.org | qiskit-community | 1 + 1
a = 1
b = 0.5
a + b
an_integer = 42 # Just an integer
a_float = 0.1 # A non-integer number, up to a fixed precision
a_boolean = True # A value that can be True or False
a_string = '''just enclose text between two 's, or two "s, or do what we did for this string''' # Text
none_of_the_above = None # The... |
https://github.com/OscarCharlieST/QISKIT_lab | OscarCharlieST | from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute, Aer
from qiskit.tools.visualization import circuit_drawer
qr = QuantumRegister(1)
cr = ClassicalRegister(1)
circuit = QuantumCircuit(qr, cr)
circuit.h(qr[0])
circuit.measure(qr[0],cr[0])
circuit_drawer(circui... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | # Import requisite modules
import math
import datetime
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# Import Qiskit packages
from qiskit.algorithms.minimum_eigensolvers import NumPyMinimumEigensolver, QAOA, SamplingVQE
from qiskit.algorithms.optimizers import COBYLA
from qiskit.c... |
https://github.com/sebasmos/QuantumVE | sebasmos | API_KEY = "5bd4ecfdc74e6680da7c79998259781431661e5326ae2f88eea95dee8f74b87530ba63fbca8105404de4ffd36e4b484631907acff73c805580928218a5ccf0b3"
import qiskit as q
from qiskit import IBMQ,schedule
import numpy as np
import qiskit.pulse as pulse
from qiskit.circuit import Parameter
%matplotlib inline
import s... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile
from qiskit.visualization import plot_circuit_layout
from qiskit.providers.fake_provider import FakeVigo
backend = FakeVigo()
ghz = QuantumCircuit(3, 3)
ghz.h(0)
ghz.cx(0,range(1,3))
ghz.barrier()
ghz.measure(range(3), range(3))
ghz.draw(output='mpl') |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit, transpile, schedule
from qiskit.visualization.timeline import draw, IQXDebugging
from qiskit.providers.fake_provider import FakeBoeblingen
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc = transpile(qc, FakeBoeblingen(), scheduling_method='alap', layout_method='trivial')
draw(... |
https://github.com/abbarreto/qiskit4 | abbarreto | %run init.ipynb
((10+9.8+9.5)/3+10)/2
(9.77+10)/2
|
https://github.com/unitaryfund/mitiq | unitaryfund | # Copyright (C) Unitary Fund
#
# This source code is licensed under the GPL license (v3) found in the
# LICENSE file in the root directory of this source tree.
"""Functions to convert between Mitiq's internal circuit representation and
Qiskit's circuit representation.
"""
import re
from typing import Any, L... |
https://github.com/kuehnste/QiskitTutorial | kuehnste | # Importing standard Qiskit libraries
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.visualization import *
from qiskit.quantum_info import state_fidelity
# Magic function to render plots in the notebook after the cell executing the plot command
%matplotlib inline
def run_on_qasm_simulator(qu... |
https://github.com/2lambda123/Qiskit-qiskit | 2lambda123 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or deriv... |
https://github.com/hkhetawat/QArithmetic | hkhetawat | # Import the Qiskit SDK
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute, Aer
from QArithmetic import cmult
# Input N
N = 3
c = QuantumRegister(1)
a = QuantumRegister(N)
b = QuantumRegister(N)
m = QuantumRegister(2*N)
cm = ClassicalRegister(2*N)
qc = Qu... |
https://github.com/xtophe388/QISKIT | xtophe388 | def digit_sum(n):
num_str = str(n)
sum = 0
for i in range(0, len(num_str)):
sum += int(num_str[i])
return sum
# CZ (Controlled-Z)
# control qubit: q0
# target qubit: q1
def CZ(qp,q0,q1):
qp.h(q1)
qp.cx(q0,q1)
qp.h(q1)
# f-SWAP
# taking into account the one-directional... |
https://github.com/qiskit-community/qiskit-translations-staging | qiskit-community | from qiskit import QuantumCircuit
from qiskit.quantum_info import Clifford, random_clifford
qc = QuantumCircuit(3)
cliff = random_clifford(2)
qc.append(cliff, [0, 1])
qc.ccx(0, 1, 2)
qc.draw('mpl') |
https://github.com/Qiskit/qiskit-transpiler-service | Qiskit | # -*- coding: utf-8 -*-
# (C) Copyright 2023 IBM. All Rights Reserved.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modificat... |
https://github.com/swe-train/qiskit__qiskit | swe-train | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# 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
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... |
https://github.com/Z-928/Bugs4Q | Z-928 | from qiskit import *
qc = QuantumCircuit(2)
qc.h(i)
qc.crz (PI/4, 0, 1)
|
https://github.com/GIRISHBELANI/QC_Benchmarks_using_dm-simulator | GIRISHBELANI | !pip install qiskit[visualization]
# Imports for Qiskit
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from qiskit import *
from qiskit import IBMQ, Aer
from qiskit import QuantumCircui... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.