repo
stringclasses
885 values
file
stringclasses
741 values
content
stringlengths
4
215k
https://github.com/kurtchahn/QiskitPrx
kurtchahn
import qiskit as qk import qiskit_aer as qaer import numpy as np import math sSimulator = qaer.Aer.backends(name="statevector_simulator")[0] mSimulator = qaer.Aer.backends(name="qasm_simulator")[0]
https://github.com/ctuning/ck-qiskit
ctuning
#!/usr/bin/env python3 import qiskit.tools.apps.optimization num_of_qubits = 2 circuit_depth = 6 num_params = 2 * num_of_qubits * circuit_depth # make sure you set this correctly to the number of parameters used by the ansatz ## Previously used for Hydrogen VQE in QISKit implementation # d...
https://github.com/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
# -*- coding: utf-8 -*- # 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....
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.compiler import transpile from qiskit.transpiler import PassManager circ = QuantumCircuit(3) circ.ccx(0, 1, 2) circ.draw(output='mpl') from qiskit.transpiler.passes import Unroller pass_ = Unroller(['u1', 'u2', 'u3', 'cx']) pm = PassManager(pass_) new_circ = pm...
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/QPower-Research/QPowerAlgo
QPower-Research
import matplotlib.pyplot as plt %matplotlib inline import numpy as np from qiskit import * from qiskit.providers.ibmq import least_busy from qiskit.tools.visualization import plot_histogram from IPython.display import display, Math, Latex def Increment(size): U = QuantumCircuit(size) control = [x...
https://github.com/Chibikuri/Quantum-Othello
Chibikuri
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from qiskit.compiler import transpile import numpy as np import collections import random import matplotlib.pyplot as plt import os plt.ioff() ''' Function to create folder ''' def createFolder(directory): try: ...
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/benkoehlL/Qiskit_Playground
benkoehlL
from qiskit import * print("GHZ") c2 = QuantumCircuit(3,3) c2.h(0) c2.h(1) c2.ccz(0,1,2) c2.x(2) c2.ccz(0,1,2) c2.x(2) c2.h(1) c2.h(2) c2.ccz(0,1,2) c2.h(2) c2.measure([i for i in range(3)], [i for i in range(3)]) simulator = Aer.get_backend('qasm_simulator') result = execute(c2, backend=simulator, sho...
https://github.com/abbarreto/qiskit4
abbarreto
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/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,1) # 回路を描画 q.draw(output="mpl") # 量子ゲートで回路を作成 q.h(0) # Hゲートを0番目の量子ビットに操作します。 # 回路を描画 q.draw(output="mpl")...
https://github.com/at2005/hodl-qiskit
at2005
from qiskit import * from qiskit.visualization import plot_histogram import re import subprocess import os ### define a class to hold hodl oracle code alongside parameters ### this allows many instances of an oracle to be defined --> not limited to ### input-dependent compilation class HODLOracle: def ...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 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...
https://github.com/Ilan-Bondarevsky/qiskit_algorithm
Ilan-Bondarevsky
from qiskit import transpile import qiskit.providers.fake_provider from qiskit_ibm_provider import IBMProvider from qiskit.transpiler.passes import RemoveBarriers from qiskit_aer import AerSimulator, Aer def run_backend(quantum_circuit, backend, *args, **kwargs): '''Run current circuit on a given backend'''...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np from qiskit import QuantumCircuit from qiskit.circuit.library.arithmetic.piecewise_chebyshev import PiecewiseChebyshev f_x, degree, breakpoints, num_state_qubits = lambda x: np.arcsin(1 / x), 2, [2, 4], 2 pw_approximation = PiecewiseChebyshev(f_x, degree, breakpoints, num_state_qubits) pw_approx...
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/2lambda123/Qiskit-qiskit
2lambda123
# -*- coding: utf-8 -*- # 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. # #...
https://github.com/GabrielPontolillo/Quantum_Algorithm_Implementations
GabrielPontolillo
from qiskit import QuantumCircuit def create_bell_pair(): qc = QuantumCircuit(2) qc.h(1) qc.cx(1, 0) return qc def encode_message(qc, qubit, msg): if len(msg) != 2 or not set([0,1]).issubset({0,1}): raise ValueError(f"message '{msg}' is invalid") if msg[1] == "1": q...
https://github.com/jdellaverson19/qiskit2020
jdellaverson19
"""Python implementation of Grovers algorithm through use of the Qiskit library to find the value 3 (|11>) out of four possible values.""" #import numpy and plot library import matplotlib.pyplot as plt import numpy as np # importing Qiskit from qiskit import IBMQ, Aer, QuantumCircuit, ClassicalRegister, Qu...
https://github.com/swe-train/qiskit__qiskit
swe-train
# 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/2lambda123/Qiskit-qiskit
2lambda123
# 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/jonasmaziero/computacao_quantica_qiskit_sbf_2023
jonasmaziero
pip install -U qiskit==0.36.2 pip install pylatexenc import qiskit qiskit.__qiskit_version__ # Copie se API Token no IBMQ e cole aqui qiskit.IBMQ.save_account('ade2e1cd8926fee57b535ff0761ddac06ce27b6ea7ea0ecb60121d873ccf19578850d46431bbb002e5a64db18657e028fd17ae71b73ce25c57002e2ff579eeb6', overwrite = True...
https://github.com/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
# 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/tomtuamnuq/compare-qiskit-ocean
tomtuamnuq
import numpy as np from linear_solver_float import LinearSolverFloat # set floating point accuracy R = 5 M = np.array([[-4,6,1], [8,-11,-2], [-3,4,1]]) # Test 2(f) Y = np.array([0.75,-1.25,0.25]) M_inv = np.linalg.inv(M) M_inv.dot(Y) num_reads = 1000 min_occurrence = ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# import all necessary objects and methods for quantum circuits from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer # define a quantum register with one qubit qreg3 = QuantumRegister(1) # define a classical register with one bit # it stores the measurement result of the quantum...
https://github.com/mmetcalf14/Hamiltonian_Downfolding_IBM
mmetcalf14
# -*- coding: utf-8 -*- # 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....
https://github.com/GabrielPontolillo/QiskitPBT
GabrielPontolillo
# class that inherits from property based test import numpy as np from qiskit import QuantumCircuit from QiskitPBT.property import Property from QiskitPBT.input_generators import RandomFourierTransformState from QiskitPBT.case_studies.quantum_fourier_transform.quantum_fourier_transform import qft_general clas...
https://github.com/petr-ivashkov/qiskit-cert-workbook
petr-ivashkov
#initialization import matplotlib.pyplot as plt import numpy as np #ignore deprecation warnings because they are annoying (not recommened generally) from warnings import simplefilter simplefilter(action='ignore', category=DeprecationWarning) # Importing standard Qiskit libraries from qiskit import * from ...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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/achilles-d/qiskitsummerjam
achilles-d
%matplotlib inline # Importing standard Qiskit libraries and configuring account from qiskit import QuantumCircuit, execute, Aer, IBMQ from qiskit.compiler import transpile, assemble from qiskit.tools.jupyter import * from qiskit.visualization import * # Loading your IBM Q account(s) provider = IBMQ.load_account...
https://github.com/Qiskit/feedback
Qiskit
!pip install pyRiemann-qiskit !pip install moabb from pyriemann_qiskit.pipelines import ( QuantumMDMWithRiemannianPipeline, ) from moabb.datasets import BI2012 from moabb.paradigms import P300 from sklearn.model_selection import train_test_split from sklearn.metrics import balanced_accuracy_score from sk...
https://github.com/2lambda123/Qiskit-qiskit
2lambda123
# Copyright 2022-2023 Ohad Lev. # 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, # or in the root directory of this package("LICE...
https://github.com/bagmk/Quantum_Machine_Learning_Express
bagmk
import qiskit from qiskit import Aer, QuantumCircuit from qiskit.utils import QuantumInstance from qiskit.opflow import AerPauliExpectation from qiskit.circuit import Parameter from qiskit_machine_learning.neural_networks import CircuitQNN from qiskit_machine_learning.connectors import TorchConnector qi = Quant...
https://github.com/menegolli/Quantum_synth
menegolli
from qiskit import * import numpy as np import random import sys from backends_select import ChooseBackEnd def GenerateCircuitSingleNote(circuit, note_id): if (note_id >= 12): sys.exit("Note must be an integer smaller than 11 and larger (or equal) to 0.") bitstring = str(bin(note_id)[2:]) ...
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources
aryashah2k
import matplotlib.pyplot as plt %matplotlib inline import numpy as np import math from qiskit.visualization import plot_state_qsphere from qiskit import * from qiskit.tools.visualization import plot_histogram from IPython.display import display, Math, Latex def reflect(U, n): for i in range(int(n/2))...
https://github.com/qismib/TraNQI
qismib
#!/usr/bin/env python # coding: utf-8 import numpy as np # Importing standard Qiskit libraries from qiskit import QuantumCircuit, transpile, Aer, IBMQ from qiskit.tools.jupyter import * from qiskit.visualization import * from ibm_quantum_widgets import * # importing packages import matplotlib.pyplot as p...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
# # your code is here or you may find the values by hand (in mind) # # # your solution is here #
https://github.com/lynnlangit/learning-quantum
lynnlangit
#@title 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distribute...
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/usamisaori/qLipschitz
usamisaori
from sklearn import datasets import pennylane as qml import numpy as np from pennylane.optimize import AdamOptimizer import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') X_train, Y_train = datasets.make_circles(n_samples=400, noise=0.06, factor=0.7) X_test, Y_test = datasets.mak...
https://github.com/qiskit-community/community.qiskit.org
qiskit-community
from qiskit import * # set up circuit (no measurements required) qc = QuantumCircuit(2) qc.h(0) qc.h(1) qc.rz(3.14/4,1) # set up simulator that returns statevectors backend = Aer.get_backend('statevector_simulator') # run the circuit to get the state vector state = execute(qc,backend).result().get_statev...
https://github.com/Keerthiraj-Nagaraj/IBM-quantum-challenge-2020
Keerthiraj-Nagaraj
from IPython.display import Image, display Image("ryoko.png", width="70") from IPython.display import Image, display Image('unstructured_search.png', width="700") Image("oracle.png", width="700") Image("step0.png", width="700") Image("step1.png", width="700") Image("step2.png", width="700") Image("g...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
# Necessary imports import numpy as np import matplotlib.pyplot as plt from torch import Tensor from torch.nn import Linear, CrossEntropyLoss, MSELoss from torch.optim import LBFGS from qiskit import QuantumCircuit from qiskit.utils import algorithm_globals from qiskit.circuit import Parameter from qiski...
https://github.com/TheGupta2012/QPE-Algorithms
TheGupta2012
from qiskit import QuantumCircuit, execute, transpile, Aer from qiskit.extensions import UnitaryGate,Initialize from qiskit.tools.visualization import plot_histogram from qiskit.compiler import assemble import numpy as np from time import sleep from qiskit.tools.monitor import job_monitor from qiskit.exten...
https://github.com/abbarreto/qiskit4
abbarreto
https://github.com/Harshithan07/Quantum-Computing-using-Qiskit-SDK
Harshithan07
from qiskit import * from qiskit.tools.visualization import plot_histogram %matplotlib inline secretnumber = '11100011' circuit = QuantumCircuit(len(secretnumber)+1,len(secretnumber)) circuit.h(range(len(secretnumber))) circuit.x(len(secretnumber)) circuit.h(len(secretnumber)) circuit.barrier() for i...
https://github.com/arnavdas88/QuGlassyIsing
arnavdas88
!pip install qiskit !git clone https://github.com/arnavdas88/QuGlassyIsing !mv QuGlassyIsing/research/pickle-files/ ./pickle from qiskit.providers.aer import QasmSimulator from qiskit.providers.aer import AerSimulator from qiskit import Aer, transpile from qiskit.circuit.library import TwoLocal from qisk...
https://github.com/aryashah2k/Quantum-Computing-Collection-Of-Resources
aryashah2k
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from math import pi # the angle of rotation theta = pi/16 # we read streams of length 8, 16, 24, 32, 40, 48, 56, 64 for i in [8, 16, 24, 32, 40, 48, 56, 64]: # quantum circuit with one qubit and one bit qreg = Quantu...
https://github.com/qBraid/qBraid
qBraid
from qiskit import * from oracle_generation import generate_oracle get_bin = lambda x, n: format(x, 'b').zfill(n) def gen_circuits(min,max,size): circuits = [] secrets = [] ORACLE_SIZE = size for i in range(min,max+1): cur_str = get_bin(i,ORACLE_SIZE-1) (circuit, secret) = generate_oracle...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt import itertools from pprint import pprint import pickle # plt.rcParams.update({'font.size': 16}) # enlarge matplotlib fonts import time import datetime # Import qubit states Zero (|0>) and One (|1>), and Pauli operators (X, Y, Z) from qiskit.opflow import ...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
number = 5 # integer real = -3.4 # float name = 'Asja' # string surname = "Sarkana" # string boolean1 = True # Boolean boolean2 = False # Boolean a = 13 b = 5 print("a =",a) print("b =",b) print() # basics operators print("a + b =",a+b) print("a - b =",a-b) print("a * b =",a*b) print("a / b =",...
https://github.com/ritamsarmah/cs239
ritamsarmah
"""Qiskit code for running Simon's algorithm on quantum hardware for 2 qubits and b = '11' """ # importing Qiskit from qiskit import IBMQ, BasicAer from qiskit.providers.ibmq import least_busy from qiskit import QuantumCircuit, execute # import basic plot tools from qiskit.visualization import plot_histogram ...
https://github.com/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister # Build a quantum circuit n = 3 # number of qubits q = QuantumRegister(n) c = ClassicalRegister(n) circuit = QuantumCircuit(q, c) circuit.x(q[1]) circuit.h(q) circuit.cx(q[0], q[1]) circuit.measure(q, c); print(circuit) circu...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt import itertools import pickle # plt.rcParams.update({'font.size': 16}) # enlarge matplotlib fonts 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...
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/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import Statevector from qiskit.visualization import plot_bloch_multivector qc = QuantumCircuit(2) qc.h(0) qc.x(1) # You can reverse the order of the qubits. from qiskit.quantum_info import DensityMatrix qc = QuantumCircuit(2) qc.h([0, 1]) qc.t...
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/GIRISHBELANI/QC_Benchmarks_using_dm-simulator
GIRISHBELANI
""" Bernstein-Vazirani Benchmark Program - QSim """ import sys import time import numpy as np from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister sys.path[1:1] = [ "_common", "_common/qsim" ] sys.path[1:1] = [ "../../_common", "../../_common/qsim" ] import execute as ex import metrics ...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# 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/bayesian-randomized-benchmarking/qiskit-advocates-bayes-RB
bayesian-randomized-benchmarking
#Import general libraries (needed for functions) import numpy as np import matplotlib.pyplot as plt from IPython import display #Import Qiskit classes import qiskit from qiskit.tools.monitor import job_monitor from qiskit import Aer from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer....
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import BasicAer, transpile, QuantumRegister, ClassicalRegister, QuantumCircuit qr = QuantumRegister(1) cr = ClassicalRegister(1) qc = QuantumCircuit(qr, cr) qc.h(0) qc.measure(0, 0) qc.draw('mpl')
https://github.com/DEBARGHYA4469/quantum-compiler
DEBARGHYA4469
# Implement the control_U2 gate # Written by Debarghya Kundu # Email : debarghya4469@iitg.ernet.in from zy_decomposition import * from qiskit import ClassicalRegister,QuantumRegister,QuantumJob from qiskit import available_backends,execute,register,get_backend from qiskit.tools.visualization import plot_his...
https://github.com/swe-train/qiskit__qiskit
swe-train
# -*- coding: utf-8 -*- # 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. # #...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt import itertools from pprint import pprint import pickle # plt.rcParams.update({'font.size': 16}) # enlarge matplotlib fonts import time import datetime # Import qubit states Zero (|0>) and One (|1>), and Pauli operators (X, Y, Z) from qiskit.opflow import ...
https://github.com/dimple12M/Qiskit-Certification-Guide
dimple12M
from qiskit import QuantumCircuit,QuantumRegister,transpile from qiskit.test.mock import FakeVigo,FakeLondon qc=QuantumCircuit(1) qc.h(0) qc.barrier(0) qc.x(0) qc.barrier(0) qc.h(0) qc.draw(output="mpl") device_backend = FakeVigo() config_details = device_backend.configuration() config_details.back...
https://github.com/abhik-99/Qiskit-Summer-School
abhik-99
!pip install -U -r grading_tools/requirements.txt from IPython.display import clear_output clear_output() import numpy as np; pi = np.pi from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram from copy import deepcopy as make_copy def prepare_hets_circuit(depth, ang...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
# If you introduce a list with less colors than bars, the color of the bars will # alternate following the sequence from the list. import numpy as np from qiskit.quantum_info import DensityMatrix from qiskit import QuantumCircuit from qiskit.visualization import plot_state_paulivec qc = QuantumCircuit(2) qc....
https://github.com/MiChaelinzo/Quantum-time-travel
MiChaelinzo
import qiskit import math from qiskit import QuantumCircuit, transpile from qiskit.visualization import plot_histogram from qiskit_aer import Aer def time_travel_circuit(target_time, num_qubits=6): """ Creates a quantum circuit simulating time travel (fictional). This circuit applies Hadamard ga...
https://github.com/quantum-melbourne/qiskit-challenge-22
quantum-melbourne
from qiskit_nature.drivers import Molecule from qiskit_nature.drivers.second_quantization import ElectronicStructureDriverType, ElectronicStructureMoleculeDriver # PSPCz molecule geometry = [['C', [ -0.2316640, 1.1348450, 0.6956120]], ['C', [ -0.8886300, 0.3253780, -0.2344140]], ...
https://github.com/urwin419/QiskitChecker
urwin419
from qiskit import QuantumCircuit def create_bell_pair(): qc = QuantumCircuit(2) qc.h(1) qc.cx(1, 0) return qc def encode_message(qc, qubit, msg): if len(msg) != 2 or not set([0,1]).issubset({0,1}): raise ValueError(f"message '{msg}' is invalid") if msg[1] == "1": q...
https://github.com/Qiskit/feedback
Qiskit
from qiskit_nature.second_q.operators import BosonicOp, FermionicOp # Create a creation operator bosonic_op = BosonicOp({'+_0': 1}, num_modes=1) # Create an annihilation operator bosonic_op = BosonicOp({'-_0': 1}, num_modes=1) bosonic_op1 = BosonicOp({'+_0 -_0 -_1 +_1': 2}, num_modes=2) bosonic_op2 = BosonicO...
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 = [] gate_counts = [] non_local_gate_counts = [] levels = [str(x) for x in range(4)...
https://github.com/QForestCommunity/launchpad
QForestCommunity
import qiskit qiskit.__qiskit_version__ from qiskit import QuantumCircuit, BasicAer, execute from qiskit.visualization import plot_histogram qcSwap = QuantumCircuit(2, 2) #create a quantum circuit with 2 quantum bits and 2 classical bits. qcSwap.x(0) #apply a pauli X gate to the first qubit to better demonst...
https://github.com/Aman-Agrawal01/Quantum-Computing-Qiskit-Tutorial
Aman-Agrawal01
from qiskit import * %matplotlib inline import numpy as np from qiskit.visualization import plot_histogram n = 2 #Number of qubits qr1 = QuantumRegister(size=n) qr2 = QuantumRegister(size=1) cr = ClassicalRegister(size=n) def function(circuit,fn): if fn == 'const-0': circuit.x(qr2) ...
https://github.com/indian-institute-of-science-qc/qiskit-aakash
indian-institute-of-science-qc
# 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/IceKhan13/purplecaffeine
IceKhan13
"""Tests for Trial.""" import os import shutil from pathlib import Path from typing import Optional from unittest import TestCase import numpy as np from qiskit import QuantumCircuit, __version__ from qiskit.circuit.library import XGate from qiskit.quantum_info import Operator from purplecaffeine import T...
https://github.com/swe-train/qiskit__qiskit
swe-train
# 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/AnikenC/JaxifiedQiskit
AnikenC
import numpy as np import qiskit from qiskit import pulse from qiskit_dynamics import Solver, DynamicsBackend from qiskit_dynamics.pulse import InstructionToSignals import jax.numpy as jnp from jax import jit, vmap, block_until_ready import chex from typing import Optional, Union from library.utils i...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import math from qiskit import pulse from qiskit.providers.fake_provider import FakeOpenPulse3Q # TODO: This example should use a real mock backend. backend = FakeOpenPulse3Q() d2 = pulse.DriveChannel(2) with pulse.build(backend) as bell_prep: pulse.u2(0, math.pi, 0) pulse.cx(0, 1) with pulse...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit, execute from qiskit.providers.fake_provider import FakeVigoV2 from qiskit.visualization import plot_gate_map backend = FakeVigoV2() plot_gate_map(backend)
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import * from qiskit.visualization import plot_histogram # quantum circuit to make a Bell state bell = QuantumCircuit(2, 2) bell.h(0) bell.cx(0, 1) meas = QuantumCircuit(2, 2) meas.measure([0,1], [0,1]) # execute the quantum circuit backend = BasicAer.get_backend('qasm_simulator') # the dev...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit import QuantumCircuit from qiskit.quantum_info import Operator from qiskit.transpiler.passes import UnitarySynthesis circuit = QuantumCircuit(1) circuit.rx(0.8, 0) unitary = Operator(circuit).data unitary_circ = QuantumCircuit(1) unitary_circ.unitary(unitary, [0]) synth = UnitarySynthesis(basi...
https://github.com/AbeerVaishnav13/Using-Qiskit
AbeerVaishnav13
import numpy as np from qiskit import * from qiskit.visualization import plot_histogram, plot_gate_map from qiskit.tools.monitor import job_monitor from qiskit.test.mock import FakeProvider import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') %matplotlib inline backends = list(fi...
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/shesha-raghunathan/DATE2019-qiskit-tutorial
shesha-raghunathan
# we import all necessary methods and objects from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from qiskit.tools.visualization import matplotlib_circuit_drawer as drawer from random import randrange # we will use 10 quantum bits and 10 classical bits qreg3 = QuantumRegister(10...
https://github.com/zeynepCankara/Introduction-Quantum-Programming
zeynepCankara
# I am a comment in python print("Hello From Quantum World :-)") # please run this cell # import the objects from qiskit from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer from random import randrange # Create my circuit and register objects qreg = QuantumRegister(2) # my...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
import numpy as np import matplotlib.pyplot as plt from qiskit import QuantumRegister, QuantumCircuit from qiskit.circuit.library import IntegerComparator from qiskit.algorithms import IterativeAmplitudeEstimation, EstimationProblem from qiskit_aer.primitives import Sampler # set problem parameters n_z = 2 ...
https://github.com/BOBO1997/osp_solutions
BOBO1997
import numpy as np import matplotlib.pyplot as plt import itertools import pickle # plt.rcParams.update({'font.size': 16}) # enlarge matplotlib fonts 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...
https://github.com/pranavdurai10/quantum-gates
pranavdurai10
''' /////////////////////////////////////////////////////////////////////////// Code written by Pranav Durai for Quantum Computer on 28.05.2023 @ 20:22:15 Component: Pauli-Y-Gate (bit-flip-gate) Framework: Qiskit 0.43.0 /////////////////////////////////////////////////////////////////////////// ''' # Impor...
https://github.com/qiskit-community/community.qiskit.org
qiskit-community
%matplotlib inline import qiskit.pulse as pulse import qiskit.pulse.pulse_lib as pulse_lib from qiskit.compiler import assemble import qiskit qiskit.__qiskit_version__ from qiskit import IBMQ IBMQ.load_account() provider = IBMQ.get_provider(hub='your-hub-name') # change to your hub name backend = provider....
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 deriv...
https://github.com/abhik-99/Qiskit-Summer-School
abhik-99
!pip install -U -r grading_tools/requirements.txt from IPython.display import clear_output clear_output() # our backend is the Pulse Simulator from resources import helper from qiskit.providers.aer import PulseSimulator backend_sim = PulseSimulator() # sample duration for pulse instructions dt = 1e-9 ...
https://github.com/MonitSharma/Qiskit-Summer-School-and-Quantum-Challenges
MonitSharma
### Install Qiskit and relevant packages, if needed ### IMPORTANT: Make sure you are on 3.10 > python < 3.12 %pip install qiskit[visualization]==1.0.2 %pip install qiskit-ibm-runtime %pip install qiskit-aer %pip install graphviz %pip install qiskit-serverless -U %pip install qiskit-transpiler-service -U %pip in...
https://github.com/swe-bench/Qiskit__qiskit
swe-bench
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 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/mcoggins96/Quantum-Computing-UK-Repository
mcoggins96
from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumCircuit, execute,IBMQ from qiskit.tools.monitor import job_monitor import numpy as np IBMQ.enable_account('ENTER API KEY HERE) provider = IBMQ.get_provider(hub='ibm-q') backend = provider.get_backend('ibmq_qasm_simulator') pi =...
https://github.com/qiskit-community/qiskit-translations-staging
qiskit-community
from qiskit.circuit import Parameter from qiskit import QuantumCircuit theta = Parameter('$\\theta$') chsh_circuits_no_meas = QuantumCircuit(2) chsh_circuits_no_meas.h(0) chsh_circuits_no_meas.cx(0, 1) chsh_circuits_no_meas.ry(theta, 0) chsh_circuits_no_meas.draw('mpl') import numpy as np number_of_pha...
https://github.com/Marduk-42/Quantum-Algorithm-Tutorials
Marduk-42
from qiskit import * import matplotlib.pyplot as plt qreg = QuantumRegister(2) creg = ClassicalRegister(2) circuit = QuantumCircuit(qreg,creg) circuit.reset(qreg[0]) circuit.reset(qreg[1]) circuit.h(qreg[0]) circuit.cx(qreg[0],qreg[1]) circuit.measure(qreg[0],creg[0]) circuit.measure(qreg[1],creg[1]) b...
https://github.com/carstenblank/dc-qiskit-stochastics
carstenblank
from hmmlearn import hmm samples = 10*[[0], [1], [1], [1], [1], [2], [2], [0], [1], [1], [1], [0], [2]] model = hmm.MultinomialHMM(n_components=4) model.fit(samples) model.emissionprob_ model.transmat_
https://github.com/usamisaori/qLipschitz
usamisaori
#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np from qiskit import QuantumCircuit # ## Create Circuit # In[2]: def createInputCircuit(data): qubits_num = len(data) qcircuit = QuantumCircuit(qubits_num, qubits_num) qubits = qcircuit.qubits for i, d in enumer...