nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
msracver/Deformable-ConvNets
6aeda878a95bcb55eadffbe125804e730574de8d
rfcn/core/DataParallelExecutorGroup.py
python
DataParallelExecutorGroup.backward
(self, out_grads=None)
Run backward on all devices. A backward should be called after a call to the forward function. Backward cannot be called unless `self.for_training` is `True`. Parameters ---------- out_grads : NDArray or list of NDArray, optional Gradient on the outputs to be propagated back. This parameter is only needed when bind is called on outputs that are not a loss function.
Run backward on all devices. A backward should be called after a call to the forward function. Backward cannot be called unless `self.for_training` is `True`.
[ "Run", "backward", "on", "all", "devices", ".", "A", "backward", "should", "be", "called", "after", "a", "call", "to", "the", "forward", "function", ".", "Backward", "cannot", "be", "called", "unless", "self", ".", "for_training", "is", "True", "." ]
def backward(self, out_grads=None): """Run backward on all devices. A backward should be called after a call to the forward function. Backward cannot be called unless `self.for_training` is `True`. Parameters ---------- out_grads : NDArray or list of NDArray, optional Gradient on the outputs to be propagated back. This parameter is only needed when bind is called on outputs that are not a loss function. """ assert self.for_training, 're-bind with for_training=True to run backward' if out_grads is None: out_grads = [] for i, exec_ in enumerate(self.execs): out_grads_slice = [] exec_.backward(out_grads=out_grads_slice)
[ "def", "backward", "(", "self", ",", "out_grads", "=", "None", ")", ":", "assert", "self", ".", "for_training", ",", "'re-bind with for_training=True to run backward'", "if", "out_grads", "is", "None", ":", "out_grads", "=", "[", "]", "for", "i", ",", "exec_",...
https://github.com/msracver/Deformable-ConvNets/blob/6aeda878a95bcb55eadffbe125804e730574de8d/rfcn/core/DataParallelExecutorGroup.py#L450-L468
entropy1337/infernal-twin
10995cd03312e39a48ade0f114ebb0ae3a711bb8
Modules/build/pip/pip/_vendor/pkg_resources/__init__.py
python
WorkingSet.__init__
(self, entries=None)
Create working set from list of path entries (default=sys.path)
Create working set from list of path entries (default=sys.path)
[ "Create", "working", "set", "from", "list", "of", "path", "entries", "(", "default", "=", "sys", ".", "path", ")" ]
def __init__(self, entries=None): """Create working set from list of path entries (default=sys.path)""" self.entries = [] self.entry_keys = {} self.by_key = {} self.callbacks = [] if entries is None: entries = sys.path for entry in entries: self.add_entry(entry)
[ "def", "__init__", "(", "self", ",", "entries", "=", "None", ")", ":", "self", ".", "entries", "=", "[", "]", "self", ".", "entry_keys", "=", "{", "}", "self", ".", "by_key", "=", "{", "}", "self", ".", "callbacks", "=", "[", "]", "if", "entries"...
https://github.com/entropy1337/infernal-twin/blob/10995cd03312e39a48ade0f114ebb0ae3a711bb8/Modules/build/pip/pip/_vendor/pkg_resources/__init__.py#L618-L629
youfou/hsdata
49866116eaeb78516829da59df59a2c0b1141c08
hsdata/utils.py
python
cards_value
(decks, mode=MODE_STANDARD)
return stats
区分职业的单卡价值排名,可在纠结是否合成或拆解时作为参考 decks: 所在卡组数量 games: 所在卡组游戏次数总和 wins: 所在卡组获胜次数总和 win_rate: 所在卡组平均胜率 (wins/games) *_rank: 在当前职业所有卡牌中的 * 排名 *_rank%: 在当前职业所有卡牌中的 * 排名百分比 (排名/卡牌数) :param decks: 卡组合集,作为分析数据源 :param mode: 模式 :return: 单卡价值排名数据
区分职业的单卡价值排名,可在纠结是否合成或拆解时作为参考
[ "区分职业的单卡价值排名,可在纠结是否合成或拆解时作为参考" ]
def cards_value(decks, mode=MODE_STANDARD): """ 区分职业的单卡价值排名,可在纠结是否合成或拆解时作为参考 decks: 所在卡组数量 games: 所在卡组游戏次数总和 wins: 所在卡组获胜次数总和 win_rate: 所在卡组平均胜率 (wins/games) *_rank: 在当前职业所有卡牌中的 * 排名 *_rank%: 在当前职业所有卡牌中的 * 排名百分比 (排名/卡牌数) :param decks: 卡组合集,作为分析数据源 :param mode: 模式 :return: 单卡价值排名数据 """ if not isinstance(decks, Decks): raise TypeError('from_decks 须为 Decks 对象') total = 'total' ranked_keys = 'decks', 'games', 'wins', 'win_rate' rpf = '_rank' ppf = '%' stats = dict() stats[total] = dict() for deck in decks.search(mode=mode): career = deck.career if career not in stats: stats[career] = dict() for card, count in deck.cards.items(): for k in total, career: if card not in stats[k]: stats[k][card] = dict( decks=0, games=0, wins=0, count=0) stats[k][card]['decks'] += 1 stats[k][card]['games'] += deck.games or 0 stats[k][card]['wins'] += deck.wins or 0 stats[k][card]['count'] += count for k in stats: for c in stats[k]: try: stats[k][c]['win_rate'] = stats[k][c]['wins'] / stats[k][c]['games'] except ZeroDivisionError: stats[k][c]['win_rate'] = None stats[k][c]['avg_count'] = stats[k][c]['count'] / stats[k][c]['decks'] rkvl = dict() for k in stats: if k not in rkvl: rkvl[k] = dict() for rk in ranked_keys: vl = [s[rk] for c, s in stats[k].items()] vl = list(filter(lambda x: x, vl)) vl.sort(reverse=True) rkvl[k][rk] = vl for k in stats: for c in stats[k]: for rk in ranked_keys: if stats[k][c][rk]: rank = rkvl[k][rk].index(stats[k][c][rk]) + 1 stats[k][c][rk + rpf] = rank stats[k][c][rk + rpf + ppf] = rank / len(stats[k]) else: stats[k][c][rk + rpf] = None stats[k][c][rk + ppf] = None return stats
[ "def", "cards_value", "(", "decks", ",", "mode", "=", "MODE_STANDARD", ")", ":", "if", "not", "isinstance", "(", "decks", ",", "Decks", ")", ":", "raise", "TypeError", "(", "'from_decks 须为 Decks 对象')", "", "total", "=", "'total'", "ranked_keys", "=", "'decks...
https://github.com/youfou/hsdata/blob/49866116eaeb78516829da59df59a2c0b1141c08/hsdata/utils.py#L58-L129
facebookresearch/Large-Scale-VRD
7ababfe1023941c3653d7aebe9f835a47f5e8277
lib/utils/lr_policy.py
python
get_step_index
(cur_iter)
return ind - 1
Given an iteration, find which learning rate step we're at.
Given an iteration, find which learning rate step we're at.
[ "Given", "an", "iteration", "find", "which", "learning", "rate", "step", "we", "re", "at", "." ]
def get_step_index(cur_iter): """Given an iteration, find which learning rate step we're at.""" assert cfg.SOLVER.STEPS[0] == 0, 'The first step should always start at 0.' steps = cfg.SOLVER.STEPS + [cfg.SOLVER.MAX_ITER] for ind, step in enumerate(steps): # NoQA if cur_iter < step: break return ind - 1
[ "def", "get_step_index", "(", "cur_iter", ")", ":", "assert", "cfg", ".", "SOLVER", ".", "STEPS", "[", "0", "]", "==", "0", ",", "'The first step should always start at 0.'", "steps", "=", "cfg", ".", "SOLVER", ".", "STEPS", "+", "[", "cfg", ".", "SOLVER",...
https://github.com/facebookresearch/Large-Scale-VRD/blob/7ababfe1023941c3653d7aebe9f835a47f5e8277/lib/utils/lr_policy.py#L89-L96
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/tkinter/__init__.py
python
Wm.wm_positionfrom
(self, who=None)
return self.tk.call('wm', 'positionfrom', self._w, who)
Instruct the window manager that the position of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".
Instruct the window manager that the position of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".
[ "Instruct", "the", "window", "manager", "that", "the", "position", "of", "this", "widget", "shall", "be", "defined", "by", "the", "user", "if", "WHO", "is", "user", "and", "by", "its", "own", "policy", "if", "WHO", "is", "program", "." ]
def wm_positionfrom(self, who=None): """Instruct the window manager that the position of this widget shall be defined by the user if WHO is "user", and by its own policy if WHO is "program".""" return self.tk.call('wm', 'positionfrom', self._w, who)
[ "def", "wm_positionfrom", "(", "self", ",", "who", "=", "None", ")", ":", "return", "self", ".", "tk", ".", "call", "(", "'wm'", ",", "'positionfrom'", ",", "self", ".", "_w", ",", "who", ")" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/tkinter/__init__.py#L1601-L1605
PyAr/fades
40a4cda535b2af6e141bdd68d6cfaab217eabe44
fades/pipmanager.py
python
PipManager.get_version
(self, dependency)
Return the installed version parsing the output of 'pip show'.
Return the installed version parsing the output of 'pip show'.
[ "Return", "the", "installed", "version", "parsing", "the", "output", "of", "pip", "show", "." ]
def get_version(self, dependency): """Return the installed version parsing the output of 'pip show'.""" logger.debug("getting installed version for %s", dependency) stdout = helpers.logged_exec([self.pip_exe, "show", str(dependency)]) version = [line for line in stdout if line.startswith('Version:')] if len(version) == 1: version = version[0].strip().split()[1] logger.debug("Installed version of %s is: %s", dependency, version) return version else: logger.error('Fades is having problems getting the installed version. ' 'Run with -v or check the logs for details') return ''
[ "def", "get_version", "(", "self", ",", "dependency", ")", ":", "logger", ".", "debug", "(", "\"getting installed version for %s\"", ",", "dependency", ")", "stdout", "=", "helpers", ".", "logged_exec", "(", "[", "self", ".", "pip_exe", ",", "\"show\"", ",", ...
https://github.com/PyAr/fades/blob/40a4cda535b2af6e141bdd68d6cfaab217eabe44/fades/pipmanager.py#L84-L96
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-linux/x64/PIL/ImageDraw2.py
python
Font.__init__
(self, color, file, size=12)
[]
def __init__(self, color, file, size=12): # FIXME: add support for bitmap fonts self.color = ImageColor.getrgb(color) self.font = ImageFont.truetype(file, size)
[ "def", "__init__", "(", "self", ",", "color", ",", "file", ",", "size", "=", "12", ")", ":", "# FIXME: add support for bitmap fonts", "self", ".", "color", "=", "ImageColor", ".", "getrgb", "(", "color", ")", "self", ".", "font", "=", "ImageFont", ".", "...
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-linux/x64/PIL/ImageDraw2.py#L34-L37
googleads/google-ads-python
2a1d6062221f6aad1992a6bcca0e7e4a93d2db86
google/ads/googleads/v8/services/services/customer_client_service/client.py
python
CustomerClientServiceClient.common_project_path
(project: str,)
return "projects/{project}".format(project=project,)
Return a fully-qualified project string.
Return a fully-qualified project string.
[ "Return", "a", "fully", "-", "qualified", "project", "string", "." ]
def common_project_path(project: str,) -> str: """Return a fully-qualified project string.""" return "projects/{project}".format(project=project,)
[ "def", "common_project_path", "(", "project", ":", "str", ",", ")", "->", "str", ":", "return", "\"projects/{project}\"", ".", "format", "(", "project", "=", "project", ",", ")" ]
https://github.com/googleads/google-ads-python/blob/2a1d6062221f6aad1992a6bcca0e7e4a93d2db86/google/ads/googleads/v8/services/services/customer_client_service/client.py#L236-L238
Cadene/tensorflow-model-zoo.torch
990b10ffc22d4c8eacb2a502f20415b4f70c74c2
models/research/pcl_rl/controller.py
python
Controller.convert_from_batched_episodes
( self, initial_state, observations, actions, rewards, terminated, pads)
return episodes
Convert time-major batch of episodes to batch-major list of episodes.
Convert time-major batch of episodes to batch-major list of episodes.
[ "Convert", "time", "-", "major", "batch", "of", "episodes", "to", "batch", "-", "major", "list", "of", "episodes", "." ]
def convert_from_batched_episodes( self, initial_state, observations, actions, rewards, terminated, pads): """Convert time-major batch of episodes to batch-major list of episodes.""" rewards = np.array(rewards) pads = np.array(pads) observations = [np.array(obs) for obs in observations] actions = [np.array(act) for act in actions] total_rewards = np.sum(rewards * (1 - pads), axis=0) total_length = np.sum(1 - pads, axis=0).astype('int32') episodes = [] num_episodes = rewards.shape[1] for i in xrange(num_episodes): length = total_length[i] ep_initial = initial_state[i] ep_obs = [obs[:length, i, ...] for obs in observations] ep_act = [act[:length + 1, i, ...] for act in actions] ep_rewards = rewards[:length, i] episodes.append( [ep_initial, ep_obs, ep_act, ep_rewards, terminated[i]]) return episodes
[ "def", "convert_from_batched_episodes", "(", "self", ",", "initial_state", ",", "observations", ",", "actions", ",", "rewards", ",", "terminated", ",", "pads", ")", ":", "rewards", "=", "np", ".", "array", "(", "rewards", ")", "pads", "=", "np", ".", "arra...
https://github.com/Cadene/tensorflow-model-zoo.torch/blob/990b10ffc22d4c8eacb2a502f20415b4f70c74c2/models/research/pcl_rl/controller.py#L336-L361
replit-archive/empythoned
977ec10ced29a3541a4973dc2b59910805695752
cpython/Misc/Vim/vim_syntax.py
python
str_regexes
()
Generator to yield various combinations of strings regexes
Generator to yield various combinations of strings regexes
[ "Generator", "to", "yield", "various", "combinations", "of", "strings", "regexes" ]
def str_regexes(): """Generator to yield various combinations of strings regexes""" regex_template = Template('matchgroup=Normal ' + 'start=+[uU]\=${raw}${sep}+ ' + 'end=+${sep}+ ' + '${skip} ' + '${contains}') skip_regex = Template(r'skip=+\\\\\|\\${sep}+') for raw in ('', '[rR]'): for separator in ("'", '"', '"""', "'''"): if len(separator) == 1: skip = skip_regex.substitute(sep=separator) else: skip = '' contains = 'contains=pythonEscape' if not raw else '' yield regex_template.substitute(raw=raw, sep=separator, skip=skip, contains = contains)
[ "def", "str_regexes", "(", ")", ":", "regex_template", "=", "Template", "(", "'matchgroup=Normal '", "+", "'start=+[uU]\\=${raw}${sep}+ '", "+", "'end=+${sep}+ '", "+", "'${skip} '", "+", "'${contains}'", ")", "skip_regex", "=", "Template", "(", "r'skip=+\\\\\\\\\\|\\\\...
https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/cpython/Misc/Vim/vim_syntax.py#L57-L73
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/sre_parse.py
python
Pattern.checkgroup
(self, gid)
return gid < self.groups and gid not in self.open
[]
def checkgroup(self, gid): return gid < self.groups and gid not in self.open
[ "def", "checkgroup", "(", "self", ",", "gid", ")", ":", "return", "gid", "<", "self", ".", "groups", "and", "gid", "not", "in", "self", ".", "open" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/sre_parse.py#L86-L87
hellerbarde/stapler
1cabc85521e2badfc1e0d690086e286e701c2d9e
staplelib/iohelper.py
python
read_pdf
(filename)
return pdf
Open a PDF file with PyPDF2.
Open a PDF file with PyPDF2.
[ "Open", "a", "PDF", "file", "with", "PyPDF2", "." ]
def read_pdf(filename): """Open a PDF file with PyPDF2.""" if not os.path.exists(filename): raise CommandError("{} does not exist".format(filename)) pdf = PdfFileReader(open(filename, "rb")) if pdf.isEncrypted: while True: pw = prompt_for_pw(filename) matched = pdf.decrypt(pw) if matched: break else: print("The password did not match.") return pdf
[ "def", "read_pdf", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "raise", "CommandError", "(", "\"{} does not exist\"", ".", "format", "(", "filename", ")", ")", "pdf", "=", "PdfFileReader", "(", "op...
https://github.com/hellerbarde/stapler/blob/1cabc85521e2badfc1e0d690086e286e701c2d9e/staplelib/iohelper.py#L30-L43
ChunyuanLI/Optimus
f63f4a7ca10aea022978500a37d72dd53a37a576
code/examples/run_bertology.py
python
compute_heads_importance
(args, model, eval_dataloader, compute_entropy=True, compute_importance=True, head_mask=None)
return attn_entropy, head_importance, preds, labels
This method shows how to compute: - head attention entropy - head importance scores according to http://arxiv.org/abs/1905.10650
This method shows how to compute: - head attention entropy - head importance scores according to http://arxiv.org/abs/1905.10650
[ "This", "method", "shows", "how", "to", "compute", ":", "-", "head", "attention", "entropy", "-", "head", "importance", "scores", "according", "to", "http", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1905", ".", "10650" ]
def compute_heads_importance(args, model, eval_dataloader, compute_entropy=True, compute_importance=True, head_mask=None): """ This method shows how to compute: - head attention entropy - head importance scores according to http://arxiv.org/abs/1905.10650 """ # Prepare our tensors n_layers, n_heads = model.bert.config.num_hidden_layers, model.bert.config.num_attention_heads head_importance = torch.zeros(n_layers, n_heads).to(args.device) attn_entropy = torch.zeros(n_layers, n_heads).to(args.device) if head_mask is None: head_mask = torch.ones(n_layers, n_heads).to(args.device) head_mask.requires_grad_(requires_grad=True) preds = None labels = None tot_tokens = 0.0 for step, batch in enumerate(tqdm(eval_dataloader, desc="Iteration", disable=args.local_rank not in [-1, 0])): batch = tuple(t.to(args.device) for t in batch) input_ids, input_mask, segment_ids, label_ids = batch # Do a forward pass (not with torch.no_grad() since we need gradients for importance score - see below) outputs = model(input_ids, token_type_ids=segment_ids, attention_mask=input_mask, labels=label_ids, head_mask=head_mask) loss, logits, all_attentions = outputs[0], outputs[1], outputs[-1] # Loss and logits are the first, attention the last loss.backward() # Backpropagate to populate the gradients in the head mask if compute_entropy: for layer, attn in enumerate(all_attentions): masked_entropy = entropy(attn.detach()) * input_mask.float().unsqueeze(1) attn_entropy[layer] += masked_entropy.sum(-1).sum(0).detach() if compute_importance: head_importance += head_mask.grad.abs().detach() # Also store our logits/labels if we want to compute metrics afterwards if preds is None: preds = logits.detach().cpu().numpy() labels = label_ids.detach().cpu().numpy() else: preds = np.append(preds, logits.detach().cpu().numpy(), axis=0) labels = np.append(labels, label_ids.detach().cpu().numpy(), axis=0) tot_tokens += input_mask.float().detach().sum().data # Normalize attn_entropy /= tot_tokens head_importance /= tot_tokens # Layerwise importance normalization if not args.dont_normalize_importance_by_layer: exponent = 2 norm_by_layer = torch.pow(torch.pow(head_importance, exponent).sum(-1), 1/exponent) head_importance /= norm_by_layer.unsqueeze(-1) + 1e-20 if not args.dont_normalize_global_importance: head_importance = (head_importance - head_importance.min()) / (head_importance.max() - head_importance.min()) # Print/save matrices np.save(os.path.join(args.output_dir, 'attn_entropy.npy'), attn_entropy.detach().cpu().numpy()) np.save(os.path.join(args.output_dir, 'head_importance.npy'), head_importance.detach().cpu().numpy()) logger.info("Attention entropies") print_2d_tensor(attn_entropy) logger.info("Head importance scores") print_2d_tensor(head_importance) logger.info("Head ranked by importance scores") head_ranks = torch.zeros(head_importance.numel(), dtype=torch.long, device=args.device) head_ranks[head_importance.view(-1).sort(descending=True)[1]] = torch.arange(head_importance.numel(), device=args.device) head_ranks = head_ranks.view_as(head_importance) print_2d_tensor(head_ranks) return attn_entropy, head_importance, preds, labels
[ "def", "compute_heads_importance", "(", "args", ",", "model", ",", "eval_dataloader", ",", "compute_entropy", "=", "True", ",", "compute_importance", "=", "True", ",", "head_mask", "=", "None", ")", ":", "# Prepare our tensors", "n_layers", ",", "n_heads", "=", ...
https://github.com/ChunyuanLI/Optimus/blob/f63f4a7ca10aea022978500a37d72dd53a37a576/code/examples/run_bertology.py#L65-L135
ProjectQ-Framework/ProjectQ
0d32c1610ba4e9aefd7f19eb52dadb4fbe5f9005
projectq/backends/_awsbraket/_awsbraket_boto3_client.py
python
AWSBraket.can_run_experiment
(self, info, device)
return nb_qubit_needed <= nb_qubit_max, nb_qubit_max, nb_qubit_needed
Check if the device is big enough to run the code. Args: info (dict): dictionary sent by the backend containing the code to run device (str): name of the device to use Returns: (tuple): (bool) True if device is big enough, False otherwise (int) maximum number of qubit available on the device (int) number of qubit needed for the circuit
Check if the device is big enough to run the code.
[ "Check", "if", "the", "device", "is", "big", "enough", "to", "run", "the", "code", "." ]
def can_run_experiment(self, info, device): """ Check if the device is big enough to run the code. Args: info (dict): dictionary sent by the backend containing the code to run device (str): name of the device to use Returns: (tuple): (bool) True if device is big enough, False otherwise (int) maximum number of qubit available on the device (int) number of qubit needed for the circuit """ nb_qubit_max = self.backends[device]['nq'] nb_qubit_needed = info['nq'] return nb_qubit_needed <= nb_qubit_max, nb_qubit_max, nb_qubit_needed
[ "def", "can_run_experiment", "(", "self", ",", "info", ",", "device", ")", ":", "nb_qubit_max", "=", "self", ".", "backends", "[", "device", "]", "[", "'nq'", "]", "nb_qubit_needed", "=", "info", "[", "'nq'", "]", "return", "nb_qubit_needed", "<=", "nb_qub...
https://github.com/ProjectQ-Framework/ProjectQ/blob/0d32c1610ba4e9aefd7f19eb52dadb4fbe5f9005/projectq/backends/_awsbraket/_awsbraket_boto3_client.py#L155-L170
readthedocs/readthedocs.org
0852d7c10d725d954d3e9a93513171baa1116d9f
readthedocs/analytics/utils.py
python
anonymize_ip_address
(ip_address)
return anonymized_ip.compressed
Anonymizes an IP address by zeroing the last 2 bytes.
Anonymizes an IP address by zeroing the last 2 bytes.
[ "Anonymizes", "an", "IP", "address", "by", "zeroing", "the", "last", "2", "bytes", "." ]
def anonymize_ip_address(ip_address): """Anonymizes an IP address by zeroing the last 2 bytes.""" # Used to anonymize an IP by zero-ing out the last 2 bytes ip_mask = int('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000', 16) try: ip_obj = ipaddress.ip_address(force_str(ip_address)) except ValueError: return None anonymized_ip = ipaddress.ip_address(int(ip_obj) & ip_mask) return anonymized_ip.compressed
[ "def", "anonymize_ip_address", "(", "ip_address", ")", ":", "# Used to anonymize an IP by zero-ing out the last 2 bytes", "ip_mask", "=", "int", "(", "'0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000'", ",", "16", ")", "try", ":", "ip_obj", "=", "ipaddress", ".", "ip_address", "(", ...
https://github.com/readthedocs/readthedocs.org/blob/0852d7c10d725d954d3e9a93513171baa1116d9f/readthedocs/analytics/utils.py#L44-L55
googledatalab/pydatalab
1c86e26a0d24e3bc8097895ddeab4d0607be4c40
google/datalab/bigquery/_schema.py
python
SchemaField.__getitem__
(self, item)
[]
def __getitem__(self, item): # TODO(gram): Currently we need this for a Schema object to work with the Parser object. # Eventually if we change Parser to only work with Schema (and not also with the # schema dictionaries in query results) we can remove this. if item == 'name': return self.name if item == 'type': return self.type if item == 'mode': return self.mode if item == 'description': return self.description
[ "def", "__getitem__", "(", "self", ",", "item", ")", ":", "# TODO(gram): Currently we need this for a Schema object to work with the Parser object.", "# Eventually if we change Parser to only work with Schema (and not also with the", "# schema dictionaries in query results) we can remove this.",...
https://github.com/googledatalab/pydatalab/blob/1c86e26a0d24e3bc8097895ddeab4d0607be4c40/google/datalab/bigquery/_schema.py#L62-L74
microsoft/NimbusML
f6be39ce9359786976429bab0ccd837e849b4ba5
src/python/nimbusml/datasets/datasets.py
python
DataSet.__setattr__
(self, name, value)
Creation of a new column. We add it to the members of the class.
Creation of a new column. We add it to the members of the class.
[ "Creation", "of", "a", "new", "column", ".", "We", "add", "it", "to", "the", "members", "of", "the", "class", "." ]
def __setattr__(self, name, value): """ Creation of a new column. We add it to the members of the class. """ if isinstance(value, (list, pandas.Series, numpy.ndarray)): if isinstance(value, pandas.Series): if value.dtype == bool: value = list(1.0 if x else 0.0 for x in value) elif value.dtype in (numpy.float32, float): pass else: raise TypeError( "Unexpexted type for values {0}".format( value.dtype)) else: raise TypeError( "You need to convert your container into a " "pandas.Series") self._new_columns[name] = value else: raise TypeError( "Unexpected issue with name={0} value type={1}".format( name, type(value)))
[ "def", "__setattr__", "(", "self", ",", "name", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "list", ",", "pandas", ".", "Series", ",", "numpy", ".", "ndarray", ")", ")", ":", "if", "isinstance", "(", "value", ",", "pandas", ...
https://github.com/microsoft/NimbusML/blob/f6be39ce9359786976429bab0ccd837e849b4ba5/src/python/nimbusml/datasets/datasets.py#L46-L69
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/tsf/v20180326/models.py
python
DescribePublicConfigsRequest.__init__
(self)
r""" :param ConfigId: 配置项ID,不传入时查询全量,高优先级 :type ConfigId: str :param Offset: 偏移量,默认为0 :type Offset: int :param Limit: 每页条数,默认为20 :type Limit: int :param ConfigIdList: 配置项ID列表,不传入时查询全量,低优先级 :type ConfigIdList: list of str :param ConfigName: 配置项名称,精确查询,不传入时查询全量 :type ConfigName: str :param ConfigVersion: 配置项版本,精确查询,不传入时查询全量 :type ConfigVersion: str
r""" :param ConfigId: 配置项ID,不传入时查询全量,高优先级 :type ConfigId: str :param Offset: 偏移量,默认为0 :type Offset: int :param Limit: 每页条数,默认为20 :type Limit: int :param ConfigIdList: 配置项ID列表,不传入时查询全量,低优先级 :type ConfigIdList: list of str :param ConfigName: 配置项名称,精确查询,不传入时查询全量 :type ConfigName: str :param ConfigVersion: 配置项版本,精确查询,不传入时查询全量 :type ConfigVersion: str
[ "r", ":", "param", "ConfigId", ":", "配置项ID,不传入时查询全量,高优先级", ":", "type", "ConfigId", ":", "str", ":", "param", "Offset", ":", "偏移量,默认为0", ":", "type", "Offset", ":", "int", ":", "param", "Limit", ":", "每页条数,默认为20", ":", "type", "Limit", ":", "int", ":", ...
def __init__(self): r""" :param ConfigId: 配置项ID,不传入时查询全量,高优先级 :type ConfigId: str :param Offset: 偏移量,默认为0 :type Offset: int :param Limit: 每页条数,默认为20 :type Limit: int :param ConfigIdList: 配置项ID列表,不传入时查询全量,低优先级 :type ConfigIdList: list of str :param ConfigName: 配置项名称,精确查询,不传入时查询全量 :type ConfigName: str :param ConfigVersion: 配置项版本,精确查询,不传入时查询全量 :type ConfigVersion: str """ self.ConfigId = None self.Offset = None self.Limit = None self.ConfigIdList = None self.ConfigName = None self.ConfigVersion = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "ConfigId", "=", "None", "self", ".", "Offset", "=", "None", "self", ".", "Limit", "=", "None", "self", ".", "ConfigIdList", "=", "None", "self", ".", "ConfigName", "=", "None", "self", ".", "Con...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/tsf/v20180326/models.py#L8419-L8439
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/apps/case_importer/views.py
python
_bulk_case_upload_api
(request, domain)
return json_response({"code": 200, "message": "success", "status_url": status_url})
[]
def _bulk_case_upload_api(request, domain): try: upload_file = request.FILES["file"] case_type = request.POST["case_type"] if not upload_file or not case_type: raise Exception except Exception: raise ImporterError("Invalid POST request. " "Both 'file' and 'case_type' are required") search_field = request.POST.get('search_field', 'case_id') create_new_cases = request.POST.get('create_new_cases') == 'on' if search_field == 'case_id': default_search_column = 'case_id' elif search_field == 'external_id': default_search_column = 'external_id' else: raise ImporterError("Illegal value for search_field: %s" % search_field) search_column = request.POST.get('search_column', default_search_column) name_column = request.POST.get('name_column', 'name') upload_comment = request.POST.get('comment') case_upload, context = _process_file_and_get_upload(upload_file, request, domain) case_upload.check_file() with case_upload.get_spreadsheet() as spreadsheet: columns = spreadsheet.get_header_columns() excel_fields = columns # hide search column and matching case fields from the update list if search_column in excel_fields: excel_fields.remove(search_column) custom_fields = [] case_fields = [] #Create the field arrays for the importer in the same format #as the "Step 2" Web UI from the manual process for f in excel_fields: if f == name_column: custom_fields.append("") case_fields.append("name") else: custom_fields.append(f) case_fields.append("") config = importer_util.ImporterConfig( couch_user_id=request.couch_user._id, excel_fields=excel_fields, case_fields=case_fields, custom_fields=custom_fields, search_column=search_column, case_type=case_type, search_field=search_field, create_new_cases=create_new_cases) case_upload.trigger_upload(domain, config, comment=upload_comment) upload_id = case_upload.upload_id status_url = absolute_reverse('case_importer_upload_status', args=(domain, upload_id)) return json_response({"code": 200, "message": "success", "status_url": status_url})
[ "def", "_bulk_case_upload_api", "(", "request", ",", "domain", ")", ":", "try", ":", "upload_file", "=", "request", ".", "FILES", "[", "\"file\"", "]", "case_type", "=", "request", ".", "POST", "[", "\"case_type\"", "]", "if", "not", "upload_file", "or", "...
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/case_importer/views.py#L305-L370
lorentzenman/sheepl
a999bcfc5e73d8c173b76a6082cbe65b6618984e
tasks/shell/CommandShell.py
python
CommandShellAutoITBlock.text_typing_block
(self)
return textwrap.indent(typing_text, self.indent_space)
Takes the Typing Text Input
Takes the Typing Text Input
[ "Takes", "the", "Typing", "Text", "Input" ]
def text_typing_block(self): """ Takes the Typing Text Input """ # Grabas the command list and goes through it # This uses the textwrap.indent to add in the indentation typing_text = '\n' for command in self.commands: # these are individual send commands so don't need to be wrapped in a block typing_text += ('Send("' + command + '{ENTER}")\n') command_delay = str(random.randint(2000, 20000)) typing_text += ("sleep(" + command_delay + ")\n") # add in exit typing_text += "Send('exit{ENTER}')\n" typing_text += "; Reset Focus\n" typing_text += 'SendKeepActive("")' return textwrap.indent(typing_text, self.indent_space)
[ "def", "text_typing_block", "(", "self", ")", ":", "# Grabas the command list and goes through it", "# This uses the textwrap.indent to add in the indentation", "typing_text", "=", "'\\n'", "for", "command", "in", "self", ".", "commands", ":", "# these are individual send command...
https://github.com/lorentzenman/sheepl/blob/a999bcfc5e73d8c173b76a6082cbe65b6618984e/tasks/shell/CommandShell.py#L369-L391
balanced/status.balancedpayments.com
e51a371079a8fa215732be3cfa57497a9d113d35
venv/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/util.py
python
egg_link_path
(dist)
Return the path for the .egg-link file if it exists, otherwise, None. There's 3 scenarios: 1) not in a virtualenv try to find in site.USER_SITE, then site_packages 2) in a no-global virtualenv try to find in site_packages 3) in a yes-global virtualenv try to find in site_packages, then site.USER_SITE (don't look in global location) For #1 and #3, there could be odd cases, where there's an egg-link in 2 locations. This method will just return the first one found.
Return the path for the .egg-link file if it exists, otherwise, None.
[ "Return", "the", "path", "for", "the", ".", "egg", "-", "link", "file", "if", "it", "exists", "otherwise", "None", "." ]
def egg_link_path(dist): """ Return the path for the .egg-link file if it exists, otherwise, None. There's 3 scenarios: 1) not in a virtualenv try to find in site.USER_SITE, then site_packages 2) in a no-global virtualenv try to find in site_packages 3) in a yes-global virtualenv try to find in site_packages, then site.USER_SITE (don't look in global location) For #1 and #3, there could be odd cases, where there's an egg-link in 2 locations. This method will just return the first one found. """ sites = [] if running_under_virtualenv(): if virtualenv_no_global(): sites.append(site_packages) else: sites.append(site_packages) if user_site: sites.append(user_site) else: if user_site: sites.append(user_site) sites.append(site_packages) for site in sites: egglink = os.path.join(site, dist.project_name) + '.egg-link' if os.path.isfile(egglink): return egglink
[ "def", "egg_link_path", "(", "dist", ")", ":", "sites", "=", "[", "]", "if", "running_under_virtualenv", "(", ")", ":", "if", "virtualenv_no_global", "(", ")", ":", "sites", ".", "append", "(", "site_packages", ")", "else", ":", "sites", ".", "append", "...
https://github.com/balanced/status.balancedpayments.com/blob/e51a371079a8fa215732be3cfa57497a9d113d35/venv/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/util.py#L391-L422
SanPen/GridCal
d3f4566d2d72c11c7e910c9d162538ef0e60df31
src/GridCal/Engine/Devices/branch.py
python
Branch.apply_tap_changer
(self, tap_changer: TapChanger)
Apply a new tap changer Argument: **tap_changer** (:class:`GridCal.Engine.Devices.branch.TapChanger`): Tap changer object
Apply a new tap changer
[ "Apply", "a", "new", "tap", "changer" ]
def apply_tap_changer(self, tap_changer: TapChanger): """ Apply a new tap changer Argument: **tap_changer** (:class:`GridCal.Engine.Devices.branch.TapChanger`): Tap changer object """ self.tap_changer = tap_changer if self.tap_module != 0: self.tap_changer.set_tap(self.tap_module) else: self.tap_module = self.tap_changer.get_tap()
[ "def", "apply_tap_changer", "(", "self", ",", "tap_changer", ":", "TapChanger", ")", ":", "self", ".", "tap_changer", "=", "tap_changer", "if", "self", ".", "tap_module", "!=", "0", ":", "self", ".", "tap_changer", ".", "set_tap", "(", "self", ".", "tap_mo...
https://github.com/SanPen/GridCal/blob/d3f4566d2d72c11c7e910c9d162538ef0e60df31/src/GridCal/Engine/Devices/branch.py#L525-L539
colinsongf/keyword_spotting
6f93c5d6356932dc34d9956100e869a4f430a386
normalize.py
python
run_command
(cmd, raw=True)
Generic function to run a command. Set raw to pass the actual command. Set dry to just print and don't actually run. Returns stdout + stderr.
Generic function to run a command. Set raw to pass the actual command. Set dry to just print and don't actually run.
[ "Generic", "function", "to", "run", "a", "command", ".", "Set", "raw", "to", "pass", "the", "actual", "command", ".", "Set", "dry", "to", "just", "print", "and", "don", "t", "actually", "run", "." ]
def run_command(cmd, raw=True): logger.info(cmd) """ Generic function to run a command. Set raw to pass the actual command. Set dry to just print and don't actually run. Returns stdout + stderr. """ logger.debug("[command] {0}".format(cmd)) if raw: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True) else: p = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) stdout, stderr = p.communicate() if p.returncode == 0: return (stdout + stderr) else: logger.error("error running command: {}".format(cmd)) logger.error(str(stderr)) raise SystemExit("Failed running a command")
[ "def", "run_command", "(", "cmd", ",", "raw", "=", "True", ")", ":", "logger", ".", "info", "(", "cmd", ")", "logger", ".", "debug", "(", "\"[command] {0}\"", ".", "format", "(", "cmd", ")", ")", "if", "raw", ":", "p", "=", "subprocess", ".", "Pope...
https://github.com/colinsongf/keyword_spotting/blob/6f93c5d6356932dc34d9956100e869a4f430a386/normalize.py#L132-L158
OpenZWave/python-openzwave
8be4c070294348f3fc268bc1d7ad2c535f352f5a
src-api/openzwave/command.py
python
ZWaveNodeSwitch.get_rgbbulbs
(self)
return self.get_values(class_id=0x33, genre='User', \ type='String', readonly=False, writeonly=False)
The command 0x33 (COMMAND_CLASS_COLOR) of this node. Retrieve the list of values to consider as RGBW bulbs. Filter rules are : command_class = 0x33 genre = "User" type = "String" readonly = False writeonly = False :return: The list of dimmers on this node :rtype: dict()
The command 0x33 (COMMAND_CLASS_COLOR) of this node. Retrieve the list of values to consider as RGBW bulbs. Filter rules are :
[ "The", "command", "0x33", "(", "COMMAND_CLASS_COLOR", ")", "of", "this", "node", ".", "Retrieve", "the", "list", "of", "values", "to", "consider", "as", "RGBW", "bulbs", ".", "Filter", "rules", "are", ":" ]
def get_rgbbulbs(self): """ The command 0x33 (COMMAND_CLASS_COLOR) of this node. Retrieve the list of values to consider as RGBW bulbs. Filter rules are : command_class = 0x33 genre = "User" type = "String" readonly = False writeonly = False :return: The list of dimmers on this node :rtype: dict() """ return self.get_values(class_id=0x33, genre='User', \ type='String', readonly=False, writeonly=False)
[ "def", "get_rgbbulbs", "(", "self", ")", ":", "return", "self", ".", "get_values", "(", "class_id", "=", "0x33", ",", "genre", "=", "'User'", ",", "type", "=", "'String'", ",", "readonly", "=", "False", ",", "writeonly", "=", "False", ")" ]
https://github.com/OpenZWave/python-openzwave/blob/8be4c070294348f3fc268bc1d7ad2c535f352f5a/src-api/openzwave/command.py#L634-L651
corpnewt/ProperTree
da07e88a95eadc7fbeb5c3739f4e2c293eed764e
Scripts/plist.py
python
_BinaryPlistParser._get_size
(self, tokenL)
return tokenL
return the size of the next object.
return the size of the next object.
[ "return", "the", "size", "of", "the", "next", "object", "." ]
def _get_size(self, tokenL): """ return the size of the next object.""" if tokenL == 0xF: m = ord(self._fp.read(1)[0]) & 0x3 s = 1 << m f = '>' + _BINARY_FORMAT[s] return struct.unpack(f, self._fp.read(s))[0] return tokenL
[ "def", "_get_size", "(", "self", ",", "tokenL", ")", ":", "if", "tokenL", "==", "0xF", ":", "m", "=", "ord", "(", "self", ".", "_fp", ".", "read", "(", "1", ")", "[", "0", "]", ")", "&", "0x3", "s", "=", "1", "<<", "m", "f", "=", "'>'", "...
https://github.com/corpnewt/ProperTree/blob/da07e88a95eadc7fbeb5c3739f4e2c293eed764e/Scripts/plist.py#L242-L250
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework
cb692f527e4e819b6c228187c5702d990a180043
external/Scripting Engine/Xenotix Python Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/pickletools.py
python
dis
(pickle, out=None, memo=None, indentlevel=4)
Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which the disassembly is printed. It defaults to sys.stdout. Optional arg 'memo' is a Python dict, used as the pickle's memo. It may be mutated by dis(), if the pickle contains PUT or BINPUT opcodes. Passing the same memo object to another dis() call then allows disassembly to proceed across multiple pickles that were all created by the same pickler with the same memo. Ordinarily you don't need to worry about this. Optional arg indentlevel is the number of blanks by which to indent a new MARK level. It defaults to 4. In addition to printing the disassembly, some sanity checks are made: + All embedded opcode arguments "make sense". + Explicit and implicit pop operations have enough items on the stack. + When an opcode implicitly refers to a markobject, a markobject is actually on the stack. + A memo entry isn't referenced before it's defined. + The markobject isn't stored in the memo. + A memo entry isn't redefined.
Produce a symbolic disassembly of a pickle.
[ "Produce", "a", "symbolic", "disassembly", "of", "a", "pickle", "." ]
def dis(pickle, out=None, memo=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which the disassembly is printed. It defaults to sys.stdout. Optional arg 'memo' is a Python dict, used as the pickle's memo. It may be mutated by dis(), if the pickle contains PUT or BINPUT opcodes. Passing the same memo object to another dis() call then allows disassembly to proceed across multiple pickles that were all created by the same pickler with the same memo. Ordinarily you don't need to worry about this. Optional arg indentlevel is the number of blanks by which to indent a new MARK level. It defaults to 4. In addition to printing the disassembly, some sanity checks are made: + All embedded opcode arguments "make sense". + Explicit and implicit pop operations have enough items on the stack. + When an opcode implicitly refers to a markobject, a markobject is actually on the stack. + A memo entry isn't referenced before it's defined. + The markobject isn't stored in the memo. + A memo entry isn't redefined. """ # Most of the hair here is for sanity checks, but most of it is needed # anyway to detect when a protocol 0 POP takes a MARK off the stack # (which in turn is needed to indent MARK blocks correctly). stack = [] # crude emulation of unpickler stack if memo is None: memo = {} # crude emulation of unpicker memo maxproto = -1 # max protocol number seen markstack = [] # bytecode positions of MARK opcodes indentchunk = ' ' * indentlevel errormsg = None for opcode, arg, pos in genops(pickle): if pos is not None: print >> out, "%5d:" % pos, line = "%-4s %s%s" % (repr(opcode.code)[1:-1], indentchunk * len(markstack), opcode.name) maxproto = max(maxproto, opcode.proto) before = opcode.stack_before # don't mutate after = opcode.stack_after # don't mutate numtopop = len(before) # See whether a MARK should be popped. markmsg = None if markobject in before or (opcode.name == "POP" and stack and stack[-1] is markobject): assert markobject not in after if __debug__: if markobject in before: assert before[-1] is stackslice if markstack: markpos = markstack.pop() if markpos is None: markmsg = "(MARK at unknown opcode offset)" else: markmsg = "(MARK at %d)" % markpos # Pop everything at and after the topmost markobject. while stack[-1] is not markobject: stack.pop() stack.pop() # Stop later code from popping too much. try: numtopop = before.index(markobject) except ValueError: assert opcode.name == "POP" numtopop = 0 else: errormsg = markmsg = "no MARK exists on stack" # Check for correct memo usage. if opcode.name in ("PUT", "BINPUT", "LONG_BINPUT"): assert arg is not None if arg in memo: errormsg = "memo key %r already defined" % arg elif not stack: errormsg = "stack is empty -- can't store into memo" elif stack[-1] is markobject: errormsg = "can't store markobject in the memo" else: memo[arg] = stack[-1] elif opcode.name in ("GET", "BINGET", "LONG_BINGET"): if arg in memo: assert len(after) == 1 after = [memo[arg]] # for better stack emulation else: errormsg = "memo key %r has never been stored into" % arg if arg is not None or markmsg: # make a mild effort to align arguments line += ' ' * (10 - len(opcode.name)) if arg is not None: line += ' ' + repr(arg) if markmsg: line += ' ' + markmsg print >> out, line if errormsg: # Note that we delayed complaining until the offending opcode # was printed. raise ValueError(errormsg) # Emulate the stack effects. if len(stack) < numtopop: raise ValueError("tries to pop %d items from stack with " "only %d items" % (numtopop, len(stack))) if numtopop: del stack[-numtopop:] if markobject in after: assert markobject not in before markstack.append(pos) stack.extend(after) print >> out, "highest protocol among opcodes =", maxproto if stack: raise ValueError("stack not empty after STOP: %r" % stack)
[ "def", "dis", "(", "pickle", ",", "out", "=", "None", ",", "memo", "=", "None", ",", "indentlevel", "=", "4", ")", ":", "# Most of the hair here is for sanity checks, but most of it is needed", "# anyway to detect when a protocol 0 POP takes a MARK off the stack", "# (which i...
https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/Xenotix Python Scripting Engine/packages/IronPython.StdLib.2.7.4/content/Lib/pickletools.py#L1892-L2026
nipy/heudiconv
80a65385ef867124611d037fceac27d27e30f480
heudiconv/main.py
python
setup_exceptionhook
()
Overloads default sys.excepthook with our exceptionhook handler. If interactive, our exceptionhook handler will invoke pdb.post_mortem; if not interactive, then invokes default handler.
Overloads default sys.excepthook with our exceptionhook handler.
[ "Overloads", "default", "sys", ".", "excepthook", "with", "our", "exceptionhook", "handler", "." ]
def setup_exceptionhook(): """ Overloads default sys.excepthook with our exceptionhook handler. If interactive, our exceptionhook handler will invoke pdb.post_mortem; if not interactive, then invokes default handler. """ def _pdb_excepthook(type, value, tb): if is_interactive(): import traceback import pdb traceback.print_exception(type, value, tb) # print() pdb.post_mortem(tb) else: lgr.warning( "We cannot setup exception hook since not in interactive mode") sys.excepthook = _pdb_excepthook
[ "def", "setup_exceptionhook", "(", ")", ":", "def", "_pdb_excepthook", "(", "type", ",", "value", ",", "tb", ")", ":", "if", "is_interactive", "(", ")", ":", "import", "traceback", "import", "pdb", "traceback", ".", "print_exception", "(", "type", ",", "va...
https://github.com/nipy/heudiconv/blob/80a65385ef867124611d037fceac27d27e30f480/heudiconv/main.py#L25-L43
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/xml/etree/ElementPath.py
python
xpath_tokenizer
(pattern, namespaces=None)
[]
def xpath_tokenizer(pattern, namespaces=None): default_namespace = namespaces.get('') if namespaces else None parsing_attribute = False for token in xpath_tokenizer_re.findall(pattern): ttype, tag = token if tag and tag[0] != "{": if ":" in tag: prefix, uri = tag.split(":", 1) try: if not namespaces: raise KeyError yield ttype, "{%s}%s" % (namespaces[prefix], uri) except KeyError: raise SyntaxError("prefix %r not found in prefix map" % prefix) from None elif default_namespace and not parsing_attribute: yield ttype, "{%s}%s" % (default_namespace, tag) else: yield token parsing_attribute = False else: yield token parsing_attribute = ttype == '@'
[ "def", "xpath_tokenizer", "(", "pattern", ",", "namespaces", "=", "None", ")", ":", "default_namespace", "=", "namespaces", ".", "get", "(", "''", ")", "if", "namespaces", "else", "None", "parsing_attribute", "=", "False", "for", "token", "in", "xpath_tokenize...
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/xml/etree/ElementPath.py#L74-L95
fluentpython/notebooks
0f6e1e8d1686743dacd9281df7c5b5921812010a
attic/metaprog/spreadsheet.py
python
Spreadsheet.__setitem__
(self, key, formula)
[]
def __setitem__(self, key, formula): self._cells[key] = formula
[ "def", "__setitem__", "(", "self", ",", "key", ",", "formula", ")", ":", "self", ".", "_cells", "[", "key", "]", "=", "formula" ]
https://github.com/fluentpython/notebooks/blob/0f6e1e8d1686743dacd9281df7c5b5921812010a/attic/metaprog/spreadsheet.py#L37-L38
bugcrowd/HUNT
ed3e1adee724bf6c98750f377f6c40cd656c82d3
Burp/lib/methodology_view.py
python
View.set_checklist
(self, file_name)
[]
def set_checklist(self, file_name): self.data.set_checklist(file_name) self.checklist = self.data.get_checklist()
[ "def", "set_checklist", "(", "self", ",", "file_name", ")", ":", "self", ".", "data", ".", "set_checklist", "(", "file_name", ")", "self", ".", "checklist", "=", "self", ".", "data", ".", "get_checklist", "(", ")" ]
https://github.com/bugcrowd/HUNT/blob/ed3e1adee724bf6c98750f377f6c40cd656c82d3/Burp/lib/methodology_view.py#L37-L39
intel/virtual-storage-manager
00706ab9701acbd0d5e04b19cc80c6b66a2973b8
source/vsm/vsm/api/urlmap.py
python
URLMap._accept_strategy
(self, host, port, environ, supported_content_types)
return mime_type, app
Check Accept header for best matching MIME type and API version.
Check Accept header for best matching MIME type and API version.
[ "Check", "Accept", "header", "for", "best", "matching", "MIME", "type", "and", "API", "version", "." ]
def _accept_strategy(self, host, port, environ, supported_content_types): """Check Accept header for best matching MIME type and API version.""" accept = Accept(environ.get('HTTP_ACCEPT', '')) app = None # Find the best match in the Accept header mime_type, params = accept.best_match(supported_content_types) if 'version' in params: app, app_url = self._match(host, port, '/v' + params['version']) if app: app = self._set_script_name(app, app_url) return mime_type, app
[ "def", "_accept_strategy", "(", "self", ",", "host", ",", "port", ",", "environ", ",", "supported_content_types", ")", ":", "accept", "=", "Accept", "(", "environ", ".", "get", "(", "'HTTP_ACCEPT'", ",", "''", ")", ")", "app", "=", "None", "# Find the best...
https://github.com/intel/virtual-storage-manager/blob/00706ab9701acbd0d5e04b19cc80c6b66a2973b8/source/vsm/vsm/api/urlmap.py#L219-L232
maas/maas
db2f89970c640758a51247c59bf1ec6f60cf4ab5
src/maasserver/ntp.py
python
get_peers_for
(node: Node)
Return NTP peers to use for the given node. For all node types other than region or region+rack controllers, this returns the empty set.
Return NTP peers to use for the given node.
[ "Return", "NTP", "peers", "to", "use", "for", "the", "given", "node", "." ]
def get_peers_for(node: Node) -> FrozenSet[str]: """Return NTP peers to use for the given node. For all node types other than region or region+rack controllers, this returns the empty set. """ if node is None: return frozenset() elif node.is_region_controller: peer_regions = RegionController.objects.exclude(id=node.id) peer_addresses_map = get_routable_address_map(peer_regions, node) peer_addresses = reduce_routable_address_map(peer_addresses_map) return frozenset(map(str, peer_addresses)) else: return frozenset()
[ "def", "get_peers_for", "(", "node", ":", "Node", ")", "->", "FrozenSet", "[", "str", "]", ":", "if", "node", "is", "None", ":", "return", "frozenset", "(", ")", "elif", "node", ".", "is_region_controller", ":", "peer_regions", "=", "RegionController", "."...
https://github.com/maas/maas/blob/db2f89970c640758a51247c59bf1ec6f60cf4ab5/src/maasserver/ntp.py#L48-L62
kelvinguu/neural-editor
3390140cb727b8c44092398fa68ceb0231b28e8b
third-party/gtd/gtd/turk.py
python
ExternalQuestionTask.url
(self)
return self._url
The task URL, not including parameters appended to the end (str).
The task URL, not including parameters appended to the end (str).
[ "The", "task", "URL", "not", "including", "parameters", "appended", "to", "the", "end", "(", "str", ")", "." ]
def url(self): """The task URL, not including parameters appended to the end (str).""" return self._url
[ "def", "url", "(", "self", ")", ":", "return", "self", ".", "_url" ]
https://github.com/kelvinguu/neural-editor/blob/3390140cb727b8c44092398fa68ceb0231b28e8b/third-party/gtd/gtd/turk.py#L244-L246
igraph/python-igraph
e9f83e8af08f24ea025596e745917197d8b44d94
src/igraph/app/shell.py
python
Shell.get_status_handler
(self)
return None
Returns the status handler (if exists) or None (if not).
Returns the status handler (if exists) or None (if not).
[ "Returns", "the", "status", "handler", "(", "if", "exists", ")", "or", "None", "(", "if", "not", ")", "." ]
def get_status_handler(self): """Returns the status handler (if exists) or None (if not).""" if self.supports_status_messages(): return self._status_handler return None
[ "def", "get_status_handler", "(", "self", ")", ":", "if", "self", ".", "supports_status_messages", "(", ")", ":", "return", "self", ".", "_status_handler", "return", "None" ]
https://github.com/igraph/python-igraph/blob/e9f83e8af08f24ea025596e745917197d8b44d94/src/igraph/app/shell.py#L317-L321
EventGhost/EventGhost
177be516849e74970d2e13cda82244be09f277ce
plugins/IrfanView/__init__.py
python
IrfanView.GetIrfanViewPath
(self)
return IrfanViewPath
Get the path of IrfanView's install-dir through querying the Windows registry.
Get the path of IrfanView's install-dir through querying the Windows registry.
[ "Get", "the", "path", "of", "IrfanView", "s", "install", "-", "dir", "through", "querying", "the", "Windows", "registry", "." ]
def GetIrfanViewPath(self): """ Get the path of IrfanView's install-dir through querying the Windows registry. """ try: iv_reg = _winreg.OpenKey( _winreg.HKEY_CLASSES_ROOT, "\\Applications\\i_view32.exe\\shell\\open\\command" ) IrfanViewPath =_winreg.QueryValue(iv_reg, None) _winreg.CloseKey(iv_reg) IrfanViewPath=IrfanViewPath[:-5] IrfanViewPath=IrfanViewPath[1:-1] except WindowsError: IrfanViewPath = None return IrfanViewPath
[ "def", "GetIrfanViewPath", "(", "self", ")", ":", "try", ":", "iv_reg", "=", "_winreg", ".", "OpenKey", "(", "_winreg", ".", "HKEY_CLASSES_ROOT", ",", "\"\\\\Applications\\\\i_view32.exe\\\\shell\\\\open\\\\command\"", ")", "IrfanViewPath", "=", "_winreg", ".", "Query...
https://github.com/EventGhost/EventGhost/blob/177be516849e74970d2e13cda82244be09f277ce/plugins/IrfanView/__init__.py#L318-L334
scipy/scipy
e0a749f01e79046642ccfdc419edbf9e7ca141ad
scipy/sparse/linalg/_norm.py
python
norm
(x, ord=None, axis=None)
Norm of a sparse matrix This function is able to return one of seven different matrix norms, depending on the value of the ``ord`` parameter. Parameters ---------- x : a sparse matrix Input sparse matrix. ord : {non-zero int, inf, -inf, 'fro'}, optional Order of the norm (see table under ``Notes``). inf means numpy's `inf` object. axis : {int, 2-tuple of ints, None}, optional If `axis` is an integer, it specifies the axis of `x` along which to compute the vector norms. If `axis` is a 2-tuple, it specifies the axes that hold 2-D matrices, and the matrix norms of these matrices are computed. If `axis` is None then either a vector norm (when `x` is 1-D) or a matrix norm (when `x` is 2-D) is returned. Returns ------- n : float or ndarray Notes ----- Some of the ord are not implemented because some associated functions like, _multi_svd_norm, are not yet available for sparse matrix. This docstring is modified based on numpy.linalg.norm. https://github.com/numpy/numpy/blob/main/numpy/linalg/linalg.py The following norms can be calculated: ===== ============================ ord norm for sparse matrices ===== ============================ None Frobenius norm 'fro' Frobenius norm inf max(sum(abs(x), axis=1)) -inf min(sum(abs(x), axis=1)) 0 abs(x).sum(axis=axis) 1 max(sum(abs(x), axis=0)) -1 min(sum(abs(x), axis=0)) 2 Not implemented -2 Not implemented other Not implemented ===== ============================ The Frobenius norm is given by [1]_: :math:`||A||_F = [\\sum_{i,j} abs(a_{i,j})^2]^{1/2}` References ---------- .. [1] G. H. Golub and C. F. Van Loan, *Matrix Computations*, Baltimore, MD, Johns Hopkins University Press, 1985, pg. 15 Examples -------- >>> from scipy.sparse import * >>> import numpy as np >>> from scipy.sparse.linalg import norm >>> a = np.arange(9) - 4 >>> a array([-4, -3, -2, -1, 0, 1, 2, 3, 4]) >>> b = a.reshape((3, 3)) >>> b array([[-4, -3, -2], [-1, 0, 1], [ 2, 3, 4]]) >>> b = csr_matrix(b) >>> norm(b) 7.745966692414834 >>> norm(b, 'fro') 7.745966692414834 >>> norm(b, np.inf) 9 >>> norm(b, -np.inf) 2 >>> norm(b, 1) 7 >>> norm(b, -1) 6
Norm of a sparse matrix
[ "Norm", "of", "a", "sparse", "matrix" ]
def norm(x, ord=None, axis=None): """ Norm of a sparse matrix This function is able to return one of seven different matrix norms, depending on the value of the ``ord`` parameter. Parameters ---------- x : a sparse matrix Input sparse matrix. ord : {non-zero int, inf, -inf, 'fro'}, optional Order of the norm (see table under ``Notes``). inf means numpy's `inf` object. axis : {int, 2-tuple of ints, None}, optional If `axis` is an integer, it specifies the axis of `x` along which to compute the vector norms. If `axis` is a 2-tuple, it specifies the axes that hold 2-D matrices, and the matrix norms of these matrices are computed. If `axis` is None then either a vector norm (when `x` is 1-D) or a matrix norm (when `x` is 2-D) is returned. Returns ------- n : float or ndarray Notes ----- Some of the ord are not implemented because some associated functions like, _multi_svd_norm, are not yet available for sparse matrix. This docstring is modified based on numpy.linalg.norm. https://github.com/numpy/numpy/blob/main/numpy/linalg/linalg.py The following norms can be calculated: ===== ============================ ord norm for sparse matrices ===== ============================ None Frobenius norm 'fro' Frobenius norm inf max(sum(abs(x), axis=1)) -inf min(sum(abs(x), axis=1)) 0 abs(x).sum(axis=axis) 1 max(sum(abs(x), axis=0)) -1 min(sum(abs(x), axis=0)) 2 Not implemented -2 Not implemented other Not implemented ===== ============================ The Frobenius norm is given by [1]_: :math:`||A||_F = [\\sum_{i,j} abs(a_{i,j})^2]^{1/2}` References ---------- .. [1] G. H. Golub and C. F. Van Loan, *Matrix Computations*, Baltimore, MD, Johns Hopkins University Press, 1985, pg. 15 Examples -------- >>> from scipy.sparse import * >>> import numpy as np >>> from scipy.sparse.linalg import norm >>> a = np.arange(9) - 4 >>> a array([-4, -3, -2, -1, 0, 1, 2, 3, 4]) >>> b = a.reshape((3, 3)) >>> b array([[-4, -3, -2], [-1, 0, 1], [ 2, 3, 4]]) >>> b = csr_matrix(b) >>> norm(b) 7.745966692414834 >>> norm(b, 'fro') 7.745966692414834 >>> norm(b, np.inf) 9 >>> norm(b, -np.inf) 2 >>> norm(b, 1) 7 >>> norm(b, -1) 6 """ if not issparse(x): raise TypeError("input is not sparse. use numpy.linalg.norm") # Check the default case first and handle it immediately. if axis is None and ord in (None, 'fro', 'f'): return _sparse_frobenius_norm(x) # Some norms require functions that are not implemented for all types. x = x.tocsr() if axis is None: axis = (0, 1) elif not isinstance(axis, tuple): msg = "'axis' must be None, an integer or a tuple of integers" try: int_axis = int(axis) except TypeError as e: raise TypeError(msg) from e if axis != int_axis: raise TypeError(msg) axis = (int_axis,) nd = 2 if len(axis) == 2: row_axis, col_axis = axis if not (-nd <= row_axis < nd and -nd <= col_axis < nd): raise ValueError('Invalid axis %r for an array with shape %r' % (axis, x.shape)) if row_axis % nd == col_axis % nd: raise ValueError('Duplicate axes given.') if ord == 2: raise NotImplementedError #return _multi_svd_norm(x, row_axis, col_axis, amax) elif ord == -2: raise NotImplementedError #return _multi_svd_norm(x, row_axis, col_axis, amin) elif ord == 1: return abs(x).sum(axis=row_axis).max(axis=col_axis)[0,0] elif ord == Inf: return abs(x).sum(axis=col_axis).max(axis=row_axis)[0,0] elif ord == -1: return abs(x).sum(axis=row_axis).min(axis=col_axis)[0,0] elif ord == -Inf: return abs(x).sum(axis=col_axis).min(axis=row_axis)[0,0] elif ord in (None, 'f', 'fro'): # The axis order does not matter for this norm. return _sparse_frobenius_norm(x) else: raise ValueError("Invalid norm order for matrices.") elif len(axis) == 1: a, = axis if not (-nd <= a < nd): raise ValueError('Invalid axis %r for an array with shape %r' % (axis, x.shape)) if ord == Inf: M = abs(x).max(axis=a) elif ord == -Inf: M = abs(x).min(axis=a) elif ord == 0: # Zero norm M = (x != 0).sum(axis=a) elif ord == 1: # special case for speedup M = abs(x).sum(axis=a) elif ord in (2, None): M = sqrt(abs(x).power(2).sum(axis=a)) else: try: ord + 1 except TypeError as e: raise ValueError('Invalid norm order for vectors.') from e M = np.power(abs(x).power(ord).sum(axis=a), 1 / ord) return M.A.ravel() else: raise ValueError("Improper number of dimensions to norm.")
[ "def", "norm", "(", "x", ",", "ord", "=", "None", ",", "axis", "=", "None", ")", ":", "if", "not", "issparse", "(", "x", ")", ":", "raise", "TypeError", "(", "\"input is not sparse. use numpy.linalg.norm\"", ")", "# Check the default case first and handle it immed...
https://github.com/scipy/scipy/blob/e0a749f01e79046642ccfdc419edbf9e7ca141ad/scipy/sparse/linalg/_norm.py#L20-L182
clinicalml/cfrnet
9daea5d8ba7cb89f413065c5ce7f0136f0e84c9b
cfr/util.py
python
pdist2sq
(X,Y)
return D
Computes the squared Euclidean distance between all pairs x in X, y in Y
Computes the squared Euclidean distance between all pairs x in X, y in Y
[ "Computes", "the", "squared", "Euclidean", "distance", "between", "all", "pairs", "x", "in", "X", "y", "in", "Y" ]
def pdist2sq(X,Y): """ Computes the squared Euclidean distance between all pairs x in X, y in Y """ C = -2*tf.matmul(X,tf.transpose(Y)) nx = tf.reduce_sum(tf.square(X),1,keep_dims=True) ny = tf.reduce_sum(tf.square(Y),1,keep_dims=True) D = (C + tf.transpose(ny)) + nx return D
[ "def", "pdist2sq", "(", "X", ",", "Y", ")", ":", "C", "=", "-", "2", "*", "tf", ".", "matmul", "(", "X", ",", "tf", ".", "transpose", "(", "Y", ")", ")", "nx", "=", "tf", ".", "reduce_sum", "(", "tf", ".", "square", "(", "X", ")", ",", "1...
https://github.com/clinicalml/cfrnet/blob/9daea5d8ba7cb89f413065c5ce7f0136f0e84c9b/cfr/util.py#L142-L148
maxpumperla/betago
ff06b467e16d7a7a22555d14181b723d853e1a70
betago/dataloader/goboard.py
python
GoBoard.fold_go_strings
(self, target, source, join_position)
Merge two go strings by joining their common moves
Merge two go strings by joining their common moves
[ "Merge", "two", "go", "strings", "by", "joining", "their", "common", "moves" ]
def fold_go_strings(self, target, source, join_position): ''' Merge two go strings by joining their common moves''' if target == source: return for stone_position in source.stones.stones: self.go_strings[stone_position] = target target.insert_stone(stone_position) target.copy_liberties_from(source) target.remove_liberty(join_position)
[ "def", "fold_go_strings", "(", "self", ",", "target", ",", "source", ",", "join_position", ")", ":", "if", "target", "==", "source", ":", "return", "for", "stone_position", "in", "source", ".", "stones", ".", "stones", ":", "self", ".", "go_strings", "[", ...
https://github.com/maxpumperla/betago/blob/ff06b467e16d7a7a22555d14181b723d853e1a70/betago/dataloader/goboard.py#L30-L38
Pymol-Scripts/Pymol-script-repo
bcd7bb7812dc6db1595953dfa4471fa15fb68c77
plugins/bnitools.py
python
AboutGui.tag_list
(self, txt_parent)
Tag list for tags to color log output.
Tag list for tags to color log output.
[ "Tag", "list", "for", "tags", "to", "color", "log", "output", "." ]
def tag_list(self, txt_parent): '''Tag list for tags to color log output. ''' for color, filter in self.txtcolors: txt_parent.tag_configure(color, foreground=color)
[ "def", "tag_list", "(", "self", ",", "txt_parent", ")", ":", "for", "color", ",", "filter", "in", "self", ".", "txtcolors", ":", "txt_parent", ".", "tag_configure", "(", "color", ",", "foreground", "=", "color", ")" ]
https://github.com/Pymol-Scripts/Pymol-script-repo/blob/bcd7bb7812dc6db1595953dfa4471fa15fb68c77/plugins/bnitools.py#L514-L518
AppScale/gts
46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9
AppServer/google/appengine/ext/admin/__init__.py
python
MemcachePageHandler.post
(self)
Handle modifying actions and/or redirect to GET page.
Handle modifying actions and/or redirect to GET page.
[ "Handle", "modifying", "actions", "and", "/", "or", "redirect", "to", "GET", "page", "." ]
def post(self): """Handle modifying actions and/or redirect to GET page.""" next_param = {} if self.request.get('action:flush'): if memcache.flush_all(): next_param['message'] = 'Cache flushed, all keys dropped.' else: next_param['message'] = 'Flushing the cache failed. Please try again.' elif self.request.get('action:display'): next_param['key'] = self.request.get('key') elif self.request.get('action:edit'): next_param['edit'] = self.request.get('key') elif self.request.get('action:delete'): key = self.request.get('key') result = memcache.delete(key) if result == memcache.DELETE_NETWORK_FAILURE: next_param['message'] = ('ERROR: Network failure, key "%s" not deleted.' % key) elif result == memcache.DELETE_ITEM_MISSING: next_param['message'] = 'Key "%s" not in cache.' % key elif result == memcache.DELETE_SUCCESSFUL: next_param['message'] = 'Key "%s" deleted.' % key else: next_param['message'] = ('Unknown return value. Key "%s" might still ' 'exist.' % key) elif self.request.get('action:save'): key = self.request.get('key') value = self.request.get('value') type_ = self.request.get('type') next_param['key'] = key try: if self._SetValue(key, type_, value): next_param['message'] = 'Key "%s" saved.' % key else: next_param['message'] = 'ERROR: Failed to save key "%s".' % key except ValueError, e: next_param['message'] = 'ERROR: Unable to encode value: %s' % e elif self.request.get('action:cancel'): next_param['key'] = self.request.get('key') else: next_param['message'] = 'Unknown action.' next = self.request.path_url if next_param: next = '%s?%s' % (next, self._urlencode(next_param)) self.redirect(next)
[ "def", "post", "(", "self", ")", ":", "next_param", "=", "{", "}", "if", "self", ".", "request", ".", "get", "(", "'action:flush'", ")", ":", "if", "memcache", ".", "flush_all", "(", ")", ":", "next_param", "[", "'message'", "]", "=", "'Cache flushed, ...
https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/google/appengine/ext/admin/__init__.py#L1046-L1098
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-linux/x64/tornado/locks.py
python
Lock.__init__
(self)
[]
def __init__(self) -> None: self._block = BoundedSemaphore(value=1)
[ "def", "__init__", "(", "self", ")", "->", "None", ":", "self", ".", "_block", "=", "BoundedSemaphore", "(", "value", "=", "1", ")" ]
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-linux/x64/tornado/locks.py#L522-L523
maoschanz/drawing
d4a69258570c7a120817484eaadac1145dedb62d
src/optionsbars/classic/optionsbar_classic.py
python
OptionsBarClassic._build_color_buttons
(self, builder)
Initialize the 2 color-buttons and popovers with the 2 previously memorized RGBA values.
Initialize the 2 color-buttons and popovers with the 2 previously memorized RGBA values.
[ "Initialize", "the", "2", "color", "-", "buttons", "and", "popovers", "with", "the", "2", "previously", "memorized", "RGBA", "values", "." ]
def _build_color_buttons(self, builder): """Initialize the 2 color-buttons and popovers with the 2 previously memorized RGBA values.""" options_manager = self.window.options_manager thumbnail_r = builder.get_object('r_btn_image') self._color_r = OptionsBarClassicColorPopover(self.color_menu_btn_r, \ thumbnail_r, False, options_manager) thumbnail_l = builder.get_object('l_btn_image') self._color_l = OptionsBarClassicColorPopover(self.color_menu_btn_l, \ thumbnail_l, True, options_manager)
[ "def", "_build_color_buttons", "(", "self", ",", "builder", ")", ":", "options_manager", "=", "self", ".", "window", ".", "options_manager", "thumbnail_r", "=", "builder", ".", "get_object", "(", "'r_btn_image'", ")", "self", ".", "_color_r", "=", "OptionsBarCla...
https://github.com/maoschanz/drawing/blob/d4a69258570c7a120817484eaadac1145dedb62d/src/optionsbars/classic/optionsbar_classic.py#L110-L121
deanishe/alfred-workflow
70d04df5bded8e501ce3bb82fa55ecc1f947f240
workflow/background.py
python
_pid_file
(name)
return wf().cachefile(name + '.pid')
Return path to PID file for ``name``. :param name: name of task :type name: ``unicode`` :returns: Path to PID file for task :rtype: ``unicode`` filepath
Return path to PID file for ``name``.
[ "Return", "path", "to", "PID", "file", "for", "name", "." ]
def _pid_file(name): """Return path to PID file for ``name``. :param name: name of task :type name: ``unicode`` :returns: Path to PID file for task :rtype: ``unicode`` filepath """ return wf().cachefile(name + '.pid')
[ "def", "_pid_file", "(", "name", ")", ":", "return", "wf", "(", ")", ".", "cachefile", "(", "name", "+", "'.pid'", ")" ]
https://github.com/deanishe/alfred-workflow/blob/70d04df5bded8e501ce3bb82fa55ecc1f947f240/workflow/background.py#L58-L67
mwouts/jupytext
f8e8352859cc22e17b11154d0770fd946c4a430a
jupytext/config.py
python
validate_jupytext_configuration_file
(config_file, config_dict)
return config
Turn a dict-like config into a JupytextConfiguration object
Turn a dict-like config into a JupytextConfiguration object
[ "Turn", "a", "dict", "-", "like", "config", "into", "a", "JupytextConfiguration", "object" ]
def validate_jupytext_configuration_file(config_file, config_dict): """Turn a dict-like config into a JupytextConfiguration object""" if config_dict is None: return None try: config = JupytextConfiguration(**config_dict) except TraitError as err: raise JupytextConfigurationError( "The Jupytext configuration file {} is incorrect: {}".format( config_file, err ) ) invalid_options = set(config_dict).difference(dir(JupytextConfiguration())) if any(invalid_options): raise JupytextConfigurationError( "The Jupytext configuration file {} is incorrect: options {} are not supported".format( config_file, ",".join(invalid_options) ) ) return config
[ "def", "validate_jupytext_configuration_file", "(", "config_file", ",", "config_dict", ")", ":", "if", "config_dict", "is", "None", ":", "return", "None", "try", ":", "config", "=", "JupytextConfiguration", "(", "*", "*", "config_dict", ")", "except", "TraitError"...
https://github.com/mwouts/jupytext/blob/f8e8352859cc22e17b11154d0770fd946c4a430a/jupytext/config.py#L406-L425
tanghaibao/goatools
647e9dd833695f688cd16c2f9ea18f1692e5c6bc
goatools/associations.py
python
read_associations
(assoc_fn, anno_type='id2gos', namespace='BP', **kws)
return obj.get_id2gos(namespace, **kws)
Return associatinos in id2gos format
Return associatinos in id2gos format
[ "Return", "associatinos", "in", "id2gos", "format" ]
def read_associations(assoc_fn, anno_type='id2gos', namespace='BP', **kws): """Return associatinos in id2gos format""" # kws get_objanno: taxids hdr_only prt allow_missing_symbol obj = get_objanno(assoc_fn, anno_type, **kws) # kws get_id2gos: ev_include ev_exclude keep_ND keep_NOT b_geneid2gos go2geneids return obj.get_id2gos(namespace, **kws)
[ "def", "read_associations", "(", "assoc_fn", ",", "anno_type", "=", "'id2gos'", ",", "namespace", "=", "'BP'", ",", "*", "*", "kws", ")", ":", "# kws get_objanno: taxids hdr_only prt allow_missing_symbol", "obj", "=", "get_objanno", "(", "assoc_fn", ",", "anno_type"...
https://github.com/tanghaibao/goatools/blob/647e9dd833695f688cd16c2f9ea18f1692e5c6bc/goatools/associations.py#L51-L56
akfamily/akshare
590e50eece9ec067da3538c7059fd660b71f1339
akshare/utils/demjson.py
python
buffered_stream.peek
(self, offset=0)
return self.__rawbuf[i]
Returns the character at the current position, or at a given offset away from the current position. If the position is beyond the limits of the document size, then an empty string '' is returned.
Returns the character at the current position, or at a given offset away from the current position. If the position is beyond the limits of the document size, then an empty string '' is returned.
[ "Returns", "the", "character", "at", "the", "current", "position", "or", "at", "a", "given", "offset", "away", "from", "the", "current", "position", ".", "If", "the", "position", "is", "beyond", "the", "limits", "of", "the", "document", "size", "then", "an...
def peek(self, offset=0): """Returns the character at the current position, or at a given offset away from the current position. If the position is beyond the limits of the document size, then an empty string '' is returned. """ i = self.cpos + offset if i < 0 or i >= self.__cmax: return '' return self.__rawbuf[i]
[ "def", "peek", "(", "self", ",", "offset", "=", "0", ")", ":", "i", "=", "self", ".", "cpos", "+", "offset", "if", "i", "<", "0", "or", "i", ">=", "self", ".", "__cmax", ":", "return", "''", "return", "self", ".", "__rawbuf", "[", "i", "]" ]
https://github.com/akfamily/akshare/blob/590e50eece9ec067da3538c7059fd660b71f1339/akshare/utils/demjson.py#L1780-L1790
enthought/mayavi
2103a273568b8f0bd62328801aafbd6252543ae8
mayavi/components/poly_data_normals.py
python
PolyDataNormals.update_pipeline
(self)
Override this method so that it *updates* the tvtk pipeline when data upstream is known to have changed. This method is invoked (automatically) when the input fires a `pipeline_changed` event.
Override this method so that it *updates* the tvtk pipeline when data upstream is known to have changed.
[ "Override", "this", "method", "so", "that", "it", "*", "updates", "*", "the", "tvtk", "pipeline", "when", "data", "upstream", "is", "known", "to", "have", "changed", "." ]
def update_pipeline(self): """Override this method so that it *updates* the tvtk pipeline when data upstream is known to have changed. This method is invoked (automatically) when the input fires a `pipeline_changed` event. """ if (len(self.inputs) == 0) or \ (len(self.inputs[0].outputs) == 0): return f = self.filter input = self.inputs[0].outputs[0] self.configure_input(f, convert_to_poly_data(input)) f.update() self.outputs = [f]
[ "def", "update_pipeline", "(", "self", ")", ":", "if", "(", "len", "(", "self", ".", "inputs", ")", "==", "0", ")", "or", "(", "len", "(", "self", ".", "inputs", "[", "0", "]", ".", "outputs", ")", "==", "0", ")", ":", "return", "f", "=", "se...
https://github.com/enthought/mayavi/blob/2103a273568b8f0bd62328801aafbd6252543ae8/mayavi/components/poly_data_normals.py#L55-L69
IronLanguages/ironpython2
51fdedeeda15727717fb8268a805f71b06c0b9f1
Src/StdLib/Lib/collections.py
python
OrderedDict.setdefault
(self, key, default=None)
return default
od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od
od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od
[ "od", ".", "setdefault", "(", "k", "[", "d", "]", ")", "-", ">", "od", ".", "get", "(", "k", "d", ")", "also", "set", "od", "[", "k", "]", "=", "d", "if", "k", "not", "in", "od" ]
def setdefault(self, key, default=None): 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od' if key in self: return self[key] self[key] = default return default
[ "def", "setdefault", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "if", "key", "in", "self", ":", "return", "self", "[", "key", "]", "self", "[", "key", "]", "=", "default", "return", "default" ]
https://github.com/IronLanguages/ironpython2/blob/51fdedeeda15727717fb8268a805f71b06c0b9f1/Src/StdLib/Lib/collections.py#L163-L168
HKUST-Aerial-Robotics/Stereo-RCNN
63c6ab98b7a5e36c7bcfdec4529804fc940ee900
lib/setup.py
python
customize_compiler_for_nvcc
(self)
inject deep into distutils to customize how the dispatch to gcc/nvcc works. If you subclass UnixCCompiler, it's not trivial to get your subclass injected in, and still have the right customizations (i.e. distutils.sysconfig.customize_compiler) run on it. So instead of going the OO route, I have this. Note, it's kindof like a wierd functional subclassing going on.
inject deep into distutils to customize how the dispatch to gcc/nvcc works.
[ "inject", "deep", "into", "distutils", "to", "customize", "how", "the", "dispatch", "to", "gcc", "/", "nvcc", "works", "." ]
def customize_compiler_for_nvcc(self): """inject deep into distutils to customize how the dispatch to gcc/nvcc works. If you subclass UnixCCompiler, it's not trivial to get your subclass injected in, and still have the right customizations (i.e. distutils.sysconfig.customize_compiler) run on it. So instead of going the OO route, I have this. Note, it's kindof like a wierd functional subclassing going on.""" # tell the compiler it can processes .cu self.src_extensions.append('.cu') # save references to the default compiler_so and _comple methods default_compiler_so = self.compiler_so super = self._compile # now redefine the _compile method. This gets executed for each # object but distutils doesn't have the ability to change compilers # based on source extension: we add it. def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts): print(extra_postargs) if os.path.splitext(src)[1] == '.cu': # use the cuda for .cu files self.set_executable('compiler_so', CUDA['nvcc']) # use only a subset of the extra_postargs, which are 1-1 translated # from the extra_compile_args in the Extension class postargs = extra_postargs['nvcc'] else: postargs = extra_postargs['gcc'] super(obj, src, ext, cc_args, postargs, pp_opts) # reset the default compiler_so, which we might have changed for cuda self.compiler_so = default_compiler_so # inject our redefined _compile method into the class self._compile = _compile
[ "def", "customize_compiler_for_nvcc", "(", "self", ")", ":", "# tell the compiler it can processes .cu", "self", ".", "src_extensions", ".", "append", "(", "'.cu'", ")", "# save references to the default compiler_so and _comple methods", "default_compiler_so", "=", "self", ".",...
https://github.com/HKUST-Aerial-Robotics/Stereo-RCNN/blob/63c6ab98b7a5e36c7bcfdec4529804fc940ee900/lib/setup.py#L69-L105
samuelclay/NewsBlur
2c45209df01a1566ea105e04d499367f32ac9ad2
apps/social/models.py
python
MSharedStory.set_source_user_id
(self, source_user_id)
[]
def set_source_user_id(self, source_user_id): if source_user_id == self.user_id: return def find_source(source_user_id, seen_user_ids): parent_shared_story = MSharedStory.objects.filter(user_id=source_user_id, story_guid=self.story_guid, story_feed_id=self.story_feed_id).limit(1) if parent_shared_story and parent_shared_story[0].source_user_id: user_id = parent_shared_story[0].source_user_id if user_id in seen_user_ids: return source_user_id else: seen_user_ids.append(user_id) return find_source(user_id, seen_user_ids) else: return source_user_id if source_user_id: source_user_id = find_source(source_user_id, []) if source_user_id == self.user_id: return elif not self.source_user_id or source_user_id != self.source_user_id: self.source_user_id = source_user_id logging.debug(" ---> Re-share from %s." % source_user_id) self.save() MInteraction.new_reshared_story(user_id=self.source_user_id, reshare_user_id=self.user_id, comments=self.comments, story_title=self.story_title, story_feed_id=self.story_feed_id, story_id=self.story_guid)
[ "def", "set_source_user_id", "(", "self", ",", "source_user_id", ")", ":", "if", "source_user_id", "==", "self", ".", "user_id", ":", "return", "def", "find_source", "(", "source_user_id", ",", "seen_user_ids", ")", ":", "parent_shared_story", "=", "MSharedStory",...
https://github.com/samuelclay/NewsBlur/blob/2c45209df01a1566ea105e04d499367f32ac9ad2/apps/social/models.py#L1713-L1745
davidpany/WMI_Forensics
0ab08dca7938d26846497be9e450b7bb2ca7fff3
CCM_RUA_Finder.py
python
sanitize_string
(input_string)
return (input_string.replace("\\\\\\\\x0020", " ") .replace("\\\\\\\\\\\\\\\\", "\\").replace("\\\\x0020", " ") .replace("\\\\\\\\", "\\").replace("&#174;", "(R)") .replace("\\x0020", " "))
Remove non-friendly characters from output strings
Remove non-friendly characters from output strings
[ "Remove", "non", "-", "friendly", "characters", "from", "output", "strings" ]
def sanitize_string(input_string): """Remove non-friendly characters from output strings""" return (input_string.replace("\\\\\\\\x0020", " ") .replace("\\\\\\\\\\\\\\\\", "\\").replace("\\\\x0020", " ") .replace("\\\\\\\\", "\\").replace("&#174;", "(R)") .replace("\\x0020", " "))
[ "def", "sanitize_string", "(", "input_string", ")", ":", "return", "(", "input_string", ".", "replace", "(", "\"\\\\\\\\\\\\\\\\x0020\"", ",", "\" \"", ")", ".", "replace", "(", "\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"", ",", "\"\\\\\"", ")", ".", "replace", "(", "\"...
https://github.com/davidpany/WMI_Forensics/blob/0ab08dca7938d26846497be9e450b7bb2ca7fff3/CCM_RUA_Finder.py#L540-L546
Tribler/tribler
f1de8bd54f293b01b2646a1dead1c1dc9dfdb356
src/tribler-core/tribler_core/components/libtorrent/download_manager/download_state.py
python
DownloadState.get_availability
(self)
return nr_seeders_complete
Return overall the availability of all pieces, using connected peers Availability is defined as the number of complete copies of a piece, thus seeders increment the availability by 1. Leechers provide a subset of piece thus we count the overall availability of all pieces provided by the connected peers and use the minimum of this + the average of all additional pieces.
Return overall the availability of all pieces, using connected peers Availability is defined as the number of complete copies of a piece, thus seeders increment the availability by 1. Leechers provide a subset of piece thus we count the overall availability of all pieces provided by the connected peers and use the minimum of this + the average of all additional pieces.
[ "Return", "overall", "the", "availability", "of", "all", "pieces", "using", "connected", "peers", "Availability", "is", "defined", "as", "the", "number", "of", "complete", "copies", "of", "a", "piece", "thus", "seeders", "increment", "the", "availability", "by",...
def get_availability(self): """ Return overall the availability of all pieces, using connected peers Availability is defined as the number of complete copies of a piece, thus seeders increment the availability by 1. Leechers provide a subset of piece thus we count the overall availability of all pieces provided by the connected peers and use the minimum of this + the average of all additional pieces. """ if not self.lt_status: return 0 # We do not have any info for this download so we cannot accurately get its availability nr_seeders_complete = 0 merged_bitfields = [0] * len(self.lt_status.pieces) peers = self.get_peerlist() for peer in peers: completed = peer.get('completed', 0) have = peer.get('have', []) if completed == 1 or have and all(have): nr_seeders_complete += 1 elif have and len(have) == len(merged_bitfields): for i in range(len(have)): if have[i]: merged_bitfields[i] += 1 if merged_bitfields: # count the number of complete copies due to overlapping leecher bitfields nr_leechers_complete = min(merged_bitfields) # detect remainder of bitfields which are > 0 nr_more_than_min = len([x for x in merged_bitfields if x > nr_leechers_complete]) fraction_additonal = float(nr_more_than_min) / len(merged_bitfields) return nr_seeders_complete + nr_leechers_complete + fraction_additonal return nr_seeders_complete
[ "def", "get_availability", "(", "self", ")", ":", "if", "not", "self", ".", "lt_status", ":", "return", "0", "# We do not have any info for this download so we cannot accurately get its availability", "nr_seeders_complete", "=", "0", "merged_bitfields", "=", "[", "0", "]"...
https://github.com/Tribler/tribler/blob/f1de8bd54f293b01b2646a1dead1c1dc9dfdb356/src/tribler-core/tribler_core/components/libtorrent/download_manager/download_state.py#L182-L216
w3h/isf
6faf0a3df185465ec17369c90ccc16e2a03a1870
lib/thirdparty/pyreadline/modes/notemacs.py
python
NotEmacsMode.set_mark
(self, e)
Set the mark to the point. If a numeric argument is supplied, the mark is set to that position.
Set the mark to the point. If a numeric argument is supplied, the mark is set to that position.
[ "Set", "the", "mark", "to", "the", "point", ".", "If", "a", "numeric", "argument", "is", "supplied", "the", "mark", "is", "set", "to", "that", "position", "." ]
def set_mark(self, e): # (C-@) '''Set the mark to the point. If a numeric argument is supplied, the mark is set to that position.''' self.l_buffer.set_mark()
[ "def", "set_mark", "(", "self", ",", "e", ")", ":", "# (C-@)", "self", ".", "l_buffer", ".", "set_mark", "(", ")" ]
https://github.com/w3h/isf/blob/6faf0a3df185465ec17369c90ccc16e2a03a1870/lib/thirdparty/pyreadline/modes/notemacs.py#L512-L515
bdcht/amoco
dac8e00b862eb6d87cc88dddd1e5316c67c1d798
amoco/logger.py
python
reset_log_file
(filename, level=logging.DEBUG)
set DEBUG log file for all loggers. Args: filename (str): filename for the FileHandler added to all amoco loggers
set DEBUG log file for all loggers.
[ "set", "DEBUG", "log", "file", "for", "all", "loggers", "." ]
def reset_log_file(filename, level=logging.DEBUG): """set DEBUG log file for all loggers. Args: filename (str): filename for the FileHandler added to all amoco loggers """ global logfile if logfile is not None: logfile.close() unset_log_file() set_file_logging(filename,level) for l in Log.loggers.values(): l.addHandler(logfile)
[ "def", "reset_log_file", "(", "filename", ",", "level", "=", "logging", ".", "DEBUG", ")", ":", "global", "logfile", "if", "logfile", "is", "not", "None", ":", "logfile", ".", "close", "(", ")", "unset_log_file", "(", ")", "set_file_logging", "(", "filenam...
https://github.com/bdcht/amoco/blob/dac8e00b862eb6d87cc88dddd1e5316c67c1d798/amoco/logger.py#L160-L173
gnemoug/sina_reptile
c3273681c1ba79273dd9197122b73135e10584a2
SDK1/weibopy/api.py
python
API.add_list_member
(self, slug, *args, **kargs)
return bind_api( path = '/%s/%s/members.json' % (self.auth.get_username(), slug), method = 'POST', payload_type = 'list', allowed_param = ['id'], require_auth = True )(self, *args, **kargs)
[]
def add_list_member(self, slug, *args, **kargs): return bind_api( path = '/%s/%s/members.json' % (self.auth.get_username(), slug), method = 'POST', payload_type = 'list', allowed_param = ['id'], require_auth = True )(self, *args, **kargs)
[ "def", "add_list_member", "(", "self", ",", "slug", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "return", "bind_api", "(", "path", "=", "'/%s/%s/members.json'", "%", "(", "self", ".", "auth", ".", "get_username", "(", ")", ",", "slug", ")", "...
https://github.com/gnemoug/sina_reptile/blob/c3273681c1ba79273dd9197122b73135e10584a2/SDK1/weibopy/api.py#L641-L648
google-research/language
61fa7260ac7d690d11ef72ca863e45a37c0bdc80
language/search_agents/muzero/state_tree.py
python
NQStateTree.to_adjustments
(self)
return adjustments
Group the yield into `QueryAdjustments`.
Group the yield into `QueryAdjustments`.
[ "Group", "the", "yield", "into", "QueryAdjustments", "." ]
def to_adjustments(self) -> List[QueryAdjustment]: """Group the yield into `QueryAdjustments`.""" leaves = self.root.leaves() adjustments = [] while leaves: leaf = leaves.pop(0) if leaf not in [operator.value for operator in Operator] or not leaves: continue if leaves[0] in ['[title]', '[contents]']: field = leaves.pop(0) term = leaves.pop(0) else: term = leaves.pop(0) field = '[all]' # in case it is a subword token while leaves and leaves[0].startswith('##'): term += leaves.pop(0).replace('##', '') adjustments.append(QueryAdjustment(Operator(leaf), Field(field), term)) return adjustments
[ "def", "to_adjustments", "(", "self", ")", "->", "List", "[", "QueryAdjustment", "]", ":", "leaves", "=", "self", ".", "root", ".", "leaves", "(", ")", "adjustments", "=", "[", "]", "while", "leaves", ":", "leaf", "=", "leaves", ".", "pop", "(", "0",...
https://github.com/google-research/language/blob/61fa7260ac7d690d11ef72ca863e45a37c0bdc80/language/search_agents/muzero/state_tree.py#L314-L333
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/vpc/v20170312/models.py
python
ModifyAddressAttributeResponse.__init__
(self)
r""" :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
r""" :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
[ "r", ":", "param", "RequestId", ":", "唯一请求", "ID,每次请求都会返回。定位问题时需要提供该次请求的", "RequestId。", ":", "type", "RequestId", ":", "str" ]
def __init__(self): r""" :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str """ self.RequestId = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "RequestId", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/vpc/v20170312/models.py#L13817-L13822
mgear-dev/mgear
06ddc26c5adb5eab07ca470c7fafa77404c8a1de
scripts/mgear/maya/shifter/component/guide.py
python
ComponentGuide.symmetrize
(self)
return True
Inverse the transform of each element of the guide.
Inverse the transform of each element of the guide.
[ "Inverse", "the", "transform", "of", "each", "element", "of", "the", "guide", "." ]
def symmetrize(self): """Inverse the transform of each element of the guide.""" if self.values["comp_side"] not in ["R", "L"]: mgear.log("Can't symmetrize central component", mgear.sev_error) return False for name, paramDef in self.paramDefs.items(): if paramDef.valueType == "string": self.setParamDefValue( name, mgear.string.convertRLName(self.values[name])) for name, t in self.tra.items(): self.tra[name] = transform.getSymmetricalTransform(t) for name, blade in self.blades.items(): self.blades[name] = vector.Blade( transform.getSymmetricalTransform(blade.transform)) return True
[ "def", "symmetrize", "(", "self", ")", ":", "if", "self", ".", "values", "[", "\"comp_side\"", "]", "not", "in", "[", "\"R\"", ",", "\"L\"", "]", ":", "mgear", ".", "log", "(", "\"Can't symmetrize central component\"", ",", "mgear", ".", "sev_error", ")", ...
https://github.com/mgear-dev/mgear/blob/06ddc26c5adb5eab07ca470c7fafa77404c8a1de/scripts/mgear/maya/shifter/component/guide.py#L392-L408
pyg-team/pytorch_geometric
b920e9a3a64e22c8356be55301c88444ff051cae
examples/graph_saint.py
python
Net.set_aggr
(self, aggr)
[]
def set_aggr(self, aggr): self.conv1.aggr = aggr self.conv2.aggr = aggr self.conv3.aggr = aggr
[ "def", "set_aggr", "(", "self", ",", "aggr", ")", ":", "self", ".", "conv1", ".", "aggr", "=", "aggr", "self", ".", "conv2", ".", "aggr", "=", "aggr", "self", ".", "conv3", ".", "aggr", "=", "aggr" ]
https://github.com/pyg-team/pytorch_geometric/blob/b920e9a3a64e22c8356be55301c88444ff051cae/examples/graph_saint.py#L37-L40
kuri65536/python-for-android
26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891
python-modules/twisted/twisted/internet/base.py
python
BaseConnector.disconnect
(self)
Disconnect whatever our state is.
Disconnect whatever our state is.
[ "Disconnect", "whatever", "our", "state", "is", "." ]
def disconnect(self): """Disconnect whatever our state is.""" if self.state == 'connecting': self.stopConnecting() elif self.state == 'connected': self.transport.loseConnection()
[ "def", "disconnect", "(", "self", ")", ":", "if", "self", ".", "state", "==", "'connecting'", ":", "self", ".", "stopConnecting", "(", ")", "elif", "self", ".", "state", "==", "'connected'", ":", "self", ".", "transport", ".", "loseConnection", "(", ")" ...
https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python-modules/twisted/twisted/internet/base.py#L997-L1002
lutris/lutris
66675a4d5537f6b2a2ba2b6df0b3cdf8924c823a
lutris/util/display.py
python
DBusScreenSaverInhibitor.inhibit
(self, game_name)
Inhibit the screen saver. Returns a cookie that must be passed to the corresponding uninhibit() call. If an error occurs, None is returned instead.
Inhibit the screen saver. Returns a cookie that must be passed to the corresponding uninhibit() call. If an error occurs, None is returned instead.
[ "Inhibit", "the", "screen", "saver", ".", "Returns", "a", "cookie", "that", "must", "be", "passed", "to", "the", "corresponding", "uninhibit", "()", "call", ".", "If", "an", "error", "occurs", "None", "is", "returned", "instead", "." ]
def inhibit(self, game_name): """Inhibit the screen saver. Returns a cookie that must be passed to the corresponding uninhibit() call. If an error occurs, None is returned instead.""" try: return self.proxy.Inhibit("(ss)", "Lutris", "Running game: %s" % game_name) except Exception: return None
[ "def", "inhibit", "(", "self", ",", "game_name", ")", ":", "try", ":", "return", "self", ".", "proxy", ".", "Inhibit", "(", "\"(ss)\"", ",", "\"Lutris\"", ",", "\"Running game: %s\"", "%", "game_name", ")", "except", "Exception", ":", "return", "None" ]
https://github.com/lutris/lutris/blob/66675a4d5537f6b2a2ba2b6df0b3cdf8924c823a/lutris/util/display.py#L284-L291
bitcraze/crazyflie-lib-python
876f0dc003b91ba5e4de05daae9d0b79cf600f81
cflib/drivers/cfusb.py
python
_get_vendor_setup
(handle, request, value, index, length)
[]
def _get_vendor_setup(handle, request, value, index, length): if pyusb1: return handle.ctrl_transfer(usb.TYPE_VENDOR | 0x80, request, wValue=value, wIndex=index, timeout=1000, data_or_wLength=length) else: return handle.controlMsg(usb.TYPE_VENDOR | 0x80, request, length, value=value, index=index, timeout=1000)
[ "def", "_get_vendor_setup", "(", "handle", ",", "request", ",", "value", ",", "index", ",", "length", ")", ":", "if", "pyusb1", ":", "return", "handle", ".", "ctrl_transfer", "(", "usb", ".", "TYPE_VENDOR", "|", "0x80", ",", "request", ",", "wValue", "="...
https://github.com/bitcraze/crazyflie-lib-python/blob/876f0dc003b91ba5e4de05daae9d0b79cf600f81/cflib/drivers/cfusb.py#L190-L197
attardi/deepnl
e1ad450f2768a084f44b128de313f19c2f15100f
bin/knn.py
python
l2_nearest
(embeddings, e, k)
return sorted_distances[1:k]
Sort vectors according to their Euclidean distance from e and return the k closest. Returns list of (index, distance^2)
Sort vectors according to their Euclidean distance from e and return the k closest. Returns list of (index, distance^2)
[ "Sort", "vectors", "according", "to", "their", "Euclidean", "distance", "from", "e", "and", "return", "the", "k", "closest", ".", "Returns", "list", "of", "(", "index", "distance^2", ")" ]
def l2_nearest(embeddings, e, k): """Sort vectors according to their Euclidean distance from e and return the k closest. Returns list of (index, distance^2) """ distances = ((embeddings - e) ** 2).sum(axis=1) # ** 0.5 sorted_distances = sorted(enumerate(distances), key=itemgetter(1)) return sorted_distances[1:k]
[ "def", "l2_nearest", "(", "embeddings", ",", "e", ",", "k", ")", ":", "distances", "=", "(", "(", "embeddings", "-", "e", ")", "**", "2", ")", ".", "sum", "(", "axis", "=", "1", ")", "# ** 0.5", "sorted_distances", "=", "sorted", "(", "enumerate", ...
https://github.com/attardi/deepnl/blob/e1ad450f2768a084f44b128de313f19c2f15100f/bin/knn.py#L67-L75
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Lib/xmlrpclib.py
python
Transport.send_request
(self, connection, handler, request_body)
[]
def send_request(self, connection, handler, request_body): if (self.accept_gzip_encoding and gzip): connection.putrequest("POST", handler, skip_accept_encoding=True) connection.putheader("Accept-Encoding", "gzip") else: connection.putrequest("POST", handler)
[ "def", "send_request", "(", "self", ",", "connection", ",", "handler", ",", "request_body", ")", ":", "if", "(", "self", ".", "accept_gzip_encoding", "and", "gzip", ")", ":", "connection", ".", "putrequest", "(", "\"POST\"", ",", "handler", ",", "skip_accept...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Lib/xmlrpclib.py#L1398-L1403
aestrivex/bctpy
32c7fe7345b281c2d4e184f5379c425c36f3bbc7
docs/sphinxext/numpy_ext/docscrape.py
python
dedent_lines
(lines)
return textwrap.dedent("\n".join(lines)).split("\n")
Deindent a list of lines maximally
Deindent a list of lines maximally
[ "Deindent", "a", "list", "of", "lines", "maximally" ]
def dedent_lines(lines): """Deindent a list of lines maximally""" return textwrap.dedent("\n".join(lines)).split("\n")
[ "def", "dedent_lines", "(", "lines", ")", ":", "return", "textwrap", ".", "dedent", "(", "\"\\n\"", ".", "join", "(", "lines", ")", ")", ".", "split", "(", "\"\\n\"", ")" ]
https://github.com/aestrivex/bctpy/blob/32c7fe7345b281c2d4e184f5379c425c36f3bbc7/docs/sphinxext/numpy_ext/docscrape.py#L414-L416
makerbot/ReplicatorG
d6f2b07785a5a5f1e172fb87cb4303b17c575d5d
skein_engines/skeinforge-47/skeinforge_application/skeinforge_plugins/craft_plugins/cool.py
python
CoolSkein.addCoolOrbits
(self, remainingOrbitTime)
Add the minimum radius cool orbits.
Add the minimum radius cool orbits.
[ "Add", "the", "minimum", "radius", "cool", "orbits", "." ]
def addCoolOrbits(self, remainingOrbitTime): 'Add the minimum radius cool orbits.' if len(self.boundaryLayer.loops) < 1: return insetBoundaryLoops = self.boundaryLayer.loops if abs(self.repository.orbitalOutset.value) > 0.1 * abs(self.perimeterWidth): insetBoundaryLoops = intercircle.getInsetLoopsFromLoops(self.boundaryLayer.loops, -self.repository.orbitalOutset.value) if len(insetBoundaryLoops) < 1: insetBoundaryLoops = self.boundaryLayer.loops largestLoop = euclidean.getLargestLoop(insetBoundaryLoops) loopArea = euclidean.getAreaLoopAbsolute(largestLoop) if loopArea < self.minimumArea: center = 0.5 * (euclidean.getMaximumByComplexPath(largestLoop) + euclidean.getMinimumByComplexPath(largestLoop)) centerXBounded = max(center.real, self.boundingRectangle.cornerMinimum.real) centerXBounded = min(centerXBounded, self.boundingRectangle.cornerMaximum.real) centerYBounded = max(center.imag, self.boundingRectangle.cornerMinimum.imag) centerYBounded = min(centerYBounded, self.boundingRectangle.cornerMaximum.imag) center = complex(centerXBounded, centerYBounded) maximumCorner = center + self.halfCorner minimumCorner = center - self.halfCorner largestLoop = euclidean.getSquareLoopWiddershins(minimumCorner, maximumCorner) pointComplex = euclidean.getXYComplexFromVector3(self.oldLocation) if pointComplex != None: largestLoop = euclidean.getLoopStartingClosest(self.perimeterWidth, pointComplex, largestLoop) intercircle.addOrbitsIfLarge( self.distanceFeedRate, largestLoop, self.orbitalFeedRatePerSecond, remainingOrbitTime, self.highestZ)
[ "def", "addCoolOrbits", "(", "self", ",", "remainingOrbitTime", ")", ":", "if", "len", "(", "self", ".", "boundaryLayer", ".", "loops", ")", "<", "1", ":", "return", "insetBoundaryLoops", "=", "self", ".", "boundaryLayer", ".", "loops", "if", "abs", "(", ...
https://github.com/makerbot/ReplicatorG/blob/d6f2b07785a5a5f1e172fb87cb4303b17c575d5d/skein_engines/skeinforge-47/skeinforge_application/skeinforge_plugins/craft_plugins/cool.py#L192-L217
lutris/lutris
66675a4d5537f6b2a2ba2b6df0b3cdf8924c823a
lutris/util/strings.py
python
split_arguments
(args)
return _split_arguments(args)
Wrapper around shlex.split that is more tolerant of errors
Wrapper around shlex.split that is more tolerant of errors
[ "Wrapper", "around", "shlex", ".", "split", "that", "is", "more", "tolerant", "of", "errors" ]
def split_arguments(args): """Wrapper around shlex.split that is more tolerant of errors""" if not args: # shlex.split seems to hangs when passed the None value return [] return _split_arguments(args)
[ "def", "split_arguments", "(", "args", ")", ":", "if", "not", "args", ":", "# shlex.split seems to hangs when passed the None value", "return", "[", "]", "return", "_split_arguments", "(", "args", ")" ]
https://github.com/lutris/lutris/blob/66675a4d5537f6b2a2ba2b6df0b3cdf8924c823a/lutris/util/strings.py#L162-L167
tensorflow/lingvo
ce10019243d954c3c3ebe739f7589b5eebfdf907
lingvo/core/conv_layers_with_time_padding.py
python
_ComputeConvOutputPaddingV2
(paddings, window, stride, padding_algorithm='SAME')
return out_paddings
Computes paddings for convolution and pooling output. - If padding_algorithm='SAME': out_padding[i] == 0 if the in_padding corresponding to that output is 0. This prevents the output from shrinking unnecessarily when striding. - If padding algorithm='VALID': out_padding[i] == 1 iff any in_padding corresponding to that output is 1. Args: paddings: The paddings tensor. It is expected to be of shape [batch, time]. window: The size of the windows. stride: The time-stride between adjacent windows. padding_algorithm: 'SAME' or 'VALID'. Returns: out_padding, The new padding tensor of size [batch, ceil(time / stride)].
Computes paddings for convolution and pooling output.
[ "Computes", "paddings", "for", "convolution", "and", "pooling", "output", "." ]
def _ComputeConvOutputPaddingV2(paddings, window, stride, padding_algorithm='SAME'): """Computes paddings for convolution and pooling output. - If padding_algorithm='SAME': out_padding[i] == 0 if the in_padding corresponding to that output is 0. This prevents the output from shrinking unnecessarily when striding. - If padding algorithm='VALID': out_padding[i] == 1 iff any in_padding corresponding to that output is 1. Args: paddings: The paddings tensor. It is expected to be of shape [batch, time]. window: The size of the windows. stride: The time-stride between adjacent windows. padding_algorithm: 'SAME' or 'VALID'. Returns: out_padding, The new padding tensor of size [batch, ceil(time / stride)]. """ if stride == 1 and padding_algorithm == 'SAME': return paddings paddings, slice_len = _PadForLengthCompatibleStridesV2( paddings, stride, padding_algorithm, 1.0) expanded_paddings = tf.expand_dims(paddings, -1) if padding_algorithm == 'SAME': # Using a strided conv1d of size 1x1 we find all non-padded positions for # the specified stride. out_paddings = tf.nn.conv1d( expanded_paddings, filters=tf.ones([1, 1, 1], paddings.dtype), stride=stride, padding='SAME', name='padding_conv') elif padding_algorithm == 'VALID': out_paddings = tf.nn.pool( expanded_paddings, [window], 'MAX', padding=padding_algorithm, strides=[stride]) out_paddings = tf.squeeze(out_paddings, -1) if stride > 1: slice_end = py_utils.GetShape(out_paddings)[1] - slice_len out_paddings = out_paddings[:, :slice_end] return out_paddings
[ "def", "_ComputeConvOutputPaddingV2", "(", "paddings", ",", "window", ",", "stride", ",", "padding_algorithm", "=", "'SAME'", ")", ":", "if", "stride", "==", "1", "and", "padding_algorithm", "==", "'SAME'", ":", "return", "paddings", "paddings", ",", "slice_len"...
https://github.com/tensorflow/lingvo/blob/ce10019243d954c3c3ebe739f7589b5eebfdf907/lingvo/core/conv_layers_with_time_padding.py#L142-L190
PaddlePaddle/PaddleX
2bab73f81ab54e328204e7871e6ae4a82e719f5d
paddlex/ppdet/engine/callbacks.py
python
WiferFaceEval.on_epoch_begin
(self, status)
[]
def on_epoch_begin(self, status): assert self.model.mode == 'eval', \ "WiferFaceEval can only be set during evaluation" for metric in self.model._metrics: metric.update(self.model.model) sys.exit()
[ "def", "on_epoch_begin", "(", "self", ",", "status", ")", ":", "assert", "self", ".", "model", ".", "mode", "==", "'eval'", ",", "\"WiferFaceEval can only be set during evaluation\"", "for", "metric", "in", "self", ".", "model", ".", "_metrics", ":", "metric", ...
https://github.com/PaddlePaddle/PaddleX/blob/2bab73f81ab54e328204e7871e6ae4a82e719f5d/paddlex/ppdet/engine/callbacks.py#L218-L223
lykoss/lykos
7859cb530b66e782b3cc32f0d7d60d1c55d4fef5
src/hooks.py
python
end_banlist
(cli, server, bot_nick, chan, message)
Handle the end of the ban list. Ordering and meaning of arguments for the end of ban list: 0 - The IRCClient instance (like everywhere else) 1 - The server the requester (i.e. the bot) is on 2 - The nickname of the requester (i.e. the bot) 3 - The channel holding the ban list 4 - A string containing some information; traditionally "End of Channel Ban List."
Handle the end of the ban list.
[ "Handle", "the", "end", "of", "the", "ban", "list", "." ]
def end_banlist(cli, server, bot_nick, chan, message): """Handle the end of the ban list. Ordering and meaning of arguments for the end of ban list: 0 - The IRCClient instance (like everywhere else) 1 - The server the requester (i.e. the bot) is on 2 - The nickname of the requester (i.e. the bot) 3 - The channel holding the ban list 4 - A string containing some information; traditionally "End of Channel Ban List." """ handle_endlistmode(cli, chan, "b")
[ "def", "end_banlist", "(", "cli", ",", "server", ",", "bot_nick", ",", "chan", ",", "message", ")", ":", "handle_endlistmode", "(", "cli", ",", "chan", ",", "\"b\"", ")" ]
https://github.com/lykoss/lykos/blob/7859cb530b66e782b3cc32f0d7d60d1c55d4fef5/src/hooks.py#L551-L564
python-trio/trio
4edfd41bd5519a2e626e87f6c6ca9fb32b90a6f4
trio/_core/_ki.py
python
currently_ki_protected
()
return ki_protection_enabled(sys._getframe())
r"""Check whether the calling code has :exc:`KeyboardInterrupt` protection enabled. It's surprisingly easy to think that one's :exc:`KeyboardInterrupt` protection is enabled when it isn't, or vice-versa. This function tells you what Trio thinks of the matter, which makes it useful for ``assert``\s and unit tests. Returns: bool: True if protection is enabled, and False otherwise.
r"""Check whether the calling code has :exc:`KeyboardInterrupt` protection enabled.
[ "r", "Check", "whether", "the", "calling", "code", "has", ":", "exc", ":", "KeyboardInterrupt", "protection", "enabled", "." ]
def currently_ki_protected(): r"""Check whether the calling code has :exc:`KeyboardInterrupt` protection enabled. It's surprisingly easy to think that one's :exc:`KeyboardInterrupt` protection is enabled when it isn't, or vice-versa. This function tells you what Trio thinks of the matter, which makes it useful for ``assert``\s and unit tests. Returns: bool: True if protection is enabled, and False otherwise. """ return ki_protection_enabled(sys._getframe())
[ "def", "currently_ki_protected", "(", ")", ":", "return", "ki_protection_enabled", "(", "sys", ".", "_getframe", "(", ")", ")" ]
https://github.com/python-trio/trio/blob/4edfd41bd5519a2e626e87f6c6ca9fb32b90a6f4/trio/_core/_ki.py#L96-L109
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/states/win_servermanager.py
python
installed
( name, features=None, recurse=False, restart=False, source=None, exclude=None, **kwargs )
return ret
Install the windows feature. To install a single feature, use the ``name`` parameter. To install multiple features, use the ``features`` parameter. .. note:: Some features require reboot after un/installation. If so, until the server is restarted other features can not be installed! Args: name (str): Short name of the feature (the right column in win_servermanager.list_available). This can be a single feature or a string of features in a comma delimited list (no spaces) .. note:: A list is not allowed in the name parameter of any state. Use the ``features`` parameter if you want to pass the features as a list features (Optional[list]): A list of features to install. If this is passed it will be used instead of the ``name`` parameter. .. versionadded:: 2018.3.0 recurse (Optional[bool]): Install all sub-features as well. If the feature is installed but one of its sub-features are not installed set this will install additional sub-features. This argument was previously renamed from ``force``. To ensure backwards compatibility ``force`` will continue to work but please update your states to use the preferred ``recurse`` arg. source (Optional[str]): Path to the source files if missing from the target system. None means that the system will use windows update services to find the required files. Default is None restart (Optional[bool]): Restarts the computer when installation is complete, if required by the role/feature installed. Default is False exclude (Optional[str]): The name of the feature to exclude when installing the named feature. This can be a single feature, a string of features in a comma-delimited list (no spaces), or a list of features. .. warning:: As there is no exclude option for the ``Add-WindowsFeature`` or ``Install-WindowsFeature`` PowerShell commands the features named in ``exclude`` will be installed with other sub-features and will then be removed. **If the feature named in ``exclude`` is not a sub-feature of one of the installed items it will still be removed.** Example: Do not use the role or feature names mentioned in the PKGMGR documentation. To get a list of available roles and features run the following command: .. code-block:: bash salt <minion_name> win_servermanager.list_available Use the name in the right column of the results. .. code-block:: yaml # Installs the IIS Web Server Role (Web-Server) IIS-WebServerRole: win_servermanager.installed: - recurse: True - name: Web-Server # Install multiple features, exclude the Web-Service install_multiple_features: win_servermanager.installed: - recurse: True - features: - RemoteAccess - XPS-Viewer - SNMP-Service - exclude: - Web-Server
Install the windows feature. To install a single feature, use the ``name`` parameter. To install multiple features, use the ``features`` parameter.
[ "Install", "the", "windows", "feature", ".", "To", "install", "a", "single", "feature", "use", "the", "name", "parameter", ".", "To", "install", "multiple", "features", "use", "the", "features", "parameter", "." ]
def installed( name, features=None, recurse=False, restart=False, source=None, exclude=None, **kwargs ): """ Install the windows feature. To install a single feature, use the ``name`` parameter. To install multiple features, use the ``features`` parameter. .. note:: Some features require reboot after un/installation. If so, until the server is restarted other features can not be installed! Args: name (str): Short name of the feature (the right column in win_servermanager.list_available). This can be a single feature or a string of features in a comma delimited list (no spaces) .. note:: A list is not allowed in the name parameter of any state. Use the ``features`` parameter if you want to pass the features as a list features (Optional[list]): A list of features to install. If this is passed it will be used instead of the ``name`` parameter. .. versionadded:: 2018.3.0 recurse (Optional[bool]): Install all sub-features as well. If the feature is installed but one of its sub-features are not installed set this will install additional sub-features. This argument was previously renamed from ``force``. To ensure backwards compatibility ``force`` will continue to work but please update your states to use the preferred ``recurse`` arg. source (Optional[str]): Path to the source files if missing from the target system. None means that the system will use windows update services to find the required files. Default is None restart (Optional[bool]): Restarts the computer when installation is complete, if required by the role/feature installed. Default is False exclude (Optional[str]): The name of the feature to exclude when installing the named feature. This can be a single feature, a string of features in a comma-delimited list (no spaces), or a list of features. .. warning:: As there is no exclude option for the ``Add-WindowsFeature`` or ``Install-WindowsFeature`` PowerShell commands the features named in ``exclude`` will be installed with other sub-features and will then be removed. **If the feature named in ``exclude`` is not a sub-feature of one of the installed items it will still be removed.** Example: Do not use the role or feature names mentioned in the PKGMGR documentation. To get a list of available roles and features run the following command: .. code-block:: bash salt <minion_name> win_servermanager.list_available Use the name in the right column of the results. .. code-block:: yaml # Installs the IIS Web Server Role (Web-Server) IIS-WebServerRole: win_servermanager.installed: - recurse: True - name: Web-Server # Install multiple features, exclude the Web-Service install_multiple_features: win_servermanager.installed: - recurse: True - features: - RemoteAccess - XPS-Viewer - SNMP-Service - exclude: - Web-Server """ if "force" in kwargs: kwargs.pop("force") ret = {"name": name, "result": True, "changes": {}, "comment": ""} # Check if features is not passed, use name. Split commas if features is None: features = name.split(",") # Make sure features is a list, split commas if not isinstance(features, list): features = features.split(",") # Determine if the feature is installed old = __salt__["win_servermanager.list_installed"]() cur_feat = [] for feature in features: if feature not in old: ret["changes"][feature] = "Will be installed recurse={}".format(recurse) elif recurse: ret["changes"][feature] = "Already installed but might install sub-features" else: cur_feat.append(feature) if cur_feat: cur_feat.insert(0, "The following features are already installed:") ret["comment"] = "\n- ".join(cur_feat) if not ret["changes"]: return ret if __opts__["test"]: ret["result"] = None return ret # Install the features status = __salt__["win_servermanager.install"]( features, recurse=recurse, restart=restart, source=source, exclude=exclude ) ret["result"] = status["Success"] # Show items failed to install fail_feat = [] new_feat = [] rem_feat = [] for feature in status["Features"]: # Features that failed to install or be removed if not status["Features"][feature].get("Success", True): fail_feat.append("- {}".format(feature)) # Features that installed elif "(exclude)" not in status["Features"][feature]["Message"]: new_feat.append("- {}".format(feature)) # Show items that were removed because they were part of `exclude` elif "(exclude)" in status["Features"][feature]["Message"]: rem_feat.append("- {}".format(feature)) if fail_feat: fail_feat.insert(0, "Failed to install the following:") if new_feat: new_feat.insert(0, "Installed the following:") if rem_feat: rem_feat.insert(0, "Removed the following (exclude):") ret["comment"] = "\n".join(fail_feat + new_feat + rem_feat) # Get the changes new = __salt__["win_servermanager.list_installed"]() ret["changes"] = salt.utils.data.compare_dicts(old, new) return ret
[ "def", "installed", "(", "name", ",", "features", "=", "None", ",", "recurse", "=", "False", ",", "restart", "=", "False", ",", "source", "=", "None", ",", "exclude", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "\"force\"", "in", "kwargs", ...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/states/win_servermanager.py#L24-L192
CvvT/dumpDex
92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1
python/idaapi.py
python
set_jumptable_info
(*args)
return _idaapi.set_jumptable_info(*args)
set_jumptable_info(ea, oi)
set_jumptable_info(ea, oi)
[ "set_jumptable_info", "(", "ea", "oi", ")" ]
def set_jumptable_info(*args): """ set_jumptable_info(ea, oi) """ return _idaapi.set_jumptable_info(*args)
[ "def", "set_jumptable_info", "(", "*", "args", ")", ":", "return", "_idaapi", ".", "set_jumptable_info", "(", "*", "args", ")" ]
https://github.com/CvvT/dumpDex/blob/92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1/python/idaapi.py#L6838-L6842
ucbdrive/few-shot-object-detection
148a039af7abce9eff59d5cdece296ad1d2b8aa0
fsdet/evaluation/coco_evaluation.py
python
COCOEvaluator.__init__
(self, dataset_name, cfg, distributed, output_dir=None)
Args: dataset_name (str): name of the dataset to be evaluated. It must have either the following corresponding metadata: "json_file": the path to the COCO format annotation Or it must be in detectron2's standard dataset format so it can be converted to COCO format automatically. cfg (CfgNode): config instance distributed (True): if True, will collect results from all ranks for evaluation. Otherwise, will evaluate the results in the current process. output_dir (str): optional, an output directory to dump results.
Args: dataset_name (str): name of the dataset to be evaluated. It must have either the following corresponding metadata: "json_file": the path to the COCO format annotation Or it must be in detectron2's standard dataset format so it can be converted to COCO format automatically. cfg (CfgNode): config instance distributed (True): if True, will collect results from all ranks for evaluation. Otherwise, will evaluate the results in the current process. output_dir (str): optional, an output directory to dump results.
[ "Args", ":", "dataset_name", "(", "str", ")", ":", "name", "of", "the", "dataset", "to", "be", "evaluated", ".", "It", "must", "have", "either", "the", "following", "corresponding", "metadata", ":", "json_file", ":", "the", "path", "to", "the", "COCO", "...
def __init__(self, dataset_name, cfg, distributed, output_dir=None): """ Args: dataset_name (str): name of the dataset to be evaluated. It must have either the following corresponding metadata: "json_file": the path to the COCO format annotation Or it must be in detectron2's standard dataset format so it can be converted to COCO format automatically. cfg (CfgNode): config instance distributed (True): if True, will collect results from all ranks for evaluation. Otherwise, will evaluate the results in the current process. output_dir (str): optional, an output directory to dump results. """ self._distributed = distributed self._output_dir = output_dir self._dataset_name = dataset_name self._cpu_device = torch.device("cpu") self._logger = logging.getLogger(__name__) self._metadata = MetadataCatalog.get(dataset_name) if not hasattr(self._metadata, "json_file"): self._logger.warning( f"json_file was not found in MetaDataCatalog for '{dataset_name}'" ) cache_path = convert_to_coco_json(dataset_name, output_dir) self._metadata.json_file = cache_path self._is_splits = ( "all" in dataset_name or "base" in dataset_name or "novel" in dataset_name ) # fmt: off self._base_classes = [ 8, 10, 11, 13, 14, 15, 22, 23, 24, 25, 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 65, 70, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, ] # fmt: on json_file = PathManager.get_local_path(self._metadata.json_file) with contextlib.redirect_stdout(io.StringIO()): self._coco_api = COCO(json_file) # Test set json files do not contain annotations (evaluation must be # performed using the COCO evaluation server). self._do_evaluation = "annotations" in self._coco_api.dataset
[ "def", "__init__", "(", "self", ",", "dataset_name", ",", "cfg", ",", "distributed", ",", "output_dir", "=", "None", ")", ":", "self", ".", "_distributed", "=", "distributed", "self", ".", "_output_dir", "=", "output_dir", "self", ".", "_dataset_name", "=", ...
https://github.com/ucbdrive/few-shot-object-detection/blob/148a039af7abce9eff59d5cdece296ad1d2b8aa0/fsdet/evaluation/coco_evaluation.py#L29-L78
chin-gyou/dialogue-utterance-rewriter
5433e43af1b14d7d3a8d2142f26e46db4322c061
batcher.py
python
Batcher.__init__
(self, data_path, vocab, hps, single_pass)
Initialize the batcher. Start threads that process the data into batches. Args: data_path: tf.Example filepattern. vocab: Vocabulary object hps: hyperparameters single_pass: If True, run through the dataset exactly once (useful for when you want to run evaluation on the dev or test set). Otherwise generate random batches indefinitely (useful for training).
Initialize the batcher. Start threads that process the data into batches. Args: data_path: tf.Example filepattern. vocab: Vocabulary object hps: hyperparameters single_pass: If True, run through the dataset exactly once (useful for when you want to run evaluation on the dev or test set). Otherwise generate random batches indefinitely (useful for training).
[ "Initialize", "the", "batcher", ".", "Start", "threads", "that", "process", "the", "data", "into", "batches", ".", "Args", ":", "data_path", ":", "tf", ".", "Example", "filepattern", ".", "vocab", ":", "Vocabulary", "object", "hps", ":", "hyperparameters", "...
def __init__(self, data_path, vocab, hps, single_pass): """Initialize the batcher. Start threads that process the data into batches. Args: data_path: tf.Example filepattern. vocab: Vocabulary object hps: hyperparameters single_pass: If True, run through the dataset exactly once (useful for when you want to run evaluation on the dev or test set). Otherwise generate random batches indefinitely (useful for training). """ self._data_path = data_path self._vocab = vocab self._hps = hps self._single_pass = single_pass # Initialize a queue of Batches waiting to be used, and a queue of Examples waiting to be batched self._batch_queue = Queue.Queue(self.BATCH_QUEUE_MAX) self._example_queue = Queue.Queue( self.BATCH_QUEUE_MAX * self._hps.batch_size) # Different settings depending on whether we're in single_pass mode or not if single_pass: self._num_example_q_threads = 1 # just one thread, so we read through the dataset just once self._num_batch_q_threads = 1 # just one thread to batch examples self._bucketing_cache_size = 1 # only load one batch's worth of examples before bucketing; this essentially means no bucketing self._finished_reading = False # this will tell us when we're finished reading the dataset else: #多线程随机性 self._num_example_q_threads = 1 #16 num threads to fill example queue self._num_batch_q_threads = 1 # 4 num threads to fill batch queue self._bucketing_cache_size = 100 # how many batches-worth of examples to load into cache before bucketing # Start the threads that load the queues self._example_q_threads = [] for _ in xrange(self._num_example_q_threads): self._example_q_threads.append( Thread(target=self.fill_example_queue)) self._example_q_threads[-1].daemon = True self._example_q_threads[-1].start() self._batch_q_threads = [] for _ in xrange(self._num_batch_q_threads): self._batch_q_threads.append(Thread(target=self.fill_batch_queue)) self._batch_q_threads[-1].daemon = True self._batch_q_threads[-1].start() # Start a thread that watches the other threads and restarts them if they're dead if not single_pass: # We don't want a watcher in single_pass mode because the threads shouldn't run forever self._watch_thread = Thread(target=self.watch_threads) self._watch_thread.daemon = True self._watch_thread.start()
[ "def", "__init__", "(", "self", ",", "data_path", ",", "vocab", ",", "hps", ",", "single_pass", ")", ":", "self", ".", "_data_path", "=", "data_path", "self", ".", "_vocab", "=", "vocab", "self", ".", "_hps", "=", "hps", "self", ".", "_single_pass", "=...
https://github.com/chin-gyou/dialogue-utterance-rewriter/blob/5433e43af1b14d7d3a8d2142f26e46db4322c061/batcher.py#L241-L290
JetBrains/python-skeletons
95ad24b666e475998e5d1cc02ed53a2188036167
struct.py
python
Struct.__init__
(self, format)
Create a new Struct object. :type format: bytes | unicode
Create a new Struct object.
[ "Create", "a", "new", "Struct", "object", "." ]
def __init__(self, format): """Create a new Struct object. :type format: bytes | unicode """ self.format = format self.size = 0
[ "def", "__init__", "(", "self", ",", "format", ")", ":", "self", ".", "format", "=", "format", "self", ".", "size", "=", "0" ]
https://github.com/JetBrains/python-skeletons/blob/95ad24b666e475998e5d1cc02ed53a2188036167/struct.py#L69-L75
yuanxiaosc/DeepNude-an-Image-to-Image-technology
87d684ef59d2de4e8b38f66a71cdd392b203ab95
Pix2Pix/conditional_adversarial_model.py
python
downsample
(filters, size, apply_batchnorm=True)
return result
[]
def downsample(filters, size, apply_batchnorm=True): initializer = tf.random_normal_initializer(0., 0.02) result = tf.keras.Sequential() result.add( tf.keras.layers.Conv2D(filters, size, strides=2, padding='same', kernel_initializer=initializer, use_bias=False)) if apply_batchnorm: result.add(tf.keras.layers.BatchNormalization()) result.add(tf.keras.layers.LeakyReLU()) return result
[ "def", "downsample", "(", "filters", ",", "size", ",", "apply_batchnorm", "=", "True", ")", ":", "initializer", "=", "tf", ".", "random_normal_initializer", "(", "0.", ",", "0.02", ")", "result", "=", "tf", ".", "keras", ".", "Sequential", "(", ")", "res...
https://github.com/yuanxiaosc/DeepNude-an-Image-to-Image-technology/blob/87d684ef59d2de4e8b38f66a71cdd392b203ab95/Pix2Pix/conditional_adversarial_model.py#L7-L20
mitogen-hq/mitogen
5b505f524a7ae170fe68613841ab92b299613d3f
mitogen/core.py
python
Latch._on_fork
(cls)
Clean up any files belonging to the parent process after a fork.
Clean up any files belonging to the parent process after a fork.
[ "Clean", "up", "any", "files", "belonging", "to", "the", "parent", "process", "after", "a", "fork", "." ]
def _on_fork(cls): """ Clean up any files belonging to the parent process after a fork. """ cls._cls_idle_socketpairs = [] while cls._cls_all_sockets: cls._cls_all_sockets.pop().close()
[ "def", "_on_fork", "(", "cls", ")", ":", "cls", ".", "_cls_idle_socketpairs", "=", "[", "]", "while", "cls", ".", "_cls_all_sockets", ":", "cls", ".", "_cls_all_sockets", ".", "pop", "(", ")", ".", "close", "(", ")" ]
https://github.com/mitogen-hq/mitogen/blob/5b505f524a7ae170fe68613841ab92b299613d3f/mitogen/core.py#L2525-L2531
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/urllib/request.py
python
URLopener._open_generic_http
(self, connection_factory, url, data)
Make an HTTP connection using connection_class. This is an internal method that should be called from open_http() or open_https(). Arguments: - connection_factory should take a host name and return an HTTPConnection instance. - url is the url to retrieval or a host, relative-path pair. - data is payload for a POST request or None.
Make an HTTP connection using connection_class.
[ "Make", "an", "HTTP", "connection", "using", "connection_class", "." ]
def _open_generic_http(self, connection_factory, url, data): """Make an HTTP connection using connection_class. This is an internal method that should be called from open_http() or open_https(). Arguments: - connection_factory should take a host name and return an HTTPConnection instance. - url is the url to retrieval or a host, relative-path pair. - data is payload for a POST request or None. """ user_passwd = None proxy_passwd= None if isinstance(url, str): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url # check whether the proxy contains authorization information proxy_passwd, host = splituser(host) # now we proceed with the url we want to obtain urltype, rest = splittype(selector) url = rest user_passwd = None if urltype.lower() != 'http': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) if proxy_bypass(realhost): host = realhost #print "proxy via http:", host, selector if not host: raise IOError('http error', 'no host given') if proxy_passwd: proxy_passwd = unquote(proxy_passwd) proxy_auth = base64.b64encode(proxy_passwd.encode()).decode('ascii') else: proxy_auth = None if user_passwd: user_passwd = unquote(user_passwd) auth = base64.b64encode(user_passwd.encode()).decode('ascii') else: auth = None http_conn = connection_factory(host) headers = {} if proxy_auth: headers["Proxy-Authorization"] = "Basic %s" % proxy_auth if auth: headers["Authorization"] = "Basic %s" % auth if realhost: headers["Host"] = realhost # Add Connection:close as we don't support persistent connections yet. # This helps in closing the socket and avoiding ResourceWarning headers["Connection"] = "close" for header, value in self.addheaders: headers[header] = value if data is not None: headers["Content-Type"] = "application/x-www-form-urlencoded" http_conn.request("POST", selector, data, headers) else: http_conn.request("GET", selector, headers=headers) try: response = http_conn.getresponse() except http.client.BadStatusLine: # something went wrong with the HTTP status line raise URLError("http protocol error: bad status line") # According to RFC 2616, "2xx" code indicates that the client's # request was successfully received, understood, and accepted. if 200 <= response.status < 300: return addinfourl(response, response.msg, "http:" + url, response.status) else: return self.http_error( url, response.fp, response.status, response.reason, response.msg, data)
[ "def", "_open_generic_http", "(", "self", ",", "connection_factory", ",", "url", ",", "data", ")", ":", "user_passwd", "=", "None", "proxy_passwd", "=", "None", "if", "isinstance", "(", "url", ",", "str", ")", ":", "host", ",", "selector", "=", "splithost"...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/urllib/request.py#L1620-L1711
willhardy/django-seo
3089686a3c490091315860979ad15ef2527c3e3e
rollyourown/seo/systemviews.py
python
SystemViews.populate
(self)
Populate this list with all views that take no arguments.
Populate this list with all views that take no arguments.
[ "Populate", "this", "list", "with", "all", "views", "that", "take", "no", "arguments", "." ]
def populate(self): """ Populate this list with all views that take no arguments. """ from django.conf import settings from django.core import urlresolvers self.append(("", "")) urlconf = settings.ROOT_URLCONF resolver = urlresolvers.RegexURLResolver(r'^/', urlconf) # Collect base level views for key, value in resolver.reverse_dict.items(): if isinstance(key, basestring): args = value[0][0][1] url = "/" + value[0][0][0] self.append((key, " ".join(key.split("_")))) # Collect namespaces (TODO: merge these two sections into one) for namespace, url in resolver.namespace_dict.items(): for key, value in url[1].reverse_dict.items(): if isinstance(key, basestring): args = value[0][0][1] full_key = '%s:%s' % (namespace, key) self.append((full_key, "%s: %s" % (namespace, " ".join(key.split("_"))))) self.sort()
[ "def", "populate", "(", "self", ")", ":", "from", "django", ".", "conf", "import", "settings", "from", "django", ".", "core", "import", "urlresolvers", "self", ".", "append", "(", "(", "\"\"", ",", "\"\"", ")", ")", "urlconf", "=", "settings", ".", "RO...
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/systemviews.py#L43-L65
cool-RR/python_toolbox
cb9ef64b48f1d03275484d707dc5079b6701ad0c
python_toolbox/third_party/sortedcontainers/sortedlist.py
python
SortedKeyList.__repr__
(self)
return '{0}({1!r}, key={2!r})'.format(type_name, list(self), self._key)
Return string representation of sorted-key list. ``skl.__repr__()`` <==> ``repr(skl)`` :return: string representation
Return string representation of sorted-key list.
[ "Return", "string", "representation", "of", "sorted", "-", "key", "list", "." ]
def __repr__(self): """Return string representation of sorted-key list. ``skl.__repr__()`` <==> ``repr(skl)`` :return: string representation """ type_name = type(self).__name__ return '{0}({1!r}, key={2!r})'.format(type_name, list(self), self._key)
[ "def", "__repr__", "(", "self", ")", ":", "type_name", "=", "type", "(", "self", ")", ".", "__name__", "return", "'{0}({1!r}, key={2!r})'", ".", "format", "(", "type_name", ",", "list", "(", "self", ")", ",", "self", ".", "_key", ")" ]
https://github.com/cool-RR/python_toolbox/blob/cb9ef64b48f1d03275484d707dc5079b6701ad0c/python_toolbox/third_party/sortedcontainers/sortedlist.py#L2530-L2539
OpenMDAO/OpenMDAO-Framework
f2e37b7de3edeaaeb2d251b375917adec059db9b
openmdao.lib/src/openmdao/lib/datatypes/domain/vector.py
python
Vector.flip_z
(self)
Convert to other-handed coordinate system.
Convert to other-handed coordinate system.
[ "Convert", "to", "other", "-", "handed", "coordinate", "system", "." ]
def flip_z(self): """ Convert to other-handed coordinate system. """ if self.z is None: raise AttributeError('flip_z: no Z component') self.z *= -1.
[ "def", "flip_z", "(", "self", ")", ":", "if", "self", ".", "z", "is", "None", ":", "raise", "AttributeError", "(", "'flip_z: no Z component'", ")", "self", ".", "z", "*=", "-", "1." ]
https://github.com/OpenMDAO/OpenMDAO-Framework/blob/f2e37b7de3edeaaeb2d251b375917adec059db9b/openmdao.lib/src/openmdao/lib/datatypes/domain/vector.py#L414-L418
google/nogotofail
7037dcb23f1fc370de784c36dbb24ae93cd5a58d
nogotofail/mitm/blame/app_blame.py
python
Server.prune_old_clients
(self)
Prune old clients that have not been heard from in a long time
Prune old clients that have not been heard from in a long time
[ "Prune", "old", "clients", "that", "have", "not", "been", "heard", "from", "in", "a", "long", "time" ]
def prune_old_clients(self): """Prune old clients that have not been heard from in a long time""" for client in self.clients.values(): if not client.check_timeouts(): self.logger.info("Blame: Client %s timed out", client.address) self.remove_client(client)
[ "def", "prune_old_clients", "(", "self", ")", ":", "for", "client", "in", "self", ".", "clients", ".", "values", "(", ")", ":", "if", "not", "client", ".", "check_timeouts", "(", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Blame: Client %s time...
https://github.com/google/nogotofail/blob/7037dcb23f1fc370de784c36dbb24ae93cd5a58d/nogotofail/mitm/blame/app_blame.py#L431-L436
kanzure/nanoengineer
874e4c9f8a9190f093625b267f9767e19f82e6c4
cad/src/commands/PlayMovie/Ui_MoviePropertyManager.py
python
Ui_MoviePropertyManager.__init__
(self, command)
Constructor for the B{Movie} property manager class that defines its UI. @param command: The parent mode where this Property Manager is used @type command: L{movieMode}
Constructor for the B{Movie} property manager class that defines its UI.
[ "Constructor", "for", "the", "B", "{", "Movie", "}", "property", "manager", "class", "that", "defines", "its", "UI", "." ]
def __init__(self, command): """ Constructor for the B{Movie} property manager class that defines its UI. @param command: The parent mode where this Property Manager is used @type command: L{movieMode} """ _superclass.__init__(self, command) self.showTopRowButtons( PM_DONE_BUTTON | \ PM_CANCEL_BUTTON | \ PM_WHATS_THIS_BUTTON) msg = '' self.MessageGroupBox.insertHtmlMessage(msg, setAsDefault=False)
[ "def", "__init__", "(", "self", ",", "command", ")", ":", "_superclass", ".", "__init__", "(", "self", ",", "command", ")", "self", ".", "showTopRowButtons", "(", "PM_DONE_BUTTON", "|", "PM_CANCEL_BUTTON", "|", "PM_WHATS_THIS_BUTTON", ")", "msg", "=", "''", ...
https://github.com/kanzure/nanoengineer/blob/874e4c9f8a9190f093625b267f9767e19f82e6c4/cad/src/commands/PlayMovie/Ui_MoviePropertyManager.py#L63-L79
MarioVilas/winappdbg
975a088ac54253d0bdef39fe831e82f24b4c11f6
winappdbg/process.py
python
Process.is_address_readable
(self, address)
return mbi.is_readable()
Determines if an address belongs to a commited and readable page. The page may or may not have additional permissions. @note: Returns always C{False} for kernel mode addresses. @type address: int @param address: Memory address to query. @rtype: bool @return: C{True} if the address belongs to a commited and readable page. @raise WindowsError: An exception is raised on error.
Determines if an address belongs to a commited and readable page. The page may or may not have additional permissions.
[ "Determines", "if", "an", "address", "belongs", "to", "a", "commited", "and", "readable", "page", ".", "The", "page", "may", "or", "may", "not", "have", "additional", "permissions", "." ]
def is_address_readable(self, address): """ Determines if an address belongs to a commited and readable page. The page may or may not have additional permissions. @note: Returns always C{False} for kernel mode addresses. @type address: int @param address: Memory address to query. @rtype: bool @return: C{True} if the address belongs to a commited and readable page. @raise WindowsError: An exception is raised on error. """ try: mbi = self.mquery(address) except WindowsError as e: if e.winerror == win32.ERROR_INVALID_PARAMETER: return False raise return mbi.is_readable()
[ "def", "is_address_readable", "(", "self", ",", "address", ")", ":", "try", ":", "mbi", "=", "self", ".", "mquery", "(", "address", ")", "except", "WindowsError", "as", "e", ":", "if", "e", ".", "winerror", "==", "win32", ".", "ERROR_INVALID_PARAMETER", ...
https://github.com/MarioVilas/winappdbg/blob/975a088ac54253d0bdef39fe831e82f24b4c11f6/winappdbg/process.py#L2693-L2715
selfteaching/selfteaching-python-camp
9982ee964b984595e7d664b07c389cddaf158f1e
exercises/1901040047/d08/mymodule/stats_word.py
python
stats_text_cn
(text)
中文词频统计
中文词频统计
[ "中文词频统计" ]
def stats_text_cn(text): '''中文词频统计''' if type(text)!=str: #添加参数型检查。 raise ValueError("文本为非字符串") d = text.replace(',','').replace('-',' ').replace('.','').replace(':','').replace(';','').replace('"','').replace('!','').replace('?','').replace('、','').replace(',','').replace('。','').replace('“','').replace('”','').replace(':','').replace(';','').replace('\n','').replace('!','').replace('?','').replace('/','').replace('*',' ').replace(' ','') d = re.sub("[A-Za-z0-9]", "",d) #借用了这个正则表达式,这里删除了英文单词,因为没有加上^ e = {} for j in d: count = d.count(j) r2 = {j:count} e.update(r2) f = sorted(e.items(),key=lambda x:x[1],reverse=True)#降序排序 print('中文单字统计频率如下: \n',f)
[ "def", "stats_text_cn", "(", "text", ")", ":", "if", "type", "(", "text", ")", "!=", "str", ":", "#添加参数型检查。", "raise", "ValueError", "(", "\"文本为非字符串\")", "", "d", "=", "text", ".", "replace", "(", "','", ",", "''", ")", ".", "replace", "(", "'-'", ...
https://github.com/selfteaching/selfteaching-python-camp/blob/9982ee964b984595e7d664b07c389cddaf158f1e/exercises/1901040047/d08/mymodule/stats_word.py#L75-L89
kubernetes-client/python
47b9da9de2d02b2b7a34fbe05afb44afd130d73a
kubernetes/client/models/v1_pod_condition.py
python
V1PodCondition.last_probe_time
(self)
return self._last_probe_time
Gets the last_probe_time of this V1PodCondition. # noqa: E501 Last time we probed the condition. # noqa: E501 :return: The last_probe_time of this V1PodCondition. # noqa: E501 :rtype: datetime
Gets the last_probe_time of this V1PodCondition. # noqa: E501
[ "Gets", "the", "last_probe_time", "of", "this", "V1PodCondition", ".", "#", "noqa", ":", "E501" ]
def last_probe_time(self): """Gets the last_probe_time of this V1PodCondition. # noqa: E501 Last time we probed the condition. # noqa: E501 :return: The last_probe_time of this V1PodCondition. # noqa: E501 :rtype: datetime """ return self._last_probe_time
[ "def", "last_probe_time", "(", "self", ")", ":", "return", "self", ".", "_last_probe_time" ]
https://github.com/kubernetes-client/python/blob/47b9da9de2d02b2b7a34fbe05afb44afd130d73a/kubernetes/client/models/v1_pod_condition.py#L79-L87
LumaPictures/pymel
fa88a3f4fa18e09bb8aa9bdf4dab53d984bada72
pymel/tools/mel2py/melparse.py
python
p_primary_expression_paren
(t)
primary_expression : LPAREN expression RPAREN
primary_expression : LPAREN expression RPAREN
[ "primary_expression", ":", "LPAREN", "expression", "RPAREN" ]
def p_primary_expression_paren(t): '''primary_expression : LPAREN expression RPAREN''' t[0] = Token(t[1] + t[2] + t[3], t[2].type)
[ "def", "p_primary_expression_paren", "(", "t", ")", ":", "t", "[", "0", "]", "=", "Token", "(", "t", "[", "1", "]", "+", "t", "[", "2", "]", "+", "t", "[", "3", "]", ",", "t", "[", "2", "]", ".", "type", ")" ]
https://github.com/LumaPictures/pymel/blob/fa88a3f4fa18e09bb8aa9bdf4dab53d984bada72/pymel/tools/mel2py/melparse.py#L2624-L2627
sahana/eden
1696fa50e90ce967df69f66b571af45356cc18da
modules/s3/s3forms.py
python
S3SQLInlineLink.validate
(self, form)
Validate this link, currently only checking whether it has a value when required=True Args: form: the form
Validate this link, currently only checking whether it has a value when required=True
[ "Validate", "this", "link", "currently", "only", "checking", "whether", "it", "has", "a", "value", "when", "required", "=", "True" ]
def validate(self, form): """ Validate this link, currently only checking whether it has a value when required=True Args: form: the form """ required = self.options.required if not required: return fname = self._formname(separator = "_") values = form.vars.get(fname) if not values: error = current.T("Value Required") \ if required is True else required form.errors[fname] = error
[ "def", "validate", "(", "self", ",", "form", ")", ":", "required", "=", "self", ".", "options", ".", "required", "if", "not", "required", ":", "return", "fname", "=", "self", ".", "_formname", "(", "separator", "=", "\"_\"", ")", "values", "=", "form",...
https://github.com/sahana/eden/blob/1696fa50e90ce967df69f66b571af45356cc18da/modules/s3/s3forms.py#L4238-L4257
awslabs/autogluon
7309118f2ab1c9519f25acf61a283a95af95842b
tabular/src/autogluon/tabular/learner/abstract_learner.py
python
AbstractLearner.predict
(self, X: DataFrame, model=None, as_pandas=True)
return y_pred
[]
def predict(self, X: DataFrame, model=None, as_pandas=True): if as_pandas: X_index = copy.deepcopy(X.index) else: X_index = None y_pred_proba = self.predict_proba(X=X, model=model, as_pandas=False, as_multiclass=False, inverse_transform=False) problem_type = self.label_cleaner.problem_type_transform or self.problem_type y_pred = get_pred_from_proba(y_pred_proba=y_pred_proba, problem_type=problem_type) if problem_type != QUANTILE: y_pred = self.label_cleaner.inverse_transform(pd.Series(y_pred)) if as_pandas: y_pred.index = X_index y_pred.name = self.label else: y_pred = y_pred.values else: if as_pandas: y_pred = pd.DataFrame(data=y_pred, columns=self.quantile_levels, index=X_index) return y_pred
[ "def", "predict", "(", "self", ",", "X", ":", "DataFrame", ",", "model", "=", "None", ",", "as_pandas", "=", "True", ")", ":", "if", "as_pandas", ":", "X_index", "=", "copy", ".", "deepcopy", "(", "X", ".", "index", ")", "else", ":", "X_index", "="...
https://github.com/awslabs/autogluon/blob/7309118f2ab1c9519f25acf61a283a95af95842b/tabular/src/autogluon/tabular/learner/abstract_learner.py#L175-L193
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
ansible/roles/lib_git/library/git_commit.py
python
GitCLI._config
(self, get_args)
return results
Do a git config --get <get_args>
Do a git config --get <get_args>
[ "Do", "a", "git", "config", "--", "get", "<get_args", ">" ]
def _config(self, get_args): ''' Do a git config --get <get_args> ''' cmd = ["config", '--get', get_args] results = self.git_cmd(cmd, output=True, output_type='raw') return results
[ "def", "_config", "(", "self", ",", "get_args", ")", ":", "cmd", "=", "[", "\"config\"", ",", "'--get'", ",", "get_args", "]", "results", "=", "self", ".", "git_cmd", "(", "cmd", ",", "output", "=", "True", ",", "output_type", "=", "'raw'", ")", "ret...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/ansible/roles/lib_git/library/git_commit.py#L298-L304
Nuitka/Nuitka
39262276993757fa4e299f497654065600453fc9
nuitka/build/inline_copy/lib/scons-2.3.2/SCons/Taskmaster.py
python
Taskmaster._validate_pending_children
(self)
Validate the content of the pending_children set. Assert if an internal error is found. This function is used strictly for debugging the taskmaster by checking that no invariants are violated. It is not used in normal operation. The pending_children set is used to detect cycles in the dependency graph. We call a "pending child" a child that is found in the "pending" state when checking the dependencies of its parent node. A pending child can occur when the Taskmaster completes a loop through a cycle. For example, lets imagine a graph made of three node (A, B and C) making a cycle. The evaluation starts at node A. The taskmaster first consider whether node A's child B is up-to-date. Then, recursively, node B needs to check whether node C is up-to-date. This leaves us with a dependency graph looking like: Next candidate \ \ Node A (Pending) --> Node B(Pending) --> Node C (NoState) ^ | | | +-------------------------------------+ Now, when the Taskmaster examines the Node C's child Node A, it finds that Node A is in the "pending" state. Therefore, Node A is a pending child of node C. Pending children indicate that the Taskmaster has potentially loop back through a cycle. We say potentially because it could also occur when a DAG is evaluated in parallel. For example, consider the following graph: Node A (Pending) --> Node B(Pending) --> Node C (Pending) --> ... | ^ | | +----------> Node D (NoState) --------+ / Next candidate / The Taskmaster first evaluates the nodes A, B, and C and starts building some children of node C. Assuming, that the maximum parallel level has not been reached, the Taskmaster will examine Node D. It will find that Node C is a pending child of Node D. In summary, evaluating a graph with a cycle will always involve a pending child at one point. A pending child might indicate either a cycle or a diamond-shaped DAG. Only a fraction of the nodes ends-up being a "pending child" of another node. This keeps the pending_children set small in practice. We can differentiate between the two cases if we wait until the end of the build. At this point, all the pending children nodes due to a diamond-shaped DAG will have been properly built (or will have failed to build). But, the pending children involved in a cycle will still be in the pending state. The taskmaster removes nodes from the pending_children set as soon as a pending_children node moves out of the pending state. This also helps to keep the pending_children set small.
Validate the content of the pending_children set. Assert if an internal error is found.
[ "Validate", "the", "content", "of", "the", "pending_children", "set", ".", "Assert", "if", "an", "internal", "error", "is", "found", "." ]
def _validate_pending_children(self): """ Validate the content of the pending_children set. Assert if an internal error is found. This function is used strictly for debugging the taskmaster by checking that no invariants are violated. It is not used in normal operation. The pending_children set is used to detect cycles in the dependency graph. We call a "pending child" a child that is found in the "pending" state when checking the dependencies of its parent node. A pending child can occur when the Taskmaster completes a loop through a cycle. For example, lets imagine a graph made of three node (A, B and C) making a cycle. The evaluation starts at node A. The taskmaster first consider whether node A's child B is up-to-date. Then, recursively, node B needs to check whether node C is up-to-date. This leaves us with a dependency graph looking like: Next candidate \ \ Node A (Pending) --> Node B(Pending) --> Node C (NoState) ^ | | | +-------------------------------------+ Now, when the Taskmaster examines the Node C's child Node A, it finds that Node A is in the "pending" state. Therefore, Node A is a pending child of node C. Pending children indicate that the Taskmaster has potentially loop back through a cycle. We say potentially because it could also occur when a DAG is evaluated in parallel. For example, consider the following graph: Node A (Pending) --> Node B(Pending) --> Node C (Pending) --> ... | ^ | | +----------> Node D (NoState) --------+ / Next candidate / The Taskmaster first evaluates the nodes A, B, and C and starts building some children of node C. Assuming, that the maximum parallel level has not been reached, the Taskmaster will examine Node D. It will find that Node C is a pending child of Node D. In summary, evaluating a graph with a cycle will always involve a pending child at one point. A pending child might indicate either a cycle or a diamond-shaped DAG. Only a fraction of the nodes ends-up being a "pending child" of another node. This keeps the pending_children set small in practice. We can differentiate between the two cases if we wait until the end of the build. At this point, all the pending children nodes due to a diamond-shaped DAG will have been properly built (or will have failed to build). But, the pending children involved in a cycle will still be in the pending state. The taskmaster removes nodes from the pending_children set as soon as a pending_children node moves out of the pending state. This also helps to keep the pending_children set small. """ for n in self.pending_children: assert n.state in (NODE_PENDING, NODE_EXECUTING), \ (str(n), StateString[n.state]) assert len(n.waiting_parents) != 0, (str(n), len(n.waiting_parents)) for p in n.waiting_parents: assert p.ref_count > 0, (str(n), str(p), p.ref_count)
[ "def", "_validate_pending_children", "(", "self", ")", ":", "for", "n", "in", "self", ".", "pending_children", ":", "assert", "n", ".", "state", "in", "(", "NODE_PENDING", ",", "NODE_EXECUTING", ")", ",", "(", "str", "(", "n", ")", ",", "StateString", "[...
https://github.com/Nuitka/Nuitka/blob/39262276993757fa4e299f497654065600453fc9/nuitka/build/inline_copy/lib/scons-2.3.2/SCons/Taskmaster.py#L652-L728
pymedusa/Medusa
1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38
lib/pkg_resources/__init__.py
python
fixup_namespace_packages
(path_item, parent=None)
Ensure that previously-declared namespace packages include path_item
Ensure that previously-declared namespace packages include path_item
[ "Ensure", "that", "previously", "-", "declared", "namespace", "packages", "include", "path_item" ]
def fixup_namespace_packages(path_item, parent=None): """Ensure that previously-declared namespace packages include path_item""" _imp.acquire_lock() try: for package in _namespace_packages.get(parent, ()): subpath = _handle_ns(package, path_item) if subpath: fixup_namespace_packages(subpath, package) finally: _imp.release_lock()
[ "def", "fixup_namespace_packages", "(", "path_item", ",", "parent", "=", "None", ")", ":", "_imp", ".", "acquire_lock", "(", ")", "try", ":", "for", "package", "in", "_namespace_packages", ".", "get", "(", "parent", ",", "(", ")", ")", ":", "subpath", "=...
https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/lib/pkg_resources/__init__.py#L2302-L2311
carla-simulator/ros-bridge
dac9e729b70a3db9da665c1fdb843e96e7e25d04
carla_ros_bridge/src/carla_ros_bridge/debug_helper.py
python
DebugHelper.destroy
(self)
Function (override) to destroy this object. Terminate ROS subscriptions :return:
Function (override) to destroy this object.
[ "Function", "(", "override", ")", "to", "destroy", "this", "object", "." ]
def destroy(self): """ Function (override) to destroy this object. Terminate ROS subscriptions :return: """ self.node.logdebug("Destroy DebugHelper") self.debug = None self.node.destroy_subscription(self.marker_subscriber)
[ "def", "destroy", "(", "self", ")", ":", "self", ".", "node", ".", "logdebug", "(", "\"Destroy DebugHelper\"", ")", "self", ".", "debug", "=", "None", "self", ".", "node", ".", "destroy_subscription", "(", "self", ".", "marker_subscriber", ")" ]
https://github.com/carla-simulator/ros-bridge/blob/dac9e729b70a3db9da665c1fdb843e96e7e25d04/carla_ros_bridge/src/carla_ros_bridge/debug_helper.py#L37-L47
nortikin/sverchok
7b460f01317c15f2681bfa3e337c5e7346f3711b
nodes/modifier_change/follow_active_quads.py
python
unwrap_mesh
(verts, faces, active_indexes, uv_verts=None, uv_faces=None, face_mask=None, mode=MODE.even)
return list(uv_vert_out), list(uv_face_out)
Unwrap mesh similar to Blender operator: follow active quad :param verts: list of tuple(float, float, float) :param faces: list of list of int :param active_indexes: list of indexes, arbitrary number :param uv_verts: list of tuple(float, float, float), only XY ate taken in account :param uv_faces: list of list of int, in the same order as faces input :param face_mask: list of bool, for selecting unwrapping faces :param mode: 'even', 'length' or 'average' :return: list of tuple(float, float, float), list of list of int (faces indexes)
Unwrap mesh similar to Blender operator: follow active quad :param verts: list of tuple(float, float, float) :param faces: list of list of int :param active_indexes: list of indexes, arbitrary number :param uv_verts: list of tuple(float, float, float), only XY ate taken in account :param uv_faces: list of list of int, in the same order as faces input :param face_mask: list of bool, for selecting unwrapping faces :param mode: 'even', 'length' or 'average' :return: list of tuple(float, float, float), list of list of int (faces indexes)
[ "Unwrap", "mesh", "similar", "to", "Blender", "operator", ":", "follow", "active", "quad", ":", "param", "verts", ":", "list", "of", "tuple", "(", "float", "float", "float", ")", ":", "param", "faces", ":", "list", "of", "list", "of", "int", ":", "para...
def unwrap_mesh(verts, faces, active_indexes, uv_verts=None, uv_faces=None, face_mask=None, mode=MODE.even): """ Unwrap mesh similar to Blender operator: follow active quad :param verts: list of tuple(float, float, float) :param faces: list of list of int :param active_indexes: list of indexes, arbitrary number :param uv_verts: list of tuple(float, float, float), only XY ate taken in account :param uv_faces: list of list of int, in the same order as faces input :param face_mask: list of bool, for selecting unwrapping faces :param mode: 'even', 'length' or 'average' :return: list of tuple(float, float, float), list of list of int (faces indexes) """ bm = bmesh.new() # create layer for marking unwrapped faces for protection from re unwrapping, should be done before mesh generation used_layer = bm.faces.layers.int.new('uv done') new_verts = bm.verts.new new_faces = bm.faces.new bm_verts = [new_verts(co) for co in verts] bm_faces = [new_faces([bm_verts[i] for i in face]) for face in faces] # get active faces f_acts = [] for ai in active_indexes: if ai < len(faces) and len(bm_faces[ai].verts) == 4 and (True if face_mask is None else face_mask[ai]): f_acts.append(bm_faces[ai]) if not f_acts: raise LookupError("Given indexes point to faces which are not quads" " or does not mark by mask if face mask was given.") # create and apply given UC coordinates to bmesh uv_act = bm.loops.layers.uv.new('node') if uv_verts and uv_faces: for face, uv_face in zip(bm_faces, uv_faces): for loop, uv_i in zip(face.loops, uv_face): loop[uv_act].uv = uv_verts[uv_i][:2] # unwrap active face if they does not have UV map for fa in f_acts: if all([loop[uv_act].uv == Vector((0, 0)) for loop in fa.loops]): for loop, co in zip(fa.loops, ((0, 0), (1, 0), (1, 1), (0, 1))): loop[uv_act].uv = co # Select faces faces = [f for i, f in enumerate(bm_faces) if len(f.verts) == 4 and (True if face_mask is None else face_mask[i])] # prepare help data if mode == MODE.average: edge_lengths = calc_average_length(bm, faces) else: edge_lengths = None # process for fa in f_acts: if fa[used_layer] == 0: walk_face_init(bm, faces, fa) for f_triple in walk_face(fa, used_layer): apply_uv(*f_triple, uv_act, mode, edge_lengths) # prepare output bm.verts.index_update() v_indexes = iter(range(100000000000)) uv_vert_out = (loop[uv_act].uv.to_3d()[:] for face in bm.faces for loop in face.loops) uv_face_out = ([next(v_indexes) for _ in face.verts] for face in bm.faces) return list(uv_vert_out), list(uv_face_out)
[ "def", "unwrap_mesh", "(", "verts", ",", "faces", ",", "active_indexes", ",", "uv_verts", "=", "None", ",", "uv_faces", "=", "None", ",", "face_mask", "=", "None", ",", "mode", "=", "MODE", ".", "even", ")", ":", "bm", "=", "bmesh", ".", "new", "(", ...
https://github.com/nortikin/sverchok/blob/7b460f01317c15f2681bfa3e337c5e7346f3711b/nodes/modifier_change/follow_active_quads.py#L23-L86
googleapis/python-ndb
e780c81cde1016651afbfcad8180d9912722cf1b
google/cloud/ndb/metadata.py
python
Property.key_to_property
(cls, key)
Return the property specified by a given __property__ key. Args: key (key.Key): key whose property name is requested. Returns: str: property specified by key, or None if the key specified only a kind.
Return the property specified by a given __property__ key.
[ "Return", "the", "property", "specified", "by", "a", "given", "__property__", "key", "." ]
def key_to_property(cls, key): """Return the property specified by a given __property__ key. Args: key (key.Key): key whose property name is requested. Returns: str: property specified by key, or None if the key specified only a kind. """ if key.kind() == Kind.KIND_NAME: return None else: return key.id()
[ "def", "key_to_property", "(", "cls", ",", "key", ")", ":", "if", "key", ".", "kind", "(", ")", "==", "Kind", ".", "KIND_NAME", ":", "return", "None", "else", ":", "return", "key", ".", "id", "(", ")" ]
https://github.com/googleapis/python-ndb/blob/e780c81cde1016651afbfcad8180d9912722cf1b/google/cloud/ndb/metadata.py#L228-L241
sqlalchemy/sqlalchemy
eb716884a4abcabae84a6aaba105568e925b7d27
lib/sqlalchemy/event/attr.py
python
_CompoundListener.exec_once_unless_exception
(self, *args, **kw)
Execute this event, but only if it has not been executed already for this collection, or was called by a previous exec_once_unless_exception call and raised an exception. If exec_once was already called, then this method will never run the callable regardless of whether it raised or not. .. versionadded:: 1.3.8
Execute this event, but only if it has not been executed already for this collection, or was called by a previous exec_once_unless_exception call and raised an exception.
[ "Execute", "this", "event", "but", "only", "if", "it", "has", "not", "been", "executed", "already", "for", "this", "collection", "or", "was", "called", "by", "a", "previous", "exec_once_unless_exception", "call", "and", "raised", "an", "exception", "." ]
def exec_once_unless_exception(self, *args, **kw): """Execute this event, but only if it has not been executed already for this collection, or was called by a previous exec_once_unless_exception call and raised an exception. If exec_once was already called, then this method will never run the callable regardless of whether it raised or not. .. versionadded:: 1.3.8 """ if not self._exec_once: self._exec_once_impl(True, *args, **kw)
[ "def", "exec_once_unless_exception", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "not", "self", ".", "_exec_once", ":", "self", ".", "_exec_once_impl", "(", "True", ",", "*", "args", ",", "*", "*", "kw", ")" ]
https://github.com/sqlalchemy/sqlalchemy/blob/eb716884a4abcabae84a6aaba105568e925b7d27/lib/sqlalchemy/event/attr.py#L295-L308
awslabs/autogluon
7309118f2ab1c9519f25acf61a283a95af95842b
core/src/autogluon/core/data/label_cleaner.py
python
LabelCleaner.construct
(problem_type: str, y: Union[Series, np.ndarray, list, DataFrame], y_uncleaned: Union[Series, np.ndarray, list, DataFrame] = None, positive_class=None)
[]
def construct(problem_type: str, y: Union[Series, np.ndarray, list, DataFrame], y_uncleaned: Union[Series, np.ndarray, list, DataFrame] = None, positive_class=None): if problem_type == SOFTCLASS: return LabelCleanerSoftclass(y) y = LabelCleaner._convert_to_valid_series(y) if y_uncleaned is not None: y_uncleaned = LabelCleaner._convert_to_valid_series(y_uncleaned) if problem_type == BINARY: return LabelCleanerBinary(y, positive_class=positive_class) elif problem_type == MULTICLASS: if y_uncleaned is None: y_uncleaned = copy.deepcopy(y) if len(y.unique()) == 2: return LabelCleanerMulticlassToBinary(y, y_uncleaned) else: return LabelCleanerMulticlass(y, y_uncleaned) elif problem_type in [REGRESSION, QUANTILE]: return LabelCleanerDummy(problem_type=problem_type) else: raise NotImplementedError
[ "def", "construct", "(", "problem_type", ":", "str", ",", "y", ":", "Union", "[", "Series", ",", "np", ".", "ndarray", ",", "list", ",", "DataFrame", "]", ",", "y_uncleaned", ":", "Union", "[", "Series", ",", "np", ".", "ndarray", ",", "list", ",", ...
https://github.com/awslabs/autogluon/blob/7309118f2ab1c9519f25acf61a283a95af95842b/core/src/autogluon/core/data/label_cleaner.py#L29-L48
jakelever/kindred
298d4868d9c9babf82d44de1bba2a9874145ce5a
kindred/CandidateRelation.py
python
CandidateRelation.__init__
(self,entities=None,knownTypesAndArgNames=None,sentence=None)
Constructor for Candidate Relation class :param entities: List of entities in relation :param knownTypesAndArgNames: List of tuples with known relation types and argument names associated with this candidate relation :param sentence: Parsed sentence containing the candidate relation :type entities: list of kindred.Entity :type knownTypesAndArgNames: list of tuples (str, list of str) :type sentence: kindred.Sentence
Constructor for Candidate Relation class :param entities: List of entities in relation :param knownTypesAndArgNames: List of tuples with known relation types and argument names associated with this candidate relation :param sentence: Parsed sentence containing the candidate relation :type entities: list of kindred.Entity :type knownTypesAndArgNames: list of tuples (str, list of str) :type sentence: kindred.Sentence
[ "Constructor", "for", "Candidate", "Relation", "class", ":", "param", "entities", ":", "List", "of", "entities", "in", "relation", ":", "param", "knownTypesAndArgNames", ":", "List", "of", "tuples", "with", "known", "relation", "types", "and", "argument", "names...
def __init__(self,entities=None,knownTypesAndArgNames=None,sentence=None): """ Constructor for Candidate Relation class :param entities: List of entities in relation :param knownTypesAndArgNames: List of tuples with known relation types and argument names associated with this candidate relation :param sentence: Parsed sentence containing the candidate relation :type entities: list of kindred.Entity :type knownTypesAndArgNames: list of tuples (str, list of str) :type sentence: kindred.Sentence """ if entities is None: entities = [] if knownTypesAndArgNames is None: knownTypesAndArgNames = [] assert isinstance(entities,list), "entities must be a list of kindred.Entity" for entity in entities: assert isinstance(entity, kindred.Entity), "entities must be a list of kindred.Entity" self.entities = entities knownTypesAndArgNamesError = "knownTypesAndArgNames must be a list of tuples where each (length=2) tuple is the name of the relation and a list of argument names" assert isinstance(knownTypesAndArgNames,list), knownTypesAndArgNamesError for knownTypeAndArgNames in knownTypesAndArgNames: assert isinstance(knownTypeAndArgNames, tuple), knownTypesAndArgNamesError assert len(knownTypeAndArgNames) == 2, knownTypesAndArgNamesError knownType,knownArgNames = knownTypeAndArgNames assert isinstance(knownType, six.string_types), knownTypesAndArgNamesError assert isinstance(knownArgNames,list), knownTypesAndArgNamesError for knownArgName in knownArgNames: assert isinstance(knownArgName, six.string_types), knownTypesAndArgNamesError self.knownTypesAndArgNames = knownTypesAndArgNames assert sentence is None or isinstance(sentence, kindred.Sentence) self.sentence = sentence
[ "def", "__init__", "(", "self", ",", "entities", "=", "None", ",", "knownTypesAndArgNames", "=", "None", ",", "sentence", "=", "None", ")", ":", "if", "entities", "is", "None", ":", "entities", "=", "[", "]", "if", "knownTypesAndArgNames", "is", "None", ...
https://github.com/jakelever/kindred/blob/298d4868d9c9babf82d44de1bba2a9874145ce5a/kindred/CandidateRelation.py#L14-L49
biopython/biopython
2dd97e71762af7b046d7f7f8a4f1e38db6b06c86
Bio/SearchIO/HmmerIO/hmmer2_text.py
python
Hmmer2TextParser.parse_hits
(self)
return hit_placeholders
Parse a HMMER2 hit block, beginning with the hit table.
Parse a HMMER2 hit block, beginning with the hit table.
[ "Parse", "a", "HMMER2", "hit", "block", "beginning", "with", "the", "hit", "table", "." ]
def parse_hits(self): """Parse a HMMER2 hit block, beginning with the hit table.""" hit_placeholders = [] while self.read_next(): if self.line.startswith("Parsed"): break if self.line.find("no hits") > -1: break if ( self.line.startswith("Sequence") or self.line.startswith("Model") or self.line.startswith("-------- ") ): continue fields = self.line.split() id_ = fields.pop(0) domain_obs_num = int(fields.pop()) evalue = float(fields.pop()) bitscore = float(fields.pop()) description = " ".join(fields).strip() hit = _HitPlaceholder() hit.id_ = id_ hit.evalue = evalue hit.bitscore = bitscore hit.description = description hit.domain_obs_num = domain_obs_num hit_placeholders.append(hit) return hit_placeholders
[ "def", "parse_hits", "(", "self", ")", ":", "hit_placeholders", "=", "[", "]", "while", "self", ".", "read_next", "(", ")", ":", "if", "self", ".", "line", ".", "startswith", "(", "\"Parsed\"", ")", ":", "break", "if", "self", ".", "line", ".", "find...
https://github.com/biopython/biopython/blob/2dd97e71762af7b046d7f7f8a4f1e38db6b06c86/Bio/SearchIO/HmmerIO/hmmer2_text.py#L137-L168