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
65f546c909aaff6c1a0dcf98
train
function
@measure_time @cache def fibonacci(n): # print(f'Calculating F({n})') if n == 0: return 0 if n == 1: return 1 return fibonacci(n - 1) + fibonacci(n - 2)
@measure_time @cache def fibonacci(n): # print(f'Calculating F({n})')
if n == 0: return 0 if n == 1: return 1 return fibonacci(n - 1) + fibonacci(n - 2)
get_current_temperature = debug(uppercase(get_current_temperature)) @measure_time def big_loop(): x = 0 for _ in range(100000000): x += 1 @measure_time @cache def fibonacci(n): # print(f'Calculating F({n})')
64
64
62
23
40
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
fibonacci
fibonacci
104
113
104
107
39388cefc3da21266abd38297cc4b937d5ddfcdb
bigcode/the-stack
train
fbfb376d51f0a77b48c536ed
train
function
def uppercase(func): @functools.wraps(func) def wrapper(*args, **kwargs): return func(*args, **kwargs).upper() return wrapper
def uppercase(func): @functools.wraps(func)
def wrapper(*args, **kwargs): return func(*args, **kwargs).upper() return wrapper
import functools from time import time def uppercase(func): @functools.wraps(func)
21
64
37
13
7
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
uppercase
uppercase
5
10
5
6
349c3eaa4d2757f17c3f17aa16d1b7ec0bc8f056
bigcode/the-stack
train
ed649d52bdb8d920ae8ecd5e
train
function
@debug @uppercase def get_current_temperature(): return '3\' celsius'
@debug @uppercase def get_current_temperature():
return '3\' celsius'
5) def print_hello_message(name): print(get_hello_message(name)) print_hello_message('Maria') # print_hello_message = repeat(3)(print_hello_message) print(get_hello_message) print(get_hello_message.__name__) @debug @uppercase def get_current_temperature():
64
64
19
11
53
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
get_current_temperature
get_current_temperature
88
91
88
90
9224ed07aca29c7d78a06a41e444eecbdbeb7072
bigcode/the-stack
train
c6c88868140e4b61785d105f
train
function
def repeat(count): def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): result = None for _ in range(count): result = func(*args, **kwargs) return result return wrapper return decorator
def repeat(count):
def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): result = None for _ in range(count): result = func(*args, **kwargs) return result return wrapper return decorator
.internal_cache[cache_key] = func(*args, **kwargs) # internal_cache[cache_key] = func(*args, **kwargs) return wrapper.internal_cache[cache_key] # return internal_cache[cache_key] wrapper.internal_cache = {} return wrapper def repeat(count):
64
64
61
4
59
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
repeat
repeat
55
66
55
55
bb150acf07175fb56068dc14301344a24ba5caeb
bigcode/the-stack
train
4efedea8f3148894280ad32f
train
function
@measure_time def big_loop(): x = 0 for _ in range(100000000): x += 1
@measure_time def big_loop():
x = 0 for _ in range(100000000): x += 1
hello_message = repeat(3)(print_hello_message) print(get_hello_message) print(get_hello_message.__name__) @debug @uppercase def get_current_temperature(): return '3\' celsius' get_current_temperature = debug(uppercase(get_current_temperature)) @measure_time def big_loop():
64
64
30
8
56
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
big_loop
big_loop
97
101
97
98
d1e05be1936fadd125136b3a4a8fa5d1abdba1b3
bigcode/the-stack
train
3552c91dcd8cf05c3a8d8c4c
train
function
@measure_time def fibonacci2(n): # print(f'Calculating F({n})') if n == 0: return 0 if n == 1: return 1 return fibonacci2(n - 1) + fibonacci2(n - 2)
@measure_time def fibonacci2(n): # print(f'Calculating F({n})')
if n == 0: return 0 if n == 1: return 1 return fibonacci2(n - 1) + fibonacci2(n - 2)
({n})') if n == 0: return 0 if n == 1: return 1 return fibonacci(n - 1) + fibonacci(n - 2) @measure_time def fibonacci2(n): # print(f'Calculating F({n})')
64
64
62
21
43
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
fibonacci2
fibonacci2
116
124
116
118
ea2e7968ebb44baf0d1adcd501581890cd1fed33
bigcode/the-stack
train
7e0ee2ac6b4b1f10afad851a
train
function
def measure_time(func): @functools.wraps(func) def wrapper(*args, **kwargs): start = time() result = func(*args, **kwargs) end = time() print(f'{func.__name__} executed in {end - start} seconds') return result return wrapper
def measure_time(func): @functools.wraps(func)
def wrapper(*args, **kwargs): start = time() result = func(*args, **kwargs) end = time() print(f'{func.__name__} executed in {end - start} seconds') return result return wrapper
import functools from time import time def uppercase(func): @functools.wraps(func) def wrapper(*args, **kwargs): return func(*args, **kwargs).upper() return wrapper def measure_time(func): @functools.wraps(func)
59
64
69
14
44
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
measure_time
measure_time
13
22
13
14
b7889cabf1500be86d2ed4fe34b718896b394fa1
bigcode/the-stack
train
ea71e40284d017cc69cf843e
train
function
def cache(func): # internal_cache = {} @functools.wraps(func) def wrapper(*args, **kwargs): cache_key = args + tuple(kwargs.values()) # if cache_key not in internal_cache: if cache_key not in wrapper.internal_cache: wrapper.internal_cache[cache_key] = func(*args, **kwargs...
def cache(func): # internal_cache = {} @functools.wraps(func)
def wrapper(*args, **kwargs): cache_key = args + tuple(kwargs.values()) # if cache_key not in internal_cache: if cache_key not in wrapper.internal_cache: wrapper.internal_cache[cache_key] = func(*args, **kwargs) # internal_cache[cache_key] = func(*args, **kwargs) ...
value) in kwargs.items()) result = func(*args, **kwargs) print(f'{func.__name__}({args_str}, {kwargs_str}) returned {result}') return result return wrapper def cache(func): # internal_cache = {} @functools.wraps(func)
64
64
120
19
44
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
cache
cache
39
52
39
41
10c8966c2326406839279ec867763082d88c3cec
bigcode/the-stack
train
428ce1dc2bd161ffafce391e
train
function
def get_hello_message(name): return f'Hello, I am {name}'
def get_hello_message(name):
return f'Hello, I am {name}'
ctools.wraps(func) def wrapper(*args, **kwargs): result = None for _ in range(count): result = func(*args, **kwargs) return result return wrapper return decorator # @debug # @cache def get_hello_message(name):
64
64
18
7
56
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
get_hello_message
get_hello_message
71
72
71
71
848e9288cc12877261d986c9e928ccdca6dd799d
bigcode/the-stack
train
1cf81a10fe2506b8ef7e6b37
train
function
@repeat(5) def print_hello_message(name): print(get_hello_message(name))
@repeat(5) def print_hello_message(name):
print(get_hello_message(name))
range(count): result = func(*args, **kwargs) return result return wrapper return decorator # @debug # @cache def get_hello_message(name): return f'Hello, I am {name}' @repeat(5) def print_hello_message(name):
63
64
20
12
51
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
print_hello_message
print_hello_message
75
77
75
76
46dd5bd95163829158dd8b3e17597bdcd4e15fe0
bigcode/the-stack
train
d3a9297a30e9ea2cd5765ac7
train
function
def debug(func): """print func name with args, kwargs and result""" @functools.wraps(func) def wrapper(*args, **kwargs): args_str = ', '.join(args) kwargs_str = ', '.join(f'{key}={value}' for (key, value) in kwargs.items()) result = func(*args, **kwargs) print(f'{func.__name...
def debug(func):
"""print func name with args, kwargs and result""" @functools.wraps(func) def wrapper(*args, **kwargs): args_str = ', '.join(args) kwargs_str = ', '.join(f'{key}={value}' for (key, value) in kwargs.items()) result = func(*args, **kwargs) print(f'{func.__name__}({args_str}, {...
ools.wraps(func) def wrapper(*args, **kwargs): start = time() result = func(*args, **kwargs) end = time() print(f'{func.__name__} executed in {end - start} seconds') return result return wrapper def debug(func):
64
64
106
4
59
Minkov/python-oop-2021-02
decorators/demos_decorators.py
Python
debug
debug
25
36
25
25
590a31975d6f7a8dfe4f6ed151f22d45271eaf8a
bigcode/the-stack
train
2722679765ca20d2500e022f
train
class
class PHI(GenericPHI): @phi_constructor def __init__(self, **kwargs): self.topic = self.phi_cfg.get('t') self.mqtt = MQTT(self.phi_cfg.get('n')) self.current_status = None if self.topic is None or self.mqtt is None: self.ready = False def get(self, port=None, cf...
class PHI(GenericPHI): @phi_constructor
def __init__(self, **kwargs): self.topic = self.phi_cfg.get('t') self.mqtt = MQTT(self.phi_cfg.get('n')) self.current_status = None if self.topic is None or self.mqtt is None: self.ready = False def get(self, port=None, cfg=None, timeout=0): return {'1': self...
Tead Sonoff Basic. Uses one of system MQTT notifiers for communication. Requires Tasmota firmware (compatible with all single port devices, for multi-ports use sonoff_mch) """ import json from eva.uc.drivers.phi.generic_phi import PHI as GenericPHI from eva.uc.driverapi import handle_phi_event from eva.uc.driverapi i...
114
114
380
12
101
alttch/eva-phi
phi/relays/sonoff_basic.py
Python
PHI
PHI
42
88
42
44
5c50b0daf92fed10ebe6d3904e8d21d200b92839
bigcode/the-stack
train
6c14b5a603695f15281faedb
train
function
def create_reperestory(media_path,product,collection,year,month,day): """ Function that create reperestories to store downloaded files Positional argument: product -- name of the product (eg. MYD06_L2); type = string collection -- collection (eg. 61); type = integer year -- pr...
def create_reperestory(media_path,product,collection,year,month,day):
""" Function that create reperestories to store downloaded files Positional argument: product -- name of the product (eg. MYD06_L2); type = string collection -- collection (eg. 61); type = integer year -- product year (eg. 61); type = integer month -- product month (eg. 61...
from datetime import date from os import path import urllib.request import os import json import pprint from . import date_converter from .. import config ########################################################################################## def create_reperestory(media_path,product,collection,year,month,day): ...
57
87
291
20
37
benjamin-hg-marchant/ideas4eo
grt/nasa_laads_daac.py
Python
create_reperestory
create_reperestory
15
40
15
16
f983e190df014dbcee7bf07a0a14d82521c6eb95
bigcode/the-stack
train
74ff433c6b3c564e8115d835
train
function
def get_file(product,collection,year,month,day,hour,minute): """ Download a single file from NASA LAADS DAAC (Level-1 and Atmosphere Archive & Distribution System Distributed Active Archive Center) (https://ladsweb.modaps.eosdis.nasa.gov/) Positional argument: product -- name of the produ...
def get_file(product,collection,year,month,day,hour,minute):
""" Download a single file from NASA LAADS DAAC (Level-1 and Atmosphere Archive & Distribution System Distributed Active Archive Center) (https://ladsweb.modaps.eosdis.nasa.gov/) Positional argument: product -- name of the product (eg. MYD06_L2); type = string collection -- collect...
integer year -- product year (eg. 61); type = integer month -- product month (eg. 61); type = integer day -- product day (eg. 61); type = integer """ if not os.path.exists("{}/{}".format(media_path,product)): os.system("mkdir {}/{}".format(media_path,product)) ...
240
240
800
17
223
benjamin-hg-marchant/ideas4eo
grt/nasa_laads_daac.py
Python
get_file
get_file
44
140
44
45
1a4a956b9f0ad461dd8c320f01a39a47cf6235db
bigcode/the-stack
train
6cc5b3f9ca0b30d2968cc97a
train
function
def problem(name): """Retrieve a problem by name.""" def parse_problem_name(problem_name): """Determines if problem_name specifies a copy and/or reversal. Args: problem_name: str, problem name, possibly with suffixes. Returns: base_name: A string with the base problem name. was_reve...
def problem(name):
"""Retrieve a problem by name.""" def parse_problem_name(problem_name): """Determines if problem_name specifies a copy and/or reversal. Args: problem_name: str, problem name, possibly with suffixes. Returns: base_name: A string with the base problem name. was_reversed: A boolean. ...
." % p_name) _PROBLEMS[p_name] = p_cls p_cls.name = p_name return p_cls # Handle if decorator was used without parens if callable(name): p_cls = name return decorator(p_cls, registration_name=default_name(p_cls)) return lambda p_cls: decorator(p_cls, name) def problem(name):
82
82
274
4
78
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
problem
problem
240
272
240
240
b4c5bd637b94c05385d1d58ad92709e21098cdde
bigcode/the-stack
train
2135462b24c8f774ee17f9e4
train
function
def ranged_hparams(name): if name not in _RANGED_HPARAMS: raise LookupError("RangedHParams set %s never registered." % name) return _RANGED_HPARAMS[name]
def ranged_hparams(name):
if name not in _RANGED_HPARAMS: raise LookupError("RangedHParams set %s never registered." % name) return _RANGED_HPARAMS[name]
return rhp_fn # Handle if decorator was used without parens if callable(name): rhp_fn = name return decorator(rhp_fn, registration_name=default_name(rhp_fn)) return lambda rhp_fn: decorator(rhp_fn, name) def ranged_hparams(name):
64
64
46
6
58
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
ranged_hparams
ranged_hparams
209
212
209
209
9837c7365061155348d7fd1acc477a62f31c5922
bigcode/the-stack
train
2b542f56f8c337ac30c53acf
train
function
def register_model(name=None): """Register a model. name defaults to class name snake-cased.""" def decorator(model_cls, registration_name=None): """Registers & returns model_cls with registration_name or default name.""" model_name = registration_name or default_name(model_cls) if model_name in _MODEL...
def register_model(name=None):
"""Register a model. name defaults to class name snake-cased.""" def decorator(model_cls, registration_name=None): """Registers & returns model_cls with registration_name or default name.""" model_name = registration_name or default_name(model_cls) if model_name in _MODELS and not tf.contrib.eager.in_e...
def default_object_name(obj): """Convert an object to the registry's default name for the object class. Args: obj: an object instance Returns: The registry's default name for the class of the object. """ return default_name(obj.__class__) def register_model(name=None):
64
64
167
6
58
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
register_model
register_model
113
130
113
113
4be77bdfd4fdf81de0985e0c2588c5db5fa54dc0
bigcode/the-stack
train
8b0d2acf7cd5bd96d91f6c54
train
function
def default_name(obj_class): """Convert a class name to the registry's default name for the class. Args: obj_class: the name of a class Returns: The registry's default name for the class. """ return _convert_camel_to_snake(obj_class.__name__)
def default_name(obj_class):
"""Convert a class name to the registry's default name for the class. Args: obj_class: the name of a class Returns: The registry's default name for the class. """ return _convert_camel_to_snake(obj_class.__name__)
"\1_\2", name) return _all_cap_re.sub(r"\1_\2", s1).lower() def _reset(): for ctr in [_MODELS, _HPARAMS, _RANGED_HPARAMS, _ATTACK_PARAMS]: ctr.clear() def default_name(obj_class):
64
64
64
6
58
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
default_name
default_name
89
98
89
89
f79f4276d1b4284de9e4b2e6d4a193bea2903506
bigcode/the-stack
train
8c402124737d90119bcbbe37
train
function
def list_attack_params(prefix=None): if prefix: return [name for name in _ATTACK_PARAMS if name.startswith(prefix)] return list(_ATTACK_PARAMS)
def list_attack_params(prefix=None):
if prefix: return [name for name in _ATTACK_PARAMS if name.startswith(prefix)] return list(_ATTACK_PARAMS)
_attack_params(), starting_spaces=4))) ap = _ATTACK_PARAMS[name]() if ap is None: raise TypeError("Attack HParams %s is None. Make sure the registered " "function returns the HParams object." % name) return ap def list_attack_params(prefix=None):
64
64
35
7
56
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
list_attack_params
list_attack_params
352
355
352
352
98e529bfb072b6ea51dde783a3f3092762c88e63
bigcode/the-stack
train
3cfbf4f0a09830ca7743e005
train
class
class Modalities(object): """An enum-like object carrying the set of available modality types.""" SYMBOL = "symbol" IMAGE = "image" AUDIO = "audio" VIDEO = "video" CLASS_LABEL = "class_label" GENERIC = "generic" REAL = "real"
class Modalities(object):
"""An enum-like object carrying the set of available modality types.""" SYMBOL = "symbol" IMAGE = "image" AUDIO = "audio" VIDEO = "video" CLASS_LABEL = "class_label" GENERIC = "generic" REAL = "real"
S = {} _MODELS = {} _PROBLEMS = {} _PRUNING_PARAMS = {} _PRUNING_STRATEGY = {} _RANGED_HPARAMS = {} # TODO(trandustin): Many files depend on this to specify modality strings; let's # remove it in the future. class Modalities(object):
64
64
64
5
59
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
Modalities
Modalities
63
71
63
63
be831533b324e3e76e82ee2ec0f68cac3dc28759
bigcode/the-stack
train
649c2c2aa89287002fa3a7a5
train
function
def default_object_name(obj): """Convert an object to the registry's default name for the object class. Args: obj: an object instance Returns: The registry's default name for the class of the object. """ return default_name(obj.__class__)
def default_object_name(obj):
"""Convert an object to the registry's default name for the object class. Args: obj: an object instance Returns: The registry's default name for the class of the object. """ return default_name(obj.__class__)
"""Convert a class name to the registry's default name for the class. Args: obj_class: the name of a class Returns: The registry's default name for the class. """ return _convert_camel_to_snake(obj_class.__name__) def default_object_name(obj):
64
64
58
6
58
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
default_object_name
default_object_name
101
110
101
101
56e4117d53e0ff052da2efa141743263072d8183
bigcode/the-stack
train
8a0010e60c197a6befe77a7a
train
function
def _convert_camel_to_snake(name): s1 = _first_cap_re.sub(r"\1_\2", name) return _all_cap_re.sub(r"\1_\2", s1).lower()
def _convert_camel_to_snake(name):
s1 = _first_cap_re.sub(r"\1_\2", name) return _all_cap_re.sub(r"\1_\2", s1).lower()
" REAL = "real" # Camel case to snake case utils _first_cap_re = re.compile("(.)([A-Z][a-z0-9]+)") _all_cap_re = re.compile("([a-z0-9])([A-Z])") def _convert_camel_to_snake(name):
64
64
45
10
54
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
_convert_camel_to_snake
_convert_camel_to_snake
79
81
79
79
0139908013bddbb1d942bc3dccac6ad98a84378a
bigcode/the-stack
train
ce51aa22c6b3835fe09c4497
train
function
def list_pruning_strategies(prefix=None): if prefix: return [name for name in _PRUNING_STRATEGY if name.startswith(prefix)] return list(_PRUNING_STRATEGY)
def list_pruning_strategies(prefix=None):
if prefix: return [name for name in _PRUNING_STRATEGY if name.startswith(prefix)] return list(_PRUNING_STRATEGY)
(), starting_spaces=4))) ps = _PRUNING_STRATEGY[name] if ps is None: raise TypeError("Pruning strategy %s is None. Make sure to register the " "function." % name) return ps def list_pruning_strategies(prefix=None):
64
64
44
10
53
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
list_pruning_strategies
list_pruning_strategies
430
433
430
430
7caa5366083f82f158aee1398ee11c3914e803d9
bigcode/the-stack
train
d790f791ce3d35dce66b4d28
train
function
def hparams(name): """Retrieve registered hparams by name.""" if name not in _HPARAMS: error_msg = "HParams set %s never registered. Sets registered:\n%s" raise LookupError( error_msg % (name, display_list_by_prefix(list_hparams(), starting_spaces=4))) hp = _HPARAMS[name]() ...
def hparams(name):
"""Retrieve registered hparams by name.""" if name not in _HPARAMS: error_msg = "HParams set %s never registered. Sets registered:\n%s" raise LookupError( error_msg % (name, display_list_by_prefix(list_hparams(), starting_spaces=4))) hp = _HPARAMS[name]() if hp is None: ...
hp_fn return hp_fn # Handle if decorator was used without parens if callable(name): hp_fn = name return decorator(hp_fn, registration_name=default_name(hp_fn)) return lambda hp_fn: decorator(hp_fn, name) def hparams(name):
64
64
117
5
59
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
hparams
hparams
164
175
164
164
c1773049872470bdd7c78c0e3c2fc99ee5242cfb
bigcode/the-stack
train
4db02a5c453e4d5bc49067d3
train
function
def attack_params(name): """Retrieve registered aparams by name.""" if name not in _ATTACK_PARAMS: error_msg = "Attack HParams set %s never registered. Sets registered:\n%s" raise LookupError( error_msg % (name, display_list_by_prefix(list_attack_params(), starting_spaces=4))) ap = _ATTACK...
def attack_params(name):
"""Retrieve registered aparams by name.""" if name not in _ATTACK_PARAMS: error_msg = "Attack HParams set %s never registered. Sets registered:\n%s" raise LookupError( error_msg % (name, display_list_by_prefix(list_attack_params(), starting_spaces=4))) ap = _ATTACK_PARAMS[name]() if ap i...
_name] = ap_fn return ap_fn # Handle if decorator was used without parens if callable(name): ap_fn = name return decorator(ap_fn, registration_name=default_name(ap_fn)) return lambda ap_fn: decorator(ap_fn, name) def attack_params(name):
64
64
119
5
59
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
attack_params
attack_params
338
349
338
338
c9e02185d40342ed02dea60665b427774f327087
bigcode/the-stack
train
13e87e76ce3b28ff35b1a14d
train
function
def list_ranged_hparams(): return list(_RANGED_HPARAMS)
def list_ranged_hparams():
return list(_RANGED_HPARAMS)
rhp_fn: decorator(rhp_fn, name) def ranged_hparams(name): if name not in _RANGED_HPARAMS: raise LookupError("RangedHParams set %s never registered." % name) return _RANGED_HPARAMS[name] def list_ranged_hparams():
64
64
17
7
57
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
list_ranged_hparams
list_ranged_hparams
215
216
215
215
d334aaf7f2fdda5788c6e7b50b5a1887680d7c21
bigcode/the-stack
train
3428fb8010e75f3639b504ef
train
function
def register_hparams(name=None): """Register an HParams set. name defaults to function name snake-cased.""" def decorator(hp_fn, registration_name=None): """Registers & returns hp_fn with registration_name or default name.""" hp_name = registration_name or default_name(hp_fn) if hp_name in _HPARAMS and...
def register_hparams(name=None):
"""Register an HParams set. name defaults to function name snake-cased.""" def decorator(hp_fn, registration_name=None): """Registers & returns hp_fn with registration_name or default name.""" hp_name = registration_name or default_name(hp_fn) if hp_name in _HPARAMS and not tf.contrib.eager.in_eager_mo...
not in _MODELS: raise LookupError("Model %s never registered. Available models:\n %s" % (name, "\n".join(list_models()))) return _MODELS[name] def list_models(): return list(sorted(_MODELS)) def register_hparams(name=None):
64
64
168
7
57
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
register_hparams
register_hparams
145
161
145
145
c3e4d6480e78fd4471e3b9001b30a8d14f0fd634
bigcode/the-stack
train
597a684c7ade6f99814bbb27
train
function
def pruning_strategies(name): """Retrieve registered pruning strategies by name.""" if name not in _PRUNING_STRATEGY: error_msg = "Pruning strategy set %s never registered. Sets registered:\n%s" raise LookupError( error_msg % (name, display_list_by_prefix( ...
def pruning_strategies(name):
"""Retrieve registered pruning strategies by name.""" if name not in _PRUNING_STRATEGY: error_msg = "Pruning strategy set %s never registered. Sets registered:\n%s" raise LookupError( error_msg % (name, display_list_by_prefix( list_pruning_strategies(), ...
= ps_fn return ps_fn # Handle if decorator was used without parens if callable(name): ps_fn = name return decorator(ps_fn, registration_name=default_name(ps_fn)) return lambda ps_fn: decorator(ps_fn, name) def pruning_strategies(name):
64
64
128
7
57
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
pruning_strategies
pruning_strategies
415
427
415
415
35f6ff7c725534f22fd32f6ea5f028ded74ea9a8
bigcode/the-stack
train
1349a848c776d2019e495dba
train
function
def register_pruning_strategy(name=None): """Register an pruning strategy. Same behaviour as register_hparams.""" def decorator(ps_fn, registration_name=None): """Registers & returns ps_fn with registration_name or default name.""" ps_name = registration_name or default_name(ps_fn) if ps_name in _PRUNI...
def register_pruning_strategy(name=None):
"""Register an pruning strategy. Same behaviour as register_hparams.""" def decorator(ps_fn, registration_name=None): """Registers & returns ps_fn with registration_name or default name.""" ps_name = registration_name or default_name(ps_fn) if ps_name in _PRUNING_STRATEGY and not tf.contrib.eager.in_ea...
registered " "function returns the HParams object." % name) return pp def list_pruning_params(prefix=None): if prefix: return [name for name in _PRUNING_PARAMS if name.startswith(prefix)] return list(_PRUNING_PARAMS) def register_pruning_strategy(name=None):
64
64
167
8
56
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
register_pruning_strategy
register_pruning_strategy
396
412
396
396
06f35c3bc697bf08300ee4035de47ba43106129d
bigcode/the-stack
train
40ed5d6876209b92df58fbe7
train
function
def register_problem(name=None): """Register a Problem. name defaults to cls name snake-cased.""" def decorator(p_cls, registration_name=None): """Registers & returns p_cls with registration_name or default name.""" p_name = registration_name or default_name(p_cls) if p_name in _PROBLEMS and not tf.con...
def register_problem(name=None):
"""Register a Problem. name defaults to cls name snake-cased.""" def decorator(p_cls, registration_name=None): """Registers & returns p_cls with registration_name or default name.""" p_name = registration_name or default_name(p_cls) if p_name in _PROBLEMS and not tf.contrib.eager.in_eager_mode(): ...
): if name not in _RANGED_HPARAMS: raise LookupError("RangedHParams set %s never registered." % name) return _RANGED_HPARAMS[name] def list_ranged_hparams(): return list(_RANGED_HPARAMS) def register_problem(name=None):
64
64
165
6
58
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
register_problem
register_problem
219
237
219
219
a75e4ee2bbf57bf3cf2f08220e38c885373c1c2c
bigcode/the-stack
train
adff63d3e309192cca0bea83
train
function
def pruning_params(name): """Retrieve registered pruning params by name.""" if name not in _PRUNING_PARAMS: error_msg = "Pruning HParams set %s never registered. Sets registered:\n%s" raise LookupError(error_msg % ( name, display_list_by_prefix(list_pruning_params(), starting_spaces=4))) pp = _PRU...
def pruning_params(name):
"""Retrieve registered pruning params by name.""" if name not in _PRUNING_PARAMS: error_msg = "Pruning HParams set %s never registered. Sets registered:\n%s" raise LookupError(error_msg % ( name, display_list_by_prefix(list_pruning_params(), starting_spaces=4))) pp = _PRUNING_PARAMS[name]() if p...
_name] = pp_fn return pp_fn # Handle if decorator was used without parens if callable(name): pp_fn = name return decorator(pp_fn, registration_name=default_name(pp_fn)) return lambda pp_fn: decorator(pp_fn, name) def pruning_params(name):
64
64
122
5
59
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
pruning_params
pruning_params
377
387
377
377
f33980d988447f560aa2030940945ad2a22b173a
bigcode/the-stack
train
ef7f4cb27e1820cb612221ef
train
function
def list_pruning_params(prefix=None): if prefix: return [name for name in _PRUNING_PARAMS if name.startswith(prefix)] return list(_PRUNING_PARAMS)
def list_pruning_params(prefix=None):
if prefix: return [name for name in _PRUNING_PARAMS if name.startswith(prefix)] return list(_PRUNING_PARAMS)
starting_spaces=4))) pp = _PRUNING_PARAMS[name]() if pp is None: raise TypeError("Pruning HParams %s is None. Make sure the registered " "function returns the HParams object." % name) return pp def list_pruning_params(prefix=None):
64
64
38
8
55
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
list_pruning_params
list_pruning_params
390
393
390
390
d809e39f85b5152bed156e87113b6b8acf8a13e1
bigcode/the-stack
train
78e8a8fb7e73a207553b079f
train
function
def display_list_by_prefix(names_list, starting_spaces=0): """Creates a help string for names_list grouped by prefix.""" cur_prefix, result_lines = None, [] space = " " * starting_spaces for name in sorted(names_list): split = name.split("_", 1) prefix = split[0] if cur_prefix != prefix: resul...
def display_list_by_prefix(names_list, starting_spaces=0):
"""Creates a help string for names_list grouped by prefix.""" cur_prefix, result_lines = None, [] space = " " * starting_spaces for name in sorted(names_list): split = name.split("_", 1) prefix = split[0] if cur_prefix != prefix: result_lines.append(space + prefix + ":") cur_prefix = pre...
% name) return ps def list_pruning_strategies(prefix=None): if prefix: return [name for name in _PRUNING_STRATEGY if name.startswith(prefix)] return list(_PRUNING_STRATEGY) def display_list_by_prefix(names_list, starting_spaces=0):
64
64
115
13
51
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
display_list_by_prefix
display_list_by_prefix
436
447
436
436
7457d1ca0ac3dc660358da0bf658cac7f900dd06
bigcode/the-stack
train
d223f6ba6a4483f695e0a667
train
function
def list_attacks(prefix=None): if prefix: return [name for name in _ATTACKS if name.startswith(prefix)] return list(_ATTACKS)
def list_attacks(prefix=None):
if prefix: return [name for name in _ATTACKS if name.startswith(prefix)] return list(_ATTACKS)
4))) attack = _ATTACKS[name]() if attack is None: raise TypeError( "Attack %s is None. Make sure the registered function returns a " "`cleverhans.attack.Attack` object." % name) return attack def list_attacks(prefix=None):
64
64
35
7
56
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
list_attacks
list_attacks
313
316
313
313
9c7796acd668fec353f076795ff9f03d3627b2a6
bigcode/the-stack
train
036992e8ddb58517c541ce4b
train
function
def _reset(): for ctr in [_MODELS, _HPARAMS, _RANGED_HPARAMS, _ATTACK_PARAMS]: ctr.clear()
def _reset():
for ctr in [_MODELS, _HPARAMS, _RANGED_HPARAMS, _ATTACK_PARAMS]: ctr.clear()
re.compile("([a-z0-9])([A-Z])") def _convert_camel_to_snake(name): s1 = _first_cap_re.sub(r"\1_\2", name) return _all_cap_re.sub(r"\1_\2", s1).lower() def _reset():
64
64
33
4
60
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
_reset
_reset
84
86
84
84
2ff1d84988d1c63c0cbca4edf4bd16b917a0208c
bigcode/the-stack
train
678e70f06c5cab7428dc3304
train
function
def attacks(name): """Retrieve registered attack by name.""" if name not in _ATTACKS: error_msg = "Attack %s never registered. Sets registered:\n%s" raise LookupError( error_msg % (name, display_list_by_prefix(list_attacks(), starting_spaces=4))) attack = _ATTACKS[name]() if...
def attacks(name):
"""Retrieve registered attack by name.""" if name not in _ATTACKS: error_msg = "Attack %s never registered. Sets registered:\n%s" raise LookupError( error_msg % (name, display_list_by_prefix(list_attacks(), starting_spaces=4))) attack = _ATTACKS[name]() if attack is None: ...
= attack_fn return attack_fn # Handle if decorator was used without parens if callable(name): attack_fn = name return decorator(attack_fn, registration_name=default_name(attack_fn)) return lambda attack_fn: decorator(attack_fn, name) def attacks(name):
64
64
120
4
60
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
attacks
attacks
298
310
298
298
366945c2f49ed8e7045dc91edadd9714faf2094f
bigcode/the-stack
train
a5a073a3d9dec2d50c51e8b2
train
function
def list_models(): return list(sorted(_MODELS))
def list_models():
return list(sorted(_MODELS))
_cls: decorator(model_cls, name) def model(name): if name not in _MODELS: raise LookupError("Model %s never registered. Available models:\n %s" % (name, "\n".join(list_models()))) return _MODELS[name] def list_models():
64
64
12
4
60
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
list_models
list_models
141
142
141
141
c0032c4fcb142c8978a21e8d1756b78daf6fec2e
bigcode/the-stack
train
33b8bed6295a184d8ae7f5eb
train
function
def help_string(): """Generate help string with contents of registry.""" help_str = """ Registry contents: ------------------ Models: %s HParams: %s RangedHParams: %s Problems: %s Attacks: %s Attack HParams: %s Pruning HParams: %s Pruning Strategies: %s """ m, hp, rhp, probs, atks, ap, pp,...
def help_string():
"""Generate help string with contents of registry.""" help_str = """ Registry contents: ------------------ Models: %s HParams: %s RangedHParams: %s Problems: %s Attacks: %s Attack HParams: %s Pruning HParams: %s Pruning Strategies: %s """ m, hp, rhp, probs, atks, ap, pp, ps = [ displ...
= name.split("_", 1) prefix = split[0] if cur_prefix != prefix: result_lines.append(space + prefix + ":") cur_prefix = prefix result_lines.append(space + " * " + name) return "\n".join(result_lines) def help_string():
64
64
186
4
60
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
help_string
help_string
450
492
450
450
755e27ea3feb735fb62ecc946ef1b5a30aef9b34
bigcode/the-stack
train
88f87adcae6cc581dbd9e94f
train
function
def register_ranged_hparams(name=None): """Register a RangedHParams set. name defaults to fn name snake-cased.""" def decorator(rhp_fn, registration_name=None): """Registers & returns hp_fn with registration_name or default name.""" rhp_name = registration_name or default_name(rhp_fn) if rhp_name in _R...
def register_ranged_hparams(name=None):
"""Register a RangedHParams set. name defaults to fn name snake-cased.""" def decorator(rhp_fn, registration_name=None): """Registers & returns hp_fn with registration_name or default name.""" rhp_name = registration_name or default_name(rhp_fn) if rhp_name in _RANGED_HPARAMS: raise LookupError("...
TypeError("HParams %s is None. Make sure the registered function " "returns the HParams object." % name) return hp def list_hparams(prefix=None): if prefix: return [name for name in _HPARAMS if name.startswith(prefix)] return list(_HPARAMS) def register_ranged_hparams(name=None):
75
75
251
9
66
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
register_ranged_hparams
register_ranged_hparams
184
206
184
184
1e55e9ab5cf60fafaffa7c7968d221918ce6358f
bigcode/the-stack
train
f03ce4f856226104890fde60
train
function
def model(name): if name not in _MODELS: raise LookupError("Model %s never registered. Available models:\n %s" % (name, "\n".join(list_models()))) return _MODELS[name]
def model(name):
if name not in _MODELS: raise LookupError("Model %s never registered. Available models:\n %s" % (name, "\n".join(list_models()))) return _MODELS[name]
model_name] = model_cls return model_cls # Handle if decorator was used without parens if callable(name): model_cls = name return decorator(model_cls, registration_name=default_name(model_cls)) return lambda model_cls: decorator(model_cls, name) def model(name):
64
64
52
4
60
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
model
model
133
138
133
133
437fb823a158678c52e5797440866daec6e92bc6
bigcode/the-stack
train
b8c995ca21a67cc83f42e7cc
train
function
def list_hparams(prefix=None): if prefix: return [name for name in _HPARAMS if name.startswith(prefix)] return list(_HPARAMS)
def list_hparams(prefix=None):
if prefix: return [name for name in _HPARAMS if name.startswith(prefix)] return list(_HPARAMS)
(list_hparams(), starting_spaces=4))) hp = _HPARAMS[name]() if hp is None: raise TypeError("HParams %s is None. Make sure the registered function " "returns the HParams object." % name) return hp def list_hparams(prefix=None):
64
64
35
7
56
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
list_hparams
list_hparams
178
181
178
178
edb35608183e64ca60126bf96cc906590ce12aab
bigcode/the-stack
train
109713f5b858f0acd5397501
train
function
def register_attack_params(name=None): """Register an attack HParams set. Same behaviour as register_hparams.""" def decorator(ap_fn, registration_name=None): """Registers & returns ap_fn with registration_name or default name.""" ap_name = registration_name or default_name(ap_fn) if ap_name in _ATTACK...
def register_attack_params(name=None):
"""Register an attack HParams set. Same behaviour as register_hparams.""" def decorator(ap_fn, registration_name=None): """Registers & returns ap_fn with registration_name or default name.""" ap_name = registration_name or default_name(ap_fn) if ap_name in _ATTACK_PARAMS and not tf.contrib.eager.in_eag...
returns a " "`cleverhans.attack.Attack` object." % name) return attack def list_attacks(prefix=None): if prefix: return [name for name in _ATTACKS if name.startswith(prefix)] return list(_ATTACKS) def register_attack_params(name=None):
64
64
163
7
57
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
register_attack_params
register_attack_params
319
335
319
319
4d42a3c654cd79c3d6ef2ea2e7f61d04d5cdc367
bigcode/the-stack
train
5497b51464c4eac6aaa77086
train
function
def list_problems(): return sorted(list(_PROBLEMS))
def list_problems():
return sorted(list(_PROBLEMS))
["%s not in the set of supported problems:" % base_name ] + all_problem_names error_msg = "\n * ".join(error_lines) raise LookupError(error_msg) return _PROBLEMS[base_name](was_reversed, was_copy) def list_problems():
64
64
14
5
59
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
list_problems
list_problems
275
276
275
275
74b21253a0e60a174282adb21a02bb3ac518cbd4
bigcode/the-stack
train
ca3281b933ac09ff69c8ca71
train
function
def register_attack(name=None): """Register an attack HParams set. Same behaviour as register_hparams.""" def decorator(attack_fn, registration_name=None): """Registers & returns attack_fn with registration_name or default name.""" attack_name = registration_name or default_name(attack_fn) if attack_na...
def register_attack(name=None):
"""Register an attack HParams set. Same behaviour as register_hparams.""" def decorator(attack_fn, registration_name=None): """Registers & returns attack_fn with registration_name or default name.""" attack_name = registration_name or default_name(attack_fn) if attack_name in _ATTACKS and not tf.contri...
] + all_problem_names error_msg = "\n * ".join(error_lines) raise LookupError(error_msg) return _PROBLEMS[base_name](was_reversed, was_copy) def list_problems(): return sorted(list(_PROBLEMS)) def register_attack(name=None):
64
64
164
6
58
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
register_attack
register_attack
279
295
279
279
73533cce37a7b9e6c42d17025f1174db06a083c6
bigcode/the-stack
train
b38aa926ea4e4e9bd3fb4026
train
function
def register_pruning_params(name=None): """Register an pruning HParams set. Same behaviour as register_hparams.""" def decorator(pp_fn, registration_name=None): """Registers & returns pp_fn with registration_name or default name.""" pp_name = registration_name or default_name(pp_fn) if pp_name in _PRUN...
def register_pruning_params(name=None):
"""Register an pruning HParams set. Same behaviour as register_hparams.""" def decorator(pp_fn, registration_name=None): """Registers & returns pp_fn with registration_name or default name.""" pp_name = registration_name or default_name(pp_fn) if pp_name in _PRUNING_PARAMS and not tf.contrib.eager.in_e...
Make sure the registered " "function returns the HParams object." % name) return ap def list_attack_params(prefix=None): if prefix: return [name for name in _ATTACK_PARAMS if name.startswith(prefix)] return list(_ATTACK_PARAMS) def register_pruning_params(name=None):
64
64
167
8
56
jinliangwei/tensor2tensor
tensor2tensor/utils/registry.py
Python
register_pruning_params
register_pruning_params
358
374
358
358
2d423a83f20a48287a000953492bd49765a8f6d1
bigcode/the-stack
train
c083f7ec758bab48c3d677dd
train
class
@keras_export('keras.layers.UpSampling2D') class UpSampling2D(Layer): """Upsampling layer for 2D inputs. Repeats the rows and columns of the data by `size[0]` and `size[1]` respectively. Examples: >>> input_shape = (2, 2, 1, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) ...
@keras_export('keras.layers.UpSampling2D') class UpSampling2D(Layer):
"""Upsampling layer for 2D inputs. Repeats the rows and columns of the data by `size[0]` and `size[1]` respectively. Examples: >>> input_shape = (2, 2, 1, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) [[[[ 0 1 2]] [[ 3 4 5]]] [[[ 6 7 8]] [[ 9 10 11]]]] ...
. Upsampling factor. Input shape: 3D tensor with shape: `(batch_size, steps, features)`. Output shape: 3D tensor with shape: `(batch_size, upsampled_steps, features)`. """ def __init__(self, size=2, **kwargs): super(UpSampling1D, self).__init__(**kwargs) self.size = int(size) self.input_s...
255
256
1,003
19
236
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
UpSampling2D
UpSampling2D
2,550
2,651
2,550
2,551
288674a4100ac8d7ea76333b72eb0546f3616539
bigcode/the-stack
train
2a43ea3fc61cf520b93dd256
train
class
@keras_export('keras.layers.Cropping1D') class Cropping1D(Layer): """Cropping layer for 1D input (e.g. temporal sequence). It crops along the time dimension (axis 1). Examples: >>> input_shape = (2, 3, 2) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) [[[ 0 1] [ 2 3] ...
@keras_export('keras.layers.Cropping1D') class Cropping1D(Layer):
"""Cropping layer for 1D input (e.g. temporal sequence). It crops along the time dimension (axis 1). Examples: >>> input_shape = (2, 3, 2) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) [[[ 0 1] [ 2 3] [ 4 5]] [[ 6 7] [ 8 9] [10 11]]] >>> y = tf.kera...
3 = input_shape[3] + self.padding[2][0] + self.padding[2][1] else: dim3 = None return tensor_shape.TensorShape( [input_shape[0], dim1, dim2, dim3, input_shape[4]]) def call(self, inputs): return backend.spatial_3d_padding( inputs, padding=self.padding, data_format=self.data_...
162
163
545
20
142
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Cropping1D
Cropping1D
3,052
3,110
3,052
3,053
f50db505bc46244d224bbed1ec5af3eb271e0ab2
bigcode/the-stack
train
b73b3218081953242316f82d
train
class
@keras_export('keras.layers.Conv3DTranspose', 'keras.layers.Convolution3DTranspose') class Conv3DTranspose(Conv3D): """Transposed convolution layer (sometimes called Deconvolution). The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite d...
@keras_export('keras.layers.Conv3DTranspose', 'keras.layers.Convolution3DTranspose') class Conv3DTranspose(Conv3D):
"""Transposed convolution layer (sometimes called Deconvolution). The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite direction of a normal convolution, i.e., from something that has the shape of the output of some convolution to something that ...
3, 1, 2 kernel_h, kernel_w = self.kernel_size stride_h, stride_w = self.strides if self.output_padding is None: out_pad_h = out_pad_w = None else: out_pad_h, out_pad_w = self.output_padding output_shape[c_axis] = self.filters output_shape[h_axis] = conv_utils.deconv_output_length...
256
256
2,813
31
224
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Conv3DTranspose
Conv3DTranspose
1,384
1,694
1,384
1,386
934fcc968c259bb67bb3862bfedd8234780e713f
bigcode/the-stack
train
800f64e7f9fc53890177c2e0
train
class
@keras_export('keras.layers.ZeroPadding1D') class ZeroPadding1D(Layer): """Zero-padding layer for 1D input (e.g. temporal sequence). Examples: >>> input_shape = (2, 2, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) [[[ 0 1 2] [ 3 4 5]] [[ 6 7 8] [ 9 10 11]]] ...
@keras_export('keras.layers.ZeroPadding1D') class ZeroPadding1D(Layer):
"""Zero-padding layer for 1D input (e.g. temporal sequence). Examples: >>> input_shape = (2, 2, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) [[[ 0 1 2] [ 3 4 5]] [[ 6 7 8] [ 9 10 11]]] >>> y = tf.keras.layers.ZeroPadding1D(padding=2)(x) >>> print(y) t...
2] if input_shape[2] is not None else None dim3 = self.size[2] * input_shape[ 3] if input_shape[3] is not None else None return tensor_shape.TensorShape( [input_shape[0], dim1, dim2, dim3, input_shape[4]]) def call(self, inputs): return backend.resize_volumes( in...
180
181
606
19
161
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
ZeroPadding1D
ZeroPadding1D
2,735
2,798
2,735
2,736
6281996e3d0db1236c10eb2daa445f94a3601f63
bigcode/the-stack
train
9f4fcf92d09141e925ad6b16
train
class
@keras_export('keras.layers.UpSampling1D') class UpSampling1D(Layer): """Upsampling layer for 1D inputs. Repeats each temporal step `size` times along the time axis. Examples: >>> input_shape = (2, 2, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) [[[ 0 1 2] [ 3 4 ...
@keras_export('keras.layers.UpSampling1D') class UpSampling1D(Layer):
"""Upsampling layer for 1D inputs. Repeats each temporal step `size` times along the time axis. Examples: >>> input_shape = (2, 2, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) [[[ 0 1 2] [ 3 4 5]] [[ 6 7 8] [ 9 10 11]]] >>> y = tf.keras.layers.UpSampli...
0], rows, cols, out_filters) def get_config(self): config = super(DepthwiseConv2D, self).get_config() config.pop('filters') config.pop('kernel_initializer') config.pop('kernel_regularizer') config.pop('kernel_constraint') config['depth_multiplier'] = self.depth_multiplier config['depthwis...
148
148
494
19
128
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
UpSampling1D
UpSampling1D
2,493
2,547
2,493
2,494
0f277ef50249e36f1fcf952189138e3361f8aaf7
bigcode/the-stack
train
8d5e83b638e002f14612eb79
train
class
@keras_export('keras.layers.Conv3D', 'keras.layers.Convolution3D') class Conv3D(Conv): """3D convolution layer (e.g. spatial convolution over volumes). This layer creates a convolution kernel that is convolved with the layer input to produce a tensor of outputs. If `use_bias` is True, a bias vector is create...
@keras_export('keras.layers.Conv3D', 'keras.layers.Convolution3D') class Conv3D(Conv):
"""3D convolution layer (e.g. spatial convolution over volumes). This layer creates a convolution kernel that is convolved with the layer input to produce a tensor of outputs. If `use_bias` is True, a bias vector is created and added to the outputs. Finally, if `activation` is not `None`, it is applied to ...
='valid', data_format=None, dilation_rate=(1, 1), groups=1, activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, bias_...
256
256
1,662
25
231
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Conv3D
Conv3D
687
831
687
688
874c379e69f1e08597a6035772aadeb272b4c181
bigcode/the-stack
train
de4a081857be567b7a50f29b
train
class
@keras_export('keras.layers.Conv2D', 'keras.layers.Convolution2D') class Conv2D(Conv): """2D convolution layer (e.g. spatial convolution over images). This layer creates a convolution kernel that is convolved with the layer input to produce a tensor of outputs. If `use_bias` is True, a bias vector is created...
@keras_export('keras.layers.Conv2D', 'keras.layers.Convolution2D') class Conv2D(Conv):
"""2D convolution layer (e.g. spatial convolution over images). This layer creates a convolution kernel that is convolved with the layer input to produce a tensor of outputs. If `use_bias` is True, a bias vector is created and added to the outputs. Finally, if `activation` is not `None`, it is applied to t...
padding='valid', data_format='channels_last', dilation_rate=1, groups=1, activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, ...
256
256
1,759
25
231
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Conv2D
Conv2D
527
684
527
528
bf4c81b7b36e9dcb668ec24a7cc7308fc6121b54
bigcode/the-stack
train
14e0ec22ac657fddef30438c
train
class
@keras_export('keras.layers.Conv2DTranspose', 'keras.layers.Convolution2DTranspose') class Conv2DTranspose(Conv2D): """Transposed convolution layer (sometimes called Deconvolution). The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite d...
@keras_export('keras.layers.Conv2DTranspose', 'keras.layers.Convolution2DTranspose') class Conv2DTranspose(Conv2D):
"""Transposed convolution layer (sometimes called Deconvolution). The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite direction of a normal convolution, i.e., from something that has the shape of the output of some convolution to something that ...
self.activation is not None: return self.activation(outputs) return outputs def compute_output_shape(self, input_shape): input_shape = tensor_shape.TensorShape(input_shape).as_list() output_shape = list(input_shape) if self.data_format == 'channels_first': c_axis, t_axis = 1, 2 else:...
256
256
2,688
31
224
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Conv2DTranspose
Conv2DTranspose
1,081
1,381
1,081
1,083
18359a6a184739c3dbffebd233a2159682f91503
bigcode/the-stack
train
3b0c458f89f43cd87d3f3ab4
train
class
@keras_export('keras.layers.UpSampling3D') class UpSampling3D(Layer): """Upsampling layer for 3D inputs. Repeats the 1st, 2nd and 3rd dimensions of the data by `size[0]`, `size[1]` and `size[2]` respectively. Examples: >>> input_shape = (2, 1, 2, 1, 3) >>> x = tf.constant(1, shape=input_shape) >>> y = ...
@keras_export('keras.layers.UpSampling3D') class UpSampling3D(Layer):
"""Upsampling layer for 3D inputs. Repeats the 1st, 2nd and 3rd dimensions of the data by `size[0]`, `size[1]` and `size[2]` respectively. Examples: >>> input_shape = (2, 1, 2, 1, 3) >>> x = tf.constant(1, shape=input_shape) >>> y = tf.keras.layers.UpSampling3D(size=2)(x) >>> print(y.shape) (2, 2, ...
width = self.size[1] * input_shape[ 3] if input_shape[3] is not None else None return tensor_shape.TensorShape( [input_shape[0], input_shape[1], height, width]) else: height = self.size[0] * input_shape[ 1] if input_shape[1] is not None else None width = self.s...
255
256
913
19
236
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
UpSampling3D
UpSampling3D
2,654
2,732
2,654
2,655
2acc80e9a5ac93761578e639fad9ed83163c3564
bigcode/the-stack
train
b772b151cfb29b38c29dd7c2
train
class
@keras_export('keras.layers.Cropping2D') class Cropping2D(Layer): """Cropping layer for 2D input (e.g. picture). It crops along spatial dimensions, i.e. height and width. Examples: >>> input_shape = (2, 28, 28, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> y = tf.keras.layers.Croppi...
@keras_export('keras.layers.Cropping2D') class Cropping2D(Layer):
"""Cropping layer for 2D input (e.g. picture). It crops along spatial dimensions, i.e. height and width. Examples: >>> input_shape = (2, 28, 28, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> y = tf.keras.layers.Cropping2D(cropping=((2, 2), (4, 4)))(x) >>> print(y.shape) (2, 24, ...
ropping1D, self).__init__(**kwargs) self.cropping = conv_utils.normalize_tuple(cropping, 2, 'cropping') self.input_spec = InputSpec(ndim=3) def compute_output_shape(self, input_shape): input_shape = tensor_shape.TensorShape(input_shape).as_list() if input_shape[1] is not None: length = input_sh...
255
256
1,542
20
235
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Cropping2D
Cropping2D
3,113
3,237
3,113
3,114
9cfc1b970e969ae1d864a7af1031fbef994ef672
bigcode/the-stack
train
69fe55ea3ee821090de31fa1
train
class
@keras_export('keras.layers.SeparableConv2D', 'keras.layers.SeparableConvolution2D') class SeparableConv2D(SeparableConv): """Depthwise separable 2D convolution. Separable convolutions consist of first performing a depthwise spatial convolution (which acts on each input channel separately) foll...
@keras_export('keras.layers.SeparableConv2D', 'keras.layers.SeparableConvolution2D') class SeparableConv2D(SeparableConv):
"""Depthwise separable 2D convolution. Separable convolutions consist of first performing a depthwise spatial convolution (which acts on each input channel separately) followed by a pointwise convolution which mixes the resulting output channels. The `depth_multiplier` argument controls how many output c...
separable_conv1d op is available. inputs = array_ops.expand_dims(inputs, spatial_start_dim) depthwise_kernel = array_ops.expand_dims(self.depthwise_kernel, 0) pointwise_kernel = array_ops.expand_dims(self.pointwise_kernel, 0) dilation_rate = (1,) + self.dilation_rate if self.padding == 'causal': ...
256
256
1,615
34
221
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
SeparableConv2D
SeparableConv2D
2,089
2,259
2,089
2,091
782b62c21f50aa64b419e764709ed98097e33df2
bigcode/the-stack
train
5799ccc37597fd05c6696f20
train
class
class Conv(Layer): """Abstract N-D convolution layer (private, used as implementation base). This layer creates a convolution kernel that is convolved (actually cross-correlated) with the layer input to produce a tensor of outputs. If `use_bias` is True (and a `bias_initializer` is provided), a bias vector i...
class Conv(Layer):
"""Abstract N-D convolution layer (private, used as implementation base). This layer creates a convolution kernel that is convolved (actually cross-correlated) with the layer input to produce a tensor of outputs. If `use_bias` is True (and a `bias_initializer` is provided), a bias vector is created and added...
__future__ import print_function import functools import six from tensorflow.python.eager import context from tensorflow.python.framework import tensor_shape from tensorflow.python.keras import activations from tensorflow.python.keras import backend from tensorflow.python.keras import constraints from tensorflow.pyt...
256
256
2,909
5
250
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Conv
Conv
52
383
52
52
bd87083c78ebc0621ca84d537a0af4edde1d35d6
bigcode/the-stack
train
66ffef0ec17c90b5c5016a9c
train
class
@keras_export('keras.layers.Cropping3D') class Cropping3D(Layer): """Cropping layer for 3D data (e.g. spatial or spatio-temporal). Examples: >>> input_shape = (2, 28, 28, 10, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> y = tf.keras.layers.Cropping3D(cropping=(2, 4, 2))(x) >>> pri...
@keras_export('keras.layers.Cropping3D') class Cropping3D(Layer):
"""Cropping layer for 3D data (e.g. spatial or spatio-temporal). Examples: >>> input_shape = (2, 28, 28, 10, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> y = tf.keras.layers.Cropping3D(cropping=(2, 4, 2))(x) >>> print(y.shape) (2, 24, 20, 6, 3) Args: cropping: Int, or tup...
ropping[1][0]:, :] elif self.cropping[0][1] == 0: return inputs[:, self.cropping[0][0]:, self.cropping[1][0]: -self.cropping[1][1], :] elif self.cropping[1][1] == 0: return inputs[:, self.cropping[0][0]:-self.cropping[0][1], self.cropping[1][0]:, :...
255
256
2,626
20
235
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Cropping3D
Cropping3D
3,240
3,419
3,240
3,241
bb49c4805c8d92f16abd0ee30dd8724665ee69f7
bigcode/the-stack
train
88ca535af022e2bece90d0ab
train
class
class SeparableConv(Conv): """Abstract base layer for separable nD convolution. This layer performs a depthwise convolution that acts separately on channels, followed by a pointwise convolution that mixes channels. If `use_bias` is True and a bias initializer is provided, it adds a bias vector to the output....
class SeparableConv(Conv):
"""Abstract base layer for separable nD convolution. This layer performs a depthwise convolution that acts separately on channels, followed by a pointwise convolution that mixes channels. If `use_bias` is True and a bias initializer is provided, it adds a bias vector to the output. It then optionally appli...
stride_d, stride_h, stride_w = self.strides if self.output_padding is None: out_pad_d = out_pad_h = out_pad_w = None else: out_pad_d, out_pad_h, out_pad_w = self.output_padding output_shape[c_axis] = self.filters output_shape[d_axis] = conv_utils.deconv_output_length( output_sh...
256
256
1,837
7
248
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
SeparableConv
SeparableConv
1,697
1,905
1,697
1,697
c225897d2c917923fb3ac5c0f038a694c462ee51
bigcode/the-stack
train
f56853027ce6d739ac7291f0
train
class
@keras_export('keras.layers.DepthwiseConv2D') class DepthwiseConv2D(Conv2D): """Depthwise 2D convolution. Depthwise convolution is a type of convolution in which a single convolutional filter is apply to each input channel (i.e. in a depthwise way). You can understand depthwise convolution as being the first...
@keras_export('keras.layers.DepthwiseConv2D') class DepthwiseConv2D(Conv2D):
"""Depthwise 2D convolution. Depthwise convolution is a type of convolution in which a single convolutional filter is apply to each input channel (i.e. in a depthwise way). You can understand depthwise convolution as being the first step in a depthwise separable convolution. It is implemented via the foll...
izer), bias_regularizer=regularizers.get(bias_regularizer), activity_regularizer=regularizers.get(activity_regularizer), depthwise_constraint=constraints.get(depthwise_constraint), pointwise_constraint=constraints.get(pointwise_constraint), bias_constraint=constraints.get(bias_co...
256
256
2,025
23
232
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
DepthwiseConv2D
DepthwiseConv2D
2,262
2,490
2,262
2,263
5536bdfb4d1a40c92870b044ffcf2a85cc87e41f
bigcode/the-stack
train
8d8f9087e12c6edbd70b60aa
train
class
@keras_export('keras.layers.SeparableConv1D', 'keras.layers.SeparableConvolution1D') class SeparableConv1D(SeparableConv): """Depthwise separable 1D convolution. This layer performs a depthwise convolution that acts separately on channels, followed by a pointwise convolution that mixes channels. ...
@keras_export('keras.layers.SeparableConv1D', 'keras.layers.SeparableConvolution1D') class SeparableConv1D(SeparableConv):
"""Depthwise separable 1D convolution. This layer performs a depthwise convolution that acts separately on channels, followed by a pointwise convolution that mixes channels. If `use_bias` is True and a bias initializer is provided, it adds a bias vector to the output. It then optionally applies an activati...
, 'depth_multiplier': self.depth_multiplier, 'dilation_rate': self.dilation_rate, 'activation': activations.serialize(self.activation), 'use_bias': self.use_bias, 'depthwise_initializer': initializers.serialize(self.dept...
255
256
1,752
34
221
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
SeparableConv1D
SeparableConv1D
1,908
2,086
1,908
1,910
89a6eebb6772168e31c44a07a116314e2c6f331d
bigcode/the-stack
train
c7a012c31071a96109dea407
train
class
@keras_export('keras.layers.ZeroPadding3D') class ZeroPadding3D(Layer): """Zero-padding layer for 3D data (spatial or spatio-temporal). Examples: >>> input_shape = (1, 1, 2, 2, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> y = tf.keras.layers.ZeroPadding3D(padding=2)(x) >>> print(y.s...
@keras_export('keras.layers.ZeroPadding3D') class ZeroPadding3D(Layer):
"""Zero-padding layer for 3D data (spatial or spatio-temporal). Examples: >>> input_shape = (1, 1, 2, 2, 3) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> y = tf.keras.layers.ZeroPadding3D(padding=2)(x) >>> print(y.shape) (1, 5, 6, 6, 3) Args: padding: Int, or tuple of 3 ints, o...
1][1] else: cols = None return tensor_shape.TensorShape( [input_shape[0], input_shape[1], rows, cols]) elif self.data_format == 'channels_last': if input_shape[1] is not None: rows = input_shape[1] + self.padding[0][0] + self.padding[0][1] else: rows = None ...
255
256
1,360
19
236
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
ZeroPadding3D
ZeroPadding3D
2,926
3,049
2,926
2,927
723b91c84d06a96f3e3e409c2cdd4b9fab76f0c6
bigcode/the-stack
train
b35c6ce3557576b6038b05fb
train
class
@keras_export('keras.layers.Conv1DTranspose', 'keras.layers.Convolution1DTranspose') class Conv1DTranspose(Conv1D): """Transposed convolution layer (sometimes called Deconvolution). The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite d...
@keras_export('keras.layers.Conv1DTranspose', 'keras.layers.Convolution1DTranspose') class Conv1DTranspose(Conv1D):
"""Transposed convolution layer (sometimes called Deconvolution). The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite direction of a normal convolution, i.e., from something that has the shape of the output of some convolution to something that ...
dilation_rate=(1, 1, 1), groups=1, activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', kernel_regularizer=None, bias_regularizer=None, activity_regularizer=...
256
256
2,095
31
225
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Conv1DTranspose
Conv1DTranspose
834
1,078
834
836
3d3e7214f5820b106a7072780af287d7d51ea8cc
bigcode/the-stack
train
3f099f207ea235784049d030
train
class
@keras_export('keras.layers.Conv1D', 'keras.layers.Convolution1D') class Conv1D(Conv): """1D convolution layer (e.g. temporal convolution). This layer creates a convolution kernel that is convolved with the layer input over a single spatial (or temporal) dimension to produce a tensor of outputs. If `use_bias...
@keras_export('keras.layers.Conv1D', 'keras.layers.Convolution1D') class Conv1D(Conv):
"""1D convolution layer (e.g. temporal convolution). This layer creates a convolution kernel that is convolved with the layer input over a single spatial (or temporal) dimension to produce a tensor of outputs. If `use_bias` is True, a bias vector is created and added to the outputs. Finally, if `activation...
if self.data_format == 'channels_last': causal_padding = [[0, 0]] * batch_rank + [[left_pad, 0], [0, 0]] else: causal_padding = [[0, 0]] * batch_rank + [[0, 0], [left_pad, 0]] return causal_padding def _get_channel_axis(self): if self.data_format == 'channels_first': return -1 - se...
256
256
1,402
25
230
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
Conv1D
Conv1D
386
524
386
387
dffae2dae12f8cd9f4bf7d56c94a9fdf5f1be0cf
bigcode/the-stack
train
bc5154d97e80e59ef9f8df59
train
class
@keras_export('keras.layers.ZeroPadding2D') class ZeroPadding2D(Layer): """Zero-padding layer for 2D input (e.g. picture). This layer can add rows and columns of zeros at the top, bottom, left and right side of an image tensor. Examples: >>> input_shape = (1, 1, 2, 2) >>> x = np.arange(np.prod(input_shap...
@keras_export('keras.layers.ZeroPadding2D') class ZeroPadding2D(Layer):
"""Zero-padding layer for 2D input (e.g. picture). This layer can add rows and columns of zeros at the top, bottom, left and right side of an image tensor. Examples: >>> input_shape = (1, 1, 2, 2) >>> x = np.arange(np.prod(input_shape)).reshape(input_shape) >>> print(x) [[[[0 1] [2 3]]]] >>> y...
_pad)`). Input shape: 3D tensor with shape `(batch_size, axis_to_pad, features)` Output shape: 3D tensor with shape `(batch_size, padded_axis, features)` """ def __init__(self, padding=1, **kwargs): super(ZeroPadding1D, self).__init__(**kwargs) self.padding = conv_utils.normalize_tuple(pa...
255
256
1,207
19
236
AdamHillier/tensorflow
tensorflow/python/keras/layers/convolutional.py
Python
ZeroPadding2D
ZeroPadding2D
2,801
2,923
2,801
2,802
0eff580fcb3fbe631ed86ed35ee04f3d250c310e
bigcode/the-stack
train
1d08ffc1c2b4536237d2688c
train
function
@cli.command('update') @click.argument('requirements', type=click.File(mode='r')) def update_requirements(requirements): """Apply version restrictions from REQUIREMENTS. The REQUIREMENTS file should contain the output of `pip freeze`. """ setup = get_setup_json() package_versions = [] for req...
@cli.command('update') @click.argument('requirements', type=click.File(mode='r')) def update_requirements(requirements):
"""Apply version restrictions from REQUIREMENTS. The REQUIREMENTS file should contain the output of `pip freeze`. """ setup = get_setup_json() package_versions = [] for requirement in requirements.readlines(): try: package, version = requirement.strip().split('==') ...
requirement or '==' not in requirement: clone['extras_require'][extra].append(requirement) else: package = requirement.split('==')[0] clone['extras_require'][extra].append(package) write_setup_json(clone) @cli.command('update') @click.argument('requireme...
77
77
259
26
51
lekah/aiida_core
utils/update_dependencies.py
Python
update_requirements
update_requirements
102
145
102
104
11b2095b2ee1fc2f49011f638144135ba2aa08b4
bigcode/the-stack
train
ab2e4daec5ef3eaa9bc03cc9
train
function
@click.group() def cli(): """Utility to update dependency requirements for `aiida-core`. Since `aiida-core` fixes the versions of almost all of its dependencies, once in a while these need to be updated. This is a manual process, but this CLI attempts to simplify it somewhat. The idea is to remote all expl...
@click.group() def cli():
"""Utility to update dependency requirements for `aiida-core`. Since `aiida-core` fixes the versions of almost all of its dependencies, once in a while these need to be updated. This is a manual process, but this CLI attempts to simplify it somewhat. The idea is to remote all explicit version restricti...
import print_function from __future__ import absolute_import import copy import os import click from validate_consistency import get_setup_json, write_setup_json FILENAME_SETUP_JSON = 'setup.json' SCRIPT_PATH = os.path.split(os.path.realpath(__file__))[0] ROOT_DIR = os.path.join(SCRIPT_PATH, os.pardir) FILEPATH_SET...
128
128
429
6
122
lekah/aiida_core
utils/update_dependencies.py
Python
cli
cli
29
61
29
30
eaeb9113bbead69ba32122b037e299359dac44cc
bigcode/the-stack
train
6b3c71db03755ec99c4c402e
train
function
@cli.command('unrestrict') @click.option('--exclude', multiple=True, help='List of package names to exclude from updating.') def unrestrict_requirements(exclude): """Remove all explicit dependency version restrictions from `setup.json`. Warning, this currently only works for dependency requirements that use th...
@cli.command('unrestrict') @click.option('--exclude', multiple=True, help='List of package names to exclude from updating.') def unrestrict_requirements(exclude):
"""Remove all explicit dependency version restrictions from `setup.json`. Warning, this currently only works for dependency requirements that use the `==` operator. Statements with different operators, additional filters after a semicolon, or with extra requirements (using `[]`) are not supported. The ...
entire procedure. Now execute the command: python update_dependencies.py update requirements.txt This will now update the `setup.json` to reinstate the exact version requirements for all dependencies. Commit the changes to `setup.json` and make a pull request. """ @cli.command('unrestrict') @clic...
90
91
306
34
56
lekah/aiida_core
utils/update_dependencies.py
Python
unrestrict_requirements
unrestrict_requirements
64
99
64
66
14e74e0c2257a2051962f156119573887616445e
bigcode/the-stack
train
e8f16f0b385d6277735cd719
train
class
class App(object): def __init__(self, ): pass _instance = None def __new__(cls,*a,**k): if not cls._instance: cls._instance = object.__new__(cls,*a,**k) return cls._instance
class App(object):
def __init__(self, ): pass _instance = None def __new__(cls,*a,**k): if not cls._instance: cls._instance = object.__new__(cls,*a,**k) return cls._instance
class App(object):
4
64
62
4
0
jinbaoqi/python-notes
singleton/singleton-2.py
Python
App
App
1
9
1
1
cb07b5794a9a4f1835032b104a9e6da459e9668d
bigcode/the-stack
train
b2316a4e26888b6b60d159a0
train
function
def idx_to_token(token, reversed_vocab): return reversed_vocab.get(token, "none")
def idx_to_token(token, reversed_vocab):
return reversed_vocab.get(token, "none")
g, vocab): return [vocab[str(t)] for t in prog] + [EOS_ID] def reverse_vocab(vocab): reversed_vocab = {} for token, idx in vocab.items(): reversed_vocab[idx] = token return reversed_vocab def idx_to_token(token, reversed_vocab):
64
64
19
9
54
hisazumi/ann-for-mts
src/data_utils.py
Python
idx_to_token
idx_to_token
167
168
167
167
2fabd2b58e579c0fcb1442156720b05658bd194f
bigcode/the-stack
train
a5674882d4a70fc96faab7bb
train
function
def raw_program_to_token_ids(prog, vocab): return [vocab[str(t)] for t in prog] + [EOS_ID]
def raw_program_to_token_ids(prog, vocab):
return [vocab[str(t)] for t in prog] + [EOS_ID]
if len(tree['children']) > 0: for sub_tree in tree['children']: child = serialize_tree_with_vocabulary_aux(sub_tree, reversed_vocabulary) current = current + child # current.append(")") return current def raw_program_to_token_ids(prog, vocab):
64
64
29
11
52
hisazumi/ann-for-mts
src/data_utils.py
Python
raw_program_to_token_ids
raw_program_to_token_ids
158
159
158
158
392713b3cea7868da1e4ac2c918895c1940a2719
bigcode/the-stack
train
edd7e45736bd76808bcf0d95
train
function
def serialize_seq_with_vocabulary(seq, vocabulary): reversed_vocabulary = reverse_vocab(vocabulary) new_seq = [] for elem in seq: if (elem != LEFT_BRACKET_ID and elem != RIGHT_BRACKET_ID): new_seq.append(idx_to_token(elem, reversed_vocabulary)) return new_seq
def serialize_seq_with_vocabulary(seq, vocabulary):
reversed_vocabulary = reverse_vocab(vocabulary) new_seq = [] for elem in seq: if (elem != LEFT_BRACKET_ID and elem != RIGHT_BRACKET_ID): new_seq.append(idx_to_token(elem, reversed_vocabulary)) return new_seq
current.append(tree['root']) if len(tree['children']) > 0: for sub_tree in tree['children']: child = serialize_tree(sub_tree) current = current + child current.append(RIGHT_BRACKET_ID) return current def serialize_seq_with_vocabulary(seq, vocabulary):
64
64
66
10
53
hisazumi/ann-for-mts
src/data_utils.py
Python
serialize_seq_with_vocabulary
serialize_seq_with_vocabulary
135
141
135
135
6cc47ae328644e52c1859fa8a4d8f8bb29b463f9
bigcode/the-stack
train
cc168340edac995dd40fe97c
train
function
def reverse_vocab(vocab): reversed_vocab = {} for token, idx in vocab.items(): reversed_vocab[idx] = token return reversed_vocab
def reverse_vocab(vocab):
reversed_vocab = {} for token, idx in vocab.items(): reversed_vocab[idx] = token return reversed_vocab
_tree_with_vocabulary_aux(sub_tree, reversed_vocabulary) current = current + child # current.append(")") return current def raw_program_to_token_ids(prog, vocab): return [vocab[str(t)] for t in prog] + [EOS_ID] def reverse_vocab(vocab):
64
64
33
6
58
hisazumi/ann-for-mts
src/data_utils.py
Python
reverse_vocab
reverse_vocab
161
165
161
161
989e5e4c263bdda009451354f82aa799ed88040d
bigcode/the-stack
train
f810c777f4a6c718167b2ce1
train
function
def prepare_data(init_data, source_vocab, target_vocab, input_format, output_format, source_serialize, target_serialize): data = [] for prog in init_data: if input_format == 'seq': source_prog = prog['source_prog'] else: source_prog = prog['source_ast'] if output_format == 'seq': targe...
def prepare_data(init_data, source_vocab, target_vocab, input_format, output_format, source_serialize, target_serialize):
data = [] for prog in init_data: if input_format == 'seq': source_prog = prog['source_prog'] else: source_prog = prog['source_ast'] if output_format == 'seq': target_prog = prog['target_prog'] else: target_prog = prog['target_ast'] if input_format == 'seq': source_p...
_vocab = {} for token, idx in vocab.items(): reversed_vocab[idx] = token return reversed_vocab def idx_to_token(token, reversed_vocab): return reversed_vocab.get(token, "none") def prepare_data(init_data, source_vocab, target_vocab, input_format, output_format, source_serialize, target_serialize):
70
70
235
26
44
hisazumi/ann-for-mts
src/data_utils.py
Python
prepare_data
prepare_data
170
193
170
170
6de9233fac2105783e1c8dfe0aeafb4db35006f8
bigcode/the-stack
train
b51b3cc67417a21146893638
train
function
def serialize_tree_with_vocabulary(tree, vocabulary): reversed_vocabulary = reverse_vocab(vocabulary) return serialize_tree_with_vocabulary_aux(tree, reversed_vocabulary)
def serialize_tree_with_vocabulary(tree, vocabulary):
reversed_vocabulary = reverse_vocab(vocabulary) return serialize_tree_with_vocabulary_aux(tree, reversed_vocabulary)
_vocabulary = reverse_vocab(vocabulary) new_seq = [] for elem in seq: if (elem != LEFT_BRACKET_ID and elem != RIGHT_BRACKET_ID): new_seq.append(idx_to_token(elem, reversed_vocabulary)) return new_seq def serialize_tree_with_vocabulary(tree, vocabulary):
64
64
34
10
53
hisazumi/ann-for-mts
src/data_utils.py
Python
serialize_tree_with_vocabulary
serialize_tree_with_vocabulary
143
145
143
143
86c8bfa79c5fee3b17ffb6368a7a6ef6afa05bfb
bigcode/the-stack
train
8717a04ef668b6b102431b41
train
function
def get_max_num_children(tree): max_num_children = len(tree['children']) for child in tree['children']: t = get_max_num_children(child) max_num_children = max(t, max_num_children) return max_num_children
def get_max_num_children(tree):
max_num_children = len(tree['children']) for child in tree['children']: t = get_max_num_children(child) max_num_children = max(t, max_num_children) return max_num_children
vocab.append(tok) for sub_tree in code["children"]: vocab = add_tokens_from_code(sub_tree, vocab, format) else: for tok in code: if not (str(tok) in vocab): vocab.append(str(tok)) return vocab def get_max_num_children(tree):
64
64
52
7
56
hisazumi/ann-for-mts
src/data_utils.py
Python
get_max_num_children
get_max_num_children
44
49
44
44
7401a6abd62ae4fbfdc86f147fac1014334e36de
bigcode/the-stack
train
1273aca6e8970cbacb948c3e
train
function
def serialize_tree_with_vocabulary_aux(tree, reversed_vocabulary): current = [] # current.append("(") current.append(idx_to_token(tree['root'], reversed_vocabulary)) if len(tree['children']) > 0: for sub_tree in tree['children']: child = serialize_tree_with_vocabulary_aux(sub_tree, reversed_vocabulary...
def serialize_tree_with_vocabulary_aux(tree, reversed_vocabulary):
current = [] # current.append("(") current.append(idx_to_token(tree['root'], reversed_vocabulary)) if len(tree['children']) > 0: for sub_tree in tree['children']: child = serialize_tree_with_vocabulary_aux(sub_tree, reversed_vocabulary) current = current + child # current.append(")") return ...
new_seq.append(idx_to_token(elem, reversed_vocabulary)) return new_seq def serialize_tree_with_vocabulary(tree, vocabulary): reversed_vocabulary = reverse_vocab(vocabulary) return serialize_tree_with_vocabulary_aux(tree, reversed_vocabulary) def serialize_tree_with_vocabulary_aux(tree, reversed_vocabulary):
64
64
90
13
51
hisazumi/ann-for-mts
src/data_utils.py
Python
serialize_tree_with_vocabulary_aux
serialize_tree_with_vocabulary_aux
147
156
147
147
38e8f06cc10f9b4f7c22b3722c80c7bd118f1f4b
bigcode/the-stack
train
464ec445b6ba03bca3afb61b
train
function
def build_vocab(train_data, vocab_filename, input_format, output_format): if not vocab_filename: source_vocab_list = [] target_vocab_list = [] for prog in train_data: if input_format == 'seq': source_prog = prog['source_prog'] else: source_prog = prog['source_ast'] if ou...
def build_vocab(train_data, vocab_filename, input_format, output_format):
if not vocab_filename: source_vocab_list = [] target_vocab_list = [] for prog in train_data: if input_format == 'seq': source_prog = prog['source_prog'] else: source_prog = prog['source_ast'] if output_format == 'seq': target_prog = prog['target_prog'] else:...
0 max_len = 0 avg_len = 0 for tree in data: current_len = get_max_num_children(tree) avg_len = avg_len + current_len max_len = max(max_len, current_len) return min_len, max_len, avg_len * 1.0 / len(data) def build_vocab(train_data, vocab_filename, input_format, output_format):
87
87
293
15
72
hisazumi/ann-for-mts
src/data_utils.py
Python
build_vocab
build_vocab
71
103
71
72
9494b3c34cf9ddb159539cae2f1058a53d574d6c
bigcode/the-stack
train
935493d98db6d2b57b7ead35
train
function
def calStat(data, serialize): if serialize: min_len = 10000 max_len = 0 avg_len = 0 for seq in data: l = len(seq) min_len = min(min_len, l) max_len = max(max_len, l) avg_len += l return min_len, max_len, avg_len * 1.0 / len(data) min_len = 0 max_len = 0 avg_len = 0 ...
def calStat(data, serialize):
if serialize: min_len = 10000 max_len = 0 avg_len = 0 for seq in data: l = len(seq) min_len = min(min_len, l) max_len = max(max_len, l) avg_len += l return min_len, max_len, avg_len * 1.0 / len(data) min_len = 0 max_len = 0 avg_len = 0 for tree in data: current_...
)) return vocab def get_max_num_children(tree): max_num_children = len(tree['children']) for child in tree['children']: t = get_max_num_children(child) max_num_children = max(t, max_num_children) return max_num_children def calStat(data, serialize):
64
64
167
7
56
hisazumi/ann-for-mts
src/data_utils.py
Python
calStat
calStat
51
69
51
51
939d23bdae820a672f1b0d14c4b4da5cdf3ceadd
bigcode/the-stack
train
fe28692bbe020d77ebeec1ef
train
function
def serialize_tree(tree): current = [] current.append(LEFT_BRACKET_ID) current.append(tree['root']) if len(tree['children']) > 0: for sub_tree in tree['children']: child = serialize_tree(sub_tree) current = current + child current.append(RIGHT_BRACKET_ID) return current
def serialize_tree(tree):
current = [] current.append(LEFT_BRACKET_ID) current.append(tree['root']) if len(tree['children']) > 0: for sub_tree in tree['children']: child = serialize_tree(sub_tree) current = current + child current.append(RIGHT_BRACKET_ID) return current
: current = {} current['root'] = vocab.get(str(code['root']), UNK_ID) current['children'] = [] for sub_tree in code['children']: current['children'].append(ast_to_token_ids(sub_tree, vocab, serialize)) return current def serialize_tree(tree):
64
64
73
5
58
hisazumi/ann-for-mts
src/data_utils.py
Python
serialize_tree
serialize_tree
124
133
124
124
d53dd62d06bab0aa67ab224b37454b9161f2e9cd
bigcode/the-stack
train
01b86cb1e54f5f219c4dbe62
train
function
def add_tokens_from_code(code, vocab, format): if format == 'tree': tok = str(code["root"]) if not (tok in vocab): vocab.append(tok) for sub_tree in code["children"]: vocab = add_tokens_from_code(sub_tree, vocab, format) else: for tok in code: if not (str(tok) in vocab): vo...
def add_tokens_from_code(code, vocab, format):
if format == 'tree': tok = str(code["root"]) if not (tok in vocab): vocab.append(tok) for sub_tree in code["children"]: vocab = add_tokens_from_code(sub_tree, vocab, format) else: for tok in code: if not (str(tok) in vocab): vocab.append(str(tok)) return vocab
ACKET, _RIGHT_BRACKET] PAD_ID = 0 GO_ID = 1 EOS_ID = 2 UNK_ID = 3 NT_ID = 4 LEFT_BRACKET_ID = 5 RIGHT_BRACKET_ID = 6 def add_tokens_from_code(code, vocab, format):
64
64
91
11
52
hisazumi/ann-for-mts
src/data_utils.py
Python
add_tokens_from_code
add_tokens_from_code
31
42
31
31
42ef2c893c135bf917ddadc9da2f07fc3782d74f
bigcode/the-stack
train
49512af7751e70ecf815f0d1
train
function
def build_trees(init_dataset, target_serialize=False): data_set = [] for (source, target) in init_dataset: source_trees = TreeManager() source_trees.build_binary_tree_from_dict(source) if target_serialize: target_seq = target[:] data_set.append((source, target, source_trees, target_seq)) ...
def build_trees(init_dataset, target_serialize=False):
data_set = [] for (source, target) in init_dataset: source_trees = TreeManager() source_trees.build_binary_tree_from_dict(source) if target_serialize: target_seq = target[:] data_set.append((source, target, source_trees, target_seq)) else: target_trees = TreeManager() target_...
data.append((source_prog, target_prog)) if input_format == 'tree' and (not source_serialize): # print("Trees %s" % data) data = build_trees(data, target_serialize) return data def build_trees(init_dataset, target_serialize=False):
64
64
120
12
51
hisazumi/ann-for-mts
src/data_utils.py
Python
build_trees
build_trees
195
207
195
195
3207c7284e37dedab2a08e2d53d99a1f9ea586ef
bigcode/the-stack
train
57abe62f8ab29bc1a49dc509
train
function
def ast_to_token_ids(code, vocab, serialize): if serialize: current = [] current.append(vocab.get(str(code['root']), UNK_ID)) if len(code['children']) > 0: current.append(LEFT_BRACKET_ID) for sub_tree in code['children']: child = ast_to_token_ids(sub_tree, vocab, serialize) cur...
def ast_to_token_ids(code, vocab, serialize):
if serialize: current = [] current.append(vocab.get(str(code['root']), UNK_ID)) if len(code['children']) > 0: current.append(LEFT_BRACKET_ID) for sub_tree in code['children']: child = ast_to_token_ids(sub_tree, vocab, serialize) current = current + child current.append(RI...
in enumerate(source_vocab_list): source_vocab_dict[token] = idx for idx, token in enumerate(target_vocab_list): target_vocab_dict[token] = idx return source_vocab_dict, target_vocab_dict, source_vocab_list, target_vocab_list def ast_to_token_ids(code, vocab, serialize):
64
64
158
11
52
hisazumi/ann-for-mts
src/data_utils.py
Python
ast_to_token_ids
ast_to_token_ids
105
122
105
105
ae58f7fd44095b30ace3c285e58b0e37524fa62b
bigcode/the-stack
train
cff4d6ffc655daaf829170ba
train
function
def remote(expr): """Annotate a portion of a primaryjoin expression with a 'remote' annotation. See the section :ref:`relationship_custom_foreign` for a description of use. .. seealso:: :ref:`relationship_custom_foreign` :func:`.foreign` """ return _annotate_columns( ...
def remote(expr):
"""Annotate a portion of a primaryjoin expression with a 'remote' annotation. See the section :ref:`relationship_custom_foreign` for a description of use. .. seealso:: :ref:`relationship_custom_foreign` :func:`.foreign` """ return _annotate_columns( expression._c...
annotate from ..sql.util import _shallow_annotate from ..sql.util import adapt_criterion_to_null from ..sql.util import ClauseAdapter from ..sql.util import join_condition from ..sql.util import selectables_overlap from ..sql.util import visit_binary_product def remote(expr):
64
64
91
4
59
durossato/APS-5--Semestre
arquivos-projeto/APS_2020/venv/Lib/site-packages/sqlalchemy/orm/relationships.py
Python
remote
remote
51
67
51
51
59bd495675062524e59e02fe851bb3a829d61fba
bigcode/the-stack
train
f7f303e78f732d6deb6424ed
train
function
def _annotate_columns(element, annotations): def clone(elem): if isinstance(elem, expression.ColumnClause): elem = elem._annotate(annotations.copy()) elem._copy_internals(clone=clone) return elem if element is not None: element = clone(element) clone = None # re...
def _annotate_columns(element, annotations):
def clone(elem): if isinstance(elem, expression.ColumnClause): elem = elem._annotate(annotations.copy()) elem._copy_internals(clone=clone) return elem if element is not None: element = clone(element) clone = None # remove gc cycles return element
able = self.parent.local_table if dest_selectable is None: dest_selectable = self.entity.local_table return ( primaryjoin, secondaryjoin, source_selectable, dest_selectable, secondary, target_adapter, ) def _anno...
64
64
76
9
55
durossato/APS-5--Semestre
arquivos-projeto/APS_2020/venv/Lib/site-packages/sqlalchemy/orm/relationships.py
Python
_annotate_columns
_annotate_columns
2,359
2,369
2,359
2,359
da4d40847d744442d2143160916198087ec22eb3
bigcode/the-stack
train
b9c8c35f7114daa4ca622b59
train
function
def foreign(expr): """Annotate a portion of a primaryjoin expression with a 'foreign' annotation. See the section :ref:`relationship_custom_foreign` for a description of use. .. seealso:: :ref:`relationship_custom_foreign` :func:`.remote` """ return _annotate_columns( ...
def foreign(expr):
"""Annotate a portion of a primaryjoin expression with a 'foreign' annotation. See the section :ref:`relationship_custom_foreign` for a description of use. .. seealso:: :ref:`relationship_custom_foreign` :func:`.remote` """ return _annotate_columns( expression._...
relationship_custom_foreign` for a description of use. .. seealso:: :ref:`relationship_custom_foreign` :func:`.foreign` """ return _annotate_columns( expression._clause_element_as_expr(expr), {"remote": True} ) def foreign(expr):
64
64
91
4
60
durossato/APS-5--Semestre
arquivos-projeto/APS_2020/venv/Lib/site-packages/sqlalchemy/orm/relationships.py
Python
foreign
foreign
70
87
70
70
6903c2cd96f692f44996d2361d840f255ffc9777
bigcode/the-stack
train
ff9c33fe2975ac90ee8a391b
train
class
class _ColInAnnotations(object): """Seralizable equivalent to: lambda c: "name" in c._annotations """ def __init__(self, name): self.name = name def __call__(self, c): return self.name in c._annotations
class _ColInAnnotations(object):
"""Seralizable equivalent to: lambda c: "name" in c._annotations """ def __init__(self, name): self.name = name def __call__(self, c): return self.name in c._annotations
averse( secondaryjoin, {}, col_to_bind ) lazywhere = sql.and_(lazywhere, secondaryjoin) bind_to_col = {binds[col].key: col for col in binds} return lazywhere, bind_to_col, equated_columns class _ColInAnnotations(object):
64
64
62
7
56
durossato/APS-5--Semestre
arquivos-projeto/APS_2020/venv/Lib/site-packages/sqlalchemy/orm/relationships.py
Python
_ColInAnnotations
_ColInAnnotations
3,409
3,419
3,409
3,409
d7fd90ccca634bf0a1340e59683ac4b4ab5f58f4
bigcode/the-stack
train
07968cb8f1064638cff718c7
train
class
@log.class_logger @util.langhelpers.dependency_for("sqlalchemy.orm.properties", add_to_all=True) class RelationshipProperty(StrategizedProperty): """Describes an object property that holds a single item or list of items that correspond to a related database table. Public constructor is the :func:`.orm.rela...
@log.class_logger @util.langhelpers.dependency_for("sqlalchemy.orm.properties", add_to_all=True) class RelationshipProperty(StrategizedProperty):
"""Describes an object property that holds a single item or list of items that correspond to a related database table. Public constructor is the :func:`.orm.relationship` function. .. seealso:: :ref:`relationship_config_toplevel` """ strategy_wildcard_key = "relationship" _pers...
sql.util import adapt_criterion_to_null from ..sql.util import ClauseAdapter from ..sql.util import join_condition from ..sql.util import selectables_overlap from ..sql.util import visit_binary_product def remote(expr): """Annotate a portion of a primaryjoin expression with a 'remote' annotation. See the...
256
256
17,684
31
225
durossato/APS-5--Semestre
arquivos-projeto/APS_2020/venv/Lib/site-packages/sqlalchemy/orm/relationships.py
Python
RelationshipProperty
RelationshipProperty
90
2,356
90
92
32b3fa39f8fba69b3181b6c66a1bd7effc3dfc7b
bigcode/the-stack
train
78fafb1846bc250ae428adff
train
class
class JoinCondition(object): def __init__( self, parent_persist_selectable, child_persist_selectable, parent_local_selectable, child_local_selectable, primaryjoin=None, secondary=None, secondaryjoin=None, parent_equivalents=None, child_...
class JoinCondition(object):
def __init__( self, parent_persist_selectable, child_persist_selectable, parent_local_selectable, child_local_selectable, primaryjoin=None, secondary=None, secondaryjoin=None, parent_equivalents=None, child_equivalents=None, con...
criterion aliased = aliased or ( source_selectable is not None and ( source_selectable is not self.parent._with_polymorphic_selectable or source_selectable._is_from_container # e.g an alias ) ) ( pr...
256
256
7,457
5
250
durossato/APS-5--Semestre
arquivos-projeto/APS_2020/venv/Lib/site-packages/sqlalchemy/orm/relationships.py
Python
JoinCondition
JoinCondition
2,372
3,406
2,372
2,372
e62637c51f8e596f146fc1f8faba7b031d5bd20f
bigcode/the-stack
train
83beca67807f54d53fc2e139
train
function
def output_path(path=None): """ Get path inside the current test suite output dir. Placing files to this dir guarantees that files will be accessible after the test suite execution. :param path: path relative to the test suite output dir :return: absolute path inside the test suite output dir ""...
def output_path(path=None):
""" Get path inside the current test suite output dir. Placing files to this dir guarantees that files will be accessible after the test suite execution. :param path: path relative to the test suite output dir :return: absolute path inside the test suite output dir """ return _join_path(_get...
path: path relative to the arcadia_tests_data directory, e.g. yatest.common.data_path("pers/rerank_service") :return: absolute path inside arcadia_tests_data """ return _join_path(_get_ya_plugin_instance().data_root, path) def output_path(path=None):
64
64
84
6
58
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
output_path
output_path
94
101
94
94
7de793b53511f24757e3318ac08dd04841d87af5
bigcode/the-stack
train
61b2f700166e24ac46ff0724
train
function
def build_path(path=None): """ Get path inside build directory :param path: path relative to the build directory, e.g. yatest.common.build_path('devtools/ya/bin') :return: absolute path inside build directory """ return _join_path(_get_ya_plugin_instance().build_root, path)
def build_path(path=None):
""" Get path inside build directory :param path: path relative to the build directory, e.g. yatest.common.build_path('devtools/ya/bin') :return: absolute path inside build directory """ return _join_path(_get_ya_plugin_instance().build_root, path)
inside arcadia :param path: path arcadia relative, e.g. yatest.common.source_path('devtools/ya') :return: absolute path to the source folder """ return _join_path(_get_ya_plugin_instance().source_root, path) def build_path(path=None):
64
64
71
6
58
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
build_path
build_path
67
73
67
67
30dc893d843bb23dd4f501488fa50837c932cb5a
bigcode/the-stack
train
05bc9880ef5eade7f47d21b6
train
function
def _get_ya_config(): try: import pytest return pytest.config except (ImportError, AttributeError): try: import library.python.testing.recipe if library.python.testing.recipe.ya: return library.python.testing.recipe except (ImportError, Att...
def _get_ya_config():
try: import pytest return pytest.config except (ImportError, AttributeError): try: import library.python.testing.recipe if library.python.testing.recipe.ya: return library.python.testing.recipe except (ImportError, AttributeError): ...
import os import functools import json import threading import six _lock = threading.Lock() def _get_ya_config():
27
64
84
7
20
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
_get_ya_config
_get_ya_config
12
23
12
12
68719006e51203932af3a1b387f2930bdb9e12b3
bigcode/the-stack
train
02fce244629527985ae14a32
train
function
def output_ram_drive_path(path=None): """ Returns path inside ram drive directory which will be saved in the testing_out_stuff directory after testing. If no ram drive was provided by environment - returns path inside testing_out_stuff directory. :param path: path relative to the output ram drive direct...
def output_ram_drive_path(path=None):
""" Returns path inside ram drive directory which will be saved in the testing_out_stuff directory after testing. If no ram drive was provided by environment - returns path inside testing_out_stuff directory. :param path: path relative to the output ram drive directory """ return _join_path(os.e...
. :return: absolute path inside the ram drive directory or None if no ram drive was provided by environment. """ if 'YA_TEST_RAM_DRIVE_PATH' in os.environ: return _join_path(os.environ['YA_TEST_RAM_DRIVE_PATH'], path) def output_ram_drive_path(path=None):
64
64
84
8
56
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
output_ram_drive_path
output_ram_drive_path
113
119
113
113
cd70c9b5065892f6a20a8dba1d4eafe8ce48c27a
bigcode/the-stack
train
cbd850d2f21f7efc35f74a48
train
function
def project_path(path=None): """ Get path in build root relating to build_root/project path """ return _join_path(os.path.join(build_path(), context.project_path), path)
def project_path(path=None):
""" Get path in build root relating to build_root/project path """ return _join_path(os.path.join(build_path(), context.project_path), path)
for the current test case """ import pytest test_out_dir = os.path.splitext(pytest.config.current_test_log_path)[0] if not os.path.exists(test_out_dir): os.makedirs(test_out_dir) return _join_path(test_out_dir, path) def project_path(path=None):
64
64
40
6
58
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
project_path
project_path
189
193
189
189
d1403e4e6ff0d085e6e0e4725c8ce391a9a3f572
bigcode/the-stack
train
f3a30abc22cec8f068b317f7
train
function
def get_param_dict_copy(): """ Return copy of dictionary with all parameters. Changes to this dictionary do *not* change parameters. :return: copy of dictionary with all parameters """ return _get_ya_plugin_instance().get_param_dict_copy()
def get_param_dict_copy():
""" Return copy of dictionary with all parameters. Changes to this dictionary do *not* change parameters. :return: copy of dictionary with all parameters """ return _get_ya_plugin_instance().get_param_dict_copy()
(key, default=None): """ Get arbitrary parameter passed via command line :param key: key :param default: default value :return: parameter value or the default """ return _get_ya_plugin_instance().get_param(key, default) def get_param_dict_copy():
64
64
55
6
58
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
get_param_dict_copy
get_param_dict_copy
168
174
168
168
842342e61bfb7f3fc71b031d8cf2b9b4acc80e02
bigcode/the-stack
train
0c2b8a96bee0116ec984fe2d
train
function
def source_path(path=None): """ Get source path inside arcadia :param path: path arcadia relative, e.g. yatest.common.source_path('devtools/ya') :return: absolute path to the source folder """ return _join_path(_get_ya_plugin_instance().source_root, path)
def source_path(path=None):
""" Get source path inside arcadia :param path: path arcadia relative, e.g. yatest.common.source_path('devtools/ya') :return: absolute path to the source folder """ return _join_path(_get_ya_plugin_instance().source_root, path)
for py.test :param func: :return: """ @functools.wraps(func) def wrapper(*args, **kwds): return func(*args, **kwds) setattr(wrapper, '__test__', False) return wrapper def source_path(path=None):
64
64
70
6
57
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
source_path
source_path
58
64
58
58
77c00d0e346c9a23f10b04058ac83df05b447905
bigcode/the-stack
train
3ba2e769c867295312a7fd56
train
function
def _register_core(name, binary_path, core_path, bt_path, pbt_path): config = _get_ya_config() with _lock: config.test_cores_count += 1 count_str = '' if config.test_cores_count == 1 else str(config.test_cores_count) log_entry = config.test_logs[config.current_item_nodeid] if binary_pa...
def _register_core(name, binary_path, core_path, bt_path, pbt_path):
config = _get_ya_config() with _lock: config.test_cores_count += 1 count_str = '' if config.test_cores_count == 1 else str(config.test_cores_count) log_entry = config.test_logs[config.current_item_nodeid] if binary_path: log_entry['{} binary{}'.format(name, count_str)] = binary...
""" return os.environ.get("YA_CXX") def global_resources(): try: return json.loads(os.environ.get("YA_GLOBAL_RESOURCES")) except (TypeError, ValueError): return {} def _register_core(name, binary_path, core_path, bt_path, pbt_path):
63
64
172
19
44
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
_register_core
_register_core
224
239
224
224
530629984b1df5045705a6f17399851aa2ce4b4a
bigcode/the-stack
train
4d4061e89ede6506f47c0e52
train
function
def binary_path(path=None): """ Get path to the built binary :param path: path to the binary relative to the build directory e.g. yatest.common.binary_path('devtools/ya/bin/ya-bin') :return: absolute path to the binary """ path = _norm_path(path) return _get_ya_plugin_instance().get_binary(p...
def binary_path(path=None):
""" Get path to the built binary :param path: path to the binary relative to the build directory e.g. yatest.common.binary_path('devtools/ya/bin/ya-bin') :return: absolute path to the binary """ path = _norm_path(path) return _get_ya_plugin_instance().get_binary(path)
uff directory after testing. If no ram drive was provided by environment - returns path inside testing_out_stuff directory. :param path: path relative to the output ram drive directory """ return _join_path(os.environ['YA_TEST_OUTPUT_RAM_DRIVE_PATH'], path) def binary_path(path=None):
64
64
81
6
58
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
binary_path
binary_path
122
129
122
122
19dd97eab62ca8123a0fc913d7a5766ef40e1104
bigcode/the-stack
train
e70c0fcf45391fe25f1728a1
train
function
def python_path(): """ Get path to the arcadia python :return: absolute path to python """ return _get_ya_plugin_instance().python_path
def python_path():
""" Get path to the arcadia python :return: absolute path to python """ return _get_ya_plugin_instance().python_path
that files will be accessible after the test suite execution :param path: path relative to the test suite working dir :return: absolute path inside the test suite working dir """ return _join_path(os.environ.get("TEST_WORK_PATH") or os.getcwd(), path) def python_path():
64
64
38
4
60
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
python_path
python_path
142
147
142
142
3391cbc56e4e5ef9857feaaa04b221bc29dc4543
bigcode/the-stack
train
a3bd8f5a9d4e072e5a915d25
train
function
def gdb_path(): """ Get path to the gdb """ return _get_ya_plugin_instance().gdb_path
def gdb_path():
""" Get path to the gdb """ return _get_ya_plugin_instance().gdb_path
): os.makedirs(test_out_dir) return _join_path(test_out_dir, path) def project_path(path=None): """ Get path in build root relating to build_root/project path """ return _join_path(os.path.join(build_path(), context.project_path), path) def gdb_path():
64
64
30
5
59
PallHaraldsson/catboost
library/python/testing/yatest_common/yatest/common/runtime.py
Python
gdb_path
gdb_path
196
200
196
196
ec88c556168ae23fece7cd382a859de4d8233114
bigcode/the-stack
train