code stringlengths 114 1.05M | path stringlengths 3 312 | quality_prob float64 0.5 0.99 | learning_prob float64 0.2 1 | filename stringlengths 3 168 | kind stringclasses 1
value |
|---|---|---|---|---|---|
import numpy as np
import random
from QuICT.core.circuit.circuit import Circuit
from QuICT.core.gate import BasicGate, UnitaryGate, Unitary, CompositeGate
from QuICT.core.noise import NoiseModel
from QuICT.core.operator import NoiseGate
from QuICT.core.utils import GateType, matrix_product_to_circuit
import QuICT.ops.... | /quict-1.0.0-1-py3-none-any.whl/QuICT/simulation/density_matrix/density_matrix_simulator.py | 0.910866 | 0.504761 | density_matrix_simulator.py | pypi |
from typing import Union
import numpy as np
from QuICT.core import Circuit
from QuICT.core.operator import Trigger
from QuICT.core.gate import BasicGate, CompositeGate
from QuICT.core.utils import GateType, MatrixType
from QuICT.ops.linalg.cpu_calculator import (
measure_gate_apply, reset_gate_apply, matrix_dot_v... | /quict-1.0.0-1-py3-none-any.whl/QuICT/simulation/state_vector/statevector_simulator.py | 0.930419 | 0.590366 | statevector_simulator.py | pypi |
from typing import *
import numpy as np
from QuICT.core import Circuit
import QuICT.ops.linalg.cpu_calculator as CPUCalculator
from QuICT.tools.exception.core import ValueError
from QuICT.tools.exception.simulation import (
UnitaryMatrixUnmatchedError, StateVectorUnmatchedError, SampleBeforeRunError
)
class Unit... | /quict-1.0.0-1-py3-none-any.whl/QuICT/simulation/unitary/unitary_simulator.py | 0.955496 | 0.600071 | unitary_simulator.py | pypi |
import numpy as np
try:
import cupy as cp
except ImportError:
cupy = None
from QuICT.core.operator import Operator
from QuICT.core.utils import GateType
class GateMatrixs:
"""
The class of storing the gates' compute matrix, without duplicate.
Args:
precision(Union[np.complex64, np.compl... | /quict-1.0.0-1-py3-none-any.whl/QuICT/simulation/utils/gate_based.py | 0.904166 | 0.408719 | gate_based.py | pypi |
import os
import numpy as np
class Result:
""" Data structure class for simulator result
Args:
mode (str): The simulator mode, usually be {device-backend}.
shots (int): The running times; must be a positive integer.
options (dict): Optional parameters for the simulator.
"""
de... | /quict-1.0.0-1-py3-none-any.whl/QuICT/simulation/utils/result.py | 0.824921 | 0.361785 | result.py | pypi |
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
OPTIONS = {
"with_labels": True,
"font_size": 20,
"font_weight": "bold",
"font_color": "white",
"node_size": 2000,
"width": 3,
}
def draw_samples_with_auxiliary(
sample, qubits, anxiliary, title: str = "Sample Distr... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/tools/drawer/graph_drawer.py | 0.857112 | 0.678487 | graph_drawer.py | pypi |
import random
from math import gcd
import numpy as np
from fractions import Fraction
from typing import List, Tuple
from QuICT.core import Circuit
from QuICT.core.gate import *
from QuICT.simulation.state_vector import StateVectorSimulator
from .utility import *
from .BEA_zip import construct_circuit as BEA_zip_circu... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/shor/shor_factor.py | 0.861742 | 0.573201 | shor_factor.py | pypi |
import numpy as np
from functools import reduce
from math import gcd
from QuICT.core.gate import X
from QuICT.simulation.state_vector import StateVectorSimulator
from QuICT.tools import Logger
from QuICT.tools.exception.core import *
logger = Logger("Shor-util")
def ex_gcd(a, b, arr):
if b == 0:
arr[0]... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/shor/utility.py | 0.58522 | 0.483526 | utility.py | pypi |
import numpy as np
from scipy.optimize import minimize
from QuICT.core import Circuit
from QuICT.core.gate import *
from QuICT.core.gate.backend import MCTOneAux
from QuICT.qcda.synthesis.quantum_state_preparation import QuantumStatePreparation
P_GLOBAL = []
T_GLOBAL = 1
def fun(x):
return -np.dot(P_GLOBAL, np... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/grover/search_with_prior_knowledge.py | 0.794544 | 0.399314 | search_with_prior_knowledge.py | pypi |
import numpy as np
from QuICT.core import Circuit
from QuICT.core.gate import *
from QuICT.core.gate.backend import MCTOneAux
from QuICT.tools import Logger
from QuICT.tools.exception.core import *
logger = Logger("Grover")
ALPHA = 1.5
def degree_counterclockwise(v1: np.ndarray, v2: np.ndarray):
"""from v1 to ... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/grover/grover.py | 0.757974 | 0.48499 | grover.py | pypi |
import numpy as np
from QuICT.algorithm.quantum_algorithm.quantum_walk import Graph, QuantumWalk
from QuICT.simulation.state_vector import StateVectorSimulator
class QuantumWalkSearch(QuantumWalk):
""" Search algorithm on a hypercube based on quantum walk and Grover.
https://arxiv.org/pdf/quant-ph/0210064.p... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/quantum_walk/quantum_walk_search.py | 0.905456 | 0.81648 | quantum_walk_search.py | pypi |
import numpy as np
from typing import Dict, List, Union
from .graph import Graph
from QuICT.core import Circuit
from QuICT.core.gate import *
from QuICT.simulation.state_vector import StateVectorSimulator
class QuantumWalk:
""" The Quantum Random Walk Algorithm. """
@property
def step(self):
ret... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/quantum_walk/quantum_walk.py | 0.923204 | 0.48438 | quantum_walk.py | pypi |
from collections import defaultdict
from typing import Dict, List, Union
import numpy as np
class Graph:
""" The graph descript position space and action space for quantum random walk """
@property
def position(self) -> int:
return self._nodes
@property
def position_qubits(self) -> int:
... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/quantum_walk/graph.py | 0.948941 | 0.659898 | graph.py | pypi |
from QuICT.simulation.state_vector import StateVectorSimulator
from .backend.canonical_QAE import amplitude_estimate as canonical_run
from .backend.max_likely_QAE import amplitude_estimate as max_likely_run
from .backend.FQAE import amplitude_estimate as fast_run
from .backend.canonical_QAE import construct_circuit as... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/amplitude_estimate/QAE.py | 0.792183 | 0.431884 | QAE.py | pypi |
from QuICT.core.gate import CompositeGate, CX, CH, X, H
from QuICT.core.gate.backend import MCTOneAux
class OracleInfo:
def __init__(
self,
n: int,
n_ancilla: int,
S_chi,
is_good_state,
custom_grover_operator=None,
) -> None:
"""Oracle information.
... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/amplitude_estimate/utility.py | 0.827828 | 0.378287 | utility.py | pypi |
import numpy as np
from QuICT.core import Circuit
from QuICT.core.gate import CompositeGate, Swap, H, Measure, IQFT
from ..utility import OracleInfo, StatePreparationInfo
def construct_circuit(
eps,
oracle: OracleInfo,
state_preparation: StatePreparationInfo,
):
# see Theorem 12, case k=1
n = or... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/amplitude_estimate/backend/canonical_QAE.py | 0.769427 | 0.391231 | canonical_QAE.py | pypi |
import numpy as np
from scipy.optimize import brute
from QuICT.core import Circuit
from QuICT.core.gate import CompositeGate
from ..utility import OracleInfo, StatePreparationInfo
def amplitude_estimate(
eps,
oracle: OracleInfo,
state_preparation: StatePreparationInfo,
simulator,
):
"""implementa... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/quantum_algorithm/amplitude_estimate/backend/max_likely_QAE.py | 0.776284 | 0.422564 | max_likely_QAE.py | pypi |
import numpy as np
from QuICT.algorithm import Algorithm
from QuICT.core import Circuit
from QuICT.core.gate import X, H, Measure
from QuICT.core.gate.backend import MCTOneAux
from QuICT.qcda.synthesis.quantum_state_preparation import QuantumStatePreparation
from QuICT.simulation.state_vector import StateVectorSimulat... | /quict-1.0.0-1-py3-none-any.whl/QuICT/algorithm/weight_decision/weight_decision.py | 0.845177 | 0.635449 | weight_decision.py | pypi |
from numpy.random import random
from typing import Union, List
from .noise_error import QuantumNoiseError, NoiseChannel
from .readout_error import ReadoutError
from QuICT.core import Circuit
from QuICT.core.gate import BasicGate, GateType, GATE_TYPE_TO_CLASS, Unitary
from QuICT.core.operator import NoiseGate
from QuIC... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/noise/noise_model.py | 0.949914 | 0.434461 | noise_model.py | pypi |
import copy
import math
import numpy as np
from typing import Union, List
from QuICT.ops.linalg.cpu_calculator import dot, tensor
from QuICT.tools.exception.core import ValueError, TypeError
from .utils import NoiseChannel
class ReadoutError:
""" The Readout error class
Example:
p(n|m) describe the ... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/noise/readout_error.py | 0.910139 | 0.683448 | readout_error.py | pypi |
from itertools import product
import numpy as np
from typing import List, Tuple
from .utils import is_kraus_ops, NoiseChannel
from QuICT.core.gate import ID, X, Y, Z
from QuICT.ops.linalg.cpu_calculator import tensor, dot
from QuICT.tools.exception.core import (
TypeError, ValueError, KrausError, NoiseApplyError,
... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/noise/noise_error.py | 0.918681 | 0.494568 | noise_error.py | pypi |
from typing import Tuple, Union, List, Dict
from types import FunctionType
from ._operator import Operator
from QuICT.core.gate import CompositeGate, BasicGate
from QuICT.tools.exception.core import TypeError, ValueError
class Trigger(Operator):
"""
The trigger for switch the dynamic circuit; contains the ta... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/operator/trigger.py | 0.962285 | 0.54577 | trigger.py | pypi |
from typing import List
from ._operator import Operator
from QuICT.core.utils import unique_id_generator
from QuICT.tools.exception.core import TypeError, CheckPointNoChildError
class CheckPoint(Operator):
""" The CheckPoint is a sign of the circuit, the Composite Gate with the related
CheckPointChild will b... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/operator/check_point.py | 0.955714 | 0.671683 | check_point.py | pypi |
from .backend.mct import *
from QuICT.core.gate import CompositeGate, X, CX, CCX
from QuICT.tools.exception.core import TypeError, ValueError
class MultiControlToffoli(object):
"""
Divided by the usages of auxiliary qubits, here are 4 implementations of multi-control Toffoli gates.
"""
__AUX_USAGES = ... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/gate/multicontrol_toffoli.py | 0.920419 | 0.406067 | multicontrol_toffoli.py | pypi |
import copy
from typing import Union
import numpy as np
from QuICT.core.utils import (
GateType, MatrixType, SPECIAL_GATE_SET, DIAGONAL_GATE_SET, CGATE_LIST,
PAULI_GATE_SET, CLIFFORD_GATE_SET,
perm_decomposition, matrix_product_to_circuit
)
from QuICT.tools.exception.core import (
TypeError, ValueError... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/gate/gate.py | 0.928051 | 0.575648 | gate.py | pypi |
import numpy as np
import random
from QuICT.core.qubit import Qubit, Qureg
from QuICT.core.gate import *
from QuICT.core.utils import GateType
from QuICT.tools.exception.core import GateQubitAssignedError
GATE_TYPE_TO_CLASS = {
GateType.h: HGate,
GateType.hy: HYGate,
GateType.s: SGate,
GateType.sdg:... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/gate/gate_builder.py | 0.781581 | 0.575916 | gate_builder.py | pypi |
from QuICT.core import *
from QuICT.core.gate import *
class MCTLinearHalfDirtyAux(object):
def execute(self, m: int, n: int):
""" A linear simulation for Toffoli gate
https://arxiv.org/abs/quant-ph/9503016 Lemma 7.2
Implement a m-bit toffoli gate in a qureg with n qubit with linear com... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/gate/backend/mct/mct_linear_dirty_aux.py | 0.967206 | 0.724212 | mct_linear_dirty_aux.py | pypi |
import numpy as np
from QuICT.core.gate import CompositeGate, H, X, CX, CU1
class MCTWithoutAux(object):
"""
Decomposition of n-qubit Toffoli gates with no ancillary qubit
Reference:
https://arxiv.org/abs/1303.3557
"""
def execute(self, n):
"""
Args:
n(int): t... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/gate/backend/mct/mct_without_aux.py | 0.921083 | 0.666526 | mct_without_aux.py | pypi |
from typing import *
import numpy as np
from QuICT.core.gate import GateType, build_gate, CompositeGate, CX
class UniformlyRotation(object):
"""
Implements the uniformly Ry or Rz gate
Reference:
https://arxiv.org/abs/quant-ph/0504100 Fig4 a)
"""
def __init__(self, gate_type=None):
... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/gate/backend/uniformly_gate/uniformly_rotation.py | 0.967545 | 0.676034 | uniformly_rotation.py | pypi |
import numpy as np
from .uniformly_rotation import UniformlyRotation
from QuICT.core.gate import build_gate, GateType, CompositeGate, H, Rz, CX
class UniformlyUnitary(object):
"""
Implements the uniformly unitary gate
Reference:
https://arxiv.org/abs/quant-ph/0504100 Fig4 b)
"""
def exe... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/gate/backend/uniformly_gate/uniformly_unitary.py | 0.952264 | 0.759872 | uniformly_unitary.py | pypi |
from enum import Enum
class GateType(Enum):
h = "H gate"
hy = "Self-inverse gate"
s = "S gate"
sdg = "The conjugate transpose of Phase gate"
x = "Pauli-X gate"
y = "Pauli-Y gate"
z = "Pauli-Z gate"
sx = "sqrt(X) gate"
sy = "sqrt(Y) gate"
sw = "sqrt(W) gate"
id = "Identity g... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/utils/gate_type.py | 0.780119 | 0.558809 | gate_type.py | pypi |
from enum import Enum
from typing import List
import numpy as np
from .circuit_matrix import CircuitMatrix, get_gates_order_by_depth
from .gate_type import GateType
class CircuitBased(object):
""" Based Class for Circuit and Composite Gate. """
@property
def name(self) -> int:
return self._name
... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/utils/circuit_info.py | 0.936822 | 0.567158 | circuit_info.py | pypi |
from typing import *
from collections import namedtuple
import numpy as np
from .gate_type import MatrixType
import QuICT.ops.linalg.cpu_calculator as CPUCalculator
from QuICT.tools.exception.core import TypeError
def get_gates_order_by_depth(gates: list) -> list:
""" Order the gates of circuit by its depth lay... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/utils/circuit_matrix.py | 0.832713 | 0.462898 | circuit_matrix.py | pypi |
from typing import Union
import numpy as np
CGATE_LIST = []
def matrix_product_to_circuit(
gate_matrix: np.ndarray,
gate_args: Union[int, list],
max_q: int,
min_q: int = 0,
gpu_output: bool = False
):
""" Expand gate matrix with the number of qubits
Args:
gate_matrix (np.ndarray... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/utils/utils.py | 0.902514 | 0.590041 | utils.py | pypi |
from typing import DefaultDict
import numpy as np
from QuICT.core.layout import Layout
class SupremacyLayout(Layout):
def __init__(self, qubits: int, name: str = "unknown"):
assert(qubits >= 5)
Layout.__init__(self, qubits, name)
self._build_supremacy_layout()
self._add_supremacy... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/layout/supremacy_layout.py | 0.820505 | 0.267193 | supremacy_layout.py | pypi |
from __future__ import annotations
from itertools import combinations
import json
import warnings
from typing import Any, Dict, List, Tuple
class LayoutEdge:
"""Implement a physical connection between physical qubits
Attributes:
u(int): Node u of edge
v(int): Node v of edge
directio... | /quict-1.0.0-1-py3-none-any.whl/QuICT/core/layout/layout.py | 0.95297 | 0.425009 | layout.py | pypi |
import math
from typing import List, Union
import numpy as np
import cupy as cp
def dot(A, B, gpu_out: bool = False, sync: bool = True):
""" dot matrix A and matrix B
Args:
A(np.array<np.complex>): the matrix A
B(np.array<np.complex>): the matrix B
gpu_out(bool): return result from G... | /quict-1.0.0-1-py3-none-any.whl/QuICT/ops/linalg/gpu_calculator.py | 0.866118 | 0.53127 | gpu_calculator.py | pypi |
import os
import subprocess
import numpy as np
try:
from QuICT.ops.backend import linalg
except ImportError:
backend_file_path = os.path.dirname(__file__) + "/../backend/linear_alg_cpu.py"
res = subprocess.call(["python3", backend_file_path])
from QuICT.ops.backend import linalg
def MatrixTensorI(A, ... | /quict-1.0.0-1-py3-none-any.whl/QuICT/ops/linalg/cpu_calculator_AOT.py | 0.804252 | 0.617051 | cpu_calculator_AOT.py | pypi |
import random
from numba import njit, prange
import numpy as np
from QuICT.ops.utils import mapping_augment
@njit(parallel=True, nogil=True)
def MatrixTensorI(A, n, m):
""" tensor I^n and A and I^m
Args:
A(np.array<np.complex>): the matrix A
n(int): the index of indentity
m(int): the... | /quict-1.0.0-1-py3-none-any.whl/QuICT/ops/linalg/cpu_calculator.py | 0.83924 | 0.662094 | cpu_calculator.py | pypi |
import cupy as cp
import numpy as np
from .gate_function import prop_add_double_kernel, prop_add_single_kernel, MeasureGate_prop
__outward_functions = [
"complex_multiply",
"float_multiply"
]
complex_multiply_single = cp.RawKernel(r'''
#include <cupy/complex.cuh>
extern "C" __global__
void Simp... | /quict-1.0.0-1-py3-none-any.whl/QuICT/ops/gate_kernel/multigpu_gate_func.py | 0.55435 | 0.188641 | multigpu_gate_func.py | pypi |
import cupy as cp
import numpy as np
import random
__outward_functions = [
"diagonal_targ",
"diagonal_targs",
"normal_targ",
"normal_targs",
"control_targ",
"diagonal_ctargs",
"control_ctargs",
"normal_ctargs",
"ctrl_normal_targs",
"normal_normal_targs",
"diagonal_normal_ta... | /quict-1.0.0-1-py3-none-any.whl/QuICT/ops/gate_kernel/gate_function.py | 0.530966 | 0.404566 | gate_function.py | pypi |
import random
import numpy as np
from numba.pycc import CC
from numba.types import bool_
from QuICT.ops.utils import mapping_augment
cc = CC("linalg")
@cc.export('matrixtensorf', 'c8[:, :](c8[:, :], i4, i4)')
@cc.export('matrixtensord', 'c16[:, :](c16[:, :], i4, i4)')
def MatrixTensorI(A, n, m):
""" tensor I^... | /quict-1.0.0-1-py3-none-any.whl/QuICT/ops/backend/linear_alg_cpu.py | 0.758332 | 0.59355 | linear_alg_cpu.py | pypi |
import weakref
import cupy as cp
import numpy as np
import QuICT.ops.linalg.gpu_calculator as GPUCalculator
class CalculationLayer:
""" The context class of GPU linear algorithm and GPU memory management.
Args:
gpu_device (int): Indicated GPU device.
memory_limit (int): the limitation of me... | /quict-1.0.0-1-py3-none-any.whl/QuICT/ops/utils/calculation_layer.py | 0.871612 | 0.424114 | calculation_layer.py | pypi |
from argparse import ArgumentParser, Namespace, RawTextHelpFormatter
from copy import deepcopy
QUICT_DESCRIBE = """
___ ___ ____ _____
/ _ \ _ _ |_ _| / ___| |_ _|
| | | | | | | | | | | | | |
| |_| | | |_| | | | | |___ | |
\__\_\ \___/ |___| \____| |_|
Welcome to Q... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/cli/quict.py | 0.822474 | 0.274546 | quict.py | pypi |
import os
import sys
from QuICT.core import Layout
from QuICT.tools import Logger, LogFormat
from QuICT.tools.interface import OPENQASMInterface
from QuICT.tools.circuit_library import CircuitLib
from QuICT.qcda.qcda import QCDA
from QuICT.qcda.synthesis.gate_transform import USTCSet, GoogleSet, IBMQSet, IonQSet, NamS... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/cli/script/qcda.py | 0.469277 | 0.204243 | qcda.py | pypi |
import os
import psutil
import subprocess
import shutil
from typing import Union, Dict
from QuICT.tools import Logger
from QuICT.tools.logger import LogFormat
from QuICT.tools.cli.utils import JobValidation
from .utils import SQLManager
logger = Logger("Job_Management_Local_Mode", LogFormat.full)
class QuICTLocalM... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/cli/client/controller.py | 0.724773 | 0.174445 | controller.py | pypi |
import os
import yaml
from typing import Union, Dict
from QuICT.core.layout import Layout
from QuICT.tools.interface import OPENQASMInterface
class JobValidation:
_SIMULATION_PARAMETERS = {
"precision": ["single", "double"],
"backend": ["state_vector", "density_matrix", "unitary"],
"devic... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/cli/utils/validation.py | 0.764276 | 0.409162 | validation.py | pypi |
import os
import shutil
from QuICT.tools import Logger
from QuICT.tools.cli.utils import JobValidation
from QuICT.tools.circuit_library import CircuitLib
logger = Logger("CLI_Circuit_Management")
default_customed_circuit_folder = os.path.join(
os.path.dirname(__file__),
"..",
"circuit"
)
def get_rand... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/cli/blueprint/circuit.py | 0.740644 | 0.380817 | circuit.py | pypi |
from copy import copy
import numpy as np
from typing import *
from QuICT.core import Circuit
from QuICT.core.gate import *
class TikzDrawer:
wire_gap = 0.8
level_gap = 1.0
rectangle_size = level_gap / 2
@classmethod
def circuit_layers(cls, circuit: Circuit) -> Iterable[List[BasicGate]]:
... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/drawer/tikz_drawer.py | 0.875162 | 0.271372 | tikz_drawer.py | pypi |
from copy import copy
from warnings import warn
class DefaultStyle:
"""IBM Design Style colors
"""
def __init__(self):
# Set colors
basis_color = '#FA74A6'
clifford_color = '#6FA4FF'
non_gate_color = '#000000'
other_color = '#BB8BFF'
pauli_color = '#05BAB6... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/drawer/ibmq_style.py | 0.648911 | 0.156169 | ibmq_style.py | pypi |
ERROR_CODE = {
# Error code table for the QuICT system.
1000: "QuICT Exception",
# 1001-1999: QuICT Core Module Exception
1001: "QuICT Core Module Type Exception",
1002: "QuICT Core Module Value Exception",
1003: "QuICT Core Module Index Exceed Exception",
1004: "QuICT Circuit Append Operato... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/exception/quict_exception.py | 0.796174 | 0.5816 | quict_exception.py | pypi |
import random
import numpy as np
from QuICT.core import Circuit
from QuICT.core.gate import *
class BenchmarkCircuitBuilder:
"""
A class fetch QuICT benchmark circuits.
Args:
width(int): number of qubits
size(int): number of gates
random_params (bool, optional): whether random pa... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/circuit_library/get_benchmark_circuit.py | 0.556761 | 0.443661 | get_benchmark_circuit.py | pypi |
import os
import re
import shutil
from typing import Union, List
from QuICT.core import Circuit
from QuICT.core.gate import GateType
from QuICT.lib.qasm.exceptions import QasmError
from QuICT.tools import Logger
from QuICT.tools.interface import OPENQASMInterface
from .circuit_lib_sql import CircuitLibDB
from .get_ben... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/circuit_library/circuitlib.py | 0.773772 | 0.297862 | circuitlib.py | pypi |
import os
from collections import OrderedDict
from configparser import ConfigParser
from QuICT.core import Circuit
from QuICT.core.gate import *
from QuICT.core.utils import GateType
from QuICT.lib import Qasm
from QuICT.tools.exception.core import QASMError
from .basic_interface import BasicInterface
class qasm_q... | /quict-1.0.0-1-py3-none-any.whl/QuICT/tools/interface/qasm_interface.py | 0.589244 | 0.336031 | qasm_interface.py | pypi |
from .utils import *
import pyaudio
def chunks(arr, n):
for i in range(0, len(arr), n):
yield arr[i:i + n]
FORMAT = pyaudio.paFloat32
CHANNELS = 1
SAMPLE_RATE = 48000
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=SAMPLE_RATE,
... | /quiet_py_wasm-0.1.3-py3-none-any.whl/quiet_py_wasm/transmitter.py | 0.569733 | 0.171824 | transmitter.py | pypi |
import pyaudio
from queue import Queue
from .utils import *
FORMAT = pyaudio.paFloat32
CHANNELS = 1
SAMPLE_RATE = 48000
p = pyaudio.PyAudio()
class Receiver:
def __init__(self, instance):
self.destroyed = False
self.instance = instance
def select_profile(self, profile):
stack = self... | /quiet_py_wasm-0.1.3-py3-none-any.whl/quiet_py_wasm/receiver.py | 0.52829 | 0.158793 | receiver.py | pypi |
import numpy as np
import tensorflow as tf
import tensorflow_probability as tfp
from keras import backend
from keras.engine import base_layer
from keras.utils import control_flow_util
@tf.keras.utils.register_keras_serializable(package="quik_ai")
class Conv2DTransposeBlock(tf.keras.layers.Layer):
def __init__(sel... | /quik-ai-1.3.2.tar.gz/quik-ai-1.3.2/src/quik_ai/layers.py | 0.901128 | 0.44342 | layers.py | pypi |
import tensorflow as tf
@tf.keras.utils.register_keras_serializable(package="quik_ai")
class MeanAbsoluteErrorMetric(tf.keras.metrics.Metric):
def __init__(self, name='mean_absolute_error', **kwargs):
super().__init__(name=name, **kwargs)
self.total = self.add_weight(name='total', initializer='zero... | /quik-ai-1.3.2.tar.gz/quik-ai-1.3.2/src/quik_ai/metrics.py | 0.896438 | 0.326889 | metrics.py | pypi |
from quik_ai import tuning
from quik_ai import layers
from quik_ai import losses
from quik_ai import metrics
import numpy as np
import tensorflow as tf
import tensorflow_probability as tfp
losses_dictionary = {
'mean_absolute_error' : tf.keras.losses.MeanAbsoluteError,
'mean_squared_error' : tf.keras.losses.M... | /quik-ai-1.3.2.tar.gz/quik-ai-1.3.2/src/quik_ai/heads.py | 0.884264 | 0.312016 | heads.py | pypi |
import re, operator, os
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
xrange = range
VERSION = (0, 2, 2)
VERSION_TAG = None
__version__ = ".".join(map(str, VERSION))
if VERSION_TAG:
__version__ = "{0}-{1}".format(
__version__, VERSION_TAG)
class Template:
... | /quik-0.2.2.tar.gz/quik-0.2.2/quik.py | 0.459561 | 0.208461 | quik.py | pypi |
import datetime, time, functools, operator, types
default_fudge = datetime.timedelta(seconds=0, microseconds=0, days=0)
def deep_eq(_v1, _v2, datetime_fudge=default_fudge, _assert=False):
"""
Tests for deep equality between two python data structures recursing
into sub-structures if necessary. Works with all ... | /quill_delta-1.0.3-py3-none-any.whl/delta/deep_eq.py | 0.511717 | 0.516839 | deep_eq.py | pypi |
import copy
import diff_match_patch
try:
from functools import reduce
except:
pass
from . import op
NULL_CHARACTER = chr(0)
DIFF_EQUAL = 0
DIFF_INSERT = 1
DIFF_DELETE = -1
def merge(a, b):
return copy.deepcopy(a or {}).update(b or {})
def differ(a, b, timeout=1):
differ = diff_match_patch.diff_ma... | /quill_delta-1.0.3-py3-none-any.whl/delta/base.py | 0.433022 | 0.162613 | base.py | pypi |
import copy
def compose(a, b, keep_null=False):
"""
Compose two operations into one.
``keep_null`` [default=false] is a boolean that controls whether None/Null
attributes are retrained.
"""
if a is None:
a = {}
if b is None:
b = {}
# deep copy b, but get rid of None ... | /quill_delta-1.0.3-py3-none-any.whl/delta/op.py | 0.661158 | 0.318459 | op.py | pypi |
# Quilla
[](https://github.com/microsoft/quilla/actions/workflows/codeql-analysis.yml)
[:
"""A marker interface that allows us to... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/interfaces.py | 0.520009 | 0.359055 | interfaces.py | pypi |
# Standard library imports
from types import StringTypes
# Zope 3 imports
from zope.interface import implements
from zope.component import getUtility
from zope.component.interface import interfaceToName
# Zope 2 imports
from Acquisition import Implicit, aq_base
from OFS.Traversable import Traversable
# CMF imports
f... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/topic.py | 0.688887 | 0.204699 | topic.py | pypi |
from Acquisition import aq_base
from ZPublisher.BaseRequest import DefaultPublishTraverse
from archive import ArchiveContainer
from archive import DayArchive
from archive import MonthArchive
from archive import YearArchive
from quills.core.interfaces import IAuthorContainer
from quills.core.interfaces import ITopicCont... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/traversal.py | 0.565059 | 0.166608 | traversal.py | pypi |
# Zope imports
from zope.interface import implements
from zope.component.interface import interfaceToName
from Acquisition import Implicit
from DateTime.DateTime import DateTime
from DateTime.DateTime import DateError
from OFS.Traversable import Traversable
# CMF imports
from Products.CMFCore.utils import getToolByNa... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/archive.py | 0.742702 | 0.150746 | archive.py | pypi |
from Acquisition import aq_base, aq_inner, aq_parent
from Products.CMFPlone.browser.interfaces import INavigationBreadcrumbs
from Products.CMFPlone.interfaces.siteroot import IPloneSiteRoot
from quills.core.interfaces import IBaseContent, IWeblogEntry, IWeblogEnhanced
from zope.component import getMultiAdapter
from zop... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/browser/breadcrumbs.py | 0.58676 | 0.184253 | breadcrumbs.py | pypi |
from zope import schema
from zope.formlib import form
from zope.interface import implements
from zope.component import getMultiAdapter
from plone.app.portlets.portlets import base
from plone.portlets.interfaces import IPortletDataProvider
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from q... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/portlets/recentcomments.py | 0.549641 | 0.185357 | recentcomments.py | pypi |
from zope.formlib import form
from zope.interface import implements
from plone.app.portlets.portlets import base
from plone.app.portlets.browser.formhelper import NullAddForm
from plone.portlets.interfaces import IPortletDataProvider
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from quills... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/portlets/tagcloud.py | 0.557123 | 0.259389 | tagcloud.py | pypi |
from zope import schema
from zope.formlib import form
from zope.interface import implements
from plone.app.portlets.portlets import base
from plone.memoize.compress import xhtml_compress
from plone.portlets.interfaces import IPortletDataProvider
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/portlets/authors.py | 0.538498 | 0.201126 | authors.py | pypi |
from zope.formlib import form
from zope.interface import implements
from plone.app.portlets.portlets import base
from plone.app.portlets.browser.formhelper import NullAddForm
from plone.memoize.compress import xhtml_compress
from plone.portlets.interfaces import IPortletDataProvider
from Products.Five.browser.pagetem... | /quills.app-1.8.1.tar.gz/quills.app-1.8.1/quills/app/portlets/archive.py | 0.606615 | 0.206564 | archive.py | pypi |
from zope.interface import Interface
# Local imports
from basecontent import IBaseContent
class IReadWeblogEntry(IBaseContent):
"""A weblog entry.
"""
def getId():
"""Return the id of the entry.
"""
def getTitle():
"""Return the title of the entry.
"""
def getTo... | /quills.core-1.7.0c1.tar.gz/quills.core-1.7.0c1/quills/core/interfaces/weblogentry.py | 0.69451 | 0.361672 | weblogentry.py | pypi |
from zope.interface import Interface
from zope import schema
# Quills import
from basecontent import IBaseContent
from topic import ITopicContainer
from topic import IAuthorContainer
from archive import IWeblogArchive
from quills.core import QuillsCoreMessageFactory as _
class IReadWeblog(IWeblogArchive,
... | /quills.core-1.7.0c1.tar.gz/quills.core-1.7.0c1/quills/core/interfaces/weblog.py | 0.815122 | 0.307345 | weblog.py | pypi |
from zope.interface import Interface
from quills.core.interfaces.basecontent import IBaseContent
class IBaseView(IBaseContent):
"""Base Quills view.
"""
def isWeblogContent(obj=None):
"""Return True if obj is one of the weblog content types in the sense of
the interface it provides; Fals... | /quills.core-1.7.0c1.tar.gz/quills.core-1.7.0c1/quills/core/browser/interfaces.py | 0.725162 | 0.331918 | interfaces.py | pypi |
import warnings
import keyword
import importlib
# String modules
import string
import secrets
import textwrap
# System modules
import subprocess
import os
import sys
import logging
import pkg_resources
import pip
import tempfile
import base64
# Math modules
import math
import statistics
import random
# Time modules... | /quilt_lang-0.11.1-py3-none-any.whl/quilt_lang/__init__.py | 0.645455 | 0.418222 | __init__.py | pypi |
import typing as T
import logging
from enum import Enum
FORMAT_STR = "%(asctime)s | %(process)d | %(name)s | %(levelname)s: %(message)s"
class Color(str, Enum):
BLACK = 0
RED = 1
GREEN = 2
YELLOW = 3
BLUE = 4
PURPLE = 5
TEAL = 6
GREY = 7
RESET_STR = "\x1b[0m"
def format_str_from_... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/logs.py | 0.582135 | 0.15863 | logs.py | pypi |
import typing as T
import datetime
from enum import Enum
from pydantic import BaseModel, Field, root_validator
import strawberry
import edge_orm
from edge_orm import UNSET, UnsetType
import sentry_sdk
from dataclasses import dataclass, asdict
def to_lower_camel(string: str) -> str:
return "".join(
word.ca... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/plugins/StrawberryFilters/default_filters.py | 0.698432 | 0.235537 | default_filters.py | pypi |
import re
import typing as T
import types
from enum import Enum
from pathlib import Path
from black import format_str, FileMode
import edge_orm
from edge_orm.types_generator.main import stringify_dict
"""NODES"""
NodeType = T.TypeVar("NodeType", bound=T.Type[edge_orm.Node])
cast_to_python_filter_name = {
"std::... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/plugins/StrawberryFilters/generator.py | 0.474388 | 0.21261 | generator.py | pypi |
import typing as T
import hashlib
from inspect import isawaitable
from typing import Optional
from sentry_sdk import configure_scope, start_span, set_user
from strawberry.extensions import SchemaExtension
from strawberry.extensions.tracing.utils import should_skip_tracing
from strawberry.types.execution import Execut... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/extensions/sentry.py | 0.767951 | 0.222025 | sentry.py | pypi |
from __future__ import annotations
import typing as T
from pydantic import BaseModel
from strawberry.types.types import TypeDefinition
from edge_orm import Node, Resolver
from quilt.vendors.Sentry.context_managers import span
NodeType = T.TypeVar("NodeType", bound=Node)
NodeTypeTemp = T.TypeVar("NodeTypeTemp", bound=N... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/gql_utils/strawberry_utils.py | 0.827306 | 0.372734 | strawberry_utils.py | pypi |
import typing as T
import functools
import inspect
from enum import Enum
from pydantic import BaseModel
from edge_orm import Resolver, Node
from edge_orm.types_generator.main import COUNT_POSTFIX
from ..strawberry_utils import StrawMixin
from strawberry.types.nodes import SelectedField
from app import helpers
NodeTyp... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/gql_utils/resolvers/models.py | 0.467332 | 0.211417 | models.py | pypi |
import typing as T
import inspect
from enum import Enum
from strawberry.type import StrawberryList
from strawberry.union import StrawberryUnion
from strawberry.types.nodes import SelectedField, FragmentSpread, InlineFragment
from quilt.gql_utils.strawberry_utils import StrawMixin
from quilt.gql_utils.resolvers.models i... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/gql_utils/resolvers/hydrate.py | 0.426202 | 0.174956 | hydrate.py | pypi |
import httpx
from pydantic import BaseModel
from quilt.vendors.GooglePlaces.main import Place, Address
from quilt import DisplayException
TZ_FROM_COORDS_URL = (
"https://getzipcodeinfo.herokuapp.com/get_tz_from_coords?lat=<LAT>&lng=<LNG>"
)
class LocationError(DisplayException):
pass
def tz_from_coords(lat... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/models/location/__init__.py | 0.683631 | 0.183942 | __init__.py | pypi |
import os
import typing as T
import httpx
from pydantic import BaseModel
from quilt.errors import DisplayException
BASE_URL = "https://maps.googleapis.com/maps/api/place"
google_places_api_key = os.environ["GOOGLE_PLACES_API_KEY"]
class GooglePlacesException(Exception):
pass
class GooglePlacesExceptionDisplay... | /quilt_py-0.10.5.tar.gz/quilt_py-0.10.5/quilt/vendors/GooglePlaces/main.py | 0.493409 | 0.184198 | main.py | pypi |
import asyncio
import dataclasses
import datetime
import typing as T
import ariadne
import importlib_resources
from . import buckets, packages
DatetimeScalar = ariadne.ScalarType(
"Datetime",
serializer=lambda value: value if value is None else value.isoformat(),
)
QueryType = ariadne.QueryType()
PackageLi... | /quilt3_local-1.2.1.tar.gz/quilt3_local-1.2.1/quilt3_local/graphql.py | 0.489748 | 0.237333 | graphql.py | pypi |
import json
import sys
import tempfile
from io import BytesIO
from math import sqrt
from typing import List, Tuple
import imageio
import numpy as np
import requests
from aicsimageio import AICSImage, readers
from PIL import Image
from .shared.decorator import QUILT_INFO_HEADER, api, validate
from .shared.utils import... | /quilt3_local-1.2.1.tar.gz/quilt3_local-1.2.1/quilt3_local/lambdas/thumbnail.py | 0.582254 | 0.373533 | thumbnail.py | pypi |
from .email import is_valid_email_address
from .results import Success, Failure
from inspect import signature
class Parameters(dict):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__dict__ = self
def with_attribute(self, parameter_name, value):
return Par... | /quiltz-domain-0.8.1.tar.gz/quiltz-domain-0.8.1/src/quiltz/domain/validator.py | 0.741955 | 0.2485 | validator.py | pypi |
(tensor-network-contraction)=
# Contraction
one of the core tasks of any tensor network algorithm: collection of tensors -> single tensor
defined as sum of products
$$
\sum_{\sigma} \prod_{i} T_i(\sigma_i)
$$
exponentially slow to do sum directly since we would have evaluate every single
combination of index value ... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/tensor-contraction.ipynb | 0.917677 | 0.920611 | tensor-contraction.ipynb | pypi |
(tensor-network-design)=
# Design
The section contains some notes on the design of quimb's tensor network
functionality that should be helpful for a) understanding how certain functions
work better, and b) implementing more advanced functions or contributing to quimb.
```
%config InlineBackend.figure_formats = ['sv... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/tensor-design.ipynb | 0.786295 | 0.983816 | tensor-design.ipynb | pypi |
# Basics
## Basic Representation
States and operators in {py:mod}`quimb` are simply dense numpy arrays
or sparse scipy matrices. All functions should directly work with these
but the class {class}`~quimb.core.qarray` is also provided as a very
thin subclass of {class}`numpy.ndarray` with a few helpful methods and
att... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/basics.ipynb | 0.489748 | 0.988154 | basics.ipynb | pypi |
(ex-tensorflow-tn-opt)=
# Optimizing a Tensor Network using Tensorflow
In this example we show how a general machine learning
strategy can be used to optimize arbitrary tensor networks
with respect to any target loss function.
We'll take the example of maximizing the overlap of some
matrix product state with periodi... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/examples/ex_tensorflow_optimize_pbc_mps.ipynb | 0.620507 | 0.989327 | ex_tensorflow_optimize_pbc_mps.ipynb | pypi |
2D Antiferromagnetic Model Example
========
This is an example of how ``ikron`` can be used to deal with a large, ``ndim > 1``, Hilbert space.
We'll define a simpler version of ``ham_heis_2D`` first:
```
import itertools
from operator import add
import numpy as np
from quimb import *
def ham_heis_2D(n, m, j=1.0, b... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/examples/ex_2d.ipynb | 0.548915 | 0.941061 | ex_2d.ipynb | pypi |
# Using `quimb` within `jax`, `flax` and `optax`
`quimb` is designed (using [`autoray`](https://github.com/jcmgray/autoray)) to
handle many different array backends, including [`jax`](https://github.com/google/jax). If you put `jax` arrays in your tensors, then `quimb` will dispatch all operations to `jax` functions,... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/examples/ex_quimb_within_jax_flax_optax.ipynb | 0.785638 | 0.981718 | ex_quimb_within_jax_flax_optax.ipynb | pypi |
MPI Interior Eigensolve with Lazy, Projected Operators
=========================
This example demonstrates some 'advanced' methods for diagonalizing large Hamiltonians.
First of all, assuming we are using ``slepc4py``, we can specify the 'arch' we want to use. In this case, there is an optimized version of 'petsc' a... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/examples/ex_distributed_shift_invert.ipynb | 0.501465 | 0.950778 | ex_distributed_shift_invert.ipynb | pypi |
# Generic Tensor Fitting
`quimb` has support for fitting arbitrary tensor networks to other tensors or tensor networks.
Here we show decomposing a 4-tensor into a ring.
```
%config InlineBackend.figure_formats = ['svg']
import numpy as np
import quimb.tensor as qtn
```
Create a target 10x10x10x10 tensor with uniform... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/examples/ex_tn_tensor_fitting.ipynb | 0.435902 | 0.980034 | ex_tn_tensor_fitting.ipynb | pypi |
# Using `quimb` within `torch`
`quimb` is designed (using [`autoray`](https://github.com/jcmgray/autoray)) to
handle many different array backends, including [`torch`](https://github.com/google/jax). If you put `torch` arrays in your tensors, then `quimb` will dispatch all operations to `torch` functions, and moreove... | /quimb-1.5.1.tar.gz/quimb-1.5.1/docs/examples/ex_quimb_within_torch.ipynb | 0.852951 | 0.984306 | ex_quimb_within_torch.ipynb | pypi |
from __future__ import annotations, print_function
import sys
from typing import Iterable, List, Optional, Set, Tuple
import quine_mccluskey_tomas789._quine_mccluskey_tomas789 as _qmc
class ResultWithProfile:
"""A wrapper around minimization results with profiling stats."""
none: ResultWithProfile
def... | /quine_mccluskey_tomas789-0.2.5-cp37-cp37m-musllinux_1_1_i686.whl/quine_mccluskey_tomas789/qm.py | 0.857231 | 0.387777 | qm.py | pypi |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.