repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
sst-macro
sst-macro-master/python/default.py
from sst.macro import * import sys import os import sst ic = setupDeprecated()
81
9.25
23
py
sst-macro
sst-macro-master/bin/sstcompile.py
""" Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering So...
8,647
32.78125
106
py
sst-macro
sst-macro-master/bin/configlib.py
""" Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering So...
3,463
35.463158
95
py
sst-macro
sst-macro-master/bin/sstlink.py
""" Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering So...
2,910
42.447761
84
py
sst-macro
sst-macro-master/bin/sstccutils.py
def swapSuffix(suffix, path): splitter = path.split(".")[:-1] splitter.append(suffix) return ".".join(splitter) def rebaseFolder(path, srcDir, dstDir): folder, fname = os.path.split(path) newBaseFolder = folder.replace(srcDir,dstDir) return os.path.join(newBaseFolder, fname) def addPrefix(prefix, path):...
1,809
26.014925
124
py
sst-macro
sst-macro-master/bin/sstcclib.py
""" Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering So...
22,732
36.637417
151
py
sst-macro
sst-macro-master/bin/tools/configlib.py
""" Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering So...
3,124
36.650602
93
py
sst-macro
sst-macro-master/bin/tools/opa_snapshot_route_tracer.py
#!/usr/bin/env python3 __license__ = """ Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by N...
4,636
37.966387
139
py
sst-macro
sst-macro-master/bin/tools/ref.py
#! /usr/bin/env python __license__ = """ Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by N...
2,790
36.716216
81
py
sst-macro
sst-macro-master/bin/tools/opareport_snapshot_parser.py
#!/usr/bin/env python3 __license__ = """ Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by N...
11,770
38.106312
185
py
sst-macro
sst-macro-master/bin/config_tools/configlib.py
""" Copyright 2009-2023 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering So...
4,253
35.672414
81
py
sst-macro
sst-macro-master/bin/plots/syncplot.py
import re import os import matplotlib.pyplot as plt import numpy as np import re import sys remap = { "MPI_Waitsome" : "MPI_Wait", "ComputeTime" : "Compute", "ComputeInstructions" : "Compute", "MPIEager1Protocol_Handle_RDMA_Header" : "MPI Compute", "MPIEager1Protocol_Handle_RDMA_Payload" : "MPI Compute", "MPIEager0...
6,559
24.038168
99
py
sst-macro
sst-macro-master/tests/testsuite_default_sst_macro.py
# -*- coding: utf-8 -*- from sst_unittest import * from sst_unittest_support import * ################################################################################ # Code to support a single instance module initialize, must be called setUp method module_init = 0 module_sema = threading.Semaphore() def initialize...
2,610
33.355263
95
py
sst-macro
sst-macro-master/tests/api/globals/config.py
import sst.macro sst.macro.loadLibrary("libsstmac_api_globals_test.so") sst.macro.setupDeprecated()
100
24.25
54
py
sst-macro
sst-macro-master/tests/api/mpi/config.py
import sst.macro sst.macro.setupDeprecated()
45
14.333333
27
py
sst-macro
sst-macro-master/share/sstlldb.py
import lldb import commands import optparse import shlex def start(debugger, command, result, internal_dict): debugger.HandleCommand("pro handle SIGUSR1 -p true -s false -n false") debugger.HandleCommand("br set -b sst_gdb_swap") debugger.HandleCommand("br com add -o bt") newCmd = "expr --ignore-breakpoints f...
911
37
82
py
sst-macro
sst-macro-master/docs/manual/figures/matplotlib/ftq/output_app1.py
#!/usr/bin/env python3 try: import sys import numpy as np import matplotlib.pyplot as plt import argparse except ImportError: print('ImportError caught. Please install matplotlib') exit() import numpy as np import matplotlib.pyplot as plt import argparse # Getting CLI args parser = argparse.A...
1,496
29.55102
85
py
sst-macro
sst-macro-master/skeletons/sst_component_example/run.py
import sst from sst.macro import * import sst.test latency="1us" comp1 = sst.Component("1", "test.dummy_switch") comp1.addParam("id", 1) comp1.addParam("latency", latency) comp2 = sst.Component("2", "test.dummy_switch") comp2.addParam("id", 2) comp2.addParam("latency", latency) port=0 comp1Id=1 comp2Id=2 makeBiNetwo...
413
18.714286
47
py
SimCSE
SimCSE-main/setup.py
import io from setuptools import setup, find_packages with io.open('./README.md', encoding='utf-8') as f: readme = f.read() setup( name='simcse', packages=['simcse'], version='0.4', license='MIT', description='A sentence embedding tool based on SimCSE', author='Tianyu Gao, Xingcheng Yao, D...
767
26.428571
88
py
SimCSE
SimCSE-main/evaluation.py
import sys import io, os import numpy as np import logging import argparse from prettytable import PrettyTable import torch import transformers from transformers import AutoModel, AutoTokenizer # Set up logger logging.basicConfig(format='%(asctime)s : %(message)s', level=logging.DEBUG) # Set PATHs PATH_TO_SENTEVAL = ...
8,127
38.456311
165
py
SimCSE
SimCSE-main/simcse_to_huggingface.py
""" Convert SimCSE's checkpoints to Huggingface style. """ import argparse import torch import os import json def main(): parser = argparse.ArgumentParser() parser.add_argument("--path", type=str, help="Path of SimCSE checkpoint folder") args = parser.parse_args() print("SimCSE checkpoint -> Hugging...
1,327
29.181818
107
py
SimCSE
SimCSE-main/train.py
import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional, Union, List, Dict, Tuple import torch import collections import random from datasets import load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPP...
24,040
39.955707
144
py
SimCSE
SimCSE-main/simcse/tool.py
import logging from tqdm import tqdm import numpy as np from numpy import ndarray import torch from torch import Tensor, device import transformers from transformers import AutoModel, AutoTokenizer from sklearn.metrics.pairwise import cosine_similarity from sklearn.preprocessing import normalize from typing import List...
12,092
41.135889
160
py
SimCSE
SimCSE-main/simcse/trainers.py
import collections import inspect import math import sys import os import re import json import shutil import time import warnings from pathlib import Path import importlib.util from packaging import version from transformers import Trainer from transformers.modeling_utils import PreTrainedModel from transformers.train...
25,360
44.368515
149
py
SimCSE
SimCSE-main/simcse/models.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.distributed as dist import transformers from transformers import RobertaTokenizer from transformers.models.roberta.modeling_roberta import RobertaPreTrainedModel, RobertaModel, RobertaLMHead from transformers.models.bert.modeling_bert impo...
13,807
34.405128
161
py
SimCSE
SimCSE-main/simcse/__init__.py
from .tool import SimCSE
25
12
24
py
SimCSE
SimCSE-main/demo/gradiodemo.py
import torch from scipy.spatial.distance import cosine from transformers import AutoModel, AutoTokenizer import gradio as gr # Import our models. The package will take care of downloading the models automatically tokenizer = AutoTokenizer.from_pretrained("princeton-nlp/sup-simcse-bert-base-uncased") model = AutoModel....
2,105
40.294118
219
py
SimCSE
SimCSE-main/demo/flaskdemo.py
import json import argparse import torch import os import random import numpy as np import requests import logging import math import copy import string from tqdm import tqdm from time import time from flask import Flask, request, jsonify from flask_cors import CORS from tornado.wsgi import WSGIContainer from tornado....
2,839
32.809524
113
py
SimCSE
SimCSE-main/SentEval/setup.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import io from setuptools import setup, find_packages with io.open('./README.md', encoding='utf-8') as f: readme = f.read(...
568
24.863636
61
py
SimCSE
SimCSE-main/SentEval/examples/infersent.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ InferSent models. See https://github.com/facebookresearch/InferSent. """ from __future__ import absolute_import, division,...
2,463
31
92
py
SimCSE
SimCSE-main/SentEval/examples/bow.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import, division, unicode_literals import sys import io import numpy as np import logging # ...
3,423
29.300885
82
py
SimCSE
SimCSE-main/SentEval/examples/googleuse.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import, division import os import sys import logging import tensorflow as tf import tensorflow...
2,205
31.441176
86
py
SimCSE
SimCSE-main/SentEval/examples/models.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ This file contains the definition of encoders used in https://arxiv.org/pdf/1705.02364.pdf """ import numpy as np import t...
9,875
36.12782
94
py
SimCSE
SimCSE-main/SentEval/examples/gensen.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Clone GenSen repo here: https://github.com/Maluuba/gensen.git And follow instructions for loading the model used in batcher...
2,429
31.4
82
py
SimCSE
SimCSE-main/SentEval/examples/skipthought.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import, division, unicode_literals """ Example of file for SkipThought in SentEval """ import ...
2,048
32.048387
97
py
SimCSE
SimCSE-main/SentEval/senteval/engine.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' Generic sentence evaluation scripts wrapper ''' from __future__ import absolute_import, division, unicode_literals from ...
6,525
49.2
139
py
SimCSE
SimCSE-main/SentEval/senteval/rank.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' Image-Caption Retrieval with COCO dataset ''' from __future__ import absolute_import, division, unicode_literals import os...
4,643
41.605505
129
py
SimCSE
SimCSE-main/SentEval/senteval/snli.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' SNLI - Entailment ''' from __future__ import absolute_import, division, unicode_literals import codecs import os import io...
4,577
39.157895
75
py
SimCSE
SimCSE-main/SentEval/senteval/utils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import, division, unicode_literals import numpy as np import re import inspect from torch impo...
2,713
27.270833
79
py
SimCSE
SimCSE-main/SentEval/senteval/binary.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' Binary classifier and corresponding datasets : MR, CR, SUBJ, MPQA ''' from __future__ import absolute_import, division, uni...
3,712
38.924731
79
py
SimCSE
SimCSE-main/SentEval/senteval/mrpc.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' MRPC : Microsoft Research Paraphrase (detection) Corpus ''' from __future__ import absolute_import, division, unicode_liter...
4,202
39.028571
80
py
SimCSE
SimCSE-main/SentEval/senteval/sts.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' STS-{2012,2013,2014,2015,2016} (unsupervised) and STS-benchmark (supervised) tasks ''' from __future__ import absolute_imp...
9,696
40.797414
104
py
SimCSE
SimCSE-main/SentEval/senteval/probing.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' probing tasks ''' from __future__ import absolute_import, division, unicode_literals import os import io import copy impo...
6,786
38.459302
120
py
SimCSE
SimCSE-main/SentEval/senteval/sick.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' SICK Relatedness and Entailment ''' from __future__ import absolute_import, division, unicode_literals import os import io...
9,243
41.599078
80
py
SimCSE
SimCSE-main/SentEval/senteval/__init__.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # from __future__ import absolute_import from senteval.engine import SE
264
23.090909
61
py
SimCSE
SimCSE-main/SentEval/senteval/trec.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' TREC question-type classification ''' from __future__ import absolute_import, division, unicode_literals import os import...
3,565
38.622222
79
py
SimCSE
SimCSE-main/SentEval/senteval/sst.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' SST - binary classification ''' from __future__ import absolute_import, division, unicode_literals import os import io im...
3,946
39.690722
94
py
SimCSE
SimCSE-main/SentEval/senteval/tools/relatedness.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Semantic Relatedness (supervised) with Pytorch """ from __future__ import absolute_import, division, unicode_literals impo...
4,552
32.725926
100
py
SimCSE
SimCSE-main/SentEval/senteval/tools/validation.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Validation and classification (train) : inner-kfold classifier (train, test) : kfold classifier (train, d...
10,358
40.939271
93
py
SimCSE
SimCSE-main/SentEval/senteval/tools/classifier.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Pytorch Classifier class in the style of scikit-learn Classifiers include Logistic Regression and MLP """ from __future__ ...
7,737
37.118227
94
py
SimCSE
SimCSE-main/SentEval/senteval/tools/__init__.py
0
0
0
py
SimCSE
SimCSE-main/SentEval/senteval/tools/ranking.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Image Annotation/Search for COCO with Pytorch """ from __future__ import absolute_import, division, unicode_literals impor...
15,275
41.433333
109
py
RISS19
RISS19-master/varcalc.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, division from astropy.coordinates import SkyCoord from astropy.table import Table, Column import astropy.units as u from astropy.utils.exceptions import AstropyWarning from lib.SM2017 import SM, kpc import logging import os import sy...
10,052
30.317757
98
py
RISS19
RISS19-master/HaVS.py
from __future__ import print_function, division import os import logging import cPickle import argparse import numpy as np import numpy.polynomial.polynomial as poly from astropy.coordinates import SkyCoord from astropy.table import Table, Column import astropy.units as u from lib.new_SM17 import SM from astropy.utils....
22,316
39.948624
186
py
RISS19
RISS19-master/lib/__init__.py
__author__ = ['Paul Hancock', 'Elliott Charlton'] __version__ = 0.9
67
33
49
py
RISS19
RISS19-master/lib/Tau.py
from astropy.constants import kpc, c from astropy.coordinates import SkyCoord from astropy.io import fits from astropy.wcs import WCS import astropy.units as u import numpy as np import os import logging from scipy.special import gamma class SM(object): """ :param ha_file: :param err_file: :param nu: f...
4,586
32.977778
107
py
RISS19
RISS19-master/lib/tau.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, division from astropy.constants import kpc, c from astropy.coordinates import SkyCoord from astropy.io import fits from astropy.wcs import WCS import astropy.units as u from astropy.table import Table, Column import numpy as np import...
15,788
38.972152
131
py
RISS19
RISS19-master/lib/SM2017.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, division """ NE2001 for extragalactic work. """ from astropy.constants import kpc, c, au from astropy.coordinates import SkyCoord from astropy.io import fits from astropy.wcs import WCS import astropy.units as u import numpy as np i...
13,420
39.303303
125
py
qfactor
qfactor-master/setup.py
from os import path from setuptools import setup, find_namespace_packages # Use READEME for long description. root_dir = path.abspath( path.dirname( __file__ ) ) readme_path = path.join( root_dir, "README.md" ) with open( readme_path, encoding = "utf-8" ) as f: long_description = f.read() # use requirements.txt...
1,980
36.377358
71
py
qfactor
qfactor-master/benchmarks/fixed_time/param_problem.py
import numpy as np import itertools as it from scipy.stats import unitary_group import qfactor from qfactor import CnotGate, Gate, optimize from qfactor.tensors import CircuitTensor import qsearch import qfast from qfast.decomposition.models.fixedmodel import FixedModel from qfast.decomposition.optimizers.lbfgs impo...
3,199
36.647059
83
py
qfactor
qfactor-master/benchmarks/fixed_time/gen_scripts.py
import os import csv script_fmt = ( "NUMQUBITS=%d\n" "GATESIZE=%d\n" "DEPTH=%d\n" "TIMEOUT=%d\n" "TESTQFACTOR=%s\n" "python fixed_time_exp.py $NUMQUBITS $GATESIZE $DEPTH $POINTS $TIMEOUT\n" ) script_name_fmt = "run_%s_%dq_%dg_%dd_%ds.sh" time...
1,526
35.357143
96
py
qfactor
qfactor-master/benchmarks/fixed_time/fixed_time_exp.py
import pickle import signal import argparse import numpy as np import itertools as it from timeit import default_timer as timer from scipy.stats import unitary_group import qfactor from qfactor import CnotGate, Gate, optimize from qfactor.tensors import CircuitTensor import qsearch import qfast from qfast.decomposi...
4,407
28.386667
95
py
qfactor
qfactor-master/benchmarks/fixed_num_problems/gen_scripts.py
import os import csv script_fmt = ( "NUMQUBITS=%d\n" "GATESIZE=%d\n" "DEPTH=%d\n" "POINTS=%d\n" "TIMEOUT=%d\n" "python rand_seq.py $NUMQUBITS $GATESIZE $DEPTH $POINTS $TIMEOUT\n" ) script_name_fmt = "run_%dq_%dg_%dd_%dp.sh" with open( "exp.cs...
950
28.71875
84
py
qfactor
qfactor-master/benchmarks/fixed_num_problems/rand_seq.py
import pickle import signal import argparse import numpy as np import itertools as it from timeit import default_timer as timer from scipy.stats import unitary_group import qfactor from qfactor import CnotGate, Gate, optimize from qfactor.tensors import CircuitTensor import qsearch import qfast from qfast.decomposi...
7,311
32.695853
92
py
qfactor
qfactor-master/examples/param_extraction.py
""" Optimize a 3-qubit circuit to be a toffoli gate. In this example, we use a more native structure and extract angles for RzGates from the optimized result. """ import numpy as np from qfactor import Gate, optimize, CnotGate, RzGate # The next two lines start qfactor's logger. import logging logging.getLogger( "...
2,589
36
77
py
qfactor
qfactor-master/examples/toffoli_synthesis.py
"""Optimize a 3-qubit circuit to be a toffoli gate.""" import numpy as np from scipy.stats import unitary_group from qfactor import Gate, optimize, get_distance # The next two lines start qfactor's logger. import logging logging.getLogger( "qfactor" ).setLevel( logging.INFO ) # We will optimize towards the toffoli...
2,262
40.145455
77
py
qfactor
qfactor-master/qfactor/utils.py
"""This module contains various utility functions.""" import logging import numpy as np logger = logging.getLogger( "qfactor" ) def get_num_qubits ( M ): """Returns the size of the square matrix, M, in qubits.""" if not is_square_matrix( M ): raise TypeError( "Invalid matrix." ) return int( ...
2,665
23.685185
80
py
qfactor
qfactor-master/qfactor/optimize.py
"""This module implements the main optimize function.""" import logging import numpy as np from qfactor import utils from qfactor.gates import Gate from qfactor.tensors import CircuitTensor logger = logging.getLogger( "qfactor" ) def optimize ( circuit, target, diff_tol_a = 1e-12, diff_tol_r = 1e-6, ...
4,932
29.83125
78
py
qfactor
qfactor-master/qfactor/__init__.py
""" Quantum Fast Circuit Optimizer (qFactor) This package provides functions to optimize the unitaries in a circuit with respect to some target unitary matrix. """ # Initialize Logging import logging _logger = logging.getLogger( "qfactor" ) _logger.setLevel(logging.CRITICAL) _handler = logging.StreamHandler() _handle...
609
25.521739
70
py
qfactor
qfactor-master/qfactor/tensors.py
"""This module implements the CircuitTensor class.""" import logging import numpy as np from qfactor import utils from qfactor.gates import Gate logger = logging.getLogger( "qfactor" ) class CircuitTensor(): """A CircuitTensor tracks an entire circuit as a tensor.""" def __init__ ( self, utry_target, gat...
5,693
32.892857
87
py
qfactor
qfactor-master/qfactor/gates/xx.py
"""This module implements the XXGate class.""" import numpy as np from qfactor import utils from qfactor.gates import Gate class XXGate ( Gate ): """A XXGate is a Quantum XX-rotation applied to a qubit.""" def __init__ ( self, theta, location, fixed = False, check_params = True ): """ Gate...
2,813
30.266667
79
py
qfactor
qfactor-master/qfactor/gates/rz.py
"""This module implements the RzGate class.""" import numpy as np from qfactor import utils from qfactor.gates import Gate class RzGate ( Gate ): """A RzGate is a Quantum Z-rotation applied to a qubit.""" def __init__ ( self, theta, location, fixed = False, check_params = True ): """ Gate ...
2,718
28.236559
79
py
qfactor
qfactor-master/qfactor/gates/rx.py
"""This module implements the RxGate class.""" import numpy as np from qfactor import utils from qfactor.gates import Gate class RxGate ( Gate ): """A RxGate is a Quantum X-rotation applied to a qubit.""" def __init__ ( self, theta, location, fixed = False, check_params = True ): """ Gate ...
2,744
29.842697
79
py
qfactor
qfactor-master/qfactor/gates/cnot.py
"""This module implements the CnotGate class.""" import numpy as np from qfactor import utils from qfactor.gates import Gate class CnotGate ( Gate ): """A CnotGate is a controlled-not applied to a pair of qubit.""" def __init__ ( self, control, target, check_params = True ): """ Gate Const...
1,760
27.868852
72
py
qfactor
qfactor-master/qfactor/gates/__init__.py
from .gate import Gate from .rx import RxGate from .ry import RyGate from .rz import RzGate from .xx import XXGate from .cnot import CnotGate
143
17
26
py
qfactor
qfactor-master/qfactor/gates/gate.py
"""This module implements the Gate class.""" import numpy as np import scipy.linalg as la from qfactor import utils class Gate(): """A Gate is a unitary operation applied to a set of qubits.""" def __init__ ( self, utry, location, fixed = False, check_params = True ): """ Gate Constructor ...
3,681
29.941176
78
py
qfactor
qfactor-master/qfactor/gates/ry.py
"""This module implements the RyGate class.""" import numpy as np from qfactor import utils from qfactor.gates import Gate class RyGate ( Gate ): """A RyGate is a Quantum Y-rotation applied to a qubit.""" def __init__ ( self, theta, location, fixed = False, check_params = True ): """ Gate ...
2,733
29.719101
79
py
qfactor
qfactor-master/tests/__init__.py
0
0
0
py
qfactor
qfactor-master/tests/optimize/test_correct.py
import numpy as np import unittest as ut from scipy.stats import unitary_group from qfactor.optimize import optimize, Gate class TestOptimizeFixed ( ut.TestCase ): def test_optimize_fixed ( self ): u1 = unitary_group.rvs( 8 ) g1 = Gate( u1, (0, 1, 2) ) circ = optimize( [ g1 ], u1 ) ...
425
18.363636
63
py
qfactor
qfactor-master/tests/optimize/__init__.py
0
0
0
py
qfactor
qfactor-master/tests/optimize/test_fixed.py
import numpy as np import unittest as ut from scipy.stats import unitary_group from qfactor.optimize import optimize, Gate class TestOptimizeFixed ( ut.TestCase ): def test_optimize_fixed ( self ): g1 = Gate( unitary_group.rvs( 4 ), (0, 1), True ) g2 = Gate( unitary_group.rvs( 8 ), (1, 2, 3), T...
562
23.478261
63
py
qfactor
qfactor-master/tests/tensors/test_constructor.py
import numpy as np import unittest as ut from qfactor.gates import Gate from qfactor.tensors import CircuitTensor class TestCircuitTensorConstructor ( ut.TestCase ): TOFFOLI = np.asarray( [[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j...
2,562
48.288462
82
py
qfactor
qfactor-master/tests/tensors/test_apply_left.py
import numpy as np import unittest as ut from scipy.stats import unitary_group from qfactor.gates import Gate from qfactor.tensors import CircuitTensor class TestApplyLeft ( ut.TestCase ): def test_apply_left ( self ): u1 = unitary_group.rvs( 8 ) u2 = unitary_group.rvs( 4 ) g = Gate( u...
931
24.189189
60
py
qfactor
qfactor-master/tests/tensors/test_calc_env_matrix.py
import numpy as np import unittest as ut from scipy.stats import unitary_group from qfactor.gates import Gate from qfactor.tensors import CircuitTensor class TestCalcEnvMatrix ( ut.TestCase ): def test_calc_env_matrix ( self ): u1 = unitary_group.rvs( 8 ) u2 = u1.conj().T ct = CircuitT...
765
20.885714
73
py
qfactor
qfactor-master/tests/tensors/test_apply_right.py
import numpy as np import unittest as ut from scipy.stats import unitary_group from qfactor.gates import Gate from qfactor.tensors import CircuitTensor class TestApplyRight ( ut.TestCase ): def test_apply_right ( self ): u1 = unitary_group.rvs( 8 ) u2 = unitary_group.rvs( 4 ) g = Gate(...
937
24.351351
60
py
qfactor
qfactor-master/tests/tensors/__init__.py
0
0
0
py
qfactor
qfactor-master/tests/tensors/test_toffoli_tensor.py
import numpy as np import unittest as ut from qfast.perm import calc_permutation_matrix from qfactor import Gate, optimize from qfactor.tensors import CircuitTensor class TestToffoliTensor ( ut.TestCase ): def test_toffoli_tensor ( self ): toffoli = np.array( [ [ 1, 0, 0, 0, 0, 0, 0, 0 ], ...
2,881
36.921053
92
py
qfactor
qfactor-master/tests/gates/__init__.py
0
0
0
py
qfactor
qfactor-master/tests/gates/xx/test_constructor.py
import scipy import numpy as np import unittest as ut from qfactor import get_distance from qfactor.gates import XXGate class TestXXGateConstructor ( ut.TestCase ): def test_xxgate_constructor_invalid ( self ): self.assertRaises( TypeError, XXGate, 1, 0 ) self.assertRaises( TypeError, XXGate, ...
1,188
32.027778
66
py
qfactor
qfactor-master/tests/gates/xx/test_repr.py
import numpy as np import unittest as ut from qfactor.gates import XXGate class TestXXGateRepr ( ut.TestCase ): def test_xxgate_repr_1 ( self ): gate = XXGate( 0., (0,1) ) self.assertEqual( repr( gate ), "(0, 1): XX(0.0)" ) def test_xxgate_repr_2 ( self ): gate = XXGate( 2., (1,3...
428
19.428571
59
py
qfactor
qfactor-master/tests/gates/xx/test_update.py
import numpy as np import unittest as ut from qfactor.gates import XXGate class TestXXGateUpdate ( ut.TestCase ): def test_xxgate_update_1 ( self ): env = XXGate( np.pi/3, (0,1) ).utry gate = XXGate( 0., (0,1) ) gate.update( env, 0 ) self.assertTrue( np.allclose( gate.theta, -...
1,020
26.594595
64
py
qfactor
qfactor-master/tests/gates/xx/__init__.py
0
0
0
py
qfactor
qfactor-master/tests/gates/rx/test_constructor.py
import scipy import numpy as np import unittest as ut from qfactor import get_distance from qfactor.gates import RxGate class TestRxGateConstructor ( ut.TestCase ): def test_rxgate_constructor_invalid ( self ): self.assertRaises( TypeError, RxGate, 1, 0 ) self.assertRaises( TypeError, RxGate, ...
1,148
31.828571
64
py
qfactor
qfactor-master/tests/gates/rx/test_repr.py
import numpy as np import unittest as ut from qfactor.gates import RxGate class TestRxGateRepr ( ut.TestCase ): def test_rxgate_repr_1 ( self ): gate = RxGate( 0., 0 ) self.assertEqual( repr( gate ), "(0,): Rx(0.0)" ) def test_rxgate_repr_2 ( self ): gate = RxGate( 2., 1 ) ...
416
18.857143
57
py
qfactor
qfactor-master/tests/gates/rx/test_update.py
import numpy as np import unittest as ut from qfactor.gates import RxGate class TestRxGateUpdate ( ut.TestCase ): def test_rxgate_update_1 ( self ): env = RxGate( np.pi/3, 0 ).utry gate = RxGate( 0., 0 ) gate.update( env, 0 ) self.assertTrue( np.allclose( gate.theta, -np.pi/3 ...
988
25.72973
64
py
qfactor
qfactor-master/tests/gates/rx/__init__.py
0
0
0
py
qfactor
qfactor-master/tests/gates/gate/test_str.py
import numpy as np import unittest as ut from qfactor.gates import Gate class TestGateStr ( ut.TestCase ): TOFFOLI = np.asarray( [[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0....
1,198
36.46875
79
py
qfactor
qfactor-master/tests/gates/gate/test_get_inverse.py
import numpy as np import unittest as ut from scipy.stats import unitary_group from qfactor.gates import Gate class TestGetInverse ( ut.TestCase ): def test_get_inverse ( self ): utry = unitary_group.rvs( 8 ) gate = Gate( utry, (0, 1, 2) ) inv_gate = gate.get_inverse() self.asse...
594
24.869565
64
py
qfactor
qfactor-master/tests/gates/gate/test_get_tensor_format.py
import numpy as np import unittest as ut from scipy.stats import unitary_group from qfactor.gates import Gate class TestGetTensorFormat ( ut.TestCase ): def test_get_tensor_format ( self ): utry = unitary_group.rvs( 8 ) gate = Gate( utry, (0, 1, 2) ) tensor = gate.get_tensor_format() ...
1,887
36.76
76
py
qfactor
qfactor-master/tests/gates/gate/test_constructor.py
import numpy as np import unittest as ut from qfactor.gates import Gate class TestGateConstructor ( ut.TestCase ): TOFFOLI = np.asarray( [[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], [0.+...
2,802
45.716667
79
py