repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
materialsproject/pymatgen | pymatgen/__init__.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/__init__.py#L52-L73 | def get_structure_from_mp(formula):
"""
Convenience method to get a crystal from the Materials Project database via
the API. Requires PMG_MAPI_KEY to be set.
Args:
formula (str): A formula
Returns:
(Structure) The lowest energy structure in Materials Project with that
f... | [
"def",
"get_structure_from_mp",
"(",
"formula",
")",
":",
"m",
"=",
"MPRester",
"(",
")",
"entries",
"=",
"m",
".",
"get_entries",
"(",
"formula",
",",
"inc_structure",
"=",
"\"final\"",
")",
"if",
"len",
"(",
"entries",
")",
"==",
"0",
":",
"raise",
"... | Convenience method to get a crystal from the Materials Project database via
the API. Requires PMG_MAPI_KEY to be set.
Args:
formula (str): A formula
Returns:
(Structure) The lowest energy structure in Materials Project with that
formula. | [
"Convenience",
"method",
"to",
"get",
"a",
"crystal",
"from",
"the",
"Materials",
"Project",
"database",
"via",
"the",
"API",
".",
"Requires",
"PMG_MAPI_KEY",
"to",
"be",
"set",
"."
] | python | train | 37.681818 |
HIPS/autograd | examples/ica.py | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/ica.py#L13-L41 | def make_ica_funs(observed_dimension, latent_dimension):
"""These functions implement independent component analysis.
The model is:
latents are drawn i.i.d. for each data point from a product of student-ts.
weights are the same across all datapoints.
each data = latents * weghts + noise."""
de... | [
"def",
"make_ica_funs",
"(",
"observed_dimension",
",",
"latent_dimension",
")",
":",
"def",
"sample",
"(",
"weights",
",",
"n_samples",
",",
"noise_std",
",",
"rs",
")",
":",
"latents",
"=",
"rs",
".",
"randn",
"(",
"latent_dimension",
",",
"n_samples",
")"... | These functions implement independent component analysis.
The model is:
latents are drawn i.i.d. for each data point from a product of student-ts.
weights are the same across all datapoints.
each data = latents * weghts + noise. | [
"These",
"functions",
"implement",
"independent",
"component",
"analysis",
"."
] | python | train | 38.517241 |
scanny/python-pptx | pptx/dml/fill.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/dml/fill.py#L131-L140 | def patterned(self):
"""Selects the pattern fill type.
Note that calling this method does not by itself set a foreground or
background color of the pattern. Rather it enables subsequent
assignments to properties like fore_color to set the pattern and
colors.
"""
... | [
"def",
"patterned",
"(",
"self",
")",
":",
"pattFill",
"=",
"self",
".",
"_xPr",
".",
"get_or_change_to_pattFill",
"(",
")",
"self",
".",
"_fill",
"=",
"_PattFill",
"(",
"pattFill",
")"
] | Selects the pattern fill type.
Note that calling this method does not by itself set a foreground or
background color of the pattern. Rather it enables subsequent
assignments to properties like fore_color to set the pattern and
colors. | [
"Selects",
"the",
"pattern",
"fill",
"type",
"."
] | python | train | 40 |
zhanglab/psamm | psamm/commands/chargecheck.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/chargecheck.py#L48-L81 | def run(self):
"""Run charge balance command"""
# Load compound information
def compound_name(id):
if id not in self._model.compounds:
return id
return self._model.compounds[id].properties.get('name', id)
# Create a set of excluded reactions
... | [
"def",
"run",
"(",
"self",
")",
":",
"# Load compound information",
"def",
"compound_name",
"(",
"id",
")",
":",
"if",
"id",
"not",
"in",
"self",
".",
"_model",
".",
"compounds",
":",
"return",
"id",
"return",
"self",
".",
"_model",
".",
"compounds",
"["... | Run charge balance command | [
"Run",
"charge",
"balance",
"command"
] | python | train | 37.470588 |
ga4gh/ga4gh-server | ga4gh/server/backend.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/backend.py#L338-L349 | def variantsGenerator(self, request):
"""
Returns a generator over the (variant, nextPageToken) pairs defined
by the specified request.
"""
compoundId = datamodel.VariantSetCompoundId \
.parse(request.variant_set_id)
dataset = self.getDataRepository().getDatas... | [
"def",
"variantsGenerator",
"(",
"self",
",",
"request",
")",
":",
"compoundId",
"=",
"datamodel",
".",
"VariantSetCompoundId",
".",
"parse",
"(",
"request",
".",
"variant_set_id",
")",
"dataset",
"=",
"self",
".",
"getDataRepository",
"(",
")",
".",
"getDatas... | Returns a generator over the (variant, nextPageToken) pairs defined
by the specified request. | [
"Returns",
"a",
"generator",
"over",
"the",
"(",
"variant",
"nextPageToken",
")",
"pairs",
"defined",
"by",
"the",
"specified",
"request",
"."
] | python | train | 44.083333 |
mozilla/taar | taar/flask_app.py | https://github.com/mozilla/taar/blob/4002eb395f0b7ad837f1578e92d590e2cf82bdca/taar/flask_app.py#L41-L86 | def flaskrun(app, default_host="127.0.0.1", default_port="8000"):
"""
Takes a flask.Flask instance and runs it. Parses
command-line flags to configure the app.
"""
# Set up the command-line options
parser = optparse.OptionParser()
parser.add_option(
"-H",
"--host",
h... | [
"def",
"flaskrun",
"(",
"app",
",",
"default_host",
"=",
"\"127.0.0.1\"",
",",
"default_port",
"=",
"\"8000\"",
")",
":",
"# Set up the command-line options",
"parser",
"=",
"optparse",
".",
"OptionParser",
"(",
")",
"parser",
".",
"add_option",
"(",
"\"-H\"",
"... | Takes a flask.Flask instance and runs it. Parses
command-line flags to configure the app. | [
"Takes",
"a",
"flask",
".",
"Flask",
"instance",
"and",
"runs",
"it",
".",
"Parses",
"command",
"-",
"line",
"flags",
"to",
"configure",
"the",
"app",
"."
] | python | train | 29.630435 |
jasonrbriggs/stomp.py | stomp/transport.py | https://github.com/jasonrbriggs/stomp.py/blob/643843c5fbf25fd24339dd0e69a9411c3d8b94c7/stomp/transport.py#L130-L137 | def set_connected(self, connected):
"""
:param bool connected:
"""
with self.__connect_wait_condition:
self.connected = connected
if connected:
self.__connect_wait_condition.notify() | [
"def",
"set_connected",
"(",
"self",
",",
"connected",
")",
":",
"with",
"self",
".",
"__connect_wait_condition",
":",
"self",
".",
"connected",
"=",
"connected",
"if",
"connected",
":",
"self",
".",
"__connect_wait_condition",
".",
"notify",
"(",
")"
] | :param bool connected: | [
":",
"param",
"bool",
"connected",
":"
] | python | train | 30.875 |
phaethon/kamene | kamene/packet.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/packet.py#L1250-L1273 | def ls(obj=None):
"""List available layers, or infos on a given layer"""
if obj is None:
import builtins
all = builtins.__dict__.copy()
all.update(globals())
objlst = sorted(conf.layers, key=lambda x:x.__name__)
for o in objlst:
print("%-10s : %s" %(... | [
"def",
"ls",
"(",
"obj",
"=",
"None",
")",
":",
"if",
"obj",
"is",
"None",
":",
"import",
"builtins",
"all",
"=",
"builtins",
".",
"__dict__",
".",
"copy",
"(",
")",
"all",
".",
"update",
"(",
"globals",
"(",
")",
")",
"objlst",
"=",
"sorted",
"(... | List available layers, or infos on a given layer | [
"List",
"available",
"layers",
"or",
"infos",
"on",
"a",
"given",
"layer"
] | python | train | 39.666667 |
notanumber/xapian-haystack | xapian_backend.py | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L552-L564 | def _build_models_query(self, query):
"""
Builds a query from `query` that filters to documents only from registered models.
"""
registered_models_ct = self.build_models_list()
if registered_models_ct:
restrictions = [xapian.Query('%s%s' % (TERM_PREFIXES[DJANGO_CT], m... | [
"def",
"_build_models_query",
"(",
"self",
",",
"query",
")",
":",
"registered_models_ct",
"=",
"self",
".",
"build_models_list",
"(",
")",
"if",
"registered_models_ct",
":",
"restrictions",
"=",
"[",
"xapian",
".",
"Query",
"(",
"'%s%s'",
"%",
"(",
"TERM_PREF... | Builds a query from `query` that filters to documents only from registered models. | [
"Builds",
"a",
"query",
"from",
"query",
"that",
"filters",
"to",
"documents",
"only",
"from",
"registered",
"models",
"."
] | python | train | 42.538462 |
T-002/pycast | pycast/common/matrix.py | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L154-L172 | def _initialize_with_array(self, data, rowBased=True):
"""Set the matrix values from a two dimensional list."""
if rowBased:
self.matrix = []
if len(data) != self._rows:
raise ValueError("Size of Matrix does not match")
for col in xrange(self._columns)... | [
"def",
"_initialize_with_array",
"(",
"self",
",",
"data",
",",
"rowBased",
"=",
"True",
")",
":",
"if",
"rowBased",
":",
"self",
".",
"matrix",
"=",
"[",
"]",
"if",
"len",
"(",
"data",
")",
"!=",
"self",
".",
"_rows",
":",
"raise",
"ValueError",
"("... | Set the matrix values from a two dimensional list. | [
"Set",
"the",
"matrix",
"values",
"from",
"a",
"two",
"dimensional",
"list",
"."
] | python | train | 46.842105 |
mitsei/dlkit | dlkit/services/assessment.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/assessment.py#L3643-L3650 | def save_assessment_part(self, assessment_part_form, *args, **kwargs):
"""Pass through to provider AssessmentPartAdminSession.update_assessment_part"""
# Implemented from kitosid template for -
# osid.resource.ResourceAdminSession.update_resource
if assessment_part_form.is_for_update():
... | [
"def",
"save_assessment_part",
"(",
"self",
",",
"assessment_part_form",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Implemented from kitosid template for -",
"# osid.resource.ResourceAdminSession.update_resource",
"if",
"assessment_part_form",
".",
"is_for_update... | Pass through to provider AssessmentPartAdminSession.update_assessment_part | [
"Pass",
"through",
"to",
"provider",
"AssessmentPartAdminSession",
".",
"update_assessment_part"
] | python | train | 62.25 |
enkore/i3pystatus | i3pystatus/sabnzbd.py | https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/sabnzbd.py#L52-L91 | def run(self):
"""Connect to SABnzbd and get the data."""
try:
answer = urlopen(self.url + "&mode=queue").read().decode()
except (HTTPError, URLError) as error:
self.output = {
"full_text": str(error.reason),
"color": "#FF0000"
... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"answer",
"=",
"urlopen",
"(",
"self",
".",
"url",
"+",
"\"&mode=queue\"",
")",
".",
"read",
"(",
")",
".",
"decode",
"(",
")",
"except",
"(",
"HTTPError",
",",
"URLError",
")",
"as",
"error",
":",
... | Connect to SABnzbd and get the data. | [
"Connect",
"to",
"SABnzbd",
"and",
"get",
"the",
"data",
"."
] | python | train | 27.825 |
CEA-COSMIC/ModOpt | modopt/opt/linear.py | https://github.com/CEA-COSMIC/ModOpt/blob/019b189cb897cbb4d210c44a100daaa08468830c/modopt/opt/linear.py#L235-L256 | def _op_method(self, data):
"""Operator
This method returns the input data operated on by all of the operators
Parameters
----------
data : np.ndarray
Input data array
Returns
-------
np.ndarray linear operation results
"""
... | [
"def",
"_op_method",
"(",
"self",
",",
"data",
")",
":",
"res",
"=",
"np",
".",
"empty",
"(",
"len",
"(",
"self",
".",
"operators",
")",
",",
"dtype",
"=",
"np",
".",
"ndarray",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"ope... | Operator
This method returns the input data operated on by all of the operators
Parameters
----------
data : np.ndarray
Input data array
Returns
-------
np.ndarray linear operation results | [
"Operator"
] | python | train | 21.227273 |
apple/turicreate | src/unity/python/turicreate/data_structures/sframe.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sframe.py#L2268-L2278 | def _row_selector(self, other):
"""
Where other is an SArray of identical length as the current Frame,
this returns a selection of a subset of rows in the current SFrame
where the corresponding row in the selector is non-zero.
"""
if type(other) is SArray:
if ... | [
"def",
"_row_selector",
"(",
"self",
",",
"other",
")",
":",
"if",
"type",
"(",
"other",
")",
"is",
"SArray",
":",
"if",
"self",
".",
"__has_size__",
"(",
")",
"and",
"other",
".",
"__has_size__",
"(",
")",
"and",
"len",
"(",
"other",
")",
"!=",
"l... | Where other is an SArray of identical length as the current Frame,
this returns a selection of a subset of rows in the current SFrame
where the corresponding row in the selector is non-zero. | [
"Where",
"other",
"is",
"an",
"SArray",
"of",
"identical",
"length",
"as",
"the",
"current",
"Frame",
"this",
"returns",
"a",
"selection",
"of",
"a",
"subset",
"of",
"rows",
"in",
"the",
"current",
"SFrame",
"where",
"the",
"corresponding",
"row",
"in",
"t... | python | train | 54.727273 |
mitsei/dlkit | dlkit/json_/assessment/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/sessions.py#L749-L788 | def submit_response(self, assessment_section_id, item_id, answer_form):
"""Submits an answer to an item.
arg: assessment_section_id (osid.id.Id): ``Id`` of the
``AssessmentSection``
arg: item_id (osid.id.Id): ``Id`` of the ``Item``
arg: answer_form (osid.assessm... | [
"def",
"submit_response",
"(",
"self",
",",
"assessment_section_id",
",",
"item_id",
",",
"answer_form",
")",
":",
"if",
"not",
"isinstance",
"(",
"answer_form",
",",
"ABCAnswerForm",
")",
":",
"raise",
"errors",
".",
"InvalidArgument",
"(",
"'argument type is not... | Submits an answer to an item.
arg: assessment_section_id (osid.id.Id): ``Id`` of the
``AssessmentSection``
arg: item_id (osid.id.Id): ``Id`` of the ``Item``
arg: answer_form (osid.assessment.AnswerForm): the response
raise: IllegalState - ``has_assessment_secti... | [
"Submits",
"an",
"answer",
"to",
"an",
"item",
"."
] | python | train | 52.55 |
smarie/python-valid8 | valid8/base.py | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L515-L539 | def _none_rejecter(validation_callable # type: Callable
):
# type: (...) -> Callable
"""
Wraps the given validation callable to reject None values. When a None value is received by the wrapper,
it is not passed to the validation_callable and instead this function will raise a Wrappin... | [
"def",
"_none_rejecter",
"(",
"validation_callable",
"# type: Callable",
")",
":",
"# type: (...) -> Callable",
"# option (a) use the `decorate()` helper method to preserve name and signature of the inner object",
"# ==> NO, we want to support also non-function callable objects",
"# option (b) s... | Wraps the given validation callable to reject None values. When a None value is received by the wrapper,
it is not passed to the validation_callable and instead this function will raise a WrappingFailure. When any other value is
received the validation_callable is called as usual.
:param validation_callabl... | [
"Wraps",
"the",
"given",
"validation",
"callable",
"to",
"reject",
"None",
"values",
".",
"When",
"a",
"None",
"value",
"is",
"received",
"by",
"the",
"wrapper",
"it",
"is",
"not",
"passed",
"to",
"the",
"validation_callable",
"and",
"instead",
"this",
"func... | python | train | 41.52 |
niemasd/TreeSwift | treeswift/Node.py | https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L238-L261 | def traverse_bfs(self):
'''Perform a Breadth-First Search (BFS) starting at this ``Node`` object'. Yields (``Node``, distance) tuples
Args:
``include_self`` (``bool``): ``True`` to include self in the traversal, otherwise ``False``
'''
if not isinstance(include_self,... | [
"def",
"traverse_bfs",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"include_self",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"\"include_self must be a bool\"",
")",
"q",
"=",
"deque",
"(",
")",
"dist",
"=",
"dict",
"(",
")",
"dist",
"[... | Perform a Breadth-First Search (BFS) starting at this ``Node`` object'. Yields (``Node``, distance) tuples
Args:
``include_self`` (``bool``): ``True`` to include self in the traversal, otherwise ``False`` | [
"Perform",
"a",
"Breadth",
"-",
"First",
"Search",
"(",
"BFS",
")",
"starting",
"at",
"this",
"Node",
"object",
".",
"Yields",
"(",
"Node",
"distance",
")",
"tuples",
"Args",
":",
"include_self",
"(",
"bool",
")",
":",
"True",
"to",
"include",
"self",
... | python | train | 46.583333 |
saltstack/salt | salt/modules/daemontools.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/daemontools.py#L157-L173 | def status(name, sig=None):
'''
Return the status for a service via daemontools, return pid if running
CLI Example:
.. code-block:: bash
salt '*' daemontools.status <service name>
'''
cmd = 'svstat {0}'.format(_service_path(name))
out = __salt__['cmd.run_stdout'](cmd, python_shell... | [
"def",
"status",
"(",
"name",
",",
"sig",
"=",
"None",
")",
":",
"cmd",
"=",
"'svstat {0}'",
".",
"format",
"(",
"_service_path",
"(",
"name",
")",
")",
"out",
"=",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"cmd",
",",
"python_shell",
"=",
"False"... | Return the status for a service via daemontools, return pid if running
CLI Example:
.. code-block:: bash
salt '*' daemontools.status <service name> | [
"Return",
"the",
"status",
"for",
"a",
"service",
"via",
"daemontools",
"return",
"pid",
"if",
"running"
] | python | train | 25.588235 |
lisael/fastidious | fastidious/parser_base.py | https://github.com/lisael/fastidious/blob/2542db9de779ddabc3a64e9eb19a4e2de99741dc/fastidious/parser_base.py#L163-L173 | def p_startswith(self, st, ignorecase=False):
"Return True if the input starts with `st` at current position"
length = len(st)
matcher = result = self.input[self.pos:self.pos + length]
if ignorecase:
matcher = result.lower()
st = st.lower()
if matcher == s... | [
"def",
"p_startswith",
"(",
"self",
",",
"st",
",",
"ignorecase",
"=",
"False",
")",
":",
"length",
"=",
"len",
"(",
"st",
")",
"matcher",
"=",
"result",
"=",
"self",
".",
"input",
"[",
"self",
".",
"pos",
":",
"self",
".",
"pos",
"+",
"length",
... | Return True if the input starts with `st` at current position | [
"Return",
"True",
"if",
"the",
"input",
"starts",
"with",
"st",
"at",
"current",
"position"
] | python | train | 35.454545 |
aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/__init__.py | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/__init__.py#L32-L44 | def _non_framed_body_length(header, plaintext_length):
"""Calculates the length of a non-framed message body, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:r... | [
"def",
"_non_framed_body_length",
"(",
"header",
",",
"plaintext_length",
")",
":",
"body_length",
"=",
"header",
".",
"algorithm",
".",
"iv_len",
"# IV",
"body_length",
"+=",
"8",
"# Encrypted Content Length",
"body_length",
"+=",
"plaintext_length",
"# Encrypted Conte... | Calculates the length of a non-framed message body, given a complete header.
:param header: Complete message header object
:type header: aws_encryption_sdk.structures.MessageHeader
:param int plaintext_length: Length of plaintext in bytes
:rtype: int | [
"Calculates",
"the",
"length",
"of",
"a",
"non",
"-",
"framed",
"message",
"body",
"given",
"a",
"complete",
"header",
"."
] | python | train | 43.769231 |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/_package.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/_package.py#L550-L592 | def predict(data, training_dir=None, model_name=None, model_version=None, cloud=False):
"""Runs prediction locally or on the cloud.
Args:
data: List of csv strings or a Pandas DataFrame that match the model schema.
training_dir: local path to the trained output folder.
model_name: deployed model name
... | [
"def",
"predict",
"(",
"data",
",",
"training_dir",
"=",
"None",
",",
"model_name",
"=",
"None",
",",
"model_version",
"=",
"None",
",",
"cloud",
"=",
"False",
")",
":",
"if",
"cloud",
":",
"if",
"not",
"model_version",
"or",
"not",
"model_name",
":",
... | Runs prediction locally or on the cloud.
Args:
data: List of csv strings or a Pandas DataFrame that match the model schema.
training_dir: local path to the trained output folder.
model_name: deployed model name
model_version: depoyed model version
cloud: bool. If False, does local prediction and ... | [
"Runs",
"prediction",
"locally",
"or",
"on",
"the",
"cloud",
"."
] | python | train | 40.139535 |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L386-L413 | def load_plugin(plugin_name):
"""
Given a plugin name, load plugin cls from plugin directory.
Will throw an exception if no plugin can be found.
"""
plugin_cls = plugin_map.get(plugin_name, None)
if not plugin_cls:
try:
plugin_module_name, plugin_cls_name = plugin_name.split(... | [
"def",
"load_plugin",
"(",
"plugin_name",
")",
":",
"plugin_cls",
"=",
"plugin_map",
".",
"get",
"(",
"plugin_name",
",",
"None",
")",
"if",
"not",
"plugin_cls",
":",
"try",
":",
"plugin_module_name",
",",
"plugin_cls_name",
"=",
"plugin_name",
".",
"split",
... | Given a plugin name, load plugin cls from plugin directory.
Will throw an exception if no plugin can be found. | [
"Given",
"a",
"plugin",
"name",
"load",
"plugin",
"cls",
"from",
"plugin",
"directory",
".",
"Will",
"throw",
"an",
"exception",
"if",
"no",
"plugin",
"can",
"be",
"found",
"."
] | python | train | 36.642857 |
NyashniyVladya/MarkovTextGenerator | MarkovTextGenerator/markov_text_generator.py | https://github.com/NyashniyVladya/MarkovTextGenerator/blob/3d90e02a507939709773ef01c7ff3ec68b2b8d4b/MarkovTextGenerator/markov_text_generator.py#L185-L211 | def get_start_array(self, *start_words, **kwargs):
"""
Генерирует начало предложения.
:start_words: Попытаться начать предложение с этих слов.
"""
if not self.start_arrays:
raise MarkovTextExcept("Не с чего начинать генерацию.")
if not start_words:
... | [
"def",
"get_start_array",
"(",
"self",
",",
"*",
"start_words",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"start_arrays",
":",
"raise",
"MarkovTextExcept",
"(",
"\"Не с чего начинать генерацию.\")",
"",
"if",
"not",
"start_words",
":",
"retu... | Генерирует начало предложения.
:start_words: Попытаться начать предложение с этих слов. | [
"Генерирует",
"начало",
"предложения",
".",
":",
"start_words",
":",
"Попытаться",
"начать",
"предложение",
"с",
"этих",
"слов",
"."
] | python | valid | 33.666667 |
pymc-devs/pymc | pymc/Model.py | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/Model.py#L221-L246 | def sample(self, iter, length=None, verbose=0):
"""
Draws iter samples from the posterior.
"""
self._cur_trace_index = 0
self.max_trace_length = iter
self._iter = iter
self.verbose = verbose or 0
self.seed()
# Assign Trace instances to tallyable o... | [
"def",
"sample",
"(",
"self",
",",
"iter",
",",
"length",
"=",
"None",
",",
"verbose",
"=",
"0",
")",
":",
"self",
".",
"_cur_trace_index",
"=",
"0",
"self",
".",
"max_trace_length",
"=",
"iter",
"self",
".",
"_iter",
"=",
"iter",
"self",
".",
"verbo... | Draws iter samples from the posterior. | [
"Draws",
"iter",
"samples",
"from",
"the",
"posterior",
"."
] | python | train | 27.692308 |
alimanfoo/vcfnp | vcfnp/array.py | https://github.com/alimanfoo/vcfnp/blob/c3f63fb11ada56d4a88076c61c81f99b8ee78b8f/vcfnp/array.py#L203-L216 | def _filenames_from_arg(filename):
"""Utility function to deal with polymorphic filenames argument."""
if isinstance(filename, string_types):
filenames = [filename]
elif isinstance(filename, (list, tuple)):
filenames = filename
else:
raise Exception('filename argument must be str... | [
"def",
"_filenames_from_arg",
"(",
"filename",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"string_types",
")",
":",
"filenames",
"=",
"[",
"filename",
"]",
"elif",
"isinstance",
"(",
"filename",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"fi... | Utility function to deal with polymorphic filenames argument. | [
"Utility",
"function",
"to",
"deal",
"with",
"polymorphic",
"filenames",
"argument",
"."
] | python | train | 39.357143 |
dmwm/DBS | Server/Python/src/dbs/web/DBSWriterModel.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSWriterModel.py#L73-L98 | def insertPrimaryDataset(self):
"""
API to insert A primary dataset in DBS
:param primaryDSObj: primary dataset object
:type primaryDSObj: dict
:key primary_ds_type: TYPE (out of valid types in DBS, MC, DATA) (Required)
:key primary_ds_name: Name of the primary dataset (... | [
"def",
"insertPrimaryDataset",
"(",
"self",
")",
":",
"try",
":",
"body",
"=",
"request",
".",
"body",
".",
"read",
"(",
")",
"indata",
"=",
"cjson",
".",
"decode",
"(",
"body",
")",
"indata",
"=",
"validateJSONInputNoCopy",
"(",
"\"primds\"",
",",
"inda... | API to insert A primary dataset in DBS
:param primaryDSObj: primary dataset object
:type primaryDSObj: dict
:key primary_ds_type: TYPE (out of valid types in DBS, MC, DATA) (Required)
:key primary_ds_name: Name of the primary dataset (Required) | [
"API",
"to",
"insert",
"A",
"primary",
"dataset",
"in",
"DBS"
] | python | train | 51.076923 |
PySimpleGUI/PySimpleGUI | PySimpleGUIWeb/Demo Programs/widgets_overview_app.py | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/PySimpleGUIWeb/Demo Programs/widgets_overview_app.py#L281-L285 | def list_view_on_selected(self, widget, selected_item_key):
""" The selection event of the listView, returns a key of the clicked event.
You can retrieve the item rapidly
"""
self.lbl.set_text('List selection: ' + self.listView.children[selected_item_key].get_text()) | [
"def",
"list_view_on_selected",
"(",
"self",
",",
"widget",
",",
"selected_item_key",
")",
":",
"self",
".",
"lbl",
".",
"set_text",
"(",
"'List selection: '",
"+",
"self",
".",
"listView",
".",
"children",
"[",
"selected_item_key",
"]",
".",
"get_text",
"(",
... | The selection event of the listView, returns a key of the clicked event.
You can retrieve the item rapidly | [
"The",
"selection",
"event",
"of",
"the",
"listView",
"returns",
"a",
"key",
"of",
"the",
"clicked",
"event",
".",
"You",
"can",
"retrieve",
"the",
"item",
"rapidly"
] | python | train | 59.8 |
dlecocq/nsq-py | nsq/backoff.py | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/backoff.py#L83-L88 | def ready(self):
'''Whether or not enough time has passed since the last failure'''
if self._last_failed:
delta = time.time() - self._last_failed
return delta >= self.backoff()
return True | [
"def",
"ready",
"(",
"self",
")",
":",
"if",
"self",
".",
"_last_failed",
":",
"delta",
"=",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_last_failed",
"return",
"delta",
">=",
"self",
".",
"backoff",
"(",
")",
"return",
"True"
] | Whether or not enough time has passed since the last failure | [
"Whether",
"or",
"not",
"enough",
"time",
"has",
"passed",
"since",
"the",
"last",
"failure"
] | python | train | 38.5 |
hozn/stravalib | stravalib/client.py | https://github.com/hozn/stravalib/blob/5500ebc39e0bf4706bb1ca4c27b25e56becaaa5f/stravalib/client.py#L1479-L1522 | def create_subscription(self, client_id, client_secret, callback_url,
object_type=model.Subscription.OBJECT_TYPE_ACTIVITY,
aspect_type=model.Subscription.ASPECT_TYPE_CREATE,
verify_token=model.Subscription.VERIFY_TOKEN_DEFAULT):
... | [
"def",
"create_subscription",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"callback_url",
",",
"object_type",
"=",
"model",
".",
"Subscription",
".",
"OBJECT_TYPE_ACTIVITY",
",",
"aspect_type",
"=",
"model",
".",
"Subscription",
".",
"ASPECT_TYPE_CREAT... | Creates a webhook event subscription.
http://strava.github.io/api/partner/v3/events/#create-a-subscription
:param client_id: application's ID, obtained during registration
:type client_id: int
:param client_secret: application's secret, obtained during registration
:type clien... | [
"Creates",
"a",
"webhook",
"event",
"subscription",
"."
] | python | train | 47.272727 |
mrooney/mintapi | mintapi/api.py | https://github.com/mrooney/mintapi/blob/44fddbeac79a68da657ad8118e02fcde968f8dfe/mintapi/api.py#L662-L672 | def get_transactions(self, include_investment=False):
"""Returns the transaction data as a Pandas DataFrame."""
assert_pd()
s = StringIO(self.get_transactions_csv(
include_investment=include_investment))
s.seek(0)
df = pd.read_csv(s, parse_dates=['Date'])
df.c... | [
"def",
"get_transactions",
"(",
"self",
",",
"include_investment",
"=",
"False",
")",
":",
"assert_pd",
"(",
")",
"s",
"=",
"StringIO",
"(",
"self",
".",
"get_transactions_csv",
"(",
"include_investment",
"=",
"include_investment",
")",
")",
"s",
".",
"seek",
... | Returns the transaction data as a Pandas DataFrame. | [
"Returns",
"the",
"transaction",
"data",
"as",
"a",
"Pandas",
"DataFrame",
"."
] | python | train | 44.909091 |
farzadghanei/distutilazy | distutilazy/clean.py | https://github.com/farzadghanei/distutilazy/blob/c3c7d062f7cb79abb7677cac57dd752127ff78e7/distutilazy/clean.py#L228-L237 | def clean_extra(self):
"""Clean extra files/directories specified by get_extra_paths()"""
extra_paths = self.get_extra_paths()
for path in extra_paths:
if not os.path.exists(path):
continue
if os.path.isdir(path):
self._clean_directory(path... | [
"def",
"clean_extra",
"(",
"self",
")",
":",
"extra_paths",
"=",
"self",
".",
"get_extra_paths",
"(",
")",
"for",
"path",
"in",
"extra_paths",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"continue",
"if",
"os",
".",
"pa... | Clean extra files/directories specified by get_extra_paths() | [
"Clean",
"extra",
"files",
"/",
"directories",
"specified",
"by",
"get_extra_paths",
"()"
] | python | train | 36.9 |
bcbio/bcbio-nextgen | bcbio/bam/counts.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/counts.py#L41-L45 | def coverage_pileup(self, space, start, end):
"""Retrieve pileup coverage across a specified region.
"""
return ((col.pos, self._normalize(col.n, self._total))
for col in self._bam.pileup(space, start, end)) | [
"def",
"coverage_pileup",
"(",
"self",
",",
"space",
",",
"start",
",",
"end",
")",
":",
"return",
"(",
"(",
"col",
".",
"pos",
",",
"self",
".",
"_normalize",
"(",
"col",
".",
"n",
",",
"self",
".",
"_total",
")",
")",
"for",
"col",
"in",
"self"... | Retrieve pileup coverage across a specified region. | [
"Retrieve",
"pileup",
"coverage",
"across",
"a",
"specified",
"region",
"."
] | python | train | 48.6 |
lrq3000/pyFileFixity | pyFileFixity/lib/aux_funcs.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/aux_funcs.py#L27-L33 | def is_dir(dirname):
'''Checks if a path is an actual directory that exists'''
if not os.path.isdir(dirname):
msg = "{0} is not a directory".format(dirname)
raise argparse.ArgumentTypeError(msg)
else:
return dirname | [
"def",
"is_dir",
"(",
"dirname",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"dirname",
")",
":",
"msg",
"=",
"\"{0} is not a directory\"",
".",
"format",
"(",
"dirname",
")",
"raise",
"argparse",
".",
"ArgumentTypeError",
"(",
"msg",
")... | Checks if a path is an actual directory that exists | [
"Checks",
"if",
"a",
"path",
"is",
"an",
"actual",
"directory",
"that",
"exists"
] | python | train | 35 |
adamcharnock/swiftwind | swiftwind/costs/models.py | https://github.com/adamcharnock/swiftwind/blob/72c715800841c3b2feabded3f3b65b76388b4cea/swiftwind/costs/models.py#L152-L160 | def get_amount_arrears_transactions(self, billing_cycle):
"""Get the sum of all transaction legs in to_account during given billing cycle"""
previous_billing_cycle = billing_cycle.get_previous()
if not previous_billing_cycle:
return Decimal(0)
return self.to_account.balance(
... | [
"def",
"get_amount_arrears_transactions",
"(",
"self",
",",
"billing_cycle",
")",
":",
"previous_billing_cycle",
"=",
"billing_cycle",
".",
"get_previous",
"(",
")",
"if",
"not",
"previous_billing_cycle",
":",
"return",
"Decimal",
"(",
"0",
")",
"return",
"self",
... | Get the sum of all transaction legs in to_account during given billing cycle | [
"Get",
"the",
"sum",
"of",
"all",
"transaction",
"legs",
"in",
"to_account",
"during",
"given",
"billing",
"cycle"
] | python | train | 52.444444 |
genialis/resolwe | resolwe/flow/serializers/fields.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/fields.py#L38-L57 | def to_internal_value(self, data):
"""Convert to internal value."""
user = getattr(self.context.get('request'), 'user')
queryset = self.get_queryset()
permission = get_full_perm('view', queryset.model)
try:
return get_objects_for_user(
user,
... | [
"def",
"to_internal_value",
"(",
"self",
",",
"data",
")",
":",
"user",
"=",
"getattr",
"(",
"self",
".",
"context",
".",
"get",
"(",
"'request'",
")",
",",
"'user'",
")",
"queryset",
"=",
"self",
".",
"get_queryset",
"(",
")",
"permission",
"=",
"get_... | Convert to internal value. | [
"Convert",
"to",
"internal",
"value",
"."
] | python | train | 37.95 |
mozilla/DeepSpeech | bin/benchmark_nc.py | https://github.com/mozilla/DeepSpeech/blob/f64aa73e7fbe9dde40d4fcf23b42ab304747d152/bin/benchmark_nc.py#L41-L61 | def exec_command(command, cwd=None):
r'''
Helper to exec locally (subprocess) or remotely (paramiko)
'''
rc = None
stdout = stderr = None
if ssh_conn is None:
ld_library_path = {'LD_LIBRARY_PATH': '.:%s' % os.environ.get('LD_LIBRARY_PATH', '')}
p = subprocess.Popen(command, stdo... | [
"def",
"exec_command",
"(",
"command",
",",
"cwd",
"=",
"None",
")",
":",
"rc",
"=",
"None",
"stdout",
"=",
"stderr",
"=",
"None",
"if",
"ssh_conn",
"is",
"None",
":",
"ld_library_path",
"=",
"{",
"'LD_LIBRARY_PATH'",
":",
"'.:%s'",
"%",
"os",
".",
"en... | r'''
Helper to exec locally (subprocess) or remotely (paramiko) | [
"r",
"Helper",
"to",
"exec",
"locally",
"(",
"subprocess",
")",
"or",
"remotely",
"(",
"paramiko",
")"
] | python | train | 43.52381 |
apache/airflow | airflow/contrib/hooks/aws_sns_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/aws_sns_hook.py#L40-L60 | def publish_to_target(self, target_arn, message):
"""
Publish a message to a topic or an endpoint.
:param target_arn: either a TopicArn or an EndpointArn
:type target_arn: str
:param message: the default message you want to send
:param message: str
"""
c... | [
"def",
"publish_to_target",
"(",
"self",
",",
"target_arn",
",",
"message",
")",
":",
"conn",
"=",
"self",
".",
"get_conn",
"(",
")",
"messages",
"=",
"{",
"'default'",
":",
"message",
"}",
"return",
"conn",
".",
"publish",
"(",
"TargetArn",
"=",
"target... | Publish a message to a topic or an endpoint.
:param target_arn: either a TopicArn or an EndpointArn
:type target_arn: str
:param message: the default message you want to send
:param message: str | [
"Publish",
"a",
"message",
"to",
"a",
"topic",
"or",
"an",
"endpoint",
"."
] | python | test | 25.52381 |
brutasse/graphite-api | graphite_api/_vendor/whisper.py | https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/_vendor/whisper.py#L535-L549 | def update(path,value,timestamp=None):
"""update(path,value,timestamp=None)
path is a string
value is a float
timestamp is either an int or float
"""
value = float(value)
fh = None
try:
fh = open(path,'r+b')
return file_update(fh, value, timestamp)
finally:
if fh:
fh.close() | [
"def",
"update",
"(",
"path",
",",
"value",
",",
"timestamp",
"=",
"None",
")",
":",
"value",
"=",
"float",
"(",
"value",
")",
"fh",
"=",
"None",
"try",
":",
"fh",
"=",
"open",
"(",
"path",
",",
"'r+b'",
")",
"return",
"file_update",
"(",
"fh",
"... | update(path,value,timestamp=None)
path is a string
value is a float
timestamp is either an int or float | [
"update",
"(",
"path",
"value",
"timestamp",
"=",
"None",
")"
] | python | train | 19.333333 |
laginha/django-mobileesp | src/django_mobileesp/mdetect.py | https://github.com/laginha/django-mobileesp/blob/91d4babb2343b992970bdb076508d380680c8b7e/src/django_mobileesp/mdetect.py#L310-L320 | def detectAndroid(self):
"""Return detection of an Android device
Detects *any* Android OS-based device: phone, tablet, and multi-media player.
Also detects Google TV.
"""
if UAgentInfo.deviceAndroid in self.__userAgent \
or self.detectGoogleTV():
return T... | [
"def",
"detectAndroid",
"(",
"self",
")",
":",
"if",
"UAgentInfo",
".",
"deviceAndroid",
"in",
"self",
".",
"__userAgent",
"or",
"self",
".",
"detectGoogleTV",
"(",
")",
":",
"return",
"True",
"return",
"False"
] | Return detection of an Android device
Detects *any* Android OS-based device: phone, tablet, and multi-media player.
Also detects Google TV. | [
"Return",
"detection",
"of",
"an",
"Android",
"device"
] | python | train | 30.454545 |
r4fek/django-cassandra-engine | django_cassandra_engine/models/__init__.py | https://github.com/r4fek/django-cassandra-engine/blob/b43f8fddd4bba143f03f73f8bbfc09e6b32c699b/django_cassandra_engine/models/__init__.py#L80-L84 | def add_field(self, field, **kwargs):
"""Add each field as a private field."""
getattr(self, self._private_fields_name).append(field)
self._expire_cache(reverse=True)
self._expire_cache(reverse=False) | [
"def",
"add_field",
"(",
"self",
",",
"field",
",",
"*",
"*",
"kwargs",
")",
":",
"getattr",
"(",
"self",
",",
"self",
".",
"_private_fields_name",
")",
".",
"append",
"(",
"field",
")",
"self",
".",
"_expire_cache",
"(",
"reverse",
"=",
"True",
")",
... | Add each field as a private field. | [
"Add",
"each",
"field",
"as",
"a",
"private",
"field",
"."
] | python | train | 45.6 |
FNNDSC/chrisapp | chrisapp/base.py | https://github.com/FNNDSC/chrisapp/blob/b176655f97206240fe173dfe86736f82f0d85bc4/chrisapp/base.py#L292-L306 | def launch(self, args=None):
"""
This method triggers the parsing of arguments.
"""
self.options = self.parse_args(args)
if self.options.saveinputmeta:
# save original input options
self.save_input_meta()
if self.options.inputmeta:
# re... | [
"def",
"launch",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"self",
".",
"options",
"=",
"self",
".",
"parse_args",
"(",
"args",
")",
"if",
"self",
".",
"options",
".",
"saveinputmeta",
":",
"# save original input options",
"self",
".",
"save_input_m... | This method triggers the parsing of arguments. | [
"This",
"method",
"triggers",
"the",
"parsing",
"of",
"arguments",
"."
] | python | train | 40.066667 |
RJT1990/pyflux | pyflux/gas/gasrank.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gas/gasrank.py#L89-L95 | def _create_ids(self, home_teams, away_teams):
"""
Creates IDs for both players/teams
"""
categories = pd.Categorical(np.append(home_teams,away_teams))
home_id, away_id = categories.codes[0:int(len(categories)/2)], categories.codes[int(len(categories)/2):len(categories)+1]
... | [
"def",
"_create_ids",
"(",
"self",
",",
"home_teams",
",",
"away_teams",
")",
":",
"categories",
"=",
"pd",
".",
"Categorical",
"(",
"np",
".",
"append",
"(",
"home_teams",
",",
"away_teams",
")",
")",
"home_id",
",",
"away_id",
"=",
"categories",
".",
"... | Creates IDs for both players/teams | [
"Creates",
"IDs",
"for",
"both",
"players",
"/",
"teams"
] | python | train | 48.428571 |
koalalorenzo/python-digitalocean | digitalocean/Manager.py | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Manager.py#L229-L239 | def get_all_floating_ips(self):
"""
This function returns a list of FloatingIP objects.
"""
data = self.get_data("floating_ips")
floating_ips = list()
for jsoned in data['floating_ips']:
floating_ip = FloatingIP(**jsoned)
floating_ip.token = se... | [
"def",
"get_all_floating_ips",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"get_data",
"(",
"\"floating_ips\"",
")",
"floating_ips",
"=",
"list",
"(",
")",
"for",
"jsoned",
"in",
"data",
"[",
"'floating_ips'",
"]",
":",
"floating_ip",
"=",
"FloatingIP",... | This function returns a list of FloatingIP objects. | [
"This",
"function",
"returns",
"a",
"list",
"of",
"FloatingIP",
"objects",
"."
] | python | valid | 35.545455 |
Parsl/parsl | parsl/providers/aws/aws.py | https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/providers/aws/aws.py#L222-L275 | def create_session(self):
"""Create a session.
First we look in self.key_file for a path to a json file with the
credentials. The key file should have 'AWSAccessKeyId' and 'AWSSecretKey'.
Next we look at self.profile for a profile name and try
to use the Session call to automat... | [
"def",
"create_session",
"(",
"self",
")",
":",
"session",
"=",
"None",
"if",
"self",
".",
"key_file",
"is",
"not",
"None",
":",
"credfile",
"=",
"os",
".",
"path",
".",
"expandvars",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"self",
".",
"key_... | Create a session.
First we look in self.key_file for a path to a json file with the
credentials. The key file should have 'AWSAccessKeyId' and 'AWSSecretKey'.
Next we look at self.profile for a profile name and try
to use the Session call to automatically pick up the keys for the profi... | [
"Create",
"a",
"session",
"."
] | python | valid | 43.407407 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_port_profile_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_port_profile_ext.py#L277-L295 | def get_port_profile_status_output_port_profile_mac_association_applied_interface_interface_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_port_profile_status = ET.Element("get_port_profile_status")
config = get_port_profile_status
outp... | [
"def",
"get_port_profile_status_output_port_profile_mac_association_applied_interface_interface_type",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_port_profile_status",
"=",
"ET",
".",
"Element",
"(",... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 52.105263 |
knipknap/SpiffWorkflow | SpiffWorkflow/specs/ThreadSplit.py | https://github.com/knipknap/SpiffWorkflow/blob/f0af7f59a332e0619e4f3c00a7d4a3d230760e00/SpiffWorkflow/specs/ThreadSplit.py#L70-L78 | def connect(self, task_spec):
"""
Connect the *following* task to this one. In other words, the
given task is added as an output task.
task -- the task to connect to.
"""
self.thread_starter.outputs.append(task_spec)
task_spec._connect_notify(self.thread_starter) | [
"def",
"connect",
"(",
"self",
",",
"task_spec",
")",
":",
"self",
".",
"thread_starter",
".",
"outputs",
".",
"append",
"(",
"task_spec",
")",
"task_spec",
".",
"_connect_notify",
"(",
"self",
".",
"thread_starter",
")"
] | Connect the *following* task to this one. In other words, the
given task is added as an output task.
task -- the task to connect to. | [
"Connect",
"the",
"*",
"following",
"*",
"task",
"to",
"this",
"one",
".",
"In",
"other",
"words",
"the",
"given",
"task",
"is",
"added",
"as",
"an",
"output",
"task",
"."
] | python | valid | 34.666667 |
python-gitlab/python-gitlab | gitlab/mixins.py | https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/mixins.py#L508-L521 | def time_estimate(self, duration, **kwargs):
"""Set an estimated time of work for the object.
Args:
duration (str): Duration in human format (e.g. 3h30)
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentic... | [
"def",
"time_estimate",
"(",
"self",
",",
"duration",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"'%s/%s/time_estimate'",
"%",
"(",
"self",
".",
"manager",
".",
"path",
",",
"self",
".",
"get_id",
"(",
")",
")",
"data",
"=",
"{",
"'duration'",
"... | Set an estimated time of work for the object.
Args:
duration (str): Duration in human format (e.g. 3h30)
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabTimeTrackingError... | [
"Set",
"an",
"estimated",
"time",
"of",
"work",
"for",
"the",
"object",
"."
] | python | train | 43.428571 |
aws/sagemaker-python-sdk | src/sagemaker/chainer/estimator.py | https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/chainer/estimator.py#L113-L137 | def create_model(self, model_server_workers=None, role=None, vpc_config_override=VPC_CONFIG_DEFAULT):
"""Create a SageMaker ``ChainerModel`` object that can be deployed to an ``Endpoint``.
Args:
role (str): The ``ExecutionRoleArn`` IAM Role ARN for the ``Model``, which is also used during
... | [
"def",
"create_model",
"(",
"self",
",",
"model_server_workers",
"=",
"None",
",",
"role",
"=",
"None",
",",
"vpc_config_override",
"=",
"VPC_CONFIG_DEFAULT",
")",
":",
"role",
"=",
"role",
"or",
"self",
".",
"role",
"return",
"ChainerModel",
"(",
"self",
".... | Create a SageMaker ``ChainerModel`` object that can be deployed to an ``Endpoint``.
Args:
role (str): The ``ExecutionRoleArn`` IAM Role ARN for the ``Model``, which is also used during
transform jobs. If not specified, the role from the Estimator will be used.
model_serv... | [
"Create",
"a",
"SageMaker",
"ChainerModel",
"object",
"that",
"can",
"be",
"deployed",
"to",
"an",
"Endpoint",
"."
] | python | train | 72.8 |
argaen/aiocache | aiocache/base.py | https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/base.py#L440-L459 | async def raw(self, command, *args, _conn=None, **kwargs):
"""
Send the raw command to the underlying client. Note that by using this CMD you
will lose compatibility with other backends.
Due to limitations with aiomcache client, args have to be provided as bytes.
For rest of bac... | [
"async",
"def",
"raw",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"_conn",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"time",
".",
"monotonic",
"(",
")",
"ret",
"=",
"await",
"self",
".",
"_raw",
"(",
"command",
",",
... | Send the raw command to the underlying client. Note that by using this CMD you
will lose compatibility with other backends.
Due to limitations with aiomcache client, args have to be provided as bytes.
For rest of backends, str.
:param command: str with the command.
:param timeo... | [
"Send",
"the",
"raw",
"command",
"to",
"the",
"underlying",
"client",
".",
"Note",
"that",
"by",
"using",
"this",
"CMD",
"you",
"will",
"lose",
"compatibility",
"with",
"other",
"backends",
"."
] | python | train | 43.6 |
FocusLab/Albertson | albertson/base.py | https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L55-L63 | def get_conn(self, aws_access_key=None, aws_secret_key=None):
'''
Hook point for overriding how the CounterPool gets its connection to
AWS.
'''
return boto.connect_dynamodb(
aws_access_key_id=aws_access_key,
aws_secret_access_key=aws_secret_key,
) | [
"def",
"get_conn",
"(",
"self",
",",
"aws_access_key",
"=",
"None",
",",
"aws_secret_key",
"=",
"None",
")",
":",
"return",
"boto",
".",
"connect_dynamodb",
"(",
"aws_access_key_id",
"=",
"aws_access_key",
",",
"aws_secret_access_key",
"=",
"aws_secret_key",
",",
... | Hook point for overriding how the CounterPool gets its connection to
AWS. | [
"Hook",
"point",
"for",
"overriding",
"how",
"the",
"CounterPool",
"gets",
"its",
"connection",
"to",
"AWS",
"."
] | python | valid | 34.555556 |
pgmpy/pgmpy | pgmpy/estimators/ConstraintBasedEstimator.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/ConstraintBasedEstimator.py#L444-L534 | def build_skeleton(nodes, independencies):
"""Estimates a graph skeleton (UndirectedGraph) from a set of independencies
using (the first part of) the PC algorithm. The independencies can either be
provided as an instance of the `Independencies`-class or by passing a
decision function tha... | [
"def",
"build_skeleton",
"(",
"nodes",
",",
"independencies",
")",
":",
"nodes",
"=",
"list",
"(",
"nodes",
")",
"if",
"isinstance",
"(",
"independencies",
",",
"Independencies",
")",
":",
"def",
"is_independent",
"(",
"X",
",",
"Y",
",",
"Zs",
")",
":",... | Estimates a graph skeleton (UndirectedGraph) from a set of independencies
using (the first part of) the PC algorithm. The independencies can either be
provided as an instance of the `Independencies`-class or by passing a
decision function that decides any conditional independency assertion.
... | [
"Estimates",
"a",
"graph",
"skeleton",
"(",
"UndirectedGraph",
")",
"from",
"a",
"set",
"of",
"independencies",
"using",
"(",
"the",
"first",
"part",
"of",
")",
"the",
"PC",
"algorithm",
".",
"The",
"independencies",
"can",
"either",
"be",
"provided",
"as",
... | python | train | 49.505495 |
gmr/tinman | tinman/application.py | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/application.py#L102-L114 | def _import_module(self, module_path):
"""Dynamically import a module returning a handle to it.
:param str module_path: The module path
:rtype: module
"""
LOGGER.debug('Importing %s', module_path)
try:
return __import__(module_path)
except ImportErro... | [
"def",
"_import_module",
"(",
"self",
",",
"module_path",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'Importing %s'",
",",
"module_path",
")",
"try",
":",
"return",
"__import__",
"(",
"module_path",
")",
"except",
"ImportError",
"as",
"error",
":",
"LOGGER",
".... | Dynamically import a module returning a handle to it.
:param str module_path: The module path
:rtype: module | [
"Dynamically",
"import",
"a",
"module",
"returning",
"a",
"handle",
"to",
"it",
"."
] | python | train | 32.153846 |
hobson/aima | aima/logic.py | https://github.com/hobson/aima/blob/3572b2fb92039b4a1abe384be8545560fbd3d470/aima/logic.py#L547-L561 | def pl_resolution(KB, alpha):
"Propositional-logic resolution: say if alpha follows from KB. [Fig. 7.12]"
clauses = KB.clauses + conjuncts(to_cnf(~alpha))
new = set()
while True:
n = len(clauses)
pairs = [(clauses[i], clauses[j])
for i in range(n) for j in range(i+1, n)]... | [
"def",
"pl_resolution",
"(",
"KB",
",",
"alpha",
")",
":",
"clauses",
"=",
"KB",
".",
"clauses",
"+",
"conjuncts",
"(",
"to_cnf",
"(",
"~",
"alpha",
")",
")",
"new",
"=",
"set",
"(",
")",
"while",
"True",
":",
"n",
"=",
"len",
"(",
"clauses",
")"... | Propositional-logic resolution: say if alpha follows from KB. [Fig. 7.12] | [
"Propositional",
"-",
"logic",
"resolution",
":",
"say",
"if",
"alpha",
"follows",
"from",
"KB",
".",
"[",
"Fig",
".",
"7",
".",
"12",
"]"
] | python | valid | 39.933333 |
incf-nidash/nidmresults | nidmresults/graph.py | https://github.com/incf-nidash/nidmresults/blob/438f7cce6abc4a4379b629bd76f4d427891e033f/nidmresults/graph.py#L358-L376 | def _get_model_fitting(self, con_est_id):
"""
Retreive model fitting that corresponds to contrast with identifier
'con_id'
from the list of model fitting objects stored in self.model_fittings
"""
for (mpe_id, pe_ids), contrasts in self.contrasts.items():
for c... | [
"def",
"_get_model_fitting",
"(",
"self",
",",
"con_est_id",
")",
":",
"for",
"(",
"mpe_id",
",",
"pe_ids",
")",
",",
"contrasts",
"in",
"self",
".",
"contrasts",
".",
"items",
"(",
")",
":",
"for",
"contrast",
"in",
"contrasts",
":",
"if",
"contrast",
... | Retreive model fitting that corresponds to contrast with identifier
'con_id'
from the list of model fitting objects stored in self.model_fittings | [
"Retreive",
"model",
"fitting",
"that",
"corresponds",
"to",
"contrast",
"with",
"identifier",
"con_id",
"from",
"the",
"list",
"of",
"model",
"fitting",
"objects",
"stored",
"in",
"self",
".",
"model_fittings"
] | python | train | 40.578947 |
gem/oq-engine | openquake/commonlib/source.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L394-L417 | def new(self, sources_by_grp):
"""
Generate a new CompositeSourceModel from the given dictionary.
:param sources_by_group: a dictionary grp_id -> sources
:returns: a new CompositeSourceModel instance
"""
source_models = []
for sm in self.source_models:
... | [
"def",
"new",
"(",
"self",
",",
"sources_by_grp",
")",
":",
"source_models",
"=",
"[",
"]",
"for",
"sm",
"in",
"self",
".",
"source_models",
":",
"src_groups",
"=",
"[",
"]",
"for",
"src_group",
"in",
"sm",
".",
"src_groups",
":",
"sg",
"=",
"copy",
... | Generate a new CompositeSourceModel from the given dictionary.
:param sources_by_group: a dictionary grp_id -> sources
:returns: a new CompositeSourceModel instance | [
"Generate",
"a",
"new",
"CompositeSourceModel",
"from",
"the",
"given",
"dictionary",
"."
] | python | train | 43.041667 |
tensorflow/cleverhans | examples/nips17_adversarial_competition/dev_toolkit/run_attacks_and_defenses.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/nips17_adversarial_competition/dev_toolkit/run_attacks_and_defenses.py#L16-L44 | def parse_args():
"""Parses command line arguments."""
parser = argparse.ArgumentParser(
description='Tool to run attacks and defenses.')
parser.add_argument('--attacks_dir', required=True,
help='Location of all attacks.')
parser.add_argument('--targeted_attacks_dir', required=True,
... | [
"def",
"parse_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Tool to run attacks and defenses.'",
")",
"parser",
".",
"add_argument",
"(",
"'--attacks_dir'",
",",
"required",
"=",
"True",
",",
"help",
"=",
"'Lo... | Parses command line arguments. | [
"Parses",
"command",
"line",
"arguments",
"."
] | python | train | 55.310345 |
astropy/astropy-helpers | astropy_helpers/setup_helpers.py | https://github.com/astropy/astropy-helpers/blob/f5a27d3f84a98ea0eebb85e0cf3e7214c6bc0d09/astropy_helpers/setup_helpers.py#L484-L505 | def iter_setup_packages(srcdir, packages):
""" A generator that finds and imports all of the ``setup_package.py``
modules in the source packages.
Returns
-------
modgen : generator
A generator that yields (modname, mod), where `mod` is the module and
`modname` is the module name for... | [
"def",
"iter_setup_packages",
"(",
"srcdir",
",",
"packages",
")",
":",
"for",
"packagename",
"in",
"packages",
":",
"package_parts",
"=",
"packagename",
".",
"split",
"(",
"'.'",
")",
"package_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"srcdir",
","... | A generator that finds and imports all of the ``setup_package.py``
modules in the source packages.
Returns
-------
modgen : generator
A generator that yields (modname, mod), where `mod` is the module and
`modname` is the module name for the ``setup_package.py`` modules. | [
"A",
"generator",
"that",
"finds",
"and",
"imports",
"all",
"of",
"the",
"setup_package",
".",
"py",
"modules",
"in",
"the",
"source",
"packages",
"."
] | python | train | 35 |
blockstack-packages/blockstack-gpg | blockstack_gpg/gpg.py | https://github.com/blockstack-packages/blockstack-gpg/blob/e4d51e4e51678d9b946596ca9dec53e2d78c8710/blockstack_gpg/gpg.py#L206-L232 | def gpg_download_key( key_id, key_server, config_dir=None ):
"""
Download a GPG key from a key server.
Do not import it into any keyrings.
Return the ASCII-armored key
"""
config_dir = get_config_dir( config_dir )
tmpdir = make_gpg_tmphome( prefix="download", config_dir=config_dir )
gpg... | [
"def",
"gpg_download_key",
"(",
"key_id",
",",
"key_server",
",",
"config_dir",
"=",
"None",
")",
":",
"config_dir",
"=",
"get_config_dir",
"(",
"config_dir",
")",
"tmpdir",
"=",
"make_gpg_tmphome",
"(",
"prefix",
"=",
"\"download\"",
",",
"config_dir",
"=",
"... | Download a GPG key from a key server.
Do not import it into any keyrings.
Return the ASCII-armored key | [
"Download",
"a",
"GPG",
"key",
"from",
"a",
"key",
"server",
".",
"Do",
"not",
"import",
"it",
"into",
"any",
"keyrings",
".",
"Return",
"the",
"ASCII",
"-",
"armored",
"key"
] | python | train | 30.333333 |
kejbaly2/metrique | metrique/reporting.py | https://github.com/kejbaly2/metrique/blob/a10b076097441b7dde687949139f702f5c1e1b35/metrique/reporting.py#L87-L99 | def add_image(self, figure, dpi=72):
'''
Adds an image to the last chapter/section.
The image will be stored in the `{self.title}_files` directory.
:param matplotlib.figure figure:
A matplotlib figure to be saved into the report
'''
name = os.path.join(self._... | [
"def",
"add_image",
"(",
"self",
",",
"figure",
",",
"dpi",
"=",
"72",
")",
":",
"name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_dir",
",",
"'/fig%s.png'",
"%",
"self",
".",
"fig_counter",
")",
"self",
".",
"fig_counter",
"+=",
"1"... | Adds an image to the last chapter/section.
The image will be stored in the `{self.title}_files` directory.
:param matplotlib.figure figure:
A matplotlib figure to be saved into the report | [
"Adds",
"an",
"image",
"to",
"the",
"last",
"chapter",
"/",
"section",
".",
"The",
"image",
"will",
"be",
"stored",
"in",
"the",
"{",
"self",
".",
"title",
"}",
"_files",
"directory",
"."
] | python | train | 37.538462 |
ptmcg/littletable | littletable.py | https://github.com/ptmcg/littletable/blob/8352f7716e458e55a6997372dadf92e179d19f98/littletable.py#L1535-L1556 | def dump(self, out=sys.stdout, row_fn=repr, limit=-1, indent=0):
"""Dump out the contents of this table in a nested listing.
@param out: output stream to write to
@param row_fn: function to call to display individual rows
@param limit: number of records to show at deepest level ... | [
"def",
"dump",
"(",
"self",
",",
"out",
"=",
"sys",
".",
"stdout",
",",
"row_fn",
"=",
"repr",
",",
"limit",
"=",
"-",
"1",
",",
"indent",
"=",
"0",
")",
":",
"NL",
"=",
"'\\n'",
"if",
"indent",
":",
"out",
".",
"write",
"(",
"\" \"",
"*",
"... | Dump out the contents of this table in a nested listing.
@param out: output stream to write to
@param row_fn: function to call to display individual rows
@param limit: number of records to show at deepest level of pivot (-1=show all)
@param indent: current nesting level | [
"Dump",
"out",
"the",
"contents",
"of",
"this",
"table",
"in",
"a",
"nested",
"listing",
"."
] | python | train | 43.818182 |
saltstack/salt | salt/modules/xbpspkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xbpspkg.py#L433-L484 | def remove(name=None, pkgs=None, recursive=True, **kwargs):
'''
name
The name of the package to be deleted.
recursive
Also remove dependent packages (not required elsewhere).
Default mode: enabled.
Multiple Package Options:
pkgs
A list of packages to delete. Must b... | [
"def",
"remove",
"(",
"name",
"=",
"None",
",",
"pkgs",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"pkg_params",
",",
"pkg_type",
"=",
"__salt__",
"[",
"'pkg_resource.parse_targets'",
"]",
"(",
"name",
",... | name
The name of the package to be deleted.
recursive
Also remove dependent packages (not required elsewhere).
Default mode: enabled.
Multiple Package Options:
pkgs
A list of packages to delete. Must be passed as a python list. The
``name`` parameter will be ignore... | [
"name",
"The",
"name",
"of",
"the",
"package",
"to",
"be",
"deleted",
"."
] | python | train | 25.538462 |
BD2KGenomics/protect | src/protect/mutation_calling/fusion.py | https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/fusion.py#L287-L352 | def split_fusion_transcript(annotation_path, transcripts):
"""
Finds the breakpoint in the fusion transcript and splits the 5' donor from the 3' acceptor
:param str annotation_path: Path to transcript annotation file
:param dict transcripts: Dictionary of fusion transcripts
:return: 5' donor sequen... | [
"def",
"split_fusion_transcript",
"(",
"annotation_path",
",",
"transcripts",
")",
":",
"annotation",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"forward",
"=",
"'ACGTN'",
"reverse",
"=",
"'TGCAN'",
"trans",
"=",
"string",
".",
"maketrans",
"(",
... | Finds the breakpoint in the fusion transcript and splits the 5' donor from the 3' acceptor
:param str annotation_path: Path to transcript annotation file
:param dict transcripts: Dictionary of fusion transcripts
:return: 5' donor sequences and 3' acceptor sequences
:rtype: tuple | [
"Finds",
"the",
"breakpoint",
"in",
"the",
"fusion",
"transcript",
"and",
"splits",
"the",
"5",
"donor",
"from",
"the",
"3",
"acceptor"
] | python | train | 44.651515 |
angr/pyvex | pyvex/lifting/__init__.py | https://github.com/angr/pyvex/blob/c418edc1146982b2a0579bf56e5993c1c7046b19/pyvex/lifting/__init__.py#L216-L229 | def register(lifter, arch_name):
"""
Registers a Lifter or Postprocessor to be used by pyvex. Lifters are are given priority based on the order
in which they are registered. Postprocessors will be run in registration order.
:param lifter: The Lifter or Postprocessor to register
:vartype lifte... | [
"def",
"register",
"(",
"lifter",
",",
"arch_name",
")",
":",
"if",
"issubclass",
"(",
"lifter",
",",
"Lifter",
")",
":",
"l",
".",
"debug",
"(",
"\"Registering lifter %s for architecture %s.\"",
",",
"lifter",
".",
"__name__",
",",
"arch_name",
")",
"lifters"... | Registers a Lifter or Postprocessor to be used by pyvex. Lifters are are given priority based on the order
in which they are registered. Postprocessors will be run in registration order.
:param lifter: The Lifter or Postprocessor to register
:vartype lifter: :class:`Lifter` or :class:`Postprocess... | [
"Registers",
"a",
"Lifter",
"or",
"Postprocessor",
"to",
"be",
"used",
"by",
"pyvex",
".",
"Lifters",
"are",
"are",
"given",
"priority",
"based",
"on",
"the",
"order",
"in",
"which",
"they",
"are",
"registered",
".",
"Postprocessors",
"will",
"be",
"run",
... | python | train | 51.285714 |
seb-m/pyinotify | python3/pyinotify.py | https://github.com/seb-m/pyinotify/blob/0f3f8950d12e4a6534320153eed1a90a778da4ae/python3/pyinotify.py#L256-L264 | def logger_init():
"""Initialize logger instance."""
log = logging.getLogger("pyinotify")
console_handler = logging.StreamHandler()
console_handler.setFormatter(
logging.Formatter("[%(asctime)s %(name)s %(levelname)s] %(message)s"))
log.addHandler(console_handler)
log.setLevel(20)
re... | [
"def",
"logger_init",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"\"pyinotify\"",
")",
"console_handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"console_handler",
".",
"setFormatter",
"(",
"logging",
".",
"Formatter",
"(",
"\"[%(asc... | Initialize logger instance. | [
"Initialize",
"logger",
"instance",
"."
] | python | train | 35.555556 |
wandb/client | wandb/apis/internal.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/apis/internal.py#L1096-L1103 | def get_file_stream_api(self):
"""This creates a new file pusher thread. Call start to initiate the thread that talks to W&B"""
if not self._file_stream_api:
if self._current_run_id is None:
raise UsageError(
'Must have a current run to use file stream AP... | [
"def",
"get_file_stream_api",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_file_stream_api",
":",
"if",
"self",
".",
"_current_run_id",
"is",
"None",
":",
"raise",
"UsageError",
"(",
"'Must have a current run to use file stream API.'",
")",
"self",
".",
"_fi... | This creates a new file pusher thread. Call start to initiate the thread that talks to W&B | [
"This",
"creates",
"a",
"new",
"file",
"pusher",
"thread",
".",
"Call",
"start",
"to",
"initiate",
"the",
"thread",
"that",
"talks",
"to",
"W&B"
] | python | train | 54 |
OpenAgInitiative/openag_python | openag/couch.py | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/couch.py#L111-L128 | def push_design_documents(self, design_path):
"""
Push the design documents stored in `design_path` to the server
"""
for db_name in os.listdir(design_path):
if db_name.startswith("__") or db_name.startswith("."):
continue
db_path = os.path.join(de... | [
"def",
"push_design_documents",
"(",
"self",
",",
"design_path",
")",
":",
"for",
"db_name",
"in",
"os",
".",
"listdir",
"(",
"design_path",
")",
":",
"if",
"db_name",
".",
"startswith",
"(",
"\"__\"",
")",
"or",
"db_name",
".",
"startswith",
"(",
"\".\"",... | Push the design documents stored in `design_path` to the server | [
"Push",
"the",
"design",
"documents",
"stored",
"in",
"design_path",
"to",
"the",
"server"
] | python | train | 37.555556 |
openego/ding0 | ding0/tools/pypsa_io.py | https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/tools/pypsa_io.py#L298-L365 | def edges_to_dict_of_dataframes(grid, edges):
"""
Export edges to DataFrame
Parameters
----------
grid: ding0.Network
edges: list
Edges of Ding0.Network graph
Returns
-------
edges_dict: dict
"""
omega = 2 * pi * 50
srid = int(cfg_ding0.get('geo', 'srid'))
... | [
"def",
"edges_to_dict_of_dataframes",
"(",
"grid",
",",
"edges",
")",
":",
"omega",
"=",
"2",
"*",
"pi",
"*",
"50",
"srid",
"=",
"int",
"(",
"cfg_ding0",
".",
"get",
"(",
"'geo'",
",",
"'srid'",
")",
")",
"lines",
"=",
"{",
"'line_id'",
":",
"[",
"... | Export edges to DataFrame
Parameters
----------
grid: ding0.Network
edges: list
Edges of Ding0.Network graph
Returns
-------
edges_dict: dict | [
"Export",
"edges",
"to",
"DataFrame"
] | python | train | 33.014706 |
Kozea/pygal | pygal/graph/graph.py | https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/graph.py#L887-L894 | def _secondary_max(self):
"""Getter for the maximum series value"""
return (
self.secondary_range[1]
if (self.secondary_range
and self.secondary_range[1] is not None) else
(max(self._secondary_values) if self._secondary_values else None)
) | [
"def",
"_secondary_max",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"secondary_range",
"[",
"1",
"]",
"if",
"(",
"self",
".",
"secondary_range",
"and",
"self",
".",
"secondary_range",
"[",
"1",
"]",
"is",
"not",
"None",
")",
"else",
"(",
"max",... | Getter for the maximum series value | [
"Getter",
"for",
"the",
"maximum",
"series",
"value"
] | python | train | 38.5 |
theolind/pymysensors | mysensors/gateway_serial.py | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_serial.py#L44-L66 | def _connect(self):
"""Connect to the serial port. This should be run in a new thread."""
while self.protocol:
_LOGGER.info('Trying to connect to %s', self.port)
try:
ser = serial.serial_for_url(
self.port, self.baud, timeout=self.timeout)
... | [
"def",
"_connect",
"(",
"self",
")",
":",
"while",
"self",
".",
"protocol",
":",
"_LOGGER",
".",
"info",
"(",
"'Trying to connect to %s'",
",",
"self",
".",
"port",
")",
"try",
":",
"ser",
"=",
"serial",
".",
"serial_for_url",
"(",
"self",
".",
"port",
... | Connect to the serial port. This should be run in a new thread. | [
"Connect",
"to",
"the",
"serial",
"port",
".",
"This",
"should",
"be",
"run",
"in",
"a",
"new",
"thread",
"."
] | python | train | 43.73913 |
sashahart/cookies | cookies.py | https://github.com/sashahart/cookies/blob/ab8185e06f221eaf65305f15e05852393723ac95/cookies.py#L995-L1016 | def add(self, *args, **kwargs):
"""Add Cookie objects by their names, or create new ones under
specified names.
Any unnamed arguments are interpreted as existing cookies, and
are added under the value in their .name attribute. With keyword
arguments, the key is interpreted as th... | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Only the first one is accessible through the main interface,",
"# others accessible through get_all (all_cookies).",
"for",
"cookie",
"in",
"args",
":",
"self",
".",
"all_cookies",
".",
... | Add Cookie objects by their names, or create new ones under
specified names.
Any unnamed arguments are interpreted as existing cookies, and
are added under the value in their .name attribute. With keyword
arguments, the key is interpreted as the cookie name and the
value as the ... | [
"Add",
"Cookie",
"objects",
"by",
"their",
"names",
"or",
"create",
"new",
"ones",
"under",
"specified",
"names",
"."
] | python | train | 41.545455 |
DistrictDataLabs/yellowbrick | yellowbrick/utils/helpers.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/utils/helpers.py#L33-L60 | def get_model_name(model):
"""
Detects the model name for a Scikit-Learn model or pipeline.
Parameters
----------
model: class or instance
The object to determine the name for. If the model is an estimator it
returns the class name; if it is a Pipeline it returns the class name
... | [
"def",
"get_model_name",
"(",
"model",
")",
":",
"if",
"not",
"is_estimator",
"(",
"model",
")",
":",
"raise",
"YellowbrickTypeError",
"(",
"\"Cannot detect the model name for non estimator: '{}'\"",
".",
"format",
"(",
"type",
"(",
"model",
")",
")",
")",
"else",... | Detects the model name for a Scikit-Learn model or pipeline.
Parameters
----------
model: class or instance
The object to determine the name for. If the model is an estimator it
returns the class name; if it is a Pipeline it returns the class name
of the final transformer or estimat... | [
"Detects",
"the",
"model",
"name",
"for",
"a",
"Scikit",
"-",
"Learn",
"model",
"or",
"pipeline",
"."
] | python | train | 28.714286 |
rjw57/starman | starman/kalman.py | https://github.com/rjw57/starman/blob/1f9475e2354c9630a61f4898ad871de1d2fdbc71/starman/kalman.py#L131-L204 | def predict(self, control=None, control_matrix=None,
process_matrix=None, process_covariance=None):
"""
Predict the next *a priori* state mean and covariance given the last
posterior. As a special case the first call to this method will
initialise the posterior and prior ... | [
"def",
"predict",
"(",
"self",
",",
"control",
"=",
"None",
",",
"control_matrix",
"=",
"None",
",",
"process_matrix",
"=",
"None",
",",
"process_covariance",
"=",
"None",
")",
":",
"# Sanitise arguments",
"if",
"process_matrix",
"is",
"None",
":",
"process_ma... | Predict the next *a priori* state mean and covariance given the last
posterior. As a special case the first call to this method will
initialise the posterior and prior estimates from the
*initial_state_estimate* and *initial_covariance* arguments passed when
this object was created. In t... | [
"Predict",
"the",
"next",
"*",
"a",
"priori",
"*",
"state",
"mean",
"and",
"covariance",
"given",
"the",
"last",
"posterior",
".",
"As",
"a",
"special",
"case",
"the",
"first",
"call",
"to",
"this",
"method",
"will",
"initialise",
"the",
"posterior",
"and"... | python | train | 43.891892 |
twilio/twilio-python | twilio/rest/preview/hosted_numbers/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/hosted_numbers/__init__.py#L38-L44 | def hosted_number_orders(self):
"""
:rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderList
"""
if self._hosted_number_orders is None:
self._hosted_number_orders = HostedNumberOrderList(self)
return self._hosted_number_orders | [
"def",
"hosted_number_orders",
"(",
"self",
")",
":",
"if",
"self",
".",
"_hosted_number_orders",
"is",
"None",
":",
"self",
".",
"_hosted_number_orders",
"=",
"HostedNumberOrderList",
"(",
"self",
")",
"return",
"self",
".",
"_hosted_number_orders"
] | :rtype: twilio.rest.preview.hosted_numbers.hosted_number_order.HostedNumberOrderList | [
":",
"rtype",
":",
"twilio",
".",
"rest",
".",
"preview",
".",
"hosted_numbers",
".",
"hosted_number_order",
".",
"HostedNumberOrderList"
] | python | train | 42.857143 |
mjj4791/python-buienradar | buienradar/buienradar.py | https://github.com/mjj4791/python-buienradar/blob/a70436f54e007ce921d5210cb296cf3e4adf9d09/buienradar/buienradar.py#L41-L52 | def condition_from_code(condcode):
"""Get the condition name from the condition code."""
if condcode in __BRCONDITIONS:
cond_data = __BRCONDITIONS[condcode]
return {CONDCODE: condcode,
CONDITION: cond_data[0],
DETAILED: cond_data[1],
EXACT: cond_d... | [
"def",
"condition_from_code",
"(",
"condcode",
")",
":",
"if",
"condcode",
"in",
"__BRCONDITIONS",
":",
"cond_data",
"=",
"__BRCONDITIONS",
"[",
"condcode",
"]",
"return",
"{",
"CONDCODE",
":",
"condcode",
",",
"CONDITION",
":",
"cond_data",
"[",
"0",
"]",
"... | Get the condition name from the condition code. | [
"Get",
"the",
"condition",
"name",
"from",
"the",
"condition",
"code",
"."
] | python | train | 32.416667 |
danilobellini/audiolazy | audiolazy/lazy_poly.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_poly.py#L202-L206 | def is_polynomial(self):
"""
Tells whether it is a linear combination of natural powers of ``x``.
"""
return all(isinstance(k, INT_TYPES) and k >= 0 for k in self._data) | [
"def",
"is_polynomial",
"(",
"self",
")",
":",
"return",
"all",
"(",
"isinstance",
"(",
"k",
",",
"INT_TYPES",
")",
"and",
"k",
">=",
"0",
"for",
"k",
"in",
"self",
".",
"_data",
")"
] | Tells whether it is a linear combination of natural powers of ``x``. | [
"Tells",
"whether",
"it",
"is",
"a",
"linear",
"combination",
"of",
"natural",
"powers",
"of",
"x",
"."
] | python | train | 36.2 |
heronotears/lazyxml | demo/dump.py | https://github.com/heronotears/lazyxml/blob/e3f1ebd3f34cfa03d022ddec90e17d60c1c81953/demo/dump.py#L54-L142 | def main():
data = {'demo':{'foo': '<foo>', 'bar': ['1', '2']}}
# xml写入文件 提供文件名
lazyxml.dump(data, 'xml/dump.xml')
# xml写入文件 提供文件句柄
with open('xml/dump-fp.xml', 'w') as fp:
lazyxml.dump(data, fp)
# xml写入文件 提供类文件对象
from cStringIO import StringIO
buffer = StringIO()
lazyxml.... | [
"def",
"main",
"(",
")",
":",
"data",
"=",
"{",
"'demo'",
":",
"{",
"'foo'",
":",
"'<foo>'",
",",
"'bar'",
":",
"[",
"'1'",
",",
"'2'",
"]",
"}",
"}",
"# xml写入文件 提供文件名",
"lazyxml",
".",
"dump",
"(",
"data",
",",
"'xml/dump.xml'",
")",
"# xml写入文件 提供文件... | <root a1="1" a2="2">
<test1 a="1" b="2" c="3">
<normal index="5" required="false">
<bar><![CDATA[1]]></bar>
<bar><![CDATA[2]]></bar>
<foo><![CDATA[<foo-1>]]></foo>
</normal>
<repeat1 index="1" required="false">
<... | [
"<root",
"a1",
"=",
"1",
"a2",
"=",
"2",
">",
"<test1",
"a",
"=",
"1",
"b",
"=",
"2",
"c",
"=",
"3",
">",
"<normal",
"index",
"=",
"5",
"required",
"=",
"false",
">",
"<bar",
">",
"<!",
"[",
"CDATA",
"[",
"1",
"]]",
">",
"<",
"/",
"bar",
... | python | train | 33.898876 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1614-L1636 | def cells_rt_meta(workbook, sheet, row, col):
"""
Traverse all cells in a row. If you find new data in a cell, add it to the list.
:param obj workbook:
:param str sheet:
:param int row:
:param int col:
:return list: Cell data for a specific row
"""
logger_excel.info("enter cells_rt_m... | [
"def",
"cells_rt_meta",
"(",
"workbook",
",",
"sheet",
",",
"row",
",",
"col",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter cells_rt_meta\"",
")",
"col_loop",
"=",
"0",
"cell_data",
"=",
"[",
"]",
"temp_sheet",
"=",
"workbook",
".",
"sheet_by_name",
... | Traverse all cells in a row. If you find new data in a cell, add it to the list.
:param obj workbook:
:param str sheet:
:param int row:
:param int col:
:return list: Cell data for a specific row | [
"Traverse",
"all",
"cells",
"in",
"a",
"row",
".",
"If",
"you",
"find",
"new",
"data",
"in",
"a",
"cell",
"add",
"it",
"to",
"the",
"list",
".",
":",
"param",
"obj",
"workbook",
":",
":",
"param",
"str",
"sheet",
":",
":",
"param",
"int",
"row",
... | python | train | 37.869565 |
Trebek/pydealer | pydealer/stack.py | https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/stack.py#L470-L516 | def get_list(self, terms, limit=0, sort=False, ranks=None):
"""
Get the specified cards from the stack.
:arg term:
The search term. Can be a card full name, value, suit,
abbreviation, or stack indice.
:arg int limit:
The number of items to retrieve fo... | [
"def",
"get_list",
"(",
"self",
",",
"terms",
",",
"limit",
"=",
"0",
",",
"sort",
"=",
"False",
",",
"ranks",
"=",
"None",
")",
":",
"ranks",
"=",
"ranks",
"or",
"self",
".",
"ranks",
"got_cards",
"=",
"[",
"]",
"try",
":",
"indices",
"=",
"self... | Get the specified cards from the stack.
:arg term:
The search term. Can be a card full name, value, suit,
abbreviation, or stack indice.
:arg int limit:
The number of items to retrieve for each term.
:arg bool sort:
Whether or not to sort the resu... | [
"Get",
"the",
"specified",
"cards",
"from",
"the",
"stack",
"."
] | python | train | 34.340426 |
psd-tools/psd-tools | src/psd_tools/api/psd_image.py | https://github.com/psd-tools/psd-tools/blob/4952b57bcf1cf2c1f16fd9d6d51d4fa0b53bce4e/src/psd_tools/api/psd_image.py#L442-L450 | def _get_pattern(self, pattern_id):
"""Get pattern item by id."""
for key in ('PATTERNS1', 'PATTERNS2', 'PATTERNS3'):
if key in self.tagged_blocks:
data = self.tagged_blocks.get_data(key)
for pattern in data:
if pattern.pattern_id == patter... | [
"def",
"_get_pattern",
"(",
"self",
",",
"pattern_id",
")",
":",
"for",
"key",
"in",
"(",
"'PATTERNS1'",
",",
"'PATTERNS2'",
",",
"'PATTERNS3'",
")",
":",
"if",
"key",
"in",
"self",
".",
"tagged_blocks",
":",
"data",
"=",
"self",
".",
"tagged_blocks",
".... | Get pattern item by id. | [
"Get",
"pattern",
"item",
"by",
"id",
"."
] | python | train | 41.777778 |
hasgeek/coaster | coaster/sqlalchemy/mixins.py | https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/sqlalchemy/mixins.py#L112-L117 | def uuid(cls):
"""UUID column, or synonym to existing :attr:`id` column if that is a UUID"""
if hasattr(cls, '__uuid_primary_key__') and cls.__uuid_primary_key__:
return synonym('id')
else:
return immutable(Column(UUIDType(binary=False), default=uuid_.uuid4, unique=True, ... | [
"def",
"uuid",
"(",
"cls",
")",
":",
"if",
"hasattr",
"(",
"cls",
",",
"'__uuid_primary_key__'",
")",
"and",
"cls",
".",
"__uuid_primary_key__",
":",
"return",
"synonym",
"(",
"'id'",
")",
"else",
":",
"return",
"immutable",
"(",
"Column",
"(",
"UUIDType",... | UUID column, or synonym to existing :attr:`id` column if that is a UUID | [
"UUID",
"column",
"or",
"synonym",
"to",
"existing",
":",
"attr",
":",
"id",
"column",
"if",
"that",
"is",
"a",
"UUID"
] | python | train | 55.166667 |
ga4gh/ga4gh-server | ga4gh/server/backend.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/backend.py#L405-L421 | def continuousGenerator(self, request):
"""
Returns a generator over the (continuous, nextPageToken) pairs
defined by the (JSON string) request.
"""
compoundId = None
if request.continuous_set_id != "":
compoundId = datamodel.ContinuousSetCompoundId.parse(
... | [
"def",
"continuousGenerator",
"(",
"self",
",",
"request",
")",
":",
"compoundId",
"=",
"None",
"if",
"request",
".",
"continuous_set_id",
"!=",
"\"\"",
":",
"compoundId",
"=",
"datamodel",
".",
"ContinuousSetCompoundId",
".",
"parse",
"(",
"request",
".",
"co... | Returns a generator over the (continuous, nextPageToken) pairs
defined by the (JSON string) request. | [
"Returns",
"a",
"generator",
"over",
"the",
"(",
"continuous",
"nextPageToken",
")",
"pairs",
"defined",
"by",
"the",
"(",
"JSON",
"string",
")",
"request",
"."
] | python | train | 41.176471 |
twisted/mantissa | xmantissa/people.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/people.py#L2357-L2366 | def render_addPersonForm(self, ctx, data):
"""
Create and return a L{liveform.LiveForm} for creating a new L{Person}.
"""
addPersonForm = liveform.LiveForm(
self.addPerson, self._baseParameters, description='Add Person')
addPersonForm.compact()
addPersonForm.j... | [
"def",
"render_addPersonForm",
"(",
"self",
",",
"ctx",
",",
"data",
")",
":",
"addPersonForm",
"=",
"liveform",
".",
"LiveForm",
"(",
"self",
".",
"addPerson",
",",
"self",
".",
"_baseParameters",
",",
"description",
"=",
"'Add Person'",
")",
"addPersonForm",... | Create and return a L{liveform.LiveForm} for creating a new L{Person}. | [
"Create",
"and",
"return",
"a",
"L",
"{",
"liveform",
".",
"LiveForm",
"}",
"for",
"creating",
"a",
"new",
"L",
"{",
"Person",
"}",
"."
] | python | train | 42.7 |
LionelAuroux/pyrser | pyrser/dsl.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/dsl.py#L599-L624 | def add_rpt(self, sequence, mod, pt):
"""Add a repeater to the previous sequence"""
modstr = self.value(mod)
if modstr == '!!':
# cursor on the REPEATER
self._stream.restore_context()
# log the error
self.diagnostic.notify(
error.Severity.ERROR,
"Canno... | [
"def",
"add_rpt",
"(",
"self",
",",
"sequence",
",",
"mod",
",",
"pt",
")",
":",
"modstr",
"=",
"self",
".",
"value",
"(",
"mod",
")",
"if",
"modstr",
"==",
"'!!'",
":",
"# cursor on the REPEATER",
"self",
".",
"_stream",
".",
"restore_context",
"(",
"... | Add a repeater to the previous sequence | [
"Add",
"a",
"repeater",
"to",
"the",
"previous",
"sequence"
] | python | test | 33.538462 |
pysal/mapclassify | mapclassify/classifiers.py | https://github.com/pysal/mapclassify/blob/5b22ec33f5802becf40557614d90cd38efa1676e/mapclassify/classifiers.py#L2178-L2183 | def _ss(self, class_def):
"""calculates sum of squares for a class"""
yc = self.y[class_def]
css = yc - yc.mean()
css *= css
return sum(css) | [
"def",
"_ss",
"(",
"self",
",",
"class_def",
")",
":",
"yc",
"=",
"self",
".",
"y",
"[",
"class_def",
"]",
"css",
"=",
"yc",
"-",
"yc",
".",
"mean",
"(",
")",
"css",
"*=",
"css",
"return",
"sum",
"(",
"css",
")"
] | calculates sum of squares for a class | [
"calculates",
"sum",
"of",
"squares",
"for",
"a",
"class"
] | python | train | 29.166667 |
chop-dbhi/varify-data-warehouse | vdw/samples/migrations/0018_create_project_groups.py | https://github.com/chop-dbhi/varify-data-warehouse/blob/1600ee1bc5fae6c68fd03b23624467298570cca8/vdw/samples/migrations/0018_create_project_groups.py#L22-L30 | def backwards(self, orm):
"Write your backwards methods here."
from django.contrib.auth.models import Group
projects = orm['samples.Project'].objects.all()
names = [PROJECT_GROUP_TEMPLATE.format(p.name) for p in projects]
# Remove groups named after these teams
Group.ob... | [
"def",
"backwards",
"(",
"self",
",",
"orm",
")",
":",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"models",
"import",
"Group",
"projects",
"=",
"orm",
"[",
"'samples.Project'",
"]",
".",
"objects",
".",
"all",
"(",
")",
"names",
"=",
"[",
"P... | Write your backwards methods here. | [
"Write",
"your",
"backwards",
"methods",
"here",
"."
] | python | train | 38.777778 |
jupyterhub/chartpress | chartpress.py | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L45-L54 | def git_remote(git_repo):
"""Return the URL for remote git repository.
Depending on the system setup it returns ssh or https remote.
"""
github_token = os.getenv(GITHUB_TOKEN_KEY)
if github_token:
return 'https://{0}@github.com/{1}'.format(
github_token, git_repo)
return 'gi... | [
"def",
"git_remote",
"(",
"git_repo",
")",
":",
"github_token",
"=",
"os",
".",
"getenv",
"(",
"GITHUB_TOKEN_KEY",
")",
"if",
"github_token",
":",
"return",
"'https://{0}@github.com/{1}'",
".",
"format",
"(",
"github_token",
",",
"git_repo",
")",
"return",
"'git... | Return the URL for remote git repository.
Depending on the system setup it returns ssh or https remote. | [
"Return",
"the",
"URL",
"for",
"remote",
"git",
"repository",
"."
] | python | train | 34.5 |
apache/spark | python/pyspark/ml/param/__init__.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/param/__init__.py#L138-L146 | def toListInt(value):
"""
Convert a value to list of ints, if possible.
"""
if TypeConverters._can_convert_to_list(value):
value = TypeConverters.toList(value)
if all(map(lambda v: TypeConverters._is_integer(v), value)):
return [int(v) for v in val... | [
"def",
"toListInt",
"(",
"value",
")",
":",
"if",
"TypeConverters",
".",
"_can_convert_to_list",
"(",
"value",
")",
":",
"value",
"=",
"TypeConverters",
".",
"toList",
"(",
"value",
")",
"if",
"all",
"(",
"map",
"(",
"lambda",
"v",
":",
"TypeConverters",
... | Convert a value to list of ints, if possible. | [
"Convert",
"a",
"value",
"to",
"list",
"of",
"ints",
"if",
"possible",
"."
] | python | train | 43 |
WebarchivCZ/WA-KAT | src/wa_kat/templates/static/js/Lib/site-packages/components/input_controller.py | https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/templates/static/js/Lib/site-packages/components/input_controller.py#L65-L114 | def _set_typeahead(cls, el, value):
"""
Convert given `el` to typeahead input and set it to `value`.
This method also sets the dropdown icons and descriptors.
Args:
el (obj): Element reference to the input you want to convert to
typeahead.
value ... | [
"def",
"_set_typeahead",
"(",
"cls",
",",
"el",
",",
"value",
")",
":",
"PlaceholderHandler",
".",
"reset_placeholder_dropdown",
"(",
"el",
")",
"# if there is no elements, show alert icon in glyph",
"if",
"not",
"value",
"and",
"not",
"el",
".",
"value",
":",
"Dr... | Convert given `el` to typeahead input and set it to `value`.
This method also sets the dropdown icons and descriptors.
Args:
el (obj): Element reference to the input you want to convert to
typeahead.
value (list): List of dicts with two keys: ``source`` and ``va... | [
"Convert",
"given",
"el",
"to",
"typeahead",
"input",
"and",
"set",
"it",
"to",
"value",
"."
] | python | train | 37.44 |
sibirrer/lenstronomy | lenstronomy/Analysis/lens_properties.py | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Analysis/lens_properties.py#L52-L80 | def velocity_dispersion(self, kwargs_lens, kwargs_lens_light, lens_light_model_bool_list=None, aniso_param=1,
r_eff=None, R_slit=0.81, dR_slit=0.1, psf_fwhm=0.7, num_evaluate=1000):
"""
computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit an... | [
"def",
"velocity_dispersion",
"(",
"self",
",",
"kwargs_lens",
",",
"kwargs_lens_light",
",",
"lens_light_model_bool_list",
"=",
"None",
",",
"aniso_param",
"=",
"1",
",",
"r_eff",
"=",
"None",
",",
"R_slit",
"=",
"0.81",
",",
"dR_slit",
"=",
"0.1",
",",
"ps... | computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit and seeing psf_fwhm.
The assumptions are a Hernquist light profile and the spherical power-law lens model at the first position.
Further information can be found in the AnalyticKinematics() class.
:param kw... | [
"computes",
"the",
"LOS",
"velocity",
"dispersion",
"of",
"the",
"lens",
"within",
"a",
"slit",
"of",
"size",
"R_slit",
"x",
"dR_slit",
"and",
"seeing",
"psf_fwhm",
".",
"The",
"assumptions",
"are",
"a",
"Hernquist",
"light",
"profile",
"and",
"the",
"spheri... | python | train | 62.137931 |
maxalbert/tohu | tohu/v6/base.py | https://github.com/maxalbert/tohu/blob/43380162fadec99cdd5c5c3152dd6b7d3a9d39a8/tohu/v6/base.py#L121-L129 | def reset(self, seed):
"""
Reset this generator's seed generator and any clones.
"""
logger.debug(f'Resetting {self} (seed={seed})')
self.seed_generator.reset(seed)
for c in self.clones:
c.reset(seed) | [
"def",
"reset",
"(",
"self",
",",
"seed",
")",
":",
"logger",
".",
"debug",
"(",
"f'Resetting {self} (seed={seed})'",
")",
"self",
".",
"seed_generator",
".",
"reset",
"(",
"seed",
")",
"for",
"c",
"in",
"self",
".",
"clones",
":",
"c",
".",
"reset",
"... | Reset this generator's seed generator and any clones. | [
"Reset",
"this",
"generator",
"s",
"seed",
"generator",
"and",
"any",
"clones",
"."
] | python | train | 28.111111 |
mongodb/mongo-python-driver | pymongo/message.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/message.py#L715-L729 | def _query_compressed(options, collection_name, num_to_skip,
num_to_return, query, field_selector,
opts, check_keys=False, ctx=None):
"""Internal compressed query message helper."""
op_query, max_bson_size = _query(
options,
collection_name,
nu... | [
"def",
"_query_compressed",
"(",
"options",
",",
"collection_name",
",",
"num_to_skip",
",",
"num_to_return",
",",
"query",
",",
"field_selector",
",",
"opts",
",",
"check_keys",
"=",
"False",
",",
"ctx",
"=",
"None",
")",
":",
"op_query",
",",
"max_bson_size"... | Internal compressed query message helper. | [
"Internal",
"compressed",
"query",
"message",
"helper",
"."
] | python | train | 32.866667 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/distribute-0.6.31-py2.7.egg/pkg_resources.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/distribute-0.6.31-py2.7.egg/pkg_resources.py#L2505-L2530 | def _compute_dependencies(self):
"""Recompute this distribution's dependencies."""
from _markerlib import compile as compile_marker
dm = self.__dep_map = {None: []}
reqs = []
# Including any condition expressions
for req in self._parsed_pkg_info.get_all('Requires-Dist') ... | [
"def",
"_compute_dependencies",
"(",
"self",
")",
":",
"from",
"_markerlib",
"import",
"compile",
"as",
"compile_marker",
"dm",
"=",
"self",
".",
"__dep_map",
"=",
"{",
"None",
":",
"[",
"]",
"}",
"reqs",
"=",
"[",
"]",
"# Including any condition expressions",... | Recompute this distribution's dependencies. | [
"Recompute",
"this",
"distribution",
"s",
"dependencies",
"."
] | python | test | 36.692308 |
mosdef-hub/mbuild | mbuild/formats/lammpsdata.py | https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/formats/lammpsdata.py#L14-L250 | def write_lammpsdata(structure, filename, atom_style='full'):
"""Output a LAMMPS data file.
Outputs a LAMMPS data file in the 'full' atom style format. Assumes use
of 'real' units. See http://lammps.sandia.gov/doc/atom_style.html for
more information on atom styles.
Parameters
----------
... | [
"def",
"write_lammpsdata",
"(",
"structure",
",",
"filename",
",",
"atom_style",
"=",
"'full'",
")",
":",
"if",
"atom_style",
"not",
"in",
"[",
"'atomic'",
",",
"'charge'",
",",
"'molecular'",
",",
"'full'",
"]",
":",
"raise",
"ValueError",
"(",
"'Atom style... | Output a LAMMPS data file.
Outputs a LAMMPS data file in the 'full' atom style format. Assumes use
of 'real' units. See http://lammps.sandia.gov/doc/atom_style.html for
more information on atom styles.
Parameters
----------
structure : parmed.Structure
ParmEd structure object
f... | [
"Output",
"a",
"LAMMPS",
"data",
"file",
".",
"Outputs",
"a",
"LAMMPS",
"data",
"file",
"in",
"the",
"full",
"atom",
"style",
"format",
".",
"Assumes",
"use",
"of",
"real",
"units",
".",
"See",
"http",
":",
"//",
"lammps",
".",
"sandia",
".",
"gov",
... | python | train | 45.590717 |
SiLab-Bonn/pyBAR | pybar/analysis/analysis_utils.py | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L192-L217 | def get_profile_histogram(x, y, n_bins=100):
'''Takes 2D point data (x,y) and creates a profile histogram similar to the TProfile in ROOT. It calculates
the y mean for every bin at the bin center and gives the y mean error as error bars.
Parameters
----------
x : array like
data x positions... | [
"def",
"get_profile_histogram",
"(",
"x",
",",
"y",
",",
"n_bins",
"=",
"100",
")",
":",
"if",
"len",
"(",
"x",
")",
"!=",
"len",
"(",
"y",
")",
":",
"raise",
"ValueError",
"(",
"'x and y dimensions have to be the same'",
")",
"y",
"=",
"y",
".",
"asty... | Takes 2D point data (x,y) and creates a profile histogram similar to the TProfile in ROOT. It calculates
the y mean for every bin at the bin center and gives the y mean error as error bars.
Parameters
----------
x : array like
data x positions
y : array like
data y positions
n_b... | [
"Takes",
"2D",
"point",
"data",
"(",
"x",
"y",
")",
"and",
"creates",
"a",
"profile",
"histogram",
"similar",
"to",
"the",
"TProfile",
"in",
"ROOT",
".",
"It",
"calculates",
"the",
"y",
"mean",
"for",
"every",
"bin",
"at",
"the",
"bin",
"center",
"and"... | python | train | 47.346154 |
kytos/python-openflow | pyof/foundation/basic_types.py | https://github.com/kytos/python-openflow/blob/4f2d0d08ab28e102ed88fe57a4ee17729f1e1bb7/pyof/foundation/basic_types.py#L307-L326 | def unpack(self, buff, offset=0):
"""Unpack a binary message into this object's attributes.
Unpack the binary value *buff* and update this object attributes based
on the results.
Args:
buff (bytes): Binary data package to be unpacked.
offset (int): Where to begi... | [
"def",
"unpack",
"(",
"self",
",",
"buff",
",",
"offset",
"=",
"0",
")",
":",
"try",
":",
"unpacked_data",
"=",
"struct",
".",
"unpack",
"(",
"'!4B'",
",",
"buff",
"[",
"offset",
":",
"offset",
"+",
"4",
"]",
")",
"self",
".",
"_value",
"=",
"'.'... | Unpack a binary message into this object's attributes.
Unpack the binary value *buff* and update this object attributes based
on the results.
Args:
buff (bytes): Binary data package to be unpacked.
offset (int): Where to begin unpacking.
Raises:
Exc... | [
"Unpack",
"a",
"binary",
"message",
"into",
"this",
"object",
"s",
"attributes",
"."
] | python | train | 37.35 |
drj11/pypng | code/png.py | https://github.com/drj11/pypng/blob/b8220ca9f58e4c5bc1d507e713744fcb8c049225/code/png.py#L1468-L1518 | def _deinterlace(self, raw):
"""
Read raw pixel data, undo filters, deinterlace, and flatten.
Return a single array of values.
"""
# Values per row (of the target image)
vpr = self.width * self.planes
# Values per image
vpi = vpr * self.height
# ... | [
"def",
"_deinterlace",
"(",
"self",
",",
"raw",
")",
":",
"# Values per row (of the target image)",
"vpr",
"=",
"self",
".",
"width",
"*",
"self",
".",
"planes",
"# Values per image",
"vpi",
"=",
"vpr",
"*",
"self",
".",
"height",
"# Interleaving writes to the out... | Read raw pixel data, undo filters, deinterlace, and flatten.
Return a single array of values. | [
"Read",
"raw",
"pixel",
"data",
"undo",
"filters",
"deinterlace",
"and",
"flatten",
".",
"Return",
"a",
"single",
"array",
"of",
"values",
"."
] | python | train | 39.568627 |
StackStorm/pybind | pybind/slxos/v17s_1_02/telemetry/collector/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/telemetry/collector/__init__.py#L168-L189 | def _set_collector_profile(self, v, load=False):
"""
Setter method for collector_profile, mapped from YANG variable /telemetry/collector/collector_profile (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_collector_profile is considered as a private
method. Back... | [
"def",
"_set_collector_profile",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",... | Setter method for collector_profile, mapped from YANG variable /telemetry/collector/collector_profile (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_collector_profile is considered as a private
method. Backends looking to populate this variable should
do so via c... | [
"Setter",
"method",
"for",
"collector_profile",
"mapped",
"from",
"YANG",
"variable",
"/",
"telemetry",
"/",
"collector",
"/",
"collector_profile",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",... | python | train | 131.272727 |
kgori/treeCl | treeCl/tree.py | https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/tree.py#L1091-L1114 | def autocorrelated_relaxed_clock(self, root_rate, autocorrel,
distribution='lognormal'):
"""
Attaches rates to each node according to autocorrelated lognormal
model from Kishino et al.(2001), or autocorrelated exponential
"""
optioncheck(distr... | [
"def",
"autocorrelated_relaxed_clock",
"(",
"self",
",",
"root_rate",
",",
"autocorrel",
",",
"distribution",
"=",
"'lognormal'",
")",
":",
"optioncheck",
"(",
"distribution",
",",
"[",
"'exponential'",
",",
"'lognormal'",
"]",
")",
"if",
"autocorrel",
"==",
"0"... | Attaches rates to each node according to autocorrelated lognormal
model from Kishino et al.(2001), or autocorrelated exponential | [
"Attaches",
"rates",
"to",
"each",
"node",
"according",
"to",
"autocorrelated",
"lognormal",
"model",
"from",
"Kishino",
"et",
"al",
".",
"(",
"2001",
")",
"or",
"autocorrelated",
"exponential"
] | python | train | 41.458333 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L11447-L11471 | def hil_gps_send(self, time_usec, fix_type, lat, lon, alt, eph, epv, vel, vn, ve, vd, cog, satellites_visible, force_mavlink1=False):
'''
The global position, as returned by the Global Positioning System
(GPS). This is NOT the global
posit... | [
"def",
"hil_gps_send",
"(",
"self",
",",
"time_usec",
",",
"fix_type",
",",
"lat",
",",
"lon",
",",
"alt",
",",
"eph",
",",
"epv",
",",
"vel",
",",
"vn",
",",
"ve",
",",
"vd",
",",
"cog",
",",
"satellites_visible",
",",
"force_mavlink1",
"=",
"False"... | The global position, as returned by the Global Positioning System
(GPS). This is NOT the global
position estimate of the sytem, but rather a RAW
sensor value. See message GLOBAL_POSITION for the
global position estimate. Coordinate frame i... | [
"The",
"global",
"position",
"as",
"returned",
"by",
"the",
"Global",
"Positioning",
"System",
"(",
"GPS",
")",
".",
"This",
"is",
"NOT",
"the",
"global",
"position",
"estimate",
"of",
"the",
"sytem",
"but",
"rather",
"a",
"RAW",
"sensor",
"value",
".",
... | python | train | 95.04 |
theislab/scanpy | scanpy/plotting/_tools/scatterplots.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/plotting/_tools/scatterplots.py#L289-L304 | def tsne(adata, **kwargs) -> Union[Axes, List[Axes], None]:
"""\
Scatter plot in tSNE basis.
Parameters
----------
{adata_color_etc}
{edges_arrows}
{scatter_bulk}
{show_save_ax}
Returns
-------
If `show==False` a :class:`~matplotlib.axes.Axes` or a list of it.
"""
r... | [
"def",
"tsne",
"(",
"adata",
",",
"*",
"*",
"kwargs",
")",
"->",
"Union",
"[",
"Axes",
",",
"List",
"[",
"Axes",
"]",
",",
"None",
"]",
":",
"return",
"plot_scatter",
"(",
"adata",
",",
"'tsne'",
",",
"*",
"*",
"kwargs",
")"
] | \
Scatter plot in tSNE basis.
Parameters
----------
{adata_color_etc}
{edges_arrows}
{scatter_bulk}
{show_save_ax}
Returns
-------
If `show==False` a :class:`~matplotlib.axes.Axes` or a list of it. | [
"\\",
"Scatter",
"plot",
"in",
"tSNE",
"basis",
"."
] | python | train | 21.75 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.