code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
async def cancel_remaining(self): self._closed = True task_list = list(self._pending) for task in task_list: task.cancel() for task in task_list: with suppress(CancelledError): await task
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment identifier call identifier argument_list attribute identifier identifier for_statement identifier identifier block expression_statement call attribute id...
Cancel all remaining tasks.
def add_tag(self, resource_type, resource_id, tag, **_params): return self.put(self.tag_path % (resource_type, resource_id, tag))
module function_definition identifier parameters identifier identifier identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier tuple identifier identifier identifier
Add a tag on the resource.
def scaledBy(self, scale): scaled = deepcopy(self) for test in scaled.elements[0].tests: if type(test.value) in (int, float): if test.property == 'scale-denominator': test.value /= scale elif test.property == 'zoom': tes...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier attribute subscript attribute identifier identifier integer identifier block if_statement comparison_operator call identifier argument...
Return a new Selector with scale denominators scaled by a number.
def allocate_buffers(self): "Create the ragged array that will be filled when we ask for items." if self.ite_len is None: len(self) self.idx = LanguageModelPreLoader.CircularIndex(len(self.dataset.x.items), not self.backwards) self.batch = np.zeros((self.bs, self.bptt+1), dtype=np.int6...
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list identifier expression_statement assignment attribute identif...
Create the ragged array that will be filled when we ask for items.
def list_users(self): folders = glob('%s/*' %(self.database)) folders.sort() return [self.print_user(x) for x in folders]
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier expression_statement call attribute identifier identifier argu...
list users, each associated with a filesystem folder
def genome_coverage(covs, s2b): COV = [] for cov in covs: COV.append(parse_cov(cov, s2b)) return pd.concat(COV)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier return_statement call attribu...
calculate genome coverage from scaffold coverage
def close_spider(self, _spider): self.df['date_download'] = pd.to_datetime( self.df['date_download'], errors='coerce', infer_datetime_format=True ) self.df['date_modify'] = pd.to_datetime( self.df['date_modify'], errors='coerce', infer_datetime_format=True ) ...
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_con...
Write out to file
def open_subreddit_page(self, name): from .subreddit_page import SubredditPage with self.term.loader('Loading subreddit'): page = SubredditPage(self.reddit, self.term, self.config, self.oauth, name) if not self.term.loader.exception: retur...
module function_definition identifier parameters identifier identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list string string_start string_content s...
Open an instance of the subreddit page for the given subreddit name.
def wafer_sso_url(context, sso_method): request = context.request url = reverse(getattr(views, '%s_login' % sso_method)) if 'next' in request.GET: url += '?' + urlencode({'next': request.GET['next']}) return url
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier binary_operator string string_start string_content str...
Return the correct URL to SSO with the given method.
def symmetric_elliot_function( signal, derivative=False ): s = 1.0 abs_signal = (1 + np.abs(signal * s)) if derivative: return s / abs_signal**2 else: return (signal * s) / abs_signal
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier float expression_statement assignment identifier parenthesized_expression binary_operator integer call attribute identifier identifier argument_list binary_operator identifier ...
A fast approximation of tanh
def _get_client(): client = salt.cloud.CloudClient( os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud'), pillars=copy.deepcopy(__pillar__.get('cloud', {})) ) return client
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscr...
Return a cloud client
def update_context(app, pagename, templatename, context, doctree): context['feedback_form_url'] = feedback_form_url(app.config.project, pagename)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list attribute attribute identifier identifier identifier identifier
Update the page rendering context to include ``feedback_form_url``.
def chr_rom(self): try: return self.raw_data[self.chr_rom_start:self.chr_rom_stop] except IndexError: raise ValueError('failed to read CHR-ROM on ROM.')
module function_definition identifier parameters identifier block try_statement block return_statement subscript attribute identifier identifier slice attribute identifier identifier attribute identifier identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_c...
Return the CHR ROM of the ROM file.
def str2bytes(x): if type(x) is bytes: return x elif type(x) is str: return bytes([ ord(i) for i in x ]) else: return str2bytes(str(x))
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier identifier block return_statement identifier elif_clause comparison_operator call identifier argument_list identifier identifier block return_statement call identifier argument_lis...
Convert input argument to bytes
def __analizar_evento(self, ret): "Comprueba y extrae el wvento informativo si existen en la respuesta XML" evt = ret.get('evento') if evt: self.Eventos = [evt] self.Evento = "%(codigo)s: %(descripcion)s" % evt
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expres...
Comprueba y extrae el wvento informativo si existen en la respuesta XML
def subtract_imagenet_mean_preprocess_batch(batch): batch = F.swapaxes(batch,0, 1) (r, g, b) = F.split(batch, num_outputs=3, axis=0) r = r - 123.680 g = g - 116.779 b = b - 103.939 batch = F.concat(b, g, r, dim=0) batch = F.swapaxes(batch,0, 1) return batch
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier integer integer expression_statement assignment tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list ide...
Subtract ImageNet mean pixel-wise from a BGR image.
def rerun(client, run, job): from renku.models.provenance import ProcessRun activity = client.process_commmit() if not isinstance(activity, ProcessRun): click.secho('No tool was found.', fg='red', file=sys.stderr) return try: args = ['cwl-runner', activity.path] if job: ...
module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator call identifier argume...
Re-run existing workflow or tool using CWL runner.
def outstanding(self): done_count = 0 for item in self: if not self.wait_any and item.fire_and_forget: done_count += 1 elif item.done: done_count += 1 if self.wait_any and done_count > 0: return False if done_count == le...
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier identifier block if_statement boolean_operator not_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment identi...
Returns whether or not this barrier has pending work.
def _hline_bokeh_(self, col): c = hv.HLine(self.df[col].mean()) return c
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute subscript attribute identifier identifier identifier identifier argument_list return_statement identifier
Returns an horizontal line from a column mean value
def mail_partial_json(self): if self.mail_partial.get("date"): self._mail_partial["date"] = self.date.isoformat() return json.dumps(self.mail_partial, ensure_ascii=False, indent=2)
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_e...
Return the JSON of mail parsed partial
def color_stream_st(istream=sys.stdin, save_palette=False, **kwargs): for line in istream: filename = line.strip() try: palette = extract_colors(filename, **kwargs) except Exception as e: print(filename, e, file=sys.stderr) continue print_colors(fi...
module function_definition identifier parameters default_parameter identifier attribute identifier identifier default_parameter identifier false dictionary_splat_pattern identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_li...
Read filenames from the input stream and detect their palette.
def command_list(prog_name, prof_mgr, prof_name, prog_args): parser = argparse.ArgumentParser( prog=prog_name ) args = parser.parse_args(prog_args) prof_stub = prof_mgr.load(prof_name) out = io.StringIO() for comp_stub in prof_stub.component_list(): if comp_stub.name() is not None: out.write(comp_stub.name...
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument...
Print the list of components.
def neutralize_variables(self, tax_benefit_system): for variable_name, variable in tax_benefit_system.variables.items(): if variable.formulas: continue if self.used_as_input_variables and (variable_name in self.used_as_input_variables): continue ...
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement attribute identifier identifier block continue_statement if_statement boolean_operator attribute identi...
Neutralizing input variables not in input dataframe and keep some crucial variables
def save(self): self.write(self.term.save) self._saved = True
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier true
Saves current cursor position, so that it can be restored later
def close_comments(self, request, queryset): queryset.update(comment_enabled=False) self.message_user( request, _('Comments are now closed for selected entries.'))
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list string string...
Close the comments for selected entries.
def requote_uri(uri): import requests.utils if six.PY2: def url_encode_non_ascii(bytes): pattern = '[\x80-\xFF]' replace = lambda c: ('%%%02x' % ord(c.group(0))).upper() return re.sub(pattern, replace, bytes) parts = urlparse(uri) uri = urlunparse( ...
module function_definition identifier parameters identifier block import_statement dotted_name identifier identifier if_statement attribute identifier identifier block function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content escape_sequence...
Requote uri if it contains non-ascii chars, spaces etc.
def get(self): if self._current: return self._resume(self._current, False) else: return self._get(None)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier false else_clause block return_statement call attribute identifier identifier argument_list none
Called by the protocol consumer
def _startRecording(self, filename): self.setOption('_log_file_name', filename) self.setOption('_log_input_only', True) self.setOption('_log', True)
module function_definition identifier parameters identifier 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 string string_start string_content string_...
Start recording the session to a file for debug purposes.
def check_colormap(cmap): names = set(['BrBG', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'Blues', 'BuGn', 'BuPu', 'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', ...
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list 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 str...
Check if cmap is one of the colorbrewer maps
def update(self, other): if self._pants_workdir != other._pants_workdir: raise ValueError('Other ClasspathProducts from a different pants workdir {}'.format(other._pants_workdir)) for target, products in other._classpaths._products_by_target.items(): self._classpaths.add_for_target(target, products)...
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribut...
Adds the contents of other to this ClasspathProducts.
def _construct_derivatives(self, coefs, **kwargs): return [self.basis_functions.derivatives_factory(coef, **kwargs) for coef in coefs]
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement list_comprehension call attribute attribute identifier identifier identifier argument_list identifier dictionary_splat identifier for_in_clause identifier identifier
Return a list of derivatives given a list of coefficients.
def train(self, net_sizes, epochs, batchsize): self.trainer = ClassificationTrainer(self.data, self.targets, net_sizes) self.trainer.learn(epochs, batchsize) return self.trainer.evaluate(batchsize)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute attribute identi...
Initialize the base trainer
def bbox_vert_aligned_right(box1, box2): if not (box1 and box2): return False return abs(box1.right - box2.right) <= 2
module function_definition identifier parameters identifier identifier block if_statement not_operator parenthesized_expression boolean_operator identifier identifier block return_statement false return_statement comparison_operator call identifier argument_list binary_operator attribute identifier identifier attribute...
Returns true if the right boundary of both boxes is within 2 pts
def compute_treshold_interval(self): intervals = [m.interval for m in self.modules if hasattr(m, "interval")] if len(intervals) > 0: self.treshold_interval = round(sum(intervals) / len(intervals))
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier if_clause call identifier argument_list identifier string string_start string_content string_end if_sta...
Current method is to compute average from all intervals.
def SetCredentials(api_key,api_passwd): global V1_API_KEY global V1_API_PASSWD global _V1_ENABLED _V1_ENABLED = True V1_API_KEY = api_key V1_API_PASSWD = api_passwd
module function_definition identifier parameters identifier identifier block global_statement identifier global_statement identifier global_statement identifier expression_statement assignment identifier true expression_statement assignment identifier identifier expression_statement assignment identifier identifier
Establish API key and password associated with APIv1 commands.
def generate_config(ctx): path = click.prompt('Please specify a location for the sample gitlint config file', default=DEFAULT_CONFIG_FILE) path = os.path.abspath(path) dir_name = os.path.dirname(path) if not os.path.exists(dir_name): click.echo(u"Error: Directory '{0}' does not exist.".format(di...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identif...
Generates a sample gitlint config file.
def fullqualname_py3(obj): if type(obj).__name__ == 'builtin_function_or_method': return _fullqualname_builtin_py3(obj) elif type(obj).__name__ == 'function': return _fullqualname_function_py3(obj) elif type(obj).__name__ in ['member_descriptor', 'method_descriptor', ...
module function_definition identifier parameters identifier block if_statement comparison_operator attribute call identifier argument_list identifier identifier string string_start string_content string_end block return_statement call identifier argument_list identifier elif_clause comparison_operator attribute call id...
Fully qualified name for objects in Python 3.
def etag(self): CHUNKSIZE = 1024 * 64 from hashlib import md5 hash = md5() with open(self.path) as fin: chunk = fin.read(CHUNKSIZE) while chunk: hash_update(hash, chunk) chunk = fin.read(CHUNKSIZE) return hash.hexdigest()
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator integer integer import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list with_statement with_clause with_item a...
Generates etag from file contents.
def _get_vqa_v2_image_feature_dataset( directory, feature_url, feature_filename="mscoco_feat.tar.gz"): feature_file = generator_utils.maybe_download_from_drive( directory, feature_filename, feature_url) with tarfile.open(feature_file, "r:gz") as feature_tar: feature_tar.extractall(directory)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier with_statement with_clause with_item as_p...
Extract the VQA V2 feature data set to directory unless it's there.
async def _load_all(self): to_delete = [] for iden, val in self._hivedict.items(): try: appt = _Appt.unpack(val) if appt.iden != iden: raise s_exc.InconsistentStorage(mesg='iden inconsistency') self._addappt(iden, appt) ...
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block try_statement block expression_statement assignment identifier call attribute i...
Load all the appointments from persistent storage
def on_same_strand(self): return (self.ref_start < self.ref_end) == (self.qry_start < self.qry_end)
module function_definition identifier parameters identifier block return_statement comparison_operator parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier
Returns true iff the direction of the alignment is the same in the reference and the query
def fix_paths(project_data, rel_path, extensions): norm_func = lambda path : os.path.normpath(os.path.join(rel_path, path)) for key in extensions: if type(project_data[key]) is dict: for k,v in project_data[key].items(): project_data[key][k] = [norm_func(i) for i in v] ...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier lambda lambda_parameters identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifie...
Fix paths for extension list
def cap(v, l): s = str(v) return s if len(s) <= l else s[-l:]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement conditional_expression identifier comparison_operator call identifier argument_list identifier identifier subscript identifier slice unary_ope...
Shortens string is above certain length.
def _api_type(self, value): if isinstance(value, six.string_types): return 'string' elif isinstance(value, six.integer_types): return 'integer' elif type(value) is datetime.datetime: return 'date'
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement string string_start string_content string_end elif_clause call identifier argument_list identifier attribute identifier identifier blo...
Returns the API type of the given value based on its python type.
def _is_in_comment_type(token_type): return token_type in [TokenType.Comment, TokenType.Newline, TokenType.Whitespace, TokenType.RST, TokenType.BeginRSTComment, TokenType.BeginInlineRST,...
module function_definition identifier parameters identifier block return_statement comparison_operator identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute...
Return true if this kind of token can be inside a comment.
def parse_rules(self): try: rule_options = self.config.items('rules') except configparser.NoSectionError: raise LogRaptorConfigError("the app %r has no defined rules!" % self.name) rules = [] for option, value in rule_options: pattern = value.re...
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause attribute identifier identifier block raise_statement call ...
Add a set of rules to the app, dividing between filter and other rule set
def bs(s: int) -> str: return str(s) if s <= 1 else bs(s >> 1) + str(s & 1)
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block return_statement conditional_expression call identifier argument_list identifier comparison_operator identifier integer binary_operator call identifier argument_list binary_operator identifier integer call ...
Converts an int to its bits representation as a string of 0's and 1's.
def make_hasher(algorithm_id): if algorithm_id == 1: return hashes.Hash(hashes.SHA1(), default_backend()) elif algorithm_id == 2: return hashes.Hash(hashes.SHA384(), default_backend()) else: raise ValueError("Unsupported signing algorithm: %s" % algorithm_id)
module function_definition identifier parameters identifier block if_statement comparison_operator identifier integer block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list elif_clause comparison_operator identifier inte...
Create a hashing object for the given signing algorithm.
def extract_rpm (archive, compression, cmd, verbosity, interactive, outdir): cpio = util.find_program("cpio") if not cpio: raise util.PatoolError("cpio(1) is required for rpm2cpio extraction; please install it") path = util.shell_quote(os.path.abspath(archive)) cmdlist = [util.shell_quote(cmd), ...
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block raise_statement ...
Extract a RPM archive.
def show_event_analysis_dialog(self): self.event_analysis_dialog.update_types() self.event_analysis_dialog.update_groups() self.event_analysis_dialog.update_cycles() self.event_analysis_dialog.show()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier ...
Create the event analysis dialog.
def apply_boundary_conditions_to_cm(external_indices, cm): cm = cm.copy() cm[external_indices, :] = 0 cm[:, external_indices] = 0 return cm
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier identifier slice integer expression_statement assignment subscript identifier slice identifier i...
Remove connections to or from external nodes.
def create_domain(self, service_id, version_number, name, comment=None): body = self._formdata({ "name": name, "comment": comment, }, FastlyDomain.FIELDS) content = self._fetch("/service/%s/version/%d/domain" % (service_id, version_number), method="POST", body=body) return FastlyDomain(self, co...
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_s...
Create a domain for a particular service and version.
def validate(self): super().validate() nb_entities = len(self.entities) if nb_entities != self.rows: raise self.error( 'Number of entities: %s != number of rows: %s' % ( nb_entities, self.rows))
module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier attribute iden...
Base validation + entities = rows.
def _numeric_param_check_range(variable_name, variable_value, range_bottom, range_top): err_msg = "%s must be between %i and %i" if variable_value < range_bottom or variable_value > range_top: raise ToolkitError(err_msg % (variable_name, range_bottom, range_top))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block raise_statem...
Checks if numeric parameter is within given range
def _setup_decompressor(self, response): encoding = response.fields.get('Content-Encoding', '').lower() if encoding == 'gzip': self._decompressor = wpull.decompression.GzipDecompressor() elif encoding == 'deflate': self._decompressor = wpull.decompression.DeflateDecompres...
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list if_statemen...
Set up the content encoding decompressor.
def _simple_acronym_detection(s, i, words, *args): acronym = ''.join(words[s:i]) for _ in xrange(s, i): del words[s] words.insert(s, ''.join(acronym)) return s
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute string string_start string_end identifier argument_list subscript identifier slice identifier identifier for_statement identifier call identifie...
Detect acronyms based on runs of upper-case letters.
def change_parameters(self,params): no_of_params = 0 for core_param in range(len(self.q)): for approx_param in range(self.q[core_param].param_no): self.q[core_param].vi_change_param(approx_param, params[no_of_params]) no_of_params += 1
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block for_statement identifier call identifier argument_list attribute subs...
Utility function for changing the approximate distribution parameters
def data_to_elem_base(self): if not self.n or self._flags['sysbase'] is False: return self.R = mul(self.R, self.Sn) / self.system.mva super(GovernorBase, self).data_to_elem_base()
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator attribute identifier identifier comparison_operator subscript attribute identifier identifier string string_start string_content string_end false block return_statement expression_statement assignment attribute ...
Custom system base unconversion function
def a_urls(html): soup = BeautifulSoup(html, 'lxml') for node in soup.find_all('a'): try: href = node['href'] except KeyError: continue yield norm_url(href)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end bl...
return normalized urls found in the 'a' tag
def add_entry(self, date, entry): in_date = False insert_at = 0 for (lineno, line) in enumerate(self.lines): if isinstance(line, DateLine) and line.date == date: in_date = True insert_at = lineno continue if in_date: ...
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier false expression_statement assignment identifier integer for_statement tuple_pattern identifier identifier call identifier argument_list attribute identifier identifier block if_statement b...
Add the given entry to the textual representation.
def _patch_hover(self, element, data): if not (self.inspection_policy == 'edges' and 'hover' in self.handles): return lidx = element.nodes.get_dimension(self.label_index) src, tgt = [dimension_sanitizer(kd.name) for kd in element.kdims[:2]] if src == 'start': src += '_values'...
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator parenthesized_expression boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator string string_start string_content string_end ...
Replace edge start and end hover data with label_index data.
def switch(self, device_id, obj_slot_id): payload = { "device-context": self._build_payload(device_id, obj_slot_id) } return self._post(self.url_prefix, payload)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier ...
Switching of device-context
def edit_file(self, filename, line): if encoding.is_text_file(filename): self.edit_goto.emit(filename, 1, '')
module function_definition identifier parameters identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier integer string string_start string_end
Handle %edit magic petitions.
def update(self): for channel in self.channels: channel.update() for i in range(len(self._project_dict["channels"])): channel_dict = self._project_dict["channels"][i] for channel in self.channels: if channel.name == channel_dict["common.ALLTYPES_NAME"]...
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call identifier argument_list call identifier argument_list subscript attribute identifier ide...
Updates the dictionary of the project
def load(self, arguments): "Load the values from the a ServerConnection arguments" features = arguments[1:-1] list(map(self.load_feature, features))
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer unary_operator integer expression_statement call identifier argument_list call identifier argument...
Load the values from the a ServerConnection arguments
def close(self): if not self.__closed: self.__closed = True self.pool.return_socket(self.sock) self.sock, self.pool = None, None
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identif...
Return this instance's socket to the connection pool.
def tiff_header(read_buffer): data = struct.unpack('BB', read_buffer[0:2]) if data[0] == 73 and data[1] == 73: endian = '<' elif data[0] == 77 and data[1] == 77: endian = '>' else: msg = ("The byte order indication in the TIFF header ({byte_order}) " "is invalid. ...
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice integer integer if_statement boolean_operator comparison_operator subscript identifier ...
Interpret the uuid raw data as a tiff header.
def _modname(path): base = os.path.basename(path) filename, ext = os.path.splitext(base) return filename
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier arg...
Return a plausible module name for the path
def await_connection(host, port): for i in range(CONNECT_ATTEMPTS): try: conn = socket.create_connection((host, port), CONNECT_TIMEOUT) conn.close() return True except (IOError, socket.error): time.sleep(1) return False
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier identifier expression_stateme...
Wait for the mongo-orchestration server to accept connections.
def reset(self): self._poolingActivation = numpy.zeros((self._numColumns), dtype="int32") self._poolingColumns = [] self._overlapDutyCycles = numpy.zeros(self._numColumns, dtype=realDType) self._activeDutyCycles = numpy.zeros(self._numColumns, dtype=realDType) self._minOverlapDutyCycles = numpy.zero...
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list parenthesized_expression attribute identifier identifier keyword_argument identifier string string_start string_content string_end expressi...
Reset the state of the temporal pooler
def calculate_current_allocation(self): for ac in self.asset_classes: ac.curr_alloc = ac.curr_value * 100 / self.total_amount
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier binary_operator binary_operator attribute identifier identifier integer attribute identifier identifier
Calculates the current allocation % based on the value
def draw(self, **kwargs): labels = ("Training Score", "Cross Validation Score") curves = ( (self.train_scores_mean_, self.train_scores_std_), (self.test_scores_mean_, self.test_scores_std_), ) colors = resolve_colors(n_colors=2) for idx, (mean, std) in enu...
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier tuple tuple attribute identifier i...
Renders the training and test learning curves.
def _typedef_both(t, base=0, item=0, leng=None, refs=None, kind=_kind_static, heap=False): v = _Typedef(base=_basicsize(t, base=base), item=_itemsize(t, item), refs=refs, leng=leng, both=True, kind=kind, type=t) v.save(t, base=base, heap=heap) return v
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier none default_parameter identifier none default_parameter identifier identifier default_parameter identifier false block expression_statement assignment ident...
Add new typedef for both data and code.
def claim(ctx, vestingid, account, amount): vesting = Vesting(vestingid) if amount: amount = Amount(float(amount), "BTS") else: amount = vesting.claimable print_tx( ctx.bitshares.vesting_balance_withdraw( vesting["id"], amount=amount, account=vesting["owner"] ...
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list iden...
Claim funds from the vesting balance
def _make_paging_message(controls): return client_list_control_pb2.ClientPagingControls( start=controls.get('start', None), limit=controls.get('limit', None))
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end none keyword_argument identifier call attribute identifier id...
Turns a raw paging controls dict into Protobuf ClientPagingControls.
def average_price(quantity_1, price_1, quantity_2, price_2): return (quantity_1 * price_1 + quantity_2 * price_2) / \ (quantity_1 + quantity_2)
module function_definition identifier parameters identifier identifier identifier identifier block return_statement binary_operator parenthesized_expression binary_operator binary_operator identifier identifier binary_operator identifier identifier line_continuation parenthesized_expression binary_operator identifier i...
Calculates the average price between two asset states.
def run_from_argv(self, argv): self.argv_string = ' '.join(argv) super(EmailNotificationCommand, self).run_from_argv(argv)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute call identifier argument_list identifier ident...
Overriden in order to access the command line arguments.
def _handle_substatements(self, stmt: Statement, sctx: SchemaContext) -> None: for s in stmt.substatements: if s.prefix: key = ( sctx.schema_data.modules[sctx.text_mid].prefix_map[s.prefix][0] + ":" + s.keyword) else: ...
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block for_statement identifier attribute identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier p...
Dispatch actions for substatements of `stmt`.
def load_data(fpath, **kwargs): ext = splitext(fpath)[1] if ext in ['.pickle', '.cPkl', '.pkl']: return load_cPkl(fpath, **kwargs) elif ext in ['.json']: return load_json(fpath, **kwargs) elif ext in ['.hdf5']: return load_hdf5(fpath, **kwargs) elif ext in ['.txt']: r...
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript call identifier argument_list identifier integer if_statement comparison_operator identifier list string string_start string_content string_end string string_start s...
More generic interface to load data
def urlparse(uri): scheme, netloc, path, params, query, fragment = parse.urlparse(uri) return ( parse.unquote(scheme), parse.unquote(netloc), parse.unquote(path), parse.unquote(params), parse.unquote(query), parse.unquote(fragment) )
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier identifier call attribute identifier identifier argument_list identifier return_statement tuple call attribute identifier identifier argument_list identif...
Parse and decode the parts of a URI.
def comicDownloaded(self, comic, filename, text=None): imageUrl = self.getUrlFromFilename(filename) size = None if self.allowdownscale: size = getDimensionForImage(filename, MaxImageSize) title = '%s - %s' % (comic.name, os.path.basename(filename)) pageUrl = comic.ref...
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier none if_statement attribute identifier identifier ...
Write RSS entry for downloaded comic.
def screenshot_themes(self, *args): from time import sleep for theme in THEMES: example.set_theme(theme) example.update() sleep(0.05) self.screenshot()
module function_definition identifier parameters identifier list_splat_pattern identifier block import_from_statement dotted_name identifier dotted_name identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attri...
Take a screenshot for all themes available
def addLocalCacheService(self): "adds a CacheService to the instatiated HendrixService" _cache = self.getCacheService() _cache.setName('cache_proxy') _cache.setServiceParent(self.hendrix)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start s...
adds a CacheService to the instatiated HendrixService
def enable_asynchronous(self): def is_monkey_patched(): try: from gevent import monkey, socket except ImportError: return False if hasattr(monkey, "saved"): return "socket" in monkey.saved return gevent.socket.socket...
module function_definition identifier parameters identifier block function_definition identifier parameters block try_statement block import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier except_clause identifier block return_statement false if_statement call identifier argument_lis...
Check if socket have been monkey patched by gevent
def separator(self): cells = dict([(column, "-" * self.column_widths[column]) for column in self.columns]) return ColorRow(self, **cells)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list list_comprehension tuple identifier binary_operator string string_start string_content string_end subscript attribute identifier identifier identifier for_in_clause identifier attri...
Generate a separator row using current column widths.
def add_tokens_for_single(self, ignore=False): args = self.single.args name = self.single.python_name self.reset_indentation(self.indent_type * self.single.indent) self.result.extend(self.tokens.make_single(name, args)) if ignore: self.single.skipped = True ...
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call a...
Add the tokens for the single signature
def _add_manifest_files(zip_file, dir_name, payload_info_list, tag_info_list): for checksum_algorithm in _get_checksum_algorithm_set(payload_info_list): _add_tag_file( zip_file, dir_name, tag_info_list, _gen_manifest_file_tup(payload_info_list, checksum_algori...
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list identifier identifier identifier call identifier argument_list identifier identifier
Generate the manifest files and add them to the zip.
def _sanity_check_construct_result_block(ir_blocks): if not isinstance(ir_blocks[-1], ConstructResult): raise AssertionError(u'The last block was not ConstructResult: {}'.format(ir_blocks)) for block in ir_blocks[:-1]: if isinstance(block, ConstructResult): raise AssertionError(u'Fou...
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list subscript identifier unary_operator integer identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list ident...
Assert that ConstructResult is always the last block, and only the last block.
def n_first_author_papers(self, refresh=True): first_authors = [1 for ab in self.get_journal_abstracts(refresh=refresh) if ab.authors[0].scopusid == self.author_id] return sum(first_authors)
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier list_comprehension integer for_in_clause identifier call attribute identifier identifier argument_list keyword_argument identifier identifier if_clause comparison_operator attri...
Return number of papers with author as the first author.
def classes(self) -> Iterator[str]: yield from ( c[:-6] for c in self.path_map.keys() if c.endswith('.class') )
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement yield generator_expression subscript identifier slice unary_operator integer for_in_clause identifier call attribute attribute identifier identifier identifier argument_list...
Yield the name of all classes discovered in the path map.
def read(self): if 'r' == self._mode: return self._read_response.text elif 'rb' == self._mode: return self._read_response.content else: raise IOError("File not opened in read mode.")
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement attribute attribute identifier identifier identifier elif_clause comparison_operator string string_start string_content ...
read the contents of the file that's been opened in read mode
def rate(): auth = request.authorization if not auth or not check_auth(auth.username, auth.password): return "60/minute" else: return "600/minute"
module function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator not_operator identifier not_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block return_statement string...
Set rate limits for authenticated and nonauthenticated users.
def add_alignment(self,align): self._target_context_errors = None self._query_context_errors = None ae = AlignmentErrors(align) self._alignment_errors.append(ae) self._general_errors.add_alignment_errors(ae)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment identifier call identifier argument_list identifier expression_statement ...
Calculate alignment errors from the alignment and add it to the profile.
def log(msg, *args, **kwargs): if len(args) == 0 and len(kwargs) == 0: print(msg) else: print(msg.format(*args, **kwargs))
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator call identifier argument_list identifier integer block expression_sta...
Print out a log message.
def configure_tty(self): attr = termios.tcgetattr(self.fd) attr[1] &= ~termios.ONLCR attr[3] &= ~termios.ECHO termios.tcsetattr(self.fd, termios.TCSANOW, attr) return b'unsetopt zle 2> /dev/null;stty -echo -onlcr -ctlecho;'
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement augmented_assignment subscript identifier integer unary_operator attribute identifier identifier expression...
We don't want \n to be replaced with \r\n, and we disable the echo
def build_class(name, basenames=(), doc=None): node = nodes.ClassDef(name, doc) for base in basenames: basenode = nodes.Name() basenode.name = base node.bases.append(basenode) basenode.parent = node return node
module function_definition identifier parameters identifier default_parameter identifier tuple default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier for_statement identifier identifier block expression_statement assign...
create and initialize an astroid ClassDef node
def OnGridEditorClosed(self, event): try: dialect, self.has_header = \ self.parent.csvwidgets.get_dialect() except TypeError: event.Skip() return 0 self.fill_cells(dialect, self.has_header, choices=False)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment pattern_list identifier attribute identifier identifier line_continuation call attribute attribute attribute identifier identifier identifier identifier argument_list except_clause identifier...
Event handler for end of output type choice
def stamp_title(kb_app: kb, sphinx_app: Sphinx, doctree: doctree): resources = sphinx_app.env.resources confdir = sphinx_app.confdir source = PurePath(doctree.attributes['source']) docname = str(source.relative_to(confdir)).split('.rst')[0] resource = resources.get(do...
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 attribute attribute identifier identifier identifier expression_statement assignment identifi...
Walk the tree and extra RST title into resource.title
def cluster_set_config_epoch(self, config_epoch): fut = self.execute(b'CLUSTER', b'SET-CONFIG-EPOCH', config_epoch) return wait_ok(fut)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement call identifier argument_list...
Set the configuration epoch in a new node.
def apply(self, callback, context): def wrapper(*args, **kwargs): try: return callback(*args, **kwargs) except bottle.HTTPError as error: return self.error_wrapper.from_status( status_line=error.status_line, msg=erro...
module function_definition identifier parameters identifier identifier identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier e...
Apply the HTTPError wrapper to the callback.