uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
0df915910db95514df507864
train
function
def build_matrices(labels,data_name,num_of_labels): labels_writers = np.zeros((len(labels[0]), len(labels), num_of_labels)) for i in range(labels_writers.shape[0]): #num of writers for year_index, labels_year in enumerate(labels): if labels_year[i] == -1: labels_writers[i][ye...
def build_matrices(labels,data_name,num_of_labels):
labels_writers = np.zeros((len(labels[0]), len(labels), num_of_labels)) for i in range(labels_writers.shape[0]): #num of writers for year_index, labels_year in enumerate(labels): if labels_year[i] == -1: labels_writers[i][year_index] = np.array([-1]*num_of_labels) ...
kl','gcn_input', 'labels_' + str(i) + '.pkl'), 'rb') as f: l = pickle.load(f) graphs.append(g) labels.append(l) print("loaded data") return graphs,labels def build_matrices(labels,data_name,num_of_labels):
64
64
173
11
52
rachelic44/Transitions
Communal_Transitions/real_changes/real_changes.py
Python
build_matrices
build_matrices
23
34
23
23
c3f3cd1af09b9f6de6cda7aae91918c8b46bbe54
bigcode/the-stack
train
95c6cdfae9e9aef6f474d274
train
function
def load_data(data_name, time_inds): graphs = [] labels = [] for i in range(time_inds): with open(os.path.join('.', 'dataset', data_name,'pkl','gcn_input', 'graph_' + str(i) + '.pkl'), 'rb') as f: g = pickle.load(f) with open(os.path.join('.', 'dataset',data_name,'pkl','gcn_input...
def load_data(data_name, time_inds):
graphs = [] labels = [] for i in range(time_inds): with open(os.path.join('.', 'dataset', data_name,'pkl','gcn_input', 'graph_' + str(i) + '.pkl'), 'rb') as f: g = pickle.load(f) with open(os.path.join('.', 'dataset',data_name,'pkl','gcn_input', 'labels_' + str(i) + '.pkl'), 'rb'...
import os import pickle import networkx as nx import numpy as np from numpy.core.defchararray import find from pathlib import Path def load_data(data_name, time_inds):
40
64
137
9
30
rachelic44/Transitions
Communal_Transitions/real_changes/real_changes.py
Python
load_data
load_data
10
21
10
10
b94a1ee4d62f1ecfe7ae6f225e2b938402c253b1
bigcode/the-stack
train
0fb0d46e0f45b6484262c60a
train
function
def recognize(arr, func): ret = [] ind = 0 while ind < len(arr): if func(arr[ind]): start = ind while ind<len(arr) and func(arr[ind]): ind += 1 end = ind-1 ret.append((start, end)) ind += 1 return ret
def recognize(arr, func):
ret = [] ind = 0 while ind < len(arr): if func(arr[ind]): start = ind while ind<len(arr) and func(arr[ind]): ind += 1 end = ind-1 ret.append((start, end)) ind += 1 return ret
+ "/pkl/real_changes_per_label/") with open("./dataset/" + data_name + "/pkl/real_changes_per_label/matrix_labels_per_person.pkl", 'wb') as handle: pickle.dump(labels_writers, handle, protocol=pickle.HIGHEST_PROTOCOL) def recognize(arr, func):
64
64
76
6
58
rachelic44/Transitions
Communal_Transitions/real_changes/real_changes.py
Python
recognize
recognize
38
49
38
38
d10e5d37d3df98ab23528a4420494fe38b58781b
bigcode/the-stack
train
d132281f5d3ba97f9abfb09e
train
function
def clear_negs(persons_7_vector,idx): label_1 = 0.177 negs = recognize(persons_7_vector[idx], lambda x:x<0) for neg_tuple in negs: if neg_tuple[0] == 0 and neg_tuple[1] == len(persons_7_vector[idx]) - 1: print("error") exit(0) if neg_tuple[0] == 0: if pers...
def clear_negs(persons_7_vector,idx):
label_1 = 0.177 negs = recognize(persons_7_vector[idx], lambda x:x<0) for neg_tuple in negs: if neg_tuple[0] == 0 and neg_tuple[1] == len(persons_7_vector[idx]) - 1: print("error") exit(0) if neg_tuple[0] == 0: if persons_7_vector[idx][neg_tuple[1] + 1] ==...
') as handle: pickle.dump(labels_writers, handle, protocol=pickle.HIGHEST_PROTOCOL) def recognize(arr, func): ret = [] ind = 0 while ind < len(arr): if func(arr[ind]): start = ind while ind<len(arr) and func(arr[ind]): ind += 1 end = ind...
109
109
365
12
96
rachelic44/Transitions
Communal_Transitions/real_changes/real_changes.py
Python
clear_negs
clear_negs
52
73
52
52
fce9f1584b2be2e7fc80e374a3548bc6f8ea2d3f
bigcode/the-stack
train
5d09b7603a5ae5b95f6a7d01
train
function
def check(file_path,current_path=False): directory = os.path.dirname(file_path) if not os.path.exists(directory): os.makedirs(directory) print("A new directory was created: "+str(file_path)) else: print("directory exists: "+str(file_path)) if current_path: if os.path.is...
def check(file_path,current_path=False):
directory = os.path.dirname(file_path) if not os.path.exists(directory): os.makedirs(directory) print("A new directory was created: "+str(file_path)) else: print("directory exists: "+str(file_path)) if current_path: if os.path.isfile(current_path): Path(curr...
data_name+"/pkl/real_changes_per_label/real_changes_label_"+str(tag)+"_tag.pkl", 'wb') as handle: pickle.dump(persons_7_labeled, handle, protocol=pickle.HIGHEST_PROTOCOL) return persons_7_labeled def check(file_path,current_path=False):
64
64
136
8
55
rachelic44/Transitions
Communal_Transitions/real_changes/real_changes.py
Python
check
check
130
147
130
130
dc6c8cdbc4e51143981bf5bae1a64c4ac8125663
bigcode/the-stack
train
e5326f46b000c811126c1cb8
train
function
def main_real_changes(num_of_labels, data_name, time_inds): # distibution of tages: ([1118271, 13916, 18088, 20961, 2044, 10461, 1687, 1540, 5650, 4651, 9367, 2938, 6477, 4060, 10889]) changes_by_label = [] graphs, labels = load_data(data_name, time_inds) build_matrices(labels,data_name,num_of_labels) ...
def main_real_changes(num_of_labels, data_name, time_inds): # distibution of tages: ([1118271, 13916, 18088, 20961, 2044, 10461, 1687, 1540, 5650, 4651, 9367, 2938, 6477, 4060, 10889])
changes_by_label = [] graphs, labels = load_data(data_name, time_inds) build_matrices(labels,data_name,num_of_labels) # check('./dataset/'+str(data_name)+'/pkl/real_changes_per_label/') for i in range(num_of_labels): x = build_labels_7_tag(i,data_name, time_inds) # with open('labe...
def main_real_changes(num_of_labels, data_name, time_inds): # distibution of tages: ([1118271, 13916, 18088, 20961, 2044, 10461, 1687, 1540, 5650, 4651, 9367, 2938, 6477, 4060, 10889])
84
78
262
84
0
rachelic44/Transitions
Communal_Transitions/real_changes/real_changes.py
Python
main_real_changes
main_real_changes
150
168
150
151
85e776d276423a4397d2bd4b324497800b0ca8b4
bigcode/the-stack
train
db95dfdc33cea13cf46d4041
train
function
def get_uniqe_path(path): """ create directory with unique name if directory already exists, count up until unique name """ unique_path = path output_num = 1 while os.path.exists(unique_path): unique_path = path + "_{}".format(output_num) output_num += 1 return unique_pa...
def get_uniqe_path(path):
""" create directory with unique name if directory already exists, count up until unique name """ unique_path = path output_num = 1 while os.path.exists(unique_path): unique_path = path + "_{}".format(output_num) output_num += 1 return unique_path
in the right place.".format(dirname)) #------------------------------------------------------------------------------------- def make_dir(directory): """ check if directory exists, otherwise makedir (workaround for python2 incompatibility) """ if not os.path.exists(directory): os.mak...
64
64
75
7
57
wiewel/KerasGems
util/filesystem.py
Python
get_uniqe_path
get_uniqe_path
66
77
66
66
83dae5df77956ec9460f73373345529085ac1821
bigcode/the-stack
train
557a9df9f4f526a47154e1d5
train
class
class Filesystem(object): #------------------------------------------------------------------------------------- def __init__(self, root): self.root = root #------------------------------------------------------------------------------------- def __getitem__(self, key): return self....
class Filesystem(object): #-------------------------------------------------------------------------------------
def __init__(self, root): self.root = root #------------------------------------------------------------------------------------- def __getitem__(self, key): return self.get_path(key) #------------------------------------------------------------------------------------- def get...
(workaround for python2 incompatibility) """ if not os.path.exists(directory): os.makedirs(directory) #------------------------------------------------------------------------------------- def get_uniqe_path(path): """ create directory with unique name if directory already exists...
117
117
390
9
107
wiewel/KerasGems
util/filesystem.py
Python
Filesystem
Filesystem
80
129
80
81
9292bcff7c48f25930394af7e6f25975108e0ab6
bigcode/the-stack
train
c8bf9688ed71424ed19ca5aa
train
function
def find_dir(dirname, parent_levels=0): """ find_dir searches for a directory in the proximity of the working directory with the specified name It will always search in the subdirectories of the working directory, but can be allowed to search in parent directories as well. * __dirname__: the name o...
def find_dir(dirname, parent_levels=0):
""" find_dir searches for a directory in the proximity of the working directory with the specified name It will always search in the subdirectories of the working directory, but can be allowed to search in parent directories as well. * __dirname__: the name of the directory to search for * __pa...
in os.walk(start_dir): if dirpath.split(os.path.sep)[-1] == dirname: return dirpath raise RuntimeError("Could not find directory '{}'. Check if programm is executed in the right place.".format(dirname)) #---------------------------------------------------------------------------------...
64
64
211
10
54
wiewel/KerasGems
util/filesystem.py
Python
find_dir
find_dir
38
53
38
38
fb85236eb448fe3b445a72095825500d9615095d
bigcode/the-stack
train
dd5798f6ed7db863329fd026
train
function
def make_dir(directory): """ check if directory exists, otherwise makedir (workaround for python2 incompatibility) """ if not os.path.exists(directory): os.makedirs(directory)
def make_dir(directory):
""" check if directory exists, otherwise makedir (workaround for python2 incompatibility) """ if not os.path.exists(directory): os.makedirs(directory)
dirpath, _, _ in os.walk(start_dir): if dirpath.split(os.path.sep)[-1] == dirname: return dirpath raise RuntimeError("Could not find directory '{}'. Check if programm is executed in the right place.".format(dirname)) #-------------------------------------------------------------------...
64
64
43
5
59
wiewel/KerasGems
util/filesystem.py
Python
make_dir
make_dir
56
63
56
56
7ede4669b094d513a3d2247462c80624ed69254a
bigcode/the-stack
train
92cef70d6571fe566b380dd3
train
function
def find_directory(dirname): dirs_to_search = ["./", "../", "../../"] for start_dir in map(os.path.abspath, dirs_to_search): for dirpath, _, _ in os.walk(start_dir): if dirpath.split(os.path.sep)[-1] == dirname: return dirpath raise RuntimeError("Could not find directory...
def find_directory(dirname):
dirs_to_search = ["./", "../", "../../"] for start_dir in map(os.path.abspath, dirs_to_search): for dirpath, _, _ in os.walk(start_dir): if dirpath.split(os.path.sep)[-1] == dirname: return dirpath raise RuntimeError("Could not find directory '{}'. Check if programm is e...
BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #****************************************************************************** import os import datetime import pathlib impo...
64
64
89
5
59
wiewel/KerasGems
util/filesystem.py
Python
find_directory
find_directory
29
35
29
29
78646762e3934bc6d72b7749dbffb3051f208aea
bigcode/the-stack
train
c1fcc4d20837f6a1559f41b2
train
function
def main(): module_args = oci_common_utils.get_common_arg_spec() module_args.update( dict( sddc_id=dict(aliases=["id"], type="str"), compartment_id=dict(type="str"), compute_availability_domain=dict(type="str"), display_name=dict(aliases=["name"], type="st...
def main():
module_args = oci_common_utils.get_common_arg_spec() module_args.update( dict( sddc_id=dict(aliases=["id"], type="str"), compartment_id=dict(type="str"), compute_availability_domain=dict(type="str"), display_name=dict(aliases=["name"], type="str"), ...
(param) is not None ) return oci_common_utils.list_all_resources( self.client.list_sddcs, compartment_id=self.module.params.get("compartment_id"), **optional_kwargs ) SddcFactsHelperCustom = get_custom_class("SddcFactsHelperCustom") class ResourceFactsHelp...
87
87
290
3
83
LaudateCorpus1/oci-ansible-collection
plugins/modules/oci_ocvp_sddc_facts.py
Python
main
main
699
744
699
699
b06ee9aaed967979e9a3e5d72f061189bb78a8e9
bigcode/the-stack
train
40ad0e7cedf69766738493b5
train
class
class ResourceFactsHelper(SddcFactsHelperCustom, SddcFactsHelperGen): pass
class ResourceFactsHelper(SddcFactsHelperCustom, SddcFactsHelperGen):
pass
( self.client.list_sddcs, compartment_id=self.module.params.get("compartment_id"), **optional_kwargs ) SddcFactsHelperCustom = get_custom_class("SddcFactsHelperCustom") class ResourceFactsHelper(SddcFactsHelperCustom, SddcFactsHelperGen):
64
64
21
18
46
LaudateCorpus1/oci-ansible-collection
plugins/modules/oci_ocvp_sddc_facts.py
Python
ResourceFactsHelper
ResourceFactsHelper
695
696
695
695
2ed72517811ca8eb49f9571d6619b192d6096a62
bigcode/the-stack
train
1bc60eba9e1b77778be0876e
train
class
class SddcFactsHelperGen(OCIResourceFactsHelperBase): """Supported operations: get, list""" def get_required_params_for_get(self): return [ "sddc_id", ] def get_required_params_for_list(self): return [ "compartment_id", ] def get_resource(self):...
class SddcFactsHelperGen(OCIResourceFactsHelperBase):
"""Supported operations: get, list""" def get_required_params_for_get(self): return [ "sddc_id", ] def get_required_params_for_list(self): return [ "compartment_id", ] def get_resource(self): return oci_common_utils.call_with_backoff( ...
OCIResourceFactsHelperBase, get_custom_class, ) try: from oci.ocvp import SddcClient HAS_OCI_PY_SDK = True except ImportError: HAS_OCI_PY_SDK = False class SddcFactsHelperGen(OCIResourceFactsHelperBase):
66
66
223
14
51
LaudateCorpus1/oci-ansible-collection
plugins/modules/oci_ocvp_sddc_facts.py
Python
SddcFactsHelperGen
SddcFactsHelperGen
654
689
654
654
899fb8b82facaf34684d711cdcf3d8595fd5500e
bigcode/the-stack
train
3e6162fc41611d588e11b645
train
class
class SamlAppConfig(AppConfig): name = "openslides.saml" verbose_name = "OpenSlides SAML" user_backend_class = SamlUserBackend def get_angular_constants(self): from .settings import get_saml_settings return {"SamlSettings": get_saml_settings().general_settings} def get_startup_hoo...
class SamlAppConfig(AppConfig):
name = "openslides.saml" verbose_name = "OpenSlides SAML" user_backend_class = SamlUserBackend def get_angular_constants(self): from .settings import get_saml_settings return {"SamlSettings": get_saml_settings().general_settings} def get_startup_hooks(self): return {20: sa...
import logging from django.apps import AppConfig from . import SAML_ENABLED from .user_backend import SamlUserBackend logger = logging.getLogger(__name__) class SamlAppConfig(AppConfig):
43
64
89
8
35
swilde/OpenSlides
openslides/saml/apps.py
Python
SamlAppConfig
SamlAppConfig
12
23
12
12
125979939bdf9fe544ad3e5852b2c86d554ecf73
bigcode/the-stack
train
2f54416027e517d6be0255d3
train
function
def saml_startup(): # Import all required stuff. from .settings import load_settings if not SAML_ENABLED: logger.info("SAML is disabled.") return load_settings() logger.info("SAML is enabled and loaded.")
def saml_startup(): # Import all required stuff.
from .settings import load_settings if not SAML_ENABLED: logger.info("SAML is disabled.") return load_settings() logger.info("SAML is enabled and loaded.")
def get_angular_constants(self): from .settings import get_saml_settings return {"SamlSettings": get_saml_settings().general_settings} def get_startup_hooks(self): return {20: saml_startup} def saml_startup(): # Import all required stuff.
64
64
55
13
51
swilde/OpenSlides
openslides/saml/apps.py
Python
saml_startup
saml_startup
26
36
26
27
fabb8bc6178d0ebc5e434591ae15e7d1d932dce0
bigcode/the-stack
train
197f2336d06f76c81b4d6a17
train
class
class UnitTest(unittest.TestCase): """Class: UnitTest Description: Class which is a representation of a unit testing. Methods: setUp test_default test_user_values test_width_zero test_width_less_zero """ def setUp(self): """Function: setUp ...
class UnitTest(unittest.TestCase):
"""Class: UnitTest Description: Class which is a representation of a unit testing. Methods: setUp test_default test_user_values test_width_zero test_width_less_zero """ def setUp(self): """Function: setUp Description: Initialization f...
#!/usr/bin/python # Classification (U) """Program: progressbar_init.py Description: Unit testing of ProgressBar.__init__ in gen_class.py. Usage: test/unit/gen_class/progressbar_init.py Arguments: """ # Libraries and Global Variables # Standard import sys import os if sys.version_info < (2,...
128
134
448
7
121
deepcoder42/python-lib
test/unit/gen_class/progressbar_init.py
Python
UnitTest
UnitTest
36
125
36
37
f1b45bdb1a474a98561a1f3ae4d4762c93143137
bigcode/the-stack
train
45db7092d2a97a30d1eaff89
train
class
class MB_fast_IAMB_Lner(MB_BasedLner): """ The MB_fast_IAMB_Lner (fast Incremental Association Markov Blanket Learner) is a subclass of MB_BasedLner. See docstring for MB_BasedLner for more info about this type of algo. See Shunkai Fu Thesis for pseudo code on which this class is based. Attri...
class MB_fast_IAMB_Lner(MB_BasedLner):
""" The MB_fast_IAMB_Lner (fast Incremental Association Markov Blanket Learner) is a subclass of MB_BasedLner. See docstring for MB_BasedLner for more info about this type of algo. See Shunkai Fu Thesis for pseudo code on which this class is based. Attributes ---------- min_sam_per_ce...
from learning.MB_BasedLner import * import operator class MB_fast_IAMB_Lner(MB_BasedLner):
27
256
1,139
14
12
artiste-qb-net/QFog-Pyodide
learning/MB_fast_IAMB_Lner.py
Python
MB_fast_IAMB_Lner
MB_fast_IAMB_Lner
5
146
5
5
96a0cc0e24c7e97380471622559afcdde5ea7ced
bigcode/the-stack
train
a4abf6dc7198eae17c474216
train
function
def test_real_fft(): t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = rfft(t) assert t1.shape == np.fft.rfft(np.ones(t.shape)).shape t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = irfft(t) assert t1.shape == ...
def test_real_fft():
t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = rfft(t) assert t1.shape == np.fft.rfft(np.ones(t.shape)).shape t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = irfft(t) assert t1.shape == np.fft.irfft(np.ones(...
30), chunk_size=(3, 20, 30)) t1 = fftn(t, s=(11, 9), axes=(1, 2)) assert t1.shape == (10, 11, 9) t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = ifftn(t, s=(11, 9), axes=(1, 2)) assert t1.shape == (10, 11, 9) t1...
170
170
567
5
165
hxri/mars
mars/tensor/fft/tests/test_fft.py
Python
test_real_fft
test_real_fft
69
110
69
69
a2bf739a75bca2a9370af43abed9a4c1cddad857
bigcode/the-stack
train
ea0b98e212faa7b7e30774e9
train
function
def test_fft_shift(): freqs = fftfreq(9, d=1. / 9).reshape(3, 3) t = ifftshift(fftshift(freqs)) assert t.dtype is not None expect_dtype = np.fft.ifftshift(np.fft.fftshift(np.fft.fftfreq(9, d=1. / 9).reshape(3, 3))).dtype assert t.dtype == expect_dtype
def test_fft_shift():
freqs = fftfreq(9, d=1. / 9).reshape(3, 3) t = ifftshift(fftshift(freqs)) assert t.dtype is not None expect_dtype = np.fft.ifftshift(np.fft.fftshift(np.fft.fftfreq(9, d=1. / 9).reshape(3, 3))).dtype assert t.dtype == expect_dtype
1 = ihfft(t, n=101) assert t1.shape == np.fft.ihfft(np.ones(t.shape), n=101).shape t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) def test_fft_shift():
64
64
99
5
59
hxri/mars
mars/tensor/fft/tests/test_fft.py
Python
test_fft_shift
test_fft_shift
148
154
148
148
6064a931f910babefd2440bfb749e804a4c0e838
bigcode/the-stack
train
fb52ac5a51ba6d0891a2a866
train
function
def test_hermitian_fft(): t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = hfft(t) assert t1.shape == np.fft.hfft(np.ones(t.shape)).shape t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = hfft(t, n=100) assert t...
def test_hermitian_fft():
t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = hfft(t) assert t1.shape == np.fft.hfft(np.ones(t.shape)).shape t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = hfft(t, n=100) assert t1.shape == np.fft.hfft(np....
.nsplits) t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = irfftn(t, s=(11, 9), axes=(1, 2)) assert t1.shape == np.fft.irfftn(np.ones(t.shape), s=(11, 9), axes=(1, 2)).shape t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) def test_hermitian_fft():
117
117
391
8
109
hxri/mars
mars/tensor/fft/tests/test_fft.py
Python
test_hermitian_fft
test_hermitian_fft
113
145
113
113
f64eac2743f101454321f0ef8cf857ad6dbd3f59
bigcode/the-stack
train
e05e8805928c563ca1215a48
train
function
def test_standard_fft(): t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = fft(t) assert t1.shape == (10, 20, 30) t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = ifft(t) assert t1.shape == (10, 20, 30) t1 =...
def test_standard_fft():
t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = fft(t) assert t1.shape == (10, 20, 30) t1 = tile(t1) assert t1.shape == tuple(sum(ns) for ns in t1.nsplits) t = ones((10, 20, 30), chunk_size=(3, 20, 30)) t1 = ifft(t) assert t1.shape == (10, 20, 30) t1 = tile(t1) assert t1.s...
agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import numpy as np from mars.core import...
147
147
493
5
141
hxri/mars
mars/tensor/fft/tests/test_fft.py
Python
test_standard_fft
test_standard_fft
25
66
25
25
a6aa59de0949c1a9293b09485c6bcba82b6c1e26
bigcode/the-stack
train
a78b216e96e5bc13a1ff361f
train
function
def test_fft_freq(): t = fftfreq(10, .1, chunk_size=3) assert t.shape == np.fft.fftfreq(10, .1).shape t = tile(t) assert t.shape == tuple(sum(ns) for ns in t.nsplits) t = rfftfreq(10, .1, chunk_size=3) assert t.shape == np.fft.rfftfreq(10, .1).shape t = tile(t) assert t.shape == tuple...
def test_fft_freq():
t = fftfreq(10, .1, chunk_size=3) assert t.shape == np.fft.fftfreq(10, .1).shape t = tile(t) assert t.shape == tuple(sum(ns) for ns in t.nsplits) t = rfftfreq(10, .1, chunk_size=3) assert t.shape == np.fft.rfftfreq(10, .1).shape t = tile(t) assert t.shape == tuple(sum(ns) for ns in t....
)) assert t.dtype is not None expect_dtype = np.fft.ifftshift(np.fft.fftshift(np.fft.fftfreq(9, d=1. / 9).reshape(3, 3))).dtype assert t.dtype == expect_dtype def test_fft_freq():
64
64
122
5
58
hxri/mars
mars/tensor/fft/tests/test_fft.py
Python
test_fft_freq
test_fft_freq
157
168
157
157
76be4fc17653c05110674eb397464947d7c537b1
bigcode/the-stack
train
9e03b3f0ec4c4957f4d78abd
train
function
@pytest.fixture @pytest.mark.django_db def packages_with_two_tasks_and_unassigned_items(one_mission_two_tasks_with_items): mission = one_mission_two_tasks_with_items strategy = Strategy.objects.get(name="StaticStrategyLogic") mp = MissionPackages.objects.create(mission=mission, strategy=strategy, max_annota...
@pytest.fixture @pytest.mark.django_db def packages_with_two_tasks_and_unassigned_items(one_mission_two_tasks_with_items):
mission = one_mission_two_tasks_with_items strategy = Strategy.objects.get(name="StaticStrategyLogic") mp = MissionPackages.objects.create(mission=mission, strategy=strategy, max_annotations=4) return mp
strategy = Strategy.objects.get(name="StaticStrategyLogic") mp = MissionPackages.objects.create(mission=mission, strategy=strategy, max_annotations=4) return mp @pytest.fixture @pytest.mark.django_db def packages_with_two_tasks_and_unassigned_items(one_mission_two_tasks_with_items):
64
64
74
26
37
heolin123/funcrowd
tests/modules/packages/conftest.py
Python
packages_with_two_tasks_and_unassigned_items
packages_with_two_tasks_and_unassigned_items
152
158
152
154
1445ccdb00c78b59160674df77f030f751dabb75
bigcode/the-stack
train
90dc080caf0b3379e13ad15b
train
function
@pytest.fixture @pytest.mark.django_db def packages_with_metadata(one_mission_one_task, item_template_one_input_one_output): template = item_template_one_input_one_output task = one_mission_one_task mission = task.mission strategy = Strategy.objects.get(name="StaticStrategyLogic") packages = Missio...
@pytest.fixture @pytest.mark.django_db def packages_with_metadata(one_mission_one_task, item_template_one_input_one_output):
template = item_template_one_input_one_output task = one_mission_one_task mission = task.mission strategy = Strategy.objects.get(name="StaticStrategyLogic") packages = MissionPackages.objects.create(mission=mission, strategy=strategy, max_annotations=1) for order, metadata in enumerate([ ...
, user1) # package with one annotation in one item package = packages.packages.all()[2] item = package.items.all()[0] add_annotation(item, user1) return packages @pytest.fixture @pytest.mark.django_db def packages_with_metadata(one_mission_one_task, item_template_one_input_one_output):
71
71
238
26
44
heolin123/funcrowd
tests/modules/packages/conftest.py
Python
packages_with_metadata
packages_with_metadata
87
109
87
89
155db65f18a75d65173942fb4e4fefddcf045283
bigcode/the-stack
train
51c3e2a60f40db72a6e5db02
train
function
@pytest.fixture @pytest.mark.django_db def packages_with_annotated_items(packages_with_items, user1, user2): packages = packages_with_items # package with two annotations in all items package = packages.packages.all()[0] item = package.items.all()[0] add_annotation(item, user1) item = package....
@pytest.fixture @pytest.mark.django_db def packages_with_annotated_items(packages_with_items, user1, user2):
packages = packages_with_items # package with two annotations in all items package = packages.packages.all()[0] item = package.items.all()[0] add_annotation(item, user1) item = package.items.all()[1] add_annotation(item, user1) item = package.items.all()[0] add_annotation(item, us...
Item.objects.create(task=task2, template=template, order=4, data={field.name: "task2 item4"}, package=package4) return packages @pytest.fixture @pytest.mark.django_db def packages_with_annotated_items(packages_with_items, user1, user2):
65
65
217
27
37
heolin123/funcrowd
tests/modules/packages/conftest.py
Python
packages_with_annotated_items
packages_with_annotated_items
52
84
52
54
08240f3b778aca8996b6304fee3e4c2b5e352840
bigcode/the-stack
train
f0c65f2eac8e595b6c79f19f
train
function
@pytest.fixture @pytest.mark.django_db def packages_with_unassigned_items(one_task_items_with_reference_annotation): task = one_task_items_with_reference_annotation mission = task.mission strategy = Strategy.objects.get(name="StaticStrategyLogic") mp = MissionPackages.objects.create(mission=mission, str...
@pytest.fixture @pytest.mark.django_db def packages_with_unassigned_items(one_task_items_with_reference_annotation):
task = one_task_items_with_reference_annotation mission = task.mission strategy = Strategy.objects.get(name="StaticStrategyLogic") mp = MissionPackages.objects.create(mission=mission, strategy=strategy, max_annotations=4) return mp
package.status = PackageStatus.IN_PROGRESS package.save() progress = package.get_user_progress(user1) progress.status = UserPackageStatus.FINISHED progress.save() return mp @pytest.fixture @pytest.mark.django_db def packages_with_unassigned_items(one_task_items_with_reference_annotation):
64
64
76
22
41
heolin123/funcrowd
tests/modules/packages/conftest.py
Python
packages_with_unassigned_items
packages_with_unassigned_items
142
149
142
144
25b234b49dd3e59a3ec5ef7fbd32fe37983a09cd
bigcode/the-stack
train
39465d90a3dc015501323c27
train
function
@pytest.fixture @pytest.mark.django_db def packages_with_items(one_mission, item_template_one_input_one_output): mission = one_mission strategy = Strategy.objects.get(name="StaticStrategyLogic") template = item_template_one_input_one_output field = template.items_fields.first() packages = MissionPa...
@pytest.fixture @pytest.mark.django_db def packages_with_items(one_mission, item_template_one_input_one_output):
mission = one_mission strategy = Strategy.objects.get(name="StaticStrategyLogic") template = item_template_one_input_one_output field = template.items_fields.first() packages = MissionPackages.objects.create(mission=mission, strategy=strategy, max_annotations=4) package1 = Package.objects.creat...
import pytest from modules.order_strategy.models import Strategy from modules.packages.consts import UserPackageStatus, PackageStatus from modules.packages.models import Package, MissionPackages from tasks.consts import FINISHED, TaskStatus from tasks.models import ( Task, Item ) from tests.conftest import add_ann...
91
154
514
24
66
heolin123/funcrowd
tests/modules/packages/conftest.py
Python
packages_with_items
packages_with_items
13
49
13
15
c10364e8933edaac70b94003e552e51c5e976d94
bigcode/the-stack
train
ee3847dfe40e0e1812c07626
train
function
@pytest.fixture @pytest.mark.django_db def packages_with_metadata_and_statuses(packages_with_metadata, user1, user2): mp = packages_with_metadata # package 1 package = Package.objects.all()[0] package.status = PackageStatus.FINISHED package.save() progress = package.get_user_progress(user1) ...
@pytest.fixture @pytest.mark.django_db def packages_with_metadata_and_statuses(packages_with_metadata, user1, user2):
mp = packages_with_metadata # package 1 package = Package.objects.all()[0] package.status = PackageStatus.FINISHED package.save() progress = package.get_user_progress(user1) progress.status = UserPackageStatus.IN_PROGRESS progress.save() progress = package.get_user_progress(user2)...
=metadata) for index in range(2): Item.objects.create(task=task, template=template, order=order, data={}, package=package) return packages @pytest.fixture @pytest.mark.django_db def packages_with_metadata_and_statuses(packages_with_metadata, user1, user2):
64
64
169
27
36
heolin123/funcrowd
tests/modules/packages/conftest.py
Python
packages_with_metadata_and_statuses
packages_with_metadata_and_statuses
112
139
112
114
b423337c076b249713c28076384f9c5d4c02945e
bigcode/the-stack
train
9bc1d9294de5b555c75a0b76
train
class
class Target(object): def __init__(self, buildozer): super(Target, self).__init__() self.buildozer = buildozer self.build_mode = 'debug' self.platform_update = False def check_requirements(self): pass def check_configuration_tokens(self, errors=None): if er...
class Target(object):
def __init__(self, buildozer): super(Target, self).__init__() self.buildozer = buildozer self.build_mode = 'debug' self.platform_update = False def check_requirements(self): pass def check_configuration_tokens(self, errors=None): if errors: self....
from sys import exit def no_config(f): f.__no_config = True return f class Target(object):
26
190
634
4
21
cbenhagen/buildozer
buildozer/target.py
Python
Target
Target
7
111
7
8
2fc8ec2af4fc1e89cf68c50e0edbc3a03878103f
bigcode/the-stack
train
1bc283821c4da725a89fc428
train
function
def no_config(f): f.__no_config = True return f
def no_config(f):
f.__no_config = True return f
from sys import exit def no_config(f):
10
64
17
5
4
cbenhagen/buildozer
buildozer/target.py
Python
no_config
no_config
3
5
3
3
2e4fdd5b2fa383a1c0fdf4b6062b0797fc07d8f9
bigcode/the-stack
train
b0856c7d0d1d0186da5245c6
train
function
async def x(client, message): try: try: await message.delete() except: pass text = message.text.split(" ") del text[0] text = " ".join(text) gTTS(text, lang="en-US").save("downloads/tts.mp3") _thread.start_new_thread( subpro...
async def x(client, message):
try: try: await message.delete() except: pass text = message.text.split(" ") del text[0] text = " ".join(text) gTTS(text, lang="en-US").save("downloads/tts.mp3") _thread.start_new_thread( subprocess.Popen(["mplayer", "downlo...
await message.reply_text(_("tts_2")) _thread.start_new_thread( subprocess.Popen(["mplayer", "downloads/tts.mp3"]).wait, () ) await m.edit(_("tts_3")) except: await message.reply_text(_("error")) async def x(client, message):
63
64
98
7
56
rshero/VoiceChatPyroBot
handlers/tts.py
Python
x
x
28
43
28
28
c619f98abfe2b8db2d8b529cf680e6c3ca79d52e
bigcode/the-stack
train
a003ff22cb86d0b83cefba31
train
function
async def tts(client, message): if message.text.replace("/tts", "") == "": await message.reply_text(_("tts_1")) else: try: gTTS(message.text.replace("/tts ", ""), lang="en-US").save("downloads/tts.mp3") m = await message.reply_text(_("tts_2")) ...
async def tts(client, message):
if message.text.replace("/tts", "") == "": await message.reply_text(_("tts_1")) else: try: gTTS(message.text.replace("/tts ", ""), lang="en-US").save("downloads/tts.mp3") m = await message.reply_text(_("tts_2")) _thread.start_new_thread( ...
import _thread import subprocess from gtts import gTTS import time from pyrogram import filters from pyrogram.handlers import MessageHandler from config import BANNED from strings import get_string as _ async def tts(client, message):
54
64
119
8
46
rshero/VoiceChatPyroBot
handlers/tts.py
Python
tts
tts
11
25
11
11
61faa0be3f9d24485bbc0db4da20205076792b65
bigcode/the-stack
train
14e20413403c4b7a971b6492
train
class
class TestAnyIterableWithItems: @pytest.mark.parametrize("item,_", DataTypes.parameters()) def test_it_fails_gracefully(self, item, _): assert item != AnyIterableWithItems(["a"]) def test_it_matches_out_of_order(self): matcher = AnyIterableWithItems([1, 2]) assert matcher == {2: "b...
class TestAnyIterableWithItems: @pytest.mark.parametrize("item,_", DataTypes.parameters())
def test_it_fails_gracefully(self, item, _): assert item != AnyIterableWithItems(["a"]) def test_it_matches_out_of_order(self): matcher = AnyIterableWithItems([1, 2]) assert matcher == {2: "b", 1: "a", 0: "c"} assert matcher == {0, 2, 1} assert matcher == [0, 1, 2, 3] ...
3] assert matcher == [2, 1, 1, 2, 3] # It is in here assert matcher != [0, 2, 1, 1, 3] assert matcher != [1, 2, 2] def test_it_matches_generators_in_order(self): matcher = AnyIterableWithItemsInOrder([0, 1, 2]) assert matcher == iter(range(3)) assert iter(range(3)...
148
148
495
20
127
hypothesis/h-matcher
tests/unit/h_matchers/matcher/collection/containment_test.py
Python
TestAnyIterableWithItems
TestAnyIterableWithItems
76
142
76
77
95348fe50edff736efd796a886cc5de00b561e10
bigcode/the-stack
train
c8d9a328c425bcce30d214a4
train
class
class TestAnyMappableWithItems: @pytest.mark.parametrize("item,_", DataTypes.parameters()) def test_it_fails_gracefully(self, item, _): assert item != AnyMappingWithItems({"a": 1}) def test_it_can_match_values(self): matcher = AnyMappingWithItems({"a": 1}) assert matcher == {"a": 1...
class TestAnyMappableWithItems: @pytest.mark.parametrize("item,_", DataTypes.parameters())
def test_it_fails_gracefully(self, item, _): assert item != AnyMappingWithItems({"a": 1}) def test_it_can_match_values(self): matcher = AnyMappingWithItems({"a": 1}) assert matcher == {"a": 1} assert {"a": 1} == matcher assert matcher == {"a": 1, "b": 2} assert...
import pytest from h_matchers import Any from h_matchers.matcher.collection.containment import ( AnyIterableWithItems, AnyIterableWithItemsInOrder, AnyMappingWithItems, ) from tests.unit.data_types import DataTypes class MultiDict(list): """Very bare bones implementation of a multi-dict.""" def ...
98
101
337
21
76
hypothesis/h-matcher
tests/unit/h_matchers/matcher/collection/containment_test.py
Python
TestAnyMappableWithItems
TestAnyMappableWithItems
19
49
19
20
9745343d8684dadfe324f4fa6bc5b7d2a3646ebf
bigcode/the-stack
train
f142ea18db2feec4b1210c6a
train
class
class TestAnyIterableWithItemsInOrder: @pytest.mark.parametrize("item,_", DataTypes.parameters()) def test_it_fails_gracefully(self, item, _): assert item != AnyIterableWithItemsInOrder(["a"]) def test_it_matches_in_order(self): matcher = AnyIterableWithItemsInOrder([1, 1, 2]) # Or...
class TestAnyIterableWithItemsInOrder: @pytest.mark.parametrize("item,_", DataTypes.parameters())
def test_it_fails_gracefully(self, item, _): assert item != AnyIterableWithItemsInOrder(["a"]) def test_it_matches_in_order(self): matcher = AnyIterableWithItemsInOrder([1, 1, 2]) # Ordered things do assert matcher == [0, 1, 1, 2, 3] assert matcher == [2, 1, 1, 2, 3] #...
a": 1, "b": 2} != matcher assert MultiDict((("a", 2), ["a", 1], ("b", 2), ["c", 3])) == matcher class TestAnyIterableWithItemsInOrder: @pytest.mark.parametrize("item,_", DataTypes.parameters())
68
68
227
22
45
hypothesis/h-matcher
tests/unit/h_matchers/matcher/collection/containment_test.py
Python
TestAnyIterableWithItemsInOrder
TestAnyIterableWithItemsInOrder
52
73
52
53
4ed919c021f7f1f2ffc32315e1e3a0e6ac35b5a6
bigcode/the-stack
train
0eb8d3af16ac6b28c595c31f
train
class
class MultiDict(list): """Very bare bones implementation of a multi-dict.""" def items(self): yield from self
class MultiDict(list):
"""Very bare bones implementation of a multi-dict.""" def items(self): yield from self
import pytest from h_matchers import Any from h_matchers.matcher.collection.containment import ( AnyIterableWithItems, AnyIterableWithItemsInOrder, AnyMappingWithItems, ) from tests.unit.data_types import DataTypes class MultiDict(list):
55
64
27
5
49
hypothesis/h-matcher
tests/unit/h_matchers/matcher/collection/containment_test.py
Python
MultiDict
MultiDict
12
16
12
12
133218405816d5f6be805837e255054e125cbf8b
bigcode/the-stack
train
715bd29e55a4fce778a1eaf1
train
class
class GramMatrix(nn.Module): def forward(self, y): (b, ch, h, w) = y.size() features = y.view(b, ch, w * h) features_t = features.transpose(1, 2) gram = features.bmm(features_t) / (ch * h * w) return gram
class GramMatrix(nn.Module):
def forward(self, y): (b, ch, h, w) = y.size() features = y.view(b, ch, w * h) features_t = features.transpose(1, 2) gram = features.bmm(features_t) / (ch * h * w) return gram
): ''' Calculates variance. ''' x_zero_meaned = x - x.mean(dim).expand_as(x) return x_zero_meaned.pow(2).mean(dim) class MultConst(nn.Module): def forward(self, input): return 255*input class GramMatrix(nn.Module):
64
64
73
6
57
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
GramMatrix
GramMatrix
68
74
68
68
9144a668c57f8c7bbfcae1b03e0af177091dccb2
bigcode/the-stack
train
ffb894ab25b4807109fcd277
train
class
class MultConst(nn.Module): def forward(self, input): return 255*input
class MultConst(nn.Module):
def forward(self, input): return 255*input
2d(planes) # return RangeBN(planes) def var(x, dim=0): ''' Calculates variance. ''' x_zero_meaned = x - x.mean(dim).expand_as(x) return x_zero_meaned.pow(2).mean(dim) class MultConst(nn.Module):
64
64
20
6
58
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
MultConst
MultConst
63
65
63
63
6cbb7af972925daba97e98fa27aa2cf7d4f6df05
bigcode/the-stack
train
e4bbef9b8136e0ce1daefb3b
train
function
def make_bn(planes): return nn.BatchNorm2d(planes)
def make_bn(planes):
return nn.BatchNorm2d(planes)
ias, momentum=MOMENTUM, quant_act_forward=ACT_FW, quant_act_backward=ACT_BW, quant_grad_act_error=GRAD_ACT_ERROR, quant_grad_act_gc=GRAD_ACT_GC, weight_bits=WEIGHT_BITS, fix_prec=fix_prec) def make_bn(planes):
64
64
15
6
58
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
make_bn
make_bn
50
51
50
50
9a12555205de9cd7c944a7e5bc503cd2bf7bc0ed
bigcode/the-stack
train
3535426f0f6cb1e1166f6b5d
train
class
class UpsampleConvLayer(torch.nn.Module): """UpsampleConvLayer Upsamples the input and then does a convolution. This method gives better results compared to ConvTranspose2d. ref: http://distill.pub/2016/deconv-checkerboard/ """ def __init__(self, in_channels, out_channels, kernel_size, stride, ...
class UpsampleConvLayer(torch.nn.Module):
"""UpsampleConvLayer Upsamples the input and then does a convolution. This method gives better results compared to ConvTranspose2d. ref: http://distill.pub/2016/deconv-checkerboard/ """ def __init__(self, in_channels, out_channels, kernel_size, stride, upsample=None): super(UpsampleConv...
self.reflection_pad = nn.ReflectionPad2d(reflection_padding) self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride) def forward(self, x): out = self.reflection_pad(x) out = self.conv2d(out) return out class UpsampleConvLayer(torch.nn.Module):
73
73
244
9
63
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
UpsampleConvLayer
UpsampleConvLayer
194
217
194
194
3807a95dc95912ff452fc3b6aa1f8932576f3c0f
bigcode/the-stack
train
bdf721a0184a3b269b8837d2
train
class
class Inspiration(nn.Module): """ Inspiration Layer (from MSG-Net paper) tuning the featuremap with target Gram Matrix ref https://arxiv.org/abs/1703.06953 """ def __init__(self, C, B=1): super(Inspiration, self).__init__() # B is equal to 1 or input mini_batch self.weight = ...
class Inspiration(nn.Module):
""" Inspiration Layer (from MSG-Net paper) tuning the featuremap with target Gram Matrix ref https://arxiv.org/abs/1703.06953 """ def __init__(self, C, B=1): super(Inspiration, self).__init__() # B is equal to 1 or input mini_batch self.weight = nn.Parameter(torch.Tensor(1,C,...
self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, stride) def forward(self, x): if self.upsample: x = self.upsample_layer(x) if self.reflection_padding != 0: x = self.reflection_pad(x) out = self.conv2d(x) return out class Inspiration(nn...
82
82
275
5
76
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
Inspiration
Inspiration
220
247
220
220
239a4de6e071c1f16881604ffbb1638f1afc096d
bigcode/the-stack
train
c21cfa414b450f93b7403be6
train
class
class ConvLayer(torch.nn.Module): def __init__(self, in_channels, out_channels, kernel_size, stride): super(ConvLayer, self).__init__() reflection_padding = int(np.floor(kernel_size / 2)) self.reflection_pad = nn.ReflectionPad2d(reflection_padding) self.conv2d = nn.Conv2d(in_channels...
class ConvLayer(torch.nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride): super(ConvLayer, self).__init__() reflection_padding = int(np.floor(kernel_size / 2)) self.reflection_pad = nn.ReflectionPad2d(reflection_padding) self.conv2d = nn.Conv2d(in_channels, out_channels, kernel_size, strid...
), nn.Conv2d(planes, planes * self.expansion, kernel_size=1, stride=1)] self.conv_block = nn.Sequential(*conv_block) def forward(self, x): return self.residual_layer(x) + self.conv_block(x) class ConvLayer(torch.nn.Module):
64
64
113
7
57
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
ConvLayer
ConvLayer
182
192
182
182
9630b8f4e8a4e43763c8bccf092e001b9d59fa1e
bigcode/the-stack
train
fd4f610bba29594bebedf7ff
train
function
def var(x, dim=0): ''' Calculates variance. ''' x_zero_meaned = x - x.mean(dim).expand_as(x) return x_zero_meaned.pow(2).mean(dim)
def var(x, dim=0):
''' Calculates variance. ''' x_zero_meaned = x - x.mean(dim).expand_as(x) return x_zero_meaned.pow(2).mean(dim)
_grad_act_error=GRAD_ACT_ERROR, quant_grad_act_gc=GRAD_ACT_GC, weight_bits=WEIGHT_BITS, fix_prec=fix_prec) def make_bn(planes): return nn.BatchNorm2d(planes) # return RangeBN(planes) def var(x, dim=0):
64
64
45
8
56
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
var
var
55
60
55
55
aa6857070b76571f9c77debdc11d2b1dab3b04f6
bigcode/the-stack
train
0f2f5080866cd522cca344d8
train
class
class Bottleneck(nn.Module): """ Pre-activation residual block Identity Mapping in Deep Residual Networks ref https://arxiv.org/abs/1603.05027 """ def __init__(self, inplanes, planes, stride=1, downsample=None, norm_layer=nn.BatchNorm2d): super(Bottleneck, self).__init__() self.expan...
class Bottleneck(nn.Module):
""" Pre-activation residual block Identity Mapping in Deep Residual Networks ref https://arxiv.org/abs/1603.05027 """ def __init__(self, inplanes, planes, stride=1, downsample=None, norm_layer=nn.BatchNorm2d): super(Bottleneck, self).__init__() self.expansion = 4 self.downsam...
ConvLayer(inplanes, planes, kernel_size=3, stride=1, upsample=stride), norm_layer(planes), nn.ReLU(inplace=True), ConvLayer(planes, planes, kernel_size=3, stride=1)] self.conv_block = nn.Sequential(*conv_block) ...
90
90
303
6
84
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
Bottleneck
Bottleneck
124
153
124
124
fd6cae1debfd1404a23c7dc6945ff27a85aeb7ed
bigcode/the-stack
train
32d9af4f0935fa2c5d01b707
train
function
def conv3x3(in_planes, out_planes, stride=1, fix_prec=False): "3x3 convolution with padding" return QConv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False, momentum=MOMENTUM, quant_act_forward=ACT_FW, quant_act_backward=ACT_BW, quant_grad_act_err...
def conv3x3(in_planes, out_planes, stride=1, fix_prec=False):
"3x3 convolution with padding" return QConv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False, momentum=MOMENTUM, quant_act_forward=ACT_FW, quant_act_backward=ACT_BW, quant_grad_act_error=GRAD_ACT_ERROR, quant_grad_act_gc=GRAD_ACT_GC, weight_bits=...
out_planes, stride=1): "3x3 convolution with padding" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False) def conv3x3(in_planes, out_planes, stride=1, fix_prec=False):
64
64
113
19
45
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
conv3x3
conv3x3
37
41
37
37
6e54f5ea01860b71d2feb23daaf92b4585f43e53
bigcode/the-stack
train
4034f1cb4c1aade22eddf3ba
train
function
def Conv3x3(in_planes, out_planes, stride=1): "3x3 convolution with padding" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False)
def Conv3x3(in_planes, out_planes, stride=1):
"3x3 convolution with padding" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False)
AD_ACT_ERROR = 0 GRAD_ACT_GC = 0 WEIGHT_BITS = 0 MOMENTUM = 0.9 DWS_BITS = 8 DWS_GRAD_BITS = 16 def Conv3x3(in_planes, out_planes, stride=1):
64
64
53
15
48
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
Conv3x3
Conv3x3
31
34
31
31
7e4afe4bbd034d41e6eb4d4f78d173eb9473cb31
bigcode/the-stack
train
21975c0a035bedb26ce45ca0
train
class
class Basicblock(nn.Module): def __init__(self, inplanes, planes, stride=1, downsample=None, norm_layer=nn.BatchNorm2d): super(Basicblock, self).__init__() self.downsample = downsample if self.downsample is not None: self.residual_layer = nn.Conv2d(inplanes, planes, ...
class Basicblock(nn.Module):
def __init__(self, inplanes, planes, stride=1, downsample=None, norm_layer=nn.BatchNorm2d): super(Basicblock, self).__init__() self.downsample = downsample if self.downsample is not None: self.residual_layer = nn.Conv2d(inplanes, planes, ...
b, ch, h, w) = y.size() features = y.view(b, ch, w * h) features_t = features.transpose(1, 2) gram = features.bmm(features_t) / (ch * h * w) return gram class Basicblock(nn.Module):
64
64
215
6
57
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
Basicblock
Basicblock
77
99
77
77
27933fb8a5ebb26bb2077eadc0757beb6ea15bc4
bigcode/the-stack
train
b1b966c6d43bfc2fd455bcf9
train
class
class UpBasicblock(nn.Module): """ Up-sample residual block (from MSG-Net paper) Enables passing identity all the way through the generator ref https://arxiv.org/abs/1703.06953 """ def __init__(self, inplanes, planes, stride=2, norm_layer=nn.BatchNorm2d): super(UpBasicblock, self).__init__()...
class UpBasicblock(nn.Module):
""" Up-sample residual block (from MSG-Net paper) Enables passing identity all the way through the generator ref https://arxiv.org/abs/1703.06953 """ def __init__(self, inplanes, planes, stride=2, norm_layer=nn.BatchNorm2d): super(UpBasicblock, self).__init__() self.residual_layer = ...
_layer(planes)] self.conv_block = nn.Sequential(*conv_block) def forward(self, input): if self.downsample is not None: residual = self.residual_layer(input) else: residual = input return residual + self.conv_block(input) class UpBasicblock(nn.Module):
65
66
223
7
58
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
UpBasicblock
UpBasicblock
102
121
102
102
3ef46146d9a102ef5b4c263f4d2cc9b880189dfe
bigcode/the-stack
train
c81a7721ecebfdb3ebc0739f
train
class
class Vgg16(torch.nn.Module): def __init__(self): super(Vgg16, self).__init__() self.conv1_1 = nn.Conv2d(3, 64, kernel_size=3, stride=1, padding=1) self.conv1_2 = nn.Conv2d(64, 64, kernel_size=3, stride=1, padding=1) self.conv2_1 = nn.Conv2d(64, 128, kernel_size=3, stride=1, padding...
class Vgg16(torch.nn.Module):
def __init__(self): super(Vgg16, self).__init__() self.conv1_1 = nn.Conv2d(3, 64, kernel_size=3, stride=1, padding=1) self.conv1_2 = nn.Conv2d(64, 64, kernel_size=3, stride=1, padding=1) self.conv2_1 = nn.Conv2d(64, 128, kernel_size=3, stride=1, padding=1) self.conv2_2 = nn....
.Tensor(1,C,C), requires_grad=True) # non-parameter buffer self.G = Variable(torch.Tensor(B,C,C), requires_grad=True) self.C = C self.reset_parameters() def reset_parameters(self): self.weight.data.uniform_(0.0, 0.02) def setTarget(self, target): self.G = target...
198
198
661
8
189
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
Vgg16
Vgg16
250
293
250
250
b16414223dcbf6ea6b765db707042bc0daa75a2e
bigcode/the-stack
train
4f87844a373b7836f1cdd6f0
train
function
def conv(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=False, fix_prec=False): return QConv2d(in_channels, out_channels, kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias, momentum=MOMENTUM, quant_act_for...
def conv(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=False, fix_prec=False):
return QConv2d(in_channels, out_channels, kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias, momentum=MOMENTUM, quant_act_forward=ACT_FW, quant_act_backward=ACT_BW, quant_grad_act_error=GRAD_ACT_ERROR, quant_grad_act_gc=GRAD_AC...
=GRAD_ACT_ERROR, quant_grad_act_gc=GRAD_ACT_GC, weight_bits=WEIGHT_BITS, fix_prec=fix_prec) def conv(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=False, fix_prec=False):
64
64
129
34
30
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
conv
conv
44
47
44
44
3a25c4f5f06c3eab773e4d9e47ccd8c3fa8ecb35
bigcode/the-stack
train
959a78cd1786eab0e1611ffa
train
class
class UpBottleneck(nn.Module): """ Up-sample residual block (from MSG-Net paper) Enables passing identity all the way through the generator ref https://arxiv.org/abs/1703.06953 """ def __init__(self, inplanes, planes, stride=2, norm_layer=nn.BatchNorm2d): super(UpBottleneck, self).__init__()...
class UpBottleneck(nn.Module):
""" Up-sample residual block (from MSG-Net paper) Enables passing identity all the way through the generator ref https://arxiv.org/abs/1703.06953 """ def __init__(self, inplanes, planes, stride=2, norm_layer=nn.BatchNorm2d): super(UpBottleneck, self).__init__() self.expansion = 4 ...
nn.Conv2d(planes, planes * self.expansion, kernel_size=1, stride=1)] self.conv_block = nn.Sequential(*conv_block) def forward(self, x): if self.downsample is not None: residual = self.residual_layer(x) else: residual = x ...
85
85
284
8
77
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
UpBottleneck
UpBottleneck
156
179
156
156
1efa131d7854f9020b9d9adb6db48ec819a8b369
bigcode/the-stack
train
961699d8bda85d603801a5df
train
class
class Net(nn.Module): def __init__(self, input_nc=3, output_nc=3, ngf=64, norm_layer=nn.InstanceNorm2d, n_blocks=6, gpu_ids=[]): super(Net, self).__init__() self.gpu_ids = gpu_ids self.gram = GramMatrix() block = Bottleneck upblock = UpBottleneck expansion = 4 ...
class Net(nn.Module):
def __init__(self, input_nc=3, output_nc=3, ngf=64, norm_layer=nn.InstanceNorm2d, n_blocks=6, gpu_ids=[]): super(Net, self).__init__() self.gpu_ids = gpu_ids self.gram = GramMatrix() block = Bottleneck upblock = UpBottleneck expansion = 4 model1 = [] ...
.relu(self.conv3_3(h)) relu3_3 = h h = F.max_pool2d(h, kernel_size=2, stride=2) h = F.relu(self.conv4_1(h)) h = F.relu(self.conv4_2(h)) h = F.relu(self.conv4_3(h)) relu4_3 = h return [relu1_2, relu2_2, relu3_3, relu4_3] class Net(nn.Module):
112
112
375
5
107
Alexiland/COMP576-Final-Project
experiments/net_quant.py
Python
Net
Net
296
336
296
296
f5c680c49d95af54db74436aa252f05519401010
bigcode/the-stack
train
4635d8caba1c74b825646cc7
train
function
def test_only_one_logo_on_top_bar(quandl_home, logger): """In home page top bar, there is only one visible logo""" logger.info("Get Quandl logo count") num_logos = quandl_home.top_bar.logo_count logger.info("Verify only one logo is visible") assert num_logos == 1, "There are more than one logos in t...
def test_only_one_logo_on_top_bar(quandl_home, logger):
"""In home page top bar, there is only one visible logo""" logger.info("Get Quandl logo count") num_logos = quandl_home.top_bar.logo_count logger.info("Verify only one logo is visible") assert num_logos == 1, "There are more than one logos in the main screen"
from pages.careers_page import CareersPage def test_only_one_logo_on_top_bar(quandl_home, logger):
25
64
85
15
9
aelnahas/automation-quandl
tests/web_tests/test_home_page.py
Python
test_only_one_logo_on_top_bar
test_only_one_logo_on_top_bar
4
9
4
4
4129cce3d709fa8ee19477daecf65e62b577ef4f
bigcode/the-stack
train
f0e939ae90a97d123e87136a
train
function
def test_top_bar_logo_links_to_home_page(quandl_home, logger): """In home page, Quandl logo on the top bar takes the user back to home page""" logger.info("Click on the Quandl logo and ensure it navigates user back to home page") quandl_home.top_bar.click_on_logo() assert quandl_home.is_loaded(), "Home ...
def test_top_bar_logo_links_to_home_page(quandl_home, logger):
"""In home page, Quandl logo on the top bar takes the user back to home page""" logger.info("Click on the Quandl logo and ensure it navigates user back to home page") quandl_home.top_bar.click_on_logo() assert quandl_home.is_loaded(), "Home page was not loaded after user clicks on top bar logo"
logo count") num_logos = quandl_home.top_bar.logo_count logger.info("Verify only one logo is visible") assert num_logos == 1, "There are more than one logos in the main screen" def test_top_bar_logo_links_to_home_page(quandl_home, logger):
64
64
90
16
48
aelnahas/automation-quandl
tests/web_tests/test_home_page.py
Python
test_top_bar_logo_links_to_home_page
test_top_bar_logo_links_to_home_page
12
16
12
12
13061d22e7e10e4cf57577b1c20131f49cda1bfc
bigcode/the-stack
train
59b7f0a7de06c2133ca6a5a5
train
function
def test_footer_has_careers_link(browser, quandl_home, logger): """In home page, There should be a link to careers page in the footer""" logger.info("Check if there is a Careers link in home page and navigate to it") quandl_home.footer.navigate_to_careers() career_page = CareersPage(browser) logger....
def test_footer_has_careers_link(browser, quandl_home, logger):
"""In home page, There should be a link to careers page in the footer""" logger.info("Check if there is a Careers link in home page and navigate to it") quandl_home.footer.navigate_to_careers() career_page = CareersPage(browser) logger.info("Verifying careers page is loaded.") assert career_page...
on the Quandl logo and ensure it navigates user back to home page") quandl_home.top_bar.click_on_logo() assert quandl_home.is_loaded(), "Home page was not loaded after user clicks on top bar logo" def test_footer_has_careers_link(browser, quandl_home, logger):
64
64
105
16
48
aelnahas/automation-quandl
tests/web_tests/test_home_page.py
Python
test_footer_has_careers_link
test_footer_has_careers_link
19
25
19
19
de5a34eacdeca3277686686ac8f627a3b76342fc
bigcode/the-stack
train
14fc34dae2c40f68e5608cdf
train
function
def group_brackets(tlist): _group_matching(tlist, sql.SquareBrackets)
def group_brackets(tlist):
_group_matching(tlist, sql.SquareBrackets)
invalid sql and unbalanced tokens. # instead of break, continue in case other "valid" groups exist continue close_idx = tidx tlist.group_tokens(cls, open_idx, close_idx) tidx_offset += close_idx - open_idx def group_brackets(tlist):
64
64
20
7
56
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_brackets
group_brackets
53
54
53
53
dbaa500ecc199ffe103ed3c8a4c46f7455c20e43
bigcode/the-stack
train
f0e0ef86ea414034039485a2
train
function
def group_begin(tlist): _group_matching(tlist, sql.Begin)
def group_begin(tlist):
_group_matching(tlist, sql.Begin)
group_matching(tlist, sql.Parenthesis) def group_case(tlist): _group_matching(tlist, sql.Case) def group_if(tlist): _group_matching(tlist, sql.If) def group_for(tlist): _group_matching(tlist, sql.For) def group_begin(tlist):
64
64
16
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_begin
group_begin
73
74
73
73
48c30190e417aa6cc5f4838b0cc6e0c35d0e7f35
bigcode/the-stack
train
c676c91edfba75ced4309540
train
function
def group_typecasts(tlist): def match(token): return token.match(T.Punctuation, '::') def valid(token): return token is not None def post(tlist, pidx, tidx, nidx): return pidx, nidx valid_prev = valid_next = valid _group(tlist, sql.Identifier, match, valid_prev,...
def group_typecasts(tlist):
def match(token): return token.match(T.Punctuation, '::') def valid(token): return token is not None def post(tlist, pidx, tidx, nidx): return pidx, nidx valid_prev = valid_next = valid _group(tlist, sql.Identifier, match, valid_prev, valid_next, post)
group_matching(tlist, sql.Case) def group_if(tlist): _group_matching(tlist, sql.If) def group_for(tlist): _group_matching(tlist, sql.For) def group_begin(tlist): _group_matching(tlist, sql.Begin) def group_typecasts(tlist):
64
64
86
7
57
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_typecasts
group_typecasts
77
88
77
77
97c528be80658115e73a5c11b09857969a1b7b2b
bigcode/the-stack
train
bd93a7f4a6cbdc6876ba63ac
train
function
def _group_matching(tlist, cls): """Groups Tokens that have beginning and end.""" opens = [] tidx_offset = 0 for idx, token in enumerate(list(tlist)): tidx = idx - tidx_offset if token.is_whitespace: # ~50% of tokens will be whitespace. Will checking early ...
def _group_matching(tlist, cls):
"""Groups Tokens that have beginning and end.""" opens = [] tidx_offset = 0 for idx, token in enumerate(list(tlist)): tidx = idx - tidx_offset if token.is_whitespace: # ~50% of tokens will be whitespace. Will checking early # for them avoid 3 comparisons,...
/BSD-3-Clause from sqlparse import sql from sqlparse import tokens as T from sqlparse.utils import recurse, imt T_NUMERICAL = (T.Number, T.Number.Integer, T.Number.Float) T_STRING = (T.String, T.String.Single, T.String.Symbol) T_NAME = (T.Name, T.Name.Placeholder) def _group_matching(tlist, cls):
83
83
279
9
74
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
_group_matching
_group_matching
18
50
18
18
72d361d7b524ec596f48ccf5727edcfe93ed32a1
bigcode/the-stack
train
295a3fcdebbd47944b6beae8
train
function
@recurse() def group_aliased(tlist): I_ALIAS = (sql.Parenthesis, sql.Function, sql.Case, sql.Identifier, sql.Operation, sql.Comparison) tidx, token = tlist.token_next_by(i=I_ALIAS, t=T.Number) while token: nidx, next_ = tlist.token_next(tidx) if isinstance(next_, sql....
@recurse() def group_aliased(tlist):
I_ALIAS = (sql.Parenthesis, sql.Function, sql.Case, sql.Identifier, sql.Operation, sql.Comparison) tidx, token = tlist.token_next_by(i=I_ALIAS, t=T.Number) while token: nidx, next_ = tlist.token_next(tidx) if isinstance(next_, sql.Identifier): tlist.group_t...
and eidx-1 eidx = tlist.token_index(end) tlist.group_tokens(sql.Where, tidx, eidx) tidx, token = tlist.token_next_by(m=sql.Where.M_OPEN, idx=tidx) @recurse() def group_aliased(tlist):
64
64
126
12
52
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_aliased
group_aliased
275
285
275
276
8df0362118f436cf315c0f4e121fbb4ccc22aba7
bigcode/the-stack
train
1a0e6775d9975df4edfca2de
train
function
def group_identifier_list(tlist): m_role = T.Keyword, ('null', 'role') sqlcls = (sql.Function, sql.Case, sql.Identifier, sql.Comparison, sql.IdentifierList, sql.Operation) ttypes = (T_NUMERICAL + T_STRING + T_NAME + (T.Keyword, T.Comment, T.Wildcard)) def match(token)...
def group_identifier_list(tlist):
m_role = T.Keyword, ('null', 'role') sqlcls = (sql.Function, sql.Case, sql.Identifier, sql.Comparison, sql.IdentifierList, sql.Operation) ttypes = (T_NUMERICAL + T_STRING + T_NAME + (T.Keyword, T.Comment, T.Wildcard)) def match(token): return token.match(T.Pun...
x, nidx): tlist[tidx].ttype = T.Operator return pidx, nidx valid_prev = valid_next = valid _group(tlist, sql.Operation, match, valid_prev, valid_next, post, extend=False) def group_identifier_list(tlist):
64
64
173
7
57
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_identifier_list
group_identifier_list
224
242
224
224
68f59e66efd955e250d85614415621ea8b9c4e69
bigcode/the-stack
train
93b84b9e277091f1f12f2971
train
function
@recurse(sql.Function) def group_functions(tlist): has_create = False has_table = False for tmp_token in tlist.tokens: if tmp_token.value == 'CREATE': has_create = True if tmp_token.value == 'TABLE': has_table = True if has_create and has_table: ...
@recurse(sql.Function) def group_functions(tlist):
has_create = False has_table = False for tmp_token in tlist.tokens: if tmp_token.value == 'CREATE': has_create = True if tmp_token.value == 'TABLE': has_table = True if has_create and has_table: return tidx, token = tlist.token_next_by(t=T.N...
(tidx) if isinstance(next_, sql.Identifier): tlist.group_tokens(sql.Identifier, tidx, nidx, extend=True) tidx, token = tlist.token_next_by(i=I_ALIAS, t=T.Number, idx=tidx) @recurse(sql.Function) def group_functions(tlist):
64
64
149
12
52
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_functions
group_functions
288
305
288
289
632d88885275dcd3c757c5875b36002253e1f46c
bigcode/the-stack
train
7ff0d5c56808de79fab76a0d
train
function
def group_operator(tlist): ttypes = T_NUMERICAL + T_STRING + T_NAME sqlcls = (sql.SquareBrackets, sql.Parenthesis, sql.Function, sql.Identifier, sql.Operation) def match(token): return imt(token, t=(T.Operator, T.Wildcard)) def valid(token): return imt(token, i=s...
def group_operator(tlist):
ttypes = T_NUMERICAL + T_STRING + T_NAME sqlcls = (sql.SquareBrackets, sql.Parenthesis, sql.Function, sql.Identifier, sql.Operation) def match(token): return imt(token, t=(T.Operator, T.Wildcard)) def valid(token): return imt(token, i=sqlcls, t=ttypes) def ...
def valid_next(token): return True def post(tlist, pidx, tidx, nidx): return pidx, tidx _group(tlist, sql.Identifier, match, valid_prev, valid_next, post, extend=True, recurse=False) def group_operator(tlist):
64
64
155
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_operator
group_operator
204
221
204
204
7dc0c0a1fd32a39d8313aeb4dbcaa8a58c59a584
bigcode/the-stack
train
f318f99ee8dcf29a73be1326
train
function
def group(stmt): for func in [ group_comments, # _group_matching group_brackets, group_parenthesis, group_case, group_if, group_for, group_begin, group_functions, group_where, group_period, group_arrays,...
def group(stmt):
for func in [ group_comments, # _group_matching group_brackets, group_parenthesis, group_case, group_if, group_for, group_begin, group_functions, group_where, group_period, group_arrays, group_id...
1 while token: if isinstance(token, sql.Parenthesis): end_idx = tidx tidx, token = tlist.token_next(tidx) if end_idx != -1: tlist.group_tokens(sql.Values, start_idx, end_idx, extend=True) def group(stmt):
64
64
121
4
60
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group
group
342
372
342
342
78fe2cfb3645c1b53eaf4a65b22371337809ffaf
bigcode/the-stack
train
c30d07ca329c62e04c4d8c45
train
function
def group_case(tlist): _group_matching(tlist, sql.Case)
def group_case(tlist):
_group_matching(tlist, sql.Case)
_tokens(cls, open_idx, close_idx) tidx_offset += close_idx - open_idx def group_brackets(tlist): _group_matching(tlist, sql.SquareBrackets) def group_parenthesis(tlist): _group_matching(tlist, sql.Parenthesis) def group_case(tlist):
64
64
17
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_case
group_case
61
62
61
61
880fa9260f21164bb84a2996fa087f6d8637aac7
bigcode/the-stack
train
4ce4955eaca66a4d6b97c452
train
function
def group_comparison(tlist): sqlcls = (sql.Parenthesis, sql.Function, sql.Identifier, sql.Operation) ttypes = T_NUMERICAL + T_STRING + T_NAME def match(token): return token.ttype == T.Operator.Comparison def valid(token): if imt(token, t=ttypes, i=sqlcls): ...
def group_comparison(tlist):
sqlcls = (sql.Parenthesis, sql.Function, sql.Identifier, sql.Operation) ttypes = T_NUMERICAL + T_STRING + T_NAME def match(token): return token.ttype == T.Operator.Comparison def valid(token): if imt(token, t=ttypes, i=sqlcls): return True el...
_by(m=m_semicolon, idx=nidx) nidx = snidx or nidx return pidx, nidx valid_prev = valid_next = valid _group(tlist, sql.Assignment, match, valid_prev, valid_next, post) def group_comparison(tlist):
64
64
164
7
57
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_comparison
group_comparison
150
171
150
150
e6de4eb5f3af3fdf588a48c49a3ef3d59aa92336
bigcode/the-stack
train
d8a62f54842a3f8c7d0624f7
train
function
def group_as(tlist): def match(token): return token.is_keyword and token.normalized == 'AS' def valid_prev(token): return token.normalized == 'NULL' or not token.is_keyword def valid_next(token): ttypes = T.DML, T.DDL return not imt(token, t=ttypes) and token is no...
def group_as(tlist):
def match(token): return token.is_keyword and token.normalized == 'AS' def valid_prev(token): return token.normalized == 'NULL' or not token.is_keyword def valid_next(token): ttypes = T.DML, T.DDL return not imt(token, t=ttypes) and token is not None def post...
valid_next = imt(next_, i=sqlcls, t=ttypes) return (pidx, nidx) if valid_next else (pidx, tidx) _group(tlist, sql.Identifier, match, valid_prev, valid_next, post) def group_as(tlist):
64
64
123
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_as
group_as
116
130
116
116
cf430ea191c87152117816034cb65abb07a7dcb8
bigcode/the-stack
train
0e99d47324edd53df0ca4bb4
train
function
@recurse(sql.Where) def group_where(tlist): tidx, token = tlist.token_next_by(m=sql.Where.M_OPEN) while token: eidx, end = tlist.token_next_by(m=sql.Where.M_CLOSE, idx=tidx) if end is None: end = tlist._groupable_tokens[-1] else: end = tlist.tokens[eidx ...
@recurse(sql.Where) def group_where(tlist):
tidx, token = tlist.token_next_by(m=sql.Where.M_OPEN) while token: eidx, end = tlist.token_next_by(m=sql.Where.M_CLOSE, idx=tidx) if end is None: end = tlist._groupable_tokens[-1] else: end = tlist.tokens[eidx - 1] # TODO: convert this to eidx ins...
None: eidx, end = tlist.token_prev(eidx, skip_ws=False) tlist.group_tokens(sql.Comment, tidx, eidx) tidx, token = tlist.token_next_by(t=T.Comment, idx=tidx) @recurse(sql.Where) def group_where(tlist):
64
64
166
12
52
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_where
group_where
258
272
258
259
59e3d0b5fb4f0624d5367a8785f987fba6b9ed53
bigcode/the-stack
train
ec7f87349c1bde7b37ba22de
train
function
def group_order(tlist): """Group together Identifier and Asc/Desc token""" tidx, token = tlist.token_next_by(t=T.Keyword.Order) while token: pidx, prev_ = tlist.token_prev(tidx) if imt(prev_, i=sql.Identifier, t=T.Number): tlist.group_tokens(sql.Identifier, pidx, tidx) ...
def group_order(tlist):
"""Group together Identifier and Asc/Desc token""" tidx, token = tlist.token_next_by(t=T.Keyword.Order) while token: pidx, prev_ = tlist.token_prev(tidx) if imt(prev_, i=sql.Identifier, t=T.Number): tlist.group_tokens(sql.Identifier, pidx, tidx) tidx = pidx ...
token: nidx, next_ = tlist.token_next(tidx) if isinstance(next_, sql.Parenthesis): tlist.group_tokens(sql.Function, tidx, nidx) tidx, token = tlist.token_next_by(t=T.Name, idx=tidx) def group_order(tlist):
64
64
107
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_order
group_order
308
316
308
308
b339da6548287e86556e701e0e2336968b581794
bigcode/the-stack
train
e7fc900939e359d6b47f975c
train
function
@recurse() def align_comments(tlist): tidx, token = tlist.token_next_by(i=sql.Comment) while token: pidx, prev_ = tlist.token_prev(tidx) if isinstance(prev_, sql.TokenList): tlist.group_tokens(sql.TokenList, pidx, tidx, extend=True) tidx = pidx tidx, token...
@recurse() def align_comments(tlist):
tidx, token = tlist.token_next_by(i=sql.Comment) while token: pidx, prev_ = tlist.token_prev(tidx) if isinstance(prev_, sql.TokenList): tlist.group_tokens(sql.TokenList, pidx, tidx, extend=True) tidx = pidx tidx, token = tlist.token_next_by(i=sql.Comment, id...
imt(prev_, i=sql.Identifier, t=T.Number): tlist.group_tokens(sql.Identifier, pidx, tidx) tidx = pidx tidx, token = tlist.token_next_by(t=T.Keyword.Order, idx=tidx) @recurse() def align_comments(tlist):
64
64
98
10
54
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
align_comments
align_comments
319
327
319
320
fb7c6312f995e016caef335e2798a6128ed72c27
bigcode/the-stack
train
6e1717b3f764fcfbd71a5724
train
function
def _group(tlist, cls, match, valid_prev=lambda t: True, valid_next=lambda t: True, post=None, extend=True, recurse=True ): """Groups together tokens that are joined by a middle token. i.e. x < y""" tidx_offset = 0 pidx, prev_ = No...
def _group(tlist, cls, match, valid_prev=lambda t: True, valid_next=lambda t: True, post=None, extend=True, recurse=True ):
"""Groups together tokens that are joined by a middle token. i.e. x < y""" tidx_offset = 0 pidx, prev_ = None, None for idx, token in enumerate(list(tlist)): tidx = idx - tidx_offset if token.is_whitespace: continue if recurse and token.is_group and not i...
, group_aliased, group_assignment, align_comments, group_identifier_list, group_values, ]: func(stmt) return stmt def _group(tlist, cls, match, valid_prev=lambda t: True, valid_next=lambda t: True, post=None, ...
76
76
255
41
34
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
_group
_group
375
405
375
381
300a9bac1e81ff8c182be8816342a9bf07e3412a
bigcode/the-stack
train
3d15baa13e67efbaa1f735d3
train
function
@recurse(sql.Identifier) def group_identifier(tlist): ttypes = (T.String.Symbol, T.Name) tidx, token = tlist.token_next_by(t=ttypes) while token: tlist.group_tokens(sql.Identifier, tidx, tidx) tidx, token = tlist.token_next_by(t=ttypes, idx=tidx)
@recurse(sql.Identifier) def group_identifier(tlist):
ttypes = (T.String.Symbol, T.Name) tidx, token = tlist.token_next_by(t=ttypes) while token: tlist.group_tokens(sql.Identifier, tidx, tidx) tidx, token = tlist.token_next_by(t=ttypes, idx=tidx)
list, pidx, tidx, nidx): return pidx, nidx valid_prev = valid_next = valid _group(tlist, sql.Comparison, match, valid_prev, valid_next, post, extend=False) @recurse(sql.Identifier) def group_identifier(tlist):
64
64
78
12
52
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_identifier
group_identifier
174
181
174
175
cfbd4eb6638b727fb78203ff3bb3d916330d50ba
bigcode/the-stack
train
c298ca1170fa82f62318db7a
train
function
def group_arrays(tlist): sqlcls = sql.SquareBrackets, sql.Identifier, sql.Function ttypes = T.Name, T.String.Symbol def match(token): return isinstance(token, sql.SquareBrackets) def valid_prev(token): return imt(token, i=sqlcls, t=ttypes) def valid_next(token): ...
def group_arrays(tlist):
sqlcls = sql.SquareBrackets, sql.Identifier, sql.Function ttypes = T.Name, T.String.Symbol def match(token): return isinstance(token, sql.SquareBrackets) def valid_prev(token): return imt(token, i=sqlcls, t=ttypes) def valid_next(token): return True def po...
, T.Name) tidx, token = tlist.token_next_by(t=ttypes) while token: tlist.group_tokens(sql.Identifier, tidx, tidx) tidx, token = tlist.token_next_by(t=ttypes, idx=tidx) def group_arrays(tlist):
64
64
130
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_arrays
group_arrays
184
201
184
184
17dd58dab9aad4bf2a830bed4078f7c129b69f03
bigcode/the-stack
train
bc4522064c00dcffa7502864
train
function
def group_values(tlist): tidx, token = tlist.token_next_by(m=(T.Keyword, 'VALUES')) start_idx = tidx end_idx = -1 while token: if isinstance(token, sql.Parenthesis): end_idx = tidx tidx, token = tlist.token_next(tidx) if end_idx != -1: tlist.group_tokens(...
def group_values(tlist):
tidx, token = tlist.token_next_by(m=(T.Keyword, 'VALUES')) start_idx = tidx end_idx = -1 while token: if isinstance(token, sql.Parenthesis): end_idx = tidx tidx, token = tlist.token_next(tidx) if end_idx != -1: tlist.group_tokens(sql.Values, start_idx, end...
_prev(tidx) if isinstance(prev_, sql.TokenList): tlist.group_tokens(sql.TokenList, pidx, tidx, extend=True) tidx = pidx tidx, token = tlist.token_next_by(i=sql.Comment, idx=tidx) def group_values(tlist):
64
64
97
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_values
group_values
330
339
330
330
fedc02fd36702b9705be0a16d130e27b0619c40d
bigcode/the-stack
train
44f95c8b962cb11e9bf33a3b
train
function
def group_for(tlist): _group_matching(tlist, sql.For)
def group_for(tlist):
_group_matching(tlist, sql.For)
, sql.SquareBrackets) def group_parenthesis(tlist): _group_matching(tlist, sql.Parenthesis) def group_case(tlist): _group_matching(tlist, sql.Case) def group_if(tlist): _group_matching(tlist, sql.If) def group_for(tlist):
64
64
16
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_for
group_for
69
70
69
69
0d1d143ff4ac792d423a74a1d2d981f60e3feca5
bigcode/the-stack
train
030fadcd712d0f3b5a06286b
train
function
def group_if(tlist): _group_matching(tlist, sql.If)
def group_if(tlist):
_group_matching(tlist, sql.If)
open_idx def group_brackets(tlist): _group_matching(tlist, sql.SquareBrackets) def group_parenthesis(tlist): _group_matching(tlist, sql.Parenthesis) def group_case(tlist): _group_matching(tlist, sql.Case) def group_if(tlist):
64
64
16
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_if
group_if
65
66
65
65
7751dbed071566979e30b314566be5197ce46304
bigcode/the-stack
train
999b0f345260073c23eca612
train
function
def group_assignment(tlist): def match(token): return token.match(T.Assignment, ':=') def valid(token): return token is not None and token.ttype not in (T.Keyword) def post(tlist, pidx, tidx, nidx): m_semicolon = T.Punctuation, ';' snidx, _ = tlist.token_next_by(m=...
def group_assignment(tlist):
def match(token): return token.match(T.Assignment, ':=') def valid(token): return token is not None and token.ttype not in (T.Keyword) def post(tlist, pidx, tidx, nidx): m_semicolon = T.Punctuation, ';' snidx, _ = tlist.token_next_by(m=m_semicolon, idx=nidx) ...
not imt(token, t=ttypes) and token is not None def post(tlist, pidx, tidx, nidx): return pidx, nidx _group(tlist, sql.Identifier, match, valid_prev, valid_next, post) def group_assignment(tlist):
64
64
136
6
58
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_assignment
group_assignment
133
147
133
133
9fb4702f984ff53c915e67d09eb18d7aa7c3b2f8
bigcode/the-stack
train
69c953086992c53d8c3b2da3
train
function
def group_parenthesis(tlist): _group_matching(tlist, sql.Parenthesis)
def group_parenthesis(tlist):
_group_matching(tlist, sql.Parenthesis)
groups exist continue close_idx = tidx tlist.group_tokens(cls, open_idx, close_idx) tidx_offset += close_idx - open_idx def group_brackets(tlist): _group_matching(tlist, sql.SquareBrackets) def group_parenthesis(tlist):
64
64
18
7
57
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_parenthesis
group_parenthesis
57
58
57
57
1cd779fede65d22d8ab47964c71fc25e2278b279
bigcode/the-stack
train
83c426990668198246f83241
train
function
@recurse(sql.Comment) def group_comments(tlist): tidx, token = tlist.token_next_by(t=T.Comment) while token: eidx, end = tlist.token_not_matching( lambda tk: imt(tk, t=T.Comment) or tk.is_whitespace, idx=tidx) if end is not None: eidx, end = tlist.token_prev(eidx, ...
@recurse(sql.Comment) def group_comments(tlist):
tidx, token = tlist.token_next_by(t=T.Comment) while token: eidx, end = tlist.token_not_matching( lambda tk: imt(tk, t=T.Comment) or tk.is_whitespace, idx=tidx) if end is not None: eidx, end = tlist.token_prev(eidx, skip_ws=False) tlist.group_tokens(sql....
list, pidx, tidx, nidx): return pidx, nidx valid_prev = valid_next = valid _group(tlist, sql.IdentifierList, match, valid_prev, valid_next, post, extend=True) @recurse(sql.Comment) def group_comments(tlist):
64
64
123
12
52
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_comments
group_comments
245
255
245
246
db4c9b3bacde89efd4e6831c8a2e7d22cfff9df9
bigcode/the-stack
train
9f0aa3c7d8837ffb87b0addd
train
function
def group_period(tlist): def match(token): return token.match(T.Punctuation, '.') def valid_prev(token): sqlcls = sql.SquareBrackets, sql.Identifier ttypes = T.Name, T.String.Symbol return imt(token, i=sqlcls, t=ttypes) def valid_next(token): # issue261, a...
def group_period(tlist):
def match(token): return token.match(T.Punctuation, '.') def valid_prev(token): sqlcls = sql.SquareBrackets, sql.Identifier ttypes = T.Name, T.String.Symbol return imt(token, i=sqlcls, t=ttypes) def valid_next(token): # issue261, allow invalid next token ...
): return token is not None def post(tlist, pidx, tidx, nidx): return pidx, nidx valid_prev = valid_next = valid _group(tlist, sql.Identifier, match, valid_prev, valid_next, post) def group_period(tlist):
65
65
219
6
59
RJD12/aparcamiento
Lib/site-packages/sqlparse/engine/grouping.py
Python
group_period
group_period
91
113
91
91
30acf69feb61a6cc5abc0fdedd48e6994e5223cb
bigcode/the-stack
train
fad2b3e44e0004d34808ae7d
train
function
def test_single_node_bst(): nums = [1] bst = sorted_array_to_bst(nums) assert bst.val == 1
def test_single_node_bst():
nums = [1] bst = sorted_array_to_bst(nums) assert bst.val == 1
assert n2.val == 2 assert n2.left.val == 1 assert n2.right.val == 3 assert n6.val == 6 assert n6.left.val == 5 assert n6.right is None def test_single_node_bst():
64
64
31
7
56
lukasmartinelli/sharpen
challenges/trees/sorted_array_balanced_bst.py
Python
test_single_node_bst
test_single_node_bst
53
56
53
53
50e45d772eee92dcec245f0f74db94e44ae74d6f
bigcode/the-stack
train
d28bef571c4930ddb8c34ca6
train
function
def sorted_array_to_bst(arr): """ Given a sorted array turn it into a balanced binary tree """ if len(arr) == 0: return None mid = len(arr) / 2 node = TreeNode(arr[mid]) node.left = sorted_array_to_bst(arr[:mid]) node.right = sorted_array_to_bst(arr[mid+1:]) return node
def sorted_array_to_bst(arr):
""" Given a sorted array turn it into a balanced binary tree """ if len(arr) == 0: return None mid = len(arr) / 2 node = TreeNode(arr[mid]) node.left = sorted_array_to_bst(arr[:mid]) node.right = sorted_array_to_bst(arr[mid+1:]) return node
class TreeNode(): def __init__(self, x): self.val = x self.left = None self.right = None def __repr__(self): return '<TreeNode {}>'.format(self.val) def sorted_array_to_bst(arr):
57
64
88
8
49
lukasmartinelli/sharpen
challenges/trees/sorted_array_balanced_bst.py
Python
sorted_array_to_bst
sorted_array_to_bst
11
23
11
11
ca3223302ad3c8b79699b89a01ed3555c086947d
bigcode/the-stack
train
059aade4cb0b76ab4107d9e6
train
function
def test_is_bst(): nums = [1, 2, 3, 4, 5, 6] bst = sorted_array_to_bst(nums) assert bst.val == 4 n2 = bst.left n6 = bst.right assert n2.val == 2 assert n2.left.val == 1 assert n2.right.val == 3 assert n6.val == 6 assert n6.left.val == 5 assert n6.right is None
def test_is_bst():
nums = [1, 2, 3, 4, 5, 6] bst = sorted_array_to_bst(nums) assert bst.val == 4 n2 = bst.left n6 = bst.right assert n2.val == 2 assert n2.left.val == 1 assert n2.right.val == 3 assert n6.val == 6 assert n6.left.val == 5 assert n6.right is None
node def test_uneven_bst(): nums = [1, 2, 3] bst = sorted_array_to_bst(nums) assert bst.val == 2 assert bst.left.val == 1 assert bst.right.val == 3 def test_is_bst():
64
64
115
6
57
lukasmartinelli/sharpen
challenges/trees/sorted_array_balanced_bst.py
Python
test_is_bst
test_is_bst
35
50
35
35
6f38ceae5184f4b13547b15042a6f2585a306bd1
bigcode/the-stack
train
b540cb01071c76225106a3c9
train
class
class TreeNode(): def __init__(self, x): self.val = x self.left = None self.right = None def __repr__(self): return '<TreeNode {}>'.format(self.val)
class TreeNode():
def __init__(self, x): self.val = x self.left = None self.right = None def __repr__(self): return '<TreeNode {}>'.format(self.val)
class TreeNode():
4
64
49
4
0
lukasmartinelli/sharpen
challenges/trees/sorted_array_balanced_bst.py
Python
TreeNode
TreeNode
1
8
1
1
052193dd626180ebb19ac9ebb040baf709c3b7a9
bigcode/the-stack
train
a5725f3f5f4c8d15e3339c87
train
function
def test_uneven_bst(): nums = [1, 2, 3] bst = sorted_array_to_bst(nums) assert bst.val == 2 assert bst.left.val == 1 assert bst.right.val == 3
def test_uneven_bst():
nums = [1, 2, 3] bst = sorted_array_to_bst(nums) assert bst.val == 2 assert bst.left.val == 1 assert bst.right.val == 3
0: return None mid = len(arr) / 2 node = TreeNode(arr[mid]) node.left = sorted_array_to_bst(arr[:mid]) node.right = sorted_array_to_bst(arr[mid+1:]) return node def test_uneven_bst():
64
64
56
8
55
lukasmartinelli/sharpen
challenges/trees/sorted_array_balanced_bst.py
Python
test_uneven_bst
test_uneven_bst
26
32
26
26
f93a6daf67269cc72b7a925cbc3d2937177cbb83
bigcode/the-stack
train
c04c9f78c967973725b80099
train
class
class Application(tk.Frame): def __init__(self, root, autosar_root): self.__root = root self.__asr_explorer = None self.__property_view = None self.__referred_by_view = None self.__search_dropdown = None self.__search_field = None self.__search_view ...
class Application(tk.Frame):
def __init__(self, root, autosar_root): self.__root = root self.__asr_explorer = None self.__property_view = None self.__referred_by_view = None self.__search_dropdown = None self.__search_field = None self.__search_view = None self.__go_to_men...
from enum import Enum import tkinter as tk import tkinter.ttk as ttk import tkinter.font as tkFont import re import os,itertools from ttkthemes import ThemedStyle from .autosarfactory import Referrable from tkinter import Menu __resourcesDir__ = os.path.join(os.path.dirname(__file__), 'resources') __PAD_X__...
97
256
4,862
6
90
girishchandranc/autosarfactory
autosarfactory/autosar_ui.py
Python
Application
Application
14
472
14
15
169e67c8a28183469c62d10cfaea587c4a1ea03c
bigcode/the-stack
train
0736a2d328b8ea31dd0248ab
train
function
def show_in_ui(autosarRoot): win = tk.Tk() Application(win, autosarRoot) win.mainloop()
def show_in_ui(autosarRoot):
win = tk.Tk() Application(win, autosarRoot) win.mainloop()
=element_text, values=type_text) def __get_padded_text_width(self, text): return self.__font__.measure(text + '__') + (2 * __PAD_X__) def __client_exit(self, root): root.destroy() def show_in_ui(autosarRoot):
64
64
28
9
55
girishchandranc/autosarfactory
autosarfactory/autosar_ui.py
Python
show_in_ui
show_in_ui
475
478
475
475
749d72e54821339ba3cf644dcd7b84512bf0efb1
bigcode/the-stack
train
74996474ea11f0f740d8405c
train
function
def fade_up(pin): """Fade brightness in the positive direction.""" for i in range(steps): cg.set_pwm(pin, max_brightness * (1 - (1 / (i + 2)))) sleep(time_step)
def fade_up(pin):
"""Fade brightness in the positive direction.""" for i in range(steps): cg.set_pwm(pin, max_brightness * (1 - (1 / (i + 2)))) sleep(time_step)
cg.get_pin('RGB_Strip', 'pin_green') max_brightness = 1.0 steps = 30 total_run_time = 60 time_step = total_run_time / (6 * steps) # 3 fades up, 3 down = 6 def fade_up(pin):
64
64
49
5
58
KyleKing/PiAlarm
.archive-python/modules/fade.py
Python
fade_up
fade_up
21
25
21
21
0a6097db408b7190cbe91420b340015dc9022947
bigcode/the-stack
train
3c039963c15f22eb487e9420
train
function
def fade_rgb_strip(): """Fade the LED strip through a full RGB sequence.""" all_off() cg.set_pwm(pin_red, 0.1) fade_up(pin_green) fade_down(pin_red) fade_up(pin_blue) fade_down(pin_green) fade_up(pin_red) fade_down(pin_blue) all_off()
def fade_rgb_strip():
"""Fade the LED strip through a full RGB sequence.""" all_off() cg.set_pwm(pin_red, 0.1) fade_up(pin_green) fade_down(pin_red) fade_up(pin_blue) fade_down(pin_green) fade_up(pin_red) fade_down(pin_blue) all_off()
(max_brightness=1): """Set LEDs to max brightness.""" cg.send('\nActivating all LED Strip pins') cg.set_pwm(pin_red, max_brightness) cg.set_pwm(pin_blue, max_brightness) cg.set_pwm(pin_green, max_brightness) def fade_rgb_strip():
64
64
73
5
59
KyleKing/PiAlarm
.archive-python/modules/fade.py
Python
fade_rgb_strip
fade_rgb_strip
51
64
51
51
36d8197cfdb171cd534f4fcec2ffc0112f83e45f
bigcode/the-stack
train
f974117bf9a4206664b2f866
train
function
def fade_down(pin): """Fade brightness in the negative direction.""" for i in range(steps): cg.set_pwm(pin, max_brightness / (i + 2)) sleep(time_step)
def fade_down(pin):
"""Fade brightness in the negative direction.""" for i in range(steps): cg.set_pwm(pin, max_brightness / (i + 2)) sleep(time_step)
fades up, 3 down = 6 def fade_up(pin): """Fade brightness in the positive direction.""" for i in range(steps): cg.set_pwm(pin, max_brightness * (1 - (1 / (i + 2)))) sleep(time_step) def fade_down(pin):
64
64
43
5
59
KyleKing/PiAlarm
.archive-python/modules/fade.py
Python
fade_down
fade_down
28
32
28
28
43b3591b56c32451e0a86a986148b90ac3e0dacf
bigcode/the-stack
train
5e810b4d8bdd306b4e6df43b
train
function
def all_off(): """Turn off LEDs.""" cg.send('\nDeactivating SOME PWM pins') cg.set_pwm(pin_red, 0) cg.set_pwm(pin_blue, 0) cg.set_pwm(pin_green, 0)
def all_off():
"""Turn off LEDs.""" cg.send('\nDeactivating SOME PWM pins') cg.set_pwm(pin_red, 0) cg.set_pwm(pin_blue, 0) cg.set_pwm(pin_green, 0)
(1 - (1 / (i + 2)))) sleep(time_step) def fade_down(pin): """Fade brightness in the negative direction.""" for i in range(steps): cg.set_pwm(pin, max_brightness / (i + 2)) sleep(time_step) def all_off():
64
64
52
4
60
KyleKing/PiAlarm
.archive-python/modules/fade.py
Python
all_off
all_off
35
40
35
35
e96c2712db716f2cf4d4f81882c1e0d82bcbb03c
bigcode/the-stack
train
ff3858c9f293803799ac612b
train
function
def all_on(max_brightness=1): """Set LEDs to max brightness.""" cg.send('\nActivating all LED Strip pins') cg.set_pwm(pin_red, max_brightness) cg.set_pwm(pin_blue, max_brightness) cg.set_pwm(pin_green, max_brightness)
def all_on(max_brightness=1):
"""Set LEDs to max brightness.""" cg.send('\nActivating all LED Strip pins') cg.set_pwm(pin_red, max_brightness) cg.set_pwm(pin_blue, max_brightness) cg.set_pwm(pin_green, max_brightness)
(time_step) def all_off(): """Turn off LEDs.""" cg.send('\nDeactivating SOME PWM pins') cg.set_pwm(pin_red, 0) cg.set_pwm(pin_blue, 0) cg.set_pwm(pin_green, 0) def all_on(max_brightness=1):
64
64
62
9
55
KyleKing/PiAlarm
.archive-python/modules/fade.py
Python
all_on
all_on
43
48
43
43
78a8b2c79f63c0538db42e7a61feec3321e4e512
bigcode/the-stack
train
427863ec79b777a88636a2b7
train
class
class Benchmarks(product.Product): @classmethod def product_source_name(cls): return "benchmarks" @classmethod def is_build_script_impl_product(cls): return False def should_build(self, host_target): return True def build(self, host_target): run_build_script_he...
class Benchmarks(product.Product): @classmethod
def product_source_name(cls): return "benchmarks" @classmethod def is_build_script_impl_product(cls): return False def should_build(self, host_target): return True def build(self, host_target): run_build_script_helper(host_target, self, self.args) def should_t...
Inc. and the Swift project authors # Licensed under Apache License v2.0 with Runtime Library Exception # # See https://swift.org/LICENSE.txt for license information # See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # # -----------------------------------------------------------------------...
99
99
331
10
89
lhames/swift
utils/swift_build_support/swift_build_support/products/benchmarks.py
Python
Benchmarks
Benchmarks
22
72
22
23
8ef6b563f783250cfa87d2fe00c13be60b984ce9
bigcode/the-stack
train
15104b4102b54dfd9ce0dc49
train
function
def run_build_script_helper(host_target, product, args): toolchain_path = args.install_destdir if platform.system() == 'Darwin': # The prefix is an absolute path, so concatenate without os.path. toolchain_path += \ targets.darwin_toolchain_prefix(args.install_prefix) # Our sourc...
def run_build_script_helper(host_target, product, args):
toolchain_path = args.install_destdir if platform.system() == 'Darwin': # The prefix is an absolute path, so concatenate without os.path. toolchain_path += \ targets.darwin_toolchain_prefix(args.install_prefix) # Our source_dir is expected to be './$SOURCE_ROOT/benchmarks'. That...
return [product.CMark, product.LLVM, product.LibCXX, product.LibICU, product.Swift, product.LLDB, product.LibDispatch, product.Foundation, product.XCTest, product.LLBui...
76
76
254
12
64
lhames/swift
utils/swift_build_support/swift_build_support/products/benchmarks.py
Python
run_build_script_helper
run_build_script_helper
75
101
75
75
5dafd2bd17885617a556afb56867aae17a7d1f3a
bigcode/the-stack
train
4380c07c91226f22984f00a3
train
class
class FileSystemSnapshotResponse(object): """ Attributes: swagger_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The key is attribute name and the value is json key in definition. """ swag...
class FileSystemSnapshotResponse(object):
""" Attributes: swagger_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The key is attribute name and the value is json key in definition. """ swagger_types = { 'items': 'list[FileS...
# coding: utf-8 """ FlashBlade REST API Client A lightweight client for FlashBlade REST API 2.0, developed by Pure Storage, Inc. (http://www.purestorage.com/). OpenAPI spec version: 2.0 Generated by: https://github.com/swagger-api/swagger-codegen.git """ import pprint import re import six imp...
121
170
568
7
113
Flav-STOR-WL/py-pure-client
pypureclient/flashblade/FB_2_0/models/file_system_snapshot_response.py
Python
FileSystemSnapshotResponse
FileSystemSnapshotResponse
24
111
24
24
0a9265f8b81bf086f43a29332d37cfd5d2becc7e
bigcode/the-stack
train
8f5e7f2b77b8617d2d792351
train
function
def page_not_found(request): '''404页面''' return render(request, 'errors/404.html')
def page_not_found(request):
'''404页面''' return render(request, 'errors/404.html')
# encoding:utf-8 from django.shortcuts import render def page_not_found(request):
18
64
22
6
11
linzhiming0826/cms
cms/views/errors.py
Python
page_not_found
page_not_found
5
7
5
5
028add2a38ee0991472813e6f9a49cb61209f0a9
bigcode/the-stack
train
9cf5718ec3abf7992d6c5893
train
function
def server_error(request): '''500页面''' return render(request, 'errors/500.html')
def server_error(request):
'''500页面''' return render(request, 'errors/500.html')
# encoding:utf-8 from django.shortcuts import render def page_not_found(request): '''404页面''' return render(request, 'errors/404.html') def server_error(request):
39
64
21
5
34
linzhiming0826/cms
cms/views/errors.py
Python
server_error
server_error
10
12
10
10
bd50cbc7a1e811f440623c8e9327b5380753ae0c
bigcode/the-stack
train
85eebe607368a7b35f9b613c
train
function
def create_federated_map_all_equal( fn: building_blocks.ComputationBuildingBlock, arg: building_blocks.ComputationBuildingBlock) -> building_blocks.Call: r"""Creates a called federated map of equal values. Call / \ Intrinsic Tuple | [Comp, Co...
def create_federated_map_all_equal( fn: building_blocks.ComputationBuildingBlock, arg: building_blocks.ComputationBuildingBlock) -> building_blocks.Call:
r"""Creates a called federated map of equal values. Call / \ Intrinsic Tuple | [Comp, Comp] Note: The `fn` is required to be deterministic and therefore should contain no `building_blocks.CompiledComputations`. Args: fn: A `building_block...
Type( (fn.type_signature, parameter_type), result_type) intrinsic = building_blocks.Intrinsic(intrinsic_defs.FEDERATED_MAP.uri, intrinsic_type) values = building_blocks.Struct((fn, arg)) return building_blocks.Call(intrinsic, values) def create_federated_map_all_equal...
93
93
311
34
59
OpenMined/federated
tensorflow_federated/python/core/impl/compiler/building_block_factory.py
Python
create_federated_map_all_equal
create_federated_map_all_equal
855
890
855
857
57c206377cee58d2fd054a7999790828896b0190
bigcode/the-stack
train
c82445e6798510caa5ce113b
train
function
def create_tensorflow_to_broadcast_scalar( scalar_type: tf.dtypes.DType, new_shape: tf.TensorShape) -> building_blocks.CompiledComputation: """Creates TF function broadcasting scalar to shape `new_shape`. Args: scalar_type: Instance of `tf.DType`, the type of the scalar we are looking to broadcas...
def create_tensorflow_to_broadcast_scalar( scalar_type: tf.dtypes.DType, new_shape: tf.TensorShape) -> building_blocks.CompiledComputation:
"""Creates TF function broadcasting scalar to shape `new_shape`. Args: scalar_type: Instance of `tf.DType`, the type of the scalar we are looking to broadcast. new_shape: Instance of `tf.TensorShape`, the shape we wish to broadcast to. Must be fully defined. Returns: Instance of `buildin...
""" proto = tensorflow_computation_factory.create_replicate_input( type_signature, n_replicas) return building_blocks.CompiledComputation(proto) def create_tensorflow_to_broadcast_scalar( scalar_type: tf.dtypes.DType, new_shape: tf.TensorShape) -> building_blocks.CompiledComputation:
68
68
229
35
33
OpenMined/federated
tensorflow_federated/python/core/impl/compiler/building_block_factory.py
Python
create_tensorflow_to_broadcast_scalar
create_tensorflow_to_broadcast_scalar
273
297
273
275
7aee1eee7434287d692305670e00808c77eefcde
bigcode/the-stack
train