repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
oscarbranson/latools | latools/filtering/classifier_obj.py | https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/classifier_obj.py#L110-L137 | def fit_meanshift(self, data, bandwidth=None, bin_seeding=False, **kwargs):
"""
Fit MeanShift clustering algorithm to data.
Parameters
----------
data : array-like
A dataset formatted by `classifier.fitting_data`.
bandwidth : float
The bandwidth v... | [
"def",
"fit_meanshift",
"(",
"self",
",",
"data",
",",
"bandwidth",
"=",
"None",
",",
"bin_seeding",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"bandwidth",
"is",
"None",
":",
"bandwidth",
"=",
"cl",
".",
"estimate_bandwidth",
"(",
"data",
... | Fit MeanShift clustering algorithm to data.
Parameters
----------
data : array-like
A dataset formatted by `classifier.fitting_data`.
bandwidth : float
The bandwidth value used during clustering.
If none, determined automatically. Note:
th... | [
"Fit",
"MeanShift",
"clustering",
"algorithm",
"to",
"data",
"."
] | python | test | 34.928571 |
MolSSI-BSE/basis_set_exchange | basis_set_exchange/manip.py | https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/manip.py#L297-L373 | def make_general(basis, use_copy=True):
"""
Makes one large general contraction for each angular momentum
If use_copy is True, the input basis set is not modified.
The output of this function is not pretty. If you want to make it nicer,
use sort_basis afterwards.
"""
zero = '0.00000000'
... | [
"def",
"make_general",
"(",
"basis",
",",
"use_copy",
"=",
"True",
")",
":",
"zero",
"=",
"'0.00000000'",
"basis",
"=",
"uncontract_spdf",
"(",
"basis",
",",
"0",
",",
"use_copy",
")",
"for",
"k",
",",
"el",
"in",
"basis",
"[",
"'elements'",
"]",
".",
... | Makes one large general contraction for each angular momentum
If use_copy is True, the input basis set is not modified.
The output of this function is not pretty. If you want to make it nicer,
use sort_basis afterwards. | [
"Makes",
"one",
"large",
"general",
"contraction",
"for",
"each",
"angular",
"momentum"
] | python | train | 30.857143 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py#L662-L673 | def vcs_rbridge_config_input_rbridge_id(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
vcs_rbridge_config = ET.Element("vcs_rbridge_config")
config = vcs_rbridge_config
input = ET.SubElement(vcs_rbridge_config, "input")
rbridge_id = ET.S... | [
"def",
"vcs_rbridge_config_input_rbridge_id",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"vcs_rbridge_config",
"=",
"ET",
".",
"Element",
"(",
"\"vcs_rbridge_config\"",
")",
"config",
"=",
"vcs_... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 40.083333 |
cltl/KafNafParserPy | KafNafParserPy/KafNafParserMod.py | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/KafNafParserMod.py#L734-L744 | def remove_dependency_layer(self):
"""
Removes the dependency layer (if exists) of the object (in memory)
"""
if self.dependency_layer is not None:
this_node = self.dependency_layer.get_node()
self.root.remove(this_node)
self.dependency_layer = self.my... | [
"def",
"remove_dependency_layer",
"(",
"self",
")",
":",
"if",
"self",
".",
"dependency_layer",
"is",
"not",
"None",
":",
"this_node",
"=",
"self",
".",
"dependency_layer",
".",
"get_node",
"(",
")",
"self",
".",
"root",
".",
"remove",
"(",
"this_node",
")... | Removes the dependency layer (if exists) of the object (in memory) | [
"Removes",
"the",
"dependency",
"layer",
"(",
"if",
"exists",
")",
"of",
"the",
"object",
"(",
"in",
"memory",
")"
] | python | train | 37.909091 |
authomatic/authomatic | authomatic/providers/__init__.py | https://github.com/authomatic/authomatic/blob/90a9ce60cc405ae8a2bf5c3713acd5d78579a04e/authomatic/providers/__init__.py#L315-L333 | def csrf_generator(secret):
"""
Generates CSRF token.
Inspired by this article:
http://blog.ptsecurity.com/2012/10/random-number-security-in-python.html
:returns:
:class:`str` Random unguessable string.
"""
# Create hash from random string plus sal... | [
"def",
"csrf_generator",
"(",
"secret",
")",
":",
"# Create hash from random string plus salt.",
"hashed",
"=",
"hashlib",
".",
"md5",
"(",
"uuid",
".",
"uuid4",
"(",
")",
".",
"bytes",
"+",
"six",
".",
"b",
"(",
"secret",
")",
")",
".",
"hexdigest",
"(",
... | Generates CSRF token.
Inspired by this article:
http://blog.ptsecurity.com/2012/10/random-number-security-in-python.html
:returns:
:class:`str` Random unguessable string. | [
"Generates",
"CSRF",
"token",
"."
] | python | test | 28.421053 |
daethnir/authprogs | authprogs/authprogs.py | https://github.com/daethnir/authprogs/blob/0b1e13a609ebeabdb0f10d11fc5dc6e0b20c0343/authprogs/authprogs.py#L296-L342 | def find_match_scp(self, rule): # pylint: disable-msg=R0911,R0912
"""Handle scp commands."""
orig_list = []
orig_list.extend(self.original_command_list)
binary = orig_list.pop(0)
allowed_binaries = ['scp', '/usr/bin/scp']
if binary not in allowed_binaries:
s... | [
"def",
"find_match_scp",
"(",
"self",
",",
"rule",
")",
":",
"# pylint: disable-msg=R0911,R0912",
"orig_list",
"=",
"[",
"]",
"orig_list",
".",
"extend",
"(",
"self",
".",
"original_command_list",
")",
"binary",
"=",
"orig_list",
".",
"pop",
"(",
"0",
")",
"... | Handle scp commands. | [
"Handle",
"scp",
"commands",
"."
] | python | train | 34.297872 |
lpomfrey/django-debreach | debreach/utils.py | https://github.com/lpomfrey/django-debreach/blob/b425bb719ea5de583fae7db5b7419e5fed569cb0/debreach/utils.py#L8-L13 | def xor(s, pad):
'''XOR a given string ``s`` with the one-time-pad ``pad``'''
from itertools import cycle
s = bytearray(force_bytes(s, encoding='latin-1'))
pad = bytearray(force_bytes(pad, encoding='latin-1'))
return binary_type(bytearray(x ^ y for x, y in zip(s, cycle(pad)))) | [
"def",
"xor",
"(",
"s",
",",
"pad",
")",
":",
"from",
"itertools",
"import",
"cycle",
"s",
"=",
"bytearray",
"(",
"force_bytes",
"(",
"s",
",",
"encoding",
"=",
"'latin-1'",
")",
")",
"pad",
"=",
"bytearray",
"(",
"force_bytes",
"(",
"pad",
",",
"enc... | XOR a given string ``s`` with the one-time-pad ``pad`` | [
"XOR",
"a",
"given",
"string",
"s",
"with",
"the",
"one",
"-",
"time",
"-",
"pad",
"pad"
] | python | train | 48.666667 |
mabuchilab/QNET | src/qnet/algebra/core/operator_algebra.py | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/operator_algebra.py#L932-L941 | def factor_coeff(cls, ops, kwargs):
"""Factor out coefficients of all factors."""
coeffs, nops = zip(*map(_coeff_term, ops))
coeff = 1
for c in coeffs:
coeff *= c
if coeff == 1:
return nops, coeffs
else:
return coeff * cls.create(*nops, **kwargs) | [
"def",
"factor_coeff",
"(",
"cls",
",",
"ops",
",",
"kwargs",
")",
":",
"coeffs",
",",
"nops",
"=",
"zip",
"(",
"*",
"map",
"(",
"_coeff_term",
",",
"ops",
")",
")",
"coeff",
"=",
"1",
"for",
"c",
"in",
"coeffs",
":",
"coeff",
"*=",
"c",
"if",
... | Factor out coefficients of all factors. | [
"Factor",
"out",
"coefficients",
"of",
"all",
"factors",
"."
] | python | train | 28.5 |
MartinThoma/hwrt | hwrt/create_ffiles.py | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/create_ffiles.py#L267-L299 | def _calculate_feature_stats(feature_list, prepared, serialization_file): # pylint: disable=R0914
"""Calculate min, max and mean for each feature. Store it in object."""
# Create feature only list
feats = [x for x, _ in prepared] # Label is not necessary
# Calculate all means / mins / maxs
means ... | [
"def",
"_calculate_feature_stats",
"(",
"feature_list",
",",
"prepared",
",",
"serialization_file",
")",
":",
"# pylint: disable=R0914",
"# Create feature only list",
"feats",
"=",
"[",
"x",
"for",
"x",
",",
"_",
"in",
"prepared",
"]",
"# Label is not necessary",
"# C... | Calculate min, max and mean for each feature. Store it in object. | [
"Calculate",
"min",
"max",
"and",
"mean",
"for",
"each",
"feature",
".",
"Store",
"it",
"in",
"object",
"."
] | python | train | 41.575758 |
nanoporetech/ont_fast5_api | ont_fast5_api/fast5_file.py | https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L153-L161 | def add_channel_info(self, data, clear=False):
""" Add channel info data to the channel_id group.
:param data: A dictionary of key/value pairs. Keys must be strings.
Values can be strings or numeric values.
:param clear: If set, any existing channel info data will be removed... | [
"def",
"add_channel_info",
"(",
"self",
",",
"data",
",",
"clear",
"=",
"False",
")",
":",
"self",
".",
"assert_writeable",
"(",
")",
"self",
".",
"_add_attributes",
"(",
"self",
".",
"global_key",
"+",
"'channel_id'",
",",
"data",
",",
"clear",
")"
] | Add channel info data to the channel_id group.
:param data: A dictionary of key/value pairs. Keys must be strings.
Values can be strings or numeric values.
:param clear: If set, any existing channel info data will be removed. | [
"Add",
"channel",
"info",
"data",
"to",
"the",
"channel_id",
"group",
".",
":",
"param",
"data",
":",
"A",
"dictionary",
"of",
"key",
"/",
"value",
"pairs",
".",
"Keys",
"must",
"be",
"strings",
".",
"Values",
"can",
"be",
"strings",
"or",
"numeric",
"... | python | train | 48 |
zomux/deepy | examples/lm/lm.py | https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/lm/lm.py#L60-L69 | def sample(self, input, steps):
"""
Sample outputs from LM.
"""
inputs = [[onehot(self.input_dim, x) for x in input]]
for _ in range(steps):
target = self.compute(inputs)[0,-1].argmax()
input.append(target)
inputs[0].append(onehot(self.input_di... | [
"def",
"sample",
"(",
"self",
",",
"input",
",",
"steps",
")",
":",
"inputs",
"=",
"[",
"[",
"onehot",
"(",
"self",
".",
"input_dim",
",",
"x",
")",
"for",
"x",
"in",
"input",
"]",
"]",
"for",
"_",
"in",
"range",
"(",
"steps",
")",
":",
"target... | Sample outputs from LM. | [
"Sample",
"outputs",
"from",
"LM",
"."
] | python | test | 34.3 |
googlefonts/glyphsLib | Lib/glyphsLib/glyphdata.py | https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L158-L164 | def _agl_compliant_name(glyph_name):
"""Return an AGL-compliant name string or None if we can't make one."""
MAX_GLYPH_NAME_LENGTH = 63
clean_name = re.sub("[^0-9a-zA-Z_.]", "", glyph_name)
if len(clean_name) > MAX_GLYPH_NAME_LENGTH:
return None
return clean_name | [
"def",
"_agl_compliant_name",
"(",
"glyph_name",
")",
":",
"MAX_GLYPH_NAME_LENGTH",
"=",
"63",
"clean_name",
"=",
"re",
".",
"sub",
"(",
"\"[^0-9a-zA-Z_.]\"",
",",
"\"\"",
",",
"glyph_name",
")",
"if",
"len",
"(",
"clean_name",
")",
">",
"MAX_GLYPH_NAME_LENGTH",... | Return an AGL-compliant name string or None if we can't make one. | [
"Return",
"an",
"AGL",
"-",
"compliant",
"name",
"string",
"or",
"None",
"if",
"we",
"can",
"t",
"make",
"one",
"."
] | python | train | 40.714286 |
python-astrodynamics/spacetrack | shovel/docs.py | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/shovel/docs.py#L18-L31 | def watch():
"""Renerate documentation when it changes."""
# Start with a clean build
sphinx_build['-b', 'html', '-E', 'docs', 'docs/_build/html'] & FG
handler = ShellCommandTrick(
shell_command='sphinx-build -b html docs docs/_build/html',
patterns=['*.rst', '*.py'],
ignore_pa... | [
"def",
"watch",
"(",
")",
":",
"# Start with a clean build",
"sphinx_build",
"[",
"'-b'",
",",
"'html'",
",",
"'-E'",
",",
"'docs'",
",",
"'docs/_build/html'",
"]",
"&",
"FG",
"handler",
"=",
"ShellCommandTrick",
"(",
"shell_command",
"=",
"'sphinx-build -b html d... | Renerate documentation when it changes. | [
"Renerate",
"documentation",
"when",
"it",
"changes",
"."
] | python | train | 35.214286 |
saltstack/salt | salt/runners/cache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/cache.py#L33-L74 | def grains(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached grains of the targeted minions.
tgt
Target to match minion ids.
.. vers... | [
"def",
"grains",
"(",
"tgt",
"=",
"None",
",",
"tgt_type",
"=",
"'glob'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"tgt",
"is",
"None",
":",
"# Change ``tgt=None`` to ``tgt`` (mandatory kwarg) in Salt Sodium.",
"# This behavior was changed in PR #45588 to fix Issue #45489... | .. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached grains of the targeted minions.
tgt
Target to match minion ids.
.. versionchanged:: 2017.7.5,2018.3.0
The ``tgt`` argume... | [
"..",
"versionchanged",
"::",
"2017",
".",
"7",
".",
"0",
"The",
"expr_form",
"argument",
"has",
"been",
"renamed",
"to",
"tgt_type",
"earlier",
"releases",
"must",
"use",
"expr_form",
"."
] | python | train | 37.142857 |
neurodata/ndio | ndio/convert/tiff.py | https://github.com/neurodata/ndio/blob/792dd5816bc770b05a3db2f4327da42ff6253531/ndio/convert/tiff.py#L8-L28 | def load(tiff_filename):
"""
Import a TIFF file into a numpy array.
Arguments:
tiff_filename: A string filename of a TIFF datafile
Returns:
A numpy array with data from the TIFF file
"""
# Expand filename to be absolute
tiff_filename = os.path.expanduser(tiff_filename)
... | [
"def",
"load",
"(",
"tiff_filename",
")",
":",
"# Expand filename to be absolute",
"tiff_filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"tiff_filename",
")",
"try",
":",
"img",
"=",
"tiff",
".",
"imread",
"(",
"tiff_filename",
")",
"except",
"Excep... | Import a TIFF file into a numpy array.
Arguments:
tiff_filename: A string filename of a TIFF datafile
Returns:
A numpy array with data from the TIFF file | [
"Import",
"a",
"TIFF",
"file",
"into",
"a",
"numpy",
"array",
"."
] | python | test | 25.380952 |
hazelcast/hazelcast-python-client | hazelcast/proxy/atomic_reference.py | https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/atomic_reference.py#L69-L78 | def contains(self, expected):
"""
Checks if the reference contains the value.
:param expected: (object), the value to check (is allowed to be ``None``).
:return: (bool), ``true`` if the value is found, ``false`` otherwise.
"""
return self._encode_invoke(atomic_reference... | [
"def",
"contains",
"(",
"self",
",",
"expected",
")",
":",
"return",
"self",
".",
"_encode_invoke",
"(",
"atomic_reference_contains_codec",
",",
"expected",
"=",
"self",
".",
"_to_data",
"(",
"expected",
")",
")"
] | Checks if the reference contains the value.
:param expected: (object), the value to check (is allowed to be ``None``).
:return: (bool), ``true`` if the value is found, ``false`` otherwise. | [
"Checks",
"if",
"the",
"reference",
"contains",
"the",
"value",
"."
] | python | train | 39.6 |
xzased/lvm2py | lvm2py/lvm.py | https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L159-L198 | def create_vg(self, name, devices):
"""
Returns a new instance of VolumeGroup with the given name and added physycal
volumes (devices)::
from lvm2py import *
lvm = LVM()
vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"])
*Args:*
* ... | [
"def",
"create_vg",
"(",
"self",
",",
"name",
",",
"devices",
")",
":",
"self",
".",
"open",
"(",
")",
"vgh",
"=",
"lvm_vg_create",
"(",
"self",
".",
"handle",
",",
"name",
")",
"if",
"not",
"bool",
"(",
"vgh",
")",
":",
"self",
".",
"close",
"("... | Returns a new instance of VolumeGroup with the given name and added physycal
volumes (devices)::
from lvm2py import *
lvm = LVM()
vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"])
*Args:*
* name (str): A volume group name.
* ... | [
"Returns",
"a",
"new",
"instance",
"of",
"VolumeGroup",
"with",
"the",
"given",
"name",
"and",
"added",
"physycal",
"volumes",
"(",
"devices",
")",
"::"
] | python | train | 32.125 |
pyrogram/pyrogram | pyrogram/client/methods/chats/kick_chat_member.py | https://github.com/pyrogram/pyrogram/blob/e7258a341ba905cfa86264c22040654db732ec1c/pyrogram/client/methods/chats/kick_chat_member.py#L27-L99 | def kick_chat_member(
self,
chat_id: Union[int, str],
user_id: Union[int, str],
until_date: int = 0
) -> Union["pyrogram.Message", bool]:
"""Use this method to kick a user from a group, a supergroup or a channel.
In the case of supergroups and channels, the user will ... | [
"def",
"kick_chat_member",
"(",
"self",
",",
"chat_id",
":",
"Union",
"[",
"int",
",",
"str",
"]",
",",
"user_id",
":",
"Union",
"[",
"int",
",",
"str",
"]",
",",
"until_date",
":",
"int",
"=",
"0",
")",
"->",
"Union",
"[",
"\"pyrogram.Message\"",
",... | Use this method to kick a user from a group, a supergroup or a channel.
In the case of supergroups and channels, the user will not be able to return to the group on their own using
invite links, etc., unless unbanned first. You must be an administrator in the chat for this to work and must
have ... | [
"Use",
"this",
"method",
"to",
"kick",
"a",
"user",
"from",
"a",
"group",
"a",
"supergroup",
"or",
"a",
"channel",
".",
"In",
"the",
"case",
"of",
"supergroups",
"and",
"channels",
"the",
"user",
"will",
"not",
"be",
"able",
"to",
"return",
"to",
"the"... | python | train | 41.219178 |
tensorflow/tensor2tensor | tensor2tensor/layers/message_passing_attention.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/message_passing_attention.py#L431-L511 | def sparse_message_pass(node_states,
adjacency_matrices,
num_edge_types,
hidden_size,
use_bias=True,
average_aggregation=False,
name="sparse_ggnn"):
"""One message-passing st... | [
"def",
"sparse_message_pass",
"(",
"node_states",
",",
"adjacency_matrices",
",",
"num_edge_types",
",",
"hidden_size",
",",
"use_bias",
"=",
"True",
",",
"average_aggregation",
"=",
"False",
",",
"name",
"=",
"\"sparse_ggnn\"",
")",
":",
"n",
"=",
"tf",
".",
... | One message-passing step for a GNN with a sparse adjacency matrix.
Implements equation 2 (the message passing step) in
[Li et al. 2015](https://arxiv.org/abs/1511.05493).
N = The number of nodes in each batch.
H = The size of the hidden states.
T = The number of edge types.
Args:
node_states: Initial... | [
"One",
"message",
"-",
"passing",
"step",
"for",
"a",
"GNN",
"with",
"a",
"sparse",
"adjacency",
"matrix",
"."
] | python | train | 45.901235 |
OpenGov/python_data_wrap | datawrap/external/xmlparse.py | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/external/xmlparse.py#L349-L356 | def DumpAsCSV (self, separator=",", file=sys.stdout):
"""dump as a comma separated value file"""
for row in range(1, self.maxRow + 1):
sep = ""
for column in range(1, self.maxColumn + 1):
file.write("%s\... | [
"def",
"DumpAsCSV",
"(",
"self",
",",
"separator",
"=",
"\",\"",
",",
"file",
"=",
"sys",
".",
"stdout",
")",
":",
"for",
"row",
"in",
"range",
"(",
"1",
",",
"self",
".",
"maxRow",
"+",
"1",
")",
":",
"sep",
"=",
"\"\"",
"for",
"column",
"in",
... | dump as a comma separated value file | [
"dump",
"as",
"a",
"comma",
"separated",
"value",
"file"
] | python | train | 56.875 |
doconix/django-mako-plus | django_mako_plus/converter/converters.py | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L133-L147 | def convert_date(value, parameter):
'''
Converts to datetime.date:
'', '-', None convert to parameter default
The first matching format in settings.DATE_INPUT_FORMATS converts to datetime
'''
value = _check_default(value, parameter, ( '', '-', None ))
if value is None or isinstance(v... | [
"def",
"convert_date",
"(",
"value",
",",
"parameter",
")",
":",
"value",
"=",
"_check_default",
"(",
"value",
",",
"parameter",
",",
"(",
"''",
",",
"'-'",
",",
"None",
")",
")",
"if",
"value",
"is",
"None",
"or",
"isinstance",
"(",
"value",
",",
"d... | Converts to datetime.date:
'', '-', None convert to parameter default
The first matching format in settings.DATE_INPUT_FORMATS converts to datetime | [
"Converts",
"to",
"datetime",
".",
"date",
":",
"-",
"None",
"convert",
"to",
"parameter",
"default",
"The",
"first",
"matching",
"format",
"in",
"settings",
".",
"DATE_INPUT_FORMATS",
"converts",
"to",
"datetime"
] | python | train | 41.933333 |
Jaymon/captain | captain/parse.py | https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/parse.py#L454-L497 | def parse_callback_args(self, raw_args):
"""This is the method that is called from Script.run(), this is the insertion
point for parsing all the arguments though on init this will find all args it
can, so this method pulls already found args from class variables"""
args = []
arg_... | [
"def",
"parse_callback_args",
"(",
"self",
",",
"raw_args",
")",
":",
"args",
"=",
"[",
"]",
"arg_info",
"=",
"self",
".",
"arg_info",
"kwargs",
"=",
"dict",
"(",
"arg_info",
"[",
"'optional'",
"]",
")",
"parsed_args",
"=",
"[",
"]",
"unknown_args",
"=",... | This is the method that is called from Script.run(), this is the insertion
point for parsing all the arguments though on init this will find all args it
can, so this method pulls already found args from class variables | [
"This",
"is",
"the",
"method",
"that",
"is",
"called",
"from",
"Script",
".",
"run",
"()",
"this",
"is",
"the",
"insertion",
"point",
"for",
"parsing",
"all",
"the",
"arguments",
"though",
"on",
"init",
"this",
"will",
"find",
"all",
"args",
"it",
"can",... | python | valid | 39.340909 |
JIC-CSB/jicimagelib | jicimagelib/image.py | https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/image.py#L266-L301 | def load(self, fpath):
"""Load a microscopy file.
:param fpath: path to microscopy file
"""
def is_microscopy_item(fpath):
"""Return True if the fpath is likely to be microscopy data.
:param fpath: file path to image
:returns: :class:`bool`
... | [
"def",
"load",
"(",
"self",
",",
"fpath",
")",
":",
"def",
"is_microscopy_item",
"(",
"fpath",
")",
":",
"\"\"\"Return True if the fpath is likely to be microscopy data.\n\n :param fpath: file path to image\n :returns: :class:`bool`\n \"\"\"",
"l",
"=... | Load a microscopy file.
:param fpath: path to microscopy file | [
"Load",
"a",
"microscopy",
"file",
".",
":",
"param",
"fpath",
":",
"path",
"to",
"microscopy",
"file"
] | python | train | 31.5 |
UDST/orca | orca/server/server.py | https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L274-L285 | def column_preview(table_name, col_name):
"""
Return the first ten elements of a column as JSON in Pandas'
"split" format.
"""
col = orca.get_table(table_name).get_column(col_name).head(10)
return (
col.to_json(orient='split', date_format='iso'),
200,
{'Content-Type': '... | [
"def",
"column_preview",
"(",
"table_name",
",",
"col_name",
")",
":",
"col",
"=",
"orca",
".",
"get_table",
"(",
"table_name",
")",
".",
"get_column",
"(",
"col_name",
")",
".",
"head",
"(",
"10",
")",
"return",
"(",
"col",
".",
"to_json",
"(",
"orien... | Return the first ten elements of a column as JSON in Pandas'
"split" format. | [
"Return",
"the",
"first",
"ten",
"elements",
"of",
"a",
"column",
"as",
"JSON",
"in",
"Pandas",
"split",
"format",
"."
] | python | train | 27.333333 |
bitesofcode/projexui | projexui/widgets/xorbbrowserwidget/xorbbrowserwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbbrowserwidget/xorbbrowserwidget.py#L392-L399 | def handleThumbDblClick( self, item ):
"""
Handles when a thumbnail item is double clicked on.
:param item | <QListWidgetItem>
"""
if ( isinstance(item, RecordListWidgetItem) ):
self.emitRecordDoubleClicked(item.record()) | [
"def",
"handleThumbDblClick",
"(",
"self",
",",
"item",
")",
":",
"if",
"(",
"isinstance",
"(",
"item",
",",
"RecordListWidgetItem",
")",
")",
":",
"self",
".",
"emitRecordDoubleClicked",
"(",
"item",
".",
"record",
"(",
")",
")"
] | Handles when a thumbnail item is double clicked on.
:param item | <QListWidgetItem> | [
"Handles",
"when",
"a",
"thumbnail",
"item",
"is",
"double",
"clicked",
"on",
".",
":",
"param",
"item",
"|",
"<QListWidgetItem",
">"
] | python | train | 35.875 |
PMEAL/OpenPNM | openpnm/algorithms/OrdinaryPercolation.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/algorithms/OrdinaryPercolation.py#L460-L474 | def plot_intrusion_curve(self, fig=None):
r"""
Plot the percolation curve as the invader volume or number fraction vs
the applied capillary pressure.
"""
# Begin creating nicely formatted plot
x, y = self.get_intrusion_data()
if fig is None:
fig = plt... | [
"def",
"plot_intrusion_curve",
"(",
"self",
",",
"fig",
"=",
"None",
")",
":",
"# Begin creating nicely formatted plot",
"x",
",",
"y",
"=",
"self",
".",
"get_intrusion_data",
"(",
")",
"if",
"fig",
"is",
"None",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",... | r"""
Plot the percolation curve as the invader volume or number fraction vs
the applied capillary pressure. | [
"r",
"Plot",
"the",
"percolation",
"curve",
"as",
"the",
"invader",
"volume",
"or",
"number",
"fraction",
"vs",
"the",
"applied",
"capillary",
"pressure",
"."
] | python | train | 32 |
closeio/tasktiger | tasktiger/worker.py | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L425-L554 | def _execute(self, queue, tasks, log, locks, queue_lock, all_task_ids):
"""
Executes the given tasks. Returns a boolean indicating whether
the tasks were executed successfully.
"""
# The tasks must use the same function.
assert len(tasks)
task_func = tasks[0].ser... | [
"def",
"_execute",
"(",
"self",
",",
"queue",
",",
"tasks",
",",
"log",
",",
"locks",
",",
"queue_lock",
",",
"all_task_ids",
")",
":",
"# The tasks must use the same function.",
"assert",
"len",
"(",
"tasks",
")",
"task_func",
"=",
"tasks",
"[",
"0",
"]",
... | Executes the given tasks. Returns a boolean indicating whether
the tasks were executed successfully. | [
"Executes",
"the",
"given",
"tasks",
".",
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"tasks",
"were",
"executed",
"successfully",
"."
] | python | train | 41.953846 |
cloudmesh/cloudmesh-common | cloudmesh/common/util.py | https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L219-L236 | def HEADING(txt=None, c="#"):
"""
Prints a message to stdout with #### surrounding it. This is useful for
nosetests to better distinguish them.
:param c: uses the given char to wrap the header
:param txt: a text message to be printed
:type txt: string
"""
frame = inspect.getouterframes(... | [
"def",
"HEADING",
"(",
"txt",
"=",
"None",
",",
"c",
"=",
"\"#\"",
")",
":",
"frame",
"=",
"inspect",
".",
"getouterframes",
"(",
"inspect",
".",
"currentframe",
"(",
")",
")",
"filename",
"=",
"frame",
"[",
"1",
"]",
"[",
"1",
"]",
".",
"replace",... | Prints a message to stdout with #### surrounding it. This is useful for
nosetests to better distinguish them.
:param c: uses the given char to wrap the header
:param txt: a text message to be printed
:type txt: string | [
"Prints",
"a",
"message",
"to",
"stdout",
"with",
"####",
"surrounding",
"it",
".",
"This",
"is",
"useful",
"for",
"nosetests",
"to",
"better",
"distinguish",
"them",
"."
] | python | train | 29.333333 |
ansible/ansible-lint | lib/ansiblelint/utils.py | https://github.com/ansible/ansible-lint/blob/b4a8743794e592698c32e760bc774a85f8eebeb5/lib/ansiblelint/utils.py#L599-L634 | def append_skipped_rules(pyyaml_data, file_text, file_type):
""" Uses ruamel.yaml to parse comments then adds a
skipped_rules list to the task (or meta yaml block)
"""
yaml = ruamel.yaml.YAML()
ruamel_data = yaml.load(file_text)
if file_type in ('tasks', 'handlers'):
ruamel_tasks = ... | [
"def",
"append_skipped_rules",
"(",
"pyyaml_data",
",",
"file_text",
",",
"file_type",
")",
":",
"yaml",
"=",
"ruamel",
".",
"yaml",
".",
"YAML",
"(",
")",
"ruamel_data",
"=",
"yaml",
".",
"load",
"(",
"file_text",
")",
"if",
"file_type",
"in",
"(",
"'ta... | Uses ruamel.yaml to parse comments then adds a
skipped_rules list to the task (or meta yaml block) | [
"Uses",
"ruamel",
".",
"yaml",
"to",
"parse",
"comments",
"then",
"adds",
"a",
"skipped_rules",
"list",
"to",
"the",
"task",
"(",
"or",
"meta",
"yaml",
"block",
")"
] | python | test | 34.527778 |
dourvaris/nano-python | src/nano/rpc.py | https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L2954-L2984 | def work_get(self, wallet, account):
"""
Retrieves work for **account** in **wallet**
.. enable_control required
.. version 8.0 required
:param wallet: Wallet to get account work for
:type wallet: str
:param account: Account to get work for
:type accoun... | [
"def",
"work_get",
"(",
"self",
",",
"wallet",
",",
"account",
")",
":",
"wallet",
"=",
"self",
".",
"_process_value",
"(",
"wallet",
",",
"'wallet'",
")",
"account",
"=",
"self",
".",
"_process_value",
"(",
"account",
",",
"'account'",
")",
"payload",
"... | Retrieves work for **account** in **wallet**
.. enable_control required
.. version 8.0 required
:param wallet: Wallet to get account work for
:type wallet: str
:param account: Account to get work for
:type account: str
:raises: :py:exc:`nano.rpc.RPCException`
... | [
"Retrieves",
"work",
"for",
"**",
"account",
"**",
"in",
"**",
"wallet",
"**"
] | python | train | 27.645161 |
delfick/aws_syncr | aws_syncr/option_spec/aws_syncr_specs.py | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/aws_syncr_specs.py#L40-L45 | def validate(self, meta, val):
"""Validate an account_id"""
val = string_or_int_as_string_spec().normalise(meta, val)
if not regexes['amazon_account_id'].match(val):
raise BadOption("Account id must match a particular regex", got=val, should_match=regexes['amazon_account_id'].pattern... | [
"def",
"validate",
"(",
"self",
",",
"meta",
",",
"val",
")",
":",
"val",
"=",
"string_or_int_as_string_spec",
"(",
")",
".",
"normalise",
"(",
"meta",
",",
"val",
")",
"if",
"not",
"regexes",
"[",
"'amazon_account_id'",
"]",
".",
"match",
"(",
"val",
... | Validate an account_id | [
"Validate",
"an",
"account_id"
] | python | train | 55.833333 |
pygobject/pgi | pgi/codegen/funcgen.py | https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/funcgen.py#L23-L36 | def may_be_null_is_nullable():
"""If may_be_null returns nullable or if NULL can be passed in.
This can still be wrong if the specific typelib is older than the linked
libgirepository.
https://bugzilla.gnome.org/show_bug.cgi?id=660879#c47
"""
repo = GIRepository()
repo.require("GLib", "2.... | [
"def",
"may_be_null_is_nullable",
"(",
")",
":",
"repo",
"=",
"GIRepository",
"(",
")",
"repo",
".",
"require",
"(",
"\"GLib\"",
",",
"\"2.0\"",
",",
"0",
")",
"info",
"=",
"repo",
".",
"find_by_name",
"(",
"\"GLib\"",
",",
"\"spawn_sync\"",
")",
"# this a... | If may_be_null returns nullable or if NULL can be passed in.
This can still be wrong if the specific typelib is older than the linked
libgirepository.
https://bugzilla.gnome.org/show_bug.cgi?id=660879#c47 | [
"If",
"may_be_null",
"returns",
"nullable",
"or",
"if",
"NULL",
"can",
"be",
"passed",
"in",
"."
] | python | train | 33.642857 |
heronotears/lazyxml | lazyxml/builder.py | https://github.com/heronotears/lazyxml/blob/e3f1ebd3f34cfa03d022ddec90e17d60c1c81953/lazyxml/builder.py#L145-L154 | def safedata(self, data, cdata=True):
r"""Convert xml special chars to entities.
:param data: the data will be converted safe.
:param cdata: whether to use cdata. Default:``True``. If not, use :func:`cgi.escape` to convert data.
:type cdata: bool
:rtype: str
"""
... | [
"def",
"safedata",
"(",
"self",
",",
"data",
",",
"cdata",
"=",
"True",
")",
":",
"safe",
"=",
"(",
"'<![CDATA[%s]]>'",
"%",
"data",
")",
"if",
"cdata",
"else",
"cgi",
".",
"escape",
"(",
"str",
"(",
"data",
")",
",",
"True",
")",
"return",
"safe"
... | r"""Convert xml special chars to entities.
:param data: the data will be converted safe.
:param cdata: whether to use cdata. Default:``True``. If not, use :func:`cgi.escape` to convert data.
:type cdata: bool
:rtype: str | [
"r",
"Convert",
"xml",
"special",
"chars",
"to",
"entities",
"."
] | python | train | 40.5 |
not-na/peng3d | peng3d/world.py | https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/world.py#L98-L105 | def render3d(self,view=None):
"""
Renders the world in 3d-mode.
If you want to render custom terrain, you may override this method. Be careful that you still call the original method or else actors may not be rendered.
"""
for actor in self.actors.values():
a... | [
"def",
"render3d",
"(",
"self",
",",
"view",
"=",
"None",
")",
":",
"for",
"actor",
"in",
"self",
".",
"actors",
".",
"values",
"(",
")",
":",
"actor",
".",
"render",
"(",
"view",
")"
] | Renders the world in 3d-mode.
If you want to render custom terrain, you may override this method. Be careful that you still call the original method or else actors may not be rendered. | [
"Renders",
"the",
"world",
"in",
"3d",
"-",
"mode",
".",
"If",
"you",
"want",
"to",
"render",
"custom",
"terrain",
"you",
"may",
"override",
"this",
"method",
".",
"Be",
"careful",
"that",
"you",
"still",
"call",
"the",
"original",
"method",
"or",
"else"... | python | test | 41.25 |
dingusdk/PythonIhcSdk | ihcsdk/ihcclient.py | https://github.com/dingusdk/PythonIhcSdk/blob/7e2067e009fe7600b49f30bff1cf91dc72fc891e/ihcsdk/ihcclient.py#L27-L51 | def authenticate(self, username: str, password: str) -> bool:
"""Do an Authentricate request and save the cookie returned to be used
on the following requests.
Return True if the request was successfull
"""
self.username = username
self.password = password
auth_p... | [
"def",
"authenticate",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
")",
"->",
"bool",
":",
"self",
".",
"username",
"=",
"username",
"self",
".",
"password",
"=",
"password",
"auth_payload",
"=",
"\"\"\"<authenticate1 xmlns=\\\"utcs\... | Do an Authentricate request and save the cookie returned to be used
on the following requests.
Return True if the request was successfull | [
"Do",
"an",
"Authentricate",
"request",
"and",
"save",
"the",
"cookie",
"returned",
"to",
"be",
"used",
"on",
"the",
"following",
"requests",
".",
"Return",
"True",
"if",
"the",
"request",
"was",
"successfull"
] | python | train | 43.88 |
saltstack/salt | salt/states/trafficserver.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/trafficserver.py#L318-L340 | def zero_cluster(name):
'''
Reset performance statistics to zero across the cluster.
.. code-block:: yaml
zero_ats_cluster:
trafficserver.zero_cluster
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
if __opts__['test']:... | [
"def",
"zero_cluster",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"''",
"}",
"if",
"__opts__",
"[",
"'test'",
"]",
":",
"ret",
"[",
"'comment'... | Reset performance statistics to zero across the cluster.
.. code-block:: yaml
zero_ats_cluster:
trafficserver.zero_cluster | [
"Reset",
"performance",
"statistics",
"to",
"zero",
"across",
"the",
"cluster",
"."
] | python | train | 22.043478 |
tensorpack/tensorpack | tensorpack/utils/utils.py | https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/utils/utils.py#L223-L293 | def find_library_full_path(name):
"""
Similar to `from ctypes.util import find_library`, but try
to return full path if possible.
"""
from ctypes.util import find_library
if os.name == "posix" and sys.platform == "darwin":
# on Mac, ctypes already returns full path
return find_l... | [
"def",
"find_library_full_path",
"(",
"name",
")",
":",
"from",
"ctypes",
".",
"util",
"import",
"find_library",
"if",
"os",
".",
"name",
"==",
"\"posix\"",
"and",
"sys",
".",
"platform",
"==",
"\"darwin\"",
":",
"# on Mac, ctypes already returns full path",
"retu... | Similar to `from ctypes.util import find_library`, but try
to return full path if possible. | [
"Similar",
"to",
"from",
"ctypes",
".",
"util",
"import",
"find_library",
"but",
"try",
"to",
"return",
"full",
"path",
"if",
"possible",
"."
] | python | train | 35.971831 |
jaraco/path.py | path/__init__.py | https://github.com/jaraco/path.py/blob/bbe7d99e7a64a004f866ace9ec12bd9b296908f5/path/__init__.py#L1091-L1094 | def rename(self, new):
""" .. seealso:: :func:`os.rename` """
os.rename(self, new)
return self._next_class(new) | [
"def",
"rename",
"(",
"self",
",",
"new",
")",
":",
"os",
".",
"rename",
"(",
"self",
",",
"new",
")",
"return",
"self",
".",
"_next_class",
"(",
"new",
")"
] | .. seealso:: :func:`os.rename` | [
"..",
"seealso",
"::",
":",
"func",
":",
"os",
".",
"rename"
] | python | train | 33 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/network/vnic/vnic_service.py | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/network/vnic/vnic_service.py#L68-L88 | def get_network_by_device(vm, device, pyvmomi_service, logger):
"""
Get a Network connected to a particular Device (vNIC)
@see https://github.com/vmware/pyvmomi/blob/master/docs/vim/dvs/PortConnection.rst
:param vm:
:param device: <vim.vm.device.VirtualVmxnet3> instance of adapt... | [
"def",
"get_network_by_device",
"(",
"vm",
",",
"device",
",",
"pyvmomi_service",
",",
"logger",
")",
":",
"try",
":",
"backing",
"=",
"device",
".",
"backing",
"if",
"hasattr",
"(",
"backing",
",",
"'network'",
")",
":",
"return",
"backing",
".",
"network... | Get a Network connected to a particular Device (vNIC)
@see https://github.com/vmware/pyvmomi/blob/master/docs/vim/dvs/PortConnection.rst
:param vm:
:param device: <vim.vm.device.VirtualVmxnet3> instance of adapter
:param pyvmomi_service:
:param logger:
:return: <vim Netw... | [
"Get",
"a",
"Network",
"connected",
"to",
"a",
"particular",
"Device",
"(",
"vNIC",
")",
"@see",
"https",
":",
"//",
"github",
".",
"com",
"/",
"vmware",
"/",
"pyvmomi",
"/",
"blob",
"/",
"master",
"/",
"docs",
"/",
"vim",
"/",
"dvs",
"/",
"PortConne... | python | train | 41.714286 |
andycasey/ads | ads/search.py | https://github.com/andycasey/ads/blob/928415e202db80658cd8532fa4c3a00d0296b5c5/ads/search.py#L461-L469 | def progress(self):
"""
Returns a string representation of the progress of the search such as
"1234/5000", which refers to the number of results retrived / the
total number of results found
"""
if self.response is None:
return "Query has not been executed"
... | [
"def",
"progress",
"(",
"self",
")",
":",
"if",
"self",
".",
"response",
"is",
"None",
":",
"return",
"\"Query has not been executed\"",
"return",
"\"{}/{}\"",
".",
"format",
"(",
"len",
"(",
"self",
".",
"articles",
")",
",",
"self",
".",
"response",
".",... | Returns a string representation of the progress of the search such as
"1234/5000", which refers to the number of results retrived / the
total number of results found | [
"Returns",
"a",
"string",
"representation",
"of",
"the",
"progress",
"of",
"the",
"search",
"such",
"as",
"1234",
"/",
"5000",
"which",
"refers",
"to",
"the",
"number",
"of",
"results",
"retrived",
"/",
"the",
"total",
"number",
"of",
"results",
"found"
] | python | train | 42.444444 |
androguard/androguard | androguard/core/bytecodes/dvm.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/dvm.py#L4557-L4569 | def show_buff(self, pos):
"""
Return the display of the instruction
:rtype: string
"""
buff = self.get_name() + " "
buff += "%x:" % self.first_key
for i in self.targets:
buff += " %x" % i
return buff | [
"def",
"show_buff",
"(",
"self",
",",
"pos",
")",
":",
"buff",
"=",
"self",
".",
"get_name",
"(",
")",
"+",
"\" \"",
"buff",
"+=",
"\"%x:\"",
"%",
"self",
".",
"first_key",
"for",
"i",
"in",
"self",
".",
"targets",
":",
"buff",
"+=",
"\" %x\"",
"%"... | Return the display of the instruction
:rtype: string | [
"Return",
"the",
"display",
"of",
"the",
"instruction"
] | python | train | 20.461538 |
coleifer/django-relationships | relationships/models.py | https://github.com/coleifer/django-relationships/blob/f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805/relationships/models.py#L112-L130 | def remove(self, user, status=None, symmetrical=False):
"""
Remove a relationship from one user to another, with the same caveats
and behavior as adding a relationship.
"""
if not status:
status = RelationshipStatus.objects.following()
res = Relationship.obje... | [
"def",
"remove",
"(",
"self",
",",
"user",
",",
"status",
"=",
"None",
",",
"symmetrical",
"=",
"False",
")",
":",
"if",
"not",
"status",
":",
"status",
"=",
"RelationshipStatus",
".",
"objects",
".",
"following",
"(",
")",
"res",
"=",
"Relationship",
... | Remove a relationship from one user to another, with the same caveats
and behavior as adding a relationship. | [
"Remove",
"a",
"relationship",
"from",
"one",
"user",
"to",
"another",
"with",
"the",
"same",
"caveats",
"and",
"behavior",
"as",
"adding",
"a",
"relationship",
"."
] | python | train | 31.789474 |
boriel/zxbasic | arch/zx48k/backend/__pload.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__pload.py#L52-L120 | def _pload(offset, size):
""" Generic parameter loading.
Emmits output code for setting IX at the right location.
size = Number of bytes to load:
1 => 8 bit value
2 => 16 bit value / string
4 => 32 bit value / f16 value
5 => 40 bit value
"""
output = []
indirect ... | [
"def",
"_pload",
"(",
"offset",
",",
"size",
")",
":",
"output",
"=",
"[",
"]",
"indirect",
"=",
"offset",
"[",
"0",
"]",
"==",
"'*'",
"if",
"indirect",
":",
"offset",
"=",
"offset",
"[",
"1",
":",
"]",
"I",
"=",
"int",
"(",
"offset",
")",
"if"... | Generic parameter loading.
Emmits output code for setting IX at the right location.
size = Number of bytes to load:
1 => 8 bit value
2 => 16 bit value / string
4 => 32 bit value / f16 value
5 => 40 bit value | [
"Generic",
"parameter",
"loading",
".",
"Emmits",
"output",
"code",
"for",
"setting",
"IX",
"at",
"the",
"right",
"location",
".",
"size",
"=",
"Number",
"of",
"bytes",
"to",
"load",
":",
"1",
"=",
">",
"8",
"bit",
"value",
"2",
"=",
">",
"16",
"bit"... | python | train | 31.753623 |
xolox/python-vcs-repo-mgr | vcs_repo_mgr/backends/git.py | https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/backends/git.py#L213-L220 | def find_branches(self):
"""Find information about the branches in the repository."""
for prefix, name, revision_id in self.find_branches_raw():
yield Revision(
branch=name,
repository=self,
revision_id=revision_id,
) | [
"def",
"find_branches",
"(",
"self",
")",
":",
"for",
"prefix",
",",
"name",
",",
"revision_id",
"in",
"self",
".",
"find_branches_raw",
"(",
")",
":",
"yield",
"Revision",
"(",
"branch",
"=",
"name",
",",
"repository",
"=",
"self",
",",
"revision_id",
"... | Find information about the branches in the repository. | [
"Find",
"information",
"about",
"the",
"branches",
"in",
"the",
"repository",
"."
] | python | train | 37.25 |
juju/python-libjuju | juju/client/connection.py | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/connection.py#L421-L432 | async def controller(self):
"""Return a Connection to the controller at self.endpoint
"""
return await Connection.connect(
self.endpoint,
username=self.username,
password=self.password,
cacert=self.cacert,
bakery_client=self.bakery_clie... | [
"async",
"def",
"controller",
"(",
"self",
")",
":",
"return",
"await",
"Connection",
".",
"connect",
"(",
"self",
".",
"endpoint",
",",
"username",
"=",
"self",
".",
"username",
",",
"password",
"=",
"self",
".",
"password",
",",
"cacert",
"=",
"self",
... | Return a Connection to the controller at self.endpoint | [
"Return",
"a",
"Connection",
"to",
"the",
"controller",
"at",
"self",
".",
"endpoint"
] | python | train | 33.166667 |
timothyb0912/pylogit | pylogit/scobit.py | https://github.com/timothyb0912/pylogit/blob/f83b0fd6debaa7358d87c3828428f6d4ead71357/pylogit/scobit.py#L216-L294 | def _scobit_transform_deriv_v(systematic_utilities,
alt_IDs,
rows_to_alts,
shape_params,
output_array=None,
*args, **kwargs):
"""
Parameters
----------
sy... | [
"def",
"_scobit_transform_deriv_v",
"(",
"systematic_utilities",
",",
"alt_IDs",
",",
"rows_to_alts",
",",
"shape_params",
",",
"output_array",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Note the np.exp is needed because the raw curvature par... | Parameters
----------
systematic_utilities : 1D ndarray.
All elements should be ints, floats, or longs. Should contain the
systematic utilities of each observation per available alternative.
Note that this vector is formed by the dot product of the design matrix
with the vector o... | [
"Parameters",
"----------",
"systematic_utilities",
":",
"1D",
"ndarray",
".",
"All",
"elements",
"should",
"be",
"ints",
"floats",
"or",
"longs",
".",
"Should",
"contain",
"the",
"systematic",
"utilities",
"of",
"each",
"observation",
"per",
"available",
"alterna... | python | train | 48.936709 |
bspaans/python-mingus | mingus/core/chords.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L852-L925 | def determine_triad(triad, shorthand=False, no_inversions=False,
placeholder=None):
"""Name the triad; return answers in a list.
The third argument should not be given. If shorthand is True the answers
will be in abbreviated form.
This function can determine major, minor, diminished and suspen... | [
"def",
"determine_triad",
"(",
"triad",
",",
"shorthand",
"=",
"False",
",",
"no_inversions",
"=",
"False",
",",
"placeholder",
"=",
"None",
")",
":",
"if",
"len",
"(",
"triad",
")",
"!=",
"3",
":",
"# warning: raise exception: not a triad",
"return",
"False",... | Name the triad; return answers in a list.
The third argument should not be given. If shorthand is True the answers
will be in abbreviated form.
This function can determine major, minor, diminished and suspended
triads. Also knows about invertions.
Examples:
>>> determine_triad(['A', 'C', 'E']... | [
"Name",
"the",
"triad",
";",
"return",
"answers",
"in",
"a",
"list",
"."
] | python | train | 32.891892 |
nornir-automation/nornir | nornir/plugins/tasks/networking/napalm_cli.py | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/networking/napalm_cli.py#L6-L19 | def napalm_cli(task: Task, commands: List[str]) -> Result:
"""
Run commands on remote devices using napalm
Arguments:
commands: commands to execute
Returns:
Result object with the following attributes set:
* result (``dict``): result of the commands execution
"""
devi... | [
"def",
"napalm_cli",
"(",
"task",
":",
"Task",
",",
"commands",
":",
"List",
"[",
"str",
"]",
")",
"->",
"Result",
":",
"device",
"=",
"task",
".",
"host",
".",
"get_connection",
"(",
"\"napalm\"",
",",
"task",
".",
"nornir",
".",
"config",
")",
"res... | Run commands on remote devices using napalm
Arguments:
commands: commands to execute
Returns:
Result object with the following attributes set:
* result (``dict``): result of the commands execution | [
"Run",
"commands",
"on",
"remote",
"devices",
"using",
"napalm"
] | python | train | 32.071429 |
click-contrib/click-configfile | tasks/clean.py | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L191-L205 | def path_glob(pattern, current_dir=None):
"""Use pathlib for ant-like patterns, like: "**/*.py"
:param pattern: File/directory pattern to use (as string).
:param current_dir: Current working directory (as Path, pathlib.Path, str)
:return Resolved Path (as path.Path).
"""
if not current_di... | [
"def",
"path_glob",
"(",
"pattern",
",",
"current_dir",
"=",
"None",
")",
":",
"if",
"not",
"current_dir",
":",
"current_dir",
"=",
"pathlib",
".",
"Path",
".",
"cwd",
"(",
")",
"elif",
"not",
"isinstance",
"(",
"current_dir",
",",
"pathlib",
".",
"Path"... | Use pathlib for ant-like patterns, like: "**/*.py"
:param pattern: File/directory pattern to use (as string).
:param current_dir: Current working directory (as Path, pathlib.Path, str)
:return Resolved Path (as path.Path). | [
"Use",
"pathlib",
"for",
"ant",
"-",
"like",
"patterns",
"like",
":",
"**",
"/",
"*",
".",
"py"
] | python | train | 38.2 |
DLR-RM/RAFCON | source/rafcon/gui/models/selection.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/selection.py#L375-L395 | def get_selected_elements_of_core_class(self, core_element_type):
"""Returns all selected elements having the specified `core_element_type` as state element class
:return: Subset of the selection, only containing elements having `core_element_type` as state element class
:rtype: set
"""... | [
"def",
"get_selected_elements_of_core_class",
"(",
"self",
",",
"core_element_type",
")",
":",
"if",
"core_element_type",
"is",
"Outcome",
":",
"return",
"self",
".",
"outcomes",
"elif",
"core_element_type",
"is",
"InputDataPort",
":",
"return",
"self",
".",
"input_... | Returns all selected elements having the specified `core_element_type` as state element class
:return: Subset of the selection, only containing elements having `core_element_type` as state element class
:rtype: set | [
"Returns",
"all",
"selected",
"elements",
"having",
"the",
"specified",
"core_element_type",
"as",
"state",
"element",
"class"
] | python | train | 45.619048 |
Bystroushaak/pyDHTMLParser | src/dhtmlparser/__init__.py | https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/__init__.py#L283-L321 | def removeTags(dom):
"""
Remove all tags from `dom` and obtain plaintext representation.
Args:
dom (str, obj, array): str, HTMLElement instance or array of elements.
Returns:
str: Plain string without tags.
"""
# python 2 / 3 shill
try:
string_type = basestring
... | [
"def",
"removeTags",
"(",
"dom",
")",
":",
"# python 2 / 3 shill",
"try",
":",
"string_type",
"=",
"basestring",
"except",
"NameError",
":",
"string_type",
"=",
"str",
"# initialize stack with proper value (based on dom parameter)",
"element_stack",
"=",
"None",
"if",
"... | Remove all tags from `dom` and obtain plaintext representation.
Args:
dom (str, obj, array): str, HTMLElement instance or array of elements.
Returns:
str: Plain string without tags. | [
"Remove",
"all",
"tags",
"from",
"dom",
"and",
"obtain",
"plaintext",
"representation",
"."
] | python | train | 25.769231 |
ThreatConnect-Inc/tcex | tcex/tcex_ti/mappings/tcex_ti_mappings.py | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/tcex_ti_mappings.py#L680-L702 | def add_attribute(self, attribute_type, attribute_value):
"""
Adds a attribute to a Group/Indicator or Victim
Args:
attribute_type:
attribute_value:
Returns: attribute json
"""
if not self.can_update():
self._tcex.handle_error(910, ... | [
"def",
"add_attribute",
"(",
"self",
",",
"attribute_type",
",",
"attribute_value",
")",
":",
"if",
"not",
"self",
".",
"can_update",
"(",
")",
":",
"self",
".",
"_tcex",
".",
"handle_error",
"(",
"910",
",",
"[",
"self",
".",
"type",
"]",
")",
"return... | Adds a attribute to a Group/Indicator or Victim
Args:
attribute_type:
attribute_value:
Returns: attribute json | [
"Adds",
"a",
"attribute",
"to",
"a",
"Group",
"/",
"Indicator",
"or",
"Victim"
] | python | train | 23.521739 |
sendgrid/sendgrid-python | sendgrid/helpers/mail/mail.py | https://github.com/sendgrid/sendgrid-python/blob/266c2abde7a35dfcce263e06bedc6a0bbdebeac9/sendgrid/helpers/mail/mail.py#L812-L818 | def add_section(self, section):
"""A block section of code to be used as substitutions
:param section: A block section of code to be used as substitutions
:type section: Section
"""
self._sections = self._ensure_append(section, self._sections) | [
"def",
"add_section",
"(",
"self",
",",
"section",
")",
":",
"self",
".",
"_sections",
"=",
"self",
".",
"_ensure_append",
"(",
"section",
",",
"self",
".",
"_sections",
")"
] | A block section of code to be used as substitutions
:param section: A block section of code to be used as substitutions
:type section: Section | [
"A",
"block",
"section",
"of",
"code",
"to",
"be",
"used",
"as",
"substitutions"
] | python | train | 39.714286 |
bykof/billomapy | billomapy/billomapy.py | https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L2249-L2262 | def get_all_items_of_offer(self, offer_id):
"""
Get all items of offer
This will iterate over all pages until it gets all elements.
So if the rate limit exceeded it will throw an Exception and you will get nothing
:param offer_id: the offer id
:return: list
"""
... | [
"def",
"get_all_items_of_offer",
"(",
"self",
",",
"offer_id",
")",
":",
"return",
"self",
".",
"_iterate_through_pages",
"(",
"get_function",
"=",
"self",
".",
"get_items_of_offer_per_page",
",",
"resource",
"=",
"OFFER_ITEMS",
",",
"*",
"*",
"{",
"'offer_id'",
... | Get all items of offer
This will iterate over all pages until it gets all elements.
So if the rate limit exceeded it will throw an Exception and you will get nothing
:param offer_id: the offer id
:return: list | [
"Get",
"all",
"items",
"of",
"offer",
"This",
"will",
"iterate",
"over",
"all",
"pages",
"until",
"it",
"gets",
"all",
"elements",
".",
"So",
"if",
"the",
"rate",
"limit",
"exceeded",
"it",
"will",
"throw",
"an",
"Exception",
"and",
"you",
"will",
"get",... | python | train | 34.928571 |
sorgerlab/indra | indra/sources/indra_db_rest/api.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/indra_db_rest/api.py#L120-L154 | def get_statements_by_hash(hash_list, ev_limit=100, best_first=True, tries=2):
"""Get fully formed statements from a list of hashes.
Parameters
----------
hash_list : list[int or str]
A list of statement hashes.
ev_limit : int or None
Limit the amount of evidence returned per Statem... | [
"def",
"get_statements_by_hash",
"(",
"hash_list",
",",
"ev_limit",
"=",
"100",
",",
"best_first",
"=",
"True",
",",
"tries",
"=",
"2",
")",
":",
"if",
"not",
"isinstance",
"(",
"hash_list",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"\"The `hash_l... | Get fully formed statements from a list of hashes.
Parameters
----------
hash_list : list[int or str]
A list of statement hashes.
ev_limit : int or None
Limit the amount of evidence returned per Statement. Default is 100.
best_first : bool
If True, the preassembled statement... | [
"Get",
"fully",
"formed",
"statements",
"from",
"a",
"list",
"of",
"hashes",
"."
] | python | train | 49.485714 |
cggh/scikit-allel | allel/chunked/core.py | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/chunked/core.py#L188-L193 | def amax(data, axis=None, mapper=None, blen=None, storage=None,
create='array', **kwargs):
"""Compute the maximum value."""
return reduce_axis(data, axis=axis, reducer=np.amax,
block_reducer=np.maximum, mapper=mapper,
blen=blen, storage=storage, create=crea... | [
"def",
"amax",
"(",
"data",
",",
"axis",
"=",
"None",
",",
"mapper",
"=",
"None",
",",
"blen",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"create",
"=",
"'array'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"reduce_axis",
"(",
"data",
",",
... | Compute the maximum value. | [
"Compute",
"the",
"maximum",
"value",
"."
] | python | train | 54.666667 |
matthiask/django-cte-forest | cte_forest/models.py | https://github.com/matthiask/django-cte-forest/blob/7bff29d69eddfcf214e9cf61647c91d28655619c/cte_forest/models.py#L1199-L1225 | def attribute_path(self, attribute, missing=None, visitor=None):
""" Generates a list of values of the `attribute` of all ancestors of
this node (as well as the node itself). If a value is ``None``, then
the optional value of `missing` is used (by default ``None``).
By defau... | [
"def",
"attribute_path",
"(",
"self",
",",
"attribute",
",",
"missing",
"=",
"None",
",",
"visitor",
"=",
"None",
")",
":",
"_parameters",
"=",
"{",
"\"node\"",
":",
"self",
",",
"\"attribute\"",
":",
"attribute",
"}",
"if",
"missing",
"is",
"not",
"None... | Generates a list of values of the `attribute` of all ancestors of
this node (as well as the node itself). If a value is ``None``, then
the optional value of `missing` is used (by default ``None``).
By default, the ``getattr(node, attribute, None) or missing``
mechanism i... | [
"Generates",
"a",
"list",
"of",
"values",
"of",
"the",
"attribute",
"of",
"all",
"ancestors",
"of",
"this",
"node",
"(",
"as",
"well",
"as",
"the",
"node",
"itself",
")",
".",
"If",
"a",
"value",
"is",
"None",
"then",
"the",
"optional",
"value",
"of",
... | python | train | 49.111111 |
mrcagney/gtfstk | gtfstk/stops.py | https://github.com/mrcagney/gtfstk/blob/c91494e6fefc02523889655a0dc92d1c0eee8d03/gtfstk/stops.py#L789-L829 | def get_stops_in_polygon(
feed: "Feed", polygon: Polygon, geo_stops=None
) -> DataFrame:
"""
Return the slice of ``feed.stops`` that contains all stops that lie
within the given Shapely Polygon object that is specified in
WGS84 coordinates.
Parameters
----------
feed : Feed
polygon ... | [
"def",
"get_stops_in_polygon",
"(",
"feed",
":",
"\"Feed\"",
",",
"polygon",
":",
"Polygon",
",",
"geo_stops",
"=",
"None",
")",
"->",
"DataFrame",
":",
"if",
"geo_stops",
"is",
"not",
"None",
":",
"f",
"=",
"geo_stops",
".",
"copy",
"(",
")",
"else",
... | Return the slice of ``feed.stops`` that contains all stops that lie
within the given Shapely Polygon object that is specified in
WGS84 coordinates.
Parameters
----------
feed : Feed
polygon : Shapely Polygon
Specified in WGS84 coordinates
geo_stops : Geopandas GeoDataFrame
A... | [
"Return",
"the",
"slice",
"of",
"feed",
".",
"stops",
"that",
"contains",
"all",
"stops",
"that",
"lie",
"within",
"the",
"given",
"Shapely",
"Polygon",
"object",
"that",
"is",
"specified",
"in",
"WGS84",
"coordinates",
"."
] | python | train | 25.243902 |
EventRegistry/event-registry-python | eventregistry/EventForText.py | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/EventForText.py#L42-L57 | def compute(self,
text, # text for which to find the most similar event
lang = "eng"): # language in which the text is written
"""
compute the list of most similar events for the given text
"""
params = { "lang": lang, "text": text, "topClusters... | [
"def",
"compute",
"(",
"self",
",",
"text",
",",
"# text for which to find the most similar event",
"lang",
"=",
"\"eng\"",
")",
":",
"# language in which the text is written",
"params",
"=",
"{",
"\"lang\"",
":",
"lang",
",",
"\"text\"",
":",
"text",
",",
"\"topClu... | compute the list of most similar events for the given text | [
"compute",
"the",
"list",
"of",
"most",
"similar",
"events",
"for",
"the",
"given",
"text"
] | python | train | 49.5625 |
wtsi-hgi/consul-lock | consullock/cli.py | https://github.com/wtsi-hgi/consul-lock/blob/deb07ab41dabbb49f4d0bbc062bc3b4b6e5d71b2/consullock/cli.py#L348-L405 | def main(cli_arguments: List[str]):
"""
Entrypoint.
:param cli_arguments: arguments passed in via the CLI
:raises SystemExit: always raised
"""
cli_configuration: CliConfiguration
try:
cli_configuration = parse_cli_configuration(cli_arguments)
except InvalidCliArgumentError as e:... | [
"def",
"main",
"(",
"cli_arguments",
":",
"List",
"[",
"str",
"]",
")",
":",
"cli_configuration",
":",
"CliConfiguration",
"try",
":",
"cli_configuration",
"=",
"parse_cli_configuration",
"(",
"cli_arguments",
")",
"except",
"InvalidCliArgumentError",
"as",
"e",
"... | Entrypoint.
:param cli_arguments: arguments passed in via the CLI
:raises SystemExit: always raised | [
"Entrypoint",
".",
":",
"param",
"cli_arguments",
":",
"arguments",
"passed",
"in",
"via",
"the",
"CLI",
":",
"raises",
"SystemExit",
":",
"always",
"raised"
] | python | train | 40.896552 |
linuxsoftware/ls.joyous | ls/joyous/models/events.py | https://github.com/linuxsoftware/ls.joyous/blob/316283140ca5171a68ad3170a5964fdc89be0b56/ls/joyous/models/events.py#L679-L687 | def status(self):
"""
The current status of the event (started, finished or pending).
"""
myNow = timezone.localtime(timezone=self.tz)
if getAwareDatetime(self.date, self.time_to, self.tz) < myNow:
return "finished"
elif getAwareDatetime(self.date, self.time_f... | [
"def",
"status",
"(",
"self",
")",
":",
"myNow",
"=",
"timezone",
".",
"localtime",
"(",
"timezone",
"=",
"self",
".",
"tz",
")",
"if",
"getAwareDatetime",
"(",
"self",
".",
"date",
",",
"self",
".",
"time_to",
",",
"self",
".",
"tz",
")",
"<",
"my... | The current status of the event (started, finished or pending). | [
"The",
"current",
"status",
"of",
"the",
"event",
"(",
"started",
"finished",
"or",
"pending",
")",
"."
] | python | train | 40.333333 |
marshmallow-code/apispec | src/apispec/ext/marshmallow/openapi.py | https://github.com/marshmallow-code/apispec/blob/e92ceffd12b2e392b8d199ed314bd2a7e6512dff/src/apispec/ext/marshmallow/openapi.py#L444-L477 | def resolve_nested_schema(self, schema):
"""Return the Open API representation of a marshmallow Schema.
Adds the schema to the spec if it isn't already present.
Typically will return a dictionary with the reference to the schema's
path in the spec unless the `schema_name_resolver` retu... | [
"def",
"resolve_nested_schema",
"(",
"self",
",",
"schema",
")",
":",
"schema_instance",
"=",
"resolve_schema_instance",
"(",
"schema",
")",
"schema_key",
"=",
"make_schema_key",
"(",
"schema_instance",
")",
"if",
"schema_key",
"not",
"in",
"self",
".",
"refs",
... | Return the Open API representation of a marshmallow Schema.
Adds the schema to the spec if it isn't already present.
Typically will return a dictionary with the reference to the schema's
path in the spec unless the `schema_name_resolver` returns `None`, in
which case the returned dicto... | [
"Return",
"the",
"Open",
"API",
"representation",
"of",
"a",
"marshmallow",
"Schema",
"."
] | python | train | 49.382353 |
tensorflow/cleverhans | examples/multigpu_advtrain/resnet_tf.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/multigpu_advtrain/resnet_tf.py#L293-L306 | def _conv(self, name, x, filter_size, in_filters, out_filters, strides):
"""Convolution."""
if self.init_layers:
conv = Conv2DnGPU(out_filters,
(filter_size, filter_size),
strides[1:3], 'SAME', w_name='DW')
conv.name = name
self.layers += [conv]
... | [
"def",
"_conv",
"(",
"self",
",",
"name",
",",
"x",
",",
"filter_size",
",",
"in_filters",
",",
"out_filters",
",",
"strides",
")",
":",
"if",
"self",
".",
"init_layers",
":",
"conv",
"=",
"Conv2DnGPU",
"(",
"out_filters",
",",
"(",
"filter_size",
",",
... | Convolution. | [
"Convolution",
"."
] | python | train | 34.642857 |
deepmind/pysc2 | pysc2/maps/lib.py | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/maps/lib.py#L125-L136 | def get(map_name):
"""Get an instance of a map by name. Errors if the map doesn't exist."""
if isinstance(map_name, Map):
return map_name
# Get the list of maps. This isn't at module scope to avoid problems of maps
# being defined after this module is imported.
maps = get_maps()
map_class = maps.get(ma... | [
"def",
"get",
"(",
"map_name",
")",
":",
"if",
"isinstance",
"(",
"map_name",
",",
"Map",
")",
":",
"return",
"map_name",
"# Get the list of maps. This isn't at module scope to avoid problems of maps",
"# being defined after this module is imported.",
"maps",
"=",
"get_maps",... | Get an instance of a map by name. Errors if the map doesn't exist. | [
"Get",
"an",
"instance",
"of",
"a",
"map",
"by",
"name",
".",
"Errors",
"if",
"the",
"map",
"doesn",
"t",
"exist",
"."
] | python | train | 34.5 |
datastax/python-driver | cassandra/cqlengine/models.py | https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cqlengine/models.py#L711-L745 | def save(self):
"""
Saves an object to the database.
.. code-block:: python
#create a person instance
person = Person(first_name='Kimberly', last_name='Eggleston')
#saves it to Cassandra
person.save()
"""
# handle polymorphic mod... | [
"def",
"save",
"(",
"self",
")",
":",
"# handle polymorphic models",
"if",
"self",
".",
"_is_polymorphic",
":",
"if",
"self",
".",
"_is_polymorphic_base",
":",
"raise",
"PolymorphicModelException",
"(",
"'cannot save polymorphic base model'",
")",
"else",
":",
"setatt... | Saves an object to the database.
.. code-block:: python
#create a person instance
person = Person(first_name='Kimberly', last_name='Eggleston')
#saves it to Cassandra
person.save() | [
"Saves",
"an",
"object",
"to",
"the",
"database",
"."
] | python | train | 32.685714 |
RudolfCardinal/pythonlib | cardinal_pythonlib/datetimefunc.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/datetimefunc.py#L57-L92 | def coerce_to_pendulum(x: PotentialDatetimeType,
assume_local: bool = False) -> Optional[DateTime]:
"""
Converts something to a :class:`pendulum.DateTime`.
Args:
x: something that may be coercible to a datetime
assume_local: if ``True``, assume local timezone; if ``Fa... | [
"def",
"coerce_to_pendulum",
"(",
"x",
":",
"PotentialDatetimeType",
",",
"assume_local",
":",
"bool",
"=",
"False",
")",
"->",
"Optional",
"[",
"DateTime",
"]",
":",
"if",
"not",
"x",
":",
"# None and blank string",
"return",
"None",
"if",
"isinstance",
"(",
... | Converts something to a :class:`pendulum.DateTime`.
Args:
x: something that may be coercible to a datetime
assume_local: if ``True``, assume local timezone; if ``False``, assume
UTC
Returns:
a :class:`pendulum.DateTime`, or ``None``.
Raises:
pendulum.parsing.ex... | [
"Converts",
"something",
"to",
"a",
":",
"class",
":",
"pendulum",
".",
"DateTime",
"."
] | python | train | 36.833333 |
programa-stic/barf-project | barf/analysis/graphs/controlflowgraph.py | https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/analysis/graphs/controlflowgraph.py#L117-L125 | def all_simple_bb_paths(self, start_address, end_address):
"""Return a list of path between start and end address.
"""
bb_start = self._find_basic_block(start_address)
bb_end = self._find_basic_block(end_address)
paths = networkx.all_simple_paths(self._graph, source=bb_start.add... | [
"def",
"all_simple_bb_paths",
"(",
"self",
",",
"start_address",
",",
"end_address",
")",
":",
"bb_start",
"=",
"self",
".",
"_find_basic_block",
"(",
"start_address",
")",
"bb_end",
"=",
"self",
".",
"_find_basic_block",
"(",
"end_address",
")",
"paths",
"=",
... | Return a list of path between start and end address. | [
"Return",
"a",
"list",
"of",
"path",
"between",
"start",
"and",
"end",
"address",
"."
] | python | train | 46.444444 |
carpedm20/ndrive | cmdline.py | https://github.com/carpedm20/ndrive/blob/ac58eaf8a8d46292ad752bb38047f65838b8ad2b/cmdline.py#L166-L175 | def do_get(self, from_path, to_path):
"""
Copy file from Ndrive to local file and print out out the metadata.
Examples:
Ndrive> get file.txt ~/ndrive-file.txt
"""
to_file = open(os.path.expanduser(to_path), "wb")
self.n.downloadFile(self.current_path + "/" + f... | [
"def",
"do_get",
"(",
"self",
",",
"from_path",
",",
"to_path",
")",
":",
"to_file",
"=",
"open",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"to_path",
")",
",",
"\"wb\"",
")",
"self",
".",
"n",
".",
"downloadFile",
"(",
"self",
".",
"current_pa... | Copy file from Ndrive to local file and print out out the metadata.
Examples:
Ndrive> get file.txt ~/ndrive-file.txt | [
"Copy",
"file",
"from",
"Ndrive",
"to",
"local",
"file",
"and",
"print",
"out",
"out",
"the",
"metadata",
"."
] | python | train | 32.9 |
rauenzi/discordbot.py | discordbot/bot_utils/paginator.py | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/bot_utils/paginator.py#L192-L212 | async def paginate(self):
"""Actually paginate the entries and run the interactive loop if necessary."""
await self.show_page(1, first=True)
while self.paginating:
react = await self.bot.wait_for_reaction(message=self.message, check=self.react_check, timeout=120.0)
if re... | [
"async",
"def",
"paginate",
"(",
"self",
")",
":",
"await",
"self",
".",
"show_page",
"(",
"1",
",",
"first",
"=",
"True",
")",
"while",
"self",
".",
"paginating",
":",
"react",
"=",
"await",
"self",
".",
"bot",
".",
"wait_for_reaction",
"(",
"message"... | Actually paginate the entries and run the interactive loop if necessary. | [
"Actually",
"paginate",
"the",
"entries",
"and",
"run",
"the",
"interactive",
"loop",
"if",
"necessary",
"."
] | python | train | 36.52381 |
smarie/python-valid8 | valid8/entry_points_inline.py | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L54-L80 | def assert_subclass_of(typ,
allowed_types # type: Union[Type, Tuple[Type]]
):
"""
An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of
success, and raises a IsWrongType exception in case of failure.
... | [
"def",
"assert_subclass_of",
"(",
"typ",
",",
"allowed_types",
"# type: Union[Type, Tuple[Type]]",
")",
":",
"if",
"not",
"issubclass",
"(",
"typ",
",",
"allowed_types",
")",
":",
"try",
":",
"# more than 1 ?",
"allowed_types",
"[",
"1",
"]",
"raise",
"IsWrongType... | An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of
success, and raises a IsWrongType exception in case of failure.
Used in validate and validation/validator
:param typ: the type to check
:param allowed_types: the type(s) to enforce. If a t... | [
"An",
"inlined",
"version",
"of",
"subclass_of",
"(",
"var_types",
")",
"(",
"value",
")",
"without",
"return",
"True",
":",
"it",
"does",
"not",
"return",
"anything",
"in",
"case",
"of",
"success",
"and",
"raises",
"a",
"IsWrongType",
"exception",
"in",
"... | python | train | 39.777778 |
stanfordnlp/stanza | stanza/text/vocab.py | https://github.com/stanfordnlp/stanza/blob/920c55d8eaa1e7105971059c66eb448a74c100d6/stanza/text/vocab.py#L176-L188 | def prune_rares(self, cutoff=2):
"""
returns a **new** `Vocab` object that is similar to this one but with rare words removed.
Note that the indices in the new `Vocab` will be remapped (because rare words will have been removed).
:param cutoff: words occuring less than this number of ti... | [
"def",
"prune_rares",
"(",
"self",
",",
"cutoff",
"=",
"2",
")",
":",
"keep",
"=",
"lambda",
"w",
":",
"self",
".",
"count",
"(",
"w",
")",
">=",
"cutoff",
"or",
"w",
"==",
"self",
".",
"_unk",
"return",
"self",
".",
"subset",
"(",
"[",
"w",
"f... | returns a **new** `Vocab` object that is similar to this one but with rare words removed.
Note that the indices in the new `Vocab` will be remapped (because rare words will have been removed).
:param cutoff: words occuring less than this number of times are removed from the vocabulary.
:return... | [
"returns",
"a",
"**",
"new",
"**",
"Vocab",
"object",
"that",
"is",
"similar",
"to",
"this",
"one",
"but",
"with",
"rare",
"words",
"removed",
".",
"Note",
"that",
"the",
"indices",
"in",
"the",
"new",
"Vocab",
"will",
"be",
"remapped",
"(",
"because",
... | python | train | 43.153846 |
aio-libs/yarl | yarl/__init__.py | https://github.com/aio-libs/yarl/blob/e47da02c00ad764e030ca7647a9565548c97d362/yarl/__init__.py#L951-L966 | def join(self, url):
"""Join URLs
Construct a full (“absolute”) URL by combining a “base URL”
(self) with another URL (url).
Informally, this uses components of the base URL, in
particular the addressing scheme, the network location and
(part of) the path, to provide mi... | [
"def",
"join",
"(",
"self",
",",
"url",
")",
":",
"# See docs for urllib.parse.urljoin",
"if",
"not",
"isinstance",
"(",
"url",
",",
"URL",
")",
":",
"raise",
"TypeError",
"(",
"\"url should be URL\"",
")",
"return",
"URL",
"(",
"urljoin",
"(",
"str",
"(",
... | Join URLs
Construct a full (“absolute”) URL by combining a “base URL”
(self) with another URL (url).
Informally, this uses components of the base URL, in
particular the addressing scheme, the network location and
(part of) the path, to provide missing components in the
... | [
"Join",
"URLs"
] | python | train | 34.75 |
tnkteja/myhelp | virtualEnvironment/lib/python2.7/site-packages/coverage/results.py | https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/results.py#L148-L151 | def total_branches(self):
"""How many total branches are there?"""
exit_counts = self.parser.exit_counts()
return sum([count for count in exit_counts.values() if count > 1]) | [
"def",
"total_branches",
"(",
"self",
")",
":",
"exit_counts",
"=",
"self",
".",
"parser",
".",
"exit_counts",
"(",
")",
"return",
"sum",
"(",
"[",
"count",
"for",
"count",
"in",
"exit_counts",
".",
"values",
"(",
")",
"if",
"count",
">",
"1",
"]",
"... | How many total branches are there? | [
"How",
"many",
"total",
"branches",
"are",
"there?"
] | python | test | 48.5 |
NetEaseGame/ATX | atx/record/android_layout.py | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/android_layout.py#L178-L181 | def get_index_node(self, idx):
'''get node with iterindex `idx`'''
idx = self.node_index.index(idx)
return self.nodes[idx] | [
"def",
"get_index_node",
"(",
"self",
",",
"idx",
")",
":",
"idx",
"=",
"self",
".",
"node_index",
".",
"index",
"(",
"idx",
")",
"return",
"self",
".",
"nodes",
"[",
"idx",
"]"
] | get node with iterindex `idx` | [
"get",
"node",
"with",
"iterindex",
"idx"
] | python | train | 36.5 |
taskcluster/taskcluster-client.py | taskcluster/auth.py | https://github.com/taskcluster/taskcluster-client.py/blob/bcc95217f8bf80bed2ae5885a19fa0035da7ebc9/taskcluster/auth.py#L501-L512 | def azureContainers(self, *args, **kwargs):
"""
List containers in an Account Managed by Auth
Retrieve a list of all containers in an account.
This method gives output: ``v1/azure-container-list-response.json#``
This method is ``stable``
"""
return self._makeA... | [
"def",
"azureContainers",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_makeApiCall",
"(",
"self",
".",
"funcinfo",
"[",
"\"azureContainers\"",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | List containers in an Account Managed by Auth
Retrieve a list of all containers in an account.
This method gives output: ``v1/azure-container-list-response.json#``
This method is ``stable`` | [
"List",
"containers",
"in",
"an",
"Account",
"Managed",
"by",
"Auth"
] | python | train | 30.5 |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/tokumx.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/tokumx.py#L210-L248 | def create_event(self, state, server, agentConfig):
"""Create an event with a message describing the replication
state of a mongo node"""
def get_state_description(state):
if state == 0:
return 'Starting Up'
elif state == 1:
return 'Pr... | [
"def",
"create_event",
"(",
"self",
",",
"state",
",",
"server",
",",
"agentConfig",
")",
":",
"def",
"get_state_description",
"(",
"state",
")",
":",
"if",
"state",
"==",
"0",
":",
"return",
"'Starting Up'",
"elif",
"state",
"==",
"1",
":",
"return",
"'... | Create an event with a message describing the replication
state of a mongo node | [
"Create",
"an",
"event",
"with",
"a",
"message",
"describing",
"the",
"replication",
"state",
"of",
"a",
"mongo",
"node"
] | python | train | 31.384615 |
kgiusti/pyngus | examples/rpc-server.py | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/rpc-server.py#L92-L100 | def process_input(self):
"""Called when socket is read-ready"""
try:
pyngus.read_socket_input(self.connection, self.socket)
except Exception as e:
LOG.error("Exception on socket read: %s", str(e))
self.connection.close_input()
self.connection.close... | [
"def",
"process_input",
"(",
"self",
")",
":",
"try",
":",
"pyngus",
".",
"read_socket_input",
"(",
"self",
".",
"connection",
",",
"self",
".",
"socket",
")",
"except",
"Exception",
"as",
"e",
":",
"LOG",
".",
"error",
"(",
"\"Exception on socket read: %s\"... | Called when socket is read-ready | [
"Called",
"when",
"socket",
"is",
"read",
"-",
"ready"
] | python | test | 39.888889 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/backwardcompat.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/backwardcompat.py#L106-L112 | def home_lib(home):
"""Return the lib dir under the 'home' installation scheme"""
if hasattr(sys, 'pypy_version_info'):
lib = 'site-packages'
else:
lib = os.path.join('lib', 'python')
return os.path.join(home, lib) | [
"def",
"home_lib",
"(",
"home",
")",
":",
"if",
"hasattr",
"(",
"sys",
",",
"'pypy_version_info'",
")",
":",
"lib",
"=",
"'site-packages'",
"else",
":",
"lib",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'lib'",
",",
"'python'",
")",
"return",
"os",
"... | Return the lib dir under the 'home' installation scheme | [
"Return",
"the",
"lib",
"dir",
"under",
"the",
"home",
"installation",
"scheme"
] | python | test | 34.285714 |
gwpy/gwpy | gwpy/types/index.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/types/index.py#L79-L86 | def is_regular(self):
"""Determine whether this `Index` contains linearly increasing samples
This also works for linear decrease
"""
if self.size <= 1:
return False
return numpy.isclose(numpy.diff(self.value, n=2), 0).all() | [
"def",
"is_regular",
"(",
"self",
")",
":",
"if",
"self",
".",
"size",
"<=",
"1",
":",
"return",
"False",
"return",
"numpy",
".",
"isclose",
"(",
"numpy",
".",
"diff",
"(",
"self",
".",
"value",
",",
"n",
"=",
"2",
")",
",",
"0",
")",
".",
"all... | Determine whether this `Index` contains linearly increasing samples
This also works for linear decrease | [
"Determine",
"whether",
"this",
"Index",
"contains",
"linearly",
"increasing",
"samples"
] | python | train | 33.625 |
pydata/xarray | xarray/core/groupby.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/groupby.py#L700-L747 | def reduce(self, func, dim=None, keep_attrs=None, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, axis=axis, **kwargs)` to ret... | [
"def",
"reduce",
"(",
"self",
",",
"func",
",",
"dim",
"=",
"None",
",",
"keep_attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"dim",
"==",
"DEFAULT_DIMS",
":",
"dim",
"=",
"ALL_DIMS",
"# TODO change this to dim = self._group_dim after",
"# the... | Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, axis=axis, **kwargs)` to return the result of collapsing
an np.ndarray over an integer v... | [
"Reduce",
"the",
"items",
"in",
"this",
"group",
"by",
"applying",
"func",
"along",
"some",
"dimension",
"(",
"s",
")",
"."
] | python | train | 42.083333 |
note35/sinon | sinon/lib/spy.py | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L378-L383 | def reset(self):
"""
Reseting wrapped function
"""
super(SinonSpy, self).unwrap()
super(SinonSpy, self).wrap2spy() | [
"def",
"reset",
"(",
"self",
")",
":",
"super",
"(",
"SinonSpy",
",",
"self",
")",
".",
"unwrap",
"(",
")",
"super",
"(",
"SinonSpy",
",",
"self",
")",
".",
"wrap2spy",
"(",
")"
] | Reseting wrapped function | [
"Reseting",
"wrapped",
"function"
] | python | train | 24.833333 |
interedition/collatex | collatex-pythonport/ClusterShell/RangeSet.py | https://github.com/interedition/collatex/blob/76dd1fcc36047bc66a87d31142e72e98b5347821/collatex-pythonport/ClusterShell/RangeSet.py#L604-L607 | def issubset(self, other):
"""Report whether another set contains this RangeSet."""
self._binary_sanity_check(other)
return set.issubset(self, other) | [
"def",
"issubset",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"_binary_sanity_check",
"(",
"other",
")",
"return",
"set",
".",
"issubset",
"(",
"self",
",",
"other",
")"
] | Report whether another set contains this RangeSet. | [
"Report",
"whether",
"another",
"set",
"contains",
"this",
"RangeSet",
"."
] | python | train | 42.5 |
Esri/ArcREST | src/arcrest/manageorg/_content.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_content.py#L1674-L1763 | def updateItem(self,
itemParameters,
clearEmptyFields=False,
data=None,
metadata=None,
text=None,
serviceUrl=None,
multipart=False):
"""
updates an item's properties using... | [
"def",
"updateItem",
"(",
"self",
",",
"itemParameters",
",",
"clearEmptyFields",
"=",
"False",
",",
"data",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"text",
"=",
"None",
",",
"serviceUrl",
"=",
"None",
",",
"multipart",
"=",
"False",
")",
":",
... | updates an item's properties using the ItemParameter class.
Inputs:
itemParameters - property class to update
clearEmptyFields - boolean, cleans up empty values
data - updates the file property of the service like a .sd file
metadata - this is an xml file that contai... | [
"updates",
"an",
"item",
"s",
"properties",
"using",
"the",
"ItemParameter",
"class",
"."
] | python | train | 39.677778 |
coldfix/udiskie | udiskie/mount.py | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L150-L170 | async def mount(self, device):
"""
Mount the device if not already mounted.
:param device: device object, block device path or mount path
:returns: whether the device is mounted.
"""
device = self._find_device(device)
if not self.is_handleable(device) or not devi... | [
"async",
"def",
"mount",
"(",
"self",
",",
"device",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
"or",
"not",
"device",
".",
"is_filesystem",
":",
"self",
".",... | Mount the device if not already mounted.
:param device: device object, block device path or mount path
:returns: whether the device is mounted. | [
"Mount",
"the",
"device",
"if",
"not",
"already",
"mounted",
"."
] | python | train | 43.333333 |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/conversion.py | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/conversion.py#L231-L286 | def generate_time(signal, sample_rate=1000):
"""
-----
Brief
-----
Function intended to generate a time axis of the input signal.
-----------
Description
-----------
The time axis generated by the acquisition process originates a set of consecutive values that represents the
adv... | [
"def",
"generate_time",
"(",
"signal",
",",
"sample_rate",
"=",
"1000",
")",
":",
"# Download of signal if the input is a url.",
"if",
"_is_a_url",
"(",
"signal",
")",
":",
"# Check if it is a Google Drive sharable link.",
"if",
"\"drive.google\"",
"in",
"signal",
":",
... | -----
Brief
-----
Function intended to generate a time axis of the input signal.
-----------
Description
-----------
The time axis generated by the acquisition process originates a set of consecutive values that represents the
advancement of time, but does not have specific units.
... | [
"-----",
"Brief",
"-----",
"Function",
"intended",
"to",
"generate",
"a",
"time",
"axis",
"of",
"the",
"input",
"signal",
"."
] | python | train | 30.071429 |
KarchinLab/probabilistic2020 | prob2020/python/permutation.py | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L555-L606 | def non_silent_ratio_permutation(context_counts,
context_to_mut,
seq_context,
gene_seq,
num_permutations=10000):
"""Performs null-permutations for non-silent ratio across all genes.
... | [
"def",
"non_silent_ratio_permutation",
"(",
"context_counts",
",",
"context_to_mut",
",",
"seq_context",
",",
"gene_seq",
",",
"num_permutations",
"=",
"10000",
")",
":",
"mycontexts",
"=",
"context_counts",
".",
"index",
".",
"tolist",
"(",
")",
"somatic_base",
"... | Performs null-permutations for non-silent ratio across all genes.
Parameters
----------
context_counts : pd.Series
number of mutations for each context
context_to_mut : dict
dictionary mapping nucleotide context to a list of observed
somatic base changes.
seq_context : Seque... | [
"Performs",
"null",
"-",
"permutations",
"for",
"non",
"-",
"silent",
"ratio",
"across",
"all",
"genes",
"."
] | python | train | 40.942308 |
Cadair/jupyter_environment_kernels | environment_kernels/envs_common.py | https://github.com/Cadair/jupyter_environment_kernels/blob/3da304550b511bda7d5d39280379b5ca39bb31bc/environment_kernels/envs_common.py#L96-L121 | def validate_IRkernel(venv_dir):
"""Validates that this env contains an IRkernel kernel and returns info to start it
Returns: tuple
(ARGV, language, resource_dir)
"""
r_exe_name = find_exe(venv_dir, "R")
if r_exe_name is None:
return [], None, None
# check if this is really an... | [
"def",
"validate_IRkernel",
"(",
"venv_dir",
")",
":",
"r_exe_name",
"=",
"find_exe",
"(",
"venv_dir",
",",
"\"R\"",
")",
"if",
"r_exe_name",
"is",
"None",
":",
"return",
"[",
"]",
",",
"None",
",",
"None",
"# check if this is really an IRkernel **kernel**",
"im... | Validates that this env contains an IRkernel kernel and returns info to start it
Returns: tuple
(ARGV, language, resource_dir) | [
"Validates",
"that",
"this",
"env",
"contains",
"an",
"IRkernel",
"kernel",
"and",
"returns",
"info",
"to",
"start",
"it"
] | python | train | 41.5 |
seperman/deepdiff | deepdiff/search.py | https://github.com/seperman/deepdiff/blob/a66879190fadc671632f154c1fcb82f5c3cef800/deepdiff/search.py#L174-L218 | def __search_dict(self,
obj,
item,
parent,
parents_ids=frozenset({}),
print_as_attribute=False):
"""Search dictionaries"""
if print_as_attribute:
parent_text = "%s.%s"
else:
... | [
"def",
"__search_dict",
"(",
"self",
",",
"obj",
",",
"item",
",",
"parent",
",",
"parents_ids",
"=",
"frozenset",
"(",
"{",
"}",
")",
",",
"print_as_attribute",
"=",
"False",
")",
":",
"if",
"print_as_attribute",
":",
"parent_text",
"=",
"\"%s.%s\"",
"els... | Search dictionaries | [
"Search",
"dictionaries"
] | python | train | 31.844444 |
angr/angr | angr/analyses/cfg/cfg_fast.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/cfg/cfg_fast.py#L102-L126 | def pop_job(self, returning=True):
"""
Pop a job from the pending jobs list.
When returning == True, we prioritize the jobs whose functions are known to be returning (function.returning is
True). As an optimization, we are sorting the pending jobs list according to job.function.returnin... | [
"def",
"pop_job",
"(",
"self",
",",
"returning",
"=",
"True",
")",
":",
"if",
"not",
"self",
":",
"return",
"None",
"if",
"not",
"returning",
":",
"return",
"self",
".",
"_pop_job",
"(",
"next",
"(",
"reversed",
"(",
"self",
".",
"_jobs",
".",
"keys"... | Pop a job from the pending jobs list.
When returning == True, we prioritize the jobs whose functions are known to be returning (function.returning is
True). As an optimization, we are sorting the pending jobs list according to job.function.returning.
:param bool returning: Only pop a pending j... | [
"Pop",
"a",
"job",
"from",
"the",
"pending",
"jobs",
"list",
"."
] | python | train | 38.12 |
kstaniek/condoor | condoor/connection.py | https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/connection.py#L617-L622 | def msg_callback(self, callback):
"""Set the message callback."""
if callable(callback):
self._msg_callback = callback
else:
self._msg_callback = None | [
"def",
"msg_callback",
"(",
"self",
",",
"callback",
")",
":",
"if",
"callable",
"(",
"callback",
")",
":",
"self",
".",
"_msg_callback",
"=",
"callback",
"else",
":",
"self",
".",
"_msg_callback",
"=",
"None"
] | Set the message callback. | [
"Set",
"the",
"message",
"callback",
"."
] | python | train | 32.166667 |
osrg/ryu | ryu/lib/stringify.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/stringify.py#L328-L361 | def from_jsondict(cls, dict_, decode_string=base64.b64decode,
**additional_args):
r"""Create an instance from a JSON style dict.
Instantiate this class with parameters specified by the dict.
This method takes the following arguments.
.. tabularcolumns:: |l|L|
... | [
"def",
"from_jsondict",
"(",
"cls",
",",
"dict_",
",",
"decode_string",
"=",
"base64",
".",
"b64decode",
",",
"*",
"*",
"additional_args",
")",
":",
"decode",
"=",
"lambda",
"k",
",",
"x",
":",
"cls",
".",
"_decode_value",
"(",
"k",
",",
"x",
",",
"d... | r"""Create an instance from a JSON style dict.
Instantiate this class with parameters specified by the dict.
This method takes the following arguments.
.. tabularcolumns:: |l|L|
=============== =====================================================
Argument Descrpition
... | [
"r",
"Create",
"an",
"instance",
"from",
"a",
"JSON",
"style",
"dict",
"."
] | python | train | 44.470588 |
ktbyers/netmiko | netmiko/extreme/extreme_slx_ssh.py | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_slx_ssh.py#L24-L33 | def save_config(
self,
cmd="copy running-config startup-config",
confirm=True,
confirm_response="y",
):
"""Save Config for Extreme SLX."""
return super(ExtremeSlxSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"copy running-config startup-config\"",
",",
"confirm",
"=",
"True",
",",
"confirm_response",
"=",
"\"y\"",
",",
")",
":",
"return",
"super",
"(",
"ExtremeSlxSSH",
",",
"self",
")",
".",
"save_config",
"(",... | Save Config for Extreme SLX. | [
"Save",
"Config",
"for",
"Extreme",
"SLX",
"."
] | python | train | 31 |
SuLab/WikidataIntegrator | wikidataintegrator/wdi_core.py | https://github.com/SuLab/WikidataIntegrator/blob/8ceb2ed1c08fec070ec9edfcf7db7b8691481b62/wikidataintegrator/wdi_core.py#L764-L778 | def get_aliases(self, lang='en'):
"""
Retrieve the aliases in a certain language
:param lang: The Wikidata language the description should be retrieved for
:return: Returns a list of aliases, an empty list if none exist for the specified language
"""
if self.fast_run:
... | [
"def",
"get_aliases",
"(",
"self",
",",
"lang",
"=",
"'en'",
")",
":",
"if",
"self",
".",
"fast_run",
":",
"return",
"list",
"(",
"self",
".",
"fast_run_container",
".",
"get_language_data",
"(",
"self",
".",
"wd_item_id",
",",
"lang",
",",
"'aliases'",
... | Retrieve the aliases in a certain language
:param lang: The Wikidata language the description should be retrieved for
:return: Returns a list of aliases, an empty list if none exist for the specified language | [
"Retrieve",
"the",
"aliases",
"in",
"a",
"certain",
"language",
":",
"param",
"lang",
":",
"The",
"Wikidata",
"language",
"the",
"description",
"should",
"be",
"retrieved",
"for",
":",
"return",
":",
"Returns",
"a",
"list",
"of",
"aliases",
"an",
"empty",
... | python | train | 45.333333 |
Frzk/Ellis | ellis/rule.py | https://github.com/Frzk/Ellis/blob/39ce8987cbc503354cf1f45927344186a8b18363/ellis/rule.py#L59-L73 | def check_limit(self, limit):
"""
Checks if the given limit is valid.
A limit must be > 0 to be considered valid.
Raises ValueError when the *limit* is not > 0.
"""
if limit > 0:
self.limit = limit
else:
raise ValueError("Rule limit must ... | [
"def",
"check_limit",
"(",
"self",
",",
"limit",
")",
":",
"if",
"limit",
">",
"0",
":",
"self",
".",
"limit",
"=",
"limit",
"else",
":",
"raise",
"ValueError",
"(",
"\"Rule limit must be strictly > 0 ({0} given)\"",
".",
"format",
"(",
"limit",
")",
")",
... | Checks if the given limit is valid.
A limit must be > 0 to be considered valid.
Raises ValueError when the *limit* is not > 0. | [
"Checks",
"if",
"the",
"given",
"limit",
"is",
"valid",
"."
] | python | train | 26.666667 |
reingart/gui2py | gui/tools/migrate.py | https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/tools/migrate.py#L186-L192 | def migrate_font(font):
"Convert PythonCard font description to gui2py style"
if 'faceName' in font:
font['face'] = font.pop('faceName')
if 'family' in font and font['family'] == 'sansSerif':
font['family'] = 'sans serif'
return font | [
"def",
"migrate_font",
"(",
"font",
")",
":",
"if",
"'faceName'",
"in",
"font",
":",
"font",
"[",
"'face'",
"]",
"=",
"font",
".",
"pop",
"(",
"'faceName'",
")",
"if",
"'family'",
"in",
"font",
"and",
"font",
"[",
"'family'",
"]",
"==",
"'sansSerif'",
... | Convert PythonCard font description to gui2py style | [
"Convert",
"PythonCard",
"font",
"description",
"to",
"gui2py",
"style"
] | python | test | 37 |
vtkiorg/vtki | vtki/plotting.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/plotting.py#L2533-L2566 | def set_background(self, color, loc='all'):
"""
Sets background color
Parameters
----------
color : string or 3 item list, optional, defaults to white
Either a string, rgb list, or hex color string. For example:
color='white'
color='w... | [
"def",
"set_background",
"(",
"self",
",",
"color",
",",
"loc",
"=",
"'all'",
")",
":",
"if",
"color",
"is",
"None",
":",
"color",
"=",
"rcParams",
"[",
"'background'",
"]",
"if",
"isinstance",
"(",
"color",
",",
"str",
")",
":",
"if",
"color",
".",
... | Sets background color
Parameters
----------
color : string or 3 item list, optional, defaults to white
Either a string, rgb list, or hex color string. For example:
color='white'
color='w'
color=[1, 1, 1]
color='#FFFFFF... | [
"Sets",
"background",
"color"
] | python | train | 34.794118 |
oanda/v20-python | src/v20/transaction.py | https://github.com/oanda/v20-python/blob/f28192f4a31bce038cf6dfa302f5878bec192fe5/src/v20/transaction.py#L6388-L6409 | def from_dict(data, ctx):
"""
Instantiate a new PositionFinancing from a dict (generally from loading
a JSON response). The data used to instantiate the PositionFinancing is
a shallow copy of the dict passed in, with any complex child types
instantiated appropriately.
"""... | [
"def",
"from_dict",
"(",
"data",
",",
"ctx",
")",
":",
"data",
"=",
"data",
".",
"copy",
"(",
")",
"if",
"data",
".",
"get",
"(",
"'financing'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'financing'",
"]",
"=",
"ctx",
".",
"convert_decimal_number"... | Instantiate a new PositionFinancing from a dict (generally from loading
a JSON response). The data used to instantiate the PositionFinancing is
a shallow copy of the dict passed in, with any complex child types
instantiated appropriately. | [
"Instantiate",
"a",
"new",
"PositionFinancing",
"from",
"a",
"dict",
"(",
"generally",
"from",
"loading",
"a",
"JSON",
"response",
")",
".",
"The",
"data",
"used",
"to",
"instantiate",
"the",
"PositionFinancing",
"is",
"a",
"shallow",
"copy",
"of",
"the",
"d... | python | train | 34.954545 |
juztin/flask-tracy | flask_tracy/base.py | https://github.com/juztin/flask-tracy/blob/8a43094f0fced3c216f7b65ad6c5c7a22c14ea25/flask_tracy/base.py#L76-L107 | def _after(self, response):
"""Calculates the request duration, and adds a transaction
ID to the header.
"""
# Ignore excluded routes.
if getattr(request, '_tracy_exclude', False):
return response
duration = None
if getattr(request, '_tracy_start_time... | [
"def",
"_after",
"(",
"self",
",",
"response",
")",
":",
"# Ignore excluded routes.",
"if",
"getattr",
"(",
"request",
",",
"'_tracy_exclude'",
",",
"False",
")",
":",
"return",
"response",
"duration",
"=",
"None",
"if",
"getattr",
"(",
"request",
",",
"'_tr... | Calculates the request duration, and adds a transaction
ID to the header. | [
"Calculates",
"the",
"request",
"duration",
"and",
"adds",
"a",
"transaction",
"ID",
"to",
"the",
"header",
"."
] | python | valid | 33.375 |
mosdef-hub/mbuild | mbuild/compound.py | https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/compound.py#L979-L993 | def xyz(self):
"""Return all particle coordinates in this compound.
Returns
-------
pos : np.ndarray, shape=(n, 3), dtype=float
Array with the positions of all particles.
"""
if not self.children:
pos = np.expand_dims(self._pos, axis=0)
el... | [
"def",
"xyz",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"children",
":",
"pos",
"=",
"np",
".",
"expand_dims",
"(",
"self",
".",
"_pos",
",",
"axis",
"=",
"0",
")",
"else",
":",
"arr",
"=",
"np",
".",
"fromiter",
"(",
"itertools",
".",
"... | Return all particle coordinates in this compound.
Returns
-------
pos : np.ndarray, shape=(n, 3), dtype=float
Array with the positions of all particles. | [
"Return",
"all",
"particle",
"coordinates",
"in",
"this",
"compound",
"."
] | python | train | 33.666667 |
JnyJny/Geometry | Geometry/point.py | https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/point.py#L148-L157 | def units(cls, scale=1):
'''
:scale: optional integer scaling factor
:return: list of three Point subclass
Returns three points whose coordinates are the head of a
unit vector from the origin ( conventionally i, j and k).
'''
return [cls(x=scale), cls(y=scale), ... | [
"def",
"units",
"(",
"cls",
",",
"scale",
"=",
"1",
")",
":",
"return",
"[",
"cls",
"(",
"x",
"=",
"scale",
")",
",",
"cls",
"(",
"y",
"=",
"scale",
")",
",",
"cls",
"(",
"z",
"=",
"scale",
")",
"]"
] | :scale: optional integer scaling factor
:return: list of three Point subclass
Returns three points whose coordinates are the head of a
unit vector from the origin ( conventionally i, j and k). | [
":",
"scale",
":",
"optional",
"integer",
"scaling",
"factor",
":",
"return",
":",
"list",
"of",
"three",
"Point",
"subclass"
] | python | train | 32.4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.