code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def add_case():
ind_ids = request.form.getlist('ind_id')
case_id = request.form['case_id']
source = request.form['source']
variant_type = request.form['type']
if len(ind_ids) == 0:
return abort(400, "must add at least one member of case")
new_case = Case(case_id=case_id, name=case_id, variant_source=source,
variant_type=variant_type, variant_mode='gemini')
for ind_id in ind_ids:
ind_obj = app.db.individual(ind_id)
new_case.individuals.append(ind_obj)
app.db.session.add(new_case)
app.db.save()
return redirect(url_for('.case', case_id=new_case.name)) | module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block return_statement call identifier argument_list integer string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier | Make a new case out of a list of individuals. |
def _update_defaults(self, defaults, old_version, verbose=False):
old_defaults = self._load_old_defaults(old_version)
for section, options in defaults:
for option in options:
new_value = options[ option ]
try:
old_value = old_defaults.get(section, option)
except (cp.NoSectionError, cp.NoOptionError):
old_value = None
if old_value is None or \
to_text_string(new_value) != old_value:
self._set(section, option, new_value, verbose) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier except_clause tuple attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier none if_statement boolean_operator comparison_operator identifier none line_continuation comparison_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier | Update defaults after a change in version |
def tfds_dir():
return os.path.dirname(os.path.dirname(os.path.dirname(__file__))) | module function_definition identifier parameters block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier | Path to tensorflow_datasets directory. |
def sys_toolbox_dir():
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'esri', 'toolboxes') | module function_definition identifier parameters block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end | Returns this site-package esri toolbox directory. |
def command_exit(self, details):
log = self._params.get('log', self._discard)
pid = self._key
status = details
why = statusfmt(status)
if status:
log.warning("pid %d for %s(%s) %s", pid, self._name, self._handler_arg, why)
else:
log.info("pid %d for %s(%s) %s", pid, self._name, self._handler_arg, why) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier attribute identifier identifier identifier | Handle the event when a utility command exits. |
def inject_environment_variables(self, d):
if not d:
return d
if isinstance(d, six.string_types):
return os.path.expandvars(d)
for k, v in d.items():
if isinstance(v, six.string_types):
d[k] = os.path.expandvars(v)
elif isinstance(v, dict):
d[k] = self.inject_environment_variables(v)
elif isinstance(v, list):
d[k] = [self.inject_environment_variables(e) for e in v]
return d | module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call attribute attribute identifier identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier return_statement identifier | Recursively injects environment variables into TOML values |
def _add_plain_namespace(self, namespace):
src_name = namespace.source_name
target_name = namespace.dest_name
src_names = self._reverse_plain.setdefault(target_name, set())
src_names.add(src_name)
if len(src_names) > 1:
existing_src = (src_names - set([src_name])).pop()
raise errors.InvalidConfiguration(
"Multiple namespaces cannot be combined into one target "
"namespace. Trying to map '%s' to '%s' but there already "
"exists a mapping from '%s' to '%s'"
% (src_name, target_name, existing_src, target_name)
)
self._plain[src_name] = namespace
src_db, _ = src_name.split(".", 1)
target_db, _ = target_name.split(".", 1)
self._plain_db.setdefault(src_db, set()).add(target_db) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute parenthesized_expression binary_operator identifier call identifier argument_list list identifier identifier argument_list raise_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier call identifier argument_list identifier argument_list identifier | Add an included and possibly renamed non-wildcard Namespace. |
def text2vocab(text, output_file, text2wfreq_kwargs={}, wfreq2vocab_kwargs={}):
with tempfile.NamedTemporaryFile(suffix='.wfreq', delete=False) as f:
wfreq_file = f.name
try:
text2wfreq(text, wfreq_file, **text2wfreq_kwargs)
wfreq2vocab(wfreq_file, output_file, **wfreq2vocab_kwargs)
except ConversionError:
raise
finally:
os.remove(wfreq_file) | module function_definition identifier parameters identifier identifier default_parameter identifier dictionary default_parameter identifier dictionary block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier false as_pattern_target identifier block expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement call identifier argument_list identifier identifier dictionary_splat identifier expression_statement call identifier argument_list identifier identifier dictionary_splat identifier except_clause identifier block raise_statement finally_clause block expression_statement call attribute identifier identifier argument_list identifier | Convienience function that uses text2wfreq and wfreq2vocab to create a vocabulary file from text. |
def _help_add_edge(self, u: BaseEntity, v: BaseEntity, attr: Mapping) -> str:
self.add_node_from_data(u)
self.add_node_from_data(v)
return self._help_add_edge_helper(u, v, attr) | module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier | Help add a pre-built edge. |
def stats_printer(stats_queue):
proc_stats = [ProcessStats(i) for i in range(FLAGS.parallel)]
print_time = start_time = time.time()
width = 107
running = True
while running:
print_time += 10
while time.time() < print_time:
try:
s = stats_queue.get(True, print_time - time.time())
if s is None:
running = False
break
proc_stats[s.proc_id] = s
except queue.Empty:
pass
replay_stats = ReplayStats()
for s in proc_stats:
replay_stats.merge(s.replay_stats)
print((" Summary %0d secs " % (print_time - start_time)).center(width, "="))
print(replay_stats)
print(" Process stats ".center(width, "-"))
print("\n".join(str(s) for s in proc_stats))
print("=" * width) | module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier integer expression_statement assignment identifier true while_statement identifier block expression_statement augmented_assignment identifier integer while_statement comparison_operator call attribute identifier identifier argument_list identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list true binary_operator identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier false break_statement expression_statement assignment subscript identifier attribute identifier identifier identifier except_clause attribute identifier identifier block pass_statement expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list call attribute parenthesized_expression binary_operator string string_start string_content string_end parenthesized_expression binary_operator identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier | A thread that consumes stats_queue and prints them every 10 seconds. |
def _connect(self):
if self._connParams:
self._conn = psycopg2.connect(**self._connParams)
else:
self._conn = psycopg2.connect('')
try:
ver_str = self._conn.get_parameter_status('server_version')
except AttributeError:
ver_str = self.getParam('server_version')
self._version = util.SoftwareVersion(ver_str) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list dictionary_splat attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_end try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier | Establish connection to PostgreSQL Database. |
def write_local_file(self, outputfile, path):
self.logger.info("Writing file to %s", path)
outputfile.seek(0)
with open(path, 'wb') as fd:
copyfileobj(outputfile, fd) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list integer with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call identifier argument_list identifier identifier | Write file to the desired path. |
def _propagate_options(self, change):
"Set the values and labels, and select the first option if we aren't initializing"
options = self._options_full
self.set_trait('_options_labels', tuple(i[0] for i in options))
self._options_values = tuple(i[1] for i in options)
if self._initializing_traits_ is not True:
if len(options) > 0:
if self.index == 0:
self._notify_trait('index', 0, 0)
else:
self.index = 0
else:
self.index = None | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier generator_expression subscript identifier integer for_in_clause identifier identifier expression_statement assignment attribute identifier identifier call identifier generator_expression subscript identifier integer for_in_clause identifier identifier if_statement comparison_operator attribute identifier identifier true block if_statement comparison_operator call identifier argument_list identifier integer block if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer integer else_clause block expression_statement assignment attribute identifier identifier integer else_clause block expression_statement assignment attribute identifier identifier none | Set the values and labels, and select the first option if we aren't initializing |
def generate(self, output_dir, catalogue, results, label):
data = results.get_raw_data()
labels = catalogue.ordered_labels
ngrams = self._generate_results(output_dir, labels, data)
ngram_table = self._generate_ngram_table(output_dir, labels, data)
corpus_table = self._generate_corpus_table(labels, ngrams)
context = {'corpus_table': corpus_table, 'focus_label': label,
'labels': labels, 'ngram_table': ngram_table, 'sep': os.sep}
report_name = 'lifetime-{}.html'.format(label)
self._write(context, output_dir, report_name) | module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier | Generates the report, writing it to `output_dir`. |
def abort(self, reason):
if _debug: ClientSSM._debug("abort %r", reason)
self.set_state(ABORTED)
abort_pdu = AbortPDU(False, self.invokeID, reason)
return abort_pdu | module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list false attribute identifier identifier identifier return_statement identifier | This function is called when the transaction should be aborted. |
def search(self, filterstr, attrlist):
return self._paged_search_ext_s(self.settings.BASE, ldap.SCOPE_SUBTREE, filterstr=filterstr,
attrlist=attrlist, page_size=self.settings.PAGE_SIZE) | module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier | Query the configured LDAP server. |
def special_mode(v):
mode1 = {
0: 'Normal',
1: 'Unknown',
2: 'Fast',
3: 'Panorama',
}
mode2 = {
0: 'Non-panoramic',
1: 'Left to right',
2: 'Right to left',
3: 'Bottom to top',
4: 'Top to bottom',
}
if not v or (v[0] not in mode1 or v[2] not in mode2):
return v
return '%s - sequence %d - %s' % (mode1[v[0]], v[1], mode2[v[2]]) | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair integer string string_start string_content string_end pair integer string string_start string_content string_end pair integer string string_start string_content string_end pair integer string string_start string_content string_end expression_statement assignment identifier dictionary pair integer string string_start string_content string_end pair integer string string_start string_content string_end pair integer string string_start string_content string_end pair integer string string_start string_content string_end pair integer string string_start string_content string_end if_statement boolean_operator not_operator identifier parenthesized_expression boolean_operator comparison_operator subscript identifier integer identifier comparison_operator subscript identifier integer identifier block return_statement identifier return_statement binary_operator string string_start string_content string_end tuple subscript identifier subscript identifier integer subscript identifier integer subscript identifier subscript identifier integer | decode Olympus SpecialMode tag in MakerNote |
def stop_workers_async(self):
self._started = False
for worker in self._workers:
worker.signal_stop() | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list | Signal that all workers should stop without waiting. |
def validate_payment_form(self):
warn_untested()
form = self.payment_form_cls(self.request.POST)
if form.is_valid():
success = form.process(self.request, self.item)
if success:
return HttpResponseRedirect(self.success_url)
else:
self.context['errors'] = self.errors['processing']
self.context[self.form_context_name] = form
self.context.setdefault("errors", self.errors['form'])
return TemplateResponse(self.request, self.payment_template, self.context) | module function_definition identifier parameters identifier block expression_statement call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement identifier block return_statement call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier | Try to validate and then process the DirectPayment form. |
def stop_process(self):
self._process.terminate()
if not self._process.waitForFinished(100):
self._process.kill() | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement not_operator call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute attribute identifier identifier identifier argument_list | Stops the child process. |
def _set_aspect(self, axes, aspect):
if ((isinstance(aspect, util.basestring) and aspect != 'square') or
self.data_aspect):
data_ratio = self.data_aspect or aspect
else:
(x0, x1), (y0, y1) = axes.get_xlim(), axes.get_ylim()
xsize = np.log(x1) - np.log(x0) if self.logx else x1-x0
ysize = np.log(y1) - np.log(y0) if self.logy else y1-y0
xsize = max(abs(xsize), 1e-30)
ysize = max(abs(ysize), 1e-30)
data_ratio = 1./(ysize/xsize)
if aspect != 'square':
data_ratio = data_ratio/aspect
axes.set_aspect(data_ratio) | module function_definition identifier parameters identifier identifier identifier block if_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator call identifier argument_list identifier attribute identifier identifier comparison_operator identifier string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier boolean_operator attribute identifier identifier identifier else_clause block expression_statement assignment pattern_list tuple_pattern identifier identifier tuple_pattern identifier identifier expression_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier conditional_expression binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier attribute identifier identifier binary_operator identifier identifier expression_statement assignment identifier conditional_expression binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier attribute identifier identifier binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier float expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier float expression_statement assignment identifier binary_operator float parenthesized_expression binary_operator identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Set the aspect on the axes based on the aspect setting. |
def make(parser):
s = parser.add_subparsers(
title='commands',
metavar='COMMAND',
help='description',
)
def install_f(args):
install(args)
install_parser = install_subparser(s)
install_parser.set_defaults(func=install_f) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier | provison Manila Share with HA |
def advise(self, item, stop=False):
hszItem = DDE.CreateStringHandle(self._idInst, item, CP_WINUNICODE)
hDdeData = DDE.ClientTransaction(LPBYTE(), 0, self._hConv, hszItem, CF_TEXT, XTYP_ADVSTOP if stop else XTYP_ADVSTART, TIMEOUT_ASYNC, LPDWORD())
DDE.FreeStringHandle(self._idInst, hszItem)
if not hDdeData:
raise DDEError("Unable to %s advise" % ("stop" if stop else "start"), self._idInst)
DDE.FreeDataHandle(hDdeData) | module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list integer attribute identifier identifier identifier identifier conditional_expression identifier identifier identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression conditional_expression string string_start string_content string_end identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Request updates when DDE data changes. |
def to_jd(year, month, day):
return (day + ceil(29.5 * (month - 1)) + (year - 1) * 354 + trunc((3 + (11 * year)) / 30) + EPOCH) - 1 | module function_definition identifier parameters identifier identifier identifier block return_statement binary_operator parenthesized_expression binary_operator binary_operator binary_operator binary_operator identifier call identifier argument_list binary_operator float parenthesized_expression binary_operator identifier integer binary_operator parenthesized_expression binary_operator identifier integer integer call identifier argument_list binary_operator parenthesized_expression binary_operator integer parenthesized_expression binary_operator integer identifier integer identifier integer | Determine Julian day count from Islamic date |
def _add_title(hist: HistogramBase, vega: dict, kwargs: dict):
title = kwargs.pop("title", hist.title)
if title:
vega["title"] = {
"text": title
} | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier | Display plot title if available. |
def _to_query_json(self):
json = {
'compression': 'GZIP' if self._compressed else 'NONE',
'ignoreUnknownValues': self._ignore_unknown_values,
'maxBadRecords': self._max_bad_records,
'sourceFormat': self._bq_source_format,
'sourceUris': self._source,
}
if self._source_format == 'csv' and self._csv_options:
json['csvOptions'] = {}
json['csvOptions'].update(self._csv_options._to_query_json())
if self._schema:
json['schema'] = {'fields': self._schema._bq_schema}
return json | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_content string_end pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier return_statement identifier | Return the table as a dictionary to be used as JSON in a query job. |
def parse_buffer_to_png(data):
images = []
c1 = 0
c2 = 0
data_len = len(data)
while c1 < data_len:
if data[c2:c2 + 4] == b'IEND' and (c2 + 8 == data_len or data[c2+9:c2+12] == b'PNG'):
images.append(Image.open(BytesIO(data[c1:c2 + 8])))
c1 = c2 + 8
c2 = c1
c2 += 1
return images | module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list identifier while_statement comparison_operator identifier identifier block if_statement boolean_operator comparison_operator subscript identifier slice identifier binary_operator identifier integer string string_start string_content string_end parenthesized_expression boolean_operator comparison_operator binary_operator identifier integer identifier comparison_operator subscript identifier slice binary_operator identifier integer binary_operator identifier integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list subscript identifier slice identifier binary_operator identifier integer expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier identifier expression_statement augmented_assignment identifier integer return_statement identifier | Parse PNG file bytes to Pillow Image |
def jpegtran(ext_args):
args = copy.copy(_JPEGTRAN_ARGS)
if Settings.destroy_metadata:
args += ["-copy", "none"]
else:
args += ["-copy", "all"]
if Settings.jpegtran_prog:
args += ["-progressive"]
args += ['-outfile']
args += [ext_args.new_filename, ext_args.old_filename]
extern.run_ext(args)
return _JPEG_FORMAT | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement augmented_assignment identifier list string string_start string_content string_end string string_start string_content string_end if_statement attribute identifier identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end expression_statement augmented_assignment identifier list string string_start string_content string_end expression_statement augmented_assignment identifier list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Create argument list for jpegtran. |
def validate_image(image, number_tiles):
TILE_LIMIT = 99 * 99
try:
number_tiles = int(number_tiles)
except:
raise ValueError('number_tiles could not be cast to integer.')
if number_tiles > TILE_LIMIT or number_tiles < 2:
raise ValueError('Number of tiles must be between 2 and {} (you \
asked for {}).'.format(TILE_LIMIT, number_tiles)) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator integer integer try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier integer block raise_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier | Basic sanity checks prior to performing a split. |
def observe(self, algorithm):
if self.__observing:
raise RuntimeError('This error observer is already observing an algorithm.')
if hasattr(algorithm, 'GetExecutive') and algorithm.GetExecutive() is not None:
algorithm.GetExecutive().AddObserver(self.event_type, self)
algorithm.AddObserver(self.event_type, self)
self.__observing = True
return | module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator call identifier argument_list identifier string string_start string_content string_end comparison_operator call attribute identifier identifier argument_list none block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier true return_statement | Make this an observer of an algorithm |
def bsseval(inargs=None):
parser = argparse.ArgumentParser()
parser.add_argument(
'reference_dir',
type=str
)
parser.add_argument(
'estimates_dir',
type=str
)
parser.add_argument('-o', help='output_dir')
parser.add_argument(
'--win', type=float, help='Window size in seconds', default=1.0
)
parser.add_argument(
'--hop', type=float, help='Hop size in seconds', default=1.0
)
parser.add_argument(
'-m', type=str, help='bss_eval version [`v3`, `v4`]', default='v4'
)
parser.add_argument(
'--version', '-v',
action='version',
version='%%(prog)s %s' % util.__version__
)
args = parser.parse_args(inargs)
if not args.o:
output_dir = args.estimates_dir
else:
output_dir = args.o
data = eval_dir(
args.reference_dir,
args.estimates_dir,
output_dir=output_dir,
mode=args.m,
win=args.win,
hop=args.hop
)
print(data) | module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list identifier | Generic cli app for bsseval results. Expects two folder with |
def setup_method_options(method, tuning_options):
kwargs = {}
maxiter = numpy.prod([len(v) for v in tuning_options.tune_params.values()])
kwargs['maxiter'] = maxiter
if method in ["Nelder-Mead", "Powell"]:
kwargs['maxfev'] = maxiter
elif method == "L-BFGS-B":
kwargs['maxfun'] = maxiter
if method in ["CG", "BFGS", "L-BFGS-B", "TNC", "SLSQP"]:
kwargs['eps'] = tuning_options.eps
elif method == "COBYLA":
kwargs['rhobeg'] = tuning_options.eps
return kwargs | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier | prepare method specific options |
def _encode_dict(self, obj):
self._increment_nested_level()
buffer = []
for key in obj:
buffer.append(self._encode_key(key) + ':' + self._encode(obj[key]))
self._decrement_nested_level()
return '{'+ ','.join(buffer) + '}' | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier identifier expression_statement call attribute identifier identifier argument_list return_statement binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end | Returns a JSON representation of a Python dict |
def _cut_selection(self, *event):
if react_to_event(self.view, self.view.editor, event):
logger.debug("cut selection")
global_clipboard.cut(self.model.selection)
return True | module function_definition identifier parameters identifier list_splat_pattern identifier block if_statement call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier return_statement true | Cuts the current selection and copys it to the clipboard. |
def assert_no_leftovers(self):
leftovers = []
for name in self._members.keys():
if name in self._members and name not in self._documented:
leftovers.append(name)
if leftovers:
raise RuntimeError("%s: undocumented members: %s" %
(self._title, ", ".join(leftovers))) | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier | Generate an error if there are leftover members. |
def available(self) -> bool:
is_available = self.api.online and \
next(
attr['Value'] for attr in
self._device_json.get('Attributes', [])
if attr.get('AttributeDisplayName') == 'online') == "True"
return is_available | module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier boolean_operator attribute attribute identifier identifier identifier line_continuation comparison_operator call identifier generator_expression subscript identifier string string_start string_content string_end for_in_clause identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end list if_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end return_statement identifier | Return if device is online or not. |
def chain_getattr(obj, attr, value=None):
try:
return _resolve_value(safe_chain_getattr(obj, attr))
except AttributeError:
return value | module function_definition identifier parameters identifier identifier default_parameter identifier none block try_statement block return_statement call identifier argument_list call identifier argument_list identifier identifier except_clause identifier block return_statement identifier | Get chain attribute for an object. |
def _concat_bgzip_fastq(finputs, out_dir, read, ldetail):
out_file = os.path.join(out_dir, "%s_%s.fastq.gz" % (ldetail["name"], read))
if not utils.file_exists(out_file):
with file_transaction(out_file) as tx_out_file:
subprocess.check_call("zcat %s | bgzip -c > %s" % (" ".join(finputs), tx_out_file), shell=True)
return out_file | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end tuple subscript identifier string string_start string_content string_end identifier if_statement not_operator call attribute identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier true return_statement identifier | Concatenate multiple input fastq files, preparing a bgzipped output file. |
def _expr2bddnode(expr):
if expr.is_zero():
return BDDNODEZERO
elif expr.is_one():
return BDDNODEONE
else:
top = expr.top
_ = bddvar(top.names, top.indices)
root = top.uniqid
lo = _expr2bddnode(expr.restrict({top: 0}))
hi = _expr2bddnode(expr.restrict({top: 1}))
return _bddnode(root, lo, hi) | module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block return_statement identifier elif_clause call attribute identifier identifier argument_list block return_statement identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list dictionary pair identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list dictionary pair identifier integer return_statement call identifier argument_list identifier identifier identifier | Convert an expression into a BDD node. |
def format_BLB():
rc("figure", facecolor="white")
rc('font', family = 'serif', size=10)
rc('xtick', labelsize=10)
rc('ytick', labelsize=10)
rc('axes', linewidth=1)
rc('xtick.major', size=4, width=1)
rc('xtick.minor', size=2, width=1)
rc('ytick.major', size=4, width=1)
rc('ytick.minor', size=2, width=1) | module function_definition identifier parameters block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier integer expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier integer expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier integer expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier integer expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier integer expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier integer expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier integer | Sets some formatting options in Matplotlib. |
def _interp(self):
if np.all(self.hrow_indices == self.row_indices):
return self._interp1d()
xpoints, ypoints = np.meshgrid(self.hrow_indices,
self.hcol_indices)
for num, data in enumerate(self.tie_data):
spl = RectBivariateSpline(self.row_indices,
self.col_indices,
data,
s=0,
kx=self.kx_,
ky=self.ky_)
new_data_ = spl.ev(xpoints.ravel(), ypoints.ravel())
self.new_data[num] = new_data_.reshape(xpoints.shape).T.copy(order='C') | module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list comparison_operator attribute identifier identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier identifier keyword_argument identifier integer keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier identifier call attribute attribute call attribute identifier identifier argument_list attribute identifier identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end | Interpolate the cartesian coordinates. |
async def get(self, request):
form = await self.get_form(request)
ctx = dict(active=self, form=form, request=request)
if self.resource:
return self.app.ps.jinja2.render(self.template_item, **ctx)
return self.app.ps.jinja2.render(self.template_list, **ctx) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier await call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement attribute identifier identifier block return_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list attribute identifier identifier dictionary_splat identifier return_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list attribute identifier identifier dictionary_splat identifier | Get collection of resources. |
def show(self):
bytecode._Print("MAP_LIST SIZE", self.size)
for i in self.map_item:
if i.item != self:
i.show() | module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list | Print with a pretty display the MapList object |
def page_count(self):
postcount = self.post_set.count()
max_pages = (postcount / get_paginate_by())
if postcount % get_paginate_by() != 0:
max_pages += 1
return max_pages | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier parenthesized_expression binary_operator identifier call identifier argument_list if_statement comparison_operator binary_operator identifier call identifier argument_list integer block expression_statement augmented_assignment identifier integer return_statement identifier | Get count of total pages |
def print_status(self):
tweets = self.received
now = time.time()
diff = now - self.since
self.since = now
self.received = 0
if diff > 0:
logger.info("Receiving tweets at %s tps", tweets / diff) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier integer if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator identifier identifier | Print out the current tweet rate and reset the counter |
def main_loop(self):
while True:
for e in pygame.event.get():
self.handle_event(e)
self.step()
pygame.time.wait(5) | module function_definition identifier parameters identifier block while_statement true block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list integer | Runs the main game loop. |
def patch(self):
original = self.__dict__['__original__']
return jsonpatch.make_patch(original, dict(self)).to_string() | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end return_statement call attribute call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier argument_list | Return a jsonpatch object representing the delta |
def update(self):
stats = self.get_init_value()
if self.input_method == 'local':
stats = self.glancesgrabhddtemp.get()
else:
pass
self.stats = stats
return self.stats | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list else_clause block pass_statement expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier | Update HDD stats using the input method. |
def matrix_str(p, decimal_places=2, print_zero=True, label_columns=False):
return '[{0}]'.format("\n ".join([(str(i) if label_columns else '') + vector_str(a, decimal_places, print_zero) for i, a in enumerate(p)])) | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier true default_parameter identifier false block return_statement call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list list_comprehension binary_operator parenthesized_expression conditional_expression call identifier argument_list identifier identifier string string_start string_end call identifier argument_list identifier identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier | Pretty-print the matrix. |
def _compute_bgid(self, bg=None):
if bg is None:
bg = self._bgdata
if isinstance(bg, qpimage.QPImage):
if "identifier" in bg:
return bg["identifier"]
else:
data = [bg.amp, bg.pha]
for key in sorted(list(bg.meta.keys())):
val = bg.meta[key]
data.append("{}={}".format(key, val))
return hash_obj(data)
elif (isinstance(bg, list) and
isinstance(bg[0], qpimage.QPImage)):
data = []
for bgii in bg:
data.append(self._compute_bgid(bgii))
return hash_obj(data)
elif (isinstance(bg, SeriesData) and
(len(bg) == 1 or
len(bg) == len(self))):
return bg.identifier
else:
raise ValueError("Unknown background data type: {}".format(bg)) | module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier list attribute identifier identifier attribute identifier identifier for_statement identifier call identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement call identifier argument_list identifier elif_clause parenthesized_expression boolean_operator call identifier argument_list identifier identifier call identifier argument_list subscript identifier integer attribute identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier elif_clause parenthesized_expression boolean_operator call identifier argument_list identifier identifier parenthesized_expression boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement attribute identifier identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier | Return a unique identifier for the background data |
def cfg_from_file(self, yaml_filename, config_dict):
import yaml
from easydict import EasyDict as edict
with open(yaml_filename, 'r') as f:
yaml_cfg = edict(yaml.load(f))
return self._merge_a_into_b(yaml_cfg, config_dict) | module function_definition identifier parameters identifier identifier identifier block import_statement dotted_name identifier import_from_statement dotted_name identifier aliased_import dotted_name identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier | Load a config file and merge it into the default options. |
def response_builder(self, response):
try:
r = response.json()
result = r['query']['results']
response = {
'num_result': r['query']['count'] ,
'result': result
}
except (Exception,) as e:
print(e)
return response.content
return response | module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier except_clause as_pattern tuple identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier return_statement attribute identifier identifier return_statement identifier | Try to return a pretty formatted response object |
def _start_reader(self):
while True:
message = yield From(self.pipe.read_message())
self._process(message) | module function_definition identifier parameters identifier block while_statement true block expression_statement assignment identifier yield call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier | Read messages from the Win32 pipe server and handle them. |
def instance_query_movie_ids(self) -> List[str]:
completions_with_desc = []
for movie_id in utils.natural_sort(self.MOVIE_DATABASE_IDS):
if movie_id in self.MOVIE_DATABASE:
movie_entry = self.MOVIE_DATABASE[movie_id]
completions_with_desc.append(argparse_completer.CompletionItem(movie_id, movie_entry['title']))
self.matches_sorted = True
return completions_with_desc | module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier true return_statement identifier | Demonstrates showing tabular hinting of tab completion information |
def makeLambdaPicklable(lambda_function):
if isinstance(lambda_function,
type(lambda: None)) and lambda_function.__name__ == '<lambda>':
def __reduce_ex__(proto):
return unpickleLambda, (marshal.dumps(lambda_function.__code__), )
lambda_function.__reduce_ex__ = __reduce_ex__
return lambda_function | module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list identifier call identifier argument_list lambda none comparison_operator attribute identifier identifier string string_start string_content string_end block function_definition identifier parameters identifier block return_statement expression_list identifier tuple call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier | Take input lambda function l and makes it picklable. |
def error(bot, update, error):
logger.error('Update {} caused error {}'.format(update, error), extra={"tag": "err"}) | module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end string string_start string_content string_end | Log Errors caused by Updates. |
def duration_minutes(duration):
if isinstance(duration, list):
res = dt.timedelta()
for entry in duration:
res += entry
return duration_minutes(res)
elif isinstance(duration, dt.timedelta):
return duration.total_seconds() / 60
else:
return duration | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement augmented_assignment identifier identifier return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier attribute identifier identifier block return_statement binary_operator call attribute identifier identifier argument_list integer else_clause block return_statement identifier | returns minutes from duration, otherwise we keep bashing in same math |
def perform_flag(request, comment):
flag, created = comments.models.CommentFlag.objects.get_or_create(
comment = comment,
user = request.user,
flag = comments.models.CommentFlag.SUGGEST_REMOVAL
)
signals.comment_was_flagged.send(
sender = comment.__class__,
comment = comment,
flag = flag,
created = created,
request = request,
) | module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Actually perform the flagging of a comment from a request. |
def bt_addr_to_string(addr):
addr_str = array.array('B', addr)
addr_str.reverse()
hex_str = hexlify(addr_str.tostring()).decode('ascii')
return ':'.join(a+b for a, b in zip(hex_str[::2], hex_str[1::2])) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call identifier argument_list call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier generator_expression binary_operator identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list subscript identifier slice integer subscript identifier slice integer integer | Convert a binary string to the hex representation. |
def read_messages(fobj, magic_table):
messages = []
while True:
magic = read_magic(fobj)
if not magic:
break
func = magic_table.get(magic)
if func is not None:
messages.append(func(fobj))
else:
log.error('Unknown magic: ' + str(' '.join('{0:02x}'.format(b)
for b in bytearray(magic))))
return messages | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list while_statement true block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list call attribute string string_start string_content string_end identifier generator_expression call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier return_statement identifier | Read messages from a file-like object until stream is exhausted. |
def update(self):
params = {}
return self.send(
url=self._base_url + 'update',
method='POST',
json=params
) | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary return_statement call attribute identifier identifier argument_list keyword_argument identifier binary_operator attribute identifier identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier | Sync up changes to reminders. |
def dispatch_failed(self, context):
traceback.print_exception(
context.exc_type, context.exc_value, context.traceback)
raise SystemExit(1) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier raise_statement call identifier argument_list integer | Print the unhandled exception and exit the application. |
def js_to_url_function(converter):
if hasattr(converter, 'js_to_url_function'):
data = converter.js_to_url_function()
else:
for cls in getmro(type(converter)):
if cls in js_to_url_functions:
data = js_to_url_functions[cls](converter)
break
else:
return 'encodeURIComponent'
return '(function(value) { %s })' % data | module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block for_statement identifier call identifier argument_list call identifier argument_list identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call subscript identifier identifier argument_list identifier break_statement else_clause block return_statement string string_start string_content string_end return_statement binary_operator string string_start string_content string_end identifier | Get the JavaScript converter function from a rule. |
def _add_job_from_spec(self, job_json, use_job_id=True):
job_id = (job_json['job_id']
if use_job_id
else self.backend.get_new_job_id())
self.add_job(str(job_json['name']), job_id)
job = self.get_job(job_json['name'])
if job_json.get('cron_schedule', None):
job.schedule(job_json['cron_schedule'])
for task in job_json.get('tasks', []):
self.add_task_to_job(job,
str(task['command']),
str(task['name']),
soft_timeout=task.get('soft_timeout', 0),
hard_timeout=task.get('hard_timeout', 0),
hostname=task.get('hostname', None))
dependencies = job_json.get('dependencies', {})
for from_node, to_nodes in dependencies.iteritems():
for to_node in to_nodes:
job.add_dependency(from_node, to_node)
if job_json.get('notes', None):
job.update_job_notes(job_json['notes']) | module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment identifier parenthesized_expression conditional_expression subscript identifier string string_start string_content string_end identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end integer keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end integer keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end | Add a single job to the Dagobah from a spec. |
def check_snmp(self):
from glances.snmp import GlancesSNMPClient
clientsnmp = GlancesSNMPClient(host=self.args.client,
port=self.args.snmp_port,
version=self.args.snmp_version,
community=self.args.snmp_community,
user=self.args.snmp_user,
auth=self.args.snmp_auth)
ret = clientsnmp.get_by_oid("1.3.6.1.2.1.1.5.0") != {}
if ret:
oid_os_name = clientsnmp.get_by_oid("1.3.6.1.2.1.1.1.0")
try:
self.system_name = self.get_system_name(oid_os_name['1.3.6.1.2.1.1.1.0'])
logger.info("SNMP system name detected: {}".format(self.system_name))
except KeyError:
self.system_name = None
logger.warning("Cannot detect SNMP system name")
return ret | module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier expression_statement assignment identifier comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end dictionary if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier except_clause identifier block expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | Chek if SNMP is available on the server. |
def _process_items(cls, vals):
"Processes list of items assigning unique paths to each."
if type(vals) is cls:
return vals.data
elif not isinstance(vals, (list, tuple)):
vals = [vals]
items = []
counts = defaultdict(lambda: 1)
cls._unpack_paths(vals, items, counts)
items = cls._deduplicate_items(items)
return items | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier identifier block return_statement attribute identifier identifier elif_clause not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list lambda integer expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier | Processes list of items assigning unique paths to each. |
def colorize(string, stack):
codes = optimize(stack)
if len(codes):
prefix = SEQ % ';'.join(map(str, codes))
suffix = SEQ % STYLE.reset
return prefix + string + suffix
else:
return string | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier block expression_statement assignment identifier binary_operator identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier binary_operator identifier attribute identifier identifier return_statement binary_operator binary_operator identifier identifier identifier else_clause block return_statement identifier | Apply optimal ANSI escape sequences to the string. |
def dt2decyear(dt):
year = dt.year
startOfThisYear = datetime(year=year, month=1, day=1)
startOfNextYear = datetime(year=year+1, month=1, day=1)
yearElapsed = sinceEpoch(dt) - sinceEpoch(startOfThisYear)
yearDuration = sinceEpoch(startOfNextYear) - sinceEpoch(startOfThisYear)
fraction = yearElapsed/yearDuration
return year + fraction | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier integer expression_statement assignment identifier call identifier argument_list keyword_argument identifier binary_operator identifier integer keyword_argument identifier integer keyword_argument identifier integer expression_statement assignment identifier binary_operator call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier return_statement binary_operator identifier identifier | Convert datetime to decimal year |
def add_signal_handler():
import signal
def handler(sig, frame):
if sig == signal.SIGINT:
librtmp.RTMP_UserInterrupt()
raise KeyboardInterrupt
signal.signal(signal.SIGINT, handler) | module function_definition identifier parameters block import_statement dotted_name identifier function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list raise_statement identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier | Adds a signal handler to handle KeyboardInterrupt. |
def adjustHeadingPointer(self):
self.headingText.set_text(str(self.heading))
self.headingText.set_size(self.fontSize) | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier | Adjust the value of the heading pointer. |
def clear(actor=()):
if not settings.plotter_instance:
return
settings.plotter_instance.clear(actor)
return settings.plotter_instance | module function_definition identifier parameters default_parameter identifier tuple block if_statement not_operator attribute identifier identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement attribute identifier identifier | Clear specific actor or list of actors from the current rendering window. |
def rsl_push_many_readings(self, value, count, stream_id):
for i in range(1, count+1):
err = self.sensor_log.push(stream_id, 0, value)
if err != Error.NO_ERROR:
return [err, i]
return [Error.NO_ERROR, count] | module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier call identifier argument_list integer binary_operator identifier integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier integer identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement list identifier identifier return_statement list attribute identifier identifier identifier | Push many copies of a reading to the RSL. |
def idxstats(in_bam, data):
index(in_bam, data["config"], check_timestamp=False)
AlignInfo = collections.namedtuple("AlignInfo", ["contig", "length", "aligned", "unaligned"])
samtools = config_utils.get_program("samtools", data["config"])
idxstats_out = subprocess.check_output([samtools, "idxstats", in_bam]).decode()
out = []
for line in idxstats_out.split("\n"):
if line.strip():
contig, length, aligned, unaligned = line.split("\t")
out.append(AlignInfo(contig, int(length), int(aligned), int(unaligned)))
return out | module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list identifier subscript identifier string string_start string_content string_end keyword_argument identifier false expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list list identifier string string_start string_content string_end identifier identifier argument_list expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block if_statement call attribute identifier identifier argument_list block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier return_statement identifier | Return BAM index stats for the given file, using samtools idxstats. |
def token_gen_call(username, password):
secret_key = 'super-secret-key-please-change'
mockusername = 'User2'
mockpassword = 'Mypassword'
if mockpassword == password and mockusername == username:
return {"token" : jwt.encode({'user': username, 'data': 'mydata'}, secret_key, algorithm='HS256')}
return 'Invalid username and/or password for user: {0}'.format(username) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block return_statement dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end identifier keyword_argument identifier string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list identifier | Authenticate and return a token |
def restart(self, key):
if key in self.queue:
if self.queue[key]['status'] in ['failed', 'done']:
new_entry = {'command': self.queue[key]['command'],
'path': self.queue[key]['path']}
self.add_new(new_entry)
self.write()
return True
return False | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block if_statement comparison_operator subscript subscript attribute identifier identifier identifier string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript subscript attribute identifier identifier identifier string string_start string_content string_end pair string string_start string_content string_end subscript subscript attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement true return_statement false | Restart a previously finished entry. |
def create_scheduler_file(scheduler: str, job: Job) -> str:
logger.debug("Create Scheduler File Function")
if job.scheduler_options is None:
scheduler_options: Dict[str, Any] = {}
else:
scheduler_options = deepcopy(job.scheduler_options)
try:
setup_string = parse_setup(scheduler_options["setup"])
del scheduler_options["setup"]
except KeyError:
setup_string = ""
header_string = create_header_string(scheduler, **scheduler_options)
header_string += get_array_string(scheduler, len(job))
if scheduler.upper() == "SLURM":
workdir = r"$SLURM_SUBMIT_DIR"
array_index = r"$SLURM_ARRAY_TASK_ID"
elif scheduler.upper() == "PBS":
workdir = r"$PBS_O_WORKDIR"
array_index = r"$PBS_ARRAY_INDEX"
return header_string + SCHEDULER_TEMPLATE.format(
workdir=workdir,
command_list=job.as_bash_array(),
setup=setup_string,
array_index=array_index,
) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier type generic_type identifier type_parameter type identifier type identifier dictionary else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end delete_statement subscript identifier string string_start string_content string_end except_clause identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier expression_statement augmented_assignment identifier call identifier argument_list identifier call identifier argument_list identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end return_statement binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier | Substitute values into a template scheduler file. |
def filter_by_key(self, keys, ID=None):
keys = to_list(keys)
fil = lambda x: x in keys
if ID is None:
ID = self.ID
return self.filter(fil, applyto='keys', ID=ID) | module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier lambda lambda_parameters identifier comparison_operator identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier | Keep only Measurements with given keys. |
def delete(self):
for field_name in self._fields:
field = self.get_field(field_name)
if not isinstance(field, PKField):
field.delete()
self.connection.srem(self.get_field('pk').collection_key, self._pk)
delattr(self, "_pk") | module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier attribute identifier identifier expression_statement call identifier argument_list identifier string string_start string_content string_end | Delete the instance from redis storage. |
def add_request_session(self):
session = new_request_session(self.config, self.cookies)
self.request_sessions[thread.get_ident()] = session | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier call attribute identifier identifier argument_list identifier | Add a request session for current thread. |
def spaceout_and_resize_panels(self):
figure = self.figure
theme = self.theme
try:
aspect_ratio = theme.themeables.property('aspect_ratio')
except KeyError:
aspect_ratio = self.coordinates.aspect(
self.layout.panel_params[0])
if aspect_ratio is None:
return
left = figure.subplotpars.left
right = figure.subplotpars.right
top = figure.subplotpars.top
bottom = figure.subplotpars.bottom
W, H = figure.get_size_inches()
w = (right-left)*W
h = w*aspect_ratio
H = h / (top-bottom)
figure.set_figheight(H) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute attribute identifier identifier identifier integer if_statement comparison_operator identifier none block return_statement expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list identifier | Adjust the space between the panels |
def OnLineColor(self, event):
color = event.GetValue().GetRGB()
borders = self.bordermap[self.borderstate]
post_command_event(self, self.BorderColorMsg, color=color,
borders=borders) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | Line color choice event handler |
def _spherical_to_cartesian(cls, coord, center):
r, theta, phi, r_dot, theta_dot, phi_dot = coord
x = r * cos(phi) * cos(theta)
y = r * cos(phi) * sin(theta)
z = r * sin(phi)
vx = r_dot * x / r - y * theta_dot - z * phi_dot * cos(theta)
vy = r_dot * y / r + x * theta_dot - z * phi_dot * sin(theta)
vz = r_dot * z / r + r * phi_dot * cos(phi)
return np.array([x, y, z, vx, vy, vz], dtype=float) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier identifier identifier binary_operator identifier identifier binary_operator binary_operator identifier identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier identifier identifier binary_operator identifier identifier binary_operator binary_operator identifier identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier identifier binary_operator binary_operator identifier identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list list identifier identifier identifier identifier identifier identifier keyword_argument identifier identifier | Spherical to cartesian conversion |
def _router_request(router, method, data=None):
if router not in ROUTERS:
return False
req_data = salt.utils.json.dumps([dict(
action=router,
method=method,
data=data,
type='rpc',
tid=1)])
config = __salt__['config.option']('zenoss')
log.debug('Making request to router %s with method %s', router, method)
url = '{0}/zport/dmd/{1}_router'.format(config.get('hostname'), ROUTERS[router])
response = _session().post(url, data=req_data)
if re.search('name="__ac_name"', response.content):
log.error('Request failed. Bad username/password.')
raise Exception('Request failed. Bad username/password.')
return salt.utils.json.loads(response.content).get('result', None) | module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier identifier block return_statement false expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier identifier expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier keyword_argument identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier argument_list string string_start string_content string_end none | Make a request to the Zenoss API router |
def transformer_tall_finetune_textclass():
hparams = transformer_tall()
hparams.learning_rate_constant = 6.25e-5
hparams.learning_rate_schedule = ("linear_warmup*constant*linear_decay")
hparams.multiproblem_schedule_max_examples = 0
hparams.multiproblem_target_eval_only = True
hparams.learning_rate_warmup_steps = 50
hparams.learning_rate_decay_steps = 25000
hparams.multiproblem_reweight_label_loss = True
hparams.multiproblem_label_weight = 0.95
return hparams | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier parenthesized_expression string string_start string_content string_end expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier float return_statement identifier | Hparams for transformer on LM for finetuning on text class problems. |
def _write_header(self):
self.output_buffer += serialize_header(header=self._header, signer=self.signer)
self.output_buffer += serialize_header_auth(
algorithm=self._encryption_materials.algorithm,
header=self.output_buffer,
data_encryption_key=self._derived_data_key,
signer=self.signer,
) | module function_definition identifier parameters identifier block expression_statement augmented_assignment attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier call identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier | Builds the message header and writes it to the output stream. |
def _is_scope_prefix(scope_name, prefix_name):
if not prefix_name:
return True
if not scope_name.endswith("/"):
scope_name += "/"
if not prefix_name.endswith("/"):
prefix_name += "/"
return scope_name.startswith(prefix_name) | module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement true if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier | Checks that `prefix_name` is a proper scope prefix of `scope_name`. |
def template(ctx, url, no_input, role_name):
command_args = {
'role_name': role_name,
'subcommand': __name__,
'url': url,
'no_input': no_input,
}
t = Template(command_args)
t.execute() | module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list | Initialize a new role from a Cookiecutter URL. |
def _get_implied_apps(self, detected_apps):
def __get_implied_apps(apps):
_implied_apps = set()
for app in apps:
try:
_implied_apps.update(set(self.apps[app]['implies']))
except KeyError:
pass
return _implied_apps
implied_apps = __get_implied_apps(detected_apps)
all_implied_apps = set()
while not all_implied_apps.issuperset(implied_apps):
all_implied_apps.update(implied_apps)
implied_apps = __get_implied_apps(all_implied_apps)
return all_implied_apps | module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript subscript attribute identifier identifier identifier string string_start string_content string_end except_clause identifier block pass_statement return_statement identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list while_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier | Get the set of apps implied by `detected_apps`. |
def _void_array_to_list(restuple, _func, _args):
shape = (restuple.e.len, 1)
array_size = np.prod(shape)
mem_size = 8 * array_size
array_str_e = string_at(restuple.e.data, mem_size)
array_str_n = string_at(restuple.n.data, mem_size)
ls_e = np.frombuffer(array_str_e, float, array_size).tolist()
ls_n = np.frombuffer(array_str_n, float, array_size).tolist()
return ls_e, ls_n | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier tuple attribute attribute identifier identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator integer identifier expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier identifier identifier argument_list return_statement expression_list identifier identifier | Convert the FFI result to Python data structures |
def _get_form(self, config_name, only_required=False):
if getattr(self, config_name, None):
return import_object_by_string(getattr(self, config_name))
def use_field(field):
if not only_required:
return True
return field.default == NOT_PROVIDED
return modelform_factory(self.model, fields=[f.name for f in self.model.get_fields() if use_field(f)]) | module function_definition identifier parameters identifier identifier default_parameter identifier false block if_statement call identifier argument_list identifier identifier none block return_statement call identifier argument_list call identifier argument_list identifier identifier function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement true return_statement comparison_operator attribute identifier identifier identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier list_comprehension attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list if_clause call identifier argument_list identifier | Get form for given config else create form |
def masked(self) -> np.ndarray:
arr = self[:]
arr.shape = self.shape
arr = wt_kit.share_nans(arr, *self.parent.channels)[0]
return np.nanmean(
arr, keepdims=True, axis=tuple(i for i in range(self.ndim) if self.shape[i] == 1)
) | module function_definition identifier parameters identifier type attribute identifier identifier block expression_statement assignment identifier subscript identifier slice expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier list_splat attribute attribute identifier identifier identifier integer return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier call identifier generator_expression identifier for_in_clause identifier call identifier argument_list attribute identifier identifier if_clause comparison_operator subscript attribute identifier identifier identifier integer | Axis expression evaluated, and masked with NaN shared from data channels. |
def count_packages(self):
packages = []
for pkg in self.dmap.values():
packages += pkg
self.count_dep += 1
self.count_pkg = len(set(packages)) | module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier call identifier argument_list call identifier argument_list identifier | Count dependencies and packages |
def merge_dicts(d1, d2):
merged = copy.deepcopy(d1)
deep_update(merged, d2, True, [])
return merged | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier identifier true list return_statement identifier | Returns a new dict that is d1 and d2 deep merged. |
def get(cls, **kwargs):
data = cls._get(**kwargs)
if data is None:
new = cls()
new.from_miss(**kwargs)
return new
return cls.deserialize(data) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary_splat identifier return_statement identifier return_statement call attribute identifier identifier argument_list identifier | Get a copy of the type from the cache and reconstruct it. |
def instances_changed(self):
value = bool(lib.EnvGetInstancesChanged(self._env))
lib.EnvSetInstancesChanged(self._env, int(False))
return value | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list false return_statement identifier | True if any instance has changed. |
def publish_page(page, languages):
for language_code, lang_name in iter_languages(languages):
url = page.get_absolute_url()
if page.publisher_is_draft:
page.publish(language_code)
log.info('page "%s" published in %s: %s', page, lang_name, url)
else:
log.info('published page "%s" already exists in %s: %s', page,
lang_name, url)
return page.reload() | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier return_statement call attribute identifier identifier argument_list | Publish a CMS page in all given languages. |
def enable_torque(self, ids):
self._set_torque_enable(dict(zip(ids, itertools.repeat(True)))) | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier call attribute identifier identifier argument_list true | Enables torque of the motors with the specified ids. |
def _scene(self):
return _EmbreeWrap(vertices=self.mesh.vertices,
faces=self.mesh.faces,
scale=self._scale) | module function_definition identifier parameters identifier block return_statement call identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier | A cached version of the pyembree scene. |
def pip_install(package, fatal=False, upgrade=False, venv=None,
constraints=None, **options):
if venv:
venv_python = os.path.join(venv, 'bin/pip')
command = [venv_python, "install"]
else:
command = ["install"]
available_options = ('proxy', 'src', 'log', 'index-url', )
for option in parse_options(options, available_options):
command.append(option)
if upgrade:
command.append('--upgrade')
if constraints:
command.extend(['-c', constraints])
if isinstance(package, list):
command.extend(package)
else:
command.append(package)
log("Installing {} package with options: {}".format(package,
command))
if venv:
subprocess.check_call(command)
else:
pip_execute(command) | module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier false default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier list identifier string string_start string_content string_end else_clause block expression_statement assignment identifier list string string_start string_content string_end expression_statement assignment identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end identifier if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call identifier argument_list identifier | Install a python package |
def add_slices(self, dashboard_id):
data = json.loads(request.form.get('data'))
session = db.session()
Slice = models.Slice
dash = (
session.query(models.Dashboard).filter_by(id=dashboard_id).first())
check_ownership(dash, raise_if_false=True)
new_slices = session.query(Slice).filter(
Slice.id.in_(data['slice_ids']))
dash.slices += new_slices
session.merge(dash)
session.commit()
session.close()
return 'SLICES ADDED' | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier parenthesized_expression call attribute call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list expression_statement call identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement string string_start string_content string_end | Add and save slices to a dashboard |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.