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 |
|---|---|---|---|---|---|---|---|---|---|
materialsproject/pymatgen | pymatgen/vis/structure_vtk.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/vis/structure_vtk.py#L329-L335 | def zoom(self, factor):
"""
Zoom the camera view by a factor.
"""
camera = self.ren.GetActiveCamera()
camera.Zoom(factor)
self.ren_win.Render() | [
"def",
"zoom",
"(",
"self",
",",
"factor",
")",
":",
"camera",
"=",
"self",
".",
"ren",
".",
"GetActiveCamera",
"(",
")",
"camera",
".",
"Zoom",
"(",
"factor",
")",
"self",
".",
"ren_win",
".",
"Render",
"(",
")"
] | Zoom the camera view by a factor. | [
"Zoom",
"the",
"camera",
"view",
"by",
"a",
"factor",
"."
] | python | train | 26.428571 |
christophertbrown/bioscripts | ctbBio/rRNA_copies.py | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_copies.py#L54-L74 | def parse_rna(rna, s2bins, min_rna):
"""
parse [16,23]SfromHMM.py output
- rna_cov[scaffold] = [0, 0, []] # [bases, length, ranges]
"""
rna_cov = {}
for seq in parse_fasta(rna):
# check that length passes threshold
length = len(seq[1])
if length < min_rna:
con... | [
"def",
"parse_rna",
"(",
"rna",
",",
"s2bins",
",",
"min_rna",
")",
":",
"rna_cov",
"=",
"{",
"}",
"for",
"seq",
"in",
"parse_fasta",
"(",
"rna",
")",
":",
"# check that length passes threshold",
"length",
"=",
"len",
"(",
"seq",
"[",
"1",
"]",
")",
"i... | parse [16,23]SfromHMM.py output
- rna_cov[scaffold] = [0, 0, []] # [bases, length, ranges] | [
"parse",
"[",
"16",
"23",
"]",
"SfromHMM",
".",
"py",
"output",
"-",
"rna_cov",
"[",
"scaffold",
"]",
"=",
"[",
"0",
"0",
"[]",
"]",
"#",
"[",
"bases",
"length",
"ranges",
"]"
] | python | train | 32.333333 |
pmacosta/pexdoc | pexdoc/exh.py | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L835-L860 | def _get_callable_full_name(self, fob, fin, uobj):
"""Get full path [module, class (if applicable), function name] of callable."""
# Check if object is a class property
name = self._property_search(fob)
if name:
del fob, fin, uobj
return name
if os.path.is... | [
"def",
"_get_callable_full_name",
"(",
"self",
",",
"fob",
",",
"fin",
",",
"uobj",
")",
":",
"# Check if object is a class property",
"name",
"=",
"self",
".",
"_property_search",
"(",
"fob",
")",
"if",
"name",
":",
"del",
"fob",
",",
"fin",
",",
"uobj",
... | Get full path [module, class (if applicable), function name] of callable. | [
"Get",
"full",
"path",
"[",
"module",
"class",
"(",
"if",
"applicable",
")",
"function",
"name",
"]",
"of",
"callable",
"."
] | python | train | 43.384615 |
lobocv/pyperform | pyperform/benchmark.py | https://github.com/lobocv/pyperform/blob/97d87e8b9ddb35bd8f2a6782965fd7735ab0349f/pyperform/benchmark.py#L85-L92 | def run_timeit(self, stmt, setup):
""" Create the function call statement as a string used for timeit. """
_timer = timeit.Timer(stmt=stmt, setup=setup)
trials = _timer.repeat(self.timeit_repeat, self.timeit_number)
self.time_average_seconds = sum(trials) / len(trials) / self.timeit_numb... | [
"def",
"run_timeit",
"(",
"self",
",",
"stmt",
",",
"setup",
")",
":",
"_timer",
"=",
"timeit",
".",
"Timer",
"(",
"stmt",
"=",
"stmt",
",",
"setup",
"=",
"setup",
")",
"trials",
"=",
"_timer",
".",
"repeat",
"(",
"self",
".",
"timeit_repeat",
",",
... | Create the function call statement as a string used for timeit. | [
"Create",
"the",
"function",
"call",
"statement",
"as",
"a",
"string",
"used",
"for",
"timeit",
"."
] | python | train | 56.125 |
wreckage/django-happenings | happenings/templatetags/weekday.py | https://github.com/wreckage/django-happenings/blob/7bca5576efa6cd4c4e87356bf9e5b8cd538ae91d/happenings/templatetags/weekday.py#L12-L48 | def weekday(year_or_num, month=None, day=None, full=False):
"""Simple tag - returns the weekday of the given (year, month, day) or of given (weekday_number).
Usage (in template):
{% weekday 2014 3 3 %}
Result: Mon
Return abbreviation by default. To return full name: pass full=True
{% weekda... | [
"def",
"weekday",
"(",
"year_or_num",
",",
"month",
"=",
"None",
",",
"day",
"=",
"None",
",",
"full",
"=",
"False",
")",
":",
"if",
"any",
"(",
"[",
"month",
",",
"day",
"]",
")",
"and",
"not",
"all",
"(",
"[",
"month",
",",
"day",
"]",
")",
... | Simple tag - returns the weekday of the given (year, month, day) or of given (weekday_number).
Usage (in template):
{% weekday 2014 3 3 %}
Result: Mon
Return abbreviation by default. To return full name: pass full=True
{% weekday 2014 3 3 full=True %}
Result: Monday
When only number ... | [
"Simple",
"tag",
"-",
"returns",
"the",
"weekday",
"of",
"the",
"given",
"(",
"year",
"month",
"day",
")",
"or",
"of",
"given",
"(",
"weekday_number",
")",
"."
] | python | test | 25.783784 |
Autodesk/aomi | aomi/filez.py | https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L102-L132 | def thaw_decrypt(vault_client, src_file, tmp_dir, opt):
"""Decrypts the encrypted ice file"""
if not os.path.isdir(opt.secrets):
LOG.info("Creating secret directory %s", opt.secrets)
os.mkdir(opt.secrets)
zip_file = "%s/aomi.zip" % tmp_dir
if opt.gpg_pass_path:
gpg_path_bits =... | [
"def",
"thaw_decrypt",
"(",
"vault_client",
",",
"src_file",
",",
"tmp_dir",
",",
"opt",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"opt",
".",
"secrets",
")",
":",
"LOG",
".",
"info",
"(",
"\"Creating secret directory %s\"",
",",
"opt"... | Decrypts the encrypted ice file | [
"Decrypts",
"the",
"encrypted",
"ice",
"file"
] | python | train | 36.903226 |
cltk/cltk | cltk/utils/contributors.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/utils/contributors.py#L46-L53 | def scantree(path: str) -> Generator:
"""Recursively yield DirEntry objects for given directory."""
for entry in os.scandir(path):
if entry.is_dir(follow_symlinks=False):
yield from scantree(entry.path)
else:
if entry.name.endswith('.py'):
yield entry | [
"def",
"scantree",
"(",
"path",
":",
"str",
")",
"->",
"Generator",
":",
"for",
"entry",
"in",
"os",
".",
"scandir",
"(",
"path",
")",
":",
"if",
"entry",
".",
"is_dir",
"(",
"follow_symlinks",
"=",
"False",
")",
":",
"yield",
"from",
"scantree",
"("... | Recursively yield DirEntry objects for given directory. | [
"Recursively",
"yield",
"DirEntry",
"objects",
"for",
"given",
"directory",
"."
] | python | train | 38.5 |
gitpython-developers/GitPython | git/objects/util.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/objects/util.py#L273-L343 | def traverse(self, predicate=lambda i, d: True,
prune=lambda i, d: False, depth=-1, branch_first=True,
visit_once=True, ignore_self=1, as_edge=False):
""":return: iterator yielding of items found when traversing self
:param predicate: f(i,d) returns False if item i at ... | [
"def",
"traverse",
"(",
"self",
",",
"predicate",
"=",
"lambda",
"i",
",",
"d",
":",
"True",
",",
"prune",
"=",
"lambda",
"i",
",",
"d",
":",
"False",
",",
"depth",
"=",
"-",
"1",
",",
"branch_first",
"=",
"True",
",",
"visit_once",
"=",
"True",
... | :return: iterator yielding of items found when traversing self
:param predicate: f(i,d) returns False if item i at depth d should not be included in the result
:param prune:
f(i,d) return True if the search should stop at item i at depth d.
Item i will not be returned.
... | [
":",
"return",
":",
"iterator",
"yielding",
"of",
"items",
"found",
"when",
"traversing",
"self"
] | python | train | 38.633803 |
fastai/fastai | fastai/torch_core.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/torch_core.py#L125-L127 | def data_collate(batch:ItemsList)->Tensor:
"Convert `batch` items to tensor data."
return torch.utils.data.dataloader.default_collate(to_data(batch)) | [
"def",
"data_collate",
"(",
"batch",
":",
"ItemsList",
")",
"->",
"Tensor",
":",
"return",
"torch",
".",
"utils",
".",
"data",
".",
"dataloader",
".",
"default_collate",
"(",
"to_data",
"(",
"batch",
")",
")"
] | Convert `batch` items to tensor data. | [
"Convert",
"batch",
"items",
"to",
"tensor",
"data",
"."
] | python | train | 51.666667 |
pytroll/satpy | satpy/readers/msi_safe.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/msi_safe.py#L172-L189 | def _get_coarse_dataset(self, key, info):
"""Get the coarse dataset refered to by `key` from the XML data."""
angles = self.root.find('.//Tile_Angles')
if key in ['solar_zenith_angle', 'solar_azimuth_angle']:
elts = angles.findall(info['xml_tag'] + '/Values_List/VALUES')
... | [
"def",
"_get_coarse_dataset",
"(",
"self",
",",
"key",
",",
"info",
")",
":",
"angles",
"=",
"self",
".",
"root",
".",
"find",
"(",
"'.//Tile_Angles'",
")",
"if",
"key",
"in",
"[",
"'solar_zenith_angle'",
",",
"'solar_azimuth_angle'",
"]",
":",
"elts",
"="... | Get the coarse dataset refered to by `key` from the XML data. | [
"Get",
"the",
"coarse",
"dataset",
"refered",
"to",
"by",
"key",
"from",
"the",
"XML",
"data",
"."
] | python | train | 51.555556 |
pettarin/ipapy | ipapy/__init__.py | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__init__.py#L104-L121 | def invalid_ipa_characters(unicode_string, indices=False):
"""
Return the list of Unicode characters
in the given Unicode string
that are not IPA valid.
Return ``None`` if ``unicode_string`` is ``None``.
:param str unicode_string: the Unicode string to be parsed
:param bool indices: if ``T... | [
"def",
"invalid_ipa_characters",
"(",
"unicode_string",
",",
"indices",
"=",
"False",
")",
":",
"if",
"unicode_string",
"is",
"None",
":",
"return",
"None",
"if",
"indices",
":",
"return",
"[",
"(",
"i",
",",
"unicode_string",
"[",
"i",
"]",
")",
"for",
... | Return the list of Unicode characters
in the given Unicode string
that are not IPA valid.
Return ``None`` if ``unicode_string`` is ``None``.
:param str unicode_string: the Unicode string to be parsed
:param bool indices: if ``True``, return a list of pairs (index, invalid character),
... | [
"Return",
"the",
"list",
"of",
"Unicode",
"characters",
"in",
"the",
"given",
"Unicode",
"string",
"that",
"are",
"not",
"IPA",
"valid",
"."
] | python | train | 40.888889 |
jeongyoonlee/Kaggler | kaggler/model/nn.py | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/model/nn.py#L43-L158 | def fit(self, X, y, X_val=None, y_val=None):
"""Train a network with the quasi-Newton method.
Args:
X (np.array of float): feature matrix for training
y (np.array of float): target values for training
X_val (np.array of float): feature matrix for validation
... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
",",
"X_val",
"=",
"None",
",",
"y_val",
"=",
"None",
")",
":",
"y",
"=",
"y",
".",
"reshape",
"(",
"(",
"len",
"(",
"y",
")",
",",
"1",
")",
")",
"if",
"sparse",
".",
"issparse",
"(",
"X",
"... | Train a network with the quasi-Newton method.
Args:
X (np.array of float): feature matrix for training
y (np.array of float): target values for training
X_val (np.array of float): feature matrix for validation
y_val (np.array of float): target values for ... | [
"Train",
"a",
"network",
"with",
"the",
"quasi",
"-",
"Newton",
"method",
".",
"Args",
":",
"X",
"(",
"np",
".",
"array",
"of",
"float",
")",
":",
"feature",
"matrix",
"for",
"training",
"y",
"(",
"np",
".",
"array",
"of",
"float",
")",
":",
"targe... | python | train | 37.405172 |
pyviz/holoviews | holoviews/core/util.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/util.py#L466-L495 | def callable_name(callable_obj):
"""
Attempt to return a meaningful name identifying a callable or generator
"""
try:
if (isinstance(callable_obj, type)
and issubclass(callable_obj, param.ParameterizedFunction)):
return callable_obj.__name__
elif (isinstance(calla... | [
"def",
"callable_name",
"(",
"callable_obj",
")",
":",
"try",
":",
"if",
"(",
"isinstance",
"(",
"callable_obj",
",",
"type",
")",
"and",
"issubclass",
"(",
"callable_obj",
",",
"param",
".",
"ParameterizedFunction",
")",
")",
":",
"return",
"callable_obj",
... | Attempt to return a meaningful name identifying a callable or generator | [
"Attempt",
"to",
"return",
"a",
"meaningful",
"name",
"identifying",
"a",
"callable",
"or",
"generator"
] | python | train | 42.533333 |
idlesign/steampak | steampak/cli.py | https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L225-L255 | def get_booster_stats(ctx, currency):
"""Prints out price stats for booster packs available in Steam user inventory."""
username = ctx.obj['username']
inventory = User(username)._get_inventory_raw()
boosters = {}
for item in inventory['rgDescriptions'].values():
is_booster = False
... | [
"def",
"get_booster_stats",
"(",
"ctx",
",",
"currency",
")",
":",
"username",
"=",
"ctx",
".",
"obj",
"[",
"'username'",
"]",
"inventory",
"=",
"User",
"(",
"username",
")",
".",
"_get_inventory_raw",
"(",
")",
"boosters",
"=",
"{",
"}",
"for",
"item",
... | Prints out price stats for booster packs available in Steam user inventory. | [
"Prints",
"out",
"price",
"stats",
"for",
"booster",
"packs",
"available",
"in",
"Steam",
"user",
"inventory",
"."
] | python | train | 28.225806 |
andrewramsay/sk8-drivers | pysk8/pysk8/core.py | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/core.py#L1382-L1403 | def get_supported_connections(self):
"""Returns the number of supported simultaneous BLE connections.
The BLED112 is capable of supporting up to 8 simultaneous BLE connections.
However, the default firmware image has a limit of just 3 devices, which
is a lot easier to run up against. T... | [
"def",
"get_supported_connections",
"(",
"self",
")",
":",
"if",
"self",
".",
"supported_connections",
"!=",
"-",
"1",
":",
"return",
"self",
".",
"supported_connections",
"if",
"self",
".",
"api",
"is",
"None",
":",
"return",
"-",
"1",
"self",
".",
"_set_... | Returns the number of supported simultaneous BLE connections.
The BLED112 is capable of supporting up to 8 simultaneous BLE connections.
However, the default firmware image has a limit of just 3 devices, which
is a lot easier to run up against. This method retrieves the current value
o... | [
"Returns",
"the",
"number",
"of",
"supported",
"simultaneous",
"BLE",
"connections",
"."
] | python | train | 38.045455 |
jgorset/facebook | facebook/user.py | https://github.com/jgorset/facebook/blob/90f035ae1828e4eeb7af428964fedf0ee99ec2ad/facebook/user.py#L190-L210 | def accounts(self):
"""
A list of structures describing apps and pages owned by this user.
"""
response = self.graph.get('%s/accounts' % self.id)
accounts = []
for item in response['data']:
account = Structure(
page = Page(
... | [
"def",
"accounts",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"graph",
".",
"get",
"(",
"'%s/accounts'",
"%",
"self",
".",
"id",
")",
"accounts",
"=",
"[",
"]",
"for",
"item",
"in",
"response",
"[",
"'data'",
"]",
":",
"account",
"=",
"St... | A list of structures describing apps and pages owned by this user. | [
"A",
"list",
"of",
"structures",
"describing",
"apps",
"and",
"pages",
"owned",
"by",
"this",
"user",
"."
] | python | train | 28.52381 |
geomet/geomet | geomet/wkb.py | https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L595-L633 | def _load_point(big_endian, type_bytes, data_bytes):
"""
Convert byte data for a Point to a GeoJSON `dict`.
:param bool big_endian:
If `True`, interpret the ``data_bytes`` in big endian order, else
little endian.
:param str type_bytes:
4-byte integer (as a binary string) indicat... | [
"def",
"_load_point",
"(",
"big_endian",
",",
"type_bytes",
",",
"data_bytes",
")",
":",
"endian_token",
"=",
"'>'",
"if",
"big_endian",
"else",
"'<'",
"if",
"type_bytes",
"==",
"WKB_2D",
"[",
"'Point'",
"]",
":",
"coords",
"=",
"struct",
".",
"unpack",
"(... | Convert byte data for a Point to a GeoJSON `dict`.
:param bool big_endian:
If `True`, interpret the ``data_bytes`` in big endian order, else
little endian.
:param str type_bytes:
4-byte integer (as a binary string) indicating the geometry type
(Point) and the dimensions (2D, Z, ... | [
"Convert",
"byte",
"data",
"for",
"a",
"Point",
"to",
"a",
"GeoJSON",
"dict",
"."
] | python | train | 43 |
klahnakoski/pyLibrary | mo_dots/nones.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/nones.py#L235-L269 | def _assign_to_null(obj, path, value, force=True):
"""
value IS ASSIGNED TO obj[self.path][key]
path IS AN ARRAY OF PROPERTY NAMES
force=False IF YOU PREFER TO use setDefault()
"""
try:
if obj is Null:
return
if _get(obj, CLASS) is NullType:
d = _get(obj, ... | [
"def",
"_assign_to_null",
"(",
"obj",
",",
"path",
",",
"value",
",",
"force",
"=",
"True",
")",
":",
"try",
":",
"if",
"obj",
"is",
"Null",
":",
"return",
"if",
"_get",
"(",
"obj",
",",
"CLASS",
")",
"is",
"NullType",
":",
"d",
"=",
"_get",
"(",... | value IS ASSIGNED TO obj[self.path][key]
path IS AN ARRAY OF PROPERTY NAMES
force=False IF YOU PREFER TO use setDefault() | [
"value",
"IS",
"ASSIGNED",
"TO",
"obj",
"[",
"self",
".",
"path",
"]",
"[",
"key",
"]",
"path",
"IS",
"AN",
"ARRAY",
"OF",
"PROPERTY",
"NAMES",
"force",
"=",
"False",
"IF",
"YOU",
"PREFER",
"TO",
"use",
"setDefault",
"()"
] | python | train | 25.514286 |
dslackw/slpkg | slpkg/main.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/main.py#L722-L745 | def auto_detect(self, args):
"""Check for already Slackware binary packages exist
"""
suffixes = [
".tgz",
".txz",
".tbz",
".tlz"
]
if (not args[0].startswith("-") and args[0] not in self.commands and
args[0].endswit... | [
"def",
"auto_detect",
"(",
"self",
",",
"args",
")",
":",
"suffixes",
"=",
"[",
"\".tgz\"",
",",
"\".txz\"",
",",
"\".tbz\"",
",",
"\".tlz\"",
"]",
"if",
"(",
"not",
"args",
"[",
"0",
"]",
".",
"startswith",
"(",
"\"-\"",
")",
"and",
"args",
"[",
"... | Check for already Slackware binary packages exist | [
"Check",
"for",
"already",
"Slackware",
"binary",
"packages",
"exist"
] | python | train | 34.625 |
PmagPy/PmagPy | SPD/lib/lib_curvature.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_curvature.py#L104-L293 | def LMA(XY,ParIni):
"""
input: list of x and y values [[x_1, y_1], [x_2, y_2], ....], and a tuple containing an initial guess (a, b, r)
which is acquired by using an algebraic circle fit (TaubinSVD)
output: a, b, r. a and b are the center of the fitting circle, and r is the radius
% Geom... | [
"def",
"LMA",
"(",
"XY",
",",
"ParIni",
")",
":",
"factorUp",
"=",
"10",
"factorDown",
"=",
"0.04",
"lambda0",
"=",
"0.01",
"epsilon",
"=",
"0.000001",
"IterMAX",
"=",
"50",
"AdjustMax",
"=",
"20",
"Xshift",
"=",
"0",
"Yshift",
"=",
"0",
"dX",
"=",
... | input: list of x and y values [[x_1, y_1], [x_2, y_2], ....], and a tuple containing an initial guess (a, b, r)
which is acquired by using an algebraic circle fit (TaubinSVD)
output: a, b, r. a and b are the center of the fitting circle, and r is the radius
% Geometric circle fit (minimizing ort... | [
"input",
":",
"list",
"of",
"x",
"and",
"y",
"values",
"[[",
"x_1",
"y_1",
"]",
"[",
"x_2",
"y_2",
"]",
"....",
"]",
"and",
"a",
"tuple",
"containing",
"an",
"initial",
"guess",
"(",
"a",
"b",
"r",
")",
"which",
"is",
"acquired",
"by",
"using",
"... | python | train | 45.273684 |
sorgerlab/indra | indra/sources/bel/api.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/api.py#L241-L256 | def process_cbn_jgif_file(file_name):
"""Return a PybelProcessor by processing a CBN JGIF JSON file.
Parameters
----------
file_name : str
The path to a CBN JGIF JSON file.
Returns
-------
bp : PybelProcessor
A PybelProcessor object which contains INDRA Statements in
... | [
"def",
"process_cbn_jgif_file",
"(",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'r'",
")",
"as",
"jgf",
":",
"return",
"process_pybel_graph",
"(",
"pybel",
".",
"from_cbn_jgif",
"(",
"json",
".",
"load",
"(",
"jgf",
")",
")",
")"
] | Return a PybelProcessor by processing a CBN JGIF JSON file.
Parameters
----------
file_name : str
The path to a CBN JGIF JSON file.
Returns
-------
bp : PybelProcessor
A PybelProcessor object which contains INDRA Statements in
bp.statements. | [
"Return",
"a",
"PybelProcessor",
"by",
"processing",
"a",
"CBN",
"JGIF",
"JSON",
"file",
"."
] | python | train | 27.4375 |
quodlibet/mutagen | mutagen/_util.py | https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/_util.py#L919-L939 | def dict_match(d, key, default=None):
"""Like __getitem__ but works as if the keys() are all filename patterns.
Returns the value of any dict key that matches the passed key.
Args:
d (dict): A dict with filename patterns as keys
key (str): A key potentially matching any of the keys
... | [
"def",
"dict_match",
"(",
"d",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"if",
"key",
"in",
"d",
"and",
"\"[\"",
"not",
"in",
"key",
":",
"return",
"d",
"[",
"key",
"]",
"else",
":",
"for",
"pattern",
",",
"value",
"in",
"iteritems",
"("... | Like __getitem__ but works as if the keys() are all filename patterns.
Returns the value of any dict key that matches the passed key.
Args:
d (dict): A dict with filename patterns as keys
key (str): A key potentially matching any of the keys
default (object): The object to return if no ... | [
"Like",
"__getitem__",
"but",
"works",
"as",
"if",
"the",
"keys",
"()",
"are",
"all",
"filename",
"patterns",
".",
"Returns",
"the",
"value",
"of",
"any",
"dict",
"key",
"that",
"matches",
"the",
"passed",
"key",
"."
] | python | train | 35.095238 |
pycampers/zproc | zproc/state/state.py | https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L253-L265 | def set(self, value: dict):
"""
Set the state, completely over-writing the previous value.
.. caution::
This kind of operation usually leads to a data race.
Please take good care while using this.
Use the :py:func:`atomic` deocrator if you're feeling anxio... | [
"def",
"set",
"(",
"self",
",",
"value",
":",
"dict",
")",
":",
"self",
".",
"_s_request_reply",
"(",
"{",
"Msgs",
".",
"cmd",
":",
"Cmds",
".",
"set_state",
",",
"Msgs",
".",
"info",
":",
"value",
"}",
")"
] | Set the state, completely over-writing the previous value.
.. caution::
This kind of operation usually leads to a data race.
Please take good care while using this.
Use the :py:func:`atomic` deocrator if you're feeling anxious. | [
"Set",
"the",
"state",
"completely",
"over",
"-",
"writing",
"the",
"previous",
"value",
"."
] | python | train | 30.692308 |
pudo/jsonmapping | jsonmapping/elastic.py | https://github.com/pudo/jsonmapping/blob/4cf0a20a393ba82e00651c6fd39522a67a0155de/jsonmapping/elastic.py#L6-L10 | def generate_schema_mapping(resolver, schema_uri, depth=1):
""" Try and recursively iterate a JSON schema and to generate an ES mapping
that encasulates it. """
visitor = SchemaVisitor({'$ref': schema_uri}, resolver)
return _generate_schema_mapping(visitor, set(), depth) | [
"def",
"generate_schema_mapping",
"(",
"resolver",
",",
"schema_uri",
",",
"depth",
"=",
"1",
")",
":",
"visitor",
"=",
"SchemaVisitor",
"(",
"{",
"'$ref'",
":",
"schema_uri",
"}",
",",
"resolver",
")",
"return",
"_generate_schema_mapping",
"(",
"visitor",
","... | Try and recursively iterate a JSON schema and to generate an ES mapping
that encasulates it. | [
"Try",
"and",
"recursively",
"iterate",
"a",
"JSON",
"schema",
"and",
"to",
"generate",
"an",
"ES",
"mapping",
"that",
"encasulates",
"it",
"."
] | python | train | 56.6 |
Alignak-monitoring/alignak | alignak/modules/inner_metrics.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modules/inner_metrics.py#L629-L688 | def manage_service_check_result_brok(self, b): # pylint: disable=too-many-branches
"""A service check result brok has just arrived ..."""
host_name = b.data.get('host_name', None)
service_description = b.data.get('service_description', None)
if not host_name or not service_description:
... | [
"def",
"manage_service_check_result_brok",
"(",
"self",
",",
"b",
")",
":",
"# pylint: disable=too-many-branches",
"host_name",
"=",
"b",
".",
"data",
".",
"get",
"(",
"'host_name'",
",",
"None",
")",
"service_description",
"=",
"b",
".",
"data",
".",
"get",
"... | A service check result brok has just arrived ... | [
"A",
"service",
"check",
"result",
"brok",
"has",
"just",
"arrived",
"..."
] | python | train | 45.8 |
python-diamond/Diamond | src/collectors/passenger_stats/passenger_stats.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L130-L158 | def get_passenger_cpu_usage(self, dict_stats):
"""
Execute % top; and return STDOUT.
"""
try:
proc1 = subprocess.Popen(
["top", "-b", "-n", "2"],
stdout=subprocess.PIPE)
(std_out, std_err) = proc1.communicate()
except OSErro... | [
"def",
"get_passenger_cpu_usage",
"(",
"self",
",",
"dict_stats",
")",
":",
"try",
":",
"proc1",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"top\"",
",",
"\"-b\"",
",",
"\"-n\"",
",",
"\"2\"",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
... | Execute % top; and return STDOUT. | [
"Execute",
"%",
"top",
";",
"and",
"return",
"STDOUT",
"."
] | python | train | 34.827586 |
ga4gh/ga4gh-server | ga4gh/server/backend.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/backend.py#L95-L114 | def _protocolObjectGenerator(self, request, numObjects, getByIndexMethod):
"""
Returns a generator over the results for the specified request, from
a set of protocol objects of the specified size. The objects are
returned by call to the specified method, which must take a single
... | [
"def",
"_protocolObjectGenerator",
"(",
"self",
",",
"request",
",",
"numObjects",
",",
"getByIndexMethod",
")",
":",
"currentIndex",
"=",
"0",
"if",
"request",
".",
"page_token",
":",
"currentIndex",
",",
"=",
"paging",
".",
"_parsePageToken",
"(",
"request",
... | Returns a generator over the results for the specified request, from
a set of protocol objects of the specified size. The objects are
returned by call to the specified method, which must take a single
integer as an argument. The returned generator yields a sequence of
(object, nextPageTo... | [
"Returns",
"a",
"generator",
"over",
"the",
"results",
"for",
"the",
"specified",
"request",
"from",
"a",
"set",
"of",
"protocol",
"objects",
"of",
"the",
"specified",
"size",
".",
"The",
"objects",
"are",
"returned",
"by",
"call",
"to",
"the",
"specified",
... | python | train | 46.1 |
reingart/gui2py | gui/doc/ext/autosummary/__init__.py | https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/doc/ext/autosummary/__init__.py#L402-L420 | def get_import_prefixes_from_env(env):
"""
Obtain current Python import prefixes (for `import_by_name`)
from ``document.env``
"""
prefixes = [None]
currmodule = env.temp_data.get('py:module')
if currmodule:
prefixes.insert(0, currmodule)
currclass = env.temp_data.get('py:class'... | [
"def",
"get_import_prefixes_from_env",
"(",
"env",
")",
":",
"prefixes",
"=",
"[",
"None",
"]",
"currmodule",
"=",
"env",
".",
"temp_data",
".",
"get",
"(",
"'py:module'",
")",
"if",
"currmodule",
":",
"prefixes",
".",
"insert",
"(",
"0",
",",
"currmodule"... | Obtain current Python import prefixes (for `import_by_name`)
from ``document.env`` | [
"Obtain",
"current",
"Python",
"import",
"prefixes",
"(",
"for",
"import_by_name",
")",
"from",
"document",
".",
"env"
] | python | test | 25.368421 |
andreikop/qutepart | qutepart/syntax/__init__.py | https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/syntax/__init__.py#L184-L188 | def _getSyntaxByLanguageName(self, syntaxName):
"""Get syntax by its name. Name is defined in the xml file
"""
xmlFileName = self._syntaxNameToXmlFileName[syntaxName]
return self._getSyntaxByXmlFileName(xmlFileName) | [
"def",
"_getSyntaxByLanguageName",
"(",
"self",
",",
"syntaxName",
")",
":",
"xmlFileName",
"=",
"self",
".",
"_syntaxNameToXmlFileName",
"[",
"syntaxName",
"]",
"return",
"self",
".",
"_getSyntaxByXmlFileName",
"(",
"xmlFileName",
")"
] | Get syntax by its name. Name is defined in the xml file | [
"Get",
"syntax",
"by",
"its",
"name",
".",
"Name",
"is",
"defined",
"in",
"the",
"xml",
"file"
] | python | train | 48.6 |
chrisspen/burlap | burlap/dj.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/dj.py#L579-L591 | def shell(self):
"""
Opens a Django focussed Python shell.
Essentially the equivalent of running `manage.py shell`.
"""
r = self.local_renderer
if '@' in self.genv.host_string:
r.env.shell_host_string = self.genv.host_string
else:
r.env.she... | [
"def",
"shell",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"local_renderer",
"if",
"'@'",
"in",
"self",
".",
"genv",
".",
"host_string",
":",
"r",
".",
"env",
".",
"shell_host_string",
"=",
"self",
".",
"genv",
".",
"host_string",
"else",
":",
"r"... | Opens a Django focussed Python shell.
Essentially the equivalent of running `manage.py shell`. | [
"Opens",
"a",
"Django",
"focussed",
"Python",
"shell",
".",
"Essentially",
"the",
"equivalent",
"of",
"running",
"manage",
".",
"py",
"shell",
"."
] | python | valid | 46.615385 |
vmware/nsxramlclient | nsxramlclient/http_session.py | https://github.com/vmware/nsxramlclient/blob/2ff892f9fb6c6bad411df2258e3a98475d0d5091/nsxramlclient/http_session.py#L78-L127 | def do_request(self, method, url, data=None, headers=None, params=None):
"""
Handle API requests / responses transport
:param method: HTTP method to use as string
:param data: Any data as PyDict (will be converted to XML string)
:param headers: Any data as PyDict
:return... | [
"def",
"do_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"response_content",
"=",
"None",
"if",
"data",
":",
"if",
"headers",
":",
"headers",
".",
"updat... | Handle API requests / responses transport
:param method: HTTP method to use as string
:param data: Any data as PyDict (will be converted to XML string)
:param headers: Any data as PyDict
:return: If response is XML then an xml.etree.ElementTree else the raw content
:raise: Any u... | [
"Handle",
"API",
"requests",
"/",
"responses",
"transport"
] | python | train | 43.76 |
knagra/farnsworth | workshift/utils.py | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/utils.py#L25-L47 | def can_manage(user, semester=None, pool=None, any_pool=False):
"""
Whether a user is allowed to manage a workshift semester. This includes the
current workshift managers, that semester's workshift managers, and site
superusers.
"""
if semester and user in semester.workshift_managers.all():
... | [
"def",
"can_manage",
"(",
"user",
",",
"semester",
"=",
"None",
",",
"pool",
"=",
"None",
",",
"any_pool",
"=",
"False",
")",
":",
"if",
"semester",
"and",
"user",
"in",
"semester",
".",
"workshift_managers",
".",
"all",
"(",
")",
":",
"return",
"True"... | Whether a user is allowed to manage a workshift semester. This includes the
current workshift managers, that semester's workshift managers, and site
superusers. | [
"Whether",
"a",
"user",
"is",
"allowed",
"to",
"manage",
"a",
"workshift",
"semester",
".",
"This",
"includes",
"the",
"current",
"workshift",
"managers",
"that",
"semester",
"s",
"workshift",
"managers",
"and",
"site",
"superusers",
"."
] | python | train | 31.130435 |
StanfordBioinformatics/loom | utils/loomengine_utils/import_manager.py | https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/import_manager.py#L406-L413 | def _set_upload_status(self, file_data_object, upload_status):
""" Set file_data_object.file_resource.upload_status
"""
uuid = file_data_object['uuid']
return self.connection.update_data_object(
uuid,
{'uuid': uuid, 'value': { 'upload_status': upload_status}}
... | [
"def",
"_set_upload_status",
"(",
"self",
",",
"file_data_object",
",",
"upload_status",
")",
":",
"uuid",
"=",
"file_data_object",
"[",
"'uuid'",
"]",
"return",
"self",
".",
"connection",
".",
"update_data_object",
"(",
"uuid",
",",
"{",
"'uuid'",
":",
"uuid"... | Set file_data_object.file_resource.upload_status | [
"Set",
"file_data_object",
".",
"file_resource",
".",
"upload_status"
] | python | train | 39.75 |
dbcli/athenacli | athenacli/main.py | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/main.py#L607-L622 | def need_completion_refresh(queries):
"""Determines if the completion needs a refresh by checking if the sql
statement is an alter, create, drop or change db."""
tokens = {
'use', '\\u',
'create',
'drop'
}
for query in sqlparse.split(queries):
try:
first_... | [
"def",
"need_completion_refresh",
"(",
"queries",
")",
":",
"tokens",
"=",
"{",
"'use'",
",",
"'\\\\u'",
",",
"'create'",
",",
"'drop'",
"}",
"for",
"query",
"in",
"sqlparse",
".",
"split",
"(",
"queries",
")",
":",
"try",
":",
"first_token",
"=",
"query... | Determines if the completion needs a refresh by checking if the sql
statement is an alter, create, drop or change db. | [
"Determines",
"if",
"the",
"completion",
"needs",
"a",
"refresh",
"by",
"checking",
"if",
"the",
"sql",
"statement",
"is",
"an",
"alter",
"create",
"drop",
"or",
"change",
"db",
"."
] | python | train | 28.375 |
theosysbio/means | src/means/approximation/mea/closure_scalar.py | https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/approximation/mea/closure_scalar.py#L107-L121 | def _set_mixed_moments_to_zero(self, closed_central_moments, n_counter):
r"""
In univariate case, set the cross-terms to 0.
:param closed_central_moments: matrix of closed central moment
:param n_counter: a list of :class:`~means.core.descriptors.Moment`\s representing central moments
... | [
"def",
"_set_mixed_moments_to_zero",
"(",
"self",
",",
"closed_central_moments",
",",
"n_counter",
")",
":",
"positive_n_counter",
"=",
"[",
"n",
"for",
"n",
"in",
"n_counter",
"if",
"n",
".",
"order",
">",
"1",
"]",
"if",
"self",
".",
"is_multivariate",
":"... | r"""
In univariate case, set the cross-terms to 0.
:param closed_central_moments: matrix of closed central moment
:param n_counter: a list of :class:`~means.core.descriptors.Moment`\s representing central moments
:type n_counter: list[:class:`~means.core.descriptors.Moment`]
:re... | [
"r",
"In",
"univariate",
"case",
"set",
"the",
"cross",
"-",
"terms",
"to",
"0",
"."
] | python | train | 49.066667 |
zabuldon/teslajsonpy | teslajsonpy/charger.py | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L97-L102 | def update(self):
"""Update the status of the range setting."""
self._controller.update(self._id, wake_if_asleep=False)
data = self._controller.get_charging_params(self._id)
if data and (time.time() - self.__manual_update_time > 60):
self.__maxrange_state = data['charge_to_ma... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_controller",
".",
"update",
"(",
"self",
".",
"_id",
",",
"wake_if_asleep",
"=",
"False",
")",
"data",
"=",
"self",
".",
"_controller",
".",
"get_charging_params",
"(",
"self",
".",
"_id",
")",
"if... | Update the status of the range setting. | [
"Update",
"the",
"status",
"of",
"the",
"range",
"setting",
"."
] | python | train | 54 |
jeffknupp/sandman2 | sandman2/service.py | https://github.com/jeffknupp/sandman2/blob/1ce21d6f7a6df77fa96fab694b0f9bb8469c166b/sandman2/service.py#L202-L232 | def _all_resources(self):
"""Return the complete collection of resources as a list of
dictionaries.
:rtype: :class:`sandman2.model.Model`
"""
queryset = self.__model__.query
args = {k: v for (k, v) in request.args.items() if k not in ('page', 'export')}
limit = N... | [
"def",
"_all_resources",
"(",
"self",
")",
":",
"queryset",
"=",
"self",
".",
"__model__",
".",
"query",
"args",
"=",
"{",
"k",
":",
"v",
"for",
"(",
"k",
",",
"v",
")",
"in",
"request",
".",
"args",
".",
"items",
"(",
")",
"if",
"k",
"not",
"i... | Return the complete collection of resources as a list of
dictionaries.
:rtype: :class:`sandman2.model.Model` | [
"Return",
"the",
"complete",
"collection",
"of",
"resources",
"as",
"a",
"list",
"of",
"dictionaries",
"."
] | python | train | 44.612903 |
googleapis/google-cloud-python | bigquery/google/cloud/bigquery/external_config.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/external_config.py#L110-L123 | def qualifier_encoded(self):
"""Union[str, bytes]: The qualifier encoded in binary.
The type is ``str`` (Python 2.x) or ``bytes`` (Python 3.x). The module
will handle base64 encoding for you.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.... | [
"def",
"qualifier_encoded",
"(",
"self",
")",
":",
"prop",
"=",
"self",
".",
"_properties",
".",
"get",
"(",
"\"qualifierEncoded\"",
")",
"if",
"prop",
"is",
"None",
":",
"return",
"None",
"return",
"base64",
".",
"standard_b64decode",
"(",
"_to_bytes",
"(",... | Union[str, bytes]: The qualifier encoded in binary.
The type is ``str`` (Python 2.x) or ``bytes`` (Python 3.x). The module
will handle base64 encoding for you.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions.%28key%29.bigtableOptio... | [
"Union",
"[",
"str",
"bytes",
"]",
":",
"The",
"qualifier",
"encoded",
"in",
"binary",
"."
] | python | train | 51.285714 |
CivicSpleen/ckcache | ckcache/async.py | https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/async.py#L190-L195 | def list(self, path=None, with_metadata=False, include_partitions=False):
'''get a list of all of the files in the repository'''
return self.upstream.list(
path,
with_metadata=with_metadata,
include_partitions=include_partitions) | [
"def",
"list",
"(",
"self",
",",
"path",
"=",
"None",
",",
"with_metadata",
"=",
"False",
",",
"include_partitions",
"=",
"False",
")",
":",
"return",
"self",
".",
"upstream",
".",
"list",
"(",
"path",
",",
"with_metadata",
"=",
"with_metadata",
",",
"in... | get a list of all of the files in the repository | [
"get",
"a",
"list",
"of",
"all",
"of",
"the",
"files",
"in",
"the",
"repository"
] | python | train | 46 |
pyQode/pyqode.core | pyqode/core/api/code_edit.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/code_edit.py#L1095-L1098 | def showEvent(self, event):
""" Overrides showEvent to update the viewport margins """
super(CodeEdit, self).showEvent(event)
self.panels.refresh() | [
"def",
"showEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"CodeEdit",
",",
"self",
")",
".",
"showEvent",
"(",
"event",
")",
"self",
".",
"panels",
".",
"refresh",
"(",
")"
] | Overrides showEvent to update the viewport margins | [
"Overrides",
"showEvent",
"to",
"update",
"the",
"viewport",
"margins"
] | python | train | 42 |
log2timeline/plaso | plaso/parsers/apache_access.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/apache_access.py#L125-L163 | def _GetISO8601String(self, structure):
"""Normalize date time parsed format to an ISO 8601 date time string.
The date and time values in Apache access log files are formatted as:
"[18/Sep/2011:19:18:28 -0400]".
Args:
structure (pyparsing.ParseResults): structure of tokens derived from a
... | [
"def",
"_GetISO8601String",
"(",
"self",
",",
"structure",
")",
":",
"time_offset",
"=",
"structure",
".",
"time_offset",
"month",
"=",
"timelib",
".",
"MONTH_DICT",
".",
"get",
"(",
"structure",
".",
"month",
".",
"lower",
"(",
")",
",",
"0",
")",
"try"... | Normalize date time parsed format to an ISO 8601 date time string.
The date and time values in Apache access log files are formatted as:
"[18/Sep/2011:19:18:28 -0400]".
Args:
structure (pyparsing.ParseResults): structure of tokens derived from a
line of a text file.
Returns:
str:... | [
"Normalize",
"date",
"time",
"parsed",
"format",
"to",
"an",
"ISO",
"8601",
"date",
"time",
"string",
".",
"The",
"date",
"and",
"time",
"values",
"in",
"Apache",
"access",
"log",
"files",
"are",
"formatted",
"as",
":",
"[",
"18",
"/",
"Sep",
"/",
"201... | python | train | 35.487179 |
contentful/contentful.py | contentful/utils.py | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/utils.py#L56-L67 | def snake_case(a_string):
"""Returns a snake cased version of a string.
:param a_string: any :class:`str` object.
Usage:
>>> snake_case('FooBar')
"foo_bar"
"""
partial = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', a_string)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', partial).lower(... | [
"def",
"snake_case",
"(",
"a_string",
")",
":",
"partial",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"a_string",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"partial",
")",
".",
"lowe... | Returns a snake cased version of a string.
:param a_string: any :class:`str` object.
Usage:
>>> snake_case('FooBar')
"foo_bar" | [
"Returns",
"a",
"snake",
"cased",
"version",
"of",
"a",
"string",
"."
] | python | train | 25.833333 |
shoebot/shoebot | lib/photobot/__init__.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/photobot/__init__.py#L589-L601 | def desaturate(self):
"""Desaturates the layer, making it grayscale.
Instantly removes all color information from the layer,
while maintaing its alpha channel.
"""
alpha = self.img.split()[3]
self.img = self.img.convert("L")
self.img = self.img... | [
"def",
"desaturate",
"(",
"self",
")",
":",
"alpha",
"=",
"self",
".",
"img",
".",
"split",
"(",
")",
"[",
"3",
"]",
"self",
".",
"img",
"=",
"self",
".",
"img",
".",
"convert",
"(",
"\"L\"",
")",
"self",
".",
"img",
"=",
"self",
".",
"img",
... | Desaturates the layer, making it grayscale.
Instantly removes all color information from the layer,
while maintaing its alpha channel. | [
"Desaturates",
"the",
"layer",
"making",
"it",
"grayscale",
".",
"Instantly",
"removes",
"all",
"color",
"information",
"from",
"the",
"layer",
"while",
"maintaing",
"its",
"alpha",
"channel",
"."
] | python | valid | 27.461538 |
yeraydiazdiaz/lunr.py | lunr/stemmer.py | https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/stemmer.py#L174-L219 | def step1ab(self):
"""step1ab() gets rid of plurals and -ed or -ing. e.g.
caresses -> caress
ponies -> poni
ties -> ti
caress -> caress
cats -> cat
feed -> feed
agreed -> agree
disabled -> ... | [
"def",
"step1ab",
"(",
"self",
")",
":",
"if",
"self",
".",
"b",
"[",
"self",
".",
"k",
"]",
"==",
"\"s\"",
":",
"if",
"self",
".",
"ends",
"(",
"\"sses\"",
")",
":",
"self",
".",
"k",
"=",
"self",
".",
"k",
"-",
"2",
"elif",
"self",
".",
"... | step1ab() gets rid of plurals and -ed or -ing. e.g.
caresses -> caress
ponies -> poni
ties -> ti
caress -> caress
cats -> cat
feed -> feed
agreed -> agree
disabled -> disable
matting ... | [
"step1ab",
"()",
"gets",
"rid",
"of",
"plurals",
"and",
"-",
"ed",
"or",
"-",
"ing",
".",
"e",
".",
"g",
"."
] | python | train | 30.826087 |
google/grr | grr/server/grr_response_server/aff4.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L439-L455 | def _MakeCacheInvariant(self, urn, age):
"""Returns an invariant key for an AFF4 object.
The object will be cached based on this key. This function is specifically
extracted to ensure that we encapsulate all security critical aspects of the
AFF4 object so that objects do not leak across security bounda... | [
"def",
"_MakeCacheInvariant",
"(",
"self",
",",
"urn",
",",
"age",
")",
":",
"precondition",
".",
"AssertType",
"(",
"urn",
",",
"Text",
")",
"return",
"\"%s:%s\"",
"%",
"(",
"urn",
",",
"self",
".",
"ParseAgeSpecification",
"(",
"age",
")",
")"
] | Returns an invariant key for an AFF4 object.
The object will be cached based on this key. This function is specifically
extracted to ensure that we encapsulate all security critical aspects of the
AFF4 object so that objects do not leak across security boundaries.
Args:
urn: The urn of the obje... | [
"Returns",
"an",
"invariant",
"key",
"for",
"an",
"AFF4",
"object",
"."
] | python | train | 36.470588 |
SuperCowPowers/workbench | workbench/workers/pe_deep_sim.py | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pe_deep_sim.py#L18-L34 | def execute(self, input_data):
''' Execute method '''
my_ssdeep = input_data['meta_deep']['ssdeep']
my_md5 = input_data['meta_deep']['md5']
# For every PE sample in the database compute my ssdeep fuzzy match
sample_set = self.workbench.generate_sample_set('exe')
results ... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"my_ssdeep",
"=",
"input_data",
"[",
"'meta_deep'",
"]",
"[",
"'ssdeep'",
"]",
"my_md5",
"=",
"input_data",
"[",
"'meta_deep'",
"]",
"[",
"'md5'",
"]",
"# For every PE sample in the database compute my ss... | Execute method | [
"Execute",
"method"
] | python | train | 48.705882 |
gbiggs/rtsprofile | rtsprofile/message_sending.py | https://github.com/gbiggs/rtsprofile/blob/fded6eddcb0b25fe9808b1b12336a4413ea00905/rtsprofile/message_sending.py#L556-L567 | def parse_xml_node(self, node):
'''Parse an xml.dom Node object representing a wait_time condition into
this object.
'''
super(WaitTime, self).parse_xml_node(node)
wait_time_nodes = node.getElementsByTagNameNS(RTS_NS, 'WaitTime')
if wait_time_nodes.length != 1:
... | [
"def",
"parse_xml_node",
"(",
"self",
",",
"node",
")",
":",
"super",
"(",
"WaitTime",
",",
"self",
")",
".",
"parse_xml_node",
"(",
"node",
")",
"wait_time_nodes",
"=",
"node",
".",
"getElementsByTagNameNS",
"(",
"RTS_NS",
",",
"'WaitTime'",
")",
"if",
"w... | Parse an xml.dom Node object representing a wait_time condition into
this object. | [
"Parse",
"an",
"xml",
".",
"dom",
"Node",
"object",
"representing",
"a",
"wait_time",
"condition",
"into",
"this",
"object",
"."
] | python | train | 38.75 |
tuomas2/automate | src/automate/extensions/webui/djangoapp/views.py | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/extensions/webui/djangoapp/views.py#L294-L305 | def toggle_value(request, name):
"""
For manual shortcut links to perform toggle actions
"""
obj = service.system.namespace.get(name, None)
if not obj or service.read_only:
raise Http404
new_status = obj.status = not obj.status
if service.redirect_from_setters:
return HttpRes... | [
"def",
"toggle_value",
"(",
"request",
",",
"name",
")",
":",
"obj",
"=",
"service",
".",
"system",
".",
"namespace",
".",
"get",
"(",
"name",
",",
"None",
")",
"if",
"not",
"obj",
"or",
"service",
".",
"read_only",
":",
"raise",
"Http404",
"new_status... | For manual shortcut links to perform toggle actions | [
"For",
"manual",
"shortcut",
"links",
"to",
"perform",
"toggle",
"actions"
] | python | train | 35.916667 |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L1077-L1100 | def lowdata_fmt():
'''
Validate and format lowdata from incoming unserialized request data
This tool requires that the hypermedia_in tool has already been run.
'''
if cherrypy.request.method.upper() != 'POST':
return
data = cherrypy.request.unserialized_data
# if the data was sen... | [
"def",
"lowdata_fmt",
"(",
")",
":",
"if",
"cherrypy",
".",
"request",
".",
"method",
".",
"upper",
"(",
")",
"!=",
"'POST'",
":",
"return",
"data",
"=",
"cherrypy",
".",
"request",
".",
"unserialized_data",
"# if the data was sent as urlencoded, we need to make i... | Validate and format lowdata from incoming unserialized request data
This tool requires that the hypermedia_in tool has already been run. | [
"Validate",
"and",
"format",
"lowdata",
"from",
"incoming",
"unserialized",
"request",
"data"
] | python | train | 36.291667 |
requests/requests-kerberos | requests_kerberos/kerberos_.py | https://github.com/requests/requests-kerberos/blob/d459afcd20d921f18bc435e8df0f120f3d2ea6a2/requests_kerberos/kerberos_.py#L189-L253 | def generate_request_header(self, response, host, is_preemptive=False):
"""
Generates the GSSAPI authentication token with kerberos.
If any GSSAPI step fails, raise KerberosExchangeError
with failure detail.
"""
# Flags used by kerberos module.
gssflags = kerbe... | [
"def",
"generate_request_header",
"(",
"self",
",",
"response",
",",
"host",
",",
"is_preemptive",
"=",
"False",
")",
":",
"# Flags used by kerberos module.",
"gssflags",
"=",
"kerberos",
".",
"GSS_C_MUTUAL_FLAG",
"|",
"kerberos",
".",
"GSS_C_SEQUENCE_FLAG",
"if",
"... | Generates the GSSAPI authentication token with kerberos.
If any GSSAPI step fails, raise KerberosExchangeError
with failure detail. | [
"Generates",
"the",
"GSSAPI",
"authentication",
"token",
"with",
"kerberos",
"."
] | python | train | 43.876923 |
astropy/photutils | photutils/segmentation/properties.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/segmentation/properties.py#L555-L563 | def bbox(self):
"""
The bounding box ``(ymin, xmin, ymax, xmax)`` of the minimal
rectangular region containing the source segment.
"""
# (stop - 1) to return the max pixel location, not the slice index
return (self._slice[0].start, self._slice[1].start,
s... | [
"def",
"bbox",
"(",
"self",
")",
":",
"# (stop - 1) to return the max pixel location, not the slice index",
"return",
"(",
"self",
".",
"_slice",
"[",
"0",
"]",
".",
"start",
",",
"self",
".",
"_slice",
"[",
"1",
"]",
".",
"start",
",",
"self",
".",
"_slice"... | The bounding box ``(ymin, xmin, ymax, xmax)`` of the minimal
rectangular region containing the source segment. | [
"The",
"bounding",
"box",
"(",
"ymin",
"xmin",
"ymax",
"xmax",
")",
"of",
"the",
"minimal",
"rectangular",
"region",
"containing",
"the",
"source",
"segment",
"."
] | python | train | 40.888889 |
sloria/konch | konch.py | https://github.com/sloria/konch/blob/15160bd0a0cac967eeeab84794bd6cdd0b5b637d/konch.py#L285-L289 | def context_list2dict(context_list: typing.Sequence[typing.Any]) -> Context:
"""Converts a list of objects (functions, classes, or modules) to a
dictionary mapping the object names to the objects.
"""
return {obj.__name__.split(".")[-1]: obj for obj in context_list} | [
"def",
"context_list2dict",
"(",
"context_list",
":",
"typing",
".",
"Sequence",
"[",
"typing",
".",
"Any",
"]",
")",
"->",
"Context",
":",
"return",
"{",
"obj",
".",
"__name__",
".",
"split",
"(",
"\".\"",
")",
"[",
"-",
"1",
"]",
":",
"obj",
"for",... | Converts a list of objects (functions, classes, or modules) to a
dictionary mapping the object names to the objects. | [
"Converts",
"a",
"list",
"of",
"objects",
"(",
"functions",
"classes",
"or",
"modules",
")",
"to",
"a",
"dictionary",
"mapping",
"the",
"object",
"names",
"to",
"the",
"objects",
"."
] | python | train | 55.6 |
dtmilano/AndroidViewClient | src/com/dtmilano/android/controlpanel.py | https://github.com/dtmilano/AndroidViewClient/blob/7e6e83fde63af99e5e4ab959712ecf94f9881aa2/src/com/dtmilano/android/controlpanel.py#L152-L157 | def tabLayout(self):
''' For all tabs, specify the number of buttons in a row '''
self.childWindow.column += 1
if self.childWindow.column > Layout.BUTTONS_NUMBER:
self.childWindow.column = 0
self.childWindow.row += 1 | [
"def",
"tabLayout",
"(",
"self",
")",
":",
"self",
".",
"childWindow",
".",
"column",
"+=",
"1",
"if",
"self",
".",
"childWindow",
".",
"column",
">",
"Layout",
".",
"BUTTONS_NUMBER",
":",
"self",
".",
"childWindow",
".",
"column",
"=",
"0",
"self",
".... | For all tabs, specify the number of buttons in a row | [
"For",
"all",
"tabs",
"specify",
"the",
"number",
"of",
"buttons",
"in",
"a",
"row"
] | python | train | 43.166667 |
wandb/client | wandb/__init__.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/__init__.py#L361-L405 | def save(glob_str, base_path=None, policy="live"):
""" Ensure all files matching *glob_str* are synced to wandb with the policy specified.
base_path: the base path to run the glob relative to
policy:
live: upload the file as it changes, overwriting the previous version
end: only upload file... | [
"def",
"save",
"(",
"glob_str",
",",
"base_path",
"=",
"None",
",",
"policy",
"=",
"\"live\"",
")",
":",
"global",
"_saved_files",
"if",
"run",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"You must call `wandb.init` before calling save\"",
")",
"if",
"polic... | Ensure all files matching *glob_str* are synced to wandb with the policy specified.
base_path: the base path to run the glob relative to
policy:
live: upload the file as it changes, overwriting the previous version
end: only upload file when the run ends | [
"Ensure",
"all",
"files",
"matching",
"*",
"glob_str",
"*",
"are",
"synced",
"to",
"wandb",
"with",
"the",
"policy",
"specified",
"."
] | python | train | 42.377778 |
git-afsantos/bonsai | bonsai/model.py | https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L1218-L1225 | def pretty_str(self, indent=0):
"""Return a human-readable string representation of this object.
Kwargs:
indent (int): The amount of spaces to use as indentation.
"""
spaces = ' ' * indent
return spaces + ', '.join(v.pretty_str() for v in self.variables) | [
"def",
"pretty_str",
"(",
"self",
",",
"indent",
"=",
"0",
")",
":",
"spaces",
"=",
"' '",
"*",
"indent",
"return",
"spaces",
"+",
"', '",
".",
"join",
"(",
"v",
".",
"pretty_str",
"(",
")",
"for",
"v",
"in",
"self",
".",
"variables",
")"
] | Return a human-readable string representation of this object.
Kwargs:
indent (int): The amount of spaces to use as indentation. | [
"Return",
"a",
"human",
"-",
"readable",
"string",
"representation",
"of",
"this",
"object",
"."
] | python | train | 37.5 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L402-L406 | def time_since(self, mtype):
'''return the time since the last message of type mtype was received'''
if not mtype in self.messages:
return time.time() - self.start_time
return time.time() - self.messages[mtype]._timestamp | [
"def",
"time_since",
"(",
"self",
",",
"mtype",
")",
":",
"if",
"not",
"mtype",
"in",
"self",
".",
"messages",
":",
"return",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"start_time",
"return",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
... | return the time since the last message of type mtype was received | [
"return",
"the",
"time",
"since",
"the",
"last",
"message",
"of",
"type",
"mtype",
"was",
"received"
] | python | train | 50.6 |
mohamedattahri/PyXMLi | pyxmli/__init__.py | https://github.com/mohamedattahri/PyXMLi/blob/a81a245be822d62f1a20c734ca14b42c786ae81e/pyxmli/__init__.py#L767-L774 | def compute_total(self, precision=None):
'''
Gets the total of the invoice with a defined decimal precision
@param precision: int Number of decimal places
@return: Decimal
'''
return quantize(sum([group.compute_total(precision) for group
in se... | [
"def",
"compute_total",
"(",
"self",
",",
"precision",
"=",
"None",
")",
":",
"return",
"quantize",
"(",
"sum",
"(",
"[",
"group",
".",
"compute_total",
"(",
"precision",
")",
"for",
"group",
"in",
"self",
".",
"__groups",
"]",
")",
",",
"places",
"=",... | Gets the total of the invoice with a defined decimal precision
@param precision: int Number of decimal places
@return: Decimal | [
"Gets",
"the",
"total",
"of",
"the",
"invoice",
"with",
"a",
"defined",
"decimal",
"precision"
] | python | train | 44.125 |
rsmuc/health_monitoring_plugins | health_monitoring_plugins/__init__.py | https://github.com/rsmuc/health_monitoring_plugins/blob/7ac29dfb9fe46c055b018cb72ad0d7d8065589b9/health_monitoring_plugins/__init__.py#L23-L33 | def update_status(self, helper, status):
""" update the helper """
if status:
self.status(status[0])
# if the status is ok, add it to the long output
if status[0] == 0:
self.add_long_output(status[1])
# if the status is not ok, add it to t... | [
"def",
"update_status",
"(",
"self",
",",
"helper",
",",
"status",
")",
":",
"if",
"status",
":",
"self",
".",
"status",
"(",
"status",
"[",
"0",
"]",
")",
"# if the status is ok, add it to the long output",
"if",
"status",
"[",
"0",
"]",
"==",
"0",
":",
... | update the helper | [
"update",
"the",
"helper"
] | python | train | 34.727273 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/work_item_tracking/work_item_tracking_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/work_item_tracking/work_item_tracking_client.py#L247-L271 | def get_classification_node(self, project, structure_group, path=None, depth=None):
"""GetClassificationNode.
Gets the classification node for a given node path.
:param str project: Project ID or project name
:param TreeStructureGroup structure_group: Structure group of the classificatio... | [
"def",
"get_classification_node",
"(",
"self",
",",
"project",
",",
"structure_group",
",",
"path",
"=",
"None",
",",
"depth",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'"... | GetClassificationNode.
Gets the classification node for a given node path.
:param str project: Project ID or project name
:param TreeStructureGroup structure_group: Structure group of the classification node, area or iteration.
:param str path: Path of the classification node.
:p... | [
"GetClassificationNode",
".",
"Gets",
"the",
"classification",
"node",
"for",
"a",
"given",
"node",
"path",
".",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
"TreeStructureGroup",
"structure_group",
":",
"Structure... | python | train | 60.04 |
ttinies/sc2common | sc2common/containers.py | https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/containers.py#L276-L290 | def angle2d(self):
"""determine the angle of this point on a circle, measured in radians (presume values represent a Vector)"""
if self.x==0:
if self.y<0: return math.pi/2.0*3
elif self.y>0: return math.pi/2.0
else: return 0
elif self... | [
"def",
"angle2d",
"(",
"self",
")",
":",
"if",
"self",
".",
"x",
"==",
"0",
":",
"if",
"self",
".",
"y",
"<",
"0",
":",
"return",
"math",
".",
"pi",
"/",
"2.0",
"*",
"3",
"elif",
"self",
".",
"y",
">",
"0",
":",
"return",
"math",
".",
"pi",... | determine the angle of this point on a circle, measured in radians (presume values represent a Vector) | [
"determine",
"the",
"angle",
"of",
"this",
"point",
"on",
"a",
"circle",
"measured",
"in",
"radians",
"(",
"presume",
"values",
"represent",
"a",
"Vector",
")"
] | python | train | 42.8 |
phoebe-project/phoebe2 | phoebe/distortions/roche.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/distortions/roche.py#L146-L157 | def d2BinaryRochedx2(r, D, q, F):
"""
Computes second derivative of the potential with respect to x.
@param r: relative radius vector (3 components)
@param D: instantaneous separation
@param q: mass ratio
@param F: synchronicity parameter
"""
return (2*r[0]*r[0]-r[1]... | [
"def",
"d2BinaryRochedx2",
"(",
"r",
",",
"D",
",",
"q",
",",
"F",
")",
":",
"return",
"(",
"2",
"*",
"r",
"[",
"0",
"]",
"*",
"r",
"[",
"0",
"]",
"-",
"r",
"[",
"1",
"]",
"*",
"r",
"[",
"1",
"]",
"-",
"r",
"[",
"2",
"]",
"*",
"r",
... | Computes second derivative of the potential with respect to x.
@param r: relative radius vector (3 components)
@param D: instantaneous separation
@param q: mass ratio
@param F: synchronicity parameter | [
"Computes",
"second",
"derivative",
"of",
"the",
"potential",
"with",
"respect",
"to",
"x",
"."
] | python | train | 40.583333 |
redhat-cip/dci-control-server | dci/api/v1/utils.py | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L41-L68 | def createCertRequest(pkey, digest="sha256"):
"""
Create a certificate request.
Arguments: pkey - The key to associate with the request
digest - Digestion method to use for signing, default is sha256
**name - The name of the subject of the request, possible
... | [
"def",
"createCertRequest",
"(",
"pkey",
",",
"digest",
"=",
"\"sha256\"",
")",
":",
"req",
"=",
"crypto",
".",
"X509Req",
"(",
")",
"req",
".",
"get_subject",
"(",
")",
".",
"C",
"=",
"\"FR\"",
"req",
".",
"get_subject",
"(",
")",
".",
"ST",
"=",
... | Create a certificate request.
Arguments: pkey - The key to associate with the request
digest - Digestion method to use for signing, default is sha256
**name - The name of the subject of the request, possible
arguments are:
C - Cou... | [
"Create",
"a",
"certificate",
"request",
".",
"Arguments",
":",
"pkey",
"-",
"The",
"key",
"to",
"associate",
"with",
"the",
"request",
"digest",
"-",
"Digestion",
"method",
"to",
"use",
"for",
"signing",
"default",
"is",
"sha256",
"**",
"name",
"-",
"The"... | python | train | 37.785714 |
LonamiWebs/Telethon | telethon/network/authenticator.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/authenticator.py#L172-L181 | def get_int(byte_array, signed=True):
"""
Gets the specified integer from its byte array.
This should be used by this module alone, as it works with big endian.
:param byte_array: the byte array representing th integer.
:param signed: whether the number is signed or not.
:return: the integer re... | [
"def",
"get_int",
"(",
"byte_array",
",",
"signed",
"=",
"True",
")",
":",
"return",
"int",
".",
"from_bytes",
"(",
"byte_array",
",",
"byteorder",
"=",
"'big'",
",",
"signed",
"=",
"signed",
")"
] | Gets the specified integer from its byte array.
This should be used by this module alone, as it works with big endian.
:param byte_array: the byte array representing th integer.
:param signed: whether the number is signed or not.
:return: the integer representing the given byte array. | [
"Gets",
"the",
"specified",
"integer",
"from",
"its",
"byte",
"array",
".",
"This",
"should",
"be",
"used",
"by",
"this",
"module",
"alone",
"as",
"it",
"works",
"with",
"big",
"endian",
"."
] | python | train | 42.1 |
foremast/foremast | src/foremast/elb/create_elb.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/elb/create_elb.py#L47-L112 | def make_elb_json(self):
"""Render the JSON template with arguments.
Returns:
str: Rendered ELB template.
"""
env = self.env
region = self.region
elb_settings = self.properties['elb']
LOG.debug('Block ELB Settings:\n%s', pformat(elb_settings))
... | [
"def",
"make_elb_json",
"(",
"self",
")",
":",
"env",
"=",
"self",
".",
"env",
"region",
"=",
"self",
".",
"region",
"elb_settings",
"=",
"self",
".",
"properties",
"[",
"'elb'",
"]",
"LOG",
".",
"debug",
"(",
"'Block ELB Settings:\\n%s'",
",",
"pformat",
... | Render the JSON template with arguments.
Returns:
str: Rendered ELB template. | [
"Render",
"the",
"JSON",
"template",
"with",
"arguments",
"."
] | python | train | 40.712121 |
mardix/Juice | juice/cli.py | https://github.com/mardix/Juice/blob/7afa8d4238868235dfcdae82272bd77958dd416a/juice/cli.py#L273-L298 | def serve(project, port, no_watch):
""" Serve application in development mode """
header("Serving application in development mode ... ")
print("- Project: %s " % project)
print("")
print("- Port: %s" % port)
print("")
module = import_module(project, True)
extra_files = []
if not n... | [
"def",
"serve",
"(",
"project",
",",
"port",
",",
"no_watch",
")",
":",
"header",
"(",
"\"Serving application in development mode ... \"",
")",
"print",
"(",
"\"- Project: %s \"",
"%",
"project",
")",
"print",
"(",
"\"\"",
")",
"print",
"(",
"\"- Port: %s\"",
"%... | Serve application in development mode | [
"Serve",
"application",
"in",
"development",
"mode"
] | python | train | 31.115385 |
LIVVkit/LIVVkit | livvkit/util/options.py | https://github.com/LIVVkit/LIVVkit/blob/680120cd437e408673e62e535fc0a246c7fc17db/livvkit/util/options.py#L111-L191 | def init(options):
""" Initialize some defaults """
# Set matlplotlib's backend so LIVVkit can plot to files.
import matplotlib
matplotlib.use('agg')
livvkit.output_dir = os.path.abspath(options.out_dir)
livvkit.index_dir = livvkit.output_dir
livvkit.verify = True if options.verify is not ... | [
"def",
"init",
"(",
"options",
")",
":",
"# Set matlplotlib's backend so LIVVkit can plot to files.",
"import",
"matplotlib",
"matplotlib",
".",
"use",
"(",
"'agg'",
")",
"livvkit",
".",
"output_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"options",
".",
... | Initialize some defaults | [
"Initialize",
"some",
"defaults"
] | python | train | 46.283951 |
mcash/merchant-api-python-sdk | mcash/mapi_client/mapi_client.py | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/mapi_client.py#L547-L559 | def update_shortlink(self, shortlink_id, callback_uri=None,
description=None):
"""Update existing shortlink registration
Arguments:
shortlink_id:
Shortlink id assigned by mCASH
"""
arguments = {'callback_uri': callback_uri,
... | [
"def",
"update_shortlink",
"(",
"self",
",",
"shortlink_id",
",",
"callback_uri",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"arguments",
"=",
"{",
"'callback_uri'",
":",
"callback_uri",
",",
"'description'",
":",
"description",
"}",
"return",
"se... | Update existing shortlink registration
Arguments:
shortlink_id:
Shortlink id assigned by mCASH | [
"Update",
"existing",
"shortlink",
"registration"
] | python | train | 39.230769 |
berkeley-cocosci/Wallace | wallace/custom.py | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/custom.py#L383-L415 | def create_participant(worker_id, hit_id, assignment_id, mode):
"""Create a participant.
This route will be hit very early on as any nodes the participant creates
will be defined in reference to the participant object.
You must specify the worker_id, hit_id, assignment_id and mode in the url.
"""
... | [
"def",
"create_participant",
"(",
"worker_id",
",",
"hit_id",
",",
"assignment_id",
",",
"mode",
")",
":",
"# check this worker hasn't already taken part",
"parts",
"=",
"models",
".",
"Participant",
".",
"query",
".",
"filter_by",
"(",
"worker_id",
"=",
"worker_id"... | Create a participant.
This route will be hit very early on as any nodes the participant creates
will be defined in reference to the participant object.
You must specify the worker_id, hit_id, assignment_id and mode in the url. | [
"Create",
"a",
"participant",
"."
] | python | train | 41.787879 |
NetEaseGame/ATX | atx/cmds/tkgui.py | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/cmds/tkgui.py#L100-L156 | def _init_items(self):
"""
.---------------.
| Ctrl | Screen |
|------| |
| Code | |
| | |
"""
root = self._root
root.resizable(0, 0)
frm_control = tk.Frame(root, bg='#bbb')
frm_control.grid(column=0, row=... | [
"def",
"_init_items",
"(",
"self",
")",
":",
"root",
"=",
"self",
".",
"_root",
"root",
".",
"resizable",
"(",
"0",
",",
"0",
")",
"frm_control",
"=",
"tk",
".",
"Frame",
"(",
"root",
",",
"bg",
"=",
"'#bbb'",
")",
"frm_control",
".",
"grid",
"(",
... | .---------------.
| Ctrl | Screen |
|------| |
| Code | |
| | | | [
".",
"---------------",
".",
"|",
"Ctrl",
"|",
"Screen",
"|",
"|",
"------",
"|",
"|",
"|",
"Code",
"|",
"|",
"|",
"|",
"|"
] | python | train | 60.035088 |
wdm0006/git-pandas | gitpandas/repository.py | https://github.com/wdm0006/git-pandas/blob/e56b817b1d66b8296d1d5e703d5db0e181d25899/gitpandas/repository.py#L621-L687 | def cumulative_blame(self, branch='master', limit=None, skip=None, num_datapoints=None, committer=True,
ignore_globs=None, include_globs=None):
"""
Returns the blame at every revision of interest. Index is a datetime, column per committer, with number of lines
blamed to ... | [
"def",
"cumulative_blame",
"(",
"self",
",",
"branch",
"=",
"'master'",
",",
"limit",
"=",
"None",
",",
"skip",
"=",
"None",
",",
"num_datapoints",
"=",
"None",
",",
"committer",
"=",
"True",
",",
"ignore_globs",
"=",
"None",
",",
"include_globs",
"=",
"... | Returns the blame at every revision of interest. Index is a datetime, column per committer, with number of lines
blamed to each committer at each timestamp as data.
:param branch: (optional, default 'master') the branch to work in
:param limit: (optional, default None), the maximum number of re... | [
"Returns",
"the",
"blame",
"at",
"every",
"revision",
"of",
"interest",
".",
"Index",
"is",
"a",
"datetime",
"column",
"per",
"committer",
"with",
"number",
"of",
"lines",
"blamed",
"to",
"each",
"committer",
"at",
"each",
"timestamp",
"as",
"data",
"."
] | python | train | 45.164179 |
pantsbuild/pants | src/python/pants/backend/jvm/tasks/jvm_dependency_analyzer.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/jvm_dependency_analyzer.py#L78-L87 | def targets_for_class(self, target, classname):
"""Search which targets from `target`'s transitive dependencies contain `classname`."""
targets_with_class = set()
for target in target.closure():
for one_class in self._target_classes(target):
if classname in one_class:
targets_with_cl... | [
"def",
"targets_for_class",
"(",
"self",
",",
"target",
",",
"classname",
")",
":",
"targets_with_class",
"=",
"set",
"(",
")",
"for",
"target",
"in",
"target",
".",
"closure",
"(",
")",
":",
"for",
"one_class",
"in",
"self",
".",
"_target_classes",
"(",
... | Search which targets from `target`'s transitive dependencies contain `classname`. | [
"Search",
"which",
"targets",
"from",
"target",
"s",
"transitive",
"dependencies",
"contain",
"classname",
"."
] | python | train | 37.3 |
CI-WATER/gsshapy | gsshapy/orm/wms_dataset.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/wms_dataset.py#L308-L390 | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, maskMap):
"""
WMS Dataset File Read from File Method
"""
# Assign file extension attribute to file object
self.fileExtension = extension
if isinstance(maskMap, RasterMapFile... | [
"def",
"_read",
"(",
"self",
",",
"directory",
",",
"filename",
",",
"session",
",",
"path",
",",
"name",
",",
"extension",
",",
"spatial",
",",
"spatialReferenceID",
",",
"maskMap",
")",
":",
"# Assign file extension attribute to file object",
"self",
".",
"fil... | WMS Dataset File Read from File Method | [
"WMS",
"Dataset",
"File",
"Read",
"from",
"File",
"Method"
] | python | train | 46.108434 |
alertot/detectem | detectem/response.py | https://github.com/alertot/detectem/blob/b1ecc3543b7c44ee76c4cac0d3896a7747bf86c1/detectem/response.py#L194-L223 | def get_valid_har(har_data):
""" Return list of valid HAR entries.
:rtype: list
"""
new_entries = []
entries = har_data.get('log', {}).get('entries', [])
logger.debug('[+] Detected %(n)d entries in HAR', {'n': len(entries)})
for entry in entries:
url = entry['request']['url']
... | [
"def",
"get_valid_har",
"(",
"har_data",
")",
":",
"new_entries",
"=",
"[",
"]",
"entries",
"=",
"har_data",
".",
"get",
"(",
"'log'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'entries'",
",",
"[",
"]",
")",
"logger",
".",
"debug",
"(",
"'[+] Detected %... | Return list of valid HAR entries.
:rtype: list | [
"Return",
"list",
"of",
"valid",
"HAR",
"entries",
"."
] | python | train | 26.533333 |
respondcreate/django-versatileimagefield | versatileimagefield/image_warmer.py | https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/image_warmer.py#L128-L156 | def warm(self):
"""
Returns a 2-tuple:
[0]: Number of images successfully pre-warmed
[1]: A list of paths on the storage class associated with the
VersatileImageField field being processed by `self` of
files that could not be successfully seeded.
"""
... | [
"def",
"warm",
"(",
"self",
")",
":",
"num_images_pre_warmed",
"=",
"0",
"failed_to_create_image_path_list",
"=",
"[",
"]",
"total",
"=",
"self",
".",
"queryset",
".",
"count",
"(",
")",
"*",
"len",
"(",
"self",
".",
"size_key_list",
")",
"for",
"a",
","... | Returns a 2-tuple:
[0]: Number of images successfully pre-warmed
[1]: A list of paths on the storage class associated with the
VersatileImageField field being processed by `self` of
files that could not be successfully seeded. | [
"Returns",
"a",
"2",
"-",
"tuple",
":",
"[",
"0",
"]",
":",
"Number",
"of",
"images",
"successfully",
"pre",
"-",
"warmed",
"[",
"1",
"]",
":",
"A",
"list",
"of",
"paths",
"on",
"the",
"storage",
"class",
"associated",
"with",
"the",
"VersatileImageFie... | python | test | 42.310345 |
smarie/python-valid8 | valid8/composition.py | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L436-L458 | def not_all(*validation_func, # type: ValidationFuncs
**kwargs
):
# type: (...) -> Callable
"""
An alias for not_(and_(validators)).
:param validation_func: the base validation function or list of base validation functions to use. A callable, a
tuple(callable, help_msg_... | [
"def",
"not_all",
"(",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Callable",
"catch_all",
"=",
"pop_kwargs",
"(",
"kwargs",
",",
"[",
"(",
"'catch_all'",
",",
"False",
")",
"]",
")",
"# in case this is... | An alias for not_(and_(validators)).
:param validation_func: the base validation function or list of base validation functions to use. A callable, a
tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several such elements. Nested lists
are supported and indicate an implici... | [
"An",
"alias",
"for",
"not_",
"(",
"and_",
"(",
"validators",
"))",
"."
] | python | train | 54 |
ASMfreaK/habitipy | habitipy/api.py | https://github.com/ASMfreaK/habitipy/blob/555b8b20faf6d553353092614a8a0d612f0adbde/habitipy/api.py#L91-L96 | def escape_keywords(arr):
"""append _ to all python keywords"""
for i in arr:
i = i if i not in kwlist else i + '_'
i = i if '-' not in i else i.replace('-', '_')
yield i | [
"def",
"escape_keywords",
"(",
"arr",
")",
":",
"for",
"i",
"in",
"arr",
":",
"i",
"=",
"i",
"if",
"i",
"not",
"in",
"kwlist",
"else",
"i",
"+",
"'_'",
"i",
"=",
"i",
"if",
"'-'",
"not",
"in",
"i",
"else",
"i",
".",
"replace",
"(",
"'-'",
","... | append _ to all python keywords | [
"append",
"_",
"to",
"all",
"python",
"keywords"
] | python | train | 32.833333 |
welbornprod/colr | colr/controls.py | https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L274-L278 | def print_flush(*args, **kwargs):
""" Like `print()`, except the file is `.flush()`ed afterwards. """
kwargs.setdefault('file', sys.stdout)
print(*args, **kwargs)
kwargs['file'].flush() | [
"def",
"print_flush",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'file'",
",",
"sys",
".",
"stdout",
")",
"print",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"kwargs",
"[",
"'file'",
"]",
".",
"fl... | Like `print()`, except the file is `.flush()`ed afterwards. | [
"Like",
"print",
"()",
"except",
"the",
"file",
"is",
".",
"flush",
"()",
"ed",
"afterwards",
"."
] | python | train | 39.4 |
softlayer/softlayer-python | SoftLayer/CLI/formatting.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/formatting.py#L26-L76 | def format_output(data, fmt='table'): # pylint: disable=R0911,R0912
"""Given some data, will format it for console output.
:param data: One of: String, Table, FormattedItem, List, Tuple,
SequentialOutput
:param string fmt (optional): One of: table, raw, json, python
"""
if isinsta... | [
"def",
"format_output",
"(",
"data",
",",
"fmt",
"=",
"'table'",
")",
":",
"# pylint: disable=R0911,R0912",
"if",
"isinstance",
"(",
"data",
",",
"utils",
".",
"string_types",
")",
":",
"if",
"fmt",
"in",
"(",
"'json'",
",",
"'jsonraw'",
")",
":",
"return"... | Given some data, will format it for console output.
:param data: One of: String, Table, FormattedItem, List, Tuple,
SequentialOutput
:param string fmt (optional): One of: table, raw, json, python | [
"Given",
"some",
"data",
"will",
"format",
"it",
"for",
"console",
"output",
"."
] | python | train | 33.431373 |
ewels/MultiQC | multiqc/modules/minionqc/minionqc.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/minionqc/minionqc.py#L113-L173 | def headers_to_use(self):
'''
Defines features of columns to be used in multiqc table
'''
headers = OrderedDict()
headers['total.reads'] = {
'title': 'Total reads',
'description': 'Total number of reads',
'format': '{:,.0f}',
'scal... | [
"def",
"headers_to_use",
"(",
"self",
")",
":",
"headers",
"=",
"OrderedDict",
"(",
")",
"headers",
"[",
"'total.reads'",
"]",
"=",
"{",
"'title'",
":",
"'Total reads'",
",",
"'description'",
":",
"'Total number of reads'",
",",
"'format'",
":",
"'{:,.0f}'",
"... | Defines features of columns to be used in multiqc table | [
"Defines",
"features",
"of",
"columns",
"to",
"be",
"used",
"in",
"multiqc",
"table"
] | python | train | 30.360656 |
LuminosoInsight/ordered-set | ordered_set.py | https://github.com/LuminosoInsight/ordered-set/blob/a29eaedcedfe5072bcee11bdef61dea321d5e9f9/ordered_set.py#L22-L39 | def is_iterable(obj):
"""
Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays.
Strings, however, should be considered as atomic values to look u... | [
"def",
"is_iterable",
"(",
"obj",
")",
":",
"return",
"(",
"hasattr",
"(",
"obj",
",",
"\"__iter__\"",
")",
"and",
"not",
"isinstance",
"(",
"obj",
",",
"str",
")",
"and",
"not",
"isinstance",
"(",
"obj",
",",
"tuple",
")",
")"
] | Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays.
Strings, however, should be considered as atomic values to look up, not
iterables. The same goe... | [
"Are",
"we",
"being",
"asked",
"to",
"look",
"up",
"a",
"list",
"of",
"things",
"instead",
"of",
"a",
"single",
"thing?",
"We",
"check",
"for",
"the",
"__iter__",
"attribute",
"so",
"that",
"this",
"can",
"cover",
"types",
"that",
"don",
"t",
"have",
"... | python | train | 36.944444 |
lesscpy/lesscpy | lesscpy/lessc/parser.py | https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/lessc/parser.py#L878-L889 | def p_color(self, p):
""" color : css_color
| css_color t_ws
"""
try:
p[0] = Color().fmt(p[1])
if len(p) > 2:
p[0] = [p[0], p[2]]
except ValueError:
self.handle_error('Illegal color ... | [
"def",
"p_color",
"(",
"self",
",",
"p",
")",
":",
"try",
":",
"p",
"[",
"0",
"]",
"=",
"Color",
"(",
")",
".",
"fmt",
"(",
"p",
"[",
"1",
"]",
")",
"if",
"len",
"(",
"p",
")",
">",
"2",
":",
"p",
"[",
"0",
"]",
"=",
"[",
"p",
"[",
... | color : css_color
| css_color t_ws | [
"color",
":",
"css_color",
"|",
"css_color",
"t_ws"
] | python | valid | 33.333333 |
boriel/zxbasic | symbols/strslice.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/strslice.py#L69-L117 | def make_node(cls, lineno, s, lower, upper):
""" Creates a node for a string slice. S is the string expression Tree.
Lower and upper are the bounds, if lower & upper are constants, and
s is also constant, then a string constant is returned.
If lower > upper, an empty string is returned.... | [
"def",
"make_node",
"(",
"cls",
",",
"lineno",
",",
"s",
",",
"lower",
",",
"upper",
")",
":",
"if",
"lower",
"is",
"None",
"or",
"upper",
"is",
"None",
"or",
"s",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"check_type",
"(",
"lineno",
",",
... | Creates a node for a string slice. S is the string expression Tree.
Lower and upper are the bounds, if lower & upper are constants, and
s is also constant, then a string constant is returned.
If lower > upper, an empty string is returned. | [
"Creates",
"a",
"node",
"for",
"a",
"string",
"slice",
".",
"S",
"is",
"the",
"string",
"expression",
"Tree",
".",
"Lower",
"and",
"upper",
"are",
"the",
"bounds",
"if",
"lower",
"&",
"upper",
"are",
"constants",
"and",
"s",
"is",
"also",
"constant",
"... | python | train | 39.428571 |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L220-L251 | def _run_cromwell(args):
"""Run CWL with Cromwell.
"""
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "cromwell_work"))
final_dir = utils.safe_makedir(os.path.join(work_dir, "final"))
if args.no_container:
_... | [
"def",
"_run_cromwell",
"(",
"args",
")",
":",
"main_file",
",",
"json_file",
",",
"project_name",
"=",
"_get_main_and_json",
"(",
"args",
".",
"directory",
")",
"work_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",... | Run CWL with Cromwell. | [
"Run",
"CWL",
"with",
"Cromwell",
"."
] | python | train | 49.46875 |
phaethon/kamene | kamene/plist.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L224-L262 | def conversations(self, getsrcdst=None, draw = True, **kargs):
"""Graphes a conversations between sources and destinations and display it
(using graphviz)
getsrcdst: a function that takes an element of the list and return the source and dest
by defaults, return source and dest... | [
"def",
"conversations",
"(",
"self",
",",
"getsrcdst",
"=",
"None",
",",
"draw",
"=",
"True",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"getsrcdst",
"is",
"None",
":",
"getsrcdst",
"=",
"lambda",
"x",
":",
"(",
"x",
"[",
"'IP'",
"]",
".",
"src",
",... | Graphes a conversations between sources and destinations and display it
(using graphviz)
getsrcdst: a function that takes an element of the list and return the source and dest
by defaults, return source and destination IP
if networkx library is available returns a DiGraph, or ... | [
"Graphes",
"a",
"conversations",
"between",
"sources",
"and",
"destinations",
"and",
"display",
"it",
"(",
"using",
"graphviz",
")",
"getsrcdst",
":",
"a",
"function",
"that",
"takes",
"an",
"element",
"of",
"the",
"list",
"and",
"return",
"the",
"source",
"... | python | train | 39.153846 |
eventbrite/eventbrite-sdk-python | eventbrite/access_methods.py | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/access_methods.py#L117-L126 | def post_event_unpublish(self, id, **data):
"""
POST /events/:id/unpublish/
Unpublishes an event. In order for a free event to be unpublished, it must not have any pending or completed orders,
even if the event is in the past. In order for a paid event to be unpublished, it must not have... | [
"def",
"post_event_unpublish",
"(",
"self",
",",
"id",
",",
"*",
"*",
"data",
")",
":",
"return",
"self",
".",
"post",
"(",
"\"/events/{0}/unpublish/\"",
".",
"format",
"(",
"id",
")",
",",
"data",
"=",
"data",
")"
] | POST /events/:id/unpublish/
Unpublishes an event. In order for a free event to be unpublished, it must not have any pending or completed orders,
even if the event is in the past. In order for a paid event to be unpublished, it must not have any pending or completed
orders, unless the event has b... | [
"POST",
"/",
"events",
"/",
":",
"id",
"/",
"unpublish",
"/",
"Unpublishes",
"an",
"event",
".",
"In",
"order",
"for",
"a",
"free",
"event",
"to",
"be",
"unpublished",
"it",
"must",
"not",
"have",
"any",
"pending",
"or",
"completed",
"orders",
"even",
... | python | train | 57 |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L840-L853 | def save_raw(self):
"""
Save the model to a in memory buffer represetation
Returns
-------
a in memory buffer represetation of the model
"""
length = ctypes.c_ulong()
cptr = ctypes.POINTER(ctypes.c_char)()
_check_call(_LIB.XGBoosterGetModelRaw(sel... | [
"def",
"save_raw",
"(",
"self",
")",
":",
"length",
"=",
"ctypes",
".",
"c_ulong",
"(",
")",
"cptr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char",
")",
"(",
")",
"_check_call",
"(",
"_LIB",
".",
"XGBoosterGetModelRaw",
"(",
"self",
".",
... | Save the model to a in memory buffer represetation
Returns
-------
a in memory buffer represetation of the model | [
"Save",
"the",
"model",
"to",
"a",
"in",
"memory",
"buffer",
"represetation"
] | python | train | 35.714286 |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L641-L678 | def _acceptpeak(peak, amp, definitive_peaks, spk1, rr_buffer):
"""
Private function intended to insert a new RR interval in the buffer.
----------
Parameters
----------
peak : int
Sample where the peak under analysis is located.
amp : int
Amplitude of the peak under analysis... | [
"def",
"_acceptpeak",
"(",
"peak",
",",
"amp",
",",
"definitive_peaks",
",",
"spk1",
",",
"rr_buffer",
")",
":",
"definitive_peaks_out",
"=",
"definitive_peaks",
"definitive_peaks_out",
"=",
"numpy",
".",
"append",
"(",
"definitive_peaks_out",
",",
"peak",
")",
... | Private function intended to insert a new RR interval in the buffer.
----------
Parameters
----------
peak : int
Sample where the peak under analysis is located.
amp : int
Amplitude of the peak under analysis.
definitive_peaks : list
List with the definitive_peaks stored... | [
"Private",
"function",
"intended",
"to",
"insert",
"a",
"new",
"RR",
"interval",
"in",
"the",
"buffer",
"."
] | python | train | 33.947368 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookmanager.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookmanager.py#L150-L166 | def get_notebook_object(self, notebook_id):
"""Get the NotebookNode representation of a notebook by notebook_id."""
path = self.find_path(notebook_id)
if not os.path.isfile(path):
raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_id)
info = os.stat(path)
... | [
"def",
"get_notebook_object",
"(",
"self",
",",
"notebook_id",
")",
":",
"path",
"=",
"self",
".",
"find_path",
"(",
"notebook_id",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"raise",
"web",
".",
"HTTPError",
"(",
"404",... | Get the NotebookNode representation of a notebook by notebook_id. | [
"Get",
"the",
"NotebookNode",
"representation",
"of",
"a",
"notebook",
"by",
"notebook_id",
"."
] | python | test | 47.352941 |
LionelAuroux/pyrser | pyrser/passes/topython.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/passes/topython.py#L106-L133 | def visit_Capture(self, node: parsing.Capture) -> [ast.stmt] or ast.expr:
"""Generates python code to capture text consumed by a clause.
#If all clauses can be inlined
self.beginTag('tagname') and clause and self.endTag('tagname')
if not self.beginTag('tagname'):
return Fal... | [
"def",
"visit_Capture",
"(",
"self",
",",
"node",
":",
"parsing",
".",
"Capture",
")",
"->",
"[",
"ast",
".",
"stmt",
"]",
"or",
"ast",
".",
"expr",
":",
"begintag",
"=",
"ast",
".",
"Attribute",
"(",
"ast",
".",
"Name",
"(",
"'self'",
",",
"ast",
... | Generates python code to capture text consumed by a clause.
#If all clauses can be inlined
self.beginTag('tagname') and clause and self.endTag('tagname')
if not self.beginTag('tagname'):
return False
<code for the clause>
if not self.endTag('tagname'):
r... | [
"Generates",
"python",
"code",
"to",
"capture",
"text",
"consumed",
"by",
"a",
"clause",
"."
] | python | test | 38.285714 |
tornadoweb/tornado | tornado/locks.py | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locks.py#L144-L154 | def notify(self, n: int = 1) -> None:
"""Wake ``n`` waiters."""
waiters = [] # Waiters we plan to run right now.
while n and self._waiters:
waiter = self._waiters.popleft()
if not waiter.done(): # Might have timed out.
n -= 1
waiters.appe... | [
"def",
"notify",
"(",
"self",
",",
"n",
":",
"int",
"=",
"1",
")",
"->",
"None",
":",
"waiters",
"=",
"[",
"]",
"# Waiters we plan to run right now.",
"while",
"n",
"and",
"self",
".",
"_waiters",
":",
"waiter",
"=",
"self",
".",
"_waiters",
".",
"popl... | Wake ``n`` waiters. | [
"Wake",
"n",
"waiters",
"."
] | python | train | 37.545455 |
kapot65/python-df-parser | dfparser/envelope_parser.py | https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/envelope_parser.py#L35-L52 | def parse_from_file(filename, nodata=False):
"""Parse df message from file.
@filename - path to file
@nodata - do not load data
@return - [binary header, metadata, binary data]
"""
header = None
with open(filename, "rb") as file:
header = read_machine_header(file)
meta_raw ... | [
"def",
"parse_from_file",
"(",
"filename",
",",
"nodata",
"=",
"False",
")",
":",
"header",
"=",
"None",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"file",
":",
"header",
"=",
"read_machine_header",
"(",
"file",
")",
"meta_raw",
"=",
"fil... | Parse df message from file.
@filename - path to file
@nodata - do not load data
@return - [binary header, metadata, binary data] | [
"Parse",
"df",
"message",
"from",
"file",
"."
] | python | train | 29.222222 |
chimera0/accel-brain-code | Automatic-Summarization/pysummarization/abstractablesemantics/re_seq_2_seq.py | https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Automatic-Summarization/pysummarization/abstractablesemantics/re_seq_2_seq.py#L746-L775 | def back_propagation(self, delta_arr):
'''
Back propagation.
Args:
delta_output_arr: Delta.
Returns:
Tuple data.
- decoder's `list` of gradations,
- encoder's `np.ndarray` of Delta,
- encoder's `list` of... | [
"def",
"back_propagation",
"(",
"self",
",",
"delta_arr",
")",
":",
"re_encoder_delta_arr",
",",
"delta_hidden_arr",
",",
"re_encoder_grads_list",
"=",
"self",
".",
"__retrospective_encoder",
".",
"hidden_back_propagate",
"(",
"delta_arr",
"[",
":",
",",
"-",
"1",
... | Back propagation.
Args:
delta_output_arr: Delta.
Returns:
Tuple data.
- decoder's `list` of gradations,
- encoder's `np.ndarray` of Delta,
- encoder's `list` of gradations. | [
"Back",
"propagation",
".",
"Args",
":",
"delta_output_arr",
":",
"Delta",
".",
"Returns",
":",
"Tuple",
"data",
".",
"-",
"decoder",
"s",
"list",
"of",
"gradations",
"-",
"encoder",
"s",
"np",
".",
"ndarray",
"of",
"Delta",
"-",
"encoder",
"s",
"list",
... | python | train | 37.633333 |
networks-lab/metaknowledge | metaknowledge/mkCollection.py | https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L309-L334 | def chunk(self, maxSize):
"""Splits the `Collection` into _maxSize_ size or smaller `Collections`
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
`list [Collection]`
> A list of `Collections` that if all m... | [
"def",
"chunk",
"(",
"self",
",",
"maxSize",
")",
":",
"chunks",
"=",
"[",
"]",
"currentSize",
"=",
"maxSize",
"+",
"1",
"for",
"i",
"in",
"self",
":",
"if",
"currentSize",
">=",
"maxSize",
":",
"currentSize",
"=",
"0",
"chunks",
".",
"append",
"(",
... | Splits the `Collection` into _maxSize_ size or smaller `Collections`
# Parameters
_maxSize_ : `int`
> The maximum number of elements in a retuned `Collection`
# Returns
`list [Collection]`
> A list of `Collections` that if all merged (`|` operator) would create the... | [
"Splits",
"the",
"Collection",
"into",
"_maxSize_",
"size",
"or",
"smaller",
"Collections"
] | python | train | 27.923077 |
lpomfrey/django-debreach | debreach/context_processors.py | https://github.com/lpomfrey/django-debreach/blob/b425bb719ea5de583fae7db5b7419e5fed569cb0/debreach/context_processors.py#L14-L36 | def csrf(request):
"""
Context processor that provides a CSRF token, or the string 'NOTPROVIDED'
if it has not been provided by either a view decorator or the middleware
"""
def _get_val():
token = get_token(request)
if token is None:
# In order to be able to provide debu... | [
"def",
"csrf",
"(",
"request",
")",
":",
"def",
"_get_val",
"(",
")",
":",
"token",
"=",
"get_token",
"(",
"request",
")",
"if",
"token",
"is",
"None",
":",
"# In order to be able to provide debugging info in the",
"# case of misconfiguration, we use a sentinel value",
... | Context processor that provides a CSRF token, or the string 'NOTPROVIDED'
if it has not been provided by either a view decorator or the middleware | [
"Context",
"processor",
"that",
"provides",
"a",
"CSRF",
"token",
"or",
"the",
"string",
"NOTPROVIDED",
"if",
"it",
"has",
"not",
"been",
"provided",
"by",
"either",
"a",
"view",
"decorator",
"or",
"the",
"middleware"
] | python | train | 37.608696 |
quodlibet/mutagen | mutagen/_senf/_fsnative.py | https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/_senf/_fsnative.py#L77-L92 | def _codec_can_decode_with_surrogatepass(codec, _cache={}):
"""Returns if a codec supports the surrogatepass error handler when
decoding. Some codecs were broken in Python <3.4
"""
try:
return _cache[codec]
except KeyError:
try:
u"\ud83d".encode(
codec, _... | [
"def",
"_codec_can_decode_with_surrogatepass",
"(",
"codec",
",",
"_cache",
"=",
"{",
"}",
")",
":",
"try",
":",
"return",
"_cache",
"[",
"codec",
"]",
"except",
"KeyError",
":",
"try",
":",
"u\"\\ud83d\"",
".",
"encode",
"(",
"codec",
",",
"_surrogatepass",... | Returns if a codec supports the surrogatepass error handler when
decoding. Some codecs were broken in Python <3.4 | [
"Returns",
"if",
"a",
"codec",
"supports",
"the",
"surrogatepass",
"error",
"handler",
"when",
"decoding",
".",
"Some",
"codecs",
"were",
"broken",
"in",
"Python",
"<3",
".",
"4"
] | python | train | 30.875 |
brunobord/meuhdb | meuhdb/core.py | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L29-L31 | def intersect(d1, d2):
"""Intersect dictionaries d1 and d2 by key *and* value."""
return dict((k, d1[k]) for k in d1 if k in d2 and d1[k] == d2[k]) | [
"def",
"intersect",
"(",
"d1",
",",
"d2",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"d1",
"[",
"k",
"]",
")",
"for",
"k",
"in",
"d1",
"if",
"k",
"in",
"d2",
"and",
"d1",
"[",
"k",
"]",
"==",
"d2",
"[",
"k",
"]",
")"
] | Intersect dictionaries d1 and d2 by key *and* value. | [
"Intersect",
"dictionaries",
"d1",
"and",
"d2",
"by",
"key",
"*",
"and",
"*",
"value",
"."
] | python | train | 51 |
ARMmbed/icetea | icetea_lib/ResourceProvider/ResourceRequirements.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/ResourceProvider/ResourceRequirements.py#L65-L75 | def _recursive_get(self, key, dic=None):
"""
Gets contents of requirement key recursively so users can search for
specific keys inside nested requirement dicts.
:param key: key or dot separated string of keys to look for.
:param dic: Optional dictionary to use in the search.
... | [
"def",
"_recursive_get",
"(",
"self",
",",
"key",
",",
"dic",
"=",
"None",
")",
":",
"return",
"recursive_search",
"(",
"key",
",",
"dic",
")",
"if",
"dic",
"else",
"recursive_search",
"(",
"key",
",",
"self",
".",
"_requirements",
")"
] | Gets contents of requirement key recursively so users can search for
specific keys inside nested requirement dicts.
:param key: key or dot separated string of keys to look for.
:param dic: Optional dictionary to use in the search.
If not provided, self._requirements is used.
:re... | [
"Gets",
"contents",
"of",
"requirement",
"key",
"recursively",
"so",
"users",
"can",
"search",
"for",
"specific",
"keys",
"inside",
"nested",
"requirement",
"dicts",
"."
] | python | train | 46.363636 |
pandas-dev/pandas | pandas/core/groupby/groupby.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1474-L1505 | def _fill(self, direction, limit=None):
"""
Shared function for `pad` and `backfill` to call Cython method.
Parameters
----------
direction : {'ffill', 'bfill'}
Direction passed to underlying Cython function. `bfill` will cause
values to be filled backwar... | [
"def",
"_fill",
"(",
"self",
",",
"direction",
",",
"limit",
"=",
"None",
")",
":",
"# Need int value for Cython",
"if",
"limit",
"is",
"None",
":",
"limit",
"=",
"-",
"1",
"return",
"self",
".",
"_get_cythonized_result",
"(",
"'group_fillna_indexer'",
",",
... | Shared function for `pad` and `backfill` to call Cython method.
Parameters
----------
direction : {'ffill', 'bfill'}
Direction passed to underlying Cython function. `bfill` will cause
values to be filled backwards. `ffill` and any other values will
default to... | [
"Shared",
"function",
"for",
"pad",
"and",
"backfill",
"to",
"call",
"Cython",
"method",
"."
] | python | train | 35.375 |
kodexlab/reliure | reliure/engine.py | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L340-L351 | def defaults(self):
""" component default component
.. Note:: default components is just an indication for user and the
views, except if the Block is required. If required then default is
selected if nothing explisitely selected.
"""
default = self._defaults
... | [
"def",
"defaults",
"(",
"self",
")",
":",
"default",
"=",
"self",
".",
"_defaults",
"# if require and no default, the first component as default",
"if",
"not",
"len",
"(",
"default",
")",
"and",
"self",
".",
"required",
"and",
"len",
"(",
"self",
".",
"_componen... | component default component
.. Note:: default components is just an indication for user and the
views, except if the Block is required. If required then default is
selected if nothing explisitely selected. | [
"component",
"default",
"component"
] | python | train | 45 |
python-bonobo/bonobo | bonobo/nodes/basics.py | https://github.com/python-bonobo/bonobo/blob/70c8e62c4a88576976e5b52e58d380d6e3227ab4/bonobo/nodes/basics.py#L320-L356 | def MapFields(function, key=True):
"""
Transformation factory that maps `function` on the values of a row.
It can be applied either to
1. all columns (`key=True`),
2. no column (`key=False`), or
3. a subset of columns by passing a callable, which takes column name and returns `bool`
(same a... | [
"def",
"MapFields",
"(",
"function",
",",
"key",
"=",
"True",
")",
":",
"@",
"use_raw_input",
"def",
"_MapFields",
"(",
"bag",
")",
":",
"try",
":",
"factory",
"=",
"type",
"(",
"bag",
")",
".",
"_make",
"except",
"AttributeError",
":",
"factory",
"=",... | Transformation factory that maps `function` on the values of a row.
It can be applied either to
1. all columns (`key=True`),
2. no column (`key=False`), or
3. a subset of columns by passing a callable, which takes column name and returns `bool`
(same as the parameter `function` in `filter`).
:... | [
"Transformation",
"factory",
"that",
"maps",
"function",
"on",
"the",
"values",
"of",
"a",
"row",
".",
"It",
"can",
"be",
"applied",
"either",
"to",
"1",
".",
"all",
"columns",
"(",
"key",
"=",
"True",
")",
"2",
".",
"no",
"column",
"(",
"key",
"=",
... | python | train | 31.675676 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.