code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def filter_files(self, path): excludes = r'|'.join([fnmatch.translate(x) for x in self.project.EXCLUDES]) or r'$.' for root, dirs, files in os.walk(path, topdown=True): dirs[:] = [d for d in dirs if not re.match(excludes, d)] dirs[:] = [os.path.join(root, d) for d in dirs] rel_path = os.path.relpath(root, path) paths = [] for f in files: if rel_path == '.': file_path = f else: file_path = os.path.join(rel_path, f) if not re.match(excludes, file_path): paths.append(f) files[:] = paths yield root, dirs, files
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier boolean_operator call attribute string string_start string_content string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute attribute identifier identifier identifier string string_start string_content string_end for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true block expression_statement assignment subscript identifier slice list_comprehension identifier for_in_clause identifier identifier if_clause not_operator call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript identifier slice list_comprehension call attribute attribute identifier identifier identifier argument_list identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier slice identifier expression_statement yield expression_list identifier identifier identifier
Exclude files based on blueprint and project configuration as well as hidden files.
def OnReplaceFind(self, event): event.text = event.GetFindString() event.flags = self._wxflag2flag(event.GetFlags()) self.OnFind(event)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
Called when a find operation is started from F&R dialog
def _preprocess_add_items(self, items): paths = [] entries = [] for item in items: if isinstance(item, string_types): paths.append(self._to_relative_path(item)) elif isinstance(item, (Blob, Submodule)): entries.append(BaseIndexEntry.from_blob(item)) elif isinstance(item, BaseIndexEntry): entries.append(item) else: raise TypeError("Invalid Type: %r" % item) return (paths, entries)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier tuple identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement tuple identifier identifier
Split the items into two lists of path strings and BaseEntries.
def tell(self): pos = ctypes.c_size_t() check_call(_LIB.MXRecordIOReaderTell(self.handle, ctypes.byref(pos))) return pos.value
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
Returns the current position of read head.
def find_project_dir(path=os.getcwd()): path_split = os.path.split(path) while path_split[1]: if in_armstrong_project(path): return path path = path_split[0] path_split = os.path.split(path) return None
module function_definition identifier parameters default_parameter identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier while_statement subscript identifier integer block if_statement call identifier argument_list identifier block return_statement identifier expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement none
Attempt to find the project root, returns None if not found
def str2actfunc(act_func): if act_func == 'sigmoid': return tf.nn.sigmoid elif act_func == 'tanh': return tf.nn.tanh elif act_func == 'relu': return tf.nn.relu
module function_definition identifier parameters identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement attribute attribute identifier identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement attribute attribute identifier identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement attribute attribute identifier identifier identifier
Convert activation function name to tf function.
def ret_range_minions(self): if HAS_RANGE is False: raise RuntimeError("Python lib 'seco.range' is not available") minions = {} range_hosts = _convert_range_to_list(self.tgt, __opts__['range_server']) return self._ret_minions(range_hosts.__contains__)
module function_definition identifier parameters identifier block if_statement comparison_operator identifier false block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list attribute identifier identifier
Return minions that are returned by a range query
def _get_symbols_to_logits_fn(self, max_decode_length): timing_signal = model_utils.get_position_encoding( max_decode_length + 1, self.params.hidden_size) decoder_self_attention_bias = model_utils.get_decoder_self_attention_bias( max_decode_length) def symbols_to_logits_fn(ids, i, cache): decoder_input = ids[:, -1:] decoder_input = self.embedding_softmax_layer(decoder_input) decoder_input += timing_signal[i:i + 1] self_attention_bias = decoder_self_attention_bias[:, :, i:i + 1, :i + 1] decoder_outputs = self.decoder_stack( decoder_input, cache.get("encoder_outputs"), self_attention_bias, cache.get("encoder_decoder_attention_bias"), cache) logits = self.embedding_softmax_layer.linear(decoder_outputs) logits = tf.squeeze(logits, axis=[1]) return logits, cache return symbols_to_logits_fn
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier integer attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript identifier slice slice unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier subscript identifier slice identifier binary_operator identifier integer expression_statement assignment identifier subscript identifier slice slice slice identifier binary_operator identifier integer slice binary_operator identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier list integer return_statement expression_list identifier identifier return_statement identifier
Returns a decoding function that calculates logits of the next tokens.
def select_eep(self, rorg_func, rorg_type, direction=None, command=None): self.rorg_func = rorg_func self.rorg_type = rorg_type self._profile = self.eep.find_profile(self._bit_data, self.rorg, rorg_func, rorg_type, direction, command) return self._profile is not None
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier identifier identifier identifier identifier return_statement comparison_operator attribute identifier identifier none
Set EEP based on FUNC and TYPE
def from_file(cls, filename, sr=22050): y, sr = librosa.load(filename, sr=sr) return cls(y, sr)
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call identifier argument_list identifier identifier
Loads an audiofile, uses sr=22050 by default.
def _handle_minion_event(self, load): id_ = load['id'] if load.get('tag', '') == '_salt_error': log.error( 'Received minion error from [%s]: %s', id_, load['data']['message'] ) for event in load.get('events', []): event_data = event.get('data', {}) if 'minions' in event_data: jid = event_data.get('jid') if not jid: continue minions = event_data['minions'] try: salt.utils.job.store_minions( self.opts, jid, minions, mminion=self.mminion, syndic_id=id_) except (KeyError, salt.exceptions.SaltCacheError) as exc: log.error( 'Could not add minion(s) %s for job %s: %s', minions, jid, exc )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier subscript subscript identifier string string_start string_content string_end 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 assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary if_statement comparison_operator string string_start string_content string_end 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 continue_statement expression_statement assignment identifier subscript identifier string string_start string_content string_end try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier except_clause as_pattern tuple identifier attribute attribute identifier identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier
Act on specific events from minions
def get(self, **kwargs): url = '%s/%s' % (self.base_url, kwargs['notification_id']) resp = self.client.list(path=url) return resp
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
Get the details for a specific notification.
def ij_jlk_to_ilk(A, B): return A.dot(B.reshape(B.shape[0], -1)).reshape(A.shape[0], B.shape[1], B.shape[2])
module function_definition identifier parameters identifier identifier block return_statement call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript attribute identifier identifier integer unary_operator integer identifier argument_list subscript attribute identifier identifier integer subscript attribute identifier identifier integer subscript attribute identifier identifier integer
Faster version of einsum 'ij,jlk->ilk'
def _scan(self): utt_sizes = {} for dset_name in self.utt_ids: per_container = [] for cnt in self.containers: dset = cnt._file[dset_name] dtype_size = dset.dtype.itemsize record_size = dtype_size * dset.size per_container.append(record_size) utt_size = sum(per_container) if utt_size > self.partition_size: raise ValueError('Records in "{0}" are larger than the partition size'.format(dset_name)) utt_sizes[dset_name] = utt_size return utt_sizes
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier binary_operator identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
For every utterance, calculate the size it will need in memory.
def minicalendar(context): today = dt.date.today() request = context['request'] home = request.site.root_page cal = CalendarPage.objects.live().descendant_of(home).first() calUrl = cal.get_url(request) if cal else None if cal: events = cal._getEventsByWeek(request, today.year, today.month) else: events = getAllEventsByWeek(request, today.year, today.month) return {'request': request, 'today': today, 'year': today.year, 'month': today.month, 'calendarUrl': calUrl, 'monthName': calendar.month_name[today.month], 'weekdayInfo': zip(weekday_abbr, weekday_name), 'events': events}
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier identifier argument_list expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list identifier identifier none if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier return_statement 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 attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end subscript attribute identifier identifier attribute identifier identifier pair string string_start string_content string_end call identifier argument_list identifier identifier pair string string_start string_content string_end identifier
Displays a little ajax version of the calendar.
def register(linter): MANAGER.register_transform(astroid.Call, transform_declare) MANAGER.register_transform(astroid.Module, transform_conf_module)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Register all transforms with the linter.
def _energy_distance_from_distance_matrices( distance_xx, distance_yy, distance_xy): return (2 * np.mean(distance_xy) - np.mean(distance_xx) - np.mean(distance_yy))
module function_definition identifier parameters identifier identifier identifier block return_statement parenthesized_expression binary_operator binary_operator binary_operator integer call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
Compute energy distance with precalculated distance matrices.
def generate_request_access_signature(parameters, secret_key): keys = parameters.keys() keys.sort() encoded_pairs = [urlencode({key: parameters[key]}) for key in keys] serialized_parameters = '&'.join(encoded_pairs) string_to_hash = '%s:%s' % (secret_key, serialized_parameters) return sha256(string_to_hash).hexdigest()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension call identifier argument_list dictionary pair identifier subscript identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier return_statement call attribute call identifier argument_list identifier identifier argument_list
Generate the parameter signature used during third party access requests
def make_category(self, string, parent=None, order=1): cat = Category( name=string.strip(), slug=slugify(SLUG_TRANSLITERATOR(string.strip()))[:49], order=order ) cat._tree_manager.insert_node(cat, parent, 'last-child', True) cat.save() if parent: parent.rght = cat.rght + 1 parent.save() return cat
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier subscript call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list slice integer keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end true expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list return_statement identifier
Make and save a category object from a string
def __rowResultToTick(self, row): keyValues = row.columns for field in TICK_FIELDS: key = "%s:%s" % (HBaseDAM.TICK, field) if 'time' != field and keyValues[key].value: keyValues[key].value = float(keyValues[key].value) return Tick(*[keyValues["%s:%s" % (HBaseDAM.TICK, field)].value for field in TICK_FIELDS])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier if_statement boolean_operator comparison_operator string string_start string_content string_end identifier attribute subscript identifier identifier identifier block expression_statement assignment attribute subscript identifier identifier identifier call identifier argument_list attribute subscript identifier identifier identifier return_statement call identifier argument_list list_splat list_comprehension attribute subscript identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier identifier for_in_clause identifier identifier
convert rowResult from Hbase to Tick
def register_views(*args): config = args[0] settings = config.get_settings() pages_config = settings[CONFIG_MODELS] resources = resources_of_config(pages_config) for resource in resources: if hasattr(resource, '__table__')\ and not hasattr(resource, 'model'): continue resource.model.pyramid_pages_template = resource.template config.add_view(resource.view, attr=resource.attr, route_name=PREFIX_PAGE, renderer=resource.template, context=resource, permission=PREFIX_PAGE)
module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block if_statement boolean_operator call identifier argument_list identifier string string_start string_content string_end line_continuation not_operator call identifier argument_list identifier string string_start string_content string_end block continue_statement expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Registration view for each resource from config.
def stopService(self): Service.stopService(self) removeDestination(self) self._reactor.callFromThread(self._reactor.stop) return deferToThreadPool( self._mainReactor, self._mainReactor.getThreadPool(), self._thread.join)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier return_statement call identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier
Stop the writer thread, wait for it to finish.
def usable_id(cls, id): try: qry_id = cls.from_name(id) if not qry_id: qry_id = cls.from_ip(id) if not qry_id: qry_id = cls.from_vhost(id) except Exception: qry_id = None if not qry_id: msg = 'unknown identifier %s' % id cls.error(msg) return qry_id
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier none if_statement not_operator identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Retrieve id from input which can be hostname, vhost, id.
def _remove_unit_rule(g, rule): new_rules = [x for x in g.rules if x != rule] refs = [x for x in g.rules if x.lhs == rule.rhs[0]] new_rules += [build_unit_skiprule(rule, ref) for ref in refs] return Grammar(new_rules)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier subscript attribute identifier identifier integer expression_statement augmented_assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list identifier
Removes 'rule' from 'g' without changing the langugage produced by 'g'.
def help_cli_search(self): help = '%sSearch: %s returns sample_sets, a sample_set is a set/list of md5s.' % (color.Yellow, color.Green) help += '\n\n\t%sSearch for all samples in the database that are known bad pe files,' % (color.Green) help += '\n\t%sthis command returns the sample_set containing the matching items'% (color.Green) help += '\n\t%s> my_bad_exes = search([\'bad\', \'exe\'])' % (color.LightBlue) help += '\n\n\t%sRun workers on this sample_set:' % (color.Green) help += '\n\t%s> pe_outputs = pe_features(my_bad_exes) %s' % (color.LightBlue, color.Normal) help += '\n\n\t%sLoop on the generator (or make a DataFrame see >help dataframe)' % (color.Green) help += '\n\t%s> for output in pe_outputs: %s' % (color.LightBlue, color.Normal) help += '\n\t\t%s print output %s' % (color.LightBlue, color.Normal) return help
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end parenthesized_expression attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end parenthesized_expression attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end parenthesized_expression attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end parenthesized_expression attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end parenthesized_expression attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier return_statement identifier
Help for Workbench CLI Search
def analyzed_projects(raw_df): df = raw_df[['PRONAC', 'proponenteCgcCpf']] analyzed_projects = df.groupby('proponenteCgcCpf')[ 'PRONAC' ].agg(['unique', 'nunique']) analyzed_projects.columns = ['pronac_list', 'num_pronacs'] return analyzed_projects
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list list string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Return all projects that was analyzed.
def updates_selection(update_selection): def handle_update(selection, *args, **kwargs): old_selection = selection.get_all() update_selection(selection, *args, **kwargs) new_selection = selection.get_all() affected_models = old_selection ^ new_selection if len(affected_models) != 0: deselected_models = old_selection - new_selection selected_models = new_selection - old_selection map(selection.relieve_model, deselected_models) map(selection.observe_model, selected_models) selection.update_core_element_lists() if selection.focus and selection.focus not in new_selection: del selection.focus affected_classes = set(model.core_element.__class__ for model in affected_models) msg_namedtuple = SelectionChangedSignalMsg(update_selection.__name__, new_selection, old_selection, affected_classes) selection.selection_changed_signal.emit(msg_namedtuple) if selection.parent_signal is not None: selection.parent_signal.emit(msg_namedtuple) return handle_update
module function_definition identifier parameters identifier block function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement call identifier argument_list attribute identifier identifier identifier expression_statement call identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier identifier block delete_statement attribute identifier identifier expression_statement assignment identifier call identifier generator_expression attribute attribute identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Decorator indicating that the decorated method could change the selection
def commit(self): self._assert_open() if self._autocommit: return if not self._conn.tds72_transaction: return self._main_cursor._commit(cont=True, isolation_level=self._isolation_level)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list if_statement attribute identifier identifier block return_statement if_statement not_operator attribute attribute identifier identifier identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true keyword_argument identifier attribute identifier identifier
Commit transaction which is currently in progress.
def chunks(seq, size): return (seq[pos:pos + size] for pos in range(0, len(seq), size))
module function_definition identifier parameters identifier identifier block return_statement generator_expression subscript identifier slice identifier binary_operator identifier identifier for_in_clause identifier call identifier argument_list integer call identifier argument_list identifier identifier
simple two-line alternative to `ubelt.chunks`
def removeMainWindow(self, mainWindow): logger.debug("removeMainWindow called") self.windowActionGroup.removeAction(mainWindow.activateWindowAction) self.repopulateAllWindowMenus() self.mainWindows.remove(mainWindow)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Removes the mainWindow from the list of windows. Saves the settings
def write_message(self, data, binary=False): self.connection.write_message(data, binary)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Write a message to the client
def ensure_no_set_overlap(train: Sequence[str], valid: Sequence[str], test: Sequence[str]) -> None: logger.debug("Ensuring that the training, validation and test data sets have no overlap") train_s = set(train) valid_s = set(valid) test_s = set(test) if train_s & valid_s: logger.warning("train and valid have overlapping items: {}".format(train_s & valid_s)) raise PersephoneException("train and valid have overlapping items: {}".format(train_s & valid_s)) if train_s & test_s: logger.warning("train and test have overlapping items: {}".format(train_s & test_s)) raise PersephoneException("train and test have overlapping items: {}".format(train_s & test_s)) if valid_s & test_s: logger.warning("valid and test have overlapping items: {}".format(valid_s & test_s)) raise PersephoneException("valid and test have overlapping items: {}".format(valid_s & test_s))
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement binary_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator identifier identifier if_statement binary_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator identifier identifier if_statement binary_operator identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator identifier identifier
Ensures no test set data has creeped into the training set.
def run_web(self, flask, host='127.0.0.1', port=5000, **options): return flask.run( host=flask.config.get('FLASK_HOST', host), port=flask.config.get('FLASK_PORT', port), debug=flask.config.get('DEBUG', False), **options )
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end false dictionary_splat identifier
Alias for Flask.run
def normalize_slice(length, index): "Fill in the Nones in a slice." is_int = False if isinstance(index, int): is_int = True index = slice(index, index+1) if index.start is None: index = slice(0, index.stop, index.step) if index.stop is None: index = slice(index.start, length, index.step) if index.start < -1: index = slice(length - index.start, index.stop, index.step) if index.stop < -1: index = slice(index.start, length - index.stop, index.step) if index.step is not None: raise NotImplementedError("You can't use steps with slicing yet") if is_int: if index.start < 0 or index.start > length: raise IndexError("index out of bounds: %r for length %s" % (index, length)) return index
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier false if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier true expression_statement assignment identifier call identifier argument_list identifier binary_operator identifier integer if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list integer attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier unary_operator integer block expression_statement assignment identifier call identifier argument_list binary_operator identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier unary_operator integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier binary_operator identifier attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end if_statement identifier block if_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement identifier
Fill in the Nones in a slice.
def mk_dir(self) : if not os.path.exists(self.abs) : os.makedirs(self.abs)
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
If this FSNode doesn't currently exist, then make a directory with this name.
def check_directory_paths(self, *args): for path in enumerate(args): path = path[1] if path is not None: try: self.check_directory_path(path) except OSError as ex: logger.warn(ex) raise return args
module function_definition identifier parameters identifier list_splat_pattern identifier block for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier integer if_statement comparison_operator identifier none block try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier raise_statement return_statement identifier
Ensure all arguments correspond to directories
def _parse(root): if root.tag == "nil-classes": return [] elif root.get("type") == "array": return [_parse(child) for child in root] d = {} for child in root: type = child.get("type") or "string" if child.get("nil"): value = None elif type == "boolean": value = True if child.text.lower() == "true" else False elif type == "dateTime": value = iso8601.parse_date(child.text) elif type == "decimal": value = decimal.Decimal(child.text) elif type == "integer": value = int(child.text) else: value = child.text d[child.tag] = value return d
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement list elif_clause comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier none elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier conditional_expression true comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end false elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier attribute identifier identifier identifier return_statement identifier
Recursively convert an Element into python data types
def validate(self, obj): if self.path: for i in self.path: obj = obj[i] obj = obj[self.field] raise NotImplementedError('Validation is not implemented yet')
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier attribute identifier identifier raise_statement call identifier argument_list string string_start string_content string_end
check if obj has this api param
def _parseSegments(self, data, elfHeader): offset = elfHeader.header.e_phoff segments = [] for i in range(elfHeader.header.e_phnum): phdr = self.__classes.PHDR.from_buffer(data, offset) segment_bytes = (c_ubyte * phdr.p_filesz).from_buffer(data, phdr.p_offset) phdrData = PhdrData(header=phdr, raw=segment_bytes, bytes=bytearray(segment_bytes), type=PT[phdr.p_type], vaddr=phdr.p_vaddr, offset=phdr.p_offset) segments.append(phdrData) offset += elfHeader.header.e_phentsize return segments
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier list for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute parenthesized_expression binary_operator identifier attribute identifier identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier subscript identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier attribute attribute identifier identifier identifier return_statement identifier
Return a list of segments
def np_lst_sq_xval(vecMdl, aryFuncChnk, aryIdxTrn, aryIdxTst): varNumXval = aryIdxTrn.shape[-1] varNumVoxChnk = aryFuncChnk.shape[-1] aryResXval = np.empty((varNumVoxChnk, varNumXval), dtype=np.float32) for idxXval in range(varNumXval): vecMdlTrn = vecMdl[aryIdxTrn[:, idxXval], :] vecMdlTst = vecMdl[aryIdxTst[:, idxXval], :] aryFuncChnkTrn = aryFuncChnk[ aryIdxTrn[:, idxXval], :] aryFuncChnkTst = aryFuncChnk[ aryIdxTst[:, idxXval], :] vecTmpPe = np.linalg.lstsq(vecMdlTrn, aryFuncChnkTrn, rcond=-1)[0] aryMdlPrdTc = np.dot(vecMdlTst, vecTmpPe) aryResXval[:, idxXval] = np.sum( (np.subtract(aryFuncChnkTst, aryMdlPrdTc))**2, axis=0) return aryResXval
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier unary_operator integer expression_statement assignment identifier subscript attribute identifier identifier unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier keyword_argument identifier attribute identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier subscript identifier slice identifier slice expression_statement assignment identifier subscript identifier subscript identifier slice identifier slice expression_statement assignment identifier subscript identifier subscript identifier slice identifier slice expression_statement assignment identifier subscript identifier subscript identifier slice identifier slice expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier unary_operator integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript identifier slice identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression call attribute identifier identifier argument_list identifier identifier integer keyword_argument identifier integer return_statement identifier
Least squares fitting in numpy with cross-validation.
def spherical(coordinates): c = coordinates r = N.linalg.norm(c,axis=0) theta = N.arccos(c[2]/r) phi = N.arctan2(c[1],c[0]) return N.column_stack((r,theta,phi))
module function_definition identifier parameters identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator subscript identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer subscript identifier integer return_statement call attribute identifier identifier argument_list tuple identifier identifier identifier
No error is propagated
def _cfactory(attr, func, argtypes, restype, errcheck=None): meth = getattr(attr, func) meth.argtypes = argtypes meth.restype = restype if errcheck: meth.errcheck = errcheck
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier identifier
Factory to create a ctypes function and automatically manage errors.
def delete_index_files(self): self.clear_cache() db_path = self.db.local_db_path() if exists(db_path): remove(db_path)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call identifier argument_list identifier block expression_statement call identifier argument_list identifier
Delete all data aside from source GTF and FASTA files
def store(bank, key, data): redis_server = _get_redis_server() redis_pipe = redis_server.pipeline() redis_key = _get_key_redis_key(bank, key) redis_bank_keys = _get_bank_keys_redis_key(bank) try: _build_bank_hier(bank, redis_pipe) value = __context__['serial'].dumps(data) redis_pipe.set(redis_key, value) log.debug('Setting the value for %s under %s (%s)', key, bank, redis_key) redis_pipe.sadd(redis_bank_keys, key) log.debug('Adding %s to %s', key, redis_bank_keys) redis_pipe.execute() except (RedisConnectionError, RedisResponseError) as rerr: mesg = 'Cannot set the Redis cache key {rkey}: {rerr}'.format(rkey=redis_key, rerr=rerr) log.error(mesg) raise SaltCacheError(mesg)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement call identifier argument_list identifier identifier expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list except_clause as_pattern tuple identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list identifier
Store the data in a Redis key.
def force_vertical_padding_after( self, index: int, padding: Union[int, float]) -> None: self.vertical_padding[index] = padding
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type none block expression_statement assignment subscript attribute identifier identifier identifier identifier
Change the padding after the given row.
def export_batch(self): batch = self.batch_cls( model=self.model, history_model=self.history_model, using=self.using ) if batch.items: try: json_file = self.json_file_cls(batch=batch, path=self.path) json_file.write() except JSONDumpFileError as e: raise TransactionExporterError(e) batch.close() return batch return None
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier if_statement attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier return_statement none
Returns a batch instance after exporting a batch of txs.
def _get_video_info(self): if not hasattr(self, '_info_cache'): encoding_backend = get_backend() try: path = os.path.abspath(self.path) except AttributeError: path = os.path.abspath(self.name) self._info_cache = encoding_backend.get_media_info(path) return self._info_cache
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier except_clause identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
Returns basic information about the video as dictionary.
def journey_options(origin: str, destination: str, via: t.Optional[str]=None, before: t.Optional[int]=None, after: t.Optional[int]=None, time: t.Optional[datetime]=None, hsl: t.Optional[bool]=None, year_card: t.Optional[bool]=None) -> ( snug.Query[t.List[Journey]]): return snug.GET('treinplanner', params={ 'fromStation': origin, 'toStation': destination, 'viaStation': via, 'previousAdvices': before, 'nextAdvices': after, 'dateTime': time, 'hslAllowed': hsl, 'yearCard': year_card, })
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type subscript attribute identifier identifier identifier none typed_default_parameter identifier type subscript attribute identifier identifier identifier none typed_default_parameter identifier type subscript attribute identifier identifier identifier none typed_default_parameter identifier type subscript attribute identifier identifier identifier none typed_default_parameter identifier type subscript attribute identifier identifier identifier none typed_default_parameter identifier type subscript attribute identifier identifier identifier none type parenthesized_expression subscript attribute identifier identifier subscript attribute identifier identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument 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 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
journey recommendations from an origin to a destination station
def component_mul(vec1, vec2): new_vec = Vector2() new_vec.X = vec1.X * vec2.X new_vec.Y = vec1.Y * vec2.Y return new_vec
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement identifier
Multiply the components of the vectors and return the result.
def setKeyboardTransformAbsolute(self, eTrackingOrigin): fn = self.function_table.setKeyboardTransformAbsolute pmatTrackingOriginToKeyboardTransform = HmdMatrix34_t() fn(eTrackingOrigin, byref(pmatTrackingOriginToKeyboardTransform)) return pmatTrackingOriginToKeyboardTransform
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list identifier call identifier argument_list identifier return_statement identifier
Set the position of the keyboard in world space
def runGetIndividual(self, id_): compoundId = datamodel.BiosampleCompoundId.parse(id_) dataset = self.getDataRepository().getDataset(compoundId.dataset_id) individual = dataset.getIndividual(id_) return self.runGetRequest(individual)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Runs a getIndividual request for the specified ID.
def close(self): self.stop_sync() [c.io.close() for c in self._controllers if c.io is not None]
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement list_comprehension call attribute attribute identifier identifier identifier argument_list for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier none
Cleans the robot by stopping synchronization and all controllers.
def process(self, metric): if self._match_metric(metric): self.metrics.append(metric) if self.should_flush(): self._send()
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list
Queue a metric. Flushing queue if batch size reached
def _check_node(self, obj): if not issubclass(type(obj), self.definition['node_class']): raise ValueError("Expected node of class " + self.definition['node_class'].__name__) if not hasattr(obj, 'id'): raise ValueError("Can't perform operation on unsaved node " + repr(obj))
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list call identifier argument_list identifier subscript attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute subscript attribute identifier identifier string string_start string_content string_end identifier if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier
check for valid node i.e correct class and is saved
def fetch_coords(self, query): q = query.add_query_parameter(req='coord') return self._parse_messages(self.get_query(q).content)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list attribute call attribute identifier identifier argument_list identifier identifier
Pull down coordinate data from the endpoint.
def init_process(self): for item in Device.objects.filter(protocol__daq_daemon=1, active=1, id__in=self.device_ids): try: tmp_device = item.get_device_instance() if tmp_device is not None: self.devices[item.pk] = tmp_device self.dt_set = min(self.dt_set, item.polling_interval) self.dt_query_data = min(self.dt_query_data, item.polling_interval) except: var = traceback.format_exc() logger.error("exception while initialisation of DAQ Process for Device %d %s %s" % ( item.pk, linesep, var)) return True
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier except_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier identifier return_statement true
init a standard daq process for multiple devices
def parse_at_root( self, root, state ): parsed_dict = self._dictionary.parse_at_root(root, state) return self._converter.from_dict(parsed_dict)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Parse the root XML element as an aggregate.
def _expand_disk(disk): ret = {} ret.update(disk.__dict__) zone = ret['extra']['zone'] ret['extra']['zone'] = {} ret['extra']['zone'].update(zone.__dict__) return ret
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end dictionary expression_statement call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier
Convert the libcloud Volume object into something more serializable.
def _dumps(obj, cls=pyjson.JSONEncoder): class WithBytes(cls): def default(self, o): if isinstance(o, bytes): warnings.warn( "Eliot will soon stop supporting encoding bytes in JSON" " on Python 3", DeprecationWarning ) return o.decode("utf-8") return cls.default(self, o) return pyjson.dumps(obj, cls=WithBytes).encode("utf-8")
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block class_definition identifier argument_list identifier block function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier identifier return_statement call attribute call attribute identifier identifier argument_list identifier keyword_argument identifier identifier identifier argument_list string string_start string_content string_end
Encode to bytes, and presume bytes in inputs are UTF-8 encoded strings.
def store_usage_stat(self, venv_data, cache): with open(self.stat_file_path, 'at') as f: self._write_venv_usage(f, venv_data)
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Log an usage record for venv_data.
def open(self, path, filename=None): scheme, key = self.getkey(path, filename=filename) return BotoReadFileHandle(scheme, key)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call identifier argument_list identifier identifier
Open a file specified by path.
def bookmarks_index_changed(self): index = self.bookmarks_list.currentIndex() if index >= 0: self.tool.reset() rectangle = self.bookmarks_list.itemData(index) self.tool.set_rectangle(rectangle) self.canvas.setExtent(rectangle) self.ok_button.setEnabled(True) else: self.ok_button.setDisabled(True)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list 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 identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list true else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list true
Update the UI when the bookmarks combobox has changed.
def append_static_code(filename, outf): basepath = os.path.dirname(os.path.realpath(__file__)) filepath = os.path.join(basepath, 'swift/%s' % filename) print("Appending content of %s" % filename) with open(filepath) as inf: for line in inf: outf.write(line)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Open and copy static code from specified file
def run_cmd_unit(self, sentry_unit, cmd): output, code = sentry_unit.run(cmd) if code == 0: self.log.debug('{} `{}` command returned {} ' '(OK)'.format(sentry_unit.info['unit_name'], cmd, code)) else: msg = ('{} `{}` command returned {} ' '{}'.format(sentry_unit.info['unit_name'], cmd, code, output)) amulet.raise_status(amulet.FAIL, msg=msg) return str(output), code
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier identifier else_clause block expression_statement assignment identifier parenthesized_expression call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier return_statement expression_list call identifier argument_list identifier identifier
Run a command on a unit, return the output and exit code.
def posted_data_dict(self): if not self.query: return None from django.http import QueryDict roughdecode = dict(item.split('=', 1) for item in self.query.split('&')) encoding = roughdecode.get('charset', None) if encoding is None: encoding = DEFAULT_ENCODING query = self.query.encode('ascii') data = QueryDict(query, encoding=encoding) return data.dict()
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement none import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier generator_expression call attribute identifier identifier argument_list string string_start string_content string_end integer for_in_clause identifier 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 string string_start string_content string_end none if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list
All the data that PayPal posted to us, as a correctly parsed dictionary of values.
def stop(self): self._logger.debug("The Slack RTMClient is shutting down.") self._stopped = True self._close_websocket()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list
Closes the websocket connection and ensures it won't reconnect.
def rotate(self, log): self.write(log, rotate=True) self.write({})
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list dictionary
Move the current log to a new file with timestamp and create a new empty log file.
def rule_low_registers(self, arg): r_num = self.check_register(arg) if r_num > 7: raise iarm.exceptions.RuleError( "Register {} is not a low register".format(arg))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block raise_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Low registers are R0 - R7
def progress_updater(size, total): current_task.update_state( state=state('PROGRESS'), meta=dict(size=size, total=total) )
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Progress reporter for checksum verification.
def _getitem(self, key): key = int(key) if key < 0: key %= self._len if len(self._pages) == 1 and 0 < key < self._len: index = self._pages[0].index return self.parent.pages._getitem(index + key) return self._pages[key]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier attribute identifier identifier if_statement boolean_operator comparison_operator call identifier argument_list attribute identifier identifier integer comparison_operator integer identifier attribute identifier identifier block expression_statement assignment identifier attribute subscript attribute identifier identifier integer identifier return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list binary_operator identifier identifier return_statement subscript attribute identifier identifier identifier
Return specified page of series from cache or file.
def _add_post_data(self, request: Request): if self._item_session.url_record.post_data: data = wpull.string.to_bytes(self._item_session.url_record.post_data) else: data = wpull.string.to_bytes( self._processor.fetch_params.post_data ) request.method = 'POST' request.fields['Content-Type'] = 'application/x-www-form-urlencoded' request.fields['Content-Length'] = str(len(data)) _logger.debug('Posting with data {0}.', data) if not request.body: request.body = Body(io.BytesIO()) with wpull.util.reset_file_offset(request.body): request.body.write(data)
module function_definition identifier parameters identifier typed_parameter identifier type identifier block if_statement attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add data to the payload.
def create_zpaq(archive, compression, cmd, verbosity, interactive, filenames): cmdlist = [cmd, 'a', archive] cmdlist.extend(filenames) cmdlist.extend(['-method', '4']) return cmdlist
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier list identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Create a ZPAQ archive.
def std(self, bessel_correction=True): if bessel_correction: n = self.n bc = n / (n - 1) else: bc = 1 return np.sqrt(np.average((self.bin_centers - self.mean) ** 2, weights=self.histogram)) * bc
module function_definition identifier parameters identifier default_parameter identifier true block if_statement identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier integer else_clause block expression_statement assignment identifier integer return_statement binary_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier integer keyword_argument identifier attribute identifier identifier identifier
Estimates std of underlying data, assuming each datapoint was exactly in the center of its bin.
def io_surface(timestep, time, fid, fld): fid.write("{} {}".format(timestep, time)) fid.writelines(["%10.2e" % item for item in fld[:]]) fid.writelines(["\n"])
module function_definition identifier parameters identifier 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 expression_statement call attribute identifier identifier argument_list list_comprehension binary_operator string string_start string_content string_end identifier for_in_clause identifier subscript identifier slice expression_statement call attribute identifier identifier argument_list list string string_start string_content escape_sequence string_end
Output for surface files
def _work(self): server = wsgi.Server( name=self._AGENT_BINARY, num_threads=CONF.AGENT.worker_count) server.start( application=_MetadataProxyHandler(), port=CONF.bind_port, host=CONF.bind_host) server.wait()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Start the neutron-hnv-metadata-proxy agent.
def ancestors(self, cl=None, noduplicates=True): if not cl: cl = self if cl.parents(): bag = [] for x in cl.parents(): if x.uri != cl.uri: bag += [x] + self.ancestors(x, noduplicates) else: bag += [x] if noduplicates: return remove_duplicates(bag) else: return bag else: return []
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true block if_statement not_operator identifier block expression_statement assignment identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment identifier binary_operator list identifier call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement augmented_assignment identifier list identifier if_statement identifier block return_statement call identifier argument_list identifier else_clause block return_statement identifier else_clause block return_statement list
returns all ancestors in the taxonomy
def device_at_index(self, index): if index >= len(self.__xid_cons): raise ValueError("Invalid device index") return self.__xid_cons[index]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement subscript attribute identifier identifier identifier
Returns the device at the specified index
def _aix_loadavg(): uptime = __salt__['cmd.run']('uptime') ldavg = uptime.split('load average') load_avg = ldavg[1].split() return {'1-min': load_avg[1].strip(','), '5-min': load_avg[2].strip(','), '15-min': load_avg[3]}
module function_definition identifier parameters block 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 assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute subscript identifier integer identifier argument_list return_statement dictionary pair string string_start string_content string_end call attribute subscript identifier integer identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute subscript identifier integer identifier argument_list string string_start string_content string_end pair string string_start string_content string_end subscript identifier integer
Return the load average on AIX
def append(self, item): print(item) super(MyList, self).append(item)
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
append item and print it to stdout
def dict2obj(d): if isinstance(d, (list, tuple)): d = [dict2obj(x) for x in d] if not isinstance(d, dict): return d class ObjectFromDict(object): pass o = ObjectFromDict() for k in d: o.__dict__[k] = dict2obj(d[k]) return o
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier if_statement not_operator call identifier argument_list identifier identifier block return_statement identifier class_definition identifier argument_list identifier block pass_statement expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list subscript identifier identifier return_statement identifier
A helper function which convert a dict to an object.
def split_focus(self): focus = self.lines[self.focus] pos = focus.edit_pos edit = urwid.Edit("", focus.edit_text[pos:], allow_tab=True) edit.original_text = "" focus.set_edit_text(focus.edit_text[:pos]) edit.set_edit_pos(0) self.lines.insert(self.focus + 1, edit)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end subscript attribute identifier identifier slice identifier keyword_argument identifier true expression_statement assignment attribute identifier identifier string string_start string_end expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier slice identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator attribute identifier identifier integer identifier
Divide the focus edit widget at the cursor location.
def _handle_ctrl_c(self, *args): if self.anybar: self.anybar.change("exclamation") if self._stop: print("\nForced shutdown...") raise SystemExit if not self._stop: hline = 42 * '=' print( '\n' + hline + "\nGot CTRL+C, waiting for current cycle...\n" "Press CTRL+C again if you're in hurry!\n" + hline ) self._stop = True
module function_definition identifier parameters identifier list_splat_pattern identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content escape_sequence string_end raise_statement identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier binary_operator integer string string_start string_content string_end expression_statement call identifier argument_list binary_operator binary_operator binary_operator string string_start string_content escape_sequence string_end identifier concatenated_string string string_start string_content escape_sequence escape_sequence string_end string string_start string_content escape_sequence string_end identifier expression_statement assignment attribute identifier identifier true
Handle the keyboard interrupts.
def _map_tril_1d_on_2d(indices, dims): N = (dims * dims - dims) / 2 m = np.ceil(np.sqrt(2 * N)) c = m - np.round(np.sqrt(2 * (N - indices))) - 1 r = np.mod(indices + (c + 1) * (c + 2) / 2 - 1, m) + 1 return np.array([r, c], dtype=np.int64)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator integer identifier expression_statement assignment identifier binary_operator binary_operator identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator integer parenthesized_expression binary_operator identifier identifier integer expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list binary_operator binary_operator identifier binary_operator binary_operator parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator identifier integer integer integer identifier integer return_statement call attribute identifier identifier argument_list list identifier identifier keyword_argument identifier attribute identifier identifier
Map 1d indices on lower triangular matrix in 2d.
def wait(self): logging.info("waiting for {} jobs to complete".format(len(self.submissions))) while not self.shutdown: time.sleep(1)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier while_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list integer
Waits for all submitted jobs to complete.
def out_of_date(self): try: latest_remote_sha = self.pr_commits(self.pull_request.refresh(True))[-1].sha print("Latest remote sha: {}".format(latest_remote_sha)) try: print("Ratelimit remaining: {}".format(self.github.ratelimit_remaining)) except Exception: print("Failed to look up ratelimit remaining") return self.last_sha != latest_remote_sha except IndexError: return False
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier attribute subscript call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list true unary_operator integer identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier try_statement block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement comparison_operator attribute identifier identifier identifier except_clause identifier block return_statement false
Check if our local latest sha matches the remote latest sha
def list_build_records_for_set(id=None, name=None, page_size=200, page_index=0, sort="", q=""): content = list_build_records_for_set_raw(id, name, page_size, page_index, sort, q) if content: return utils.format_json_list(content)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier integer default_parameter identifier string string_start string_end default_parameter identifier string string_start string_end block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
List all build records for a BuildConfigurationSet
def delete(sql, *args, **kwargs): assert "delete" in sql.lower(), 'This function requires a delete statement, provided: {}'.format(sql) CoyoteDb.execute_and_commit(sql, *args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block assert_statement comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Deletes and commits with an insert sql statement
def action(self): user = self.args['--user'] if self.args['--user'] else None reset = True if self.args['--reset'] else False if self.args['generate']: generate_network(user, reset) elif self.args['publish']: publish_network(user, reset)
module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end none expression_statement assignment identifier conditional_expression true subscript attribute identifier identifier string string_start string_content string_end false if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier identifier elif_clause subscript attribute identifier identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier identifier
Invoke functions according to the supplied flags
def tick(self): instant_rate = self.count / float(self.tick_interval_s) self.count = 0 if self.initialized: self.rate += (self.alpha * (instant_rate - self.rate)) else: self.rate = instant_rate self.initialized = True
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier integer if_statement attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier parenthesized_expression binary_operator identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier true
Mark the passage of time and decay the current rate accordingly.
def header_length(bytearray): groups_of_3, leftover = divmod(len(bytearray), 3) n = groups_of_3 * 4 if leftover: n += 4 return n
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier integer expression_statement assignment identifier binary_operator identifier integer if_statement identifier block expression_statement augmented_assignment identifier integer return_statement identifier
Return the length of s when it is encoded with base64.
def _estimate_paired_innerdist(fastq_file, pair_file, ref_file, out_base, out_dir, data): mean, stdev = _bowtie_for_innerdist("100000", fastq_file, pair_file, ref_file, out_base, out_dir, data, True) if not mean or not stdev: mean, stdev = _bowtie_for_innerdist("1", fastq_file, pair_file, ref_file, out_base, out_dir, data, True) if not mean or not stdev: mean, stdev = 200, 50 return mean, stdev
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list string string_start string_content string_end identifier identifier identifier identifier identifier identifier true if_statement boolean_operator not_operator identifier not_operator identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list string string_start string_content string_end identifier identifier identifier identifier identifier identifier true if_statement boolean_operator not_operator identifier not_operator identifier block expression_statement assignment pattern_list identifier identifier expression_list integer integer return_statement expression_list identifier identifier
Use Bowtie to estimate the inner distance of paired reads.
def _cutoff(self, coeffs, vscale): bnd = self._threshold(vscale) inds = np.nonzero(abs(coeffs) >= bnd) if len(inds[0]): N = inds[0][-1] else: N = 0 return N+1
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator call identifier argument_list identifier identifier if_statement call identifier argument_list subscript identifier integer block expression_statement assignment identifier subscript subscript identifier integer unary_operator integer else_clause block expression_statement assignment identifier integer return_statement binary_operator identifier integer
Compute cutoff index after which the coefficients are deemed negligible.
def median(self, name, **kwargs): data = self.get(name,**kwargs) return np.percentile(data,[50])
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement call attribute identifier identifier argument_list identifier list integer
Median of the distribution.
def _guess_caller(): import inspect global _caller_path caller = inspect.stack()[1] caller_module = inspect.getmodule(caller[0]) if hasattr(caller_module, '__file__'): _caller_path = os.path.abspath(caller_module.__file__) return _caller_path
module function_definition identifier parameters block import_statement dotted_name identifier global_statement identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement identifier
try to guess which module import app.py
def to_data(s): if s.startswith('GPSTime'): s = 'Gps' + s[3:] if '_' in s: return "".join([i.capitalize() for i in s.split("_")]) return s
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript identifier slice integer if_statement comparison_operator string string_start string_content string_end identifier block return_statement call attribute string string_start string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Format a data variable name.
def generate_security_data(self): timestamp = int(time.time()) security_dict = { 'content_type': str(self.target_object._meta), 'object_pk': str(self.target_object._get_pk_val()), 'timestamp': str(timestamp), 'security_hash': self.initial_security_hash(timestamp), } return security_dict
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list attribute attribute identifier identifier identifier pair string string_start string_content string_end call identifier argument_list call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement identifier
Generate a dict of security data for "initial" data.
def new_batch(self): i = next(self.slicer) return self.X_all[i], self.Y_all[i]
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier return_statement expression_list subscript attribute identifier identifier identifier subscript attribute identifier identifier identifier
Return a new batch of X and Y by taking a chunk of data from the complete X and Y
def acit(rest): "Look up an acronym" word = rest.strip() res = util.lookup_acronym(word) if res is None: return "Arg! I couldn't expand that..." else: return ' | '.join(res)
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 assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement string string_start string_content string_end else_clause block return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Look up an acronym
def form_valid(self, form): form.cleaned_data.pop('template', None) self.request.session[EMAIL_VALIDATION_STR] = {'form_data': form.cleaned_data} return HttpResponseRedirect(reverse('emailConfirmation'))
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none expression_statement assignment subscript attribute attribute identifier identifier identifier identifier dictionary pair string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end
Pass form data to the confirmation view
def logReload(options): event_handler = Reload(options) observer = Observer() observer.schedule(event_handler, path='.', recursive=True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() pid = os.getpid() chalk.eraser() chalk.green('\nHendrix successfully closed.') os.kill(pid, 15) observer.join() exit('\n')
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier true expression_statement call attribute identifier identifier argument_list try_statement block while_statement true block expression_statement call attribute identifier identifier argument_list integer except_clause identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content escape_sequence string_end
encompasses all the logic for reloading observer.