repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
dropbox/stone | stone/frontend/parser.py | https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/frontend/parser.py#L718-L727 | def p_examples_add(self, p):
'examples : examples example'
p[0] = p[1]
if p[2].label in p[0]:
existing_ex = p[0][p[2].label]
self.errors.append(
("Example with label '%s' already defined on line %d." %
(existing_ex.label, existing_ex.linen... | [
"def",
"p_examples_add",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"if",
"p",
"[",
"2",
"]",
".",
"label",
"in",
"p",
"[",
"0",
"]",
":",
"existing_ex",
"=",
"p",
"[",
"0",
"]",
"[",
"p",
"[",
"2",
"]... | examples : examples example | [
"examples",
":",
"examples",
"example"
] | python | train |
chuck1/codemach | codemach/machine.py | https://github.com/chuck1/codemach/blob/b0e02f363da7aa58de7d6ad6499784282958adeb/codemach/machine.py#L374-L380 | def pop(self, n):
"""
Pop the **n** topmost items from the stack and return them as a ``list``.
"""
poped = self.__stack[len(self.__stack) - n:]
del self.__stack[len(self.__stack) - n:]
return poped | [
"def",
"pop",
"(",
"self",
",",
"n",
")",
":",
"poped",
"=",
"self",
".",
"__stack",
"[",
"len",
"(",
"self",
".",
"__stack",
")",
"-",
"n",
":",
"]",
"del",
"self",
".",
"__stack",
"[",
"len",
"(",
"self",
".",
"__stack",
")",
"-",
"n",
":",... | Pop the **n** topmost items from the stack and return them as a ``list``. | [
"Pop",
"the",
"**",
"n",
"**",
"topmost",
"items",
"from",
"the",
"stack",
"and",
"return",
"them",
"as",
"a",
"list",
"."
] | python | test |
iamteem/redisco | redisco/containers.py | https://github.com/iamteem/redisco/blob/a7ba19ff3c38061d6d8bc0c10fa754baadcfeb91/redisco/containers.py#L145-L147 | def update(self, *others):
"""Update the set, adding elements from all others."""
self.db.sunionstore(self.key, [self.key] + [o.key for o in others]) | [
"def",
"update",
"(",
"self",
",",
"*",
"others",
")",
":",
"self",
".",
"db",
".",
"sunionstore",
"(",
"self",
".",
"key",
",",
"[",
"self",
".",
"key",
"]",
"+",
"[",
"o",
".",
"key",
"for",
"o",
"in",
"others",
"]",
")"
] | Update the set, adding elements from all others. | [
"Update",
"the",
"set",
"adding",
"elements",
"from",
"all",
"others",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/mygaphas/tools.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/tools.py#L750-L777 | def on_button_press(self, event):
"""Handle button press events.
If the (mouse) button is pressed on top of a Handle (item.Handle), that handle is grabbed and can be
dragged around.
"""
if not event.get_button()[1] == 1: # left mouse button
return False
view... | [
"def",
"on_button_press",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"event",
".",
"get_button",
"(",
")",
"[",
"1",
"]",
"==",
"1",
":",
"# left mouse button",
"return",
"False",
"view",
"=",
"self",
".",
"view",
"item",
",",
"handle",
"=",
"... | Handle button press events.
If the (mouse) button is pressed on top of a Handle (item.Handle), that handle is grabbed and can be
dragged around. | [
"Handle",
"button",
"press",
"events",
"."
] | python | train |
rikrd/inspire | inspirespeech/htk_model.py | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk_model.py#L85-L103 | def load_model(*args):
"""Load an HTK model from one ore more files.
:param args: Filenames of the model (e.g. macros hmmdefs)
:return: The model as an OrderedDict()
"""
text = ''
for fnm in args:
text += open(fnm).read()
text += '\n'
parser = htk_model_parser.htk_modelPars... | [
"def",
"load_model",
"(",
"*",
"args",
")",
":",
"text",
"=",
"''",
"for",
"fnm",
"in",
"args",
":",
"text",
"+=",
"open",
"(",
"fnm",
")",
".",
"read",
"(",
")",
"text",
"+=",
"'\\n'",
"parser",
"=",
"htk_model_parser",
".",
"htk_modelParser",
"(",
... | Load an HTK model from one ore more files.
:param args: Filenames of the model (e.g. macros hmmdefs)
:return: The model as an OrderedDict() | [
"Load",
"an",
"HTK",
"model",
"from",
"one",
"ore",
"more",
"files",
"."
] | python | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L450-L496 | def _get_type_of_macro(macros, objs):
r"""Set macros types
Example::
ARG\d -> ARGN,
HOSTBLABLA -> class one and set Host in class)
_HOSTTOTO -> HOST CUSTOM MACRO TOTO
SERVICESTATEID:srv-1:Load$ -> MACRO SERVICESTATEID of the service Load of host srv-1
:param ma... | [
"def",
"_get_type_of_macro",
"(",
"macros",
",",
"objs",
")",
":",
"for",
"macro",
"in",
"macros",
":",
"# ARGN Macros",
"if",
"re",
".",
"match",
"(",
"r'ARG\\d'",
",",
"macro",
")",
":",
"macros",
"[",
"macro",
"]",
"[",
"'type'",
"]",
"=",
"'ARGN'",... | r"""Set macros types
Example::
ARG\d -> ARGN,
HOSTBLABLA -> class one and set Host in class)
_HOSTTOTO -> HOST CUSTOM MACRO TOTO
SERVICESTATEID:srv-1:Load$ -> MACRO SERVICESTATEID of the service Load of host srv-1
:param macros: macros list in a dictionary
:typ... | [
"r",
"Set",
"macros",
"types"
] | python | train |
AltSchool/dynamic-rest | dynamic_rest/routers.py | https://github.com/AltSchool/dynamic-rest/blob/5b0338c3dd8bc638d60c3bb92645857c5b89c920/dynamic_rest/routers.py#L227-L246 | def get_canonical_path(resource_key, pk=None):
"""
Return canonical resource path.
Arguments:
resource_key - Canonical resource key
i.e. Serializer.get_resource_key().
pk - (Optional) Object's primary key for a single-resource URL.
Retu... | [
"def",
"get_canonical_path",
"(",
"resource_key",
",",
"pk",
"=",
"None",
")",
":",
"if",
"resource_key",
"not",
"in",
"resource_map",
":",
"# Note: Maybe raise?",
"return",
"None",
"base_path",
"=",
"get_script_prefix",
"(",
")",
"+",
"resource_map",
"[",
"reso... | Return canonical resource path.
Arguments:
resource_key - Canonical resource key
i.e. Serializer.get_resource_key().
pk - (Optional) Object's primary key for a single-resource URL.
Returns: Absolute URL as string. | [
"Return",
"canonical",
"resource",
"path",
"."
] | python | train |
google/apitools | apitools/gen/service_registry.py | https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/gen/service_registry.py#L371-L421 | def __ComputeMethodInfo(self, method_description, request, response,
request_field):
"""Compute the base_api.ApiMethodInfo for this method."""
relative_path = self.__names.NormalizeRelativePath(
''.join((self.__client_info.base_path,
method_de... | [
"def",
"__ComputeMethodInfo",
"(",
"self",
",",
"method_description",
",",
"request",
",",
"response",
",",
"request_field",
")",
":",
"relative_path",
"=",
"self",
".",
"__names",
".",
"NormalizeRelativePath",
"(",
"''",
".",
"join",
"(",
"(",
"self",
".",
... | Compute the base_api.ApiMethodInfo for this method. | [
"Compute",
"the",
"base_api",
".",
"ApiMethodInfo",
"for",
"this",
"method",
"."
] | python | train |
dswah/pyGAM | pygam/pygam.py | https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/pygam.py#L1075-L1115 | def _estimate_r2(self, X=None, y=None, mu=None, weights=None):
"""
estimate some pseudo R^2 values
currently only computes explained deviance.
results are stored
Parameters
----------
y : array-like of shape (n_samples,)
output data vector
mu... | [
"def",
"_estimate_r2",
"(",
"self",
",",
"X",
"=",
"None",
",",
"y",
"=",
"None",
",",
"mu",
"=",
"None",
",",
"weights",
"=",
"None",
")",
":",
"if",
"mu",
"is",
"None",
":",
"mu",
"=",
"self",
".",
"predict_mu",
"(",
"X",
"=",
"X",
")",
"if... | estimate some pseudo R^2 values
currently only computes explained deviance.
results are stored
Parameters
----------
y : array-like of shape (n_samples,)
output data vector
mu : array-like of shape (n_samples,)
expected value of the targets given... | [
"estimate",
"some",
"pseudo",
"R^2",
"values"
] | python | train |
radjkarl/imgProcessor | imgProcessor/interpolate/interpolate2dStructuredCrossAvg.py | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredCrossAvg.py#L7-L19 | def interpolate2dStructuredCrossAvg(grid, mask, kernel=15, power=2):
'''
#######
usefull if large empty areas need to be filled
'''
vals = np.empty(shape=4, dtype=grid.dtype)
dist = np.empty(shape=4, dtype=np.uint16)
weights = np.empty(shape=4, dtype=np.float32)
valid = np.em... | [
"def",
"interpolate2dStructuredCrossAvg",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
")",
":",
"vals",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"4",
",",
"dtype",
"=",
"grid",
".",
"dtype",
")",
"dist",
"=",
"np"... | #######
usefull if large empty areas need to be filled | [
"#######",
"usefull",
"if",
"large",
"empty",
"areas",
"need",
"to",
"be",
"filled"
] | python | train |
NYUCCL/psiTurk | psiturk/psiturk_shell.py | https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/psiturk_shell.py#L1029-L1051 | def do_worker(self, arg):
"""
Usage:
worker approve (--all | --hit <hit_id> ... | <assignment_id> ...) [--all-studies] [--force]
worker reject (--hit <hit_id> | <assignment_id> ...)
worker unreject (--hit <hit_id> | <assignment_id> ...)
worker bonus (--amount <am... | [
"def",
"do_worker",
"(",
"self",
",",
"arg",
")",
":",
"if",
"arg",
"[",
"'approve'",
"]",
":",
"self",
".",
"worker_approve",
"(",
"arg",
"[",
"'--all'",
"]",
",",
"arg",
"[",
"'<hit_id>'",
"]",
",",
"arg",
"[",
"'<assignment_id>'",
"]",
",",
"arg",... | Usage:
worker approve (--all | --hit <hit_id> ... | <assignment_id> ...) [--all-studies] [--force]
worker reject (--hit <hit_id> | <assignment_id> ...)
worker unreject (--hit <hit_id> | <assignment_id> ...)
worker bonus (--amount <amount> | --auto) (--hit <hit_id> | <assignment_... | [
"Usage",
":",
"worker",
"approve",
"(",
"--",
"all",
"|",
"--",
"hit",
"<hit_id",
">",
"...",
"|",
"<assignment_id",
">",
"...",
")",
"[",
"--",
"all",
"-",
"studies",
"]",
"[",
"--",
"force",
"]",
"worker",
"reject",
"(",
"--",
"hit",
"<hit_id",
"... | python | train |
shoebot/shoebot | lib/graph/__init__.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L725-L797 | def create(iterations=1000, distance=1.0, layout=LAYOUT_SPRING, depth=True):
""" Returns a new graph with predefined styling.
"""
#global _ctx
_ctx.colormode(_ctx.RGB)
g = graph(iterations, distance, layout)
# Styles for different types of nodes.
s = style.style
... | [
"def",
"create",
"(",
"iterations",
"=",
"1000",
",",
"distance",
"=",
"1.0",
",",
"layout",
"=",
"LAYOUT_SPRING",
",",
"depth",
"=",
"True",
")",
":",
"#global _ctx",
"_ctx",
".",
"colormode",
"(",
"_ctx",
".",
"RGB",
")",
"g",
"=",
"graph",
"(",
"i... | Returns a new graph with predefined styling. | [
"Returns",
"a",
"new",
"graph",
"with",
"predefined",
"styling",
"."
] | python | valid |
log2timeline/dfvfs | dfvfs/resolver/resolver.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/resolver/resolver.py#L42-L66 | def OpenFileEntry(cls, path_spec_object, resolver_context=None):
"""Opens a file entry object defined by path specification.
Args:
path_spec_object (PathSpec): path specification.
resolver_context (Optional[Context]): resolver context, where None
represents the built in context which is n... | [
"def",
"OpenFileEntry",
"(",
"cls",
",",
"path_spec_object",
",",
"resolver_context",
"=",
"None",
")",
":",
"file_system",
"=",
"cls",
".",
"OpenFileSystem",
"(",
"path_spec_object",
",",
"resolver_context",
"=",
"resolver_context",
")",
"if",
"resolver_context",
... | Opens a file entry object defined by path specification.
Args:
path_spec_object (PathSpec): path specification.
resolver_context (Optional[Context]): resolver context, where None
represents the built in context which is not multi process safe.
Returns:
FileEntry: file entry or None... | [
"Opens",
"a",
"file",
"entry",
"object",
"defined",
"by",
"path",
"specification",
"."
] | python | train |
log2timeline/plaso | plaso/analysis/browser_search.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/analysis/browser_search.py#L117-L135 | def _ExtractGMailSearchQuery(self, url):
"""Extracts a search query from a GMail search URL.
GMail: https://mail.google.com/mail/u/0/#search/query[/?]
Args:
url (str): URL.
Returns:
str: search query or None if no query was found.
"""
if 'search/' not in url:
return None
... | [
"def",
"_ExtractGMailSearchQuery",
"(",
"self",
",",
"url",
")",
":",
"if",
"'search/'",
"not",
"in",
"url",
":",
"return",
"None",
"_",
",",
"_",
",",
"line",
"=",
"url",
".",
"partition",
"(",
"'search/'",
")",
"line",
",",
"_",
",",
"_",
"=",
"l... | Extracts a search query from a GMail search URL.
GMail: https://mail.google.com/mail/u/0/#search/query[/?]
Args:
url (str): URL.
Returns:
str: search query or None if no query was found. | [
"Extracts",
"a",
"search",
"query",
"from",
"a",
"GMail",
"search",
"URL",
"."
] | python | train |
lowandrew/OLCTools | coreGenome/core.py | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/coreGenome/core.py#L169-L193 | def annotatedcore(self):
"""
Calculates the core genome of organisms using custom databases
"""
logging.info('Calculating annotated core')
# Determine the total number of core genes
self.total_core()
# Iterate through all the samples, and process all Escherichia
... | [
"def",
"annotatedcore",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Calculating annotated core'",
")",
"# Determine the total number of core genes",
"self",
".",
"total_core",
"(",
")",
"# Iterate through all the samples, and process all Escherichia",
"for",
"sample... | Calculates the core genome of organisms using custom databases | [
"Calculates",
"the",
"core",
"genome",
"of",
"organisms",
"using",
"custom",
"databases"
] | python | train |
PmagPy/PmagPy | pmagpy/pmag.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2827-L3374 | def PintPars(datablock, araiblock, zijdblock, start, end, accept, **kwargs):
"""
calculate the paleointensity magic parameters make some definitions
"""
if 'version' in list(kwargs.keys()) and kwargs['version'] == 3:
meth_key = 'method_codes'
beta_key = 'int_b_beta'
temp_key, m... | [
"def",
"PintPars",
"(",
"datablock",
",",
"araiblock",
",",
"zijdblock",
",",
"start",
",",
"end",
",",
"accept",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'version'",
"in",
"list",
"(",
"kwargs",
".",
"keys",
"(",
")",
")",
"and",
"kwargs",
"[",
"... | calculate the paleointensity magic parameters make some definitions | [
"calculate",
"the",
"paleointensity",
"magic",
"parameters",
"make",
"some",
"definitions"
] | python | train |
gem/oq-engine | openquake/hazardlib/gsim/atkinson_boore_1995.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/atkinson_boore_1995.py#L75-L105 | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values.
"""
C = self.COEFFS[imt]
# clip rhypo at 10 (this is the minimum ... | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
")",
":",
"C",
"=",
"self",
".",
"COEFFS",
"[",
"imt",
"]",
"# clip rhypo at 10 (this is the minimum distance used in",
"# deriving the equation), se... | See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values. | [
"See",
":",
"meth",
":",
"superclass",
"method",
"<",
".",
"base",
".",
"GroundShakingIntensityModel",
".",
"get_mean_and_stddevs",
">",
"for",
"spec",
"of",
"input",
"and",
"result",
"values",
"."
] | python | train |
globality-corp/microcosm-flask | microcosm_flask/formatting/base.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/formatting/base.py#L50-L74 | def build_etag(self, response, include_etag=True, **kwargs):
"""
Add an etag to the response body.
Uses spooky where possible because it is empirically fast and well-regarded.
See: http://blog.reverberate.org/2012/01/state-of-hash-functions-2012.html
"""
if not include... | [
"def",
"build_etag",
"(",
"self",
",",
"response",
",",
"include_etag",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"include_etag",
":",
"return",
"if",
"not",
"spooky",
":",
"# use built-in md5",
"response",
".",
"add_etag",
"(",
")",
"... | Add an etag to the response body.
Uses spooky where possible because it is empirically fast and well-regarded.
See: http://blog.reverberate.org/2012/01/state-of-hash-functions-2012.html | [
"Add",
"an",
"etag",
"to",
"the",
"response",
"body",
"."
] | python | train |
fananimi/pyzk | zk/base.py | https://github.com/fananimi/pyzk/blob/1a765d616526efdcb4c9adfcc9b1d10f6ed8b938/zk/base.py#L1349-L1395 | def __recieve_tcp_data(self, data_recv, size):
""" data_recv, raw tcp packet
must analyze tcp_length
must return data, broken
"""
data = []
tcp_length = self.__test_tcp_top(data_recv)
if self.verbose: print ("tcp_length {}, size {}".format(tcp_length, size))
... | [
"def",
"__recieve_tcp_data",
"(",
"self",
",",
"data_recv",
",",
"size",
")",
":",
"data",
"=",
"[",
"]",
"tcp_length",
"=",
"self",
".",
"__test_tcp_top",
"(",
"data_recv",
")",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"\"tcp_length {}, size {}\"",
... | data_recv, raw tcp packet
must analyze tcp_length
must return data, broken | [
"data_recv",
"raw",
"tcp",
"packet",
"must",
"analyze",
"tcp_length"
] | python | train |
tanwanirahul/django-batch-requests | batch_requests/settings.py | https://github.com/tanwanirahul/django-batch-requests/blob/9c5afc42f7542f466247f4ffed9c44e1c49fa20d/batch_requests/settings.py#L27-L34 | def import_class(class_path):
'''
Imports the class for the given class name.
'''
module_name, class_name = class_path.rsplit(".", 1)
module = import_module(module_name)
claz = getattr(module, class_name)
return claz | [
"def",
"import_class",
"(",
"class_path",
")",
":",
"module_name",
",",
"class_name",
"=",
"class_path",
".",
"rsplit",
"(",
"\".\"",
",",
"1",
")",
"module",
"=",
"import_module",
"(",
"module_name",
")",
"claz",
"=",
"getattr",
"(",
"module",
",",
"class... | Imports the class for the given class name. | [
"Imports",
"the",
"class",
"for",
"the",
"given",
"class",
"name",
"."
] | python | train |
RedisJSON/rejson-py | rejson/client.py | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L205-L213 | def jsonarrinsert(self, name, path, index, *args):
"""
Inserts the objects ``args`` to the array at index ``index`` under the
``path` in key ``name``
"""
pieces = [name, str_path(path), index]
for o in args:
pieces.append(self._encode(o))
return self.e... | [
"def",
"jsonarrinsert",
"(",
"self",
",",
"name",
",",
"path",
",",
"index",
",",
"*",
"args",
")",
":",
"pieces",
"=",
"[",
"name",
",",
"str_path",
"(",
"path",
")",
",",
"index",
"]",
"for",
"o",
"in",
"args",
":",
"pieces",
".",
"append",
"("... | Inserts the objects ``args`` to the array at index ``index`` under the
``path` in key ``name`` | [
"Inserts",
"the",
"objects",
"args",
"to",
"the",
"array",
"at",
"index",
"index",
"under",
"the",
"path",
"in",
"key",
"name"
] | python | train |
vecnet/vecnet.openmalaria | vecnet/openmalaria/scenario/interventions.py | https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/interventions.py#L516-L523 | def anophelesParams(self):
"""
:rtype: AnophelesParams
"""
list_of_anopheles = []
for anophelesParams in self.gvi.findall("anophelesParams"):
list_of_anopheles.append(AnophelesParams(anophelesParams))
return list_of_anopheles | [
"def",
"anophelesParams",
"(",
"self",
")",
":",
"list_of_anopheles",
"=",
"[",
"]",
"for",
"anophelesParams",
"in",
"self",
".",
"gvi",
".",
"findall",
"(",
"\"anophelesParams\"",
")",
":",
"list_of_anopheles",
".",
"append",
"(",
"AnophelesParams",
"(",
"ano... | :rtype: AnophelesParams | [
":",
"rtype",
":",
"AnophelesParams"
] | python | train |
juicer/juicer | juicer/utils/__init__.py | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/__init__.py#L837-L844 | def repo_def_matches_reality(juicer_def, pulp_def):
"""Compare a juicer repo def with a given pulp definition. Compute and
return the update necessary to make `pulp_def` match `juicer_def`.
`juicer_def` - A JuicerRepo() object representing a juicer repository
`pulp_def` - A PulpRepo() object representi... | [
"def",
"repo_def_matches_reality",
"(",
"juicer_def",
",",
"pulp_def",
")",
":",
"return",
"juicer",
".",
"common",
".",
"Repo",
".",
"RepoDiff",
"(",
"juicer_repo",
"=",
"juicer_def",
",",
"pulp_repo",
"=",
"pulp_def",
")"
] | Compare a juicer repo def with a given pulp definition. Compute and
return the update necessary to make `pulp_def` match `juicer_def`.
`juicer_def` - A JuicerRepo() object representing a juicer repository
`pulp_def` - A PulpRepo() object representing a pulp repository | [
"Compare",
"a",
"juicer",
"repo",
"def",
"with",
"a",
"given",
"pulp",
"definition",
".",
"Compute",
"and",
"return",
"the",
"update",
"necessary",
"to",
"make",
"pulp_def",
"match",
"juicer_def",
"."
] | python | train |
sebp/scikit-survival | sksurv/kernels/clinical.py | https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/kernels/clinical.py#L35-L50 | def _get_continuous_and_ordinal_array(x):
"""Convert array from continuous and ordered categorical columns"""
nominal_columns = x.select_dtypes(include=['object', 'category']).columns
ordinal_columns = pandas.Index([v for v in nominal_columns if x[v].cat.ordered])
continuous_columns = x.select_dtypes(in... | [
"def",
"_get_continuous_and_ordinal_array",
"(",
"x",
")",
":",
"nominal_columns",
"=",
"x",
".",
"select_dtypes",
"(",
"include",
"=",
"[",
"'object'",
",",
"'category'",
"]",
")",
".",
"columns",
"ordinal_columns",
"=",
"pandas",
".",
"Index",
"(",
"[",
"v... | Convert array from continuous and ordered categorical columns | [
"Convert",
"array",
"from",
"continuous",
"and",
"ordered",
"categorical",
"columns"
] | python | train |
django-fluent/django-fluent-blogs | fluent_blogs/admin/abstractbase.py | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/admin/abstractbase.py#L72-L85 | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Allow formfield_overrides to contain field names too.
"""
overrides = self.formfield_overrides.get(db_field.name)
if overrides:
kwargs.update(overrides)
field = super(AbstractEntryBaseAdmin, self).formf... | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"*",
"*",
"kwargs",
")",
":",
"overrides",
"=",
"self",
".",
"formfield_overrides",
".",
"get",
"(",
"db_field",
".",
"name",
")",
"if",
"overrides",
":",
"kwargs",
".",
"update",
"(",
"o... | Allow formfield_overrides to contain field names too. | [
"Allow",
"formfield_overrides",
"to",
"contain",
"field",
"names",
"too",
"."
] | python | train |
Qiskit/qiskit-terra | qiskit/validation/base.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L201-L224 | def _create_validation_schema(schema_cls):
"""Create a patched Schema for validating models.
Model validation is not part of Marshmallow. Schemas have a ``validate``
method but this delegates execution on ``load`` and discards the result.
Similarly, ``load`` will call ``_deserialize`` o... | [
"def",
"_create_validation_schema",
"(",
"schema_cls",
")",
":",
"validation_schema",
"=",
"schema_cls",
"(",
")",
"for",
"_",
",",
"field",
"in",
"validation_schema",
".",
"fields",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"ModelT... | Create a patched Schema for validating models.
Model validation is not part of Marshmallow. Schemas have a ``validate``
method but this delegates execution on ``load`` and discards the result.
Similarly, ``load`` will call ``_deserialize`` on every field in the
schema.
This fun... | [
"Create",
"a",
"patched",
"Schema",
"for",
"validating",
"models",
"."
] | python | test |
robinandeer/puzzle | puzzle/models/sql/models.py | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/sql/models.py#L55-L59 | def case_comments(self):
"""Return only comments made on the case."""
comments = (comment for comment in self.comments if
comment.variant_id is None)
return comments | [
"def",
"case_comments",
"(",
"self",
")",
":",
"comments",
"=",
"(",
"comment",
"for",
"comment",
"in",
"self",
".",
"comments",
"if",
"comment",
".",
"variant_id",
"is",
"None",
")",
"return",
"comments"
] | Return only comments made on the case. | [
"Return",
"only",
"comments",
"made",
"on",
"the",
"case",
"."
] | python | train |
inasafe/inasafe | safe/utilities/gis.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/gis.py#L356-L363 | def qgis_version_detailed():
"""Get the detailed version of QGIS.
:returns: List containing major, minor and patch.
:rtype: list
"""
version = str(Qgis.QGIS_VERSION_INT)
return [int(version[0]), int(version[1:3]), int(version[3:])] | [
"def",
"qgis_version_detailed",
"(",
")",
":",
"version",
"=",
"str",
"(",
"Qgis",
".",
"QGIS_VERSION_INT",
")",
"return",
"[",
"int",
"(",
"version",
"[",
"0",
"]",
")",
",",
"int",
"(",
"version",
"[",
"1",
":",
"3",
"]",
")",
",",
"int",
"(",
... | Get the detailed version of QGIS.
:returns: List containing major, minor and patch.
:rtype: list | [
"Get",
"the",
"detailed",
"version",
"of",
"QGIS",
"."
] | python | train |
webrecorder/pywb | pywb/apps/frontendapp.py | https://github.com/webrecorder/pywb/blob/77f8bb647639dd66f6b92b7a9174c28810e4b1d9/pywb/apps/frontendapp.py#L105-L130 | def _init_routes(self):
"""Initialize the routes and based on the configuration file makes available
specific routes (proxy mode, record)"""
self.url_map = Map()
self.url_map.add(Rule('/static/_/<coll>/<path:filepath>', endpoint=self.serve_static))
self.url_map.add(Rule('/static/... | [
"def",
"_init_routes",
"(",
"self",
")",
":",
"self",
".",
"url_map",
"=",
"Map",
"(",
")",
"self",
".",
"url_map",
".",
"add",
"(",
"Rule",
"(",
"'/static/_/<coll>/<path:filepath>'",
",",
"endpoint",
"=",
"self",
".",
"serve_static",
")",
")",
"self",
"... | Initialize the routes and based on the configuration file makes available
specific routes (proxy mode, record) | [
"Initialize",
"the",
"routes",
"and",
"based",
"on",
"the",
"configuration",
"file",
"makes",
"available",
"specific",
"routes",
"(",
"proxy",
"mode",
"record",
")"
] | python | train |
pysal/giddy | giddy/markov.py | https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/markov.py#L811-L830 | def summary(self, file_name=None):
"""
A summary method to call the Markov homogeneity test to test for
temporally lagged spatial dependence.
To learn more about the properties of the tests, refer to
:cite:`Rey2016a` and :cite:`Kang2018`.
"""
class_names = ["C%d... | [
"def",
"summary",
"(",
"self",
",",
"file_name",
"=",
"None",
")",
":",
"class_names",
"=",
"[",
"\"C%d\"",
"%",
"i",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"k",
")",
"]",
"regime_names",
"=",
"[",
"\"LAG%d\"",
"%",
"i",
"for",
"i",
"in",
"... | A summary method to call the Markov homogeneity test to test for
temporally lagged spatial dependence.
To learn more about the properties of the tests, refer to
:cite:`Rey2016a` and :cite:`Kang2018`. | [
"A",
"summary",
"method",
"to",
"call",
"the",
"Markov",
"homogeneity",
"test",
"to",
"test",
"for",
"temporally",
"lagged",
"spatial",
"dependence",
"."
] | python | train |
Alignak-monitoring/alignak | alignak/objects/item.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L587-L611 | def fill_data_brok_from(self, data, brok_type):
"""
Add properties to 'data' parameter with properties of this object when 'brok_type'
parameter is defined in fill_brok of these properties
:param data: object to fill
:type data: object
:param brok_type: name of brok_type... | [
"def",
"fill_data_brok_from",
"(",
"self",
",",
"data",
",",
"brok_type",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"# Configuration properties",
"for",
"prop",
",",
"entry",
"in",
"list",
"(",
"cls",
".",
"properties",
".",
"items",
"(",
")",
")",
... | Add properties to 'data' parameter with properties of this object when 'brok_type'
parameter is defined in fill_brok of these properties
:param data: object to fill
:type data: object
:param brok_type: name of brok_type
:type brok_type: var
:return: None | [
"Add",
"properties",
"to",
"data",
"parameter",
"with",
"properties",
"of",
"this",
"object",
"when",
"brok_type",
"parameter",
"is",
"defined",
"in",
"fill_brok",
"of",
"these",
"properties"
] | python | train |
miguelmoreto/pycomtrade | src/pyComtrade.py | https://github.com/miguelmoreto/pycomtrade/blob/1785ebbc96c01a60e58fb11f0aa4848be855aa0d/src/pyComtrade.py#L300-L306 | def getAnalogID(self,num):
"""
Returns the COMTRADE ID of a given channel number.
The number to be given is the same of the COMTRADE header.
"""
listidx = self.An.index(num) # Get the position of the channel number.
return self.Ach_id[listidx] | [
"def",
"getAnalogID",
"(",
"self",
",",
"num",
")",
":",
"listidx",
"=",
"self",
".",
"An",
".",
"index",
"(",
"num",
")",
"# Get the position of the channel number.",
"return",
"self",
".",
"Ach_id",
"[",
"listidx",
"]"
] | Returns the COMTRADE ID of a given channel number.
The number to be given is the same of the COMTRADE header. | [
"Returns",
"the",
"COMTRADE",
"ID",
"of",
"a",
"given",
"channel",
"number",
".",
"The",
"number",
"to",
"be",
"given",
"is",
"the",
"same",
"of",
"the",
"COMTRADE",
"header",
"."
] | python | train |
marteinn/genres | genres/db.py | https://github.com/marteinn/genres/blob/4bbc90f7c2c527631380c08b4d99a4e40abed955/genres/db.py#L89-L102 | def _parse_entry(entry, limit=10):
"""
Finds both label and if provided, the points for ranking.
"""
entry = entry.split(",")
label = entry[0]
points = limit
if len(entry) > 1:
proc = float(entry[1].strip())
points = limit * proc
... | [
"def",
"_parse_entry",
"(",
"entry",
",",
"limit",
"=",
"10",
")",
":",
"entry",
"=",
"entry",
".",
"split",
"(",
"\",\"",
")",
"label",
"=",
"entry",
"[",
"0",
"]",
"points",
"=",
"limit",
"if",
"len",
"(",
"entry",
")",
">",
"1",
":",
"proc",
... | Finds both label and if provided, the points for ranking. | [
"Finds",
"both",
"label",
"and",
"if",
"provided",
"the",
"points",
"for",
"ranking",
"."
] | python | train |
ddorn/GUI | GUI/math.py | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/math.py#L109-L117 | def normnorm(self):
"""
Return a vecor noraml to this one with a norm of one
:return: V2
"""
n = self.norm()
return V2(-self.y / n, self.x / n) | [
"def",
"normnorm",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"norm",
"(",
")",
"return",
"V2",
"(",
"-",
"self",
".",
"y",
"/",
"n",
",",
"self",
".",
"x",
"/",
"n",
")"
] | Return a vecor noraml to this one with a norm of one
:return: V2 | [
"Return",
"a",
"vecor",
"noraml",
"to",
"this",
"one",
"with",
"a",
"norm",
"of",
"one"
] | python | train |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/reflect/RecursiveObjectWriter.py | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/reflect/RecursiveObjectWriter.py#L93-L107 | def copy_properties(dest, src):
"""
Copies content of one object to another object
by recursively reading all properties from source object
and then recursively writing them to destination object.
:param dest: a destination object to write properties to.
:param src: a s... | [
"def",
"copy_properties",
"(",
"dest",
",",
"src",
")",
":",
"if",
"dest",
"==",
"None",
"or",
"src",
"==",
"None",
":",
"return",
"values",
"=",
"RecursiveObjectReader",
".",
"get_properties",
"(",
"src",
")",
"RecursiveObjectWriter",
".",
"set_properties",
... | Copies content of one object to another object
by recursively reading all properties from source object
and then recursively writing them to destination object.
:param dest: a destination object to write properties to.
:param src: a source object to read properties from | [
"Copies",
"content",
"of",
"one",
"object",
"to",
"another",
"object",
"by",
"recursively",
"reading",
"all",
"properties",
"from",
"source",
"object",
"and",
"then",
"recursively",
"writing",
"them",
"to",
"destination",
"object",
"."
] | python | train |
numba/llvmlite | llvmlite/binding/targets.py | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/targets.py#L47-L69 | def get_host_cpu_features():
"""
Returns a dictionary-like object indicating the CPU features for current
architecture and whether they are enabled for this CPU. The key-value pairs
are the feature name as string and a boolean indicating whether the feature
is available. The returned value is an i... | [
"def",
"get_host_cpu_features",
"(",
")",
":",
"with",
"ffi",
".",
"OutputString",
"(",
")",
"as",
"out",
":",
"outdict",
"=",
"FeatureMap",
"(",
")",
"if",
"not",
"ffi",
".",
"lib",
".",
"LLVMPY_GetHostCPUFeatures",
"(",
"out",
")",
":",
"raise",
"Runti... | Returns a dictionary-like object indicating the CPU features for current
architecture and whether they are enabled for this CPU. The key-value pairs
are the feature name as string and a boolean indicating whether the feature
is available. The returned value is an instance of ``FeatureMap`` class,
whic... | [
"Returns",
"a",
"dictionary",
"-",
"like",
"object",
"indicating",
"the",
"CPU",
"features",
"for",
"current",
"architecture",
"and",
"whether",
"they",
"are",
"enabled",
"for",
"this",
"CPU",
".",
"The",
"key",
"-",
"value",
"pairs",
"are",
"the",
"feature"... | python | train |
inspirehep/harvesting-kit | harvestingkit/utils.py | https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L376-L392 | def convert_date_from_iso_to_human(value):
"""Convert a date-value to the ISO date standard for humans."""
try:
year, month, day = value.split("-")
except ValueError:
# Not separated by "-". Space?
try:
year, month, day = value.split(" ")
except ValueError:
... | [
"def",
"convert_date_from_iso_to_human",
"(",
"value",
")",
":",
"try",
":",
"year",
",",
"month",
",",
"day",
"=",
"value",
".",
"split",
"(",
"\"-\"",
")",
"except",
"ValueError",
":",
"# Not separated by \"-\". Space?",
"try",
":",
"year",
",",
"month",
"... | Convert a date-value to the ISO date standard for humans. | [
"Convert",
"a",
"date",
"-",
"value",
"to",
"the",
"ISO",
"date",
"standard",
"for",
"humans",
"."
] | python | valid |
Jammy2211/PyAutoLens | autolens/model/profiles/mass_profiles.py | https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L353-L356 | def einstein_radius_rescaled(self):
"""Rescale the einstein radius by slope and axis_ratio, to reduce its degeneracy with other mass-profiles
parameters"""
return ((3 - self.slope) / (1 + self.axis_ratio)) * self.einstein_radius ** (self.slope - 1) | [
"def",
"einstein_radius_rescaled",
"(",
"self",
")",
":",
"return",
"(",
"(",
"3",
"-",
"self",
".",
"slope",
")",
"/",
"(",
"1",
"+",
"self",
".",
"axis_ratio",
")",
")",
"*",
"self",
".",
"einstein_radius",
"**",
"(",
"self",
".",
"slope",
"-",
"... | Rescale the einstein radius by slope and axis_ratio, to reduce its degeneracy with other mass-profiles
parameters | [
"Rescale",
"the",
"einstein",
"radius",
"by",
"slope",
"and",
"axis_ratio",
"to",
"reduce",
"its",
"degeneracy",
"with",
"other",
"mass",
"-",
"profiles",
"parameters"
] | python | valid |
Falkonry/falkonry-python-client | falkonryclient/service/falkonry.py | https://github.com/Falkonry/falkonry-python-client/blob/0aeb2b00293ee94944f1634e9667401b03da29c1/falkonryclient/service/falkonry.py#L438-L446 | def get_status(self, tracker_id):
"""
Get status of a task
:param tracker_id: string
"""
url = '/app/track/' + tracker_id
response = self.http.get(url)
return response | [
"def",
"get_status",
"(",
"self",
",",
"tracker_id",
")",
":",
"url",
"=",
"'/app/track/'",
"+",
"tracker_id",
"response",
"=",
"self",
".",
"http",
".",
"get",
"(",
"url",
")",
"return",
"response"
] | Get status of a task
:param tracker_id: string | [
"Get",
"status",
"of",
"a",
"task",
":",
"param",
"tracker_id",
":",
"string"
] | python | train |
touilleMan/marshmallow-mongoengine | marshmallow_mongoengine/conversion/fields.py | https://github.com/touilleMan/marshmallow-mongoengine/blob/21223700ea1f1d0209c967761e5c22635ee721e7/marshmallow_mongoengine/conversion/fields.py#L143-L155 | def register_field(mongo_field_cls, marshmallow_field_cls,
available_params=()):
"""
Bind a marshmallow field to it corresponding mongoengine field
:param mongo_field_cls: Mongoengine Field
:param marshmallow_field_cls: Marshmallow Field
:param available_params: List of :class mar... | [
"def",
"register_field",
"(",
"mongo_field_cls",
",",
"marshmallow_field_cls",
",",
"available_params",
"=",
"(",
")",
")",
":",
"class",
"Builder",
"(",
"MetaFieldBuilder",
")",
":",
"AVAILABLE_PARAMS",
"=",
"available_params",
"MARSHMALLOW_FIELD_CLS",
"=",
"marshmal... | Bind a marshmallow field to it corresponding mongoengine field
:param mongo_field_cls: Mongoengine Field
:param marshmallow_field_cls: Marshmallow Field
:param available_params: List of :class marshmallow_mongoengine.cnoversion.params.MetaParam:
instances to import the mongoengine field config to ma... | [
"Bind",
"a",
"marshmallow",
"field",
"to",
"it",
"corresponding",
"mongoengine",
"field",
":",
"param",
"mongo_field_cls",
":",
"Mongoengine",
"Field",
":",
"param",
"marshmallow_field_cls",
":",
"Marshmallow",
"Field",
":",
"param",
"available_params",
":",
"List",... | python | train |
Azure/azure-sdk-for-python | azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_face_list_operations.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-vision-face/azure/cognitiveservices/vision/face/operations/large_face_list_operations.py#L778-L855 | def add_face_from_stream(
self, large_face_list_id, image, user_data=None, target_face=None, custom_headers=None, raw=False, callback=None, **operation_config):
"""Add a face to a large face list. The input face is specified as an
image with a targetFace rectangle. It returns a persistedFace... | [
"def",
"add_face_from_stream",
"(",
"self",
",",
"large_face_list_id",
",",
"image",
",",
"user_data",
"=",
"None",
",",
"target_face",
"=",
"None",
",",
"custom_headers",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"callback",
"=",
"None",
",",
"*",
"*",
... | Add a face to a large face list. The input face is specified as an
image with a targetFace rectangle. It returns a persistedFaceId
representing the added face, and persistedFaceId will not expire.
:param large_face_list_id: Id referencing a particular large face
list.
:type lar... | [
"Add",
"a",
"face",
"to",
"a",
"large",
"face",
"list",
".",
"The",
"input",
"face",
"is",
"specified",
"as",
"an",
"image",
"with",
"a",
"targetFace",
"rectangle",
".",
"It",
"returns",
"a",
"persistedFaceId",
"representing",
"the",
"added",
"face",
"and"... | python | test |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/collection.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/collection.py#L2359-L2454 | def find_one_and_update(self, filter, update,
projection=None, sort=None, upsert=False,
return_document=ReturnDocument.BEFORE, **kwargs):
"""Finds a single document and updates it, returning either the
original or the updated document.
>... | [
"def",
"find_one_and_update",
"(",
"self",
",",
"filter",
",",
"update",
",",
"projection",
"=",
"None",
",",
"sort",
"=",
"None",
",",
"upsert",
"=",
"False",
",",
"return_document",
"=",
"ReturnDocument",
".",
"BEFORE",
",",
"*",
"*",
"kwargs",
")",
":... | Finds a single document and updates it, returning either the
original or the updated document.
>>> db.test.find_one_and_update(
... {'_id': 665}, {'$inc': {'count': 1}, '$set': {'done': True}})
{u'_id': 665, u'done': False, u'count': 25}}
By default :meth:`find_one_and... | [
"Finds",
"a",
"single",
"document",
"and",
"updates",
"it",
"returning",
"either",
"the",
"original",
"or",
"the",
"updated",
"document",
"."
] | python | train |
softlayer/softlayer-python | SoftLayer/managers/ipsec.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/ipsec.py#L179-L187 | def remove_remote_subnet(self, context_id, subnet_id):
"""Removes a remote subnet from a tunnel context.
:param int context_id: The id-value representing the context instance.
:param int subnet_id: The id-value representing the remote subnet.
:return bool: True if remote subnet removal ... | [
"def",
"remove_remote_subnet",
"(",
"self",
",",
"context_id",
",",
"subnet_id",
")",
":",
"return",
"self",
".",
"context",
".",
"removeCustomerSubnetFromNetworkTunnel",
"(",
"subnet_id",
",",
"id",
"=",
"context_id",
")"
] | Removes a remote subnet from a tunnel context.
:param int context_id: The id-value representing the context instance.
:param int subnet_id: The id-value representing the remote subnet.
:return bool: True if remote subnet removal was successful. | [
"Removes",
"a",
"remote",
"subnet",
"from",
"a",
"tunnel",
"context",
"."
] | python | train |
apache/incubator-heron | third_party/python/cpplint/cpplint.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/third_party/python/cpplint/cpplint.py#L739-L754 | def IsErrorSuppressedByNolint(category, linenum):
"""Returns true if the specified error category is suppressed on this line.
Consults the global error_suppressions map populated by
ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions.
Args:
category: str, the category of the error.
... | [
"def",
"IsErrorSuppressedByNolint",
"(",
"category",
",",
"linenum",
")",
":",
"return",
"(",
"_global_error_suppressions",
".",
"get",
"(",
"category",
",",
"False",
")",
"or",
"linenum",
"in",
"_error_suppressions",
".",
"get",
"(",
"category",
",",
"set",
"... | Returns true if the specified error category is suppressed on this line.
Consults the global error_suppressions map populated by
ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions.
Args:
category: str, the category of the error.
linenum: int, the current line number.
Returns:
... | [
"Returns",
"true",
"if",
"the",
"specified",
"error",
"category",
"is",
"suppressed",
"on",
"this",
"line",
"."
] | python | valid |
chrisspen/burlap | burlap/vm.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/vm.py#L644-L654 | def respawn(name=None, group=None):
"""
Deletes and recreates one or more VM instances.
"""
if name is None:
name = get_name()
delete(name=name, group=group)
instance = get_or_create(name=name, group=group)
env.host_string = instance.public_dns_name | [
"def",
"respawn",
"(",
"name",
"=",
"None",
",",
"group",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"get_name",
"(",
")",
"delete",
"(",
"name",
"=",
"name",
",",
"group",
"=",
"group",
")",
"instance",
"=",
"get_or_creat... | Deletes and recreates one or more VM instances. | [
"Deletes",
"and",
"recreates",
"one",
"or",
"more",
"VM",
"instances",
"."
] | python | valid |
amperser/proselint | proselint/checks/misc/illogic.py | https://github.com/amperser/proselint/blob/cb619ee4023cc7856f5fb96aec2a33a2c9f1a2e2/proselint/checks/misc/illogic.py#L52-L60 | def check_without_your_collusion(text):
"""Check the textself."""
err = "misc.illogic.collusion"
msg = "It's impossible to defraud yourself. Try 'aquiescence'."
regex = "without your collusion"
return existence_check(
text, [regex], err, msg, require_padding=False, offset=-1) | [
"def",
"check_without_your_collusion",
"(",
"text",
")",
":",
"err",
"=",
"\"misc.illogic.collusion\"",
"msg",
"=",
"\"It's impossible to defraud yourself. Try 'aquiescence'.\"",
"regex",
"=",
"\"without your collusion\"",
"return",
"existence_check",
"(",
"text",
",",
"[",
... | Check the textself. | [
"Check",
"the",
"textself",
"."
] | python | train |
aws/aws-encryption-sdk-python | doc/conf.py | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/doc/conf.py#L21-L27 | def get_version():
"""Reads the version (MAJOR.MINOR) from this module."""
release = get_release()
split_version = release.split(".")
if len(split_version) == 3:
return ".".join(split_version[:2])
return release | [
"def",
"get_version",
"(",
")",
":",
"release",
"=",
"get_release",
"(",
")",
"split_version",
"=",
"release",
".",
"split",
"(",
"\".\"",
")",
"if",
"len",
"(",
"split_version",
")",
"==",
"3",
":",
"return",
"\".\"",
".",
"join",
"(",
"split_version",
... | Reads the version (MAJOR.MINOR) from this module. | [
"Reads",
"the",
"version",
"(",
"MAJOR",
".",
"MINOR",
")",
"from",
"this",
"module",
"."
] | python | train |
gitpython-developers/GitPython | git/objects/submodule/base.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/objects/submodule/base.py#L287-L308 | def _write_git_file_and_module_config(cls, working_tree_dir, module_abspath):
"""Writes a .git file containing a (preferably) relative path to the actual git module repository.
It is an error if the module_abspath cannot be made into a relative path, relative to the working_tree_dir
:note: will ... | [
"def",
"_write_git_file_and_module_config",
"(",
"cls",
",",
"working_tree_dir",
",",
"module_abspath",
")",
":",
"git_file",
"=",
"osp",
".",
"join",
"(",
"working_tree_dir",
",",
"'.git'",
")",
"rela_path",
"=",
"osp",
".",
"relpath",
"(",
"module_abspath",
",... | Writes a .git file containing a (preferably) relative path to the actual git module repository.
It is an error if the module_abspath cannot be made into a relative path, relative to the working_tree_dir
:note: will overwrite existing files !
:note: as we rewrite both the git file as well as the ... | [
"Writes",
"a",
".",
"git",
"file",
"containing",
"a",
"(",
"preferably",
")",
"relative",
"path",
"to",
"the",
"actual",
"git",
"module",
"repository",
".",
"It",
"is",
"an",
"error",
"if",
"the",
"module_abspath",
"cannot",
"be",
"made",
"into",
"a",
"r... | python | train |
gem/oq-engine | openquake/hazardlib/gsim/zhao_2016.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/zhao_2016.py#L82-L102 | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values.
"""
# extracting dictionary of coefficients specific to required
#... | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
")",
":",
"# extracting dictionary of coefficients specific to required",
"# intensity measure type.",
"C",
"=",
"self",
".",
"COEFFS",
"[",
"imt",
"... | See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values. | [
"See",
":",
"meth",
":",
"superclass",
"method",
"<",
".",
"base",
".",
"GroundShakingIntensityModel",
".",
"get_mean_and_stddevs",
">",
"for",
"spec",
"of",
"input",
"and",
"result",
"values",
"."
] | python | train |
COLORFULBOARD/revision | revision/client.py | https://github.com/COLORFULBOARD/revision/blob/2f22e72cce5b60032a80c002ac45c2ecef0ed987/revision/client.py#L225-L233 | def tmp_file_path(self):
"""
:return:
:rtype: str
"""
return os.path.normpath(os.path.join(
TMP_DIR,
self.filename
)) | [
"def",
"tmp_file_path",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"TMP_DIR",
",",
"self",
".",
"filename",
")",
")"
] | :return:
:rtype: str | [
":",
"return",
":",
":",
"rtype",
":",
"str"
] | python | train |
PythonCharmers/python-future | src/future/types/newbytes.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/types/newbytes.py#L324-L332 | def rindex(self, sub, *args):
'''
S.rindex(sub [,start [,end]]) -> int
Like S.rfind() but raise ValueError when the substring is not found.
'''
pos = self.rfind(sub, *args)
if pos == -1:
raise ValueError('substring not found') | [
"def",
"rindex",
"(",
"self",
",",
"sub",
",",
"*",
"args",
")",
":",
"pos",
"=",
"self",
".",
"rfind",
"(",
"sub",
",",
"*",
"args",
")",
"if",
"pos",
"==",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"'substring not found'",
")"
] | S.rindex(sub [,start [,end]]) -> int
Like S.rfind() but raise ValueError when the substring is not found. | [
"S",
".",
"rindex",
"(",
"sub",
"[",
"start",
"[",
"end",
"]]",
")",
"-",
">",
"int"
] | python | train |
dhermes/bezier | src/bezier/surface.py | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/surface.py#L322-L352 | def edges(self):
"""The edges of the surface.
.. doctest:: surface-edges
:options: +NORMALIZE_WHITESPACE
>>> nodes = np.asfortranarray([
... [0.0, 0.5 , 1.0, 0.1875, 0.625, 0.0],
... [0.0, -0.1875, 0.0, 0.5 , 0.625, 1.0],
... ])
... | [
"def",
"edges",
"(",
"self",
")",
":",
"edge1",
",",
"edge2",
",",
"edge3",
"=",
"self",
".",
"_get_edges",
"(",
")",
"# NOTE: It is crucial that we return copies here. Since the edges",
"# are cached, if they were mutable, callers could",
"# inadvertently mutate th... | The edges of the surface.
.. doctest:: surface-edges
:options: +NORMALIZE_WHITESPACE
>>> nodes = np.asfortranarray([
... [0.0, 0.5 , 1.0, 0.1875, 0.625, 0.0],
... [0.0, -0.1875, 0.0, 0.5 , 0.625, 1.0],
... ])
>>> surface = bezier.S... | [
"The",
"edges",
"of",
"the",
"surface",
"."
] | python | train |
un33k/django-ipware | ipware/utils.py | https://github.com/un33k/django-ipware/blob/dc6b754137d1bb7d056ac206a6e0443aa3ed68dc/ipware/utils.py#L91-L100 | def get_ip_info(ip_str):
"""
Given a string, it returns a tuple of (IP, Routable).
"""
ip = None
is_routable_ip = False
if is_valid_ip(ip_str):
ip = ip_str
is_routable_ip = is_public_ip(ip)
return ip, is_routable_ip | [
"def",
"get_ip_info",
"(",
"ip_str",
")",
":",
"ip",
"=",
"None",
"is_routable_ip",
"=",
"False",
"if",
"is_valid_ip",
"(",
"ip_str",
")",
":",
"ip",
"=",
"ip_str",
"is_routable_ip",
"=",
"is_public_ip",
"(",
"ip",
")",
"return",
"ip",
",",
"is_routable_ip... | Given a string, it returns a tuple of (IP, Routable). | [
"Given",
"a",
"string",
"it",
"returns",
"a",
"tuple",
"of",
"(",
"IP",
"Routable",
")",
"."
] | python | train |
log2timeline/dfvfs | dfvfs/vfs/tar_file_system.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/tar_file_system.py#L165-L190 | def GetTARInfoByPathSpec(self, path_spec):
"""Retrieves the TAR info for a path specification.
Args:
path_spec (PathSpec): a path specification.
Returns:
tarfile.TARInfo: TAR info or None if it does not exist.
Raises:
PathSpecError: if the path specification is incorrect.
"""
... | [
"def",
"GetTARInfoByPathSpec",
"(",
"self",
",",
"path_spec",
")",
":",
"location",
"=",
"getattr",
"(",
"path_spec",
",",
"'location'",
",",
"None",
")",
"if",
"location",
"is",
"None",
":",
"raise",
"errors",
".",
"PathSpecError",
"(",
"'Path specification m... | Retrieves the TAR info for a path specification.
Args:
path_spec (PathSpec): a path specification.
Returns:
tarfile.TARInfo: TAR info or None if it does not exist.
Raises:
PathSpecError: if the path specification is incorrect. | [
"Retrieves",
"the",
"TAR",
"info",
"for",
"a",
"path",
"specification",
"."
] | python | train |
senaite/senaite.core | bika/lims/content/calculation.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/calculation.py#L237-L262 | def getCalculationDependencies(self, flat=False, deps=None):
""" Recursively calculates all dependencies of this calculation.
The return value is dictionary of dictionaries (of dictionaries...)
{service_UID1:
{service_UID2:
{service_UID3: {},
... | [
"def",
"getCalculationDependencies",
"(",
"self",
",",
"flat",
"=",
"False",
",",
"deps",
"=",
"None",
")",
":",
"if",
"deps",
"is",
"None",
":",
"deps",
"=",
"[",
"]",
"if",
"flat",
"is",
"True",
"else",
"{",
"}",
"for",
"service",
"in",
"self",
"... | Recursively calculates all dependencies of this calculation.
The return value is dictionary of dictionaries (of dictionaries...)
{service_UID1:
{service_UID2:
{service_UID3: {},
service_UID4: {},
},
},
... | [
"Recursively",
"calculates",
"all",
"dependencies",
"of",
"this",
"calculation",
".",
"The",
"return",
"value",
"is",
"dictionary",
"of",
"dictionaries",
"(",
"of",
"dictionaries",
"...",
")"
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/data.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L853-L866 | def check_dataset_in_collection(dataset_id, collection_id, **kwargs):
"""
Check whether a dataset is contained inside a collection
:param dataset ID
:param collection ID
:returns 'Y' or 'N'
"""
_get_collection(collection_id)
collection_item = _get_collection_item(collect... | [
"def",
"check_dataset_in_collection",
"(",
"dataset_id",
",",
"collection_id",
",",
"*",
"*",
"kwargs",
")",
":",
"_get_collection",
"(",
"collection_id",
")",
"collection_item",
"=",
"_get_collection_item",
"(",
"collection_id",
",",
"dataset_id",
")",
"if",
"colle... | Check whether a dataset is contained inside a collection
:param dataset ID
:param collection ID
:returns 'Y' or 'N' | [
"Check",
"whether",
"a",
"dataset",
"is",
"contained",
"inside",
"a",
"collection",
":",
"param",
"dataset",
"ID",
":",
"param",
"collection",
"ID",
":",
"returns",
"Y",
"or",
"N"
] | python | train |
wavycloud/pyboto3 | pyboto3/rds.py | https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/rds.py#L6300-L6729 | def modify_db_instance(DBInstanceIdentifier=None, AllocatedStorage=None, DBInstanceClass=None, DBSubnetGroupName=None, DBSecurityGroups=None, VpcSecurityGroupIds=None, ApplyImmediately=None, MasterUserPassword=None, DBParameterGroupName=None, BackupRetentionPeriod=None, PreferredBackupWindow=None, PreferredMaintenanceW... | [
"def",
"modify_db_instance",
"(",
"DBInstanceIdentifier",
"=",
"None",
",",
"AllocatedStorage",
"=",
"None",
",",
"DBInstanceClass",
"=",
"None",
",",
"DBSubnetGroupName",
"=",
"None",
",",
"DBSecurityGroups",
"=",
"None",
",",
"VpcSecurityGroupIds",
"=",
"None",
... | Modifies settings for a DB instance. You can change one or more database configuration parameters by specifying these parameters and the new values in the request.
See also: AWS API Documentation
Examples
This example immediately changes the specified settings for the specified DB instance.
Expecte... | [
"Modifies",
"settings",
"for",
"a",
"DB",
"instance",
".",
"You",
"can",
"change",
"one",
"or",
"more",
"database",
"configuration",
"parameters",
"by",
"specifying",
"these",
"parameters",
"and",
"the",
"new",
"values",
"in",
"the",
"request",
".",
"See",
"... | python | train |
djgagne/hagelslag | hagelslag/evaluation/ObjectEvaluator.py | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/ObjectEvaluator.py#L62-L87 | def load_forecasts(self):
"""
Loads the forecast files and gathers the forecast information into pandas DataFrames.
"""
forecast_path = self.forecast_json_path + "/{0}/{1}/".format(self.run_date.strftime("%Y%m%d"),
self... | [
"def",
"load_forecasts",
"(",
"self",
")",
":",
"forecast_path",
"=",
"self",
".",
"forecast_json_path",
"+",
"\"/{0}/{1}/\"",
".",
"format",
"(",
"self",
".",
"run_date",
".",
"strftime",
"(",
"\"%Y%m%d\"",
")",
",",
"self",
".",
"ensemble_member",
")",
"fo... | Loads the forecast files and gathers the forecast information into pandas DataFrames. | [
"Loads",
"the",
"forecast",
"files",
"and",
"gathers",
"the",
"forecast",
"information",
"into",
"pandas",
"DataFrames",
"."
] | python | train |
budacom/trading-bots | trading_bots/bots/registry.py | https://github.com/budacom/trading-bots/blob/8cb68bb8d0b5f822108db1cc5dae336e3d3c3452/trading_bots/bots/registry.py#L199-L254 | def populate(self, installed_bots=None):
"""
Load bots.
Import each bot module.
It is thread-safe and idempotent, but not re-entrant.
"""
if self.ready:
return
# populate() might be called by two threads in parallel on servers
# that create th... | [
"def",
"populate",
"(",
"self",
",",
"installed_bots",
"=",
"None",
")",
":",
"if",
"self",
".",
"ready",
":",
"return",
"# populate() might be called by two threads in parallel on servers",
"# that create threads before initializing the WSGI callable.",
"with",
"self",
".",
... | Load bots.
Import each bot module.
It is thread-safe and idempotent, but not re-entrant. | [
"Load",
"bots",
".",
"Import",
"each",
"bot",
"module",
".",
"It",
"is",
"thread",
"-",
"safe",
"and",
"idempotent",
"but",
"not",
"re",
"-",
"entrant",
"."
] | python | train |
titusjan/argos | argos/config/qtctis.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/config/qtctis.py#L54-L65 | def createPenWidthCti(nodeName, defaultData=1.0, zeroValueText=None):
""" Creates a FloatCti with defaults for configuring a QPen width.
If specialValueZero is set, this string will be displayed when 0.0 is selected.
If specialValueZero is None, the minValue will be 0.1
"""
# A pen line wid... | [
"def",
"createPenWidthCti",
"(",
"nodeName",
",",
"defaultData",
"=",
"1.0",
",",
"zeroValueText",
"=",
"None",
")",
":",
"# A pen line width of zero indicates a cosmetic pen. This means that the pen width is",
"# always drawn one pixel wide, independent of the transformation set on th... | Creates a FloatCti with defaults for configuring a QPen width.
If specialValueZero is set, this string will be displayed when 0.0 is selected.
If specialValueZero is None, the minValue will be 0.1 | [
"Creates",
"a",
"FloatCti",
"with",
"defaults",
"for",
"configuring",
"a",
"QPen",
"width",
"."
] | python | train |
robin900/gspread-dataframe | gspread_dataframe.py | https://github.com/robin900/gspread-dataframe/blob/b64fef7ec196bfed69362aa35c593f448830a735/gspread_dataframe.py#L59-L77 | def _resize_to_minimum(worksheet, rows=None, cols=None):
"""
Resize the worksheet to guarantee a minimum size, either in rows,
or columns, or both.
Both rows and cols are optional.
"""
# get the current size
current_cols, current_rows = (
worksheet.col_count,
worksheet.row_c... | [
"def",
"_resize_to_minimum",
"(",
"worksheet",
",",
"rows",
"=",
"None",
",",
"cols",
"=",
"None",
")",
":",
"# get the current size",
"current_cols",
",",
"current_rows",
"=",
"(",
"worksheet",
".",
"col_count",
",",
"worksheet",
".",
"row_count",
")",
"if",
... | Resize the worksheet to guarantee a minimum size, either in rows,
or columns, or both.
Both rows and cols are optional. | [
"Resize",
"the",
"worksheet",
"to",
"guarantee",
"a",
"minimum",
"size",
"either",
"in",
"rows",
"or",
"columns",
"or",
"both",
"."
] | python | train |
grantmcconnaughey/Lintly | lintly/builds.py | https://github.com/grantmcconnaughey/Lintly/blob/73c1ee36740ac5bb2a32d3f24fca2a27f4d4e466/lintly/builds.py#L82-L97 | def find_diff_violations(self, patch):
"""
Uses the diff for this build to find changed lines that also have violations.
"""
violations = collections.defaultdict(list)
for line in patch.changed_lines:
file_violations = self._all_violations.get(line['file_name'])
... | [
"def",
"find_diff_violations",
"(",
"self",
",",
"patch",
")",
":",
"violations",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"line",
"in",
"patch",
".",
"changed_lines",
":",
"file_violations",
"=",
"self",
".",
"_all_violations",
".",
... | Uses the diff for this build to find changed lines that also have violations. | [
"Uses",
"the",
"diff",
"for",
"this",
"build",
"to",
"find",
"changed",
"lines",
"that",
"also",
"have",
"violations",
"."
] | python | train |
mandeep/Travis-Encrypt | travis/cli.py | https://github.com/mandeep/Travis-Encrypt/blob/0dd2da1c71feaadcb84bdeb26827e6dfe1bd3b41/travis/cli.py#L53-L107 | def cli(username, repository, path, password, deploy, env, clipboard, env_file):
"""Encrypt passwords and environment variables for use with Travis CI.
Travis Encrypt requires as arguments the user's GitHub username and repository name.
Once the arguments are passed, a password prompt will ask for the pass... | [
"def",
"cli",
"(",
"username",
",",
"repository",
",",
"path",
",",
"password",
",",
"deploy",
",",
"env",
",",
"clipboard",
",",
"env_file",
")",
":",
"key",
"=",
"retrieve_public_key",
"(",
"'{}/{}'",
".",
"format",
"(",
"username",
",",
"repository",
... | Encrypt passwords and environment variables for use with Travis CI.
Travis Encrypt requires as arguments the user's GitHub username and repository name.
Once the arguments are passed, a password prompt will ask for the password that needs
to be encrypted. The given password will then be encrypted via the P... | [
"Encrypt",
"passwords",
"and",
"environment",
"variables",
"for",
"use",
"with",
"Travis",
"CI",
"."
] | python | train |
saltstack/salt | salt/states/boto_secgroup.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_secgroup.py#L603-L663 | def absent(
name,
vpc_id=None,
vpc_name=None,
region=None,
key=None,
keyid=None,
profile=None):
'''
Ensure a security group with the specified name does not exist.
name
Name of the security group.
vpc_id
The ID of the VPC to remov... | [
"def",
"absent",
"(",
"name",
",",
"vpc_id",
"=",
"None",
",",
"vpc_name",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",... | Ensure a security group with the specified name does not exist.
name
Name of the security group.
vpc_id
The ID of the VPC to remove the security group from, if any. Exclusive with vpc_name.
vpc_name
The name of the VPC to remove the security group from, if any. Exclusive with vpc_... | [
"Ensure",
"a",
"security",
"group",
"with",
"the",
"specified",
"name",
"does",
"not",
"exist",
"."
] | python | train |
LogicalDash/LiSE | allegedb/allegedb/__init__.py | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/__init__.py#L972-L983 | def new_multidigraph(self, name, data=None, **attr):
"""Return a new instance of type MultiDiGraph, initialized with the given
data if provided.
:arg name: a name for the graph
:arg data: dictionary or NetworkX graph object providing initial state
"""
self._init_graph(n... | [
"def",
"new_multidigraph",
"(",
"self",
",",
"name",
",",
"data",
"=",
"None",
",",
"*",
"*",
"attr",
")",
":",
"self",
".",
"_init_graph",
"(",
"name",
",",
"'MultiDiGraph'",
")",
"mdg",
"=",
"MultiDiGraph",
"(",
"self",
",",
"name",
",",
"data",
",... | Return a new instance of type MultiDiGraph, initialized with the given
data if provided.
:arg name: a name for the graph
:arg data: dictionary or NetworkX graph object providing initial state | [
"Return",
"a",
"new",
"instance",
"of",
"type",
"MultiDiGraph",
"initialized",
"with",
"the",
"given",
"data",
"if",
"provided",
"."
] | python | train |
bcbio/bcbio-nextgen | scripts/utils/plink_to_vcf.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/plink_to_vcf.py#L119-L154 | def fix_nonref_positions(in_file, ref_file):
"""Fix Genotyping VCF positions where the bases are all variants.
The plink/pseq output does not handle these correctly, and
has all reference/variant bases reversed.
"""
ignore_chrs = ["."]
ref2bit = twobit.TwoBitFile(open(ref_file))
out_file = ... | [
"def",
"fix_nonref_positions",
"(",
"in_file",
",",
"ref_file",
")",
":",
"ignore_chrs",
"=",
"[",
"\".\"",
"]",
"ref2bit",
"=",
"twobit",
".",
"TwoBitFile",
"(",
"open",
"(",
"ref_file",
")",
")",
"out_file",
"=",
"in_file",
".",
"replace",
"(",
"\"-raw.v... | Fix Genotyping VCF positions where the bases are all variants.
The plink/pseq output does not handle these correctly, and
has all reference/variant bases reversed. | [
"Fix",
"Genotyping",
"VCF",
"positions",
"where",
"the",
"bases",
"are",
"all",
"variants",
"."
] | python | train |
iotile/coretools | transport_plugins/websocket/iotile_transport_websocket/generic/async_client.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/generic/async_client.py#L89-L104 | async def stop(self):
"""Stop this websocket client and disconnect from the server.
This method is idempotent and may be called multiple times. If called
when there is no active connection, it will simply return.
"""
if self._connection_task is None:
return
... | [
"async",
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_connection_task",
"is",
"None",
":",
"return",
"try",
":",
"await",
"self",
".",
"_connection_task",
".",
"stop",
"(",
")",
"finally",
":",
"self",
".",
"_con",
"=",
"None",
"self",
... | Stop this websocket client and disconnect from the server.
This method is idempotent and may be called multiple times. If called
when there is no active connection, it will simply return. | [
"Stop",
"this",
"websocket",
"client",
"and",
"disconnect",
"from",
"the",
"server",
"."
] | python | train |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/widgets/reftrackwidget.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/reftrackwidget.py#L59-L73 | def select(self, ):
"""Store the selected taskfileinfo self.selected and accept the dialog
:returns: None
:rtype: None
:raises: None
"""
s = self.browser.selected_indexes(self.browser.get_depth()-1)
if not s:
return
i = s[0].internalPointer()
... | [
"def",
"select",
"(",
"self",
",",
")",
":",
"s",
"=",
"self",
".",
"browser",
".",
"selected_indexes",
"(",
"self",
".",
"browser",
".",
"get_depth",
"(",
")",
"-",
"1",
")",
"if",
"not",
"s",
":",
"return",
"i",
"=",
"s",
"[",
"0",
"]",
".",
... | Store the selected taskfileinfo self.selected and accept the dialog
:returns: None
:rtype: None
:raises: None | [
"Store",
"the",
"selected",
"taskfileinfo",
"self",
".",
"selected",
"and",
"accept",
"the",
"dialog"
] | python | train |
pypa/pipenv | pipenv/patched/notpip/_vendor/html5lib/treeadapters/sax.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/treeadapters/sax.py#L13-L50 | def to_sax(walker, handler):
"""Call SAX-like content handler based on treewalker walker
:arg walker: the treewalker to use to walk the tree to convert it
:arg handler: SAX handler to use
"""
handler.startDocument()
for prefix, namespace in prefix_mapping.items():
handler.startPrefixM... | [
"def",
"to_sax",
"(",
"walker",
",",
"handler",
")",
":",
"handler",
".",
"startDocument",
"(",
")",
"for",
"prefix",
",",
"namespace",
"in",
"prefix_mapping",
".",
"items",
"(",
")",
":",
"handler",
".",
"startPrefixMapping",
"(",
"prefix",
",",
"namespac... | Call SAX-like content handler based on treewalker walker
:arg walker: the treewalker to use to walk the tree to convert it
:arg handler: SAX handler to use | [
"Call",
"SAX",
"-",
"like",
"content",
"handler",
"based",
"on",
"treewalker",
"walker"
] | python | train |
eventbrite/eventbrite-sdk-python | eventbrite/access_methods.py | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/access_methods.py#L425-L460 | def post_series_publish(self, id, **data):
"""
POST /series/:id/publish/
Publishes a repeating event series and all of its occurrences that are not already canceled or deleted. Once a date is cancelled it can still be uncancelled and can be viewed by the public. A deleted date cannot be undelete... | [
"def",
"post_series_publish",
"(",
"self",
",",
"id",
",",
"*",
"*",
"data",
")",
":",
"return",
"self",
".",
"post",
"(",
"\"/series/{0}/publish/\"",
".",
"format",
"(",
"id",
")",
",",
"data",
"=",
"data",
")"
] | POST /series/:id/publish/
Publishes a repeating event series and all of its occurrences that are not already canceled or deleted. Once a date is cancelled it can still be uncancelled and can be viewed by the public. A deleted date cannot be undeleted and cannot by viewed by the public. In order for
publ... | [
"POST",
"/",
"series",
"/",
":",
"id",
"/",
"publish",
"/",
"Publishes",
"a",
"repeating",
"event",
"series",
"and",
"all",
"of",
"its",
"occurrences",
"that",
"are",
"not",
"already",
"canceled",
"or",
"deleted",
".",
"Once",
"a",
"date",
"is",
"cancell... | python | train |
SITools2/pySitools2_1.0 | sitools2/core/pySitools2.py | https://github.com/SITools2/pySitools2_1.0/blob/acd13198162456ba401a0b923af989bb29feb3b6/sitools2/core/pySitools2.py#L373-L379 | def __parseColumns(self):
"""Returns the list of columns related to the dataset."""
columns = []
if self.__dataItem.has_key('columnModel'):
for column in self.__dataItem['columnModel']:
columns.append(Column(column))
return columns | [
"def",
"__parseColumns",
"(",
"self",
")",
":",
"columns",
"=",
"[",
"]",
"if",
"self",
".",
"__dataItem",
".",
"has_key",
"(",
"'columnModel'",
")",
":",
"for",
"column",
"in",
"self",
".",
"__dataItem",
"[",
"'columnModel'",
"]",
":",
"columns",
".",
... | Returns the list of columns related to the dataset. | [
"Returns",
"the",
"list",
"of",
"columns",
"related",
"to",
"the",
"dataset",
"."
] | python | train |
kwikteam/phy | phy/stats/ccg.py | https://github.com/kwikteam/phy/blob/7e9313dc364304b7d2bd03b92938347343703003/phy/stats/ccg.py#L19-L26 | def _increment(arr, indices):
"""Increment some indices in a 1D vector of non-negative integers.
Repeated indices are taken into account."""
arr = _as_array(arr)
indices = _as_array(indices)
bbins = np.bincount(indices)
arr[:len(bbins)] += bbins
return arr | [
"def",
"_increment",
"(",
"arr",
",",
"indices",
")",
":",
"arr",
"=",
"_as_array",
"(",
"arr",
")",
"indices",
"=",
"_as_array",
"(",
"indices",
")",
"bbins",
"=",
"np",
".",
"bincount",
"(",
"indices",
")",
"arr",
"[",
":",
"len",
"(",
"bbins",
"... | Increment some indices in a 1D vector of non-negative integers.
Repeated indices are taken into account. | [
"Increment",
"some",
"indices",
"in",
"a",
"1D",
"vector",
"of",
"non",
"-",
"negative",
"integers",
".",
"Repeated",
"indices",
"are",
"taken",
"into",
"account",
"."
] | python | train |
benley/butcher | butcher/util.py | https://github.com/benley/butcher/blob/8b18828ea040af56b7835beab5fd03eab23cc9ee/butcher/util.py#L91-L102 | def flatten(listish):
"""Flatten an arbitrarily-nested list of strings and lists.
Works for any subclass of basestring and any type of iterable.
"""
for elem in listish:
if (isinstance(elem, collections.Iterable)
and not isinstance(elem, basestring)):
for subelem in ... | [
"def",
"flatten",
"(",
"listish",
")",
":",
"for",
"elem",
"in",
"listish",
":",
"if",
"(",
"isinstance",
"(",
"elem",
",",
"collections",
".",
"Iterable",
")",
"and",
"not",
"isinstance",
"(",
"elem",
",",
"basestring",
")",
")",
":",
"for",
"subelem"... | Flatten an arbitrarily-nested list of strings and lists.
Works for any subclass of basestring and any type of iterable. | [
"Flatten",
"an",
"arbitrarily",
"-",
"nested",
"list",
"of",
"strings",
"and",
"lists",
"."
] | python | train |
DataBiosphere/toil | src/toil/wdl/wdl_synthesis.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/wdl/wdl_synthesis.py#L560-L598 | def write_function(self, job):
'''
Writes out a python function for each WDL "task" object.
Each python function is a unit of work written out as a string in
preparation to being written out to a file. In WDL, each "job" is
called a "task". Each WDL task is written out in mult... | [
"def",
"write_function",
"(",
"self",
",",
"job",
")",
":",
"# write the function header",
"fn_section",
"=",
"self",
".",
"write_function_header",
"(",
"job",
")",
"# write out commandline keywords",
"fn_section",
"+=",
"self",
".",
"write_function_cmdline",
"(",
"jo... | Writes out a python function for each WDL "task" object.
Each python function is a unit of work written out as a string in
preparation to being written out to a file. In WDL, each "job" is
called a "task". Each WDL task is written out in multiple steps:
1: Header and inputs (e.g. 'de... | [
"Writes",
"out",
"a",
"python",
"function",
"for",
"each",
"WDL",
"task",
"object",
"."
] | python | train |
jazzband/django-push-notifications | push_notifications/wns.py | https://github.com/jazzband/django-push-notifications/blob/c4a0d710711fa27bfb6533c0bf3468cb67a62679/push_notifications/wns.py#L259-L322 | def dict_to_xml_schema(data):
"""
Input a dictionary to be converted to xml. There should be only one key at
the top level. The value must be a dict with (required) `children` key and
(optional) `attrs` key. This will be called the `sub-element dictionary`.
The `attrs` value must be a dictionary; each value will ... | [
"def",
"dict_to_xml_schema",
"(",
"data",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"root",
"=",
"_add_element_attrs",
"(",
"ET",
".",
"Element",
"(",
"key",
")",
",",
"value",
".",
"get",
"(",
"\"attrs\"",
",",... | Input a dictionary to be converted to xml. There should be only one key at
the top level. The value must be a dict with (required) `children` key and
(optional) `attrs` key. This will be called the `sub-element dictionary`.
The `attrs` value must be a dictionary; each value will be added to the
element's xml tag a... | [
"Input",
"a",
"dictionary",
"to",
"be",
"converted",
"to",
"xml",
".",
"There",
"should",
"be",
"only",
"one",
"key",
"at",
"the",
"top",
"level",
".",
"The",
"value",
"must",
"be",
"a",
"dict",
"with",
"(",
"required",
")",
"children",
"key",
"and",
... | python | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/device_adapter.py#L364-L381 | def _find_connection(self, topic):
"""Attempt to find a connection id corresponding with a topic
The device is found by assuming the topic ends in <slug>/[control|data]/channel
Args:
topic (string): The topic we received a message on
Returns:
int: The internal ... | [
"def",
"_find_connection",
"(",
"self",
",",
"topic",
")",
":",
"parts",
"=",
"topic",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"parts",
")",
"<",
"3",
":",
"return",
"None",
"slug",
"=",
"parts",
"[",
"-",
"3",
"]",
"return",
"slug"
] | Attempt to find a connection id corresponding with a topic
The device is found by assuming the topic ends in <slug>/[control|data]/channel
Args:
topic (string): The topic we received a message on
Returns:
int: The internal connect id (device slug) associated with this ... | [
"Attempt",
"to",
"find",
"a",
"connection",
"id",
"corresponding",
"with",
"a",
"topic"
] | python | train |
MediaFire/mediafire-python-open-sdk | mediafire/uploader.py | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L353-L363 | def _upload_check(self, upload_info, resumable=False):
"""Wrapper around upload/check"""
return self._api.upload_check(
filename=upload_info.name,
size=upload_info.size,
hash_=upload_info.hash_info.file,
folder_key=upload_info.folder_key,
filed... | [
"def",
"_upload_check",
"(",
"self",
",",
"upload_info",
",",
"resumable",
"=",
"False",
")",
":",
"return",
"self",
".",
"_api",
".",
"upload_check",
"(",
"filename",
"=",
"upload_info",
".",
"name",
",",
"size",
"=",
"upload_info",
".",
"size",
",",
"h... | Wrapper around upload/check | [
"Wrapper",
"around",
"upload",
"/",
"check"
] | python | train |
NuGrid/NuGridPy | nugridpy/data_plot.py | https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/data_plot.py#L1540-L1935 | def abu_chart(self, cycle, mass_range=None ,ilabel=True,
imlabel=True, imlabel_fontsize=8, imagic=False,
boxstable=True, lbound=(-12, 0),
plotaxis=[0, 0, 0, 0], show=True, color_map='jet',
ifig=None,data_provided=False,thedata=None,
... | [
"def",
"abu_chart",
"(",
"self",
",",
"cycle",
",",
"mass_range",
"=",
"None",
",",
"ilabel",
"=",
"True",
",",
"imlabel",
"=",
"True",
",",
"imlabel_fontsize",
"=",
"8",
",",
"imagic",
"=",
"False",
",",
"boxstable",
"=",
"True",
",",
"lbound",
"=",
... | Plots an abundance chart
Parameters
----------
cycle : string, integer or list
The cycle we are looking in. If it is a list of cycles,
this method will then do a plot for each of these cycles
and save them all to a file.
mass_range : list, optional
... | [
"Plots",
"an",
"abundance",
"chart"
] | python | train |
gem/oq-engine | openquake/commands/plot.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/plot.py#L120-L140 | def make_figure_source_geom(extractors, what):
"""
Extract the geometry of a given sources
Example:
http://127.0.0.1:8800/v1/calc/30/extract/source_geom/1,2,3
"""
import matplotlib.pyplot as plt
fig = plt.figure()
[ex] = extractors
sitecol = ex.get('sitecol')
geom_by_src = vars(e... | [
"def",
"make_figure_source_geom",
"(",
"extractors",
",",
"what",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"[",
"ex",
"]",
"=",
"extractors",
"sitecol",
"=",
"ex",
".",
"get",
"(",
"'site... | Extract the geometry of a given sources
Example:
http://127.0.0.1:8800/v1/calc/30/extract/source_geom/1,2,3 | [
"Extract",
"the",
"geometry",
"of",
"a",
"given",
"sources",
"Example",
":",
"http",
":",
"//",
"127",
".",
"0",
".",
"0",
".",
"1",
":",
"8800",
"/",
"v1",
"/",
"calc",
"/",
"30",
"/",
"extract",
"/",
"source_geom",
"/",
"1",
"2",
"3"
] | python | train |
cloudtools/stacker | stacker/actions/build.py | https://github.com/cloudtools/stacker/blob/ad6013a03a560c46ba3c63c4d153336273e6da5d/stacker/actions/build.py#L41-L59 | def should_update(stack):
"""Tests whether a stack should be submitted for updates to CF.
Args:
stack (:class:`stacker.stack.Stack`): The stack object to check.
Returns:
bool: If the stack should be updated, return True.
"""
if stack.locked:
if not stack.force:
... | [
"def",
"should_update",
"(",
"stack",
")",
":",
"if",
"stack",
".",
"locked",
":",
"if",
"not",
"stack",
".",
"force",
":",
"logger",
".",
"debug",
"(",
"\"Stack %s locked and not in --force list. \"",
"\"Refusing to update.\"",
",",
"stack",
".",
"name",
")",
... | Tests whether a stack should be submitted for updates to CF.
Args:
stack (:class:`stacker.stack.Stack`): The stack object to check.
Returns:
bool: If the stack should be updated, return True. | [
"Tests",
"whether",
"a",
"stack",
"should",
"be",
"submitted",
"for",
"updates",
"to",
"CF",
"."
] | python | train |
quora/qcore | qcore/asserts.py | https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L104-L130 | def assert_eq(expected, actual, message=None, tolerance=None, extra=None):
"""Raises an AssertionError if expected != actual.
If tolerance is specified, raises an AssertionError if either
- expected or actual isn't a number, or
- the difference between expected and actual is larger than the tolerance.
... | [
"def",
"assert_eq",
"(",
"expected",
",",
"actual",
",",
"message",
"=",
"None",
",",
"tolerance",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"if",
"tolerance",
"is",
"None",
":",
"assert",
"expected",
"==",
"actual",
",",
"_assert_fail_message",
... | Raises an AssertionError if expected != actual.
If tolerance is specified, raises an AssertionError if either
- expected or actual isn't a number, or
- the difference between expected and actual is larger than the tolerance. | [
"Raises",
"an",
"AssertionError",
"if",
"expected",
"!",
"=",
"actual",
"."
] | python | train |
PMEAL/OpenPNM | openpnm/utils/petsc.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/utils/petsc.py#L49-L97 | def _initialize_A(self):
r"""
This method creates the petsc sparse coefficients matrix from the
OpenPNM scipy one. The method also equally decomposes the matrix at
certain rows into different blocks (each block contains all the
columns) and distributes them over the pre-assigned ... | [
"def",
"_initialize_A",
"(",
"self",
")",
":",
"# Matrix of coefficients size",
"self",
".",
"m",
",",
"self",
".",
"n",
"=",
"(",
"self",
".",
"A",
")",
".",
"shape",
"# Create a petsc sparse matrix",
"self",
".",
"petsc_A",
"=",
"PETSc",
".",
"Mat",
"(",... | r"""
This method creates the petsc sparse coefficients matrix from the
OpenPNM scipy one. The method also equally decomposes the matrix at
certain rows into different blocks (each block contains all the
columns) and distributes them over the pre-assigned cores for parallel
comput... | [
"r",
"This",
"method",
"creates",
"the",
"petsc",
"sparse",
"coefficients",
"matrix",
"from",
"the",
"OpenPNM",
"scipy",
"one",
".",
"The",
"method",
"also",
"equally",
"decomposes",
"the",
"matrix",
"at",
"certain",
"rows",
"into",
"different",
"blocks",
"(",... | python | train |
mikedh/trimesh | trimesh/exchange/ply.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/exchange/ply.py#L289-L419 | def elements_to_kwargs(elements, fix_texture, image):
"""
Given an elements data structure, extract the keyword
arguments that a Trimesh object constructor will expect.
Parameters
------------
elements: OrderedDict object, with fields and data loaded
Returns
-----------
kwargs: dic... | [
"def",
"elements_to_kwargs",
"(",
"elements",
",",
"fix_texture",
",",
"image",
")",
":",
"kwargs",
"=",
"{",
"'metadata'",
":",
"{",
"'ply_raw'",
":",
"elements",
"}",
"}",
"vertices",
"=",
"np",
".",
"column_stack",
"(",
"[",
"elements",
"[",
"'vertex'",... | Given an elements data structure, extract the keyword
arguments that a Trimesh object constructor will expect.
Parameters
------------
elements: OrderedDict object, with fields and data loaded
Returns
-----------
kwargs: dict, with keys for Trimesh constructor.
eg: mesh = trime... | [
"Given",
"an",
"elements",
"data",
"structure",
"extract",
"the",
"keyword",
"arguments",
"that",
"a",
"Trimesh",
"object",
"constructor",
"will",
"expect",
"."
] | python | train |
alvarogzp/telegram-bot-framework | bot/action/standard/userinfo.py | https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/userinfo.py#L26-L30 | def get_instance(cls, state):
""":rtype: UserStorageHandler"""
if cls.instance is None:
cls.instance = UserStorageHandler(state)
return cls.instance | [
"def",
"get_instance",
"(",
"cls",
",",
"state",
")",
":",
"if",
"cls",
".",
"instance",
"is",
"None",
":",
"cls",
".",
"instance",
"=",
"UserStorageHandler",
"(",
"state",
")",
"return",
"cls",
".",
"instance"
] | :rtype: UserStorageHandler | [
":",
"rtype",
":",
"UserStorageHandler"
] | python | train |
aliyun/aliyun-log-python-sdk | aliyun/log/logclient.py | https://github.com/aliyun/aliyun-log-python-sdk/blob/ac383db0a16abf1e5ef7df36074374184b43516e/aliyun/log/logclient.py#L1691-L1710 | def get_machine_group(self, project_name, group_name):
""" get machine group in a project
Unsuccessful opertaion will cause an LogException.
:type project_name: string
:param project_name: the Project name
:type group_name: string
:param group_name: the group n... | [
"def",
"get_machine_group",
"(",
"self",
",",
"project_name",
",",
"group_name",
")",
":",
"headers",
"=",
"{",
"}",
"params",
"=",
"{",
"}",
"resource",
"=",
"\"/machinegroups/\"",
"+",
"group_name",
"(",
"resp",
",",
"headers",
")",
"=",
"self",
".",
"... | get machine group in a project
Unsuccessful opertaion will cause an LogException.
:type project_name: string
:param project_name: the Project name
:type group_name: string
:param group_name: the group name to get
:return: GetMachineGroupResponse
... | [
"get",
"machine",
"group",
"in",
"a",
"project",
"Unsuccessful",
"opertaion",
"will",
"cause",
"an",
"LogException",
".",
":",
"type",
"project_name",
":",
"string",
":",
"param",
"project_name",
":",
"the",
"Project",
"name",
":",
"type",
"group_name",
":",
... | python | train |
KartikTalwar/Duolingo | duolingo.py | https://github.com/KartikTalwar/Duolingo/blob/0f7e9a0d4bfa864ade82890fca3789679ef38bee/duolingo.py#L237-L255 | def get_languages(self, abbreviations=False):
"""
Get praticed languages.
:param abbreviations: Get language as abbreviation or not
:type abbreviations: bool
:return: List of languages
:rtype: list of str
"""
data = []
for lang in self.user_data.... | [
"def",
"get_languages",
"(",
"self",
",",
"abbreviations",
"=",
"False",
")",
":",
"data",
"=",
"[",
"]",
"for",
"lang",
"in",
"self",
".",
"user_data",
".",
"languages",
":",
"if",
"lang",
"[",
"'learning'",
"]",
":",
"if",
"abbreviations",
":",
"data... | Get praticed languages.
:param abbreviations: Get language as abbreviation or not
:type abbreviations: bool
:return: List of languages
:rtype: list of str | [
"Get",
"praticed",
"languages",
"."
] | python | train |
pystorm/pystorm | pystorm/bolt.py | https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/bolt.py#L496-L503 | def _batch_entry_run(self):
"""The inside of ``_batch_entry``'s infinite loop.
Separated out so it can be properly unit tested.
"""
time.sleep(self.secs_between_batches)
with self._batch_lock:
self.process_batches() | [
"def",
"_batch_entry_run",
"(",
"self",
")",
":",
"time",
".",
"sleep",
"(",
"self",
".",
"secs_between_batches",
")",
"with",
"self",
".",
"_batch_lock",
":",
"self",
".",
"process_batches",
"(",
")"
] | The inside of ``_batch_entry``'s infinite loop.
Separated out so it can be properly unit tested. | [
"The",
"inside",
"of",
"_batch_entry",
"s",
"infinite",
"loop",
"."
] | python | train |
sidecars/python-quickbooks | quickbooks/mixins.py | https://github.com/sidecars/python-quickbooks/blob/4cb2b6da46423bad8b32b85d87f9a97b698144fd/quickbooks/mixins.py#L211-L228 | def query(cls, select, qb=None):
"""
:param select: QBO SQL query select statement
:param qb:
:return: Returns list
"""
if not qb:
qb = QuickBooks()
json_data = qb.query(select)
obj_list = []
if cls.qbo_object_name in json_data["Quer... | [
"def",
"query",
"(",
"cls",
",",
"select",
",",
"qb",
"=",
"None",
")",
":",
"if",
"not",
"qb",
":",
"qb",
"=",
"QuickBooks",
"(",
")",
"json_data",
"=",
"qb",
".",
"query",
"(",
"select",
")",
"obj_list",
"=",
"[",
"]",
"if",
"cls",
".",
"qbo_... | :param select: QBO SQL query select statement
:param qb:
:return: Returns list | [
":",
"param",
"select",
":",
"QBO",
"SQL",
"query",
"select",
"statement",
":",
"param",
"qb",
":",
":",
"return",
":",
"Returns",
"list"
] | python | train |
saltstack/salt | salt/modules/azurearm_network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/azurearm_network.py#L240-L269 | def security_rules_list(security_group, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
List security rules within a network security group.
:param security_group: The network security group to query.
:param resource_group: The resource group name assigned to the
network securit... | [
"def",
"security_rules_list",
"(",
"security_group",
",",
"resource_group",
",",
"*",
"*",
"kwargs",
")",
":",
"netconn",
"=",
"__utils__",
"[",
"'azurearm.get_client'",
"]",
"(",
"'network'",
",",
"*",
"*",
"kwargs",
")",
"try",
":",
"secrules",
"=",
"netco... | .. versionadded:: 2019.2.0
List security rules within a network security group.
:param security_group: The network security group to query.
:param resource_group: The resource group name assigned to the
network security group.
CLI Example:
.. code-block:: bash
salt-call azurear... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train |
rochacbruno/manage | manage/auto_import.py | https://github.com/rochacbruno/manage/blob/e904c451862f036f4be8723df5704a9844103c74/manage/auto_import.py#L13-L21 | def import_submodules(name, submodules=None):
"""Import all submodules for a package/module name"""
sys.path.insert(0, name)
if submodules:
for submodule in submodules:
import_string('{0}.{1}'.format(name, submodule))
else:
for item in pkgutil.walk_packages([name]):
... | [
"def",
"import_submodules",
"(",
"name",
",",
"submodules",
"=",
"None",
")",
":",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"name",
")",
"if",
"submodules",
":",
"for",
"submodule",
"in",
"submodules",
":",
"import_string",
"(",
"'{0}.{1}'",
"."... | Import all submodules for a package/module name | [
"Import",
"all",
"submodules",
"for",
"a",
"package",
"/",
"module",
"name"
] | python | train |
NicolasLM/spinach | spinach/brokers/redis.py | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/redis.py#L100-L118 | def enqueue_jobs(self, jobs: Iterable[Job]):
"""Enqueue a batch of jobs."""
jobs_to_queue = list()
for job in jobs:
if job.should_start:
job.status = JobStatus.QUEUED
else:
job.status = JobStatus.WAITING
jobs_to_queue.append(job... | [
"def",
"enqueue_jobs",
"(",
"self",
",",
"jobs",
":",
"Iterable",
"[",
"Job",
"]",
")",
":",
"jobs_to_queue",
"=",
"list",
"(",
")",
"for",
"job",
"in",
"jobs",
":",
"if",
"job",
".",
"should_start",
":",
"job",
".",
"status",
"=",
"JobStatus",
".",
... | Enqueue a batch of jobs. | [
"Enqueue",
"a",
"batch",
"of",
"jobs",
"."
] | python | train |
metagriffin/asset | asset/plugin.py | https://github.com/metagriffin/asset/blob/f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c/asset/plugin.py#L112-L184 | def plugins(group, spec=None):
# TODO: share this documentation with `../doc/plugin.rst`...
'''
Returns a `PluginSet` object for the specified setuptools-style
entrypoint `group`. This is just a wrapper around
`pkg_resources.iter_entry_points` that allows the plugins to sort
and override themselves.
The ... | [
"def",
"plugins",
"(",
"group",
",",
"spec",
"=",
"None",
")",
":",
"# TODO: share this documentation with `../doc/plugin.rst`...",
"pspec",
"=",
"_parse_spec",
"(",
"spec",
")",
"plugs",
"=",
"list",
"(",
"_get_registered_plugins",
"(",
"group",
",",
"pspec",
")"... | Returns a `PluginSet` object for the specified setuptools-style
entrypoint `group`. This is just a wrapper around
`pkg_resources.iter_entry_points` that allows the plugins to sort
and override themselves.
The optional `spec` parameter controls how and what plugins are
loaded. If it is ``None`` or the special... | [
"Returns",
"a",
"PluginSet",
"object",
"for",
"the",
"specified",
"setuptools",
"-",
"style",
"entrypoint",
"group",
".",
"This",
"is",
"just",
"a",
"wrapper",
"around",
"pkg_resources",
".",
"iter_entry_points",
"that",
"allows",
"the",
"plugins",
"to",
"sort",... | python | train |
jleclanche/fireplace | fireplace/game.py | https://github.com/jleclanche/fireplace/blob/d0fc0e97e185c0210de86631be20638659c0609e/fireplace/game.py#L193-L201 | def queue_actions(self, source, actions, event_args=None):
"""
Queue a list of \a actions for processing from \a source.
Triggers an aura refresh afterwards.
"""
source.event_args = event_args
ret = self.trigger_actions(source, actions)
source.event_args = None
return ret | [
"def",
"queue_actions",
"(",
"self",
",",
"source",
",",
"actions",
",",
"event_args",
"=",
"None",
")",
":",
"source",
".",
"event_args",
"=",
"event_args",
"ret",
"=",
"self",
".",
"trigger_actions",
"(",
"source",
",",
"actions",
")",
"source",
".",
"... | Queue a list of \a actions for processing from \a source.
Triggers an aura refresh afterwards. | [
"Queue",
"a",
"list",
"of",
"\\",
"a",
"actions",
"for",
"processing",
"from",
"\\",
"a",
"source",
".",
"Triggers",
"an",
"aura",
"refresh",
"afterwards",
"."
] | python | train |
joyent/python-manta | manta/auth.py | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L246-L310 | def ssh_key_info_from_key_data(key_id, priv_key=None):
"""Get/load SSH key info necessary for signing.
@param key_id {str} Either a private ssh key fingerprint, e.g.
'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
an ssh private key file (like ssh's IdentityFile config option)... | [
"def",
"ssh_key_info_from_key_data",
"(",
"key_id",
",",
"priv_key",
"=",
"None",
")",
":",
"if",
"FINGERPRINT_RE",
".",
"match",
"(",
"key_id",
")",
"and",
"priv_key",
":",
"key_info",
"=",
"{",
"\"fingerprint\"",
":",
"key_id",
",",
"\"priv_key\"",
":",
"p... | Get/load SSH key info necessary for signing.
@param key_id {str} Either a private ssh key fingerprint, e.g.
'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
an ssh private key file (like ssh's IdentityFile config option).
@param priv_key {str} Optional. SSH private key file dat... | [
"Get",
"/",
"load",
"SSH",
"key",
"info",
"necessary",
"for",
"signing",
"."
] | python | train |
mosdef-hub/mbuild | mbuild/utils/conversion.py | https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/utils/conversion.py#L4-L23 | def RB_to_OPLS(c0, c1, c2, c3, c4, c5):
"""Converts Ryckaert-Bellemans type dihedrals to OPLS type.
Parameters
----------
c0, c1, c2, c3, c4, c5 : Ryckaert-Belleman coefficients (in kcal/mol)
Returns
-------
opls_coeffs : np.array, shape=(4,)
Array containing the OPLS dihedrals coe... | [
"def",
"RB_to_OPLS",
"(",
"c0",
",",
"c1",
",",
"c2",
",",
"c3",
",",
"c4",
",",
"c5",
")",
":",
"f1",
"=",
"(",
"-",
"1.5",
"*",
"c3",
")",
"-",
"(",
"2",
"*",
"c1",
")",
"f2",
"=",
"c0",
"+",
"c1",
"+",
"c3",
"f3",
"=",
"-",
"0.5",
... | Converts Ryckaert-Bellemans type dihedrals to OPLS type.
Parameters
----------
c0, c1, c2, c3, c4, c5 : Ryckaert-Belleman coefficients (in kcal/mol)
Returns
-------
opls_coeffs : np.array, shape=(4,)
Array containing the OPLS dihedrals coeffs f1, f2, f3, and f4
(in kcal/mol) | [
"Converts",
"Ryckaert",
"-",
"Bellemans",
"type",
"dihedrals",
"to",
"OPLS",
"type",
"."
] | python | train |
rodluger/everest | everest/inject.py | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/inject.py#L28-L334 | def Inject(ID, inj_model='nPLD', t0=None, per=None, dur=0.1, depth=0.001,
mask=False, trn_win=5, poly_order=3, make_fits=False, **kwargs):
'''
Run one of the :py:obj:`everest` models with injected transits and attempt
to recover the transit depth at the end with a simple linear regression
wit... | [
"def",
"Inject",
"(",
"ID",
",",
"inj_model",
"=",
"'nPLD'",
",",
"t0",
"=",
"None",
",",
"per",
"=",
"None",
",",
"dur",
"=",
"0.1",
",",
"depth",
"=",
"0.001",
",",
"mask",
"=",
"False",
",",
"trn_win",
"=",
"5",
",",
"poly_order",
"=",
"3",
... | Run one of the :py:obj:`everest` models with injected transits and attempt
to recover the transit depth at the end with a simple linear regression
with a polynomial baseline. The depth is stored in the
:py:obj:`inject` attribute of the model (a dictionary) as
:py:obj:`rec_depth`. A control injection is ... | [
"Run",
"one",
"of",
"the",
":",
"py",
":",
"obj",
":",
"everest",
"models",
"with",
"injected",
"transits",
"and",
"attempt",
"to",
"recover",
"the",
"transit",
"depth",
"at",
"the",
"end",
"with",
"a",
"simple",
"linear",
"regression",
"with",
"a",
"pol... | python | train |
theislab/scvelo | scvelo/tools/rank_velocity_genes.py | https://github.com/theislab/scvelo/blob/c7a96d70edfe705e86bf364434a9527d4fd8df11/scvelo/tools/rank_velocity_genes.py#L39-L52 | def select_groups(adata, groups='all', key='louvain'):
"""Get subset of groups in adata.obs[key].
"""
strings_to_categoricals(adata)
if isinstance(groups, list) and isinstance(groups[0], int): groups = [str(n) for n in groups]
categories = adata.obs[key].cat.categories
groups_masks = np.array([c... | [
"def",
"select_groups",
"(",
"adata",
",",
"groups",
"=",
"'all'",
",",
"key",
"=",
"'louvain'",
")",
":",
"strings_to_categoricals",
"(",
"adata",
")",
"if",
"isinstance",
"(",
"groups",
",",
"list",
")",
"and",
"isinstance",
"(",
"groups",
"[",
"0",
"]... | Get subset of groups in adata.obs[key]. | [
"Get",
"subset",
"of",
"groups",
"in",
"adata",
".",
"obs",
"[",
"key",
"]",
"."
] | python | train |
jrderuiter/pybiomart | src/pybiomart/dataset.py | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/dataset.py#L88-L92 | def filters(self):
"""List of filters available for the dataset."""
if self._filters is None:
self._filters, self._attributes = self._fetch_configuration()
return self._filters | [
"def",
"filters",
"(",
"self",
")",
":",
"if",
"self",
".",
"_filters",
"is",
"None",
":",
"self",
".",
"_filters",
",",
"self",
".",
"_attributes",
"=",
"self",
".",
"_fetch_configuration",
"(",
")",
"return",
"self",
".",
"_filters"
] | List of filters available for the dataset. | [
"List",
"of",
"filters",
"available",
"for",
"the",
"dataset",
"."
] | python | train |
spyder-ide/spyder | spyder/plugins/editor/plugin.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1831-L1847 | def print_file(self):
"""Print current file"""
editor = self.get_current_editor()
filename = self.get_current_filename()
printer = Printer(mode=QPrinter.HighResolution,
header_font=self.get_plugin_font('printer_header'))
printDialog = QPrintDialog(... | [
"def",
"print_file",
"(",
"self",
")",
":",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"filename",
"=",
"self",
".",
"get_current_filename",
"(",
")",
"printer",
"=",
"Printer",
"(",
"mode",
"=",
"QPrinter",
".",
"HighResolution",
",",
"he... | Print current file | [
"Print",
"current",
"file"
] | python | train |
qacafe/cdrouter.py | cdrouter/devices.py | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/devices.py#L312-L321 | def connect(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Open proxy connection to a device's management interface.
:param id: Device ID as an int.
:return: :class:`devices.Connection <devices.Connection>` object
:rtype: devices.Connection
"""
schema = C... | [
"def",
"connect",
"(",
"self",
",",
"id",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"schema",
"=",
"ConnectionSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"post",
"(",
"self",
".",
"base",
"+",
"str",
"(",
"id",
")",
"+"... | Open proxy connection to a device's management interface.
:param id: Device ID as an int.
:return: :class:`devices.Connection <devices.Connection>` object
:rtype: devices.Connection | [
"Open",
"proxy",
"connection",
"to",
"a",
"device",
"s",
"management",
"interface",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.