code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def spin2_polar(self): return coordinates.cartesian_to_spherical_polar( self.spin2x, self.spin2y, self.spin2z)
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
Returns the polar spin angle of mass 2.
def tag_path(cls, project, incident, tag): return google.api_core.path_template.expand( "projects/{project}/incidents/{incident}/tags/{tag}", project=project, incident=incident, tag=tag, )
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Return a fully-qualified tag string.
def record_coverage_zero(self, rule, offset): self.coverage_lines.append('DA:{},0'.format(rule.source_line + offset))
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list binary_operator attribute identifier identifier identifier
Add entry to coverage saying this selector was parsed
def _get_url(ssl, url, port, path): if ssl: return 'https://{0}:{1}/management/domain/{2}'.format(url, port, path) else: return 'http://{0}:{1}/management/domain/{2}'.format(url, port, path)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier else_clause block return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier
Returns the URL of the endpoint
def check_future(self, fut): done = self.done = fut.done() if done and not self.prev_done: self.done_since = self.ioloop.time() self.prev_done = done
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier assignment attribute identifier identifier call attribute identifier identifier argument_list if_statement boolean_operator identifier not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier
Call with each future that is to be yielded on
def _collect_for_instance(self, instance, connection): with connection.cursor() as cursor: for queue, metrics in self.get_queue_info(instance, cursor): for name, metric in metrics.items(): self.publish('.'.join((instance, queue, name)), metric) with connection.cursor() as cursor: consumers = self.get_consumer_info(instance, cursor) for queue, consumer, metrics in consumers: for name, metric in metrics.items(): key_parts = (instance, queue, 'consumers', consumer, name) self.publish('.'.join(key_parts), metric)
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list tuple identifier identifier identifier identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier for_statement pattern_list identifier identifier identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier tuple identifier identifier string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
Collects metrics for a named connection.
def update_order(self, order_id, order_deets): request = self._put("transactions/orders/" + str(order_id), order_deets) return self.responder(request)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier
Updates an existing order transaction.
def query(self, model_cls): self._filters_cmd = list() self.query_filters = list() self._order_by_cmd = None self._offset = 0 self._limit = 0 self.query_class = model_cls._name return self
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier
SQLAlchemy query like method
def ScheduleKillNotification(self): kill_timestamp = (rdfvalue.RDFDatetime().Now() + self.stuck_flows_timeout) with queue_manager.QueueManager(token=self.token) as manager: manager.QueueNotification( session_id=self.session_id, in_progress=True, timestamp=kill_timestamp) self.context.kill_timestamp = kill_timestamp
module function_definition identifier parameters identifier block expression_statement assignment identifier parenthesized_expression binary_operator call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier true keyword_argument identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier
Schedules a kill notification for this flow.
def format_command( command_args, command_output, ): text = 'Command arguments: {}\n'.format(command_args) if not command_output: text += 'Command output: None' elif logger.getEffectiveLevel() > logging.DEBUG: text += 'Command output: [use --verbose to show]' else: if not command_output.endswith('\n'): command_output += '\n' text += ( 'Command output:\n{}' '-----------------------------------------' ).format(command_output) return text
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier if_statement not_operator identifier block expression_statement augmented_assignment identifier string string_start string_content string_end elif_clause comparison_operator call attribute identifier identifier argument_list attribute identifier identifier block expression_statement augmented_assignment identifier string string_start string_content string_end else_clause block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier call attribute parenthesized_expression concatenated_string string string_start string_content escape_sequence string_end string string_start string_content string_end identifier argument_list identifier return_statement identifier
Format command information for logging.
def isDeleteKeyEvent(self, keyEvent): return self._start is not None and \ (keyEvent.matches(QKeySequence.Delete) or \ (keyEvent.key() == Qt.Key_Backspace and keyEvent.modifiers() == Qt.NoModifier))
module function_definition identifier parameters identifier identifier block return_statement boolean_operator comparison_operator attribute identifier identifier none line_continuation parenthesized_expression boolean_operator call attribute identifier identifier argument_list attribute identifier identifier line_continuation parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list attribute identifier identifier comparison_operator call attribute identifier identifier argument_list attribute identifier identifier
Check if key event should be handled as Delete command
def _GetServiceKey(): global _service_key if _service_key is None: hive = getattr(winreg, config.CONFIG["Client.config_hive"]) path = config.CONFIG["Client.config_key"] _service_key = winreg.CreateKeyEx(hive, path, 0, winreg.KEY_ALL_ACCESS) return _service_key
module function_definition identifier parameters block global_statement identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier integer attribute identifier identifier return_statement identifier
Returns the service key.
def s3path(self, rel_path): import urlparse path = self.path(rel_path, public_url=True) parts = list(urlparse.urlparse(path)) parts[0] = 's3' parts[1] = self.bucket_name return urlparse.urlunparse(parts)
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier integer string string_start string_content string_end expression_statement assignment subscript identifier integer attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
Return the path as an S3 schema
def clearAnnouncements(self): try: q = models.Announcement.delete().where( models.Announcement.id > 0) q.execute() except Exception as e: raise exceptions.RepoManagerException(e)
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list comparison_operator attribute attribute identifier identifier identifier integer expression_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block raise_statement call attribute identifier identifier argument_list identifier
Flushes the announcement table.
def update_channels(self): if not self.gui_up: return self.logger.debug("channel configuration has changed--updating gui") try: channel = self.fv.get_channel(self.chname) except KeyError: channel = self.fv.get_channel_info() if channel is None: raise ValueError('No channel available') self.chname = channel.name w = self.w.channel_name w.clear() self.chnames = list(self.fv.get_channel_names()) for chname in self.chnames: w.append_text(chname) try: i = self.chnames.index(channel.name) except IndexError: i = 0 self.w.channel_name.set_index(i) self.redo()
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end 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 if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier 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 integer expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Update the GUI to reflect channels and image listing.
def _detach_children(self): children = [val[0] for val in self._children.values()] for child in children: child()._parent = list(self) self._children.clear()
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier identifier block expression_statement assignment attribute call identifier argument_list identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Remove all children and give them independent parent copies.
def cnormpath (path): path = normpath(path) if os.name == 'nt': path = path.replace("/", "\\") if not os.path.isabs(path): path = normpath(os.path.join(sys.prefix, path)) return path
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
Norm a path name to platform specific notation and make it absolute.
def show_service_profile(self, flavor_profile, **_params): return self.get(self.service_profile_path % (flavor_profile), params=_params)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier parenthesized_expression identifier keyword_argument identifier identifier
Fetches information for a certain Neutron service flavor profile.
def default_arguments(cls): func = cls.__init__ args = func.__code__.co_varnames defaults = func.__defaults__ index = -len(defaults) return {k: v for k, v in zip(args[index:], defaults)}
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier unary_operator call identifier argument_list identifier return_statement dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list subscript identifier slice identifier identifier
Returns the available kwargs of the called class
def __SetBody(self, http_request, method_config, request, upload): if not method_config.request_field: return request_type = _LoadClass( method_config.request_type_name, self.__client.MESSAGES_MODULE) if method_config.request_field == REQUEST_IS_BODY: body_value = request body_type = request_type else: body_value = getattr(request, method_config.request_field) body_field = request_type.field_by_name( method_config.request_field) util.Typecheck(body_field, messages.MessageField) body_type = body_field.type body_value = body_value or body_type() if upload and not body_value: return util.Typecheck(body_value, body_type) http_request.headers['content-type'] = 'application/json' http_request.body = self.__client.SerializeMessage(body_value)
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier boolean_operator identifier call identifier argument_list if_statement boolean_operator identifier not_operator identifier block return_statement expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier
Fill in the body on http_request.
def transformToNative(obj): if obj.isNative: return obj obj.isNative = True if obj.value == '': obj.value = [] return obj tzinfo = getTzid(getattr(obj, 'tzid_param', None)) obj.value = [stringToPeriod(x, tzinfo) for x in obj.value.split(",")] return obj
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement identifier expression_statement assignment attribute identifier identifier true if_statement comparison_operator attribute identifier identifier string string_start string_end block expression_statement assignment attribute identifier identifier list return_statement identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier string string_start string_content string_end none expression_statement assignment attribute identifier identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement identifier
Convert comma separated periods into tuples.
def bills(self, member_id, type='introduced'): "Same as BillsClient.by_member" path = "members/{0}/bills/{1}.json".format(member_id, type) return self.fetch(path)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier
Same as BillsClient.by_member
def update_window(turn_from, tick_from, turn_to, tick_to, updfun, branchd): if turn_from in branchd: for past_state in branchd[turn_from][tick_from+1:]: updfun(*past_state) for midturn in range(turn_from+1, turn_to): if midturn in branchd: for past_state in branchd[midturn][:]: updfun(*past_state) if turn_to in branchd: for past_state in branchd[turn_to][:tick_to+1]: updfun(*past_state)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block if_statement comparison_operator identifier identifier block for_statement identifier subscript subscript identifier identifier slice binary_operator identifier integer block expression_statement call identifier argument_list list_splat identifier for_statement identifier call identifier argument_list binary_operator identifier integer identifier block if_statement comparison_operator identifier identifier block for_statement identifier subscript subscript identifier identifier slice block expression_statement call identifier argument_list list_splat identifier if_statement comparison_operator identifier identifier block for_statement identifier subscript subscript identifier identifier slice binary_operator identifier integer block expression_statement call identifier argument_list list_splat identifier
Iterate over a window of time in ``branchd`` and call ``updfun`` on the values
def clear(self): for sample in self.metadata: try: delattr(sample.depth, 'bases') delattr(sample.depth, 'coverage') delattr(sample.depth, 'length') delattr(sample.depth, 'stddev') except AttributeError: pass
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block try_statement block expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end except_clause identifier block pass_statement
Clear out large attributes from the metadata objects
def cmd_signing_key(self, args): if len(args) == 0: print("usage: signing setup passphrase") return if not self.master.mavlink20(): print("You must be using MAVLink2 for signing") return passphrase = args[0] key = self.passphrase_to_key(passphrase) self.master.setup_signing(key, sign_outgoing=True, allow_unsigned_callback=self.allow_unsigned) print("Setup signing key")
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call identifier argument_list string string_start string_content string_end return_statement if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end
set signing key on connection
def search(self, initial_ids, initial_cache): state, state_shapes = self._create_initial_state(initial_ids, initial_cache) finished_state = tf.while_loop( self._continue_search, self._search_step, loop_vars=[state], shape_invariants=[state_shapes], parallel_iterations=1, back_prop=False) finished_state = finished_state[0] alive_seq = finished_state[_StateKeys.ALIVE_SEQ] alive_log_probs = finished_state[_StateKeys.ALIVE_LOG_PROBS] finished_seq = finished_state[_StateKeys.FINISHED_SEQ] finished_scores = finished_state[_StateKeys.FINISHED_SCORES] finished_flags = finished_state[_StateKeys.FINISHED_FLAGS] finished_seq = tf.where( tf.reduce_any(finished_flags, 1), finished_seq, alive_seq) finished_scores = tf.where( tf.reduce_any(finished_flags, 1), finished_scores, alive_log_probs) return finished_seq, finished_scores
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier list identifier keyword_argument identifier list identifier keyword_argument identifier integer keyword_argument identifier false expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier integer identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier integer identifier identifier return_statement expression_list identifier identifier
Beam search for sequences with highest scores.
def rank(): rank_data_url = 'https://raw.githubusercontent.com/Microsoft/LightGBM/master/examples/lambdarank/' x_train, y_train = sklearn.datasets.load_svmlight_file(cache(rank_data_url + 'rank.train')) x_test, y_test = sklearn.datasets.load_svmlight_file(cache(rank_data_url + 'rank.test')) q_train = np.loadtxt(cache(rank_data_url + 'rank.train.query')) q_test = np.loadtxt(cache(rank_data_url + 'rank.test.query')) return x_train, y_train, x_test, y_test, q_train, q_test
module function_definition identifier parameters block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list binary_operator identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list binary_operator identifier string string_start string_content string_end return_statement expression_list identifier identifier identifier identifier identifier identifier
Ranking datasets from lightgbm repository.
def frombits(cls, bits='0'): if len(bits) > cls._len: raise ValueError('too many bits %r' % (bits,)) return cls.fromint(bits[::-1], 2)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier return_statement call attribute identifier identifier argument_list subscript identifier slice unary_operator integer integer
Create a set from binary string.
def _segment_with_tokens(text, tokens): list_form = [] text_ptr = 0 for token in tokens: inter_token_string = [] while not text[text_ptr:].startswith(token): inter_token_string.append(text[text_ptr]) text_ptr += 1 if text_ptr >= len(text): raise ValueError("Tokenization produced tokens that do not belong in string!") text_ptr += len(token) if inter_token_string: list_form.append(''.join(inter_token_string)) list_form.append(token) if text_ptr < len(text): list_form.append(text[text_ptr:]) return list_form
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier integer for_statement identifier identifier block expression_statement assignment identifier list while_statement not_operator call attribute subscript identifier slice identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement augmented_assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list subscript identifier slice identifier return_statement identifier
Segment a string around the tokens created by a passed-in tokenizer
def from_file(cls, source): if hasattr(source, 'read'): relations = cls.from_string(source.read()) else: with open(source) as f: relations = cls.from_string(f.read()) return relations
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list else_clause block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement identifier
Instantiate Relations from a relations file.
def cancel(self, order_id): response = self.request(E.cancelSslCertRequest( E.id(order_id) )) return int(response.data.id)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier argument_list attribute attribute identifier identifier identifier
Cancel an ordered SSL certificate.
def _handle_blacklisted_tag(self): strip = lambda text: text.rstrip().lower() while True: this, next = self._read(), self._read(1) if this is self.END: self._fail_route() elif this == "<" and next == "/": self._head += 3 if self._read() != ">" or (strip(self._read(-1)) != strip(self._stack[1].text)): self._head -= 1 self._emit_text("</") continue self._emit(tokens.TagOpenClose()) self._emit_text(self._read(-1)) self._emit(tokens.TagCloseClose()) return self._pop() elif this == "&": self._parse_entity() else: self._emit_text(this) self._head += 1
module function_definition identifier parameters identifier block expression_statement assignment identifier lambda lambda_parameters identifier call attribute call attribute identifier identifier argument_list identifier argument_list while_statement true block expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list elif_clause boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment attribute identifier identifier integer if_statement boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end parenthesized_expression comparison_operator call identifier argument_list call attribute identifier identifier argument_list unary_operator integer call identifier argument_list attribute subscript attribute identifier identifier integer identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end continue_statement expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list unary_operator integer expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier integer
Handle the body of an HTML tag that is parser-blacklisted.
def wid_to_gid(wid): widval = wid[1:] if len(wid) > 3 else wid xorval = 474 if len(wid) > 3 else 31578 return str(int(widval, 36) ^ xorval)
module function_definition identifier parameters identifier block expression_statement assignment identifier conditional_expression subscript identifier slice integer comparison_operator call identifier argument_list identifier integer identifier expression_statement assignment identifier conditional_expression integer comparison_operator call identifier argument_list identifier integer integer return_statement call identifier argument_list binary_operator call identifier argument_list identifier integer identifier
Calculate gid of a worksheet from its wid.
def send_trending_data(events): bodies = {} top_hits = sorted( [(key, count) for key, count in events.items()], key=lambda x: x[1], reverse=True )[:100] for (site, content_id), count in top_hits: if not len(site) or not re.match(CONTENT_ID_REGEX, content_id): continue bodies.setdefault(site, []) bodies[site].append([content_id, count]) for site, points in bodies.items(): name = "{}_trending".format(site) try: data = [{ "name": name, "columns": ["content_id", "value"], "points": points, }] INFLUXDB_CLIENT.write_points(data) except Exception as e: LOGGER.exception(e)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier subscript call identifier argument_list list_comprehension tuple identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier subscript identifier integer keyword_argument identifier true slice integer for_statement pattern_list tuple_pattern identifier identifier identifier identifier block if_statement boolean_operator not_operator call identifier argument_list identifier not_operator call attribute identifier identifier argument_list identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list identifier list expression_statement call attribute subscript identifier identifier identifier argument_list list identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier try_statement block expression_statement assignment identifier list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier 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
creates data point payloads for trending data to influxdb
def DCM_update(IMU, ATT, MAG, GPS): global dcm_state if dcm_state is None: dcm_state = DCM_State(ATT.Roll, ATT.Pitch, ATT.Yaw) mag = Vector3(MAG.MagX, MAG.MagY, MAG.MagZ) gyro = Vector3(IMU.GyrX, IMU.GyrY, IMU.GyrZ) accel = Vector3(IMU.AccX, IMU.AccY, IMU.AccZ) accel2 = Vector3(IMU.AccX, IMU.AccY, IMU.AccZ) dcm_state.update(gyro, accel, mag, GPS) return dcm_state
module function_definition identifier parameters identifier identifier identifier identifier block global_statement identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier return_statement identifier
implement full DCM system
def cancel_email_change(self): if not self.email_new: return self.email_new = None self.email_confirmed = True self.email_link = None self.email_new = None self.email_link_expires = None
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none
Cancel email change for new users and roll back data
def wait_until_finished(self): try: self.thread.join() except KeyboardInterrupt: self._logger.debug('Keyboard interrupt detected, stopping driver.') self._active = False self._wake_queue()
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause 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 false expression_statement call attribute identifier identifier argument_list
Blocking method to wait until the driver finished its execution.
def osu_run1(data_set='osu_run1', sample_every=4): path = os.path.join(data_path, data_set) if not data_available(data_set): import zipfile download_data(data_set) zip = zipfile.ZipFile(os.path.join(data_path, data_set, 'run1TXT.ZIP'), 'r') for name in zip.namelist(): zip.extract(name, path) from . import mocap Y, connect = mocap.load_text_data('Aug210106', path) Y = Y[0:-1:sample_every, :] return data_details_return({'Y': Y, 'connect' : connect}, data_set)
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement not_operator call identifier argument_list identifier block import_statement dotted_name identifier expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier import_from_statement relative_import import_prefix dotted_name identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier subscript identifier slice integer unary_operator integer identifier slice return_statement call identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier identifier
Ohio State University's Run1 motion capture data set.
def _convert_seconds(self, packed_seconds): seconds = struct.unpack("!H", packed_seconds[:2])[0] seconds += struct.unpack("!I", packed_seconds[2:])[0] return seconds
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice integer integer expression_statement augmented_assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice integer integer return_statement identifier
Unpack the internal representation.
def randomise_labels( self, inplace=False, ): if not inplace: t = self.copy() else: t = self names = list(t.labels) random.shuffle(names) for l in t._tree.leaf_node_iter(): l.taxon._label = names.pop() t._dirty = True return t
module function_definition identifier parameters identifier default_parameter identifier false block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true return_statement identifier
Shuffles the leaf labels, but doesn't alter the tree structure
def add_for_targets(self, targets, classpath_elements): for target in targets: self.add_for_target(target, classpath_elements)
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Adds classpath path elements to the products of all the provided targets.
def _request(self, request, proxies, timeout, verify, **_): settings = self.http.merge_environment_settings( request.url, proxies, False, verify, None) self._delay() response = self.http.send( request, timeout=timeout, allow_redirects=False, **settings) self._update(response.headers) return response
module function_definition identifier parameters identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier false identifier none expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false dictionary_splat identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
This is where we apply rate limiting and make the HTTP request.
def cartesian_to_homogeneous(cartesian_matrix, matrix_type="numpy"): dimension_x, dimension_y = cartesian_matrix.shape if matrix_type == "numpy": homogeneous_matrix = np.eye(dimension_x + 1) elif matrix_type == "sympy": homogeneous_matrix = sympy.eye(dimension_x + 1) homogeneous_matrix[:-1, :-1] = cartesian_matrix return homogeneous_matrix
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier integer expression_statement assignment subscript identifier slice unary_operator integer slice unary_operator integer identifier return_statement identifier
Converts a cartesian matrix to an homogenous matrix
def _remove_soma_initial_point(tree): if tree.points[0][COLS.TYPE] == POINT_TYPE.SOMA: tree.points = tree.points[1:]
module function_definition identifier parameters identifier block if_statement comparison_operator subscript subscript attribute identifier identifier integer attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice integer
Remove tree's initial point if soma
def users_forgot_password(self, email, **kwargs): return self.__call_api_post('users.forgotPassword', email=email, data=kwargs)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
Send email to reset your password.
def exclude_paths(args): results = [] if args.exclude: for excl_path in args.exclude: results.append(os.path.abspath(os.path.join(args.root, excl_path))) return results
module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
Returns the absolute paths for excluded path.
def build_transform(self): cfg = self.cfg if cfg.INPUT.TO_BGR255: to_bgr_transform = T.Lambda(lambda x: x * 255) else: to_bgr_transform = T.Lambda(lambda x: x[[2, 1, 0]]) normalize_transform = T.Normalize( mean=cfg.INPUT.PIXEL_MEAN, std=cfg.INPUT.PIXEL_STD ) transform = T.Compose( [ T.ToPILImage(), T.Resize(self.min_image_size), T.ToTensor(), to_bgr_transform, normalize_transform, ] ) return transform
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list lambda lambda_parameters identifier binary_operator identifier integer else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list lambda lambda_parameters identifier subscript identifier list integer integer integer expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Creates a basic transformation that was used to train the models
def loaded(self, request, *args, **kwargs): serializer = self.get_serializer(list(Pack.objects.all()), many=True) return Response(serializer.data)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true return_statement call identifier argument_list attribute identifier identifier
Return a list of loaded Packs.
def extract_version(): with open('pdftools/__init__.py', 'r') as f: content = f.read() version_match = _version_re.search(content) version = str(ast.literal_eval(version_match.group(1))) return version
module function_definition identifier parameters block with_statement with_clause with_item as_pattern call identifier argument_list string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer return_statement identifier
Extract the version from the package.
def exists(self, path, **kwargs): try: self.get_file_status(path, **kwargs) return True except HdfsFileNotFoundException: return False
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier dictionary_splat identifier return_statement true except_clause identifier block return_statement false
Return true if the given path exists
def filename_to_task_id(fname): fname = os.path.basename(fname) shard_id_increment = { "train": 0, "dev": 800, "test": 900, } parts = fname.split("-") split = parts[1] shard_id = parts[2] task_id = int(shard_id) + shard_id_increment[split] return task_id
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier binary_operator call identifier argument_list identifier subscript identifier identifier return_statement identifier
Map filename to the task id that created it assuming 1k tasks.
def add_route(app_or_blueprint, fn, context=default_context): transmute_func = TransmuteFunction( fn, args_not_from_request=["request"] ) handler = create_handler(transmute_func, context=context) get_swagger_spec(app_or_blueprint).add_func(transmute_func, context) for p in transmute_func.paths: sanic_path = _convert_to_sanic_path(p) app_or_blueprint.add_route(handler, sanic_path, methods=list(transmute_func.methods))
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute call identifier argument_list identifier identifier argument_list identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier
a decorator that adds a transmute route to the application
def new_event(self, event_data: str) -> None: event = self.parse_event_xml(event_data) if EVENT_OPERATION in event: self.manage_event(event)
module function_definition identifier parameters identifier typed_parameter identifier type identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
New event to process.
def LoadServerCertificate(self, server_certificate=None, ca_certificate=None): try: server_certificate.Verify(ca_certificate.GetPublicKey()) except rdf_crypto.VerificationError as e: self.server_name = None raise IOError("Server cert is invalid: %s" % e) server_cert_serial = server_certificate.GetSerialNumber() if server_cert_serial < config.CONFIG["Client.server_serial_number"]: raise IOError("Server certificate serial number is too old.") elif server_cert_serial > config.CONFIG["Client.server_serial_number"]: logging.info("Server serial number updated to %s", server_cert_serial) config.CONFIG.Set("Client.server_serial_number", server_cert_serial) config.CONFIG.Write() self.server_name = server_certificate.GetCN() self.server_certificate = server_certificate self.ca_certificate = ca_certificate self.server_public_key = server_certificate.GetPublicKey() self._ClearServerCipherCache()
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement assignment attribute identifier identifier none raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier subscript attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Loads and verifies the server certificate.
def get(self, field, cluster): if _is_list(cluster): return [self.get(field, c) for c in cluster] assert field in self._fields default = self._fields[field] return self._data.get(cluster, {}).get(field, default)
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier block return_statement list_comprehension call attribute identifier identifier argument_list identifier identifier for_in_clause identifier identifier assert_statement comparison_operator identifier attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier return_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier dictionary identifier argument_list identifier identifier
Retrieve the value of one cluster.
def system(self): if self._resources is None: self.__init() if "system" in self._resources: url = self._url + "/system" return _system.System(url=url, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port, initialize=True) else: return None
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true else_clause block return_statement none
returns an object to work with the site system
def jinja_node_to_python(node): if isinstance(node, nodes.Const): return node.value if isinstance(node, nodes.Neg): return -jinja_node_to_python(node.node) if isinstance(node, nodes.Name): return node.name if isinstance(node, (nodes.List, nodes.Tuple)): value = [] for i in node.items: value.append(jinja_node_to_python(i)) return value if isinstance(node, nodes.Dict): value = {} for pair in node.items: value[pair.key.value] = jinja_node_to_python(pair.value) return value if isinstance(node, nodes.Call): if not isinstance(node.node, nodes.Name) or node.node.name not in ("_", "translate", "gettext"): raise FormDefinitionError("Cannot convert function calls from jinja to python other than translation calls") return lazy_translate(jinja_node_to_python(node.args[0])) raise Exception("Cannot convert jinja nodes to python")
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement unary_operator call identifier argument_list attribute identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement attribute identifier identifier if_statement call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier return_statement identifier if_statement call identifier argument_list identifier attribute identifier identifier block if_statement boolean_operator not_operator call identifier argument_list attribute identifier identifier attribute identifier identifier comparison_operator attribute attribute identifier identifier identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list subscript attribute identifier identifier integer raise_statement call identifier argument_list string string_start string_content string_end
Converts a Jinja2 node to its python equivalent
def _to_diagonally_dominant(mat): mat += np.diag(np.sum(mat != 0, axis=1) + 0.01) return mat
module function_definition identifier parameters identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list comparison_operator identifier integer keyword_argument identifier integer float return_statement identifier
Make matrix unweighted diagonally dominant using the Laplacian.
def save_data(self): if len(self.data.keys()) == 0: return assert 'episode' in self.data sorted_indexes = np.argsort(self.data['episode']) sorted_data = {} for key, values in self.data.items(): assert len(self.data[key]) == len(sorted_indexes) sorted_data[key] = np.array([self.data[key][idx] for idx in sorted_indexes]).tolist() with open(self.filepath, 'w') as f: json.dump(sorted_data, f)
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list integer block return_statement assert_statement comparison_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block assert_statement comparison_operator call identifier argument_list subscript attribute identifier identifier identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier call attribute call attribute identifier identifier argument_list list_comprehension subscript subscript attribute identifier identifier identifier identifier for_in_clause identifier identifier identifier argument_list 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
Save metrics in a json file
def new(filename: str, *, file_attrs: Optional[Dict[str, str]] = None) -> LoomConnection: if filename.startswith("~/"): filename = os.path.expanduser(filename) if file_attrs is None: file_attrs = {} f = h5py.File(name=filename, mode='w') f.create_group('/layers') f.create_group('/row_attrs') f.create_group('/col_attrs') f.create_group('/row_graphs') f.create_group('/col_graphs') f.flush() f.close() ds = connect(filename, validate=False) for vals in file_attrs: ds.attrs[vals] = file_attrs[vals] currentTime = time.localtime(time.time()) ds.attrs['CreationDate'] = timestamp() ds.attrs["LOOM_SPEC_VERSION"] = loompy.loom_spec_version return ds
module function_definition identifier parameters typed_parameter identifier type identifier keyword_separator typed_default_parameter identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier none type identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier false for_statement identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
Create an empty Loom file, and return it as a context manager.
def corrupt_bytes(s, p=0.01, n=None): s = bytes(s) s = array.array("B",s) l = len(s) if n is None: n = max(1,int(l*p)) for i in random.sample(range(l), n): s[i] = (s[i]+random.randint(1,255))%256 return s.tobytes()
module function_definition identifier parameters identifier default_parameter identifier float default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list integer call identifier argument_list binary_operator identifier identifier for_statement identifier call attribute identifier identifier argument_list call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier binary_operator parenthesized_expression binary_operator subscript identifier identifier call attribute identifier identifier argument_list integer integer integer return_statement call attribute identifier identifier argument_list
Corrupt a given percentage or number of bytes from bytes
def initialize_options(self): self._file_lines_cache = dict() self.suppress_codes = list() self.exclusions = list() self.cache_directory = "" self.stamp_directory = "" self.disable_linters = list() self.show_lint_files = 0
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment attribute identifier identifier string string_start string_end expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer
Set all options to their initial values.
def iter_tree_with_handed_function(self, function, *function_args): def iter_all_children(row_iter, function, function_args): if isinstance(row_iter, Gtk.TreeIter): function(row_iter, *function_args) for n in reversed(range(self.tree_store.iter_n_children(row_iter))): child_iter = self.tree_store.iter_nth_child(row_iter, n) iter_all_children(child_iter, function, function_args) else: self._logger.warning("Iter has to be TreeIter -> handed argument is: {0}".format(row_iter)) next_iter = self.tree_store.get_iter_first() while next_iter: iter_all_children(next_iter, function, function_args) next_iter = self.tree_store.iter_next(next_iter)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call identifier argument_list identifier list_splat identifier for_statement identifier call identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call identifier argument_list identifier identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list while_statement identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier
Iterate tree view with condition check function
def bootstrap_general_election(self, election): election_day = election.election_day page_type, created = PageType.objects.get_or_create( model_type=ContentType.objects.get( app_label="election", model="electionday" ), election_day=election_day, ) PageContent.objects.get_or_create( content_type=ContentType.objects.get_for_model(page_type), object_id=page_type.pk, election_day=election_day, )
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Create a general election page type
def addLineAnnot(self, p1, p2): CheckParent(self) val = _fitz.Page_addLineAnnot(self, p1, p2) if not val: return val.thisown = True val.parent = weakref.proxy(self) self._annot_refs[id(val)] = val return val
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier if_statement not_operator identifier block return_statement expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier call identifier argument_list identifier identifier return_statement identifier
Add 'Line' annot for points p1 and p2.
def from_dict(d): query_params_match = d.get('@query_params_match') query_person_match = d.get('@query_person_match') valid_since = d.get('@valid_since') if valid_since: valid_since = str_to_datetime(valid_since) source = Source.from_dict(d.get('source', {})) fields = Record.fields_from_dict(d) return Record(source=source, fields=fields, query_params_match=query_params_match, query_person_match=query_person_match, valid_since=valid_since)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute 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 expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Transform the dict to a record object and return the record.
def _encode(values, salt, min_length, alphabet, separators, guards): len_alphabet = len(alphabet) len_separators = len(separators) values_hash = sum(x % (i + 100) for i, x in enumerate(values)) encoded = lottery = alphabet[values_hash % len(alphabet)] for i, value in enumerate(values): alphabet_salt = (lottery + salt + alphabet)[:len_alphabet] alphabet = _reorder(alphabet, alphabet_salt) last = _hash(value, alphabet) encoded += last value %= ord(last[0]) + i encoded += separators[value % len_separators] encoded = encoded[:-1] return (encoded if len(encoded) >= min_length else _ensure_length(encoded, min_length, alphabet, guards, values_hash))
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier generator_expression binary_operator identifier parenthesized_expression binary_operator identifier integer for_in_clause pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier assignment identifier subscript identifier binary_operator identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier subscript parenthesized_expression binary_operator binary_operator identifier identifier identifier slice identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment identifier binary_operator call identifier argument_list subscript identifier integer identifier expression_statement augmented_assignment identifier subscript identifier binary_operator identifier identifier expression_statement assignment identifier subscript identifier slice unary_operator integer return_statement parenthesized_expression conditional_expression identifier comparison_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier identifier identifier identifier
Helper function that does the hash building without argument checks.
def _winapi(self, func, *a, **kw): self.flush() if _DEBUG_RENDER_OUTPUT: self.LOG.write(('%r' % func.__name__).encode('utf-8') + b'\n') self.LOG.write(b' ' + ', '.join(['%r' % i for i in a]).encode('utf-8') + b'\n') self.LOG.write(b' ' + ', '.join(['%r' % type(i) for i in a]).encode('utf-8') + b'\n') self.LOG.flush() try: return func(*a, **kw) except ArgumentError as e: if _DEBUG_RENDER_OUTPUT: self.LOG.write((' Error in %r %r %s\n' % (func.__name__, e, e)).encode('utf-8'))
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute parenthesized_expression binary_operator string string_start string_content string_end attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end call attribute call attribute string string_start string_content string_end identifier argument_list list_comprehension binary_operator string string_start string_content string_end identifier for_in_clause identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end call attribute call attribute string string_start string_content string_end identifier argument_list list_comprehension binary_operator string string_start string_content string_end call identifier argument_list identifier for_in_clause identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute parenthesized_expression binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier identifier identifier identifier argument_list string string_start string_content string_end
Flush and call win API function.
def clean_dict(d): ktd = list() for k, v in d.items(): if not v: ktd.append(k) elif type(v) is dict: d[k] = clean_dict(v) for k in ktd: d.pop(k) return d
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
remove the keys with None values.
def argsort_k_smallest(x, k): if k == 0: return np.array([], dtype=np.intp) if k is None or k >= len(x): return np.argsort(x) indices = np.argpartition(x, k)[:k] values = x[indices] return indices[np.argsort(values)]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block return_statement call attribute identifier identifier argument_list list keyword_argument identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier none comparison_operator identifier call identifier argument_list identifier block return_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier identifier slice identifier expression_statement assignment identifier subscript identifier identifier return_statement subscript identifier call attribute identifier identifier argument_list identifier
Return no more than ``k`` indices of smallest values.
def find_by_b64ids(self, _ids, **kwargs): return self.find_by_ids([ObjectId(base64.b64decode(_id)) for _id in _ids], **kwargs)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list list_comprehension call identifier argument_list call attribute identifier identifier argument_list identifier for_in_clause identifier identifier dictionary_splat identifier
Pass me a list of base64-encoded ObjectId
def top_referrers(self, domain_only=True): referrer = self._referrer_clause(domain_only) return (self.get_query() .select(referrer, fn.Count(PageView.id)) .group_by(referrer) .order_by(fn.Count(PageView.id).desc()) .tuples())
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement parenthesized_expression call attribute call attribute call attribute call attribute call attribute identifier identifier argument_list identifier argument_list identifier call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list identifier identifier argument_list call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list identifier argument_list
What domains send us the most traffic?
def _make_graphite_api_points_list(influxdb_data): _data = {} for key in influxdb_data.keys(): _data[key[0]] = [(datetime.datetime.fromtimestamp(float(d['time'])), d['value']) for d in influxdb_data.get_points(key[0])] return _data
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier subscript identifier integer list_comprehension tuple call attribute attribute identifier identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_in_clause identifier call attribute identifier identifier argument_list subscript identifier integer return_statement identifier
Make graphite-api data points dictionary from Influxdb ResultSet data
def _name_variation_has_only_initials(name): def _is_initial(name_variation): return len(name_variation) == 1 or u'.' in name_variation parsed_name = ParsedName.loads(name) return all([_is_initial(name_part) for name_part in parsed_name])
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block return_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier
Detects whether the name variation consists only from initials.
def process_request(self, unused_request): tasklets._state.clear_all_pending() ctx = tasklets.make_default_context() tasklets.set_context(ctx)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
Called by Django before deciding which view to execute.
def get(self, request, *args, **kwargs): private_file = self.get_private_file() if not self.can_access_file(private_file): return HttpResponseForbidden('Private storage access denied') if not private_file.exists(): return self.serve_file_not_found(private_file) else: return self.serve_file(private_file)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator call attribute identifier identifier argument_list identifier block return_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list block return_statement call attribute identifier identifier argument_list identifier else_clause block return_statement call attribute identifier identifier argument_list identifier
Handle incoming GET requests
def build_schema( source: Union[str, Source], assume_valid=False, assume_valid_sdl=False, no_location=False, experimental_fragment_variables=False, ) -> GraphQLSchema: return build_ast_schema( parse( source, no_location=no_location, experimental_fragment_variables=experimental_fragment_variables, ), assume_valid=assume_valid, assume_valid_sdl=assume_valid_sdl, )
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier false type identifier block return_statement call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Build a GraphQLSchema directly from a source document.
def _download_ontology(url, local_file): current_app.logger.debug( "Copying remote ontology '%s' to file '%s'." % (url, local_file) ) try: request = requests.get(url, stream=True) if request.status_code == 200: with open(local_file, 'wb') as f: for chunk in request.iter_content(chunk_size): f.write(chunk) except IOError as e: current_app.logger.exception(e) return False else: current_app.logger.debug("Done copying.") return True
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true if_statement comparison_operator attribute identifier identifier integer block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement false else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement true
Download the ontology and stores it in CLASSIFIER_WORKDIR.
def float(self, **kwargs): for key in kwargs: setattr(self, key, kwargs[key]) self.command = self.COMMAND_FLOAT
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier subscript identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier
Remove power from the motor.
def join_or_die(self): if self._phase_desc.options.timeout_s is not None: self.join(self._phase_desc.options.timeout_s) else: self.join(DEFAULT_PHASE_TIMEOUT_S) if isinstance(self._phase_execution_outcome, PhaseExecutionOutcome): return self._phase_execution_outcome if self.is_alive(): self.kill() return PhaseExecutionOutcome(None) return PhaseExecutionOutcome(threads.ThreadTerminationError())
module function_definition identifier parameters identifier block if_statement comparison_operator attribute attribute attribute identifier identifier identifier identifier none block expression_statement call attribute identifier identifier argument_list attribute attribute attribute identifier identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list attribute identifier identifier identifier block return_statement attribute identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list none return_statement call identifier argument_list call attribute identifier identifier argument_list
Wait for thread to finish, returning a PhaseExecutionOutcome instance.
def _get_beacons(self, include_opts=True, include_pillar=True): beacons = {} if include_pillar: pillar_beacons = self.opts.get('pillar', {}).get('beacons', {}) if not isinstance(pillar_beacons, dict): raise ValueError('Beacons must be of type dict.') beacons.update(pillar_beacons) if include_opts: opts_beacons = self.opts.get('beacons', {}) if not isinstance(opts_beacons, dict): raise ValueError('Beacons must be of type dict.') beacons.update(opts_beacons) return beacons
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier true block expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end dictionary if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return the beacons data structure
def check_token(self, token: 'RedisEphemeralTokens') -> bool: if self.get_state() is None: return False correct_token = self.make_token(self) self.clear() return constant_time_compare(correct_token, token)
module function_definition identifier parameters identifier typed_parameter identifier type string string_start string_content string_end type identifier block if_statement comparison_operator call attribute identifier identifier argument_list none block return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list identifier identifier
Check that a token is correct for a given scope token.
def convert_string(string, chars=None): if chars is None: chars = [',', '.', '-', '/', ':', ' '] for ch in chars: if ch in string: string = string.replace(ch, ' ') return string
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement identifier
Remove certain characters from a string.
def run(self): while (self._run_thread): (mode, version, packet) = self._read_packet() if (mode == PROP_PACKET_SENSE): self._decode_sense_packet(version, packet) elif (mode == PROP_PACKET_CTRL): self._decode_ctrl_packet(version, packet)
module function_definition identifier parameters identifier block while_statement parenthesized_expression attribute identifier identifier block expression_statement assignment tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list if_statement parenthesized_expression comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier elif_clause parenthesized_expression comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Main thread that reads from input and populates the sensors.
def _list_variables(self, station_codes): rvar = re.compile(r"\n\s([A-Z]{2}[A-Z0-9]{0,1})\(\w+\)") variables = set() resp = requests.post( self.obs_retrieval_url, data={ "state": "nil", "hsa": "nil", "of": "3", "extraids": " ".join(station_codes), "sinceday": -1, }, ) resp.raise_for_status() list(map(variables.add, rvar.findall(resp.text))) return variables
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier pair string string_start string_content string_end unary_operator integer expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Internal helper to list the variables for the given station codes.
def _path_is_executable_others(path): prevpath = None while path and path != prevpath: try: if not os.stat(path).st_mode & stat.S_IXOTH: return False except OSError: return False prevpath = path path, _ = os.path.split(path) return True
module function_definition identifier parameters identifier block expression_statement assignment identifier none while_statement boolean_operator identifier comparison_operator identifier identifier block try_statement block if_statement not_operator binary_operator attribute call attribute identifier identifier argument_list identifier identifier attribute identifier identifier block return_statement false except_clause identifier block return_statement false expression_statement assignment identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement true
Check every part of path for executable permission
def _update_pwm(self): if self._is_on: values = self._get_pwm_values() else: values = [0] * len(self._driver.pins) self._driver.set_pwm(values)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier binary_operator list integer call identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Update the pwm values of the driver regarding the current state.
def _add_new_methods(cls): for name, method in cls.context.new_methods.items(): if hasattr(cls.context.new_class, name): raise ValueError( "Name collision in state machine class - '{name}'." .format(name) ) setattr(cls.context.new_class, name, method)
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block if_statement call identifier argument_list attribute attribute identifier identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list attribute attribute identifier identifier identifier identifier identifier
Add all generated methods to result class.
def _altair_hline_(self, xfield, yfield, opts, style, encode): try: rawy = yfield if ":" in yfield: rawy = yfield.split(":")[0] mean = self.df[rawy].mean() l = [] i = 0 while i < len(self.df[rawy]): l.append(mean) i += 1 self.df["Mean"] = l chart = Chart(self.df).mark_line(**style).encode(x=xfield, \ y="Mean", **encode).properties(**opts) self.drop("Mean") return chart except Exception as e: self.err(e, "Can not draw mean line chart")
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block try_statement block expression_statement assignment identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier list expression_statement assignment identifier integer while_statement comparison_operator identifier call identifier argument_list subscript attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute call attribute call attribute call identifier argument_list attribute identifier identifier identifier argument_list dictionary_splat identifier identifier argument_list keyword_argument identifier identifier line_continuation keyword_argument identifier string string_start string_content string_end dictionary_splat identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end
Get a mean line chart
def run(self, host='0.0.0.0', port=8080): waitress.serve(self.app, host=host, port=port)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Launch a development web server.
def _convert_latitude(self, latitude): return int((180 - (180 / pi * log(tan( pi / 4 + latitude * pi / 360)))) * (2 ** self._zoom) * self._size / 360)
module function_definition identifier parameters identifier identifier block return_statement call identifier argument_list binary_operator binary_operator binary_operator parenthesized_expression binary_operator integer parenthesized_expression binary_operator binary_operator integer identifier call identifier argument_list call identifier argument_list binary_operator binary_operator identifier integer binary_operator binary_operator identifier identifier integer parenthesized_expression binary_operator integer attribute identifier identifier attribute identifier identifier integer
Convert from latitude to the y position in overall map.
def cython_debug_files(): files = [] for path in sys_path: pattern = os.path.join(path, '*', 'cython_debug', 'cython_debug_info_*') files.extend(glob.glob(pattern)) return files
module function_definition identifier parameters block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier
Cython extra debug information files
def _topological_sort(self, targets): target_set = set(targets) return [t for t in reversed(sort_targets(targets)) if t in target_set]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement list_comprehension identifier for_in_clause identifier call identifier argument_list call identifier argument_list identifier if_clause comparison_operator identifier identifier
Topologically order a list of targets
def encrypt(self, s, mac_bytes=10): if isinstance(s, six.text_type): raise ValueError( "Encode `s` to a bytestring yourself to" + " prevent problems with different default encodings") out = BytesIO() with self.encrypt_to(out, mac_bytes) as f: f.write(s) return out.getvalue()
module function_definition identifier parameters identifier identifier default_parameter identifier integer block if_statement call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list
Encrypt `s' for this pubkey.
def files(self): self._printer('\tFiles Walk') for directory in self.directory: for path in os.listdir(directory): full_path = os.path.join(directory, path) if os.path.isfile(full_path): if not path.startswith('.'): self.filepaths.append(full_path) return self._get_filepaths()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end for_statement identifier attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list
Return list of files in root directory
def remove_key(self, key): try: self._own_keys.discard(key) if self._parent and self._parent.has_key(key): self._container[key] = self._parent[key] else: del self._container[key] except KeyError: pass
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement boolean_operator attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment subscript attribute identifier identifier identifier subscript attribute identifier identifier identifier else_clause block delete_statement subscript attribute identifier identifier identifier except_clause identifier block pass_statement
Remove own key, value
def _get_zone_name(self): if self._name is None: tags = ["GetZoneName"] root = self.exec_appcommand_post(tags) if root is None: _LOGGER.error("Getting ZoneName failed.") else: zone = self._get_own_zone() try: name = root.find( "./cmd/{zone}".format(zone=zone)).text except AttributeError: _LOGGER.error("No ZoneName found for zone %s", self.zone) else: self._name = name.strip()
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier attribute call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list
Get receivers zone name if not set yet.
def delete(self, _key) : "removes a document from the cache" try : doc = self.cacheStore[_key] doc.prev.nextDoc = doc.nextDoc doc.nextDoc.prev = doc.prev del(self.cacheStore[_key]) except KeyError : raise KeyError("Document with _key %s is not available in cache" % _key)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end try_statement block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier delete_statement parenthesized_expression subscript attribute identifier identifier identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
removes a document from the cache
def unquote_pre_filter(pre_filter, _regex=re.compile(r'[\\]+')): if pre_filter.startswith('"') and pre_filter.endswith('"'): pre_filter = pre_filter[1:-1] pre_filter = _regex.sub(lambda x: x.group(0)[:len(x.group(0)) // 2], pre_filter) return pre_filter
module function_definition identifier parameters identifier default_parameter identifier call attribute identifier identifier argument_list string string_start string_content string_end block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier slice integer unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list lambda lambda_parameters identifier subscript call attribute identifier identifier argument_list integer slice binary_operator call identifier argument_list call attribute identifier identifier argument_list integer integer identifier return_statement identifier
Unquote a pre-filter condition.
def copyresource( resource, filename, destdir ): data = pkgutil.get_data(resource, os.path.join('resources',filename) ) with open( os.path.join(destdir,filename), 'wb' ) as fp: fp.write(data)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier with_statement with_clause with_item as_pattern call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
Copy a resource file to a destination