sequence stringlengths 1.27k 35.1k | code stringlengths 75 8.58k |
|---|---|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_array'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23']}; {'id': '4', 'type': 'iden... | def send_array(
socket, A=None, metadata=None, flags=0,
copy=False, track=False, compress=None,
chunksize=50 * 1000 * 1000
):
md = {}
md['timestamp'] = datetime.datetime.now().isoformat()
if metadata:
md.update(metadata)
if A is None:
md['parts'] = 0
socke... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recv_array'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'ch... | def recv_array(
socket,
flags=0,
copy=False,
track=False,
poll=None,
poll_timeout=10000
):
if poll is None:
md = socket.recv_json(flags=flags)
else:
socks = dict(poll.poll(poll_timeout))
if socks.get(socket) == zmq.POLLIN:
reply... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reduce_fit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def reduce_fit(interface, state, label, inp):
from disco.util import kvgroup
import numpy as np
out = interface.output(0)
fit_model = {"y_labels": [], "y_sum": 0, "iv": set()}
combiner = {}
means, variances = [], []
k_prev = ""
for key, value in kvgroup(inp):
k_split = key.split(... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map_predict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def map_predict(interface, state, label, inp):
import numpy as np
out = interface.output(0)
continuous = [j for i, j in enumerate(state["X_indices"]) if
state["X_meta"][i] == "c"]
discrete = [j for i, j in enumerate(state["X_indices"]) if
state["X_meta"][i] == "d"]
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'json_dumps'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'};... | def json_dumps(obj):
try:
return json.dumps(obj, indent=2, sort_keys=True, allow_nan=False)
except ValueError:
pass
json_str = json.dumps(obj, indent=2, sort_keys=True, allow_nan=True)
json_obj = json.loads(json_str)
def do_map(obj):
if obj is None:
return None
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_json_mask'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []... | def add_json_mask(self, start, method_str, json_producer):
def send_json(drh, rem_path):
obj = json_producer(drh, rem_path)
if not isinstance(obj, Response):
obj = Response(obj)
ctype = obj.get_ctype("application/json")
code = obj.code
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_text_mask'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []... | def add_text_mask(self, start, method_str, text_producer):
def send_text(drh, rem_path):
text = text_producer(drh, rem_path)
if not isinstance(text, Response):
text = Response(text)
ctype = text.get_ctype("text/plain")
code = text.code
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_token_obj'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def get_token_obj(self, token, expire=_token_default):
if expire == _token_default:
expire = self.get_default_token_expiration()
now = get_time()
until = now + expire if expire is not None else None
with self._token_lock:
first_valid = None
for (pos, k... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def handle_cmd(self, cmd):
cmd = cmd.strip()
segments = []
for s in cmd.split():
if s.startswith('
break
segments.append(s)
args = []
if not len(segments):
return
while segments:
cur_cmd = "_".join(segments)
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_request'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def handle_request(self):
timeout = self.socket.gettimeout()
if timeout is None:
timeout = self.timeout
elif self.timeout is not None:
timeout = min(timeout, self.timeout)
ctime = get_time()
done_req = False
shutdown_latency = self.shutdown_latency... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'info_gain_nominal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | def info_gain_nominal(x, y, separate_max):
x_vals = np.unique(x)
if len(x_vals) < 3:
return None
y_dist = Counter(y)
h_y = h(y_dist.values())
dist, splits = nominal_splits(x, y, x_vals, y_dist, separate_max)
indices, repeat = (range(1, len(dist)), 1) if len(dist) < 50 else (range(1, len(... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_endpoints_using_catalog_api'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'child... | def get_endpoints_using_catalog_api(domain, token):
headers = {"X-App-Token": token}
uri = "http://api.us.socrata.com/api/catalog/v1?domains={0}&offset={1}&limit=1000"
ret = []
endpoints_thus_far = set()
offset = 0
while True:
try:
r = requests.get(uri.format(domain, offset),... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stratify_by_scores'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'childr... | def stratify_by_scores(scores, goal_n_strata='auto', method='cum_sqrt_F',
n_bins = 'auto'):
available_methods = ['equal_size', 'cum_sqrt_F']
if method not in available_methods:
raise ValueError("method argument is invalid")
if (method == 'cum_sqrt_F') or (goal_n_strata == 'aut... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_target'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def _get_target(self, target):
depth = target.count('.') + 1
parts = target.split('.', 1)
for m in self.modules:
if parts[0] == m.name:
if depth < 3:
return m
for p in self.packages:
if parts[0] == p.name:
if dep... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'by_user'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'};... | def by_user(config):
client = Client()
client.prepare_connection()
audit_api = API(client)
CLI.parse_membership('Groups by User', audit_api.by_user()) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_sortkey'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'table... | def get_sortkey(table):
wfs = WebFeatureService(url=bcdata.OWS_URL, version="2.0.0")
return sorted(wfs.get_schema("pub:" + table)["properties"].keys())[0] |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'define_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier',... | def define_request(
dataset, query=None, crs="epsg:4326", bounds=None, sortby=None, pagesize=10000
):
table = validate_name(dataset)
n = bcdata.get_count(table, query=query)
chunks = math.ceil(n / pagesize)
if chunks > 1 and not sortby:
sortby = get_sortkey(table)
param_dicts = []
fo... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_sorted'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def _get_sorted(self, resources):
tmp = []
for resource in resources:
path = resource._path
priority = path.count('/') * 10 - path.count('{')
tmp.append((priority, resource))
return [resource for prio, resource in reversed(sorted(tmp))] |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_new_posts_and_pages'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def find_new_posts_and_pages(db):
Q = Query()
for root, dirs, files in os.walk(CONFIG['content_root']):
for filename in sorted([f for f in files if
f.endswith(('md', 'markdown'))]):
fullpath = os.path.join(root, filename)
_p = fullpath.split(CONFIG[... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_locations'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def get_locations(self, filter_to_my_group=False):
resp = self._post('general-retrievelocations', 'locations')
groups = {}
if resp['groupinfo']:
for group in resp['groupinfo']:
groups[group['id']] = Group(
name=group.get('na... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_image_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def _image_url(image, dst_color=None, src_color=None):
if src_color and dst_color:
if not Image:
raise Exception("Images manipulation require PIL")
file = StringValue(image).value
path = None
if callable(STATIC_ROOT):
try:
_file, _storage = list(STATIC_ROOT(file))... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize_selectors'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'childr... | def normalize_selectors(self, _selectors, extra_selectors=None, extra_parents=None):
_selectors = _spaces_re.sub(' ', _selectors)
if isinstance(extra_selectors, basestring):
extra_selectors = extra_selectors.split(',')
if isinstance(extra_parents, basestring):
extra_paren... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_properties'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13']}; {'id': '4',... | def _get_properties(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr):
prop, value = (_prop_split_re.split(c_property, 1) + [None])[:2]
try:
is_var = (c_property[len(prop)] == '=')
except IndexError:
is_var = False
prop... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'ERROR', 'children': ['2', '299']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '9']}; {'id': '3', 'type': 'function_name', 'children': [], 'value': 'link_with_parents'}; {'id': '4', 'type': 'parameters', 'children': ['5', '6', ... | def link_with_parents(self, parent, c_selectors, c_rules):
parent_found = None
for p_selectors, p_rules in self.parts.items():
_p_selectors, _, _ = p_selectors.partition(' extends ')
_p_selectors = _p_selectors.split(',')
new_selectors = set()
found = Fals... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_extends'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def parse_extends(self):
for _selectors, rules in self.parts.items():
if ' extends ' in _selectors:
selectors, _, parent = _selectors.partition(' extends ')
parents = parent.split('&')
del self.parts[_selectors]
for parent in parents:
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scan'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | def scan(self, restrict):
while True:
best_pat = None
best_pat_len = 0
for p, regexp in self.patterns:
if restrict and p not in restrict and p not in self.ignore:
continue
m = regexp.match(self.input, self.pos)
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_form_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def read_form_data(self):
if self.processed_data:
raise exceptions.AlreadyProcessed('The data has already been processed for this form')
if self.readonly:
return
if request.method == self.method:
if self.method == 'POST':
data = request.form
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_imm_trans_setattr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []... | def _imm_trans_setattr(self, name, value):
'''
An immutable's transient setattr allows params to be set, and runs checks as they are.
'''
params = _imm_param_data(self)
dd = object.__getattribute__(self, '__dict__')
if name in params:
(_, tx_fn, arg_lists, check_fns, deps) = params[name]... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'verify_consistency'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children... | def verify_consistency(predictions, scores, proba, opt_class):
if predictions.shape != scores.shape:
raise ValueError("predictions and scores arrays have inconsistent " +
"dimensions.")
n_class = scores.shape[1] if scores.ndim > 1 else 1
if proba is None:
proba = np.... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_call'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def _call(self, context):
req = context.request
if not req.has_key("method"):
raise RpcException(ERR_INVALID_REQ, "Invalid Request. No 'method'.")
method = req["method"]
if method == "barrister-idl":
return self.contract.idl_parsed
iface_name, func_name = ... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def validate(self, expected_type, is_array, val):
if val == None:
if expected_type.optional:
return True, None
else:
return False, "Value cannot be null"
elif is_array:
if not isinstance(val, list):
return self._type_err... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def validate(self, val):
if type(val) is not dict:
return False, "%s is not a dict" % (str(val))
for k, v in val.items():
field = self.field(k)
if field:
ok, msg = self.contract.validate(field, field.is_array, v)
if not ok:
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_struct'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'};... | def parse_struct(s):
docs = s['comment']
code = '<span class="k">struct</span> <span class="gs">%s</span>' % s['name']
if s['extends']:
code += ' extends <span class="gs">%s</span>' % s['extends']
code += ' {\n'
namelen = 0
typelen = 0
for v in s["fields"]:
tlen = len(format_... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_interface'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'i... | def parse_interface(iface):
sections = [ ]
docs = iface['comment']
code = '<span class="k">interface</span> <span class="gs">%s</span> {\n' % iface['name']
for v in iface["functions"]:
func_code = ' <span class="nf">%s</span>(' % v['name']
i = 0
for p in v["params"]:
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | def run(self):
model = self.model
configfile = self.configfile
interval = self.interval
sockets = self.sockets
model.initialize(configfile)
if model.state == 'pause':
logger.info(
"model initialized and started in pause mode, waiting for reques... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def save(self, *args, **kwargs):
if self.publication:
publication = self.publication
if not self.title:
self.title = publication.title
if not self.subtitle:
first_author = publication.first_author
if first_author == publication.... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sen... | def cmd(send, msg, args):
implements = ['the golden gate bridge', 'a large trout', 'a clue-by-four', 'a fresh haddock', 'moon', 'an Itanium', 'fwilson', 'a wombat']
methods = ['around a bit', 'upside the head']
if not msg:
channel = args['target'] if args['target'] != 'private' else args['config']['... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sen... | def cmd(send, msg, args):
if not msg:
send("Invalid Syntax.")
return
char = msg[0]
msg = [x.replace(r'\/', '/') for x in re.split(r'(?<!\\)\%s' % char, msg[1:], maxsplit=2)]
if len(msg) == 2 and args['config']['feature'].getboolean('lazyregex'):
msg.append('')
if not msg or l... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_single_session_to_to_ordered_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'id... | def _add_single_session_to_to_ordered_dict(self, d, dataset_index, recommended_only):
for model_index, model in enumerate(self.models):
show_null = False
if recommended_only:
if self.recommendation_enabled:
if self.recommended_model is None:
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_group_models'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def _group_models(self):
od = OrderedDict()
for i, model in enumerate(self.models):
output = getattr(model, "output", {})
if output.get("AIC") and output.get("BMD") and output["BMD"] > 0:
key = "{}-{}".format(output["AIC"], output["BMD"])
if key in... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'random_stats'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],... | def random_stats(self, all_stats, race, ch_class):
stats = []
res = {}
for s in all_stats:
stats.append(s['stat'])
res[s['stat']] = 0
cur_stat = 0
for stat in stats:
for ndx, i in enumerate(self.classes.dat):
if i['name'] == ch_... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'palette'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fg'}... | def palette(fg, bg=-1):
if not hasattr(palette, "counter"):
palette.counter = 1
if not hasattr(palette, "selections"):
palette.selections = {}
selection = "%s%s" % (str(fg), str(bg))
if not selection in palette.selections:
palette.selections[selection] = palette.counter
p... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'coordinate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def coordinate(self, panes=[], index=0):
y = 0
for i, element in enumerate(self.panes):
x = 0
if isinstance(element, list):
current_height = 0
for j, pane in enumerate(element):
if pane.hidden: continue
curre... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_MakePackagePages'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'ch... | def _MakePackagePages(self, package, showprivate=False, nested=False, showinh=False):
def checkNoNested(mod):
try:
all = mod.__all__
except AttributeError:
return False
mems = inspect.getmembers(mod, inspect.ismodule)
mems = [m for ... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_DocPackageFromTop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'childre... | def _DocPackageFromTop(self, packages, showprivate=False, showinh=False):
appIndex = ''
if not isinstance(packages, list):
packages = [packages]
if os.path.exists('content'):
shutil.rmtree('content')
os.makedirs('content')
appIndex += r'''
.. toctree::
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sen... | def cmd(send, msg, args):
if not args['config']['feature'].getboolean('hooks'):
send("Hooks are disabled, and this command depends on hooks. Please contact the bot admin(s).")
return
if args['type'] == 'privmsg':
send("Note-passing should be done in public.")
return
try:
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_category'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def add_category(self, category):
'''
Add unicode category to set
Unicode categories are strings like 'Ll', 'Lu', 'Nd', etc.
See `unicodedata.category()`
'''
if category == sre.CATEGORY_DIGIT:
self._categories |= UNICODE_DIGIT_CATEGORIES
elif category ... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_estimate_free'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def _estimate_free(self):
capacity_deferred = self.channel.total_capacity()
open_tasks_deferred = self.channel.tasks(state=[task_states.OPEN])
avg_delta_deferred = self.estimate_duration()
deferreds = [capacity_deferred,
open_tasks_deferred,
avg_... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'package'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | def package(self):
if self.method == 'buildNotification':
return self.params[1]['name']
if self.method in ('createImage', 'image', 'livecd'):
return self.params[0]
if self.method == 'indirectionimage':
return self.params[0]['name']
if self.method not i... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_admin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def is_admin(self, send, nick, required_role='admin'):
if not required_role:
return True
with self.db.session_scope() as session:
admin = session.query(orm.Permissions).filter(orm.Permissions.nick == nick).first()
if admin is None:
return False
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_mode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [],... | def do_mode(self, target, msg, nick, send):
mode_changes = irc.modes.parse_channel_modes(msg)
with self.data_lock:
for change in mode_changes:
if change[1] == 'v':
self.voiced[target][change[2]] = True if change[0] == '+' else False
if chan... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_kick'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children... | def do_kick(self, send, target, nick, msg, slogan=True):
if not self.kick_enabled:
return
if target not in self.channels:
send("%s: you're lucky, private message kicking hasn't been implemented yet." % nick)
return
with self.data_lock:
ops = [k for... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_msg'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def handle_msg(self, c, e):
if e.type not in ['authenticate', 'error', 'join', 'part', 'quit']:
nick = e.source.nick
else:
nick = e.source
if e.arguments is None:
msg = ""
else:
msg = " ".join(e.arguments).strip()
target = nick if e... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sen... | def cmd(send, msg, args):
nick = args['nick']
channel = args['target'] if args['target'] != 'private' else args['config']['core']['channel']
levels = {
1: 'Whirr...',
2: 'Vrrm...',
3: 'Zzzzhhhh...',
4: 'SHFRRRRM...',
5: 'GEEEEZZSH...',
6: 'PLAAAAIIID...',
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmdloop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | def cmdloop(self, intro=None):
''' Override the command loop to handle Ctrl-C. '''
self.preloop()
if self.use_rawinput and self.completekey:
try:
import readline
self.old_completer = readline.get_completer()
readline.set_completer(self.... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'free'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | def free(self, local_path):
'''
Stop synchronization of local_path
'''
config = self.get_config()
folder = st_util.find_folder_with_path(local_path, config)
self.delete_folder(local_path, config)
pruned = st_util.prune_devices(folder, config)
self.set_config(config)
if pruned:
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_package_update_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | def get_package_update_list(package_name, version):
package_version = semantic_version.Version.coerce(version)
package_data = get_pypi_package_data(package_name)
version_data = get_pypi_package_data(package_name, version)
current_release = ''
current_release_license = ''
latest_release = ''
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'page_location_template'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def page_location_template(self):
cycle = self.election_day.cycle.name
model_class = self.model_type.model_class()
if model_class == ElectionDay:
return "/{}/".format(cycle)
if model_class == Office:
if self.jurisdiction:
if self.division_level.nam... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ask'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | def _ask(self, answers):
if isinstance(self.validator, list):
for v in self.validator:
v.answers = answers
else:
self.validator.answers = answers
while(True):
q = self.question % answers
if not self.choices():
logger... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_annotate_fn_args'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '11']}; {'id': '4', 'type': 'identifier', 'ch... | def _annotate_fn_args(stack, fn_opname, nargs, nkw=-1, consume_fn_name=True):
kwarg_names = []
if nkw == -1:
if sys.version_info[0] < 3:
nargs, nkw = (nargs % 256, 2 * nargs // 256)
else:
if fn_opname == 'CALL_FUNCTION_KW':
if qj._DEBUG_QJ:
assert len(stack) and stack[-1].opnam... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_mediation_matrix'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def generate_mediation_matrix(dsm):
cat = dsm.categories
ent = dsm.entities
size = dsm.size[0]
if not cat:
cat = ['appmodule'] * size
packages = [e.split('.')[0] for e in ent]
mediation_matrix = [[0 for _ in range(size)]
for _ in ra... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def check(self, dsm, independence_factor=5, **kwargs):
least_common_mechanism = False
message = ''
data = dsm.data
categories = dsm.categories
dsm_size = dsm.size[0]
if not categories:
categories = ['appmodule'] * dsm_size
dependent_module_number = []
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'abstract'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'class_'}... | def abstract(class_):
if not inspect.isclass(class_):
raise TypeError("@abstract can only be applied to classes")
abc_meta = None
class_meta = type(class_)
if class_meta not in (_ABCMetaclass, _ABCObjectMetaclass):
if class_meta is type:
abc_meta = _ABCMetaclass
elif ... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'final'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id... | def final(arg):
if inspect.isclass(arg):
if not isinstance(arg, ObjectMetaclass):
raise ValueError("@final can only be applied to a class "
"that is a subclass of Object")
elif not is_method(arg):
raise TypeError("@final can only be applied to classes or ... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'override'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'... | def override(base=ABSENT):
arg = base
if inspect.isfunction(arg) or isinstance(arg, NonInstanceMethod):
_OverrideDecorator.maybe_signal_classmethod(arg)
decorator = _OverrideDecorator(None)
return decorator(arg)
if arg is ABSENT:
return _OverrideDecorator(None)
if is_clas... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'i... | def _index(*args, **kwargs):
start = kwargs.pop('start', 0)
step = kwargs.pop('step', 1)
if len(args) == 2:
elem, list_ = args
ensure_sequence(list_)
predicate = lambda item: item == elem
else:
ensure_keyword_args(kwargs,
mandatory=('in_',), op... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tally_poll'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args'}... | def tally_poll(args):
if not args.msg:
return "Syntax: !vote tally <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
pid = int(args.msg)
poll = get_open_poll(args.session, pid)
if poll is None:
return "That poll doesn't exist or was deleted. Use !po... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_setup_pages'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def _setup_pages(cls, config):
from cms.exceptions import NoHomeFound
from cms.models import Page
from cms.utils import get_language_list
from django.conf import settings
from django.utils.translation import override
app_page = None
get_url = False
if geta... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pretty_description'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [... | def pretty_description(description, wrap_at=None, indent=0):
if wrap_at is None or wrap_at < 0:
width = console_width(default=79)
if wrap_at is None:
wrap_at = width
else:
wrap_at += width
indent = ' ' * indent
text_wrapper = textwrap.TextWrapper(
widt... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10', '13', '16']}; {'id': '4', 'type': 'identifier', 'children': ... | def search(term, category=Categories.ALL, pages=1, sort=None, order=None):
s = Search()
s.search(term=term, category=category, pages=pages, sort=sort, order=order)
return s |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'popular'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']... | def popular(category=None, sortOption = "title"):
s = Search()
s.popular(category, sortOption)
return s |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parameter', 'children':... | def recent(category=None, pages=1, sort=None, order=None):
s = Search()
s.recent(category, pages, sort, order)
return s |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pick_action_todo'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '67']}; {'id': '... | def pick_action_todo():
for ndx, todo in enumerate(things_to_do):
if roll_dice(todo["chance"]):
cur_act = actions[get_action_by_name(todo["name"])]
if todo["WHERE_COL"] == "energy" and my_char["energy"] > todo["WHERE_VAL"]:
return cur_act
if todo["WHERE_CO... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'soup'... | def select(soup, selector):
tokens = selector.split()
current_context = [soup]
for token in tokens:
m = attribselect_re.match(token)
if m:
tag, attribute, operator, value = m.groups()
if not tag:
tag = True
checker = attribute_checker(opera... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'try_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def try_(block, except_=None, else_=None, finally_=None):
ensure_callable(block)
if not (except_ or else_ or finally_):
raise TypeError("at least one of `except_`, `else_` or `finally_` "
"functions must be provided")
if else_ and not except_:
raise TypeError("`else_`... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'replace_u_end_day'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | def replace_u_end_day(day, year, month):
day = day.lstrip('-')
year = int(year)
month = int(month.lstrip('-'))
if day == 'uu' or day == '3u':
return str(calendar.monthrange(year, month)[1])
if day == '0u' or day == '1u':
return day.replace('u', '9')
if day == '2u' or day == 'u9':... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zero_year_special_case'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'chil... | def zero_year_special_case(from_date, to_date, start, end):
if start == 'pos' and end == 'pos':
if from_date.startswith('0000') and not to_date.startswith('0000'):
return True
if not from_date.startswith('0000') and to_date.startswith('0000'):
return False
if from_dat... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_valid_interval'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def is_valid_interval(edtf_candidate):
from_date = None
to_date = None
end, start = 'pos', 'pos'
if edtf_candidate.count('/') == 1:
edtf_candidate = replace_all(edtf_candidate, interval_replacements)
edtf_candidate = re.sub(U_PATTERN, replace_u, edtf_candidate)
parts = edtf_candi... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'template'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['5... | def template(page=None, layout=None, **kwargs):
pkey = "_template_extends__"
def decorator(f):
if inspect.isclass(f):
layout_ = layout or page
extends = kwargs.pop("extends", None)
if extends and hasattr(extends, pkey):
items = getattr(extends, pkey).i... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getargspec'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'};... | def getargspec(obj):
argnames, varargs, varkw, _defaults = None, None, None, None
if inspect.isfunction(obj) or inspect.ismethod(obj):
argnames, varargs, varkw, _defaults = inspect.getargspec(obj)
elif inspect.isclass(obj):
if inspect.ismethoddescriptor(obj.__init__):
argnames, v... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_overlap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children... | async def _find_overlap(queries, client, find_method, get_method,
overlap_function):
results = []
for query in queries:
candidates = await getattr(client, find_method)(query)
if not candidates:
raise ValueError('no result found for {!r}'.format(query))
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'power'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'set_'}; {'i... | def power(set_):
ensure_countable(set_)
result = chain.from_iterable(combinations(set_, r)
for r in xrange(len(set_) + 1))
return _harmonize_subset_types(set_, result) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_pws_in_order'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'chil... | def generate_pws_in_order(self, n, filter_func=None, N_max=1e6):
states = [(-1.0, helper.START)]
p_min = 1e-9 / (n**2)
ret = []
done = set()
already_added_in_heap = set()
while len(ret) < n and len(states) > 0:
p, s = heapq.heappop(states)
if p < 0... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expand_seed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def expand_seed(self, start_seed, num_iterations, val):
self.grd.set_tile(start_seed[0], start_seed[1], val)
cur_pos = [start_seed[0], start_seed[1]]
while num_iterations > 0:
num_iterations -= 1
for y in range(cur_pos[0]-randint(0,2), cur_pos[0] + randint(0,2)):
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'denoise_grid'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def denoise_grid(self, val, expand=1):
updated_grid = [[self.grd.get_tile(y,x) \
for x in range(self.grd.grid_width)] \
for y in range(self.grd.grid_height)]
for row in range(self.grd.get_grid_height() - expand):
for col in range(self.grd.get_g... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def run(self, num_runs, show_trails, log_file_base):
print("--------------------------------------------------")
print("Starting Simulation - target = ", self.agent_list[0].target_y, self.agent_list[0].target_x)
self.world.grd.set_tile(self.agent_list[0].target_y , self.agent_list[0].target_x , ... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a... | def merge(arg, *rest, **kwargs):
ensure_keyword_args(kwargs, optional=('default',))
has_default = 'default' in kwargs
if has_default:
default = ensure_callable(kwargs['default'])
unary_result = True
if rest:
fs = (ensure_callable(arg),) + tuple(imap(ensure_callable, rest))
un... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sen... | def cmd(send, msg, args):
if not args['config']['feature'].getboolean('hooks'):
send("Hooks are disabled, and this command depends on hooks. Please contact the bot admin(s).")
return
session = args['db']
parser = arguments.ArgParser(args['config'])
group = parser.add_mutually_exclusive_g... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'buildPrices'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'childre... | def buildPrices(data, roles=None, regex=default_price_regex,
default=None, additional={}):
''' Create a dictionary with price information. Multiple ways are
supported.
:rtype: :obj:`dict`: keys are role as str, values are the prices as
cent count'''
if isinstance(dat... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'toTag'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def toTag(self, output):
''' This methods adds all data of this canteen as canteen xml tag
to the given xml Document.
:meth:`toXMLFeed` uses this method to create the XML Feed. So there is
normally no need to call it directly.
:param output: XML Document to which the data should ... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '33']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'AddAnalogShortIdMsecRecord'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12', '15', '18', '21', '2... | def AddAnalogShortIdMsecRecord(site_service, tag, time_value, msec, value,
low_warn=False, high_warn=False, low_alarm=False, high_alarm=False,
oor_low=False, oor_high=False, unreliable=False, manual=False):
szService = c_char_p(site_service.encode('utf-8'))
szPointId = c_char_p(tag.encode('utf-8'))
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_node_ids'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def update_node_ids(self, sub_job_num=None):
dag_id = '%s.%s' % (self.cluster_id, sub_job_num) if sub_job_num else str(self.cluster_id)
job_delimiter = '+++'
attr_delimiter = ';;;'
format = [
'-format', '"%d' + attr_delimiter + '"', 'ClusterId',
'-format', '"%v' +... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'concat_cols'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '14']}; {'id': '4', 'type': '... | def concat_cols(df1,df2,idx_col,df1_cols,df2_cols,
df1_suffix,df2_suffix,wc_cols=[],suffix_all=False):
df1=df1.set_index(idx_col)
df2=df2.set_index(idx_col)
if not len(wc_cols)==0:
for wc in wc_cols:
df1_cols=df1_cols+[c for c in df1.columns if wc in c]
df... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def to_json(self, indent=None, sort_keys=True):
return json.dumps(self.to_dict(), indent=indent, sort_keys=sort_keys) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_method_decoration'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'... | def _validate_method_decoration(meta, class_):
super_mro = class_.__mro__[1:]
own_methods = ((name, member)
for name, member in class_.__dict__.items()
if is_method(member))
for name, method in own_methods:
shadowed_method, base_class = n... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_status'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'bug... | def _parse_status(bug_el):
bug = Bugreport()
for field in ('originator', 'subject', 'msgid', 'package', 'severity',
'owner', 'summary', 'location', 'source', 'pending',
'forwarded'):
setattr(bug, field, _parse_string_el(bug_el(field)))
bug.date = datetime.utcfromt... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def set(self, attr, value):
def escape_new_syntax(value, double_quote_escape='"'):
value = str(value)
value = value.replace("'", "''")
value = value.replace('"', '%s"' % double_quote_escape)
if ' ' in value or '\t' in value:
value = "'%s'" % value
... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def _update_status(self, sub_job_num=None):
job_id = '%s.%s' % (self.cluster_id, sub_job_num) if sub_job_num else str(self.cluster_id)
format = ['-format', '"%d"', 'JobStatus']
cmd = 'condor_q {0} {1} && condor_history {0} {1}'.format(job_id, ' '.join(format))
args = [cmd]
out, e... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mangle'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'... | def mangle(text):
text_bytes = text.encode('utf-8')
buff = BytesIO(text_bytes)
mangled = BytesIO()
last_tok = token.INDENT
last_line = -1
last_col = 0
last_line_text = ''
open_list_dicts = 0
tokens = tokenizer(buff.readline)
for t, text, (line_s, col_s), (line_e, col_e), line in ... |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18', '34']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_array_from_hist2D'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '13']}; {'id': '4', 'type': 'typed_parameter'... | def get_array_from_hist2D(hist: Hist, set_zero_to_NaN: bool = True, return_bin_edges: bool = False) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
shape = (hist.GetYaxis().GetNbins(), hist.GetXaxis().GetNbins())
hist_array = np.array([hist.GetBinContent(x) for x in range(1, hist.GetNcells()) if not hist.IsBinUnd... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.