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
a656315e207d69cc7a8cbe7f
train
function
def file_fixit(existing, desired): result = 0 file_system = tree() for path in existing: t = file_system for directory in directories(path): t = t[directory] for path in desired: t = file_system for directory in directories(path): if directory no...
def file_fixit(existing, desired):
result = 0 file_system = tree() for path in existing: t = file_system for directory in directories(path): t = t[directory] for path in desired: t = file_system for directory in directories(path): if directory not in t: result += 1...
bytes in the input file, which is asymptotically optimal. """ from collections import defaultdict ROOT_DIR = '' def tree(): return defaultdict(tree) def directories(path): for directory in path.split('/'): if directory != ROOT_DIR: yield directory def file_fixit(existing, desired):
64
64
89
8
55
py-in-the-sky/challenges
google-code-jam/file_fixit.py
Python
file_fixit
file_fixit
26
42
26
26
464ff565cc5be288eda0e8010e72fcf4d8cf94a5
bigcode/the-stack
train
a4777ef331d9243b4bcd741c
train
function
def main(): T = int(input().strip()) for t in range(1, T+1): N, M = map(int, input().strip().split()) existing = (input().strip() for _ in range(N)) desired = (input().strip() for _ in range(M)) print("Case #{}: {}".format(t, file_fixit(existing, desired)))
def main():
T = int(input().strip()) for t in range(1, T+1): N, M = map(int, input().strip().split()) existing = (input().strip() for _ in range(N)) desired = (input().strip() for _ in range(M)) print("Case #{}: {}".format(t, file_fixit(existing, desired)))
= file_system for directory in directories(path): t = t[directory] for path in desired: t = file_system for directory in directories(path): if directory not in t: result += 1 t = t[directory] return result def main():
64
64
84
3
60
py-in-the-sky/challenges
google-code-jam/file_fixit.py
Python
main
main
45
52
45
45
fb8eb7f91b001f2049af006c4d20f7dcd0230e9b
bigcode/the-stack
train
b2b9d6b9c1d88dd1b43eda1b
train
function
def set_constraints(constraints, constraint_list): """ Update the constraint_layers list with filtered ee.Images according to user parameters Args: constraints (dict): a str json formatted list of constraints. Use the formatting specified in the QuestionModel constraint_list (list): the lis...
def set_constraints(constraints, constraint_list):
""" Update the constraint_layers list with filtered ee.Images according to user parameters Args: constraints (dict): a str json formatted list of constraints. Use the formatting specified in the QuestionModel constraint_list (list): the list of all the constraint layer. each layer is repres...
) .add(1) ) # set constraints as 0 values idict_cons, constraint_exp = get_constraint_expression(constraint_list) exp_dict = {"wlc": wlc_image, **idict_cons} exp = f"( wlc * {constraint_exp} )" wlc_image = wlc_image.expression(exp, exp_dict) wlc_out = wlc_image.clip(aoi_ee) re...
116
116
387
9
106
sepal-contrib/se.plan
component/scripts/functions.py
Python
set_constraints
set_constraints
93
147
93
93
026d4b964a2953bb4afc9c47adc01c676a0676b7
bigcode/the-stack
train
faefa406f463275a76f4b178
train
function
def get_bool_constraint(value, layer_id): """ set a contraint in the provided layer list using the name provided by the criteria and the value provided by the user. The function will find the layer in the list and update the eeimage mask Args: value (bool): a bool value to mask the category. Tr...
def get_bool_constraint(value, layer_id):
""" set a contraint in the provided layer list using the name provided by the criteria and the value provided by the user. The function will find the layer in the list and update the eeimage mask Args: value (bool): a bool value to mask the category. True: mask it, False: keep only this one ...
""" # extract an ee.Image image = ee.Image(layer_id) # filter the image according to min and max values set by the user image = image.gte(values[0]).And(image.lte(values[1])) return image def get_bool_constraint(value, layer_id):
64
64
156
9
54
sepal-contrib/se.plan
component/scripts/functions.py
Python
get_bool_constraint
get_bool_constraint
220
239
220
220
e87e68fff160796cf890cbcf8de42f1fd73ad1f3
bigcode/the-stack
train
e0ff070067e53206c9a16f62
train
function
def get_expression(benefit_list, cost_list): fdict_bene, idict_bene, benefits_exp = get_benefit_expression(benefit_list) idict_cost, costs_exp = get_cost_expression(cost_list) expression_dict = {**fdict_bene, **idict_bene, **idict_cost} expression = f"( ( {benefits_exp} / {costs_exp} ))" return e...
def get_expression(benefit_list, cost_list):
fdict_bene, idict_bene, benefits_exp = get_benefit_expression(benefit_list) idict_cost, costs_exp = get_cost_expression(cost_list) expression_dict = {**fdict_bene, **idict_bene, **idict_cost} expression = f"( ( {benefits_exp} / {costs_exp} ))" return expression, expression_dict
str): the method to use """ normalize = {"minmax": _minmax, "quintile": _quintile} return normalize[method](ee.Image(layer["layer"]), ee_aoi, name=layer["name"]) def get_expression(benefit_list, cost_list):
63
64
97
11
52
sepal-contrib/se.plan
component/scripts/functions.py
Python
get_expression
get_expression
367
375
367
368
47f54f4fd9ade96b87ad51f2b9b1032d76e5974d
bigcode/the-stack
train
77d768f6b9318f5c092fe657
train
function
def _percentile(ee_image, ee_aoi, scale=10000, percentile=[3, 97], name="layer_id"): """Use the percentile normalization""" tmp_ee_image = ee_image.rename("img") percents = tmp_ee_image.reduceRegion( geometry=ee_aoi.geometry(), reducer=ee.Reducer.percentile(percentiles=percentile), ...
def _percentile(ee_image, ee_aoi, scale=10000, percentile=[3, 97], name="layer_id"):
"""Use the percentile normalization""" tmp_ee_image = ee_image.rename("img") percents = tmp_ee_image.reduceRegion( geometry=ee_aoi.geometry(), reducer=ee.Reducer.percentile(percentiles=percentile), scale=scale, ) img_low = ee.Number(percents.get(f"img_p{percentile[0]}")) ...
= ee.Number(mmvalues.get(key_min)) img_max = ee.Number(mmvalues.get(key_max)) return ee_image.unitScale(img_min, img_max).float() def _percentile(ee_image, ee_aoi, scale=10000, percentile=[3, 97], name="layer_id"):
64
64
160
29
35
sepal-contrib/se.plan
component/scripts/functions.py
Python
_percentile
_percentile
285
299
285
285
6ce612ab47d494b6dd41d4561acf7cd43fac2d29
bigcode/the-stack
train
b62b3b42cc36249db9a78a55
train
function
def normalize_benefits(benefit_list, ee_aoi, method="minmax"): """ Normalize each benefits using the provided method Args: benefit_list (list): the list of the benefit ee_aoi (ee.FeatureCollection): the aoi as an ee.FeatureCollection method (str, optional): the method to use to norm...
def normalize_benefits(benefit_list, ee_aoi, method="minmax"):
""" Normalize each benefits using the provided method Args: benefit_list (list): the list of the benefit ee_aoi (ee.FeatureCollection): the aoi as an ee.FeatureCollection method (str, optional): the method to use to normalize Return: the normalized benefit_list """...
ee.Image image = ee.Image(layer_id) # filter the image according to the value provided by the user image = image.eq(0) if value else image.eq(1) return image def normalize_benefits(benefit_list, ee_aoi, method="minmax"):
64
64
124
19
44
sepal-contrib/se.plan
component/scripts/functions.py
Python
normalize_benefits
normalize_benefits
242
260
242
242
320b5b0323a1791e773e599963623ee299b59293
bigcode/the-stack
train
40dc4c6ea3f2a3df220b9bd9
train
function
def get_cat_constraint(cat_id, value, name, layer_id): """ Return fully defined layer dict for the constraint list Args: cat_id (int): the category number to mask in the landcover image value (bool): a bool value to mask the category. True: mask it, False: keep only this one name (s...
def get_cat_constraint(cat_id, value, name, layer_id):
""" Return fully defined layer dict for the constraint list Args: cat_id (int): the category number to mask in the landcover image value (bool): a bool value to mask the category. True: mask it, False: keep only this one name (str): the constraint name layer_id (str): the ge...
if i["id"] == "land_cover") # else use the one that have the same name else: constraint_layer = next(i for i in constraint_list if i["id"] == layer_name) return constraint_layer def get_cat_constraint(cat_id, value, name, layer_id):
64
64
199
14
49
sepal-contrib/se.plan
component/scripts/functions.py
Python
get_cat_constraint
get_cat_constraint
171
195
171
171
38aa29a52a705e92f9f11d696fd7a46821216243
bigcode/the-stack
train
0407ff521166a62b423ee2eb
train
function
def _quintile(ee_image, ee_aoi, scale=100, name="layer_id"): """use quintile normailzation""" quintile_collection = ee_image.reduceRegions( collection=ee_aoi, reducer=ee.Reducer.percentile( percentiles=[20, 40, 60, 80], outputNames=["low", "lowmed", "highmed", "high"], ...
def _quintile(ee_image, ee_aoi, scale=100, name="layer_id"):
"""use quintile normailzation""" quintile_collection = ee_image.reduceRegions( collection=ee_aoi, reducer=ee.Reducer.percentile( percentiles=[20, 40, 60, 80], outputNames=["low", "lowmed", "highmed", "high"], ), tileScale=2, scale=scale, ) ...
img") percents = tmp_ee_image.reduceRegion( geometry=ee_aoi.geometry(), reducer=ee.Reducer.percentile(percentiles=percentile), scale=scale, ) img_low = ee.Number(percents.get(f"img_p{percentile[0]}")) img_high = ee.Number(percents.get(f"img_p{percentile[1]}")).add(0.1e-13) ...
136
136
455
22
114
sepal-contrib/se.plan
component/scripts/functions.py
Python
_quintile
_quintile
302
350
302
302
143b05d4a6822f7c86f3e9c9e56b63aaf6c1b3a4
bigcode/the-stack
train
e4ae43cabaf9f6e77e8699cb
train
function
def wlc(layer_list, constraints, priorities, aoi_ee): """ Compute the resoration suitability indicator over the specified AOI the computation will take into account all the parameters specified by the user in the app Args: layer_list (dict): the list of layers items constraints (str): a...
def wlc(layer_list, constraints, priorities, aoi_ee):
""" Compute the resoration suitability indicator over the specified AOI the computation will take into account all the parameters specified by the user in the app Args: layer_list (dict): the list of layers items constraints (str): a str json formatted list of constraints. Use the forma...
import ee import json from traitlets import Any, HasTraits from component import parameter as cp from component import model from component.message import cm ee.Initialize() #################################################### ### default parameters of the singleton ######## #####################################...
138
201
673
15
123
sepal-contrib/se.plan
component/scripts/functions.py
Python
wlc
wlc
26
90
26
26
b34bb1c120ba1cae793d9c2842c34a4174d6380a
bigcode/the-stack
train
db34ce5f376e1a56cfede8fd
train
function
def get_range_constraint(values, layer_id): """ set a contraint in the provided layer list using the name provided by the criteria and the values provided by the user. The function will find the layer in the list and update the eeimage mask Args: values (list): the min and max value of the spec...
def get_range_constraint(values, layer_id):
""" set a contraint in the provided layer list using the name provided by the criteria and the values provided by the user. The function will find the layer in the list and update the eeimage mask Args: values (list): the min and max value of the specified range layer_id (str): the gee ...
neq(cat_id) if value else image.eq(cat_id) return { "id": "land_cover", "theme": "constraints", "subtheme": "Socio-economic", "name": name, "eeimage": image, } def get_range_constraint(values, layer_id):
64
64
150
9
55
sepal-contrib/se.plan
component/scripts/functions.py
Python
get_range_constraint
get_range_constraint
198
217
198
198
19edbcc44933adb0dab0bf20e664e7b7bcba2753
bigcode/the-stack
train
3eb98a36573e5ed5a223222e
train
function
def _minmax(ee_image, ee_aoi, scale=10000, name="layer_id"): """use the minmax normalization""" mmvalues = ee_image.reduceRegion( reducer=ee.Reducer.minMax(), geometry=ee_aoi.geometry(), scale=scale, maxPixels=1e13, bestEffort=True, tileScale=4, ) band_n...
def _minmax(ee_image, ee_aoi, scale=10000, name="layer_id"):
"""use the minmax normalization""" mmvalues = ee_image.reduceRegion( reducer=ee.Reducer.minMax(), geometry=ee_aoi.geometry(), scale=scale, maxPixels=1e13, bestEffort=True, tileScale=4, ) band_name = ee.String(ee_image.bandNames().get(0)) key_min = ba...
normalized benefit_list """ # update the layer images for layer in benefit_list: layer.update(eeimage=normalize_image(layer, ee_aoi, method)) return benefit_list def _minmax(ee_image, ee_aoi, scale=10000, name="layer_id"):
64
64
158
22
41
sepal-contrib/se.plan
component/scripts/functions.py
Python
_minmax
_minmax
263
282
263
263
ef77b3a1d2a5cbfc11d26d8ba3f6da0cd9b5f089
bigcode/the-stack
train
401c7846bb55cc4c7ae3cb39
train
function
def get_layer(layer_name, constraint_list): """Return the layer dict Args: layer_name(str): the layer name (with spaces) constraint_list(list of dict): the list of each layer and it's eeimage Return: (dict): the layer dict""" # for all land cover constraints we use the same la...
def get_layer(layer_name, constraint_list):
"""Return the layer dict Args: layer_name(str): the layer name (with spaces) constraint_list(list of dict): the list of each layer and it's eeimage Return: (dict): the layer dict""" # for all land cover constraints we use the same layer if layer_name in cp.land_use_criteri...
_geographic = next( item for item in constraint_list if item["name"] == "Current tree cover less than potential" ) default_geographic.update(eeimage=ee.Image(default_geographic["layer"])) return constraint_list def get_layer(layer_name, constraint_list):
64
64
145
9
54
sepal-contrib/se.plan
component/scripts/functions.py
Python
get_layer
get_layer
150
168
150
150
4917d574d6dcf49681d3b63925763cc068cc3a35
bigcode/the-stack
train
846df5f8c5802454d9ecb37b
train
function
def get_constraint_expression(constraint_list): idict = {f"cn{i}": e["eeimage"] for i, e in enumerate(constraint_list)} exp = [f"(cn{i})" for i, e in enumerate(constraint_list)] exp_string = f"({'*'.join(exp)})" return idict, exp_string
def get_constraint_expression(constraint_list):
idict = {f"cn{i}": e["eeimage"] for i, e in enumerate(constraint_list)} exp = [f"(cn{i})" for i, e in enumerate(constraint_list)] exp_string = f"({'*'.join(exp)})" return idict, exp_string
": e["eeimage"] for i, e in enumerate(cost_list)} exp = [f"(c{i})" for i, e in enumerate(cost_list)] exp_string = f"({'+'.join(exp)})" return idict, exp_string def get_constraint_expression(constraint_list):
64
64
76
8
55
sepal-contrib/se.plan
component/scripts/functions.py
Python
get_constraint_expression
get_constraint_expression
400
406
400
401
70604492aa904be372bde46f7f6f179074ef32df
bigcode/the-stack
train
ad48412616aa3de61e44c8ce
train
function
def get_cost_expression(cost_list): idict = {f"c{i}": e["eeimage"] for i, e in enumerate(cost_list)} exp = [f"(c{i})" for i, e in enumerate(cost_list)] exp_string = f"({'+'.join(exp)})" return idict, exp_string
def get_cost_expression(cost_list):
idict = {f"c{i}": e["eeimage"] for i, e in enumerate(cost_list)} exp = [f"(c{i})" for i, e in enumerate(cost_list)] exp_string = f"({'+'.join(exp)})" return idict, exp_string
exp_bene = [f"(f{i}*b{i})" for i, e in enumerate(benefit_list)] benefits_exp = f"({'+'.join(exp_bene)})" return fdict_bene, idict_bene, benefits_exp def get_cost_expression(cost_list):
64
64
73
7
56
sepal-contrib/se.plan
component/scripts/functions.py
Python
get_cost_expression
get_cost_expression
391
397
391
392
ff6e28a9133769c8cf3947e3e5e65a7eeeabb155
bigcode/the-stack
train
9722ba0a34a862db394eb608
train
function
def get_benefit_expression(benefit_list): # build expressions for benefits fdict_bene = {f"f{i}": e["norm_weight"] for i, e in enumerate(benefit_list)} idict_bene = {f"b{i}": e["eeimage"] for i, e in enumerate(benefit_list)} exp_bene = [f"(f{i}*b{i})" for i, e in enumerate(benefit_list)] benefits...
def get_benefit_expression(benefit_list): # build expressions for benefits
fdict_bene = {f"f{i}": e["norm_weight"] for i, e in enumerate(benefit_list)} idict_bene = {f"b{i}": e["eeimage"] for i, e in enumerate(benefit_list)} exp_bene = [f"(f{i}*b{i})" for i, e in enumerate(benefit_list)] benefits_exp = f"({'+'.join(exp_bene)})" return fdict_bene, idict_bene, benefits_ex...
_dict = {**fdict_bene, **idict_bene, **idict_cost} expression = f"( ( {benefits_exp} / {costs_exp} ))" return expression, expression_dict def get_benefit_expression(benefit_list): # build expressions for benefits
64
64
134
18
45
sepal-contrib/se.plan
component/scripts/functions.py
Python
get_benefit_expression
get_benefit_expression
378
388
378
380
20264835d2c0cc96f6644ca7fa4410f1b6a8ba0b
bigcode/the-stack
train
5b5487dd74b1d5637f3d2279
train
function
def normalize_image(layer, ee_aoi, method="mixmax"): """ Return the normalize image of a set layer using the provided method Args: layer (dict): the fully qualified layer dict ee_aoi (ee.FeatureCollection): the defined aoi method (str): the method to use """ normalize = {"m...
def normalize_image(layer, ee_aoi, method="mixmax"):
""" Return the normalize image of a set layer using the provided method Args: layer (dict): the fully qualified layer dict ee_aoi (ee.FeatureCollection): the defined aoi method (str): the method to use """ normalize = {"minmax": _minmax, "quintile": _quintile} return no...
med).And(ee_image.lte(high)), 4) .where(ee_image.gt(high), 5) ) return out return ee.ImageCollection(vaild_quintiles_list.map(conditions)).mosaic() def normalize_image(layer, ee_aoi, method="mixmax"):
64
64
113
14
50
sepal-contrib/se.plan
component/scripts/functions.py
Python
normalize_image
normalize_image
353
364
353
353
a1b4394bc7b3f53e29bfd7b248e297375e44d597
bigcode/the-stack
train
b6413a53fd53243cf88d933d
train
class
class toolkit: def __init__ (self, token, assets_path = None): self.__logger = None self.assets = _features._assets(self, assets_path) self.core = _api.core(token) self.replies = _features.replies() self.uploader = _api.uploader(self) @property def __event_loop(self)...
class toolkit:
def __init__ (self, token, assets_path = None): self.__logger = None self.assets = _features._assets(self, assets_path) self.core = _api.core(token) self.replies = _features.replies() self.uploader = _api.uploader(self) @property def __event_loop(self): retur...
from vkbotkit.objects.data import response from . import _features, _api from .. import objects import asyncio """ Copyright 2022 kensoi """ import os import random import typing class toolkit:
48
256
879
3
44
kensoi/testbotkit
vkbotkit/framework/_app.py
Python
toolkit
toolkit
13
122
13
13
a831653370dcc89e59d7a289c6106ca07a339cb7
bigcode/the-stack
train
b07d5c3d606b134fa7f17994
train
class
class librabot: def __init__(self, token, assetpath = None, libpath = None): if not assetpath: assetpath = os.getcwd() + objects.path_separator + "assets" if not libpath: libpath = os.getcwd() + objects.path_separator + "library" self.library = _features.cal...
class librabot:
def __init__(self, token, assetpath = None, libpath = None): if not assetpath: assetpath = os.getcwd() + objects.path_separator + "assets" if not libpath: libpath = os.getcwd() + objects.path_separator + "library" self.library = _features.callbacklib(libpath...
await self.delete_message(package) return await self.api.messages.send(**kwargs) async def delete_message(self, package): return await self.api.messages.delete(conversation_message_ids = package.conversation_message_id, peer_id = package.peer_id, delete_for_all = 1) cl...
64
64
110
4
60
kensoi/testbotkit
vkbotkit/framework/_app.py
Python
librabot
librabot
126
139
126
126
c7d3e6422fb5b072737c593d73f56dcfd29caf0e
bigcode/the-stack
train
954c5370707fc2fa5343dd71
train
class
class OnedimLR(BaseLR): def __init__(self, scale: float, gamma: float, alpha: float, c: float): self.__scale = scale self.__gamma = gamma self.__alpha = alpha self.__c = c self.__v = LRvalue(0, 1) def __call__(self, t: int, grad_t: np.ndarray) -> LRvalue: self.__...
class OnedimLR(BaseLR):
def __init__(self, scale: float, gamma: float, alpha: float, c: float): self.__scale = scale self.__gamma = gamma self.__alpha = alpha self.__c = c self.__v = LRvalue(0, 1) def __call__(self, t: int, grad_t: np.ndarray) -> LRvalue: self.__v.lr = self.__scale * se...
import numpy as np from .base import BaseLR from .value import LRvalue class OnedimLR(BaseLR):
27
64
133
8
18
georgios-vassos1/fastsgd
fastsgd/learning_rate/onedim.py
Python
OnedimLR
OnedimLR
5
15
5
5
74fb5474e78d4c383793d6c62d8f3c8c3eb52843
bigcode/the-stack
train
a7aa1a9a4ee8e461d211fe51
train
function
def chk_instance_identifier(old, new, oldts, newts, ctx): # FIXME: return
def chk_instance_identifier(old, new, oldts, newts, ctx): # FIXME:
return
oidbase.arg.split(':')[-1]): extra.remove(nidbase) for n in extra: err_add(ctx.errors, n.pos, 'CHK_DEF_ADDED', ('base', n.arg)) def chk_instance_identifier(old, new, oldts, newts, ctx): # FIXME:
64
64
23
20
44
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_instance_identifier
chk_instance_identifier
744
746
744
745
8a97fc1500a532b2fff196967c045dc698960b91
bigcode/the-stack
train
627c829bfdf3ce37d05879a8
train
function
def pyang_plugin_init(): plugin.register_plugin(CheckUpdatePlugin())
def pyang_plugin_init():
plugin.register_plugin(CheckUpdatePlugin())
sys import os import io from pyang import context from pyang import repository from pyang import plugin from pyang import statements from pyang import error from pyang import util from pyang import types from pyang.error import err_add def pyang_plugin_init():
64
64
14
6
57
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
pyang_plugin_init
pyang_plugin_init
21
22
21
21
f1c67814feb59ae5bc3916f24232dc0adb4b958a
bigcode/the-stack
train
0da09688926eb15d2082cf6d
train
function
def chk_integer(old, new, oldts, newts, ctx): chk_range(old, new, oldts, newts, ctx)
def chk_integer(old, new, oldts, newts, ctx):
chk_range(old, new, oldts, newts, ctx)
ts.name, newts.name)) return # check the allowed restriction changes if oldts.name in chk_type_func: chk_type_func[oldts.name](old, new, oldts, newts, ctx) def chk_integer(old, new, oldts, newts, ctx):
64
64
30
15
49
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_integer
chk_integer
649
650
649
649
fe7baad1b2e63b99c2165b3d5e50e98274bb1547
bigcode/the-stack
train
590cc5c33e1eacdecc735d68
train
function
def err_def_removed(old, newp, ctx): old_arg = old.arg if old.keyword == 'presence': old_arg = old.parent.arg err_add(ctx.errors, newp.pos, 'CHK_DEF_REMOVED', (old.keyword, old_arg, old.pos))
def err_def_removed(old, newp, ctx):
old_arg = old.arg if old.keyword == 'presence': old_arg = old.parent.arg err_add(ctx.errors, newp.pos, 'CHK_DEF_REMOVED', (old.keyword, old_arg, old.pos))
CHK_DEF_ADDED', (new.keyword, new_arg)) def err_def_added2(new, node, ctx): err_add(ctx.errors, new.pos, 'CHK_DEF_ADDED2', (new.keyword, new.arg, node.keyword, node.arg)) def err_def_removed(old, newp, ctx):
64
64
61
11
53
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
err_def_removed
err_def_removed
790
795
790
790
854f03592686a04ca7a5bebc970c73b6ab9ea1ad
bigcode/the-stack
train
e92ed8a2c97482d8f1c89005
train
function
def chk_input_output(old, new, ctx): chk_i_children(old, new, ctx)
def chk_input_output(old, new, ctx):
chk_i_children(old, new, ctx)
, new, ctx) def chk_choice(old, new, ctx): chk_mandatory(old, new, ctx) chk_i_children(old, new, ctx) def chk_case(old, new, ctx): chk_i_children(old, new, ctx) def chk_input_output(old, new, ctx):
64
64
20
10
54
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_input_output
chk_input_output
631
632
631
631
5e29d1f3fa01f12767bca2a097697b88aca211b1
bigcode/the-stack
train
a7bd76ca19712dd81e02e06f
train
function
def chk_key(old, new, ctx): oldkey = old.search_one('key') newkey = new.search_one('key') if oldkey is None and newkey is None: pass elif oldkey is None and newkey is not None: err_def_added(newkey, ctx) elif oldkey is not None and newkey is None: err_def_removed(oldkey, new,...
def chk_key(old, new, ctx):
oldkey = old.search_one('key') newkey = new.search_one('key') if oldkey is None and newkey is None: pass elif oldkey is None and newkey is not None: err_def_added(newkey, ctx) elif oldkey is not None and newkey is None: err_def_removed(oldkey, new, ctx) else: # ch...
) elif oldpresence is not None and newpresence is None: err_def_removed(oldpresence, new, ctx) elif oldpresence.arg != newpresence.arg: err_add(ctx.errors, newpresence.pos, 'CHK_UNDECIDED_PRESENCE', ()) def chk_key(old, new, ctx):
65
66
220
9
56
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_key
chk_key
566
585
566
566
e1f161a586d4f58effe789d57cd9a4a57b5ea732
bigcode/the-stack
train
0abbcf283295cde0d3dceebd
train
function
def chk_presence(old, new, ctx): oldpresence = old.search_one('presence') newpresence = new.search_one('presence') if oldpresence is None and newpresence is None: pass elif oldpresence is None and newpresence is not None: err_def_added(newpresence, ctx) elif oldpresence is not None a...
def chk_presence(old, new, ctx):
oldpresence = old.search_one('presence') newpresence = new.search_one('presence') if oldpresence is None and newpresence is None: pass elif oldpresence is None and newpresence is not None: err_def_added(newpresence, ctx) elif oldpresence is not None and newpresence is None: e...
newmax = new.search_one('max-elements') if oldmax is None: pass elif newmax is None: pass elif int(newmax.arg) < int(oldmax.arg): err_def_changed(oldmax, newmax, ctx) def chk_presence(old, new, ctx):
64
64
121
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_presence
chk_presence
554
564
554
554
d93fe0f3f15f59a9db410caf049d9cfb70bb2eb6
bigcode/the-stack
train
809ebbe4a3b2d36c5f4879b9
train
function
def chk_children(oldch, newchs, newp, ctx): newch = None for ch in newchs: if ch.arg == oldch.arg: newch = ch break if newch is None: err_def_removed(oldch, newp, ctx) return if newch.keyword != oldch.keyword: err_add(ctx.errors, newch.pos, 'CHK_C...
def chk_children(oldch, newchs, newp, ctx):
newch = None for ch in newchs: if ch.arg == oldch.arg: newch = ch break if newch is None: err_def_removed(oldch, newp, ctx) return if newch.keyword != oldch.keyword: err_add(ctx.errors, newch.pos, 'CHK_CHILD_KEYWORD_CHANGED', (oldc...
for new_child in new.i_children if new_child.arg not in old_child_args] for newch in added_new_children: if statements.is_mandatory_node(newch): err_add(ctx.errors, newch.pos, 'CHK_NEW_MANDATORY', newch.arg) def chk_child(oldch, newp, ctx): chk_children(oldch, newp.i_children, newp, ctx) d...
99
99
332
14
85
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_children
chk_children
391
425
391
391
a839b1f5a4c44a0ae3b7e81f2d54e361ca8d4cca
bigcode/the-stack
train
1861722530565199e02a7a00
train
function
def chk_dummy(old, new, oldts, newts, ctx): return
def chk_dummy(old, new, oldts, newts, ctx):
return
!= len(oldts.types): err_add(ctx.errors, new.pos, 'CHK_UNION_TYPES', ()) else: for o, n in zip(oldts.types, newts.types): chk_type(o, n, ctx) def chk_dummy(old, new, oldts, newts, ctx):
64
64
18
15
49
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_dummy
chk_dummy
755
756
755
755
9c4e155dc334de918c5bb1a3f8042e9bebb19f52
bigcode/the-stack
train
9076c40be573195248a0bb83
train
function
def chk_child(oldch, newp, ctx): chk_children(oldch, newp.i_children, newp, ctx)
def chk_child(oldch, newp, ctx):
chk_children(oldch, newp.i_children, newp, ctx)
.i_children if new_child.arg not in old_child_args] for newch in added_new_children: if statements.is_mandatory_node(newch): err_add(ctx.errors, newch.pos, 'CHK_NEW_MANDATORY', newch.arg) def chk_child(oldch, newp, ctx):
64
64
27
11
53
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_child
chk_child
388
389
388
388
c771d96a358e52394a657eaff164b8974f4072da
bigcode/the-stack
train
10dea5400683217359e26473
train
function
def chk_module(ctx, oldmod, newmod): chk_modulename(oldmod, newmod, ctx) chk_namespace(oldmod, newmod, ctx) chk_revision(oldmod, newmod, ctx) for olds in oldmod.search('feature'): chk_feature(olds, newmod, ctx) for olds in oldmod.search('identity'): chk_identity(olds, newmod, ct...
def chk_module(ctx, oldmod, newmod):
chk_modulename(oldmod, newmod, ctx) chk_namespace(oldmod, newmod, ctx) chk_revision(oldmod, newmod, ctx) for olds in oldmod.search('feature'): chk_feature(olds, newmod, ctx) for olds in oldmod.search('identity'): chk_identity(olds, newmod, ctx) for olds in oldmod.search('typ...
modules:") for x in oldrepo.get_modules_and_revisions(oldctx): (m, r, (fmt, filename)) = x print(" %s" % filename) print("") chk_module(ctx, oldmod, newmod) def chk_module(ctx, oldmod, newmod):
66
66
220
11
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_module
chk_module
193
224
193
194
2bf1b58e736e07e47f2c87c5210eb5696992832b
bigcode/the-stack
train
c206ae8377c769e27fda11ca
train
function
def chk_when(old, new, ctx): oldwhen = old.search('when') newwhen = new.search('when') # remove all common whens for oldw in old.search('when'): neww = new.search_one('when', arg = oldw.arg) if neww is not None: newwhen.remove(neww) oldwhen.remove(oldw) if new...
def chk_when(old, new, ctx):
oldwhen = old.search('when') newwhen = new.search('when') # remove all common whens for oldw in old.search('when'): neww = new.search_one('when', arg = oldw.arg) if neww is not None: newwhen.remove(neww) oldwhen.remove(oldw) if new.i_module.i_version == '1.1':...
newm in newmust: err_add(ctx.errors, newm.pos, 'CHK_NEW_MUST', ()) else: for newm in newmust: err_add(ctx.errors, newm.pos, 'CHK_UNDECIDED_MUST', ()) def chk_when(old, new, ctx):
63
64
189
9
54
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_when
chk_when
479
497
479
479
1f32a60d6b3ca95cd2133dcb200f6e1a9e9897ff
bigcode/the-stack
train
5690537536b351b47a77659d
train
function
def err_def_changed(old, new, ctx): err_add(ctx.errors, new.pos, 'CHK_DEF_CHANGED', (new.keyword, new.arg, old.arg))
def err_def_changed(old, new, ctx):
err_add(ctx.errors, new.pos, 'CHK_DEF_CHANGED', (new.keyword, new.arg, old.arg))
p, ctx): old_arg = old.arg if old.keyword == 'presence': old_arg = old.parent.arg err_add(ctx.errors, newp.pos, 'CHK_DEF_REMOVED', (old.keyword, old_arg, old.pos)) def err_def_changed(old, new, ctx):
64
64
35
10
54
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
err_def_changed
err_def_changed
797
799
797
797
8e3a53cfb9a3362c28bab32e6f6302aad577962b
bigcode/the-stack
train
5369c77a9048b912f32c7b8a
train
function
def chk_config(old, new, ctx): if not old.i_config and new.i_config: if statements.is_mandatory_node(new): err_add(ctx.errors, new.pos, 'CHK_MANDATORY_CONFIG', new.arg) elif old.i_config and not new.i_config: err_add(ctx.errors, new.pos, 'CHK_BAD_CONFIG', new.arg)
def chk_config(old, new, ctx):
if not old.i_config and new.i_config: if statements.is_mandatory_node(new): err_add(ctx.errors, new.pos, 'CHK_MANDATORY_CONFIG', new.arg) elif old.i_config and not new.i_config: err_add(ctx.errors, new.pos, 'CHK_BAD_CONFIG', new.arg)
_removed(s, new, ctx) # make sure no if-features are added for s in new.search('if-feature'): if old.search_one('if-feature', arg=s.arg) is None: err_def_added2(s, new, ctx) def chk_config(old, new, ctx):
64
64
77
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_config
chk_config
453
458
453
453
7d3d36a5d50e15b3ce802158aaf8026d13c5ed0c
bigcode/the-stack
train
1ccd8009a994ed89bc238cc3
train
function
def chk_list(old, new, ctx): chk_min_max(old, new, ctx) chk_key(old, new, ctx) chk_unique(old, new, ctx) chk_i_children(old, new, ctx)
def chk_list(old, new, ctx):
chk_min_max(old, new, ctx) chk_key(old, new, ctx) chk_unique(old, new, ctx) chk_i_children(old, new, ctx)
new.search_one('type'), ctx) chk_units(old, new, ctx) chk_min_max(old, new, ctx) def chk_container(old, new, ctx): chk_presence(old, new, ctx) chk_i_children(old, new, ctx) def chk_list(old, new, ctx):
64
64
47
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_list
chk_list
618
622
618
618
2a4200a18192e71f97adaddeb3dc9e7b80b62c6e
bigcode/the-stack
train
a46b2b65ebc927d7033b08db
train
function
def check_update(ctx, newmod): oldpath = os.pathsep.join(ctx.opts.old_path) olddir = os.path.dirname(ctx.opts.check_update_from) if olddir == '': olddir = '.' oldpath += os.pathsep + olddir oldrepo = repository.FileRepository(oldpath, use_env=False) oldctx = context.Context(oldrepo) ...
def check_update(ctx, newmod):
oldpath = os.pathsep.join(ctx.opts.old_path) olddir = os.path.dirname(ctx.opts.check_update_from) if olddir == '': olddir = '.' oldpath += os.pathsep + olddir oldrepo = repository.FileRepository(oldpath, use_env=False) oldctx = context.Context(oldrepo) oldctx.opts = ctx.opts oldc...
: 10, p5, bullet 2)") error.add_error_code( 'CHK_RESTRICTION_CHANGED', 1, "the %s has been illegally restricted" + " (RFC 6020: 10, p5, bullet 3)") error.add_error_code( 'CHK_UNION_TYPES', 1, "the member types in the union have changed") d...
125
125
417
8
117
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
check_update
check_update
139
190
139
139
3188ff7bf3a162cfe1477218dc518e3614327e59
bigcode/the-stack
train
91388db1291e852a4a2510fc
train
function
def chk_min_max(old, new, ctx): oldmin = old.search_one('min-elements') newmin = new.search_one('min-elements') if newmin is None: pass elif oldmin is None: err_def_added(newmin, ctx) elif int(newmin.arg) > int(oldmin.arg): err_def_changed(oldmin, newmin, ctx) oldmax = ol...
def chk_min_max(old, new, ctx):
oldmin = old.search_one('min-elements') newmin = new.search_one('min-elements') if newmin is None: pass elif oldmin is None: err_def_added(newmin, ctx) elif int(newmin.arg) > int(oldmin.arg): err_def_changed(oldmin, newmin, ctx) oldmax = old.search_one('max-elements') ...
mandatory') if newmandatory is not None and newmandatory.arg == 'true': if oldmandatory is None: err_def_added(newmandatory, ctx) elif oldmandatory.arg == 'false': err_def_changed(oldmandatory, newmandatory, ctx) def chk_min_max(old, new, ctx):
64
64
150
10
54
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_min_max
chk_min_max
536
552
536
536
73b5845a1d27361bfec3a2a42aea3dea088536b9
bigcode/the-stack
train
45fab3bc1458cfa269a4b49e
train
function
def chk_leafref(old, new, oldts, newts, ctx): # verify that the path refers to the same leaf if (not hasattr(old.parent, 'i_leafref_ptr') or not hasattr(new.parent, 'i_leafref_ptr')): return if (old.parent.i_leafref_ptr is None or new.parent.i_leafref_ptr is None): return ...
def chk_leafref(old, new, oldts, newts, ctx): # verify that the path refers to the same leaf
if (not hasattr(old.parent, 'i_leafref_ptr') or not hasattr(new.parent, 'i_leafref_ptr')): return if (old.parent.i_leafref_ptr is None or new.parent.i_leafref_ptr is None): return def cmp_node(optr, nptr): if optr.parent is None: return if (optr.i_...
n[1])) def chk_binary(old, new, oldts, newts, ctx): # FIXME: see types.py; we can't check the length return def chk_leafref(old, new, oldts, newts, ctx): # verify that the path refers to the same leaf
64
64
191
28
35
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_leafref
chk_leafref
713
729
713
714
3a379eb37ab7bc261d133710af7bdf8156a56971
bigcode/the-stack
train
b562d09114c1aa72bf3cbe66
train
function
def chk_union(old, new, oldts, newts, ctx): if len(newts.types) != len(oldts.types): err_add(ctx.errors, new.pos, 'CHK_UNION_TYPES', ()) else: for o, n in zip(oldts.types, newts.types): chk_type(o, n, ctx)
def chk_union(old, new, oldts, newts, ctx):
if len(newts.types) != len(oldts.types): err_add(ctx.errors, new.pos, 'CHK_UNION_TYPES', ()) else: for o, n in zip(oldts.types, newts.types): chk_type(o, n, ctx)
n in extra: err_add(ctx.errors, n.pos, 'CHK_DEF_ADDED', ('base', n.arg)) def chk_instance_identifier(old, new, oldts, newts, ctx): # FIXME: return def chk_union(old, new, oldts, newts, ctx):
64
64
71
15
48
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_union
chk_union
748
753
748
748
4042e176fde3f16c6c726a07164bd3f2d18339c3
bigcode/the-stack
train
b490a43460324d31abca6780
train
function
def chk_namespace(oldmod, newmod, ctx): oldns = oldmod.search_one('namespace') newns = newmod.search_one('namespace') if oldns is not None and newns is not None and oldns.arg != newns.arg: err_add(ctx.errors, newmod.pos, 'CHK_INVALID_NAMESPACE', ())
def chk_namespace(oldmod, newmod, ctx):
oldns = oldmod.search_one('namespace') newns = newmod.search_one('namespace') if oldns is not None and newns is not None and oldns.arg != newns.arg: err_add(ctx.errors, newmod.pos, 'CHK_INVALID_NAMESPACE', ())
chk_i_children(oldmod, newmod, ctx) def chk_modulename(oldmod, newmod, ctx): if oldmod.arg != newmod.arg: err_add(ctx.errors, newmod.pos, 'CHK_INVALID_MODULENAME', ()) def chk_namespace(oldmod, newmod, ctx):
63
64
71
11
52
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_namespace
chk_namespace
230
234
230
230
48f21cebc4b82637f11cf501540699252574356d
bigcode/the-stack
train
fbb37c7fb3f4e30a02773160
train
function
def chk_notification(olds, newmod, ctx): news = chk_stmt(olds, newmod, ctx) if news is None: return chk_i_children(olds, news, ctx)
def chk_notification(olds, newmod, ctx):
news = chk_stmt(olds, newmod, ctx) if news is None: return chk_i_children(olds, news, ctx)
_i_children(olds, news, ctx) def chk_rpc(olds, newmod, ctx): news = chk_stmt(olds, newmod, ctx) if news is None: return chk_i_children(olds, news, ctx) def chk_notification(olds, newmod, ctx):
64
64
44
11
53
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_notification
chk_notification
305
309
305
305
e76038fc2e97059aeb51894fa8a568c732392e9e
bigcode/the-stack
train
d226d7a7d456e087a2239a74
train
function
def chk_unique(old, new, ctx): # do not check the unique argument string; check the parsed unique instead # i_unique is not set in groupings; ignore if not hasattr(old, 'i_unique') or not hasattr(new, 'i_unique'): return oldunique = [] for u, l in old.i_unique: oldunique.append((u, [...
def chk_unique(old, new, ctx): # do not check the unique argument string; check the parsed unique instead # i_unique is not set in groupings; ignore
if not hasattr(old, 'i_unique') or not hasattr(new, 'i_unique'): return oldunique = [] for u, l in old.i_unique: oldunique.append((u, [s.arg for s in l])) for u, l in new.i_unique: # check if this unique was present before o = util.keysearch([s.arg for s in l], 1, olduniq...
1] != util.split_identifier(nk)[1]: err_def_changed(oldkey, newkey, ctx) return def chk_unique(old, new, ctx): # do not check the unique argument string; check the parsed unique instead # i_unique is not set in groupings; ignore
64
64
154
38
25
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_unique
chk_unique
587
601
587
589
c62dd2c22ccb826053337ba1299605c115030c95
bigcode/the-stack
train
aa66e2104e4353cd3e86ae44
train
function
def get_latest_revision(m): revs = [r.arg for r in m.search('revision')] revs.sort() if len(revs) > 0: return revs[-1] else: return None
def get_latest_revision(m):
revs = [r.arg for r in m.search('revision')] revs.sort() if len(revs) > 0: return revs[-1] else: return None
: err_add(ctx.errors, newmod.pos, 'CHK_NO_REVISION', ()) elif (oldrev is not None) and (oldrev >= newrev): err_add(ctx.errors, newmod.pos, 'CHK_BAD_REVISION', (newrev, oldrev)) def get_latest_revision(m):
64
64
50
6
58
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
get_latest_revision
get_latest_revision
244
250
244
244
5a0edb18eb62c30fece3eccf4b34c166c3b54946
bigcode/the-stack
train
3066810b3e3a1b3406ab89e1
train
function
def chk_status(old, new, ctx): oldstatus = old.search_one('status') newstatus = new.search_one('status') if oldstatus is None or oldstatus.arg == 'current': # any new status is ok return if newstatus is None: err_add(ctx.errors, new.pos, 'CHK_INVALID_STATUS', ("(i...
def chk_status(old, new, ctx):
oldstatus = old.search_one('status') newstatus = new.search_one('status') if oldstatus is None or oldstatus.arg == 'current': # any new status is ok return if newstatus is None: err_add(ctx.errors, new.pos, 'CHK_INVALID_STATUS', ("(implicit) current", oldstatus.ar...
case': chk_case(oldch, newch, ctx) elif newch.keyword == 'input': chk_input_output(oldch, newch, ctx) elif newch.keyword == 'output': chk_input_output(oldch, newch, ctx) def chk_status(old, new, ctx):
64
64
140
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_status
chk_status
427
439
427
427
cf352719fdb66e8593d79db3d30ec749a8e4ee1d
bigcode/the-stack
train
0d9f8c3ff330b8d258cdff04
train
function
def chk_decimal64(old, new, oldts, newts, ctx): oldbasets = get_base_type(oldts) newbasets = get_base_type(newts) if newbasets.fraction_digits != oldbasets.fraction_digits: err_add(ctx.errors, new.pos, 'CHK_DEF_CHANGED', ('fraction-digits', newts.fraction_digits, old...
def chk_decimal64(old, new, oldts, newts, ctx):
oldbasets = get_base_type(oldts) newbasets = get_base_type(newts) if newbasets.fraction_digits != oldbasets.fraction_digits: err_add(ctx.errors, new.pos, 'CHK_DEF_CHANGED', ('fraction-digits', newts.fraction_digits, oldts.fraction_digits)) # a decimal64 can only ...
(ctx.errors, new.pos, 'CHK_RESTRICTION_CHANGED', 'range') else: err_add(ctx.errors, nts.ranges_pos, 'CHK_DEF_ADDED', ('range', str(nts.ranges))) def chk_decimal64(old, new, oldts, newts, ctx):
64
64
114
16
48
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_decimal64
chk_decimal64
667
675
667
667
ed9254862dfd00bdaa98a44b6e10e1d9704929e9
bigcode/the-stack
train
e9cf8ed873bc0d3a6e65f059
train
function
def chk_revision(oldmod, newmod, ctx): oldrev = get_latest_revision(oldmod) newrev = get_latest_revision(newmod) if newrev is None: err_add(ctx.errors, newmod.pos, 'CHK_NO_REVISION', ()) elif (oldrev is not None) and (oldrev >= newrev): err_add(ctx.errors, newmod.pos, 'CHK_BAD_REVISION',...
def chk_revision(oldmod, newmod, ctx):
oldrev = get_latest_revision(oldmod) newrev = get_latest_revision(newmod) if newrev is None: err_add(ctx.errors, newmod.pos, 'CHK_NO_REVISION', ()) elif (oldrev is not None) and (oldrev >= newrev): err_add(ctx.errors, newmod.pos, 'CHK_BAD_REVISION', (newrev, oldrev))
('namespace') newns = newmod.search_one('namespace') if oldns is not None and newns is not None and oldns.arg != newns.arg: err_add(ctx.errors, newmod.pos, 'CHK_INVALID_NAMESPACE', ()) def chk_revision(oldmod, newmod, ctx):
63
64
95
11
52
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_revision
chk_revision
236
242
236
236
704b6d115966187b4835635e2979eafec3b2fcbc
bigcode/the-stack
train
bca39889e196ac866cc52e6b
train
function
def chk_must(old, new, ctx): oldmust = old.search('must') newmust = new.search('must') # remove all common musts for oldm in old.search('must'): newm = new.search_one('must', arg = oldm.arg) if newm is not None: newmust.remove(newm) oldmust.remove(oldm) if len...
def chk_must(old, new, ctx):
oldmust = old.search('must') newmust = new.search('must') # remove all common musts for oldm in old.search('must'): newm = new.search_one('must', arg = oldm.arg) if newm is not None: newmust.remove(newm) oldmust.remove(oldm) if len(newmust) == 0: # thi...
.is_mandatory_node(new): err_add(ctx.errors, new.pos, 'CHK_MANDATORY_CONFIG', new.arg) elif old.i_config and not new.i_config: err_add(ctx.errors, new.pos, 'CHK_BAD_CONFIG', new.arg) def chk_must(old, new, ctx):
64
64
177
10
54
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_must
chk_must
460
477
460
460
2eba0bee35b07b84231d0c02fe1edab27b1dbce6
bigcode/the-stack
train
da5f767e348daa95803f4ca5
train
function
def chk_string(old, new, oldts, newts, ctx): # FIXME: see types.py; we can't check the length return
def chk_string(old, new, oldts, newts, ctx): # FIXME: see types.py; we can't check the length
return
ts, newts, ctx) def get_base_type(ts): if ts.base is None: return ts else: return get_base_type(ts.base) def chk_string(old, new, oldts, newts, ctx): # FIXME: see types.py; we can't check the length
64
64
32
29
35
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_string
chk_string
683
685
683
684
3b34fdead54eb4270c3c126e1ad553cebf069e49
bigcode/the-stack
train
fc4a187ede1c5539fd53eda9
train
function
def chk_case(old, new, ctx): chk_i_children(old, new, ctx)
def chk_case(old, new, ctx):
chk_i_children(old, new, ctx)
(old, new, ctx) chk_unique(old, new, ctx) chk_i_children(old, new, ctx) def chk_choice(old, new, ctx): chk_mandatory(old, new, ctx) chk_i_children(old, new, ctx) def chk_case(old, new, ctx):
64
64
19
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_case
chk_case
628
629
628
628
f2b6dbfa415bbc8f7f366236f708c4e375a5379e
bigcode/the-stack
train
4e8efb06c7bf330a8229410d
train
function
def chk_choice(old, new, ctx): chk_mandatory(old, new, ctx) chk_i_children(old, new, ctx)
def chk_choice(old, new, ctx):
chk_mandatory(old, new, ctx) chk_i_children(old, new, ctx)
_i_children(old, new, ctx) def chk_list(old, new, ctx): chk_min_max(old, new, ctx) chk_key(old, new, ctx) chk_unique(old, new, ctx) chk_i_children(old, new, ctx) def chk_choice(old, new, ctx):
64
64
30
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_choice
chk_choice
624
626
624
624
8133a1dd12c135e3807aac3215e87274cf12e0f9
bigcode/the-stack
train
3be4995bfd48673c9045b738
train
function
def chk_typedef(olds, newmod, ctx): news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_typedefs) if news is None: return chk_type(olds.search_one('type'), news.search_one('type'), ctx)
def chk_typedef(olds, newmod, ctx):
news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_typedefs) if news is None: return chk_type(olds.search_one('type'), news.search_one('type'), ctx)
((oldbase.i_identity.i_module.i_modulename != newbase.i_identity.i_module.i_modulename) or (oldbase.i_identity.arg != newbase.i_identity.arg)): err_def_changed(oldbase, newbase, ctx) def chk_typedef(olds, newmod, ctx):
64
64
61
12
52
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_typedef
chk_typedef
287
291
287
287
5d5b783d4f59c46564d2fe44498d61e84cb46197
bigcode/the-stack
train
65e26fd7fa57f7be749c514b
train
function
def err_def_added2(new, node, ctx): err_add(ctx.errors, new.pos, 'CHK_DEF_ADDED2', (new.keyword, new.arg, node.keyword, node.arg))
def err_def_added2(new, node, ctx):
err_add(ctx.errors, new.pos, 'CHK_DEF_ADDED2', (new.keyword, new.arg, node.keyword, node.arg))
def err_def_added(new, ctx): new_arg = new.arg if new.keyword == 'presence': new_arg = new.parent.arg err_add(ctx.errors, new.pos, 'CHK_DEF_ADDED', (new.keyword, new_arg)) def err_def_added2(new, node, ctx):
64
64
41
11
53
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
err_def_added2
err_def_added2
786
788
786
786
3683d223eb7c14c79a74e67f847fc758242492e0
bigcode/the-stack
train
3b61fa44a5d62b1405589109
train
class
class CheckUpdatePlugin(plugin.PyangPlugin): def add_opts(self, optparser): optlist = [ optparse.make_option("--check-update-from", metavar="OLDMODULE", dest="check_update_from", help="Verify that ...
class CheckUpdatePlugin(plugin.PyangPlugin):
def add_opts(self, optparser): optlist = [ optparse.make_option("--check-update-from", metavar="OLDMODULE", dest="check_update_from", help="Verify that upgrade from OLDMODULE" \ ...
"""YANG module update check tool This plugin checks if an updated version of a module follows the rules defined in Section 10 of RFC 6020 and Section 11 of RFC 7950. """ import optparse import sys import os import io from pyang import context from pyang import repository from pyang import plugin from pyang import sta...
129
256
1,095
9
120
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
CheckUpdatePlugin
CheckUpdatePlugin
24
137
24
24
ab7643a6eb5037bdb37e62ce8828664242f3957a
bigcode/the-stack
train
443026fa133ad99974ed98d8
train
function
def chk_bits(old, new, oldts, newts, ctx): # verify that all old bits are still in new, with the same positions for name, pos in oldts.bits: n = util.keysearch(name, 0, newts.bits) if n is None: err_add(ctx.errors, new.pos, 'CHK_DEF_REMOVED', ('bit', name, old.pos...
def chk_bits(old, new, oldts, newts, ctx): # verify that all old bits are still in new, with the same positions
for name, pos in oldts.bits: n = util.keysearch(name, 0, newts.bits) if n is None: err_add(ctx.errors, new.pos, 'CHK_DEF_REMOVED', ('bit', name, old.pos)) elif n[1] != pos: err_add(ctx.errors, new.pos, 'CHK_BIT_POSITION_CHANGED', ...
n[1] != val: err_add(ctx.errors, new.pos, 'CHK_ENUM_VALUE_CHANGED', (name, val, n[1])) def chk_bits(old, new, oldts, newts, ctx): # verify that all old bits are still in new, with the same positions
64
64
121
32
32
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_bits
chk_bits
698
707
698
699
f46f958b870912a062ecaec36017ad7111d2f1f7
bigcode/the-stack
train
2c089f8a8a14099e6d5fb680
train
function
def chk_if_feature(old, new, ctx): # make sure no if-features are removed if node is mandatory for s in old.search('if-feature'): if new.search_one('if-feature', arg=s.arg) is None: if statements.is_mandatory_node(new): err_def_removed(s, new, ctx) # make sure no if-feat...
def chk_if_feature(old, new, ctx): # make sure no if-features are removed if node is mandatory
for s in old.search('if-feature'): if new.search_one('if-feature', arg=s.arg) is None: if statements.is_mandatory_node(new): err_def_removed(s, new, ctx) # make sure no if-features are added for s in new.search('if-feature'): if old.search_one('if-feature', arg=s...
status.arg == 'obsolete' and newstatus.arg != 'obsolete')): err_add(ctx.errors, newstatus.pos, 'CHK_INVALID_STATUS', (newstatus.arg, oldstatus.arg)) def chk_if_feature(old, new, ctx): # make sure no if-features are removed if node is mandatory
64
64
119
25
39
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_if_feature
chk_if_feature
441
451
441
442
76639dc87ee7fa5b8115fa1398f0d7c49cd87522
bigcode/the-stack
train
db02d2af1d3e5e8ad6d25c42
train
function
def chk_binary(old, new, oldts, newts, ctx): # FIXME: see types.py; we can't check the length return
def chk_binary(old, new, oldts, newts, ctx): # FIXME: see types.py; we can't check the length
return
)) elif n[1] != pos: err_add(ctx.errors, new.pos, 'CHK_BIT_POSITION_CHANGED', (name, pos, n[1])) def chk_binary(old, new, oldts, newts, ctx): # FIXME: see types.py; we can't check the length
64
64
32
29
35
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_binary
chk_binary
709
711
709
710
42e1574a11a3c1537d7b37290372afb96797806e
bigcode/the-stack
train
4bba8a11a2382224fe8067ee
train
function
def chk_range(old, new, oldts, newts, ctx): ots = old.i_type_spec nts = new.i_type_spec if not isinstance(nts, types.RangeTypeSpec): return if isinstance(ots, types.RangeTypeSpec): tmperrors = [] types.validate_ranges(tmperrors, new.pos, ots.ranges, new) if tmperrors: ...
def chk_range(old, new, oldts, newts, ctx):
ots = old.i_type_spec nts = new.i_type_spec if not isinstance(nts, types.RangeTypeSpec): return if isinstance(ots, types.RangeTypeSpec): tmperrors = [] types.validate_ranges(tmperrors, new.pos, ots.ranges, new) if tmperrors: err_add(ctx.errors, new.pos, 'CHK_R...
_type_func[oldts.name](old, new, oldts, newts, ctx) def chk_integer(old, new, oldts, newts, ctx): chk_range(old, new, oldts, newts, ctx) def chk_range(old, new, oldts, newts, ctx):
64
64
137
15
49
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_range
chk_range
652
665
652
652
ebf3ecded42aa89a95d625ab6e0e5fdc6f044852
bigcode/the-stack
train
63256a2c9304bfbaa1c38e35
train
function
def get_base_type(ts): if ts.base is None: return ts else: return get_base_type(ts.base)
def get_base_type(ts):
if ts.base is None: return ts else: return get_base_type(ts.base)
_add(ctx.errors, new.pos, 'CHK_DEF_CHANGED', ('fraction-digits', newts.fraction_digits, oldts.fraction_digits)) # a decimal64 can only be restricted with range chk_range(old, new, oldts, newts, ctx) def get_base_type(ts):
64
64
28
6
58
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
get_base_type
get_base_type
677
681
677
677
c716a6234080f47bfc83d7a5e83571ee113fd606
bigcode/the-stack
train
4e458be2fbc828dd5130e4e8
train
function
def chk_identityref(old, new, oldts, newts, ctx): # verify that the bases are the same extra = [n for n in newts.idbases] for oidbase in oldts.idbases: for nidbase in newts.idbases: if (nidbase.i_module.i_modulename == oidbase.i_module.i_modulename and ...
def chk_identityref(old, new, oldts, newts, ctx): # verify that the bases are the same
extra = [n for n in newts.idbases] for oidbase in oldts.idbases: for nidbase in newts.idbases: if (nidbase.i_module.i_modulename == oidbase.i_module.i_modulename and nidbase.arg.split(':')[-1] == oidbase.arg.split(':')[-1]): extra.remov...
err_add(ctx.errors, new.pos, 'CHK_LEAFREF_PATH_CHANGED', ()) cmp_node(old.parent.i_leafref_ptr[0], new.parent.i_leafref_ptr[0]) def chk_identityref(old, new, oldts, newts, ctx): # verify that the bases are the same
64
64
137
26
38
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_identityref
chk_identityref
731
742
731
732
fe771e4c18807acc4706010d6838c485a55d1e16
bigcode/the-stack
train
9741bcac274e44eaa6f996ed
train
function
def chk_type(old, new, ctx): oldts = old.i_type_spec newts = new.i_type_spec if oldts is None or newts is None: return # verify that the base type is the same if oldts.name != newts.name: err_add(ctx.errors, new.pos, 'CHK_BASE_TYPE_CHANGED', (oldts.name, newts.name)) ...
def chk_type(old, new, ctx):
oldts = old.i_type_spec newts = new.i_type_spec if oldts is None or newts is None: return # verify that the base type is the same if oldts.name != newts.name: err_add(ctx.errors, new.pos, 'CHK_BASE_TYPE_CHANGED', (oldts.name, newts.name)) return # check t...
(old, new, ctx) chk_i_children(old, new, ctx) def chk_case(old, new, ctx): chk_i_children(old, new, ctx) def chk_input_output(old, new, ctx): chk_i_children(old, new, ctx) def chk_type(old, new, ctx):
64
64
130
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_type
chk_type
634
647
634
634
c44f510ce6c2ca79fb275d67b322a4179961a0bb
bigcode/the-stack
train
b1d378a3cc3e979ff5ce92d4
train
function
def chk_rpc(olds, newmod, ctx): news = chk_stmt(olds, newmod, ctx) if news is None: return chk_i_children(olds, news, ctx)
def chk_rpc(olds, newmod, ctx):
news = chk_stmt(olds, newmod, ctx) if news is None: return chk_i_children(olds, news, ctx)
def chk_grouping(olds, newmod, ctx): news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_groupings) if news is None: return chk_i_children(olds, news, ctx) def chk_rpc(olds, newmod, ctx):
64
64
44
11
53
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_rpc
chk_rpc
299
303
299
299
b62f9b90972c91cccaffd0b70c7fa546651119bc
bigcode/the-stack
train
99a5ca410b3aecb05a7244a5
train
function
def chk_units(old, new, ctx): oldunits = old.search_one('units') if oldunits is None: return newunits = new.search_one('units') if newunits is None: err_def_removed(oldunits, new, ctx) elif newunits.arg != oldunits.arg: err_def_changed(oldunits, newunits, ctx)
def chk_units(old, new, ctx):
oldunits = old.search_one('units') if oldunits is None: return newunits = new.search_one('units') if newunits is None: err_def_removed(oldunits, new, ctx) elif newunits.arg != oldunits.arg: err_def_changed(oldunits, newunits, ctx)
neww in newwhen: err_add(ctx.errors, neww.pos, 'CHK_NEW_WHEN', ()) else: for neww in newwhen: err_add(ctx.errors, neww.pos, 'CHK_UNDECIDED_WHEN', ()) def chk_units(old, new, ctx):
63
64
79
9
54
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_units
chk_units
499
507
499
499
179da431fdb34455350f59a796c065b01179393b
bigcode/the-stack
train
18709f7397578d4ef5a5978f
train
function
def chk_i_children(old, new, ctx): for oldch in old.i_children: chk_child(oldch, new, ctx) old_child_args = [oldch.arg for oldch in old.i_children] added_new_children = [new_child for new_child in new.i_children if new_child.arg not in old_child_args] for newch in added_new_children: if...
def chk_i_children(old, new, ctx):
for oldch in old.i_children: chk_child(oldch, new, ctx) old_child_args = [oldch.arg for oldch in old.i_children] added_new_children = [new_child for new_child in new.i_children if new_child.arg not in old_child_args] for newch in added_new_children: if statements.is_mandatory_node(newch...
.keyword, arg = olds.arg) if news is None: err_def_removed(olds, newp, ctx) return None chk_status(olds, news, ctx) chk_if_feature(olds, news, ctx) return news def chk_i_children(old, new, ctx):
64
64
112
10
53
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_i_children
chk_i_children
378
386
378
378
65f68b824b23e59d590ea5aca8c9a5e65d0da9c9
bigcode/the-stack
train
3cd62c379b56dc47da4301cf
train
function
def chk_enumeration(old, new, oldts, newts, ctx): # verify that all old enums are still in new, with the same values for name, val in oldts.enums: n = util.keysearch(name, 0, newts.enums) if n is None: err_add(ctx.errors, new.pos, 'CHK_DEF_REMOVED', ('enum', name,...
def chk_enumeration(old, new, oldts, newts, ctx): # verify that all old enums are still in new, with the same values
for name, val in oldts.enums: n = util.keysearch(name, 0, newts.enums) if n is None: err_add(ctx.errors, new.pos, 'CHK_DEF_REMOVED', ('enum', name, old.pos)) elif n[1] != val: err_add(ctx.errors, new.pos, 'CHK_ENUM_VALUE_CHANGED', ...
_string(old, new, oldts, newts, ctx): # FIXME: see types.py; we can't check the length return def chk_enumeration(old, new, oldts, newts, ctx): # verify that all old enums are still in new, with the same values
64
64
123
34
29
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_enumeration
chk_enumeration
687
696
687
688
fcb92be4a8d4a0a60d28aa7ad916cd086758a323
bigcode/the-stack
train
dcacfe80b3ba8d64fd05e9dd
train
function
def err_def_added(new, ctx): new_arg = new.arg if new.keyword == 'presence': new_arg = new.parent.arg err_add(ctx.errors, new.pos, 'CHK_DEF_ADDED', (new.keyword, new_arg))
def err_def_added(new, ctx):
new_arg = new.arg if new.keyword == 'presence': new_arg = new.parent.arg err_add(ctx.errors, new.pos, 'CHK_DEF_ADDED', (new.keyword, new_arg))
'bits': chk_bits, 'binary': chk_binary, 'leafref': chk_leafref, 'identityref': chk_identityref, 'instance-identifier': chk_instance_identifier, 'empty': chk_dummy, 'union': chk_union} def err_def_added(new, ctx):
64
64
53
8
56
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
err_def_added
err_def_added
780
784
780
780
21a39f1a64aba008ce5dd095451118ece6ef4bcc
bigcode/the-stack
train
acf95b4958f51448916da093
train
function
def chk_leaf_list(old, new, ctx): chk_type(old.search_one('type'), new.search_one('type'), ctx) chk_units(old, new, ctx) chk_min_max(old, new, ctx)
def chk_leaf_list(old, new, ctx):
chk_type(old.search_one('type'), new.search_one('type'), ctx) chk_units(old, new, ctx) chk_min_max(old, new, ctx)
chk_leaf(old, new, ctx): chk_type(old.search_one('type'), new.search_one('type'), ctx) chk_units(old, new, ctx) chk_default(old, new, ctx) chk_mandatory(old, new, ctx) def chk_leaf_list(old, new, ctx):
64
64
46
10
54
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_leaf_list
chk_leaf_list
609
612
609
609
adbfe32b68d526e27a4476f88c64487b3cba27be
bigcode/the-stack
train
07e5a9444141789eb78aaecd
train
function
def chk_grouping(olds, newmod, ctx): news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_groupings) if news is None: return chk_i_children(olds, news, ctx)
def chk_grouping(olds, newmod, ctx):
news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_groupings) if news is None: return chk_i_children(olds, news, ctx)
, ctx): news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_typedefs) if news is None: return chk_type(olds.search_one('type'), news.search_one('type'), ctx) def chk_grouping(olds, newmod, ctx):
64
64
53
12
52
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_grouping
chk_grouping
293
297
293
293
d8d171ba4eda4a865d075671b885cb5d09d8a0dc
bigcode/the-stack
train
2ff5d13b4be7c7c21e9f1127
train
function
def chk_extension(olds, newmod, ctx): news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_extensions) if news is None: return oldarg = olds.search_one('argument') newarg = news.search_one('argument') if oldarg is None and newarg is not None: err_def_added(newarg, ctx) elif ol...
def chk_extension(olds, newmod, ctx):
news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_extensions) if news is None: return oldarg = olds.search_one('argument') newarg = news.search_one('argument') if oldarg is None and newarg is not None: err_def_added(newarg, ctx) elif oldarg is not None and newarg is None: ...
is None: return chk_i_children(olds, news, ctx) def chk_notification(olds, newmod, ctx): news = chk_stmt(olds, newmod, ctx) if news is None: return chk_i_children(olds, news, ctx) def chk_extension(olds, newmod, ctx):
72
72
243
11
61
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_extension
chk_extension
311
330
311
311
d775bcda92cbd5b8cf1b8b085acdcab915be5dbd
bigcode/the-stack
train
3af152452dfca9777be4c2de
train
function
def chk_container(old, new, ctx): chk_presence(old, new, ctx) chk_i_children(old, new, ctx)
def chk_container(old, new, ctx):
chk_presence(old, new, ctx) chk_i_children(old, new, ctx)
_mandatory(old, new, ctx) def chk_leaf_list(old, new, ctx): chk_type(old.search_one('type'), new.search_one('type'), ctx) chk_units(old, new, ctx) chk_min_max(old, new, ctx) def chk_container(old, new, ctx):
64
64
28
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_container
chk_container
614
616
614
614
976bbe7c7a49bb4ed3603cff34a8f1c0679867ae
bigcode/the-stack
train
e220d66d940fb73adfa75b3a
train
function
def chk_identity(olds, newmod, ctx): news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_identities) if news is None: return # make sure the base isn't changed (other than syntactically) oldbases = olds.search('base') newbases = news.search('base') if newmod.i_version == '1.1': ...
def chk_identity(olds, newmod, ctx):
news = chk_stmt_definitions(olds, newmod, ctx, newmod.i_identities) if news is None: return # make sure the base isn't changed (other than syntactically) oldbases = olds.search('base') newbases = news.search('base') if newmod.i_version == '1.1': old_ids = [oldbase.i_identity.arg ...
(ctx.errors, newmod.pos, 'CHK_BAD_REVISION', (newrev, oldrev)) def get_latest_revision(m): revs = [r.arg for r in m.search('revision')] revs.sort() if len(revs) > 0: return revs[-1] else: return None def chk_feature(olds, newmod, ctx): chk_stmt_definitions(olds, newmod, ctx, newmod...
110
110
368
11
99
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_identity
chk_identity
255
285
255
255
4c91e9ddb653f6a7334c7d60075f2f2e8dc29e9b
bigcode/the-stack
train
9abf7469780eb04d4a379ca8
train
function
def chk_feature(olds, newmod, ctx): chk_stmt_definitions(olds, newmod, ctx, newmod.i_features)
def chk_feature(olds, newmod, ctx):
chk_stmt_definitions(olds, newmod, ctx, newmod.i_features)
oldrev)) def get_latest_revision(m): revs = [r.arg for r in m.search('revision')] revs.sort() if len(revs) > 0: return revs[-1] else: return None def chk_feature(olds, newmod, ctx):
64
64
29
11
52
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_feature
chk_feature
252
253
252
252
caf5cce22df8b4ba384390fd3d383af5f6c3fd01
bigcode/the-stack
train
4b4002b59b8bc12eaba16c11
train
function
def chk_stmt(olds, newp, ctx): news = newp.search_one(olds.keyword, arg = olds.arg) if news is None: err_def_removed(olds, newp, ctx) return None chk_status(olds, news, ctx) chk_if_feature(olds, news, ctx) return news
def chk_stmt(olds, newp, ctx):
news = newp.search_one(olds.keyword, arg = olds.arg) if news is None: err_def_removed(olds, newp, ctx) return None chk_status(olds, news, ctx) chk_if_feature(olds, news, ctx) return news
= definitions[olds.arg] if news is None: err_def_removed(olds, newp, ctx) return None chk_status(olds, news, ctx) chk_if_feature(olds, news, ctx) return news def chk_stmt(olds, newp, ctx):
64
64
74
11
52
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_stmt
chk_stmt
369
376
369
369
4483bdbf3c3158b79b0363d696d0a2bd45bf940b
bigcode/the-stack
train
71b880fce449841e34bb6621
train
function
def chk_default(old, new, ctx): newdefault = new.search_one('default') olddefault = old.search_one('default') if olddefault is None and newdefault is None: return if olddefault is not None and newdefault is None: err_def_removed(olddefault, new, ctx) elif olddefault is None and newde...
def chk_default(old, new, ctx):
newdefault = new.search_one('default') olddefault = old.search_one('default') if olddefault is None and newdefault is None: return if olddefault is not None and newdefault is None: err_def_removed(olddefault, new, ctx) elif olddefault is None and newdefault is not None: # def...
None: return newunits = new.search_one('units') if newunits is None: err_def_removed(oldunits, new, ctx) elif newunits.arg != oldunits.arg: err_def_changed(oldunits, newunits, ctx) def chk_default(old, new, ctx):
64
64
195
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_default
chk_default
509
525
509
509
ff480e5414ef35468eef8a231a6a8cbedfff5fdd
bigcode/the-stack
train
616404bf21102f4657f4ffaa
train
function
def chk_mandatory(old, new, ctx): oldmandatory = old.search_one('mandatory') newmandatory = new.search_one('mandatory') if newmandatory is not None and newmandatory.arg == 'true': if oldmandatory is None: err_def_added(newmandatory, ctx) elif oldmandatory.arg == 'false': ...
def chk_mandatory(old, new, ctx):
oldmandatory = old.search_one('mandatory') newmandatory = new.search_one('mandatory') if newmandatory is not None and newmandatory.arg == 'true': if oldmandatory is None: err_def_added(newmandatory, ctx) elif oldmandatory.arg == 'false': err_def_changed(oldmandatory, ...
oldtype.i_typedef.i_default_str != newdefault.arg): err_add(ctx.errors, newdefault.pos, 'CHK_IMPLICIT_DEFAULT', ()) elif olddefault.arg != newdefault.arg: err_def_changed(olddefault, newdefault, ctx) def chk_mandatory(old, new, ctx):
64
64
83
11
53
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_mandatory
chk_mandatory
527
534
527
527
358a48d903f3411883dc39c475d18083a6aec60a
bigcode/the-stack
train
74cd49e406c6df156896fe20
train
function
def chk_stmt_definitions(olds, newp, ctx, definitions): news = None if olds.arg in definitions: news = definitions[olds.arg] if news is None: err_def_removed(olds, newp, ctx) return None chk_status(olds, news, ctx) chk_if_feature(olds, news, ctx) return news
def chk_stmt_definitions(olds, newp, ctx, definitions):
news = None if olds.arg in definitions: news = definitions[olds.arg] if news is None: err_def_removed(olds, newp, ctx) return None chk_status(olds, news, ctx) chk_if_feature(olds, news, ctx) return news
for olds in oldmod.search('augment', arg=t): err_def_removed(olds, newmod, ctx) else: for oldch in targets[t]: chk_children(oldch, newchs, newmod, ctx) def chk_stmt_definitions(olds, newp, ctx, definitions):
64
64
82
15
49
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_stmt_definitions
chk_stmt_definitions
358
367
358
358
4c49a68df4f15a848db7295702b9e3da79ad2847
bigcode/the-stack
train
7e3471431e29b308aa60c535
train
function
def chk_modulename(oldmod, newmod, ctx): if oldmod.arg != newmod.arg: err_add(ctx.errors, newmod.pos, 'CHK_INVALID_MODULENAME', ())
def chk_modulename(oldmod, newmod, ctx):
if oldmod.arg != newmod.arg: err_add(ctx.errors, newmod.pos, 'CHK_INVALID_MODULENAME', ())
, newmod, ctx) for olds in oldmod.search('extension'): chk_extension(olds, newmod, ctx) chk_augment(oldmod, newmod, ctx) chk_i_children(oldmod, newmod, ctx) def chk_modulename(oldmod, newmod, ctx):
64
64
41
13
51
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_modulename
chk_modulename
226
228
226
226
67c370542cadfa7ddd64fd73da65ecab4eee423d
bigcode/the-stack
train
f3fcc82bbda8fc5937b9ef42
train
function
def chk_augment(oldmod, newmod, ctx): # group augment of same target together, and compare with all # augment of same target in newmod targets = {} for olds in oldmod.search('augment'): if olds.arg in targets: targets[olds.arg].extend(olds.i_children) else: target...
def chk_augment(oldmod, newmod, ctx): # group augment of same target together, and compare with all # augment of same target in newmod
targets = {} for olds in oldmod.search('augment'): if olds.arg in targets: targets[olds.arg].extend(olds.i_children) else: targets[olds.arg] = list(olds.i_children) # copy for t in targets: newchs = [] # this is not quite correct; it should be ok to ch...
elif (oldyin is not None and newyin is not None and newyin.arg != oldyin.arg): err_def_changed(oldyin, newyin, ctx) def chk_augment(oldmod, newmod, ctx): # group augment of same target together, and compare with all # augment of same target in newmod
72
72
241
36
36
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_augment
chk_augment
333
356
333
335
802b44bd9da292ba598ce9ece609a08b45da8d4e
bigcode/the-stack
train
36099aaf54b9bb79acf9f502
train
function
def chk_leaf(old, new, ctx): chk_type(old.search_one('type'), new.search_one('type'), ctx) chk_units(old, new, ctx) chk_default(old, new, ctx) chk_mandatory(old, new, ctx)
def chk_leaf(old, new, ctx):
chk_type(old.search_one('type'), new.search_one('type'), ctx) chk_units(old, new, ctx) chk_default(old, new, ctx) chk_mandatory(old, new, ctx)
: # check if this unique was present before o = util.keysearch([s.arg for s in l], 1, oldunique) if o is not None: oldunique.remove(o) else: err_def_added(u, ctx) def chk_leaf(old, new, ctx):
64
64
55
9
55
JieZhang0822/pyang
pyang/plugins/check_update.py
Python
chk_leaf
chk_leaf
603
607
603
603
59253876ff354ec41b762105deb4e402e1543f83
bigcode/the-stack
train
4fe3da50aef4d25fa0efca77
train
class
class PostCategoriaAPI(Resource): def get(self, id): cur = mysql.connection.cursor() cur.execute('''select p.titulo, c.nombre as categoria from myblog.post as p left join myblog.categoria as c on p.idcategoria = c.idcategoria where p.idcategoria= ''' + id ) result = cur.fetchall() return str(result...
class PostCategoriaAPI(Resource):
def get(self, id): cur = mysql.connection.cursor() cur.execute('''select p.titulo, c.nombre as categoria from myblog.post as p left join myblog.categoria as c on p.idcategoria = c.idcategoria where p.idcategoria= ''' + id ) result = cur.fetchall() return str(result)
funcuionalidad de nuestra app api = Api(app) app.config['MYSQL_USER'] = 'root' app.config['MYSQL_PASSWORD'] = 'rootcodigo8' app.config['MYSQL_DB'] = 'myblog' app.config['MYSQL_CURSORCLASS'] = 'DictCursor' class PostCategoriaAPI(Resource):
64
64
77
6
58
jolurn/my-blog
app.py
Python
PostCategoriaAPI
PostCategoriaAPI
16
21
16
16
019fe1bd9064fc778dae7ef032713210f7fe9c7a
bigcode/the-stack
train
ec6cadab8a95f68aa25b5f28
train
class
class PostAPI(Resource): def get(self): cur = mysql.connection.cursor() cur.execute("select * from post") result = cur.fetchall() return str(result)
class PostAPI(Resource):
def get(self): cur = mysql.connection.cursor() cur.execute("select * from post") result = cur.fetchall() return str(result)
categoria where p.idcategoria= ''' + id ) result = cur.fetchall() return str(result) class CategoriaAPI(Resource): def get(self): cur = mysql.connection.cursor() cur.execute("select * from categoria") result = cur.fetchall() return str(result) class PostAPI(Resource):
64
64
38
5
59
jolurn/my-blog
app.py
Python
PostAPI
PostAPI
30
35
30
30
d1e2725c681fd26653487cbb11d6fb4367691f98
bigcode/the-stack
train
4612d0ee3ddc7d25855d5c0f
train
class
class CategoriaAPI(Resource): def get(self): cur = mysql.connection.cursor() cur.execute("select * from categoria") result = cur.fetchall() return str(result)
class CategoriaAPI(Resource):
def get(self): cur = mysql.connection.cursor() cur.execute("select * from categoria") result = cur.fetchall() return str(result)
.connection.cursor() cur.execute('''select p.titulo, c.nombre as categoria from myblog.post as p left join myblog.categoria as c on p.idcategoria = c.idcategoria where p.idcategoria= ''' + id ) result = cur.fetchall() return str(result) class CategoriaAPI(Resource):
64
64
38
5
59
jolurn/my-blog
app.py
Python
CategoriaAPI
CategoriaAPI
23
28
23
23
c4bfcb693cfc41f344439c3f5fc95bf98f6da2f9
bigcode/the-stack
train
60d1b827b70d6846ba3957a6
train
class
class TinkoffCreditRequestException(Exception): pass
class TinkoffCreditRequestException(Exception):
pass
from typing import Union import requests from django.conf import settings from banking.base import Bank class TinkoffCreditRequestException(Exception):
29
64
12
9
19
tough-dev-school/education-backend
src/tinkoff/credit.py
Python
TinkoffCreditRequestException
TinkoffCreditRequestException
9
10
9
9
a0264e15bdd2826e798f1d58ba07f3d39f1b5588
bigcode/the-stack
train
0211d8aa5a134c6511b87ee5
train
class
class TinkoffCredit(Bank): name = 'Т.Кредит' def get_initial_payment_url(self) -> str: result = self.call( url=self.get_create_order_url(), payload={ 'shopId': settings.TINKOFF_CREDIT_SHOP_ID, 'showcaseId': settings.TINKOFF_CREDIT_SHOWCASE_ID, ...
class TinkoffCredit(Bank):
name = 'Т.Кредит' def get_initial_payment_url(self) -> str: result = self.call( url=self.get_create_order_url(), payload={ 'shopId': settings.TINKOFF_CREDIT_SHOP_ID, 'showcaseId': settings.TINKOFF_CREDIT_SHOWCASE_ID, 'sum': self.pr...
from typing import Union import requests from django.conf import settings from banking.base import Bank class TinkoffCreditRequestException(Exception): pass class TinkoffCredit(Bank):
40
127
424
8
31
tough-dev-school/education-backend
src/tinkoff/credit.py
Python
TinkoffCredit
TinkoffCredit
13
71
13
13
03f64de09ac2d9eb9e1cf6e236babfef4095c1e9
bigcode/the-stack
train
5b8007a882434e720da22c8d
train
function
def load_NeuroMarketing(path): """ :param path: path to NeuroMarketing dataset :return: numpy array of data and labels """ original_name = [] for file in os.listdir(path + '25-users/'): if re.search('\.txt$', file): original_name.append(file[:-4]) name = sort_Neu...
def load_NeuroMarketing(path):
""" :param path: path to NeuroMarketing dataset :return: numpy array of data and labels """ original_name = [] for file in os.listdir(path + '25-users/'): if re.search('\.txt$', file): original_name.append(file[:-4]) name = sort_NeuroMarketing(original_name) ...
(1, 9)] mat_list_2 = [path + 's' + str(x) for x in range(10, 33)] data, labels = data_integration(mat_list_1 + mat_list_2) return data, labels def load_NeuroMarketing(path):
64
64
203
8
55
LiJiaqi96/DEEG
deeg/access.py
Python
load_NeuroMarketing
load_NeuroMarketing
73
95
73
73
102d435264189b9dd1d1f0313979004b7e021367
bigcode/the-stack
train
2f0f202f1fe7c12ca380a850
train
function
def load_data(fname, *, preload=False, verbose=None, **kwargs): """ :param fname: Files you are gonna read :param mne: Indicate if the file is mne-supported :return: numpy array of eeg data """ ext = "".join(Path(fname).suffixes) if ext in supported: if ext == ".csv": ...
def load_data(fname, *, preload=False, verbose=None, **kwargs):
""" :param fname: Files you are gonna read :param mne: Indicate if the file is mne-supported :return: numpy array of eeg data """ ext = "".join(Path(fname).suffixes) if ext in supported: if ext == ".csv": return supported[ext](fname) else: ra...
bin": read_raw, ".data": read_raw, ".sqd": read_raw, ".con": read_raw, ".ds": read_raw, ".txt": read_raw, ".csv": read_csv } def load_data(fname, *, preload=False, verbose=None, **kwargs):
64
64
124
15
49
LiJiaqi96/DEEG
deeg/access.py
Python
load_data
load_data
37
50
37
37
79f5b609c2fef733aec07c5690de1568c1659e50
bigcode/the-stack
train
f558c0be5ddd02051c5be656
train
function
def load_SEED(folder_path, feature_name, frequency_band): ''' :param folder_path: directory of ExtractedFeatures :param feature_name: feature name, for example 'de_LDS', 'asm_LDS' etc. Take de_LDS1 as an example: the demension is (62, 235, 5), 62 for 62 channels, 235 for 235 seconds and 5 for 5 different...
def load_SEED(folder_path, feature_name, frequency_band):
''' :param folder_path: directory of ExtractedFeatures :param feature_name: feature name, for example 'de_LDS', 'asm_LDS' etc. Take de_LDS1 as an example: the demension is (62, 235, 5), 62 for 62 channels, 235 for 235 seconds and 5 for 5 different frequency bands. :param frequency_band: the input ban...
'25-users/'): if re.search('\.txt$', file): original_name.append(file[:-4]) name = sort_NeuroMarketing(original_name) data = [] label = [] for i in name: dataFile = open(path + '25-users/' + i + '.txt') data.append(np.array([eval(i) for i in dataFile.read().s...
169
169
564
13
155
LiJiaqi96/DEEG
deeg/access.py
Python
load_SEED
load_SEED
97
147
97
97
85e539883abc0ae2de006e443890c5bec4828d70
bigcode/the-stack
train
eb136ff51c001511a557224f
train
function
def load_DEAP(path): """ :param path: path to DEAP dataset DEAP dataset contains 32 participant files so the path points to the folder that stores those files. :return: numpy array of data and labels """ if path[-1] != "/": path += "/" mat_list_1 = [path + 's0' + str(x) for x...
def load_DEAP(path):
""" :param path: path to DEAP dataset DEAP dataset contains 32 participant files so the path points to the folder that stores those files. :return: numpy array of data and labels """ if path[-1] != "/": path += "/" mat_list_1 = [path + 's0' + str(x) for x in range(1, 9)] ...
= raw[:] return data """ Main package for loading existing public datasets: 1. DEAP 2. SEED 3. DREAMER 4. NeuroMarketing to numpy array with dimension (p, m, e). """ def load_DEAP(path):
64
64
144
6
58
LiJiaqi96/DEEG
deeg/access.py
Python
load_DEAP
load_DEAP
60
71
60
60
b936b9230342766788505812fb3f2f6e98fdf201
bigcode/the-stack
train
31247b83523caed047267670
train
function
def ConvFactory(data, num_filter, kernel, stride=(1,1), pad=(0, 0), name=None, suffix=''): conv = mx.symbol.Convolution(data=data, workspace=512, num_filter=num_filter, kernel=kernel, stride=stride, pad=pad, name='conv_%s%s' %(name, suffix)) bn = mx.symbol.BatchNorm(data=conv, name='bn_%s%s' %(name, suffix)) ...
def ConvFactory(data, num_filter, kernel, stride=(1,1), pad=(0, 0), name=None, suffix=''):
conv = mx.symbol.Convolution(data=data, workspace=512, num_filter=num_filter, kernel=kernel, stride=stride, pad=pad, name='conv_%s%s' %(name, suffix)) bn = mx.symbol.BatchNorm(data=conv, name='bn_%s%s' %(name, suffix)) act = mx.symbol.Activation(data=bn, act_type='relu', name='relu_%s%s' %(name, suffix)) ...
""" An variant of inception-bn.py for the full imagenet dataset with >= 21841 classes """ import find_mxnet import mxnet as mx def ConvFactory(data, num_filter, kernel, stride=(1,1), pad=(0, 0), name=None, suffix=''):
63
64
127
29
33
vkuznet/mxnet
example/image-classification/symbol_inception-bn-full.py
Python
ConvFactory
ConvFactory
8
12
8
8
a97f754f981da0c26bd943ae820882dbd62ed146
bigcode/the-stack
train
db73fd959853a5d9eddb4fcd
train
function
def InceptionFactoryA(data, num_1x1, num_3x3red, num_3x3, num_d3x3red, num_d3x3, pool, proj, name): # 1x1 c1x1 = ConvFactory(data=data, num_filter=num_1x1, kernel=(1, 1), name=('%s_1x1' % name)) # 3x3 reduce + 3x3 c3x3r = ConvFactory(data=data, num_filter=num_3x3red, kernel=(1, 1), name=('%s_3x3' % name...
def InceptionFactoryA(data, num_1x1, num_3x3red, num_3x3, num_d3x3red, num_d3x3, pool, proj, name): # 1x1
c1x1 = ConvFactory(data=data, num_filter=num_1x1, kernel=(1, 1), name=('%s_1x1' % name)) # 3x3 reduce + 3x3 c3x3r = ConvFactory(data=data, num_filter=num_3x3red, kernel=(1, 1), name=('%s_3x3' % name), suffix='_reduce') c3x3 = ConvFactory(data=c3x3r, num_filter=num_3x3, kernel=(3, 3), pad=(1, 1), name=('...
conv = mx.symbol.Convolution(data=data, workspace=512, num_filter=num_filter, kernel=kernel, stride=stride, pad=pad, name='conv_%s%s' %(name, suffix)) bn = mx.symbol.BatchNorm(data=conv, name='bn_%s%s' %(name, suffix)) act = mx.symbol.Activation(data=bn, act_type='relu', name='relu_%s%s' %(name, suffix)) r...
149
149
497
52
96
vkuznet/mxnet
example/image-classification/symbol_inception-bn-full.py
Python
InceptionFactoryA
InceptionFactoryA
14
29
14
15
93c5d6ad0dcc0c396e5ab6c49a66d05f483a1f22
bigcode/the-stack
train
d7d37d6150d99ceedfcd0dd8
train
function
def get_symbol(num_classes = 21841): # data data = mx.symbol.Variable(name="data") # stage 1 conv1 = ConvFactory(data=data, num_filter=96, kernel=(7, 7), stride=(2, 2), pad=(3, 3), name='conv1') pool1 = mx.symbol.Pooling(data=conv1, kernel=(3, 3), stride=(2, 2), name='pool1', pool_type='max') # ...
def get_symbol(num_classes = 21841): # data
data = mx.symbol.Variable(name="data") # stage 1 conv1 = ConvFactory(data=data, num_filter=96, kernel=(7, 7), stride=(2, 2), pad=(3, 3), name='conv1') pool1 = mx.symbol.Pooling(data=conv1, kernel=(3, 3), stride=(2, 2), name='pool1', pool_type='max') # stage 2 conv2red = ConvFactory(data=pool1, n...
3x3r, num_filter=num_d3x3, kernel=(3, 3), pad=(1, 1), stride=(1, 1), name=('%s_double_3x3_0' % name)) cd3x3 = ConvFactory(data=cd3x3, num_filter=num_d3x3, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name=('%s_double_3x3_1' % name)) # pool + proj pooling = mx.symbol.Pooling(data=data, kernel=(3, 3), stride=(2,...
215
215
719
14
200
vkuznet/mxnet
example/image-classification/symbol_inception-bn-full.py
Python
get_symbol
get_symbol
45
74
45
46
ad4f23482a50286a1e3f7788be8ada906b469aeb
bigcode/the-stack
train
60cc60574f6e4ceeef38cbe8
train
function
def InceptionFactoryB(data, num_3x3red, num_3x3, num_d3x3red, num_d3x3, name): # 3x3 reduce + 3x3 c3x3r = ConvFactory(data=data, num_filter=num_3x3red, kernel=(1, 1), name=('%s_3x3' % name), suffix='_reduce') c3x3 = ConvFactory(data=c3x3r, num_filter=num_3x3, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name=(...
def InceptionFactoryB(data, num_3x3red, num_3x3, num_d3x3red, num_d3x3, name): # 3x3 reduce + 3x3
c3x3r = ConvFactory(data=data, num_filter=num_3x3red, kernel=(1, 1), name=('%s_3x3' % name), suffix='_reduce') c3x3 = ConvFactory(data=c3x3r, num_filter=num_3x3, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name=('%s_3x3' % name)) # double 3x3 reduce + double 3x3 cd3x3r = ConvFactory(data=data, num_filter=...
cproj = ConvFactory(data=pooling, num_filter=proj, kernel=(1, 1), name=('%s_proj' % name)) # concat concat = mx.symbol.Concat(*[c1x1, c3x3, cd3x3, cproj], name='ch_concat_%s_chconcat' % name) return concat def InceptionFactoryB(data, num_3x3red, num_3x3, num_d3x3red, num_d3x3, name): # 3x3 reduce + 3x...
126
126
421
48
77
vkuznet/mxnet
example/image-classification/symbol_inception-bn-full.py
Python
InceptionFactoryB
InceptionFactoryB
31
43
31
32
10eb18b67dcb8826dda014b224d8f7ac129e99c7
bigcode/the-stack
train
38a59ae7a3adc34d53d9769a
train
class
class BuildLocalPythonDistributionsTestBase(PythonTaskTestBase, SchedulerTestBase): @classmethod def task_type(cls): return BuildLocalPythonDistributions # This is an informally-specified nested dict -- see ../test_ctypes.py for an example. Special # keys are 'key' (used to index into `self.target_dict`) ...
class BuildLocalPythonDistributionsTestBase(PythonTaskTestBase, SchedulerTestBase): @classmethod
def task_type(cls): return BuildLocalPythonDistributions # This is an informally-specified nested dict -- see ../test_ctypes.py for an example. Special # keys are 'key' (used to index into `self.target_dict`) and 'filemap' (creates files at the # specified relative paths). The rest of the keys are fed into...
# coding=utf-8 # Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import absolute_import, division, print_function, unicode_literals import re from builtins import next from pants.backend.native.register import rules as n...
150
256
1,054
22
127
omerzach/pants
tests/python/pants_test/backend/python/tasks/util/build_local_dists_test_base.py
Python
BuildLocalPythonDistributionsTestBase
BuildLocalPythonDistributionsTestBase
18
119
18
20
3fa953a2ed700677b8c998dce6ad8543bcf1326f
bigcode/the-stack
train
a5735ce59b7083b7b92e1311
train
function
def test_data(client): # pre-test setup, select application response = client.get('/application/specs/AdcTest') # test proper response = client.get('/plot/channels/data') data = json.loads(response.data)['data'] assert len(data) == 1024
def test_data(client): # pre-test setup, select application
response = client.get('/application/specs/AdcTest') # test proper response = client.get('/plot/channels/data') data = json.loads(response.data)['data'] assert len(data) == 1024
Voltage B"},{"enabled":false,"id":6,"max_value":600,"min_value":0,"name":"Voltage C"}]\n' response = client.get('/plot/channels/specs') assert known_good_response in response.data def test_data(client): # pre-test setup, select application
64
64
64
14
49
uscope-platform/uscope_server
test/test_plot.py
Python
test_data
test_data
37
43
37
38
0ed2264682865461f9eda758ed0d5a8f97b650db
bigcode/the-stack
train
53d8506505070069f42c5256
train
function
@pytest.fixture def client(): app = app_factory.create_app() with app.test_client() as client: yield client
@pytest.fixture def client():
app = app_factory.create_app() with app.test_client() as client: yield client
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import json import pytest import app_factory @pytest.fixture def clien...
64
64
27
6
57
uscope-platform/uscope_server
test/test_plot.py
Python
client
client
23
27
23
24
7f1ed08b0537a40de8a1f35e34d2a2fab79fe5d3
bigcode/the-stack
train
27d103241cc056ae04c8eb9e
train
function
def test_plotChannels(client): # pre-test setup, select application response = client.get('/application/specs/AdcTest') # test proper known_good_response = b'[{"enabled":false,"id":1,"max_value":180,"min_value":0,"name":"Current A"},{"enabled":false,"id":2,"max_value":180,"min_value":0,"name":"Current B...
def test_plotChannels(client): # pre-test setup, select application
response = client.get('/application/specs/AdcTest') # test proper known_good_response = b'[{"enabled":false,"id":1,"max_value":180,"min_value":0,"name":"Current A"},{"enabled":false,"id":2,"max_value":180,"min_value":0,"name":"Current B"},{"enabled":false,"id":3,"max_value":180,"min_value":0,"name":"Current...
specific language governing permissions and # limitations under the License. import json import pytest import app_factory @pytest.fixture def client(): app = app_factory.create_app() with app.test_client() as client: yield client def test_plotChannels(client): # pre-test setup, sel...
64
64
204
15
48
uscope-platform/uscope_server
test/test_plot.py
Python
test_plotChannels
test_plotChannels
29
35
29
30
4238e9ed6d2f51ba32b75ee20883a7ae88a3fa0e
bigcode/the-stack
train
5338f8aca3a7bbcb6c9ebc61
train
class
class IpifInterconnectMatrixTC(SimTestCase): CLK = 10 * Time.ns def tearDown(self): self.rmSim() SimTestCase.tearDown(self) def mySetUp(self, read_latency=0, write_latency=0): SimTestCase.setUp(self) AUTO = AUTO_ADDR u = IpifInterconnectMatrix() u.MASTERS ...
class IpifInterconnectMatrixTC(SimTestCase):
CLK = 10 * Time.ns def tearDown(self): self.rmSim() SimTestCase.tearDown(self) def mySetUp(self, read_latency=0, write_latency=0): SimTestCase.setUp(self) AUTO = AUTO_ADDR u = IpifInterconnectMatrix() u.MASTERS = (ALL,) u.SLAVES = ( (0x...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from hwt.hdl.constants import READ, WRITE, Time from hwt.simulator.simTestCase import SimTestCase from hwtLib.abstract.busInterconnect import AUTO_ADDR, ALL from hwtLib.xilinx.ipif.interconnectMatrix import IpifInterconnectMatrix from pyMathBitPrecise.bit_utils import mas...
96
183
610
12
83
Nic30/hwtLib
hwtLib/xilinx/ipif/interconnectMatrix_test.py
Python
IpifInterconnectMatrixTC
IpifInterconnectMatrixTC
11
76
11
11
e47216f59afe56398ddad7c535bc6ae659a28d61
bigcode/the-stack
train
024477212f2a7d41df163ca7
train
class
class TestApi: def __init__(self): pass def GET(self): data = web.input() logg.info(data) return pictureget.getpic() # req = top.api.PictureGetRequest("gw.api.taobao.com") # req.set_app_info(top.appinfo("12527264", "2d62590fed388a69f21da953b3673f36")) # r...
class TestApi:
def __init__(self): pass def GET(self): data = web.input() logg.info(data) return pictureget.getpic() # req = top.api.PictureGetRequest("gw.api.taobao.com") # req.set_app_info(top.appinfo("12527264", "2d62590fed388a69f21da953b3673f36")) # req.picture_id =...
# coding:UTF-8 import web import top.api import json from base import logg import pictureget class TestApi:
31
133
444
4
26
forestsheep/middleman
api/testapi.py
Python
TestApi
TestApi
9
54
9
9
90819ac0761d589212ed87515624680e27b8daf2
bigcode/the-stack
train
2060d55a85794bf074f929cb
train
function
def has_all_mentions(doc, relation): has_mentions = all(len(doc["coref"][x[1]]) > 0 for x in relation) return has_mentions
def has_all_mentions(doc, relation):
has_mentions = all(len(doc["coref"][x[1]]) > 0 for x in relation) return has_mentions
": "task", "Method": "model_name"} map_true_entity_to_available = {v: k for k, v in map_available_entity_to_true.items()} used_entities = list(map_available_entity_to_true.keys()) true_entities = list(map_available_entity_to_true.values()) def has_all_mentions(doc, relation):
64
64
36
8
56
PlusLabNLP/TempGen
bre_eval.py
Python
has_all_mentions
has_all_mentions
19
21
19
19
5d567e6bc710ae053fc69ccf3ac0ab7ae58bf4fb
bigcode/the-stack
train
9fa845b8333b4db4d141b7c7
train
function
def compute_mapping(predicted_relations: List[Dict[str, str]], gold_entities: Dict[str, List], doc_tokens: List[str]): ''' Each relation in predicted_relations is a dict with two elements (for binary relation). e.g. { 'Metric': 'accuracy', 'Task': 'N...
def compute_mapping(predicted_relations: List[Dict[str, str]], gold_entities: Dict[str, List], doc_tokens: List[str]):
''' Each relation in predicted_relations is a dict with two elements (for binary relation). e.g. { 'Metric': 'accuracy', 'Task': 'Natural language inference', } ''' # make a copy so we don't alter the original data gold_entities = deepcopy(gold_entities) predicted_mentio...
_to_true.items()} used_entities = list(map_available_entity_to_true.keys()) true_entities = list(map_available_entity_to_true.values()) def has_all_mentions(doc, relation): has_mentions = all(len(doc["coref"][x[1]]) > 0 for x in relation) return has_mentions def compute_mapping(predicted_relations: List[Dict[...
96
96
321
33
62
PlusLabNLP/TempGen
bre_eval.py
Python
compute_mapping
compute_mapping
23
55
23
25
99322e08461127d9ed0dd280e798c3d2b5d32fa4
bigcode/the-stack
train
0ca1aa5c23512a05c38418e5
train
function
def bre_eval(predicted_relations, gold_data): all_metrics = [] for types in combinations(used_entities, 2): for doc in gold_data: relations = predicted_relations[doc["doc_id"]] mapping = compute_mapping(relations, doc['coref'], doc["words"]) ...
def bre_eval(predicted_relations, gold_data):
all_metrics = [] for types in combinations(used_entities, 2): for doc in gold_data: relations = predicted_relations[doc["doc_id"]] mapping = compute_mapping(relations, doc['coref'], doc["words"]) for relation in relations: fo...
predicted_mention in gold_mentions: gold_entity_name_to_pop = gold_entity_name predicted_mention2gold_entity_name[predicted_mention] = gold_entity_name break # Make sure each gold entity is only assigned once. if gold_entity_name_to_pop is not None: ...
114
114
383
12
101
PlusLabNLP/TempGen
bre_eval.py
Python
bre_eval
bre_eval
60
96
60
61
db2e58454410fad0324b064d7f8083a5dd20066b
bigcode/the-stack
train