code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def describe_partitioner(self, ):
self._seqid += 1
d = self._reqs[self._seqid] = defer.Deferred()
self.send_describe_partitioner()
return d | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'describe_partitioner'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | returns the partitioner used by this cluster |
def check_config_integrity(self):
tasks_by_hash = {_hash_task(t): t for t in self.config_tasks}
if len(tasks_by_hash) != len(self.config_tasks):
raise Exception("Fatal error: there was a hash duplicate in the scheduled tasks config.")
for h, task in tasks_by_hash.items():
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_config_integrity'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Make sure the scheduler config is valid |
def parse_compound(self):
compound_tag = Compound()
for token in self.collect_tokens_until('CLOSE_COMPOUND'):
item_key = token.value
if token.type not in ('NUMBER', 'STRING', 'QUOTED_STRING'):
raise self.error(f'Expected compound key but got {item_key!r}')
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_compound'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Parse a compound from the token stream. |
def domain_whois(self, domain):
uri = self._uris["whois_domain"].format(domain)
resp_json = self.get_parse(uri)
return resp_json | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'domain_whois'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Gets whois information for a domain |
def capture_exception(fn):
def wrapped(*args):
try:
return fn(*args)
except Exception as e:
return e
return wrapped | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'capture_exception'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | decorator that catches and returns an exception from wrapped function |
def from_string(cls, line, ignore_bad_cookies=False,
ignore_bad_attributes=True):
"Construct a Cookie object from a line of Set-Cookie header data."
cookie_dict = parse_one_response(
line, ignore_bad_cookies=ignore_bad_cookies,
ignore_bad_attributes=ignore_bad... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_string'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [],... | Construct a Cookie object from a line of Set-Cookie header data. |
def __zipped_files_data(self):
files = {}
with zipfile.ZipFile(self.__zip_file) as thezip:
for zipinfo in thezip.infolist():
if zipinfo.filename.endswith('metadata/icons.json'):
with thezip.open(zipinfo) as compressed_file:
files['i... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__zipped_files_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Get a dict of all files of interest from the FA release zipfile. |
def reduce_l1(attrs, inputs, proto_obj):
new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'})
new_attrs = translation_utils._add_extra_attributes(new_attrs,
{'ord' : 1})
return 'norm', new_attrs, inputs | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reduce_l1'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Reduce input tensor by l1 normalization. |
def clean_cookie(self):
if not self.is_cookie_necessary:
return self
headers = self.request.get('headers', {})
cookies = SimpleCookie(headers['Cookie'])
for k, v in cookies.items():
new_cookie = '; '.join(
[i.OutputString() for i in cookies.values(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_cookie'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Only clean the cookie from headers and return self. |
def _find_keys(self, identity='image'):
prefix = add_prefix('', identity)
raw_keys = self._find_keys_raw(prefix) or []
for raw_key in raw_keys:
yield del_prefix(raw_key) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_keys'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Finds and returns all keys for identity, |
def extra(request, provider):
identity = request.session.get('identity', None)
if not identity:
raise Http404
if request.method == "POST":
form = str_to_class(settings.EXTRA_FORM)(request.POST)
if form.is_valid():
user = form.save(request, identity, provider)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extra'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'reques... | Handle registration of new user with extra data for profile |
def _get_primary_type(ttypes, parent, logstream=stderr):
if len(ttypes) > 1:
if logstream:
message = '[tag::transcript::primary_transcript]'
message += ' WARNING: feature {:s}'.format(parent.slug)
message += ' has multiple associated transcript types'
message ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_primary_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | Check for multiple transcript types and, if possible, select one. |
def toString(self) -> str:
return ' '.join(attr.html for attr in self._dict.values()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'toString'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Return string representation of collections. |
def reapply_sampling_strategies(self):
check_sensor = self._inspecting_client.future_check_sensor
for sensor_name, strategy in list(self._strategy_cache.items()):
try:
sensor_exists = yield check_sensor(sensor_name)
if not sensor_exists:
se... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reapply_sampling_strategies'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],... | Reapply all sensor strategies using cached values |
def ask_password(*question: Token) -> str:
tokens = get_ask_tokens(question)
info(*tokens)
answer = read_password()
return answer | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ask_password'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '... | Ask the user to enter a password. |
def resources(self):
used_resources = self._used_resources()
ret = collections.defaultdict(dict)
for resource, total in six.iteritems(self._resources):
ret[resource]['total'] = total
if resource in used_resources:
ret[resource]['used'] = used_resources[res... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resources'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | get total resources and available ones |
def warning(self, msg, *args, **kwargs):
self._log("WARNING", msg, args, kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'warning'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Log 'msg % args' with the warning severity level |
def encode_value_using_ma(message_attribute: int, value: Optional[Union[int, float]]) -> int:
if message_attribute == MA_TX3AC_100A:
if value is None:
return 0xfe
return int(value)
elif message_attribute == MA_TX3AC_10A:
if value is None:
return 0xfe
retur... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode_value_using_ma'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'chi... | Encode special sensor value using the message attribute. |
def homogeneous_poisson(self):
return (1. - 2. / 3. * self.g_vrh / self.k_vrh) / \
(2. + 2. / 3. * self.g_vrh / self.k_vrh) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'homogeneous_poisson'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | returns the homogeneous poisson ratio |
def paragraph_spans(self):
if not self.is_tagged(PARAGRAPHS):
self.tokenize_paragraphs()
return self.spans(PARAGRAPHS) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'paragraph_spans'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | The list of spans representing ``paragraphs`` layer elements. |
def _build_url(*args, **kwargs) -> str:
resource_url = API_RESOURCES_URLS
for key in args:
resource_url = resource_url[key]
if kwargs:
resource_url = resource_url.format(**kwargs)
return urljoin(URL, resource_url) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': [... | Return a valid url. |
def transformer_base_v3():
hparams = transformer_base_v2()
hparams.optimizer_adam_beta2 = 0.997
hparams.learning_rate_schedule = (
"constant*linear_warmup*rsqrt_decay*rsqrt_hidden_size")
hparams.learning_rate_constant = 2.0
return hparams | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transformer_base_v3'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '17', '... | Base parameters for Transformer model. |
def lookup(ctx, number, comment, cache):
phone = PhoneNumber(number, comment=comment)
info('{0} | {1}'.format(phone.number, ctx.obj['config']['lookups'].keys()))
if phone.number in ctx.obj['config']['lookups']:
info('{0} is already cached:'.format(phone.number))
info(jsonify(ctx.obj['config'... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lookup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Get the carrier and country code for a phone number |
def emit_metadata_for_region_py(self, region, region_filename, module_prefix):
terrobj = self.territory[region]
with open(region_filename, "w") as outfile:
prnt(_REGION_METADATA_PROLOG % {'region': terrobj.identifier(), 'module': module_prefix}, file=outfile)
prnt("PHONE_METADATA... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'emit_metadata_for_region_py'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', ... | Emit Python code generating the metadata for the given region |
def readBimFile(basefilename):
bim_fn = basefilename+'.bim'
rv = SP.loadtxt(bim_fn,delimiter='\t',usecols = (0,3),dtype=int)
return rv | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'readBimFile'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'basef... | Helper fuinction that reads bim files |
def combobox_set_model_from_list(cb, items):
cb.clear()
model = gtk.ListStore(str)
for i in items:
model.append([i])
cb.set_model(model)
if type(cb) == gtk.ComboBoxEntry:
cb.set_text_column(0)
elif type(cb) == gtk.ComboBox:
cell = gtk.CellRendererText()
cb.pack_st... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'combobox_set_model_from_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children... | Setup a ComboBox or ComboBoxEntry based on a list of strings. |
def _setse(self, i):
if i > 0:
u = (i * 2) - 1
else:
u = -2 * i
self._setue(u) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_setse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Initialise bitstring with signed exponential-Golomb code for integer i. |
def import_from_string(full_class_name):
s = full_class_name.split('.')
class_name = s[-1]
module_name = full_class_name[:-len(class_name)-1]
module = importlib.import_module(module_name)
klass = getattr(module, class_name)
return klass | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_from_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | return a class based on it's full class name |
def _show_psrs():
sep = os.linesep
types = "Supported types: " + ", ".join(API.list_types())
cids = "IDs: " + ", ".join(c for c, _ps in API.list_by_cid())
x_vs_ps = [" %s: %s" % (x, ", ".join(p.cid() for p in ps))
for x, ps in API.list_by_extension()]
exts = "File extensions:" + sep ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_show_psrs'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '26', '46', '76'... | Show list of info of parsers available |
def info_1(*tokens: Token, **kwargs: Any) -> None:
info(bold, blue, "::", reset, *tokens, **kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'info_1'}; {'id': '3', 'type': 'parameters', 'children': ['4', '9']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '... | Print an important informative message |
def visit_num(self, node, parent):
return nodes.Const(
node.n,
getattr(node, "lineno", None),
getattr(node, "col_offset", None),
parent,
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_num'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | visit a Num node by returning a fresh instance of Const |
def specialRound(number, rounding):
temp = 0
if rounding == 0:
temp = number
else:
temp = round(number, rounding)
if temp % 1 == 0:
return int(temp)
else:
return float(temp) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'specialRound'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | A method used to round a number in the way that UsefulUtils rounds. |
def load_projects(self):
server_config = Config.instance().get_section_config("Server")
projects_path = os.path.expanduser(server_config.get("projects_path", "~/GNS3/projects"))
os.makedirs(projects_path, exist_ok=True)
try:
for project_path in os.listdir(projects_path):
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_projects'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Preload the list of projects from disk |
def _set_element_property(parent_to_parse, element_path, prop_name, value):
element = get_element(parent_to_parse)
if element is None:
return None
if element_path and not element_exists(element, element_path):
element = insert_element(element, 0, element_path)
if not isinstance(value, st... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_element_property'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'child... | Assigns the value to the parsed parent element and then returns it |
def kernel(self):
stop_words = [ y.lower() for y in self.abbreviations.values() + self.filler_words ]
kernel = ' '.join([ x for x in self.expand().split() if x.lower() not in stop_words ])
kernel = re.sub(r'\s*United States', '', kernel)
return kernel | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'kernel'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | The 'kernel' is an attempt to get at just the most pithy words in the name |
def to_file_mode(self):
for message_no in range(len(self.messages)):
self.__to_file(message_no) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_file_mode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Write all the messages to files |
def _won_in(self):
if not self._summary['finished']:
return
starting_age = self._summary['settings']['starting_age'].lower()
if starting_age == 'post imperial':
starting_age = 'imperial'
ages_reached = set([starting_age])
for player in self._summary['playe... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_won_in'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Get age the game was won in. |
def _get_goslimids_norel(self, dagslim):
go_slims = set()
go2obj = self.gosubdag.go2obj
for goid in dagslim:
goobj = go2obj[goid]
if not goobj.relationship:
go_slims.add(goobj.id)
return go_slims | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_goslimids_norel'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Get all GO slim GO IDs that do not have a relationship. |
def cli(ctx, project_dir):
exit_code = SCons(project_dir).verify()
ctx.exit(exit_code) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {... | Verify the verilog code. |
def list_commands(self, ctx):
rv = defaults.list_commands(ctx)
if self._commands_dir:
for filename in os.listdir(self._commands_dir):
if _is_command_file(filename) and filename[:-3] not in rv:
rv.append(filename[:-3])
rv.sort()
return r... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_commands'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | List commands from the commands dir and default group |
def close(self):
if self._device is not None:
ibsta = self._lib.ibonl(self._device, 0)
self._check_status(ibsta)
self._device = None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Closes the gpib transport. |
def _normalize_branch_node(self, node):
not_blank_items_count = sum(1 for x in range(17) if node[x])
assert not_blank_items_count >= 1
if not_blank_items_count > 1:
self._encode_node(node)
return node
not_blank_index = [i for i, item in enumerate(node) if item][0]... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_normalize_branch_node'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | node should have only one item changed |
def remove_server(self, name):
for i in self._server_list:
if i['key'] == name:
try:
self._server_list.remove(i)
logger.debug("Remove server %s from the list" % name)
logger.debug("Updated servers list (%s servers): %s" % (
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_server'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Remove a server from the dict. |
def close(self):
self.fire(JSONStreamer.DOC_END_EVENT)
self._stack = None
self._parser.close() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Closes the streamer which causes a `DOC_END_EVENT` to be fired and frees up memory used by yajl |
def _collected_label(collect, label):
if not collect.__name__.startswith('<'):
return label + ' ' + collect.__name__
else:
return label | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_collected_label'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Label of a collected column. |
def canonical_name(sgf_name):
sgf_name = os.path.normpath(sgf_name)
assert sgf_name.endswith('.sgf'), sgf_name
sgf_name = sgf_name[:-4]
with_folder = re.search(r'/([^/]*/eval/.*)', sgf_name)
if with_folder:
return with_folder.group(1)
return os.path.basename(sgf_name) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'canonical_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sg... | Keep filename and some date folders |
def which(cmd, path="PATH"):
if os.path.exists(cmd):
return cmd
if cmd[0] == '/':
return None
for segment in os.getenv(path).split(":"):
program = os.path.normpath(os.path.join(segment, cmd))
if os.path.exists(program):
return program
return None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'which'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cmd'};... | Find cmd on PATH. |
def from_module(self, path):
bundles = PythonLoader(path).load_bundles()
for name in bundles:
self.register(name, bundles[name]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_module'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Register bundles from a Python module |
def __install_ssh_config(self, config):
if not config.is_affirmative('use_global_ssh', default="no"):
ssh_config_injection = self._build_ssh_config(config)
if not os.path.exists(ssh_config_path):
if self.injections.in_noninjected_file(ssh_config_path, "Host %s" % config.g... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__install_ssh_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Install the ssh configuration |
def _get_release_params():
release_name = request.form.get('release_name')
utils.jsonify_assert(release_name, 'release_name required')
release_number = request.form.get('release_number', type=int)
utils.jsonify_assert(release_number is not None, 'release_number required')
return release_name, releas... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_release_params'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '16', '24', '... | Gets the release params from the current request. |
async def get_alarms(self):
url = '{}{}'.format(self.base_url, self.endpoint)
try:
with async_timeout.timeout(5, loop=self._loop):
response = await self._session.get(url)
_LOGGER.debug(
"Response from Netdata: %s", response.status)
data... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_alarms'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Get alarms for a Netdata instance. |
def readline(self) -> bytes:
assert self._state == ConnectionState.created, \
'Expect conn created. Got {}.'.format(self._state)
with self._close_timer.with_timeout():
data = yield from \
self.run_network_operation(
self.reader.readline(),
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'readline'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Read a line of data. |
def host_context(func):
"Sets the context of the setting to the current host"
@wraps(func)
def decorator(*args, **kwargs):
hosts = get_hosts_settings()
with settings(**hosts[env.host]):
return func(*args, **kwargs)
return decorator | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'host_context'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func... | Sets the context of the setting to the current host |
def metadata(self):
from sqlalchemy import MetaData
metadata = MetaData(bind=self.engine, schema=self._schema)
metadata.reflect(self.engine)
return metadata | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Return an SqlAlchemy MetaData object, bound to the engine. |
def automeshgrid(
x, y, step=0.02, xstep=None, ystep=None, pad=0.5, xpad=None, ypad=None
):
if xpad is None:
xpad = pad
if xstep is None:
xstep = step
if ypad is None:
ypad = pad
if ystep is None:
ystep = step
xmin = x.min() - xpad
xmax = x.max() + xpad
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'automeshgrid'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21']}; {'id': '4', 'type': 'ide... | Make a meshgrid, inferred from data. |
def parse_leehom_logs(self, f):
regexes = {
'total': r"Total reads[\s\:]+(\d+)",
'merged_trimming': r"Merged \(trimming\)\s+(\d+)",
'merged_overlap': r"Merged \(overlap\)\s+(\d+)",
'kept': r"Kept PE/SR\s+(\d+)",
'trimmed': r"Trimmed SR\s+(\d+)",
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_leehom_logs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Go through log file looking for leehom output |
def stop(self):
if self._timer:
self._timer.stop()
self._timer.deleteLater() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Stop the current timer if there is one and cancel the async call. |
def add_scope(self, scope_type, scope_name, scope_start, is_method=False):
if self._curr is not None:
self._curr['end'] = scope_start - 1
self._curr = {
'type': scope_type, 'name': scope_name,
'start': scope_start, 'end': scope_start
}
if is_method and... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_scope'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': ... | we identified a scope and add it to positions. |
def length(self, t0=0, t1=1, error=None, min_depth=None):
return abs(self.end - self.start)*(t1-t0) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'length'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [... | returns the length of the line segment between t0 and t1. |
def unstruct_strat(self):
return (
UnstructureStrategy.AS_DICT
if self._unstructure_attrs == self.unstructure_attrs_asdict
else UnstructureStrategy.AS_TUPLE
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unstruct_strat'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | The default way of unstructuring ``attrs`` classes. |
def secured_clipboard(item):
expire_clock = time.time()
def set_text(clipboard, selectiondata, info, data):
if 15.0 >= time.time() - expire_clock:
selectiondata.set_text(item.get_secret())
clipboard.clear()
def clear(clipboard, data):
pass
targets = [("STRING", 0,... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'secured_clipboard'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | This clipboard only allows 1 paste |
def action(route, template='', methods=['GET']):
def real_decorator(function):
function.pi_api_action = True
function.pi_api_route = route
function.pi_api_template = template
function.pi_api_methods = methods
if hasattr(function, 'pi_api_crossdomain'):
if not func... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'action'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Decorator to create an action |
def destroy(self):
result = self._result(
["heroku", "apps:destroy", "--app", self.name, "--confirm", self.name]
)
return result | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'destroy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Destroy an app and all its add-ons |
def send(self, message):
serialized = message.SerializeToString()
log_binary(_LOGGER, '>> Send', Data=serialized)
if self._chacha:
serialized = self._chacha.encrypt(serialized)
log_binary(_LOGGER, '>> Send', Encrypted=serialized)
data = write_variant(len(serialize... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Send message to device. |
def remove_routes(self, item, routes):
for route in routes:
items = self._routes.get(route)
try:
items.remove(item)
LOG.debug('removed item from route %s', route)
except ValueError:
pass
if not items:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_routes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Removes item from matching routes |
def update(self):
stats = self.get_init_value()
if self.input_method == 'local':
self.uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())
stats = str(self.uptime).split('.')[0]
elif self.input_method == 'snmp':
uptime = self.get_stats_snmp(snm... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Update uptime stat using the input method. |
def _add_image(collection, image):
image_prep = {
'id': image.id,
'name': image.name,
'created_at': image.created_at,
'file': image.file,
'min_disk': image.min_disk,
'min_ram': image.min_ram,
'owner': image.owner,
'prote... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_image'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c... | Add image to given dictionary |
def _find_in_columncollection(columns, name):
for col in columns:
if col.name == name or getattr(col, '_label', None) == name:
return col
return None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_in_columncollection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ... | Find a column in a column collection by name or _label |
async def _retransmit(self, sequence_number):
packet = self.__rtp_history.get(sequence_number % RTP_HISTORY_SIZE)
if packet and packet.sequence_number == sequence_number:
if self.__rtx_payload_type is not None:
packet = wrap_rtx(packet,
paylo... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_retransmit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Retransmit an RTP packet which was reported as lost. |
def update_earthquake_info(self):
self.label_earthquake_model()
current_index = self.earthquake_function.currentIndex()
model = EARTHQUAKE_FUNCTIONS[current_index]
notes = ''
for note in model['notes']:
notes += note + '\n\n'
citations = ''
for citatio... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_earthquake_info'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Update information about earthquake info. |
def check_status_logfile(self, checker_func):
self.status = checker_func(self.logfile)
return self.status | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_status_logfile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Check on the status of this particular job using the logfile |
def configure_logger(logger, filename, folder, log_level):
fmt = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
if folder is not None:
log_file = os.path.join(folder, filename)
hdl = logging.FileHandler(log_file)
hdl.setFormatter(fmt)
hdl.setLevel(log_level)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'configure_logger'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children':... | Configure logging behvior for the simulations. |
def dynamic_sum(values, limit_n=1000, acc=0, depth=4):
if len(values) < limit_n:
return acc + sum(values)
if depth > 0:
half = len(values) // 2
return add(
dynamic_sum(values[:half], limit_n, acc, depth=depth-1),
dynamic_sum(values[half:], limit_n, 0, depth=depth-... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dynamic_sum'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': []... | Example of dynamic sum. |
def _handle_tag_fileattributes(self):
obj = _make_object("FileAttributes")
bc = BitConsumer(self._src)
bc.u_get(1)
obj.UseDirectBlit = bc.u_get(1)
obj.UseGPU = bc.u_get(1)
obj.HasMetadata = bc.u_get(1)
obj.ActionScript3 = bc.u_get(1)
bc.u_get(2)
ob... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handle_tag_fileattributes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Handle the FileAttributes tag. |
def query_one(cls, *args, **kwargs):
doc = cls._coll.find_one(*args, **kwargs)
if doc:
return cls.from_storage(doc) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query_one'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Same as collection.find_one, but return Document then dict |
def _default_format(self, occur):
if self.text or self.children:
return self.start_tag() + "%s" + self.end_tag()
return self.start_tag(empty=True) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_default_format'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Return the default serialization format. |
def generate_moffat_profile(seeing_fwhm, alpha):
scale = 2 * math.sqrt(2**(1.0 / alpha) - 1)
gamma = seeing_fwhm / scale
amplitude = 1.0 / math.pi * (alpha - 1) / gamma**2
seeing_model = Moffat2D(amplitude=amplitude,
x_mean=0.0,
y_mean=0.0,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_moffat_profile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | Generate a normalized Moffat profile from its FWHM and alpha |
def encode_images_as_png(images):
if tf.executing_eagerly():
for image in images:
yield tf.image.encode_png(image).numpy()
else:
(height, width, channels) = images[0].shape
with tf.Graph().as_default():
image_t = tf.placeholder(dtype=tf.uint8, shape=(height, width, channels))
encoded_i... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode_images_as_png'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Yield images encoded as pngs. |
def validate(collection, onerror: Callable[[str, List], None] = None):
BioCValidator(onerror).validate(collection) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'co... | Validate BioC data structure. |
def setup_hob(self):
if self.m.hob is None:
return
hob_out_unit = self.m.hob.iuhobsv
new_hob_out_fname = os.path.join(self.m.model_ws,self.m.get_output_attribute(unit=hob_out_unit))
org_hob_out_fname = os.path.join(self.org_model_ws,self.m.get_output_attribute(unit=hob_out_un... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_hob'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | setup observations from the MODFLOW HOB package |
def _insert(self, key, records, count):
if key not in self.records:
assert key not in self.counts
self.records[key] = records
self.counts[key] = count
else:
self.records[key] = np.vstack((self.records[key], records))
assert key in self.counts
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_insert'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Insert records according to key |
def parse_sam(sam, qual):
for line in sam:
if line.startswith('@'):
continue
line = line.strip().split()
if int(line[4]) == 0 or int(line[4]) < qual:
continue
yield line | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_sam'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sa... | parse sam file and check mapping quality |
def chunkWidgets(self, group):
ui_groups = []
subgroup = []
for index, item in enumerate(group['items']):
if getin(item, ['options', 'full_width'], False):
ui_groups.append(subgroup)
ui_groups.append([item])
subgroup = []
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'chunkWidgets'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | chunk the widgets up into groups based on their sizing hints |
def _check_arguments(self):
if self.argument_checked:
return
assert(self.symbol is not None)
self.argument_checked = True
_check_arguments(self.symbol)
if self.allow_extra_params:
if self.arg_params:
arg_names = set(self.symbol.list_argumen... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_arguments'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | verify the argument of the default symbol and user provided parameters |
def prepare_file(filename):
directory = os.path.join(utils.get_project_root(), "analyzation/")
if not os.path.exists(directory):
os.makedirs(directory)
workfilename = os.path.join(directory, filename)
open(workfilename, 'w').close()
return workfilename | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepare_file'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file... | Truncate the file and return the filename. |
def _get_controller_type(self):
if self.node_type == self.NODE_CONTROLLER_ROOT and self.name in self.CONTROLLERS:
return self.name
elif self.parent:
return self.parent.controller_type
else:
return None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_controller_type'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Returns the current node's controller type |
def _csr_matrix_indices(S):
m, n = S.shape
for i in range(m):
for j in range(S.indptr[i], S.indptr[i+1]):
row_index, col_index = i, S.indices[j]
yield row_index, col_index | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_csr_matrix_indices'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Generate the indices of nonzero entries of a csr_matrix S |
def arrows_at(self, x, y):
for arrow in self.arrows():
if arrow.collide_point(x, y):
yield arrow | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'arrows_at'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Iterate over arrows that collide the given point. |
def imeicsum(text):
digs = []
for i in range(14):
v = int(text[i])
if i % 2:
v *= 2
[digs.append(int(x)) for x in str(v)]
chek = 0
valu = sum(digs)
remd = valu % 10
if remd != 0:
chek = 10 - remd
return str(chek) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'imeicsum'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; ... | Calculate the imei check byte. |
def normalize_dictionary_values(dictionary):
for key, val in dictionary.iteritems():
if isinstance(val, dict):
dictionary[key] = normalize_dictionary_values(val)
elif isinstance(val, list):
dictionary[key] = list(val)
else:
dictionary[key] = normalize_valu... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize_dictionary_values'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],... | Normalizes the values in a dictionary recursivly. |
def steady_connection(self):
return SteadyPgConnection(self._maxusage, self._setsession, True,
*self._args, **self._kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'steady_connection'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Get a steady, unpooled PostgreSQL connection. |
def redis(self):
if self._redis is None:
self._redis = redis.StrictRedis(host=self.args.redis_host, port=self.args.redis_port)
return self._redis | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'redis'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Return instance of Redis. |
def example_clinical_data(study_name, environment):
odm = ODM("test system")(
ClinicalData("Mediflex", "DEV")(
SubjectData("MDSOL", "IJS TEST4", transaction_type="Insert")(
StudyEventData("SUBJECT")(
FormData("EN", transaction_type="Update")(
ItemGrou... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'example_clinical_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Test demonstrating building clinical data |
def position_scales(self):
l = [s for s in self
if ('x' in s.aesthetics) or ('y' in s.aesthetics)]
return Scales(l) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'position_scales'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Return a list of the position scales that are present |
def _get_adj_list_adjacency(self, umis, counts, threshold):
adj_list = {umi: [] for umi in umis}
if len(umis) > 25:
umi_length = len(umis[0])
substr_idx = build_substr_idx(umis, umi_length, threshold)
iter_umi_pairs = iter_nearest_neighbours(umis, substr_idx)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_adj_list_adjacency'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'chi... | identify all umis within hamming distance threshold |
def _resume(self):
try:
self._cursor.close()
except PyMongoError:
pass
self._cursor = self._create_cursor() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_resume'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Reestablish this change stream after a resumable error. |
def zrem(self, key, member, *members):
return self.execute(b'ZREM', key, member, *members) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zrem'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Remove one or more members from a sorted set. |
def file_upload_to(self, instance, filename):
ext = filename.split(".")[-1]
filename = "{}.{}".format(uuid.uuid4(), ext)
return os.path.join("document", filename) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'file_upload_to'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Callable passed to the FileField's upload_to kwarg on Document.file |
def Forget(self, obj):
obj = _get_idstr(obj)
try:
self.memo.remove(obj)
except ValueError:
pass | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Forget'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Forget we've seen this object. |
def roll(self):
x, y, z, w = self.x, self.y, self.z, self.w
return math.atan2(2*y*w - 2*x*z, 1 - 2*y*y - 2*z*z) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'roll'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Calculates the Roll of the Quaternion. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.