code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def _init(self): self._line_number = next_line( self._communication.last_requested_line_number, self._file.read(1)[0])
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier subscript call attribute attribute identifier identifier identifier argument_list integer integer
Read the line number.
def list(ctx): log.debug('chemdataextractor.config.list') for k in config: click.echo('%s : %s' % (k, config[k]))
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript identifier identifier
List all config values.
def equalize_terminal_double_bond(mol): for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: nb = list(mol.neighbors(i).values())[0] if nb.order == 2: nb.type = 2
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator call attribute identifier identifier argument_list identifier integer block expression_statement assignment identifier subscript call identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier argument_list integer if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment attribute identifier identifier integer
Show equalized double bond if it is connected to terminal atom.
def visit_Bytes(self, node: ast.Bytes) -> bytes: result = node.s self.recomputed_values[node] = result return node.s
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement attribute identifier identifier
Recompute the value as the bytes at the node.
def process_message(message, notification): if not set(VITAL_MESSAGE_FIELDS) <= set(message): logger.info('JSON Message Missing Vital Fields') return HttpResponse('Missing Vital Fields') if message['notificationType'] == 'Complaint': return process_complaint(message, notification) if message['notificationType'] == 'Bounce': return process_bounce(message, notification) if message['notificationType'] == 'Delivery': return process_delivery(message, notification) else: return HttpResponse('Unknown Notification Type')
module function_definition identifier parameters identifier identifier block if_statement not_operator comparison_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block return_statement call identifier argument_list identifier identifier if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block return_statement call identifier argument_list identifier identifier if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block return_statement call identifier argument_list identifier identifier else_clause block return_statement call identifier argument_list string string_start string_content string_end
Function to process a JSON message delivered from Amazon
def wipe_table(self, table: str) -> int: sql = "DELETE FROM " + self.delimit(table) return self.db_exec(sql)
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Delete all records from a table. Use caution!
def getall(self, table): try: self._check_db() except Exception as e: self.err(e, "Can not connect to database") return if table not in self.db.tables: self.warning("The table " + table + " does not exists") return try: res = self.db[table].all() df = pd.DataFrame(list(res)) return df except Exception as e: self.err(e, "Error retrieving data in table")
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list 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 return_statement if_statement comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end return_statement try_statement block expression_statement assignment identifier call attribute subscript attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier 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 all rows values for a table
def build_day(self, dt): self.month = str(dt.month) self.year = str(dt.year) self.day = str(dt.day) logger.debug("Building %s-%s-%s" % (self.year, self.month, self.day)) self.request = self.create_request(self.get_url()) path = self.get_build_path() self.build_file(path, self.get_content())
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list
Build the page for the provided day.
def run_add_system(name, token, org, system, prompt): repo = get_repo(token=token, org=org, name=name) try: repo.create_label(name=system.strip(), color=SYSTEM_LABEL_COLOR) click.secho("Successfully added new system {}".format(system), fg="green") if prompt and click.confirm("Run update to re-generate the page?"): run_update(name=name, token=token, org=org) except GithubException as e: if e.status == 422: click.secho( "Unable to add new system {}, it already exists.".format(system), fg="yellow") return raise
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier string string_start string_content string_end if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier string string_start string_content string_end return_statement raise_statement
Adds a new system to the repo.
def R_isrk(self, k): ind = int(self.index[self.R_time_var_index, k]) R = self.R[:, :, ind] if (R.shape[0] == 1): inv_square_root = np.sqrt(1.0/R) else: if self.svd_each_time: (U, S, Vh) = sp.linalg.svd(R, full_matrices=False, compute_uv=True, overwrite_a=False, check_finite=True) inv_square_root = U * 1.0/np.sqrt(S) else: if ind in self.R_square_root: inv_square_root = self.R_square_root[ind] else: (U, S, Vh) = sp.linalg.svd(R, full_matrices=False, compute_uv=True, overwrite_a=False, check_finite=True) inv_square_root = U * 1.0/np.sqrt(S) self.R_square_root[ind] = inv_square_root return inv_square_root
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier slice slice identifier if_statement parenthesized_expression comparison_operator subscript attribute identifier identifier integer integer block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator float identifier else_clause block if_statement attribute identifier identifier block expression_statement assignment tuple_pattern identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier false keyword_argument identifier true keyword_argument identifier false keyword_argument identifier true expression_statement assignment identifier binary_operator binary_operator identifier float call attribute identifier identifier argument_list identifier else_clause block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier else_clause block expression_statement assignment tuple_pattern identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier false keyword_argument identifier true keyword_argument identifier false keyword_argument identifier true expression_statement assignment identifier binary_operator binary_operator identifier float call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement identifier
Function returns the inverse square root of R matrix on step k.
def getfields(comm): fields = [] for field in comm: if 'field' in field: fields.append(field) return fields
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
get all the fields that have the key 'field'
def _no_ntplt(self, ntplt): sys.stdout.write(" {GO_USR:>6,} usr {GO_ALL:>6,} GOs DID NOT WRITE: {B} {D}\n".format( B=self.grprobj.get_fout_base(ntplt.hdrgo), D=ntplt.desc, GO_USR=len(ntplt.gosubdag.go_sources), GO_ALL=len(ntplt.gosubdag.go2obj)))
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier call identifier argument_list attribute attribute identifier identifier identifier
Print a message about the GO DAG Plot we are NOT plotting.
def hash160(self, is_compressed=None): if is_compressed is None: is_compressed = self.is_compressed() if is_compressed: if self._hash160_compressed is None: self._hash160_compressed = hash160(self.sec(is_compressed=is_compressed)) return self._hash160_compressed if self._hash160_uncompressed is None: self._hash160_uncompressed = hash160(self.sec(is_compressed=is_compressed)) return self._hash160_uncompressed
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement attribute identifier identifier
Return the hash160 representation of this key, if available.
def transloadsForPeer(self, peer): for tl in self.transloads.itervalues(): if peer in tl.peers: yield tl
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier attribute identifier identifier block expression_statement yield identifier
Returns an iterator of transloads that apply to a particular peer.
def transmit_tc_bpdu(self): if not self.send_tc_flg: timer = datetime.timedelta(seconds=self.port_times.max_age + self.port_times.forward_delay) self.send_tc_timer = datetime.datetime.today() + timer self.send_tc_flg = True
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier binary_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier binary_operator call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier true
Set send_tc_flg to send Topology Change BPDU.
def distances(self): from molmod.ext import graphs_floyd_warshall distances = np.zeros((self.num_vertices,)*2, dtype=int) for i, j in self.edges: distances[i, j] = 1 distances[j, i] = 1 graphs_floyd_warshall(distances) return distances
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator tuple attribute identifier identifier integer keyword_argument identifier identifier for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier identifier integer expression_statement assignment subscript identifier identifier identifier integer expression_statement call identifier argument_list identifier return_statement identifier
The matrix with the all-pairs shortest path lenghts
def load_cfg(self): if self.cfg_mode == 'json': with open(self.cfg_file) as opened_file: return json.load(opened_file) else: with open(self.cfg_file) as ymlfile: return yaml.safe_load(ymlfile)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier
loads our config object accessible via self.cfg
def refactor_ifs(stmnt, ifs): if isinstance(stmnt, _ast.BoolOp): test, right = stmnt.values if isinstance(stmnt.op, _ast.Or): test = _ast.UnaryOp(op=_ast.Not(), operand=test, lineno=0, col_offset=0) ifs.append(test) return refactor_ifs(right, ifs) return stmnt
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment pattern_list identifier identifier attribute identifier identifier if_statement call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier identifier return_statement identifier
for if statements in list comprehension
def _linear_seaborn_(self, label=None, style=None, opts=None): xticks, yticks = self._get_ticks(opts) try: fig = sns.lmplot(self.x, self.y, data=self.df) fig = self._set_with_height(fig, opts) return fig except Exception as e: self.err(e, self.linear_, "Can not draw linear regression chart")
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier string string_start string_content string_end
Returns a Seaborn linear regression plot
def _parse_feature_names(feature_names, new_names): if isinstance(feature_names, set): return FeatureParser._parse_names_set(feature_names) if isinstance(feature_names, dict): return FeatureParser._parse_names_dict(feature_names) if isinstance(feature_names, (tuple, list)): return FeatureParser._parse_names_tuple(feature_names, new_names) raise ValueError('Failed to parse {}, expected dictionary, set or tuple'.format(feature_names))
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier tuple identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Helping function of `_parse_features` that parses a collection of feature names.
def _reset(self): with self._lock: self.stop() self.start() for svc_ref in self.get_bindings(): if not self.requirement.filter.matches( svc_ref.get_properties() ): self.on_service_departure(svc_ref)
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list block if_statement not_operator call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier
Called when the filter has been changed
def run(self, args): args = vars(args) positionals = [] keywords = {} for action in self.argparser._actions: if not hasattr(action, 'label'): continue if action.label == 'positional': positionals.append(args[action.dest]) elif action.label == 'varargs': positionals.extend(args[action.dest]) elif action.label == 'keyword': keywords[action.dest] = args[action.dest] elif action.label == 'varkwargs': kwpairs = iter(args[action.dest] or []) for key in kwpairs: try: key, value = key.split('=', 1) except ValueError: value = next(kwpairs) key = key.strip('-') keywords[key] = value return self.func(*positionals, **keywords)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list expression_statement assignment identifier dictionary for_statement identifier attribute attribute identifier identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block continue_statement if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier attribute identifier identifier subscript identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list boolean_operator subscript identifier attribute identifier identifier list for_statement identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer except_clause identifier 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 expression_statement assignment subscript identifier identifier identifier return_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier
Convert the unordered args into function arguments.
def clip_grad(learn:Learner, clip:float=0.1)->Learner: "Add gradient clipping of `clip` during training." learn.callback_fns.append(partial(GradientClipping, clip=clip)) return learn
module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier float type identifier block expression_statement string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
Add gradient clipping of `clip` during training.
def unlock(name, zk_hosts=None, identifier=None, max_concurrency=1, ephemeral_lease=False, profile=None, scheme=None, username=None, password=None, default_acl=None): ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} conn_kwargs = {'profile': profile, 'scheme': scheme, 'username': username, 'password': password, 'default_acl': default_acl} if __opts__['test']: ret['result'] = None ret['comment'] = 'Released lock if it is here' return ret if identifier is None: identifier = __grains__['id'] unlocked = __salt__['zk_concurrency.unlock'](name, zk_hosts=zk_hosts, identifier=identifier, max_concurrency=max_concurrency, ephemeral_lease=ephemeral_lease, **conn_kwargs) if unlocked: ret['result'] = True else: ret['comment'] = 'Unable to find lease for path {0}'.format(name) return ret
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier false default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end false pair string string_start string_content string_end string string_start string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end none expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier if_statement comparison_operator identifier none block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end true else_clause block expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Remove lease from semaphore.
def _init_socket(self): if self.ddpsocket: self.ddpsocket.remove_all_listeners('received_message') self.ddpsocket.remove_all_listeners('closed') self.ddpsocket.remove_all_listeners('opened') self.ddpsocket.close_connection() self.ddpsocket = None self.ddpsocket = DDPSocket(self.url, self.debug) self.ddpsocket.on('received_message', self.received_message) self.ddpsocket.on('closed', self.closed) self.ddpsocket.on('opened', self.opened)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
Initialize the ddp socket
def check_extension(conn, extension: str) -> bool: query = 'SELECT installed_version FROM pg_available_extensions WHERE name=%s;' with conn.cursor() as cursor: cursor.execute(query, (extension,)) result = cursor.fetchone() if result is None: raise psycopg2.ProgrammingError( 'Extension is not available for installation.', extension ) else: extension_version = result[0] return bool(extension_version)
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier tuple identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement assignment identifier subscript identifier integer return_statement call identifier argument_list identifier
Check to see if an extension is installed.
def close(self): self._input.close() self._call_parse() root = self._pop_message() assert not self._msgstack if root.get_content_maintype() == 'multipart' \ and not root.is_multipart(): defect = errors.MultipartInvariantViolationDefect() self.policy.handle_defect(root, defect) return root
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list assert_statement not_operator attribute identifier identifier if_statement boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end line_continuation not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier
Parse all remaining data and return the root message object.
def cli(env): mgr = SoftLayer.LoadBalancerManager(env.client) table = formatting.Table(['price_id', 'capacity', 'description', 'price']) table.sortby = 'price' table.align['price'] = 'r' table.align['capacity'] = 'r' table.align['id'] = 'r' packages = mgr.get_lb_pkgs() for package in packages: table.add_row([ package['prices'][0]['id'], package.get('capacity'), package['description'], '%.2f' % float(package['prices'][0]['recurringFee']) ]) env.fout(table)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list list subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end call identifier argument_list subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
Get price options to create a load balancer with.
def relabel(self, qubits: Qubits) -> 'Gate': gate = copy(self) gate.vec = gate.vec.relabel(qubits) return gate
module function_definition identifier parameters identifier typed_parameter identifier type identifier type string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Return a copy of this Gate with new qubits
def setData(self, index, value, role=Qt.EditRole): item = self.itemAt(index) if not item: return False d = item.declaration if role == Qt.CheckStateRole: checked = value == Qt.Checked if checked != d.checked: d.checked = checked d.toggled(checked) return True elif role == Qt.EditRole: if value != d.text: d.text = value return True return super(QAbstractAtomItemModel, self).setData(index, value, role)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement false expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier comparison_operator identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement true elif_clause comparison_operator identifier attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier return_statement true return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier
Set the data for the item at the given index to the given value.
def wiki(searchterm): searchterm = quote(searchterm) url = "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&format=json" url = url.format(searchterm) result = requests.get(url).json() pages = result["query"]["search"] pages = [p for p in pages if 'may refer to' not in p["snippet"]] if not pages: return "" page = quote(pages[0]["title"].encode("utf8")) link = "http://en.wikipedia.org/wiki/{0}".format(page) r = requests.get( "http://en.wikipedia.org/w/api.php?format=json&action=parse&page={0}". format(page)).json() soup = BeautifulSoup(r["parse"]["text"]["*"], "html5lib") p = soup.find('p').get_text() p = p[:8000] return u"{0}\n{1}".format(p, link)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement not_operator identifier block return_statement string string_start string_end expression_statement assignment identifier call identifier argument_list call attribute subscript subscript identifier integer string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier argument_list expression_statement assignment identifier call identifier argument_list subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement assignment identifier subscript identifier slice integer return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier identifier
return the top wiki search result for the term
def __inner_predict(self, data_idx): if data_idx >= self.__num_dataset: raise ValueError("Data_idx should be smaller than number of dataset") if self.__inner_predict_buffer[data_idx] is None: if data_idx == 0: n_preds = self.train_set.num_data() * self.__num_class else: n_preds = self.valid_sets[data_idx - 1].num_data() * self.__num_class self.__inner_predict_buffer[data_idx] = np.zeros(n_preds, dtype=np.float64) if not self.__is_predicted_cur_iter[data_idx]: tmp_out_len = ctypes.c_int64(0) data_ptr = self.__inner_predict_buffer[data_idx].ctypes.data_as(ctypes.POINTER(ctypes.c_double)) _safe_call(_LIB.LGBM_BoosterGetPredict( self.handle, ctypes.c_int(data_idx), ctypes.byref(tmp_out_len), data_ptr)) if tmp_out_len.value != len(self.__inner_predict_buffer[data_idx]): raise ValueError("Wrong length of predict results for data %d" % (data_idx)) self.__is_predicted_cur_iter[data_idx] = True return self.__inner_predict_buffer[data_idx]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript attribute identifier identifier identifier none block if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier binary_operator call attribute subscript attribute identifier identifier binary_operator identifier integer identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier if_statement not_operator subscript attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute attribute subscript attribute identifier identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator attribute identifier identifier call identifier argument_list subscript attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier expression_statement assignment subscript attribute identifier identifier identifier true return_statement subscript attribute identifier identifier identifier
Predict for training and validation dataset.
def view_required_params_per_trt(token, dstore): csm_info = dstore['csm_info'] tbl = [] for grp_id, trt in sorted(csm_info.grp_by("trt").items()): gsims = csm_info.gsim_lt.get_gsims(trt) maker = ContextMaker(trt, gsims) distances = sorted(maker.REQUIRES_DISTANCES) siteparams = sorted(maker.REQUIRES_SITES_PARAMETERS) ruptparams = sorted(maker.REQUIRES_RUPTURE_PARAMETERS) tbl.append((grp_id, ' '.join(map(repr, map(repr, gsims))), distances, siteparams, ruptparams)) return rst_table( tbl, header='grp_id gsims distances siteparams ruptparams'.split(), fmt=scientificformat)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list tuple identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list identifier identifier identifier identifier identifier return_statement call identifier argument_list identifier keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier
Display the parameters needed by each tectonic region type
def _run(name, cmd, exec_driver=None, output=None, stdin=None, python_shell=True, output_loglevel='debug', ignore_retcode=False, use_vt=False, keep_env=None): if exec_driver is None: exec_driver = _get_exec_driver() ret = __salt__['container_resource.run']( name, cmd, container_type=__virtualname__, exec_driver=exec_driver, output=output, stdin=stdin, python_shell=python_shell, output_loglevel=output_loglevel, ignore_retcode=ignore_retcode, use_vt=use_vt, keep_env=keep_env) if output in (None, 'all'): return ret else: return ret[output]
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier true default_parameter identifier string string_start string_content string_end default_parameter identifier false default_parameter identifier false default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator identifier tuple none string string_start string_content string_end block return_statement identifier else_clause block return_statement subscript identifier identifier
Common logic for docker.run functions
def str2float(text): try: return float(re.sub(r"\(.+\)*", "", text)) except TypeError: if isinstance(text, list) and len(text) == 1: return float(re.sub(r"\(.+\)*", "", text[0])) except ValueError as ex: if text.strip() == ".": return 0 raise ex
module function_definition identifier parameters identifier block try_statement block return_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier except_clause identifier block if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier integer block return_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end subscript identifier integer except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement integer raise_statement identifier
Remove uncertainty brackets from strings and return the float.
def _convert_label(label): style = qt_font_to_style(label.get("font"), label.get("color")) return { "text": html.escape(label["text"]), "rotation": 0, "style": style, "x": int(label["x"]), "y": int(label["y"]) }
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list 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 return_statement dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end
Convert a label from 1.X to the new format
def _renameClasses(classes, prefix): renameMap = {} for classID, glyphList in classes.items(): if len(glyphList) == 0: groupName = "%s_empty_lu.%d_st.%d_cl.%d" % (prefix, classID[0], classID[1], classID[2]) elif len(glyphList) == 1: groupName = list(glyphList)[0] else: glyphList = list(sorted(glyphList)) groupName = prefix + glyphList[0] renameMap[classID] = groupName return renameMap
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier subscript identifier integer subscript identifier integer subscript identifier integer elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier subscript call identifier argument_list identifier integer else_clause block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier subscript identifier integer expression_statement assignment subscript identifier identifier identifier return_statement identifier
Replace class IDs with nice strings.
def graceful_ctrlc(func): @wraps(func) def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except KeyboardInterrupt: exit(1) return wrapper
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause identifier block expression_statement call identifier argument_list integer return_statement identifier
Makes the decorated function exit with code 1 on CTRL+C.
def from_fqdn(cls, fqdn): result = cls.list({'fqdn': fqdn}) if len(result) > 0: return result[0]['id']
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement subscript subscript identifier integer string string_start string_content string_end
Retrieve domain id associated to a FQDN.
def async_get_measurements(self, uid, fields='*'): return (yield from self._get('/pods/{}/measurements'.format(uid), fields=fields))[0]
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block return_statement subscript parenthesized_expression yield call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier identifier integer
Get measurements of a device.
def _read_mz(self, mz_offset, mz_len, mz_enc_len): self.ibd.seek(mz_offset) data = self.ibd.read(mz_enc_len) self.ibd.seek(0, 2) data = self.mz_compression.decompress(data) return tuple(np.fromstring(data, dtype=self.mz_dtype))
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list integer integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier
reads a mz array from the currently open ibd file
def list_ebs(region, filter_by_kwargs): conn = boto.ec2.connect_to_region(region) instances = conn.get_all_volumes() return lookup(instances, filter_by=filter_by_kwargs)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list identifier keyword_argument identifier identifier
List running ebs volumes.
def _align_from_fastq(fastq1, fastq2, aligner, align_ref, sam_ref, names, align_dir, data): config = data["config"] align_fn = TOOLS[aligner].align_fn out = align_fn(fastq1, fastq2, align_ref, names, align_dir, data) if isinstance(out, dict): assert out.get("work_bam"), (dd.get_sample_name(data), out.get("work_bam")) return out else: work_bam = bam.sam_to_bam(out, config) data["work_bam"] = bam.sort(work_bam, config) return data
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier attribute subscript identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier if_statement call identifier argument_list identifier identifier block assert_statement call attribute identifier identifier argument_list string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier return_statement identifier
Align from fastq inputs, producing sorted BAM output.
def register_ddk_task(self, *args, **kwargs): kwargs["task_class"] = DdkTask return self.register_task(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier
Register a ddk task.
def save_user_and_user_email(self, user, user_email): if self.UserEmailClass: self.db_adapter.save_object(user_email) self.db_adapter.save_object(user)
module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Save the User and UserEmail object.
def handle_rule_versions(self, filename, rule_type, rule): if 'versions' in rule: versions = rule.pop('versions') for version_key_suffix in versions: version = versions[version_key_suffix] version['key_suffix'] = version_key_suffix tmp_rule = dict(rule, **version) self.rules[filename].append(Rule(filename, rule_type, tmp_rule)) else: self.rules[filename].append(Rule(filename, rule_type, rule))
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list call identifier argument_list identifier identifier identifier else_clause block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list call identifier argument_list identifier identifier identifier
For each version of a rule found in the ruleset, append a new Rule object
def wrap(value): if isinstance(value, Document) or isinstance(value, DocumentList): return value elif isinstance(value, dict): return Document(value) elif isinstance(value, list): return DocumentList(value) else: return value
module function_definition identifier parameters identifier block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block return_statement identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier else_clause block return_statement identifier
Wraps the given value in a Document or DocumentList as applicable.
def parse_TKIP_hdr(pkt): assert pkt.FCfield.protected tkip_layer = pkt[Dot11TKIP] payload = tkip_layer.data if not tkip_layer.ext_iv: raise ValueError("Extended IV must be set for TKIP") TSC0 = tkip_layer.TSC0 TSC1 = tkip_layer.TSC1 WEPseed = tkip_layer.WEPSeed TSC2 = tkip_layer.TSC2 TSC3 = tkip_layer.TSC3 TSC4 = tkip_layer.TSC4 TSC5 = tkip_layer.TSC5 assert (TSC1 | 0x20) & 0x7f == WEPseed TA = [orb(e) for e in mac2str(pkt.addr2)] TSC = [TSC0, TSC1, TSC2, TSC3, TSC4, TSC5] return TSC, TA, payload
module function_definition identifier parameters identifier block assert_statement attribute attribute identifier identifier identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier assert_statement comparison_operator binary_operator parenthesized_expression binary_operator identifier integer integer identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier list identifier identifier identifier identifier identifier identifier return_statement expression_list identifier identifier identifier
Extract TSCs, TA and encoded-data from a packet @pkt
def guess_input_handler(seqs, add_seq_names=False): if isinstance(seqs, str): if '\n' in seqs: return '_input_as_multiline_string' else: return '_input_as_string' if isinstance(seqs, list) and len(seqs) and isinstance(seqs[0], tuple): return '_input_as_seq_id_seq_pairs' if add_seq_names: return '_input_as_seqs' return '_input_as_lines'
module function_definition identifier parameters identifier default_parameter identifier false block if_statement call identifier argument_list identifier identifier block if_statement comparison_operator string string_start string_content escape_sequence string_end identifier block return_statement string string_start string_content string_end else_clause block return_statement string string_start string_content string_end if_statement boolean_operator boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier call identifier argument_list subscript identifier integer identifier block return_statement string string_start string_content string_end if_statement identifier block return_statement string string_start string_content string_end return_statement string string_start string_content string_end
Returns the name of the input handler for seqs.
def _select_default_algorithm(analysis): if not analysis or analysis == "Standard": return "Standard", {"aligner": "bwa", "platform": "illumina", "quality_format": "Standard", "recalibrate": False, "realign": False, "mark_duplicates": True, "variantcaller": False} elif "variant" in analysis: try: config, _ = template.name_to_config(analysis) except ValueError: config, _ = template.name_to_config("freebayes-variant") return "variant", config["details"][0]["algorithm"] else: return analysis, {}
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator identifier comparison_operator identifier string string_start string_content string_end block return_statement expression_list string string_start string_content string_end 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 false pair string string_start string_content string_end false pair string string_start string_content string_end true pair string string_start string_content string_end false elif_clause comparison_operator string string_start string_content string_end identifier block try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list string string_start string_content string_end subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end else_clause block return_statement expression_list identifier dictionary
Provide default algorithm sections from templates or standard
def spatial_slice_zeros(x): return tf.cast(tf.reduce_all(tf.less_equal(x, 0.0), [0, 1, 2]), tf.float32)
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier float list integer integer integer attribute identifier identifier
Experimental summary that shows how many planes are unused for a batch.
def _spawn(self): self.queue = Queue(maxsize=self.num_threads * 10) for i in range(self.num_threads): t = Thread(target=self._consume) t.daemon = True t.start()
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier binary_operator attribute identifier identifier integer for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list
Initialize the queue and the threads.
def del_node(self, char, node): del self._real.character[char].node[node] for cache in ( self._char_nodes_rulebooks_cache, self._node_stat_cache, self._node_successors_cache ): try: del cache[char][node] except KeyError: pass if char in self._char_nodes_cache and node in self._char_nodes_cache[char]: self._char_nodes_cache[char] = self._char_nodes_cache[char] - frozenset([node]) if char in self._portal_stat_cache: portal_stat_cache_char = self._portal_stat_cache[char] if node in portal_stat_cache_char: del portal_stat_cache_char[node] for charo in portal_stat_cache_char.values(): if node in charo: del charo[node] if char in self._char_portals_rulebooks_cache: portal_rulebook_cache_char = self._char_portals_rulebooks_cache[char] if node in portal_rulebook_cache_char: del portal_rulebook_cache_char[node] for porto in portal_rulebook_cache_char.values(): if node in porto: del porto[node]
module function_definition identifier parameters identifier identifier identifier block delete_statement subscript attribute subscript attribute attribute identifier identifier identifier identifier identifier identifier for_statement identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier block try_statement block delete_statement subscript subscript identifier identifier identifier except_clause identifier block pass_statement if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier subscript attribute identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier binary_operator subscript attribute identifier identifier identifier call identifier argument_list list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block delete_statement subscript identifier identifier
Remove a node from a character.
def adapt_sum(line, cfg, filter_obj): lines = filter_obj.filter_all(line) res_s = [sum(it) for it in lines] r = res_s.index(min(res_s)) return lines[r]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier return_statement subscript identifier identifier
Determine best filter by sum of all row values
def pupatizeElements(self) : for i in range(len(self)) : self[i] = self[i].pupa()
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment subscript identifier identifier call attribute subscript identifier identifier identifier argument_list
Transform all raba object into pupas
def clear_last_check(self): with db.session.begin_nested(): self.last_check = None self.last_check_at = datetime.utcnow() return self
module function_definition identifier parameters identifier block with_statement with_clause with_item call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement identifier
Clear the checksum of the file.
def extract(json_object, args, csv_writer): found = [[]] for attribute in args.attributes: item = attribute.getElement(json_object) if len(item) == 0: for row in found: row.append("NA") else: found1 = [] for value in item: if value is None: value = "NA" new = copy.deepcopy(found) for row in new: row.append(value) found1.extend(new) found = found1 for row in found: csv_writer.writerow(row) return len(found)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Extract and write found attributes.
def _CheckCollation(cursor): cur_collation_connection = _ReadVariable("collation_connection", cursor) if cur_collation_connection != COLLATION: logging.warning("Require MySQL collation_connection of %s, got %s.", COLLATION, cur_collation_connection) cur_collation_database = _ReadVariable("collation_database", cursor) if cur_collation_database != COLLATION: logging.warning( "Require MySQL collation_database of %s, got %s." " To create your database, use: %s", COLLATION, cur_collation_database, CREATE_DATABASE_QUERY)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier identifier identifier
Checks MySQL collation and warns if misconfigured.
def _text_attr(self, attr): attr = text[attr] if attr == "reset": self.cursor_attributes = self.default_attributes elif attr == "underline-off": self.cursor_attributes = self._remove_text_attr("underline") elif attr == "blink-off": self.cursor_attributes = self._remove_text_attr("blink") elif attr == "reverse-off": self.cursor_attributes = self._remove_text_attr("reverse") else: self.cursor_attributes = self._add_text_attr(attr)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier
Given a text attribute, set the current cursor appropriately.
def _get(self, operation, field): self._check_exists() query = {Mark.FLD_OP: operation.name, Mark.FLD_MARK + "." + field: {"$exists": True}} return self._track.find_one(query)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair attribute identifier identifier attribute identifier identifier pair binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier dictionary pair string string_start string_content string_end true return_statement call attribute attribute identifier identifier identifier argument_list identifier
Get tracked position for a given operation and field.
def _send_method(self, method_sig, args=bytes(), content=None): if isinstance(args, AMQPWriter): args = args.getvalue() self.connection.method_writer.write_method(self.channel_id, method_sig, args, content)
module function_definition identifier parameters identifier identifier default_parameter identifier call identifier argument_list default_parameter identifier none block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier identifier identifier
Send a method for our channel.
def cleanup(test_data, udfs, tmp_data, tmp_db): con = make_ibis_client(ENV) if udfs: con.hdfs.rmdir(os.path.join(ENV.test_data_dir, 'udf')) if test_data: con.drop_database(ENV.test_data_db, force=True) con.hdfs.rmdir(ENV.test_data_dir) if tmp_data: con.hdfs.rmdir(ENV.tmp_dir) if tmp_db: con.drop_database(ENV.tmp_db, force=True)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true
Cleanup Ibis test data and UDFs
def _is_somatic(rec): if _has_somatic_flag(rec): return True if _is_mutect2_somatic(rec): return True ss_flag = rec.INFO.get("SS") if ss_flag is not None: if str(ss_flag) == "2": return True status_flag = rec.INFO.get("STATUS") if status_flag is not None: if str(status_flag).lower() in ["somatic", "likelysomatic", "strongsomatic", "samplespecific"]: return True epr = rec.INFO.get("EPR", "").split(",") if epr and all([p == "pass" for p in epr]): return True return False
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier block return_statement true if_statement call identifier argument_list identifier block return_statement true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block if_statement comparison_operator call identifier argument_list identifier string string_start string_content string_end block return_statement true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block if_statement comparison_operator call attribute call identifier argument_list identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement true expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier call identifier argument_list list_comprehension comparison_operator identifier string string_start string_content string_end for_in_clause identifier identifier block return_statement true return_statement false
Handle somatic classifications from MuTect, MuTect2, VarDict and VarScan
def copyfile(self, target): shutil.copyfile(self.path, self._to_backend(target))
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier
Copies this file to the given `target` location.
def serveUpcoming(self, request): myurl = self.get_url(request) today = timezone.localdate() monthlyUrl = myurl + self.reverse_subpage('serveMonth', args=[today.year, today.month]) weekNum = gregorian_to_week_date(today)[1] weeklyUrl = myurl + self.reverse_subpage('serveWeek', args=[today.year, weekNum]) listUrl = myurl + self.reverse_subpage('servePast') upcomingEvents = self._getUpcomingEvents(request) paginator = Paginator(upcomingEvents, self.EventsPerPage) try: eventsPage = paginator.page(request.GET.get('page')) except PageNotAnInteger: eventsPage = paginator.page(1) except EmptyPage: eventsPage = paginator.page(paginator.num_pages) return render(request, "joyous/calendar_list_upcoming.html", {'self': self, 'page': self, 'version': __version__, 'today': today, 'weeklyUrl': weeklyUrl, 'monthlyUrl': monthlyUrl, 'listUrl': listUrl, 'events': eventsPage})
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier subscript call identifier argument_list identifier integer expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier list attribute identifier identifier identifier expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
Upcoming events list view.
def transmit_agnocomplete_context(self): user = super(AgnocompleteContextQuerysetMixin, self) \ .transmit_agnocomplete_context() if user: self.queryset = self.agnocomplete.get_queryset() return user
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier line_continuation identifier argument_list if_statement identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list return_statement identifier
We'll reset the current queryset only if the user is set.
def _add_timeout(self, request, future): io_loop = IOLoop.current() t = io_loop.call_later( request.ttl, self._request_timed_out, request.id, request.service, request.ttl, future, ) io_loop.add_future(future, lambda f: io_loop.remove_timeout(t))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier
Adds a timeout for the given request to the given future.
def to_base_variable(self): return Variable(self.dims, self._data, self._attrs, encoding=self._encoding, fastpath=True)
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true
Return this variable as a base xarray.Variable
def verify(path): path = pathlib.Path(path) valid = False if path.suffix == ".npy": try: nf = np.load(str(path), mmap_mode="r", allow_pickle=False) except (OSError, ValueError, IsADirectoryError): pass else: if len(nf.shape) == 2: valid = True return valid
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier false if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier false except_clause tuple identifier identifier identifier block pass_statement else_clause block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier true return_statement identifier
Verify that `path` has a supported numpy file format
def start(st_reg_number): weights = [9, 8, 7, 6, 5, 4, 3, 2] digit_state_registration = st_reg_number[-1] if len(st_reg_number) != 9: return False sum_total = 0 for i in range(0, 8): sum_total = sum_total + weights[i] * int(st_reg_number[i]) if sum_total % 11 == 0: return digit_state_registration[-1] == '0' digit_check = 11 - sum_total % 11 return str(digit_check) == digit_state_registration
module function_definition identifier parameters identifier block expression_statement assignment identifier list integer integer integer integer integer integer integer integer expression_statement assignment identifier subscript identifier unary_operator integer if_statement comparison_operator call identifier argument_list identifier integer block return_statement false expression_statement assignment identifier integer for_statement identifier call identifier argument_list integer integer block expression_statement assignment identifier binary_operator identifier binary_operator subscript identifier identifier call identifier argument_list subscript identifier identifier if_statement comparison_operator binary_operator identifier integer integer block return_statement comparison_operator subscript identifier unary_operator integer string string_start string_content string_end expression_statement assignment identifier binary_operator integer binary_operator identifier integer return_statement comparison_operator call identifier argument_list identifier identifier
Checks the number valiaty for the Paraiba state
def app_state(self, app): if not self.available or not self.screen_on: return STATE_OFF if self.current_app["package"] == app: return STATE_ON return STATE_OFF
module function_definition identifier parameters identifier identifier block if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block return_statement identifier if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end identifier block return_statement identifier return_statement identifier
Informs if application is running.
def load_user_catalog(): cat_dir = user_data_dir() if not os.path.isdir(cat_dir): return Catalog() else: return YAMLFilesCatalog(cat_dir)
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement call identifier argument_list else_clause block return_statement call identifier argument_list identifier
Return a catalog for the platform-specific user Intake directory
def acceptable(value, capitalize=False): name = regexes['punctuation'].sub("", regexes['joins'].sub("_", value)) name = regexes['repeated_underscore'].sub("_", name.strip('_')) if capitalize: name_parts = [] for word in name.split('_'): name_parts.append(word[0].upper()) if len(word) > 1: name_parts.append(word[1:]) name = ''.join(name_parts) return name
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute subscript identifier integer identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list subscript identifier slice integer expression_statement assignment identifier call attribute string string_start string_end identifier argument_list identifier return_statement identifier
Convert a string into something that can be used as a valid python variable name
def round(self, digits=0): self._left = round(self._left, digits) self._bottom = round(self._bottom, digits) self._width = round(self._width, digits) self._height = round(self._height, digits)
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier
Round the dimensions of the given rectangle to the given number of digits.
def _build_session(username, password, trans_label=None): bigip = requests.session() bigip.auth = (username, password) bigip.verify = False bigip.headers.update({'Content-Type': 'application/json'}) if trans_label: trans_id = __salt__['grains.get']('bigip_f5_trans:{label}'.format(label=trans_label)) if trans_id: bigip.headers.update({'X-F5-REST-Coordination-Id': trans_id}) else: bigip.headers.update({'X-F5-REST-Coordination-Id': None}) return bigip
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier tuple identifier identifier expression_statement assignment attribute identifier identifier false expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end none return_statement identifier
Create a session to be used when connecting to iControl REST.
def T(self, ID, sign): lon = self.terms[sign][ID] ID = 'T_%s_%s' % (ID, sign) return self.G(ID, 0, lon)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript subscript attribute identifier identifier identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier return_statement call attribute identifier identifier argument_list identifier integer identifier
Returns the term of an object in a sign.
def to_json(self): res_dict = {} def gen_dep_edge(node, edge, dep_tgt, aliases): return { 'target': dep_tgt.address.spec, 'dependency_type': self._edge_type(node.concrete_target, edge, dep_tgt), 'products_used': len(edge.products_used), 'products_used_ratio': self._used_ratio(dep_tgt, edge), 'aliases': [alias.address.spec for alias in aliases], } for node in self._nodes.values(): res_dict[node.concrete_target.address.spec] = { 'cost': self._cost(node.concrete_target), 'cost_transitive': self._trans_cost(node.concrete_target), 'products_total': node.products_total, 'dependencies': [gen_dep_edge(node, edge, dep_tgt, node.dep_aliases.get(dep_tgt, {})) for dep_tgt, edge in node.dep_edges.items()], } yield str(json.dumps(res_dict, indent=2, sort_keys=True))
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary function_definition identifier parameters identifier identifier identifier identifier block return_statement dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier identifier identifier pair string string_start string_content string_end call identifier argument_list attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier pair string string_start string_content string_end list_comprehension attribute attribute identifier identifier identifier for_in_clause identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier attribute attribute attribute identifier identifier identifier identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end list_comprehension call identifier argument_list identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier dictionary for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement yield call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier true
Outputs the entire graph.
def upgrade(cfg): db_node = cfg["db"] old_db_elems = ["host", "name", "port", "pass", "user", "dialect"] has_old_db_elems = [x in db_node for x in old_db_elems] if any(has_old_db_elems): print("Old database configuration found. " "Converting to new connect_string. " "This will *not* be stored in the configuration automatically.") cfg["db"]["connect_string"] = \ "{dialect}://{user}:{password}@{host}:{port}/{name}".format( dialect=cfg["db"]["dialect"]["value"], user=cfg["db"]["user"]["value"], password=cfg["db"]["pass"]["value"], host=cfg["db"]["host"]["value"], port=cfg["db"]["port"]["value"], name=cfg["db"]["name"]["value"])
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end 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 expression_statement assignment identifier list_comprehension comparison_operator identifier identifier for_in_clause identifier identifier if_statement call identifier argument_list identifier block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end
Provide forward migration for configuration files.
def envs(self): load = {'cmd': '_file_envs'} return salt.utils.data.decode(self.channel.send(load)) if six.PY2 \ else self.channel.send(load)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end return_statement conditional_expression call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier line_continuation call attribute attribute identifier identifier identifier argument_list identifier
Return a list of available environments
def check_stf_agent(adbprefix=None, kill=False): if adbprefix is None: adbprefix = ['adb'] command = adbprefix + ['shell', 'ps'] out = subprocess.check_output(command).strip() out = out.splitlines() if len(out) > 1: first, out = out[0], out[1:] idx = first.split().index('PID') pid = None for line in out: if 'stf.agent' in line: pid = line.split()[idx] print 'stf.agent is running, pid is', pid break if pid is not None: if kill: print 'killing', pid command = adbprefix + ['shell', 'kill', '-9', pid] subprocess.call(command) return False return True return False
module function_definition identifier parameters default_parameter identifier none default_parameter identifier false block if_statement comparison_operator identifier none block expression_statement assignment identifier list string string_start string_content string_end expression_statement assignment identifier binary_operator identifier list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier expression_list subscript identifier integer subscript identifier slice integer expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier none for_statement identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier print_statement string string_start string_content string_end identifier break_statement if_statement comparison_operator identifier none block if_statement identifier block print_statement string string_start string_content string_end identifier expression_statement assignment identifier binary_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier return_statement false return_statement true return_statement false
return True if agent is alive.
def write_bool(self, flag): if flag: self.write(b"\x01") else: self.write(b"\x00")
module function_definition identifier parameters identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
Writes a boolean to the underlying output file as a 1-byte value.
def _push(self): push_cmds = self.vcs.push_commands() if not push_cmds: return if utils.ask("OK to push commits to the server?"): for push_cmd in push_cmds: output = utils.system(push_cmd) logger.info(output)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement not_operator identifier block return_statement if_statement call attribute identifier identifier argument_list string string_start string_content string_end block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Offer to push changes, if needed.
def focusWindow(self, hwnd): Debug.log(3, "Focusing window: " + str(hwnd)) SW_RESTORE = 9 if ctypes.windll.user32.IsIconic(hwnd): ctypes.windll.user32.ShowWindow(hwnd, SW_RESTORE) ctypes.windll.user32.SetForegroundWindow(hwnd)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list integer binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier integer if_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
Brings specified window to the front
def calc_buffered_bounds( format, bounds, meters_per_pixel_dim, layer_name, geometry_type, buffer_cfg): if not buffer_cfg: return bounds format_buffer_cfg = buffer_cfg.get(format.extension) if format_buffer_cfg is None: return bounds geometry_type = normalize_geometry_type(geometry_type) per_layer_cfg = format_buffer_cfg.get('layer', {}).get(layer_name) if per_layer_cfg is not None: layer_geom_pixels = per_layer_cfg.get(geometry_type) if layer_geom_pixels is not None: assert isinstance(layer_geom_pixels, Number) result = bounds_buffer( bounds, meters_per_pixel_dim * layer_geom_pixels) return result by_geometry_pixels = format_buffer_cfg.get('geometry', {}).get( geometry_type) if by_geometry_pixels is not None: assert isinstance(by_geometry_pixels, Number) result = bounds_buffer( bounds, meters_per_pixel_dim * by_geometry_pixels) return result return bounds
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier binary_operator identifier identifier return_statement identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list identifier if_statement comparison_operator identifier none block assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier binary_operator identifier identifier return_statement identifier return_statement identifier
Calculate the buffered bounds per format per layer based on config.
def _from_dict(cls, _dict): args = {} if 'age' in _dict: args['age'] = FaceAge._from_dict(_dict.get('age')) if 'gender' in _dict: args['gender'] = FaceGender._from_dict(_dict.get('gender')) if 'face_location' in _dict: args['face_location'] = FaceLocation._from_dict( _dict.get('face_location')) return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a Face object from a json dictionary.
def down(self, point): self._vdown = arcball_map_to_sphere(point, self._center, self._radius) self._qdown = self._qpre = self._qnow if self._constrain and self._axes is not None: self._axis = arcball_nearest_axis(self._vdown, self._axes) self._vdown = arcball_constrain_to_axis(self._vdown, self._axis) else: self._axis = None
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier assignment attribute identifier identifier attribute identifier identifier if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier none
Set initial cursor window coordinates and pick constrain-axis.
def handle(self, *args, **options): self._connection = Auth()._get_connection() if len(args) == 0: containers = self._connection.list_containers() if not containers: print("No containers were found for this account.") elif len(args) == 1: containers = self._connection.list_container_object_names(args[0]) if not containers: print("No matching container found.") else: raise CommandError("Pass one and only one [container_name] as an argument") for container in containers: print(container)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier call attribute call identifier argument_list identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement not_operator identifier block expression_statement call identifier argument_list string string_start string_content string_end elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier integer if_statement not_operator identifier block expression_statement call identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement call identifier argument_list identifier
Lists all the items in a container to stdout.
def solve(self, solver_klass=None): t0 = time() om = self._construct_opf_model(self.case) if om is None: return {"converged": False, "output": {"message": "No Ref Bus."}} if solver_klass is not None: result = solver_klass(om, opt=self.opt).solve() elif self.dc: result = DCOPFSolver(om, opt=self.opt).solve() else: result = PIPSSolver(om, opt=self.opt).solve() result["elapsed"] = time() - t0 if self.opt.has_key("verbose"): if self.opt["verbose"]: logger.info("OPF completed in %.3fs." % result["elapsed"]) return result
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block return_statement dictionary pair string string_start string_content string_end false pair string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute call identifier argument_list identifier keyword_argument identifier attribute identifier identifier identifier argument_list elif_clause attribute identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier keyword_argument identifier attribute identifier identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute call identifier argument_list identifier keyword_argument identifier attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end binary_operator call identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement identifier
Solves an optimal power flow and returns a results dictionary.
def _pop_index(self, index, has_default): try: if index is NOT_SET: index = len(self._list) - 1 key, value = self._list.pop() else: key, value = self._list.pop(index) if index < 0: index += len(self._list) + 1 except IndexError: if has_default: return None, None, None else: raise index2, value2 = self._dict.pop(key) assert index == index2 assert value is value2 return key, index, value
module function_definition identifier parameters identifier identifier identifier block try_statement block if_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier binary_operator call identifier argument_list attribute identifier identifier integer except_clause identifier block if_statement identifier block return_statement expression_list none none none else_clause block raise_statement expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier assert_statement comparison_operator identifier identifier assert_statement comparison_operator identifier identifier return_statement expression_list identifier identifier identifier
Remove an element by index, or last element.
def html(self, label, *msg): lbl = "[" + label + "] " txt = lbl + " " + " ".join(list(msg)) if self.notebook is True: html = HTML(txt) display(lbl + html) else: print(lbl + txt)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier true block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list binary_operator identifier identifier else_clause block expression_statement call identifier argument_list binary_operator identifier identifier
Prints html in notebook
def variant(self, case_id, variant_id): case_obj = self.case(case_id) plugin, case_id = self.select_plugin(case_obj) variant = plugin.variant(case_id, variant_id) return variant
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Fetch a single variant from variant source.
def on_episode_end(self, episode, logs): duration = timeit.default_timer() - self.starts[episode] metrics = self.metrics[episode] if np.isnan(metrics).all(): mean_metrics = np.array([np.nan for _ in self.metrics_names]) else: mean_metrics = np.nanmean(metrics, axis=0) assert len(mean_metrics) == len(self.metrics_names) data = list(zip(self.metrics_names, mean_metrics)) data += list(logs.items()) data += [('episode', episode), ('duration', duration)] for key, value in data: if key not in self.data: self.data[key] = [] self.data[key].append(value) if self.interval is not None and episode % self.interval == 0: self.save_data() del self.metrics[episode] del self.starts[episode]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list subscript attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement call attribute call attribute identifier identifier argument_list identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier integer assert_statement comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier identifier expression_statement augmented_assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement augmented_assignment identifier list tuple string string_start string_content string_end identifier tuple string string_start string_content string_end identifier for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier list expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator binary_operator identifier attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list delete_statement subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier
Compute and print metrics at the end of each episode
def get(self, entry): if self.apiVersion == 1: path = self.secretsmount + '/' + entry else: path = self.secretsmount + '/data/' + entry proj = yield self._http.get('/v1/{0}'.format(path)) code = yield proj.code if code != 200: raise KeyError("The key %s does not exist in Vault provider: request" " return code:%d." % (entry, code)) json = yield proj.json() if self.apiVersion == 1: ret = json.get('data', {}).get('value') else: ret = json.get('data', {}).get('data', {}).get('value') return ret
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier else_clause block expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier yield 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 yield attribute identifier identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier yield call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end return_statement identifier
get the value from vault secret backend
def open(cls, blob, username, password): return cls(blob, blob.encryption_key(username, password))
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier
Creates a vault from a blob object
def save(self): active_language = get_language() for (name, value) in self.cleaned_data.items(): if name not in registry: name, code = name.rsplit('_modeltranslation_', 1) else: code = None setting_obj, created = Setting.objects.get_or_create(name=name) if settings.USE_MODELTRANSLATION: if registry[name]["translatable"]: try: activate(code) except: pass finally: setting_obj.value = value activate(active_language) else: for code in OrderedDict(settings.LANGUAGES): setattr(setting_obj, build_localized_fieldname('value', code), value) else: setting_obj.value = value setting_obj.save()
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer else_clause block expression_statement assignment identifier none expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement attribute identifier identifier block if_statement subscript subscript identifier identifier string string_start string_content string_end block try_statement block expression_statement call identifier argument_list identifier except_clause block pass_statement finally_clause block expression_statement assignment attribute identifier identifier identifier expression_statement call identifier argument_list identifier else_clause block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call identifier argument_list identifier call identifier argument_list string string_start string_content string_end identifier identifier else_clause block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Save each of the settings to the DB.
def next_frame_pixel_noise(): hparams = next_frame_basic_deterministic() hparams.add_hparam("video_modality_input_noise", 0.05) hparams.bottom["inputs"] = modalities.video_pixel_noise_bottom hparams.top["inputs"] = modalities.video_top return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end float expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
Basic 2-frame conv model with pixel noise.
async def on_raw_authenticate(self, message): if self._sasl_timer: self._sasl_timer.cancel() self._sasl_timer = None response = ' '.join(message.params) if response != EMPTY_MESSAGE: self._sasl_challenge += base64.b64decode(response) if len(response) % RESPONSE_LIMIT > 0: await self._sasl_respond() else: self._sasl_timer = self.eventloop.call_later(self.SASL_TIMEOUT, self._sasl_abort(timeout=True))
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement augmented_assignment attribute identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator binary_operator call identifier argument_list identifier identifier integer block expression_statement await call attribute identifier identifier argument_list else_clause block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier true
Received part of the authentication challenge.
def get(self, request, *args, **kwargs): self.object = self.get_object() can_delete = True protected_objects = [] collector_message = None collector = Collector(using="default") try: collector.collect([self.object]) except ProtectedError as e: collector_message = ( "Cannot delete %s because it has relations " "that depends on it." % self.object ) protected_objects = e.protected_objects can_delete = False if can_delete and self.redirect: messages.success(request, self.get_success_message(self.object)) return self.delete(request, *args, **kwargs) context = self.get_context_data( object=self.object, can_delete=can_delete, collector_message=collector_message, protected_objects=protected_objects, ) return self.render_to_response(context)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier true expression_statement assignment identifier list expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list list attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier false if_statement boolean_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list identifier
Catch protected relations and show to user.
def cor(y_true, y_pred): y_true, y_pred = _mask_nan(y_true, y_pred) return np.corrcoef(y_true, y_pred)[0, 1]
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier return_statement subscript call attribute identifier identifier argument_list identifier identifier integer integer
Compute Pearson correlation coefficient.
def clock_in(request): user = request.user active_entry = utils.get_active_entry(user, select_for_update=True) initial = dict([(k, v) for k, v in request.GET.items()]) data = request.POST or None form = ClockInForm(data, initial=initial, user=user, active=active_entry) if form.is_valid(): entry = form.save() message = 'You have clocked into {0} on {1}.'.format( entry.activity.name, entry.project) messages.info(request, message) return HttpResponseRedirect(reverse('dashboard')) return render(request, 'timepiece/entry/clock_in.html', { 'form': form, 'active': active_entry, })
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call identifier argument_list list_comprehension tuple identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier boolean_operator attribute identifier identifier none expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier
For clocking the user into a project.