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 |
|---|---|---|---|---|---|---|---|---|---|
SiLab-Bonn/pyBAR | pybar/ViTablesPlugin/pybar_plugin.py | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/ViTablesPlugin/pybar_plugin.py#L188-L214 | def plot(self):
"""Export a given dataset to a `CSV` file.
This method is a slot connected to the `export` QAction. See the
:meth:`addEntry` method for details.
"""
# The PyTables node tied to the current leaf of the databases tree
current = self.vtgui.dbs_tree_view.curr... | [
"def",
"plot",
"(",
"self",
")",
":",
"# The PyTables node tied to the current leaf of the databases tree",
"current",
"=",
"self",
".",
"vtgui",
".",
"dbs_tree_view",
".",
"currentIndex",
"(",
")",
"leaf",
"=",
"self",
".",
"vtgui",
".",
"dbs_tree_model",
".",
"n... | Export a given dataset to a `CSV` file.
This method is a slot connected to the `export` QAction. See the
:meth:`addEntry` method for details. | [
"Export",
"a",
"given",
"dataset",
"to",
"a",
"CSV",
"file",
"."
] | python | train | 52.962963 |
NiklasRosenstein-Python/nr-deprecated | nr/concurrency.py | https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/concurrency.py#L499-L533 | def add_listener(self, event, callback, once=False):
"""
Register a *callback* for the specified *event*. The function will be
called with the #Job as its first argument. If *once* is #True, the
listener will be removed after it has been invoked once or when the
job is re-started.
Note that if ... | [
"def",
"add_listener",
"(",
"self",
",",
"event",
",",
"callback",
",",
"once",
"=",
"False",
")",
":",
"if",
"not",
"callable",
"(",
"callback",
")",
":",
"raise",
"TypeError",
"(",
"'callback must be callable'",
")",
"if",
"isinstance",
"(",
"event",
","... | Register a *callback* for the specified *event*. The function will be
called with the #Job as its first argument. If *once* is #True, the
listener will be removed after it has been invoked once or when the
job is re-started.
Note that if the event already ocurred, *callback* will be called
immediat... | [
"Register",
"a",
"*",
"callback",
"*",
"for",
"the",
"specified",
"*",
"event",
"*",
".",
"The",
"function",
"will",
"be",
"called",
"with",
"the",
"#Job",
"as",
"its",
"first",
"argument",
".",
"If",
"*",
"once",
"*",
"is",
"#True",
"the",
"listener",... | python | train | 36.428571 |
crytic/pyevmasm | pyevmasm/evmasm.py | https://github.com/crytic/pyevmasm/blob/d27daf19a36d630a31499e783b716cf1165798d8/pyevmasm/evmasm.py#L491-L513 | def disassemble(bytecode, pc=0, fork=DEFAULT_FORK):
""" Disassemble an EVM bytecode
:param bytecode: binary representation of an evm bytecode
:type bytecode: str | bytes | bytearray
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork... | [
"def",
"disassemble",
"(",
"bytecode",
",",
"pc",
"=",
"0",
",",
"fork",
"=",
"DEFAULT_FORK",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"map",
"(",
"str",
",",
"disassemble_all",
"(",
"bytecode",
",",
"pc",
"=",
"pc",
",",
"fork",
"=",
"fork",
... | Disassemble an EVM bytecode
:param bytecode: binary representation of an evm bytecode
:type bytecode: str | bytes | bytearray
:param pc: program counter of the first instruction(optional)
:type pc: int
:param fork: fork name (optional)
:type fork: str
:return: th... | [
"Disassemble",
"an",
"EVM",
"bytecode"
] | python | valid | 30.782609 |
annoviko/pyclustering | pyclustering/cluster/examples/xmeans_examples.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/examples/xmeans_examples.py#L60-L64 | def cluster_sample1():
"Start with wrong number of clusters."
start_centers = [[3.7, 5.5]]
template_clustering(start_centers, SIMPLE_SAMPLES.SAMPLE_SIMPLE1, criterion = splitting_type.BAYESIAN_INFORMATION_CRITERION)
template_clustering(start_centers, SIMPLE_SAMPLES.SAMPLE_SIMPLE1, criterion = splitt... | [
"def",
"cluster_sample1",
"(",
")",
":",
"start_centers",
"=",
"[",
"[",
"3.7",
",",
"5.5",
"]",
"]",
"template_clustering",
"(",
"start_centers",
",",
"SIMPLE_SAMPLES",
".",
"SAMPLE_SIMPLE1",
",",
"criterion",
"=",
"splitting_type",
".",
"BAYESIAN_INFORMATION_CRI... | Start with wrong number of clusters. | [
"Start",
"with",
"wrong",
"number",
"of",
"clusters",
"."
] | python | valid | 72.4 |
codelv/enaml-native | src/enamlnative/core/dev.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L902-L919 | def do_hotswap(self, msg):
""" Attempt to hotswap the code """
#: Show hotswap tooltip
try:
self.app.widget.showTooltip("Hot swapping...", now=True)
except:
pass
self.save_changed_files(msg)
hotswap = self.hotswap
app = self.app
tr... | [
"def",
"do_hotswap",
"(",
"self",
",",
"msg",
")",
":",
"#: Show hotswap tooltip",
"try",
":",
"self",
".",
"app",
".",
"widget",
".",
"showTooltip",
"(",
"\"Hot swapping...\"",
",",
"now",
"=",
"True",
")",
"except",
":",
"pass",
"self",
".",
"save_change... | Attempt to hotswap the code | [
"Attempt",
"to",
"hotswap",
"the",
"code"
] | python | train | 30 |
racker/torment | torment/fixtures/__init__.py | https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/fixtures/__init__.py#L181-L184 | def description(self) -> str:
'''Test name in nose output (intended to be overridden).'''
return '{0.uuid.hex}—{1}'.format(self, self.context.module) | [
"def",
"description",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'{0.uuid.hex}—{1}'.f",
"o",
"rmat(s",
"e",
"lf, ",
"s",
"lf.c",
"o",
"ntext.m",
"o",
"dule)",
""
] | Test name in nose output (intended to be overridden). | [
"Test",
"name",
"in",
"nose",
"output",
"(",
"intended",
"to",
"be",
"overridden",
")",
"."
] | python | train | 40.75 |
gofed/gofedlib | gofedlib/go/apidiff/apidiff.py | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/apidiff/apidiff.py#L231-L250 | def _constructTypeQualifiedName(self, type, full=False):
"""
For given type construct its full qualified name.
AnonymousField = [ "*" ] TypeName .
TypeName = identifier | QualifiedIdent .
QualifiedIdent = PackageName "." identifier .
"""
t = type["type"]
if t == TYPE_IDENT:
return type["def"]
eli... | [
"def",
"_constructTypeQualifiedName",
"(",
"self",
",",
"type",
",",
"full",
"=",
"False",
")",
":",
"t",
"=",
"type",
"[",
"\"type\"",
"]",
"if",
"t",
"==",
"TYPE_IDENT",
":",
"return",
"type",
"[",
"\"def\"",
"]",
"elif",
"t",
"==",
"TYPE_POINTER",
"... | For given type construct its full qualified name.
AnonymousField = [ "*" ] TypeName .
TypeName = identifier | QualifiedIdent .
QualifiedIdent = PackageName "." identifier . | [
"For",
"given",
"type",
"construct",
"its",
"full",
"qualified",
"name",
"."
] | python | train | 28.4 |
scanny/python-pptx | pptx/chart/data.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/data.py#L638-L645 | def add_data_point(self, value, number_format=None):
"""
Return a CategoryDataPoint object newly created with value *value*,
an optional *number_format*, and appended to this sequence.
"""
data_point = CategoryDataPoint(self, value, number_format)
self.append(data_point)
... | [
"def",
"add_data_point",
"(",
"self",
",",
"value",
",",
"number_format",
"=",
"None",
")",
":",
"data_point",
"=",
"CategoryDataPoint",
"(",
"self",
",",
"value",
",",
"number_format",
")",
"self",
".",
"append",
"(",
"data_point",
")",
"return",
"data_poin... | Return a CategoryDataPoint object newly created with value *value*,
an optional *number_format*, and appended to this sequence. | [
"Return",
"a",
"CategoryDataPoint",
"object",
"newly",
"created",
"with",
"value",
"*",
"value",
"*",
"an",
"optional",
"*",
"number_format",
"*",
"and",
"appended",
"to",
"this",
"sequence",
"."
] | python | train | 42.25 |
CalebBell/fluids | fluids/geometry.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1746-L1779 | def h_from_V(self, V, method='spline'):
r'''Method to calculate the height of liquid in a fully defined tank
given a specified volume of liquid in it `V`. `V` must be under the
maximum volume. If the method is 'spline', and the interpolation table
is not yet defined, creates it by callin... | [
"def",
"h_from_V",
"(",
"self",
",",
"V",
",",
"method",
"=",
"'spline'",
")",
":",
"if",
"method",
"==",
"'spline'",
":",
"if",
"not",
"self",
".",
"table",
":",
"self",
".",
"set_table",
"(",
")",
"return",
"float",
"(",
"self",
".",
"interp_h_from... | r'''Method to calculate the height of liquid in a fully defined tank
given a specified volume of liquid in it `V`. `V` must be under the
maximum volume. If the method is 'spline', and the interpolation table
is not yet defined, creates it by calling the method set_table. If the
method is... | [
"r",
"Method",
"to",
"calculate",
"the",
"height",
"of",
"liquid",
"in",
"a",
"fully",
"defined",
"tank",
"given",
"a",
"specified",
"volume",
"of",
"liquid",
"in",
"it",
"V",
".",
"V",
"must",
"be",
"under",
"the",
"maximum",
"volume",
".",
"If",
"the... | python | train | 41.147059 |
iliana/python-simplemediawiki | simplemediawiki.py | https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L289-L319 | def namespaces(self, psuedo=True):
"""
Fetches a list of namespaces for this wiki and returns them as a
dictionary of namespace IDs corresponding to namespace names. If
*psuedo* is ``True``, the dictionary will also list psuedo-namespaces,
which are the "Special:" and "Media:" na... | [
"def",
"namespaces",
"(",
"self",
",",
"psuedo",
"=",
"True",
")",
":",
"if",
"self",
".",
"_namespaces",
"is",
"None",
":",
"result",
"=",
"self",
".",
"call",
"(",
"{",
"'action'",
":",
"'query'",
",",
"'meta'",
":",
"'siteinfo'",
",",
"'siprop'",
... | Fetches a list of namespaces for this wiki and returns them as a
dictionary of namespace IDs corresponding to namespace names. If
*psuedo* is ``True``, the dictionary will also list psuedo-namespaces,
which are the "Special:" and "Media:" namespaces (special because they
have no content ... | [
"Fetches",
"a",
"list",
"of",
"namespaces",
"for",
"this",
"wiki",
"and",
"returns",
"them",
"as",
"a",
"dictionary",
"of",
"namespace",
"IDs",
"corresponding",
"to",
"namespace",
"names",
".",
"If",
"*",
"psuedo",
"*",
"is",
"True",
"the",
"dictionary",
"... | python | train | 44.419355 |
robotools/fontParts | Lib/fontParts/base/glyph.py | https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/glyph.py#L2033-L2045 | def _getLayer(self, name, **kwargs):
"""
name will be a string, but there may not be a
layer with a name matching the string. If not,
a ``ValueError`` must be raised.
Subclasses may override this method.
"""
for glyph in self.layers:
if glyph.layer.na... | [
"def",
"_getLayer",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"glyph",
"in",
"self",
".",
"layers",
":",
"if",
"glyph",
".",
"layer",
".",
"name",
"==",
"name",
":",
"return",
"glyph",
"raise",
"ValueError",
"(",
"\"No layer... | name will be a string, but there may not be a
layer with a name matching the string. If not,
a ``ValueError`` must be raised.
Subclasses may override this method. | [
"name",
"will",
"be",
"a",
"string",
"but",
"there",
"may",
"not",
"be",
"a",
"layer",
"with",
"a",
"name",
"matching",
"the",
"string",
".",
"If",
"not",
"a",
"ValueError",
"must",
"be",
"raised",
"."
] | python | train | 35.076923 |
tensorflow/cleverhans | cleverhans/utils_tf.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils_tf.py#L28-L50 | def model_loss(y, model, mean=True):
"""
Define loss of TF graph
:param y: correct labels
:param model: output of the model
:param mean: boolean indicating whether should return mean of loss
or vector of losses for each input of the batch
:return: return mean of loss if True, otherwise return... | [
"def",
"model_loss",
"(",
"y",
",",
"model",
",",
"mean",
"=",
"True",
")",
":",
"warnings",
".",
"warn",
"(",
"\"This function is deprecated and will be removed on or after\"",
"\" 2019-04-05. Switch to cleverhans.train.train.\"",
")",
"op",
"=",
"model",
".",
"op",
... | Define loss of TF graph
:param y: correct labels
:param model: output of the model
:param mean: boolean indicating whether should return mean of loss
or vector of losses for each input of the batch
:return: return mean of loss if True, otherwise return vector with per
sample loss | [
"Define",
"loss",
"of",
"TF",
"graph",
":",
"param",
"y",
":",
"correct",
"labels",
":",
"param",
"model",
":",
"output",
"of",
"the",
"model",
":",
"param",
"mean",
":",
"boolean",
"indicating",
"whether",
"should",
"return",
"mean",
"of",
"loss",
"or",... | python | train | 30.478261 |
saltstack/salt | salt/modules/heat.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/heat.py#L365-L428 | def delete_stack(name=None, poll=0, timeout=60, profile=None):
'''
Delete a stack (heat stack-delete)
name
Name of the stack
poll
Poll and report events until stack complete
timeout
Stack creation timeout in minute
profile
Profile to use
CLI Examples:
... | [
"def",
"delete_stack",
"(",
"name",
"=",
"None",
",",
"poll",
"=",
"0",
",",
"timeout",
"=",
"60",
",",
"profile",
"=",
"None",
")",
":",
"h_client",
"=",
"_auth",
"(",
"profile",
")",
"ret",
"=",
"{",
"'result'",
":",
"True",
",",
"'comment'",
":"... | Delete a stack (heat stack-delete)
name
Name of the stack
poll
Poll and report events until stack complete
timeout
Stack creation timeout in minute
profile
Profile to use
CLI Examples:
.. code-block:: bash
salt '*' heat.delete_stack name=mystack po... | [
"Delete",
"a",
"stack",
"(",
"heat",
"stack",
"-",
"delete",
")"
] | python | train | 27.75 |
nvbn/thefuck | thefuck/types.py | https://github.com/nvbn/thefuck/blob/40ab4eb62db57627bff10cf029d29c94704086a2/thefuck/types.py#L165-L180 | def is_match(self, command):
"""Returns `True` if rule matches the command.
:type command: Command
:rtype: bool
"""
if command.output is None and self.requires_output:
return False
try:
with logs.debug_time(u'Trying rule: {};'.format(self.name))... | [
"def",
"is_match",
"(",
"self",
",",
"command",
")",
":",
"if",
"command",
".",
"output",
"is",
"None",
"and",
"self",
".",
"requires_output",
":",
"return",
"False",
"try",
":",
"with",
"logs",
".",
"debug_time",
"(",
"u'Trying rule: {};'",
".",
"format",... | Returns `True` if rule matches the command.
:type command: Command
:rtype: bool | [
"Returns",
"True",
"if",
"rule",
"matches",
"the",
"command",
"."
] | python | train | 28.4375 |
django-extensions/django-extensions | django_extensions/management/commands/pipchecker.py | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/pipchecker.py#L297-L313 | def check_other(self):
"""
If the requirement is frozen somewhere other than pypi or github, skip.
If you have a private pypi or use --extra-index-url, consider contributing
support here.
"""
if self.reqs:
self.stdout.write(self.style.ERROR("\nOnly pypi and g... | [
"def",
"check_other",
"(",
"self",
")",
":",
"if",
"self",
".",
"reqs",
":",
"self",
".",
"stdout",
".",
"write",
"(",
"self",
".",
"style",
".",
"ERROR",
"(",
"\"\\nOnly pypi and github based requirements are supported:\"",
")",
")",
"for",
"name",
",",
"re... | If the requirement is frozen somewhere other than pypi or github, skip.
If you have a private pypi or use --extra-index-url, consider contributing
support here. | [
"If",
"the",
"requirement",
"is",
"frozen",
"somewhere",
"other",
"than",
"pypi",
"or",
"github",
"skip",
"."
] | python | train | 48.176471 |
delph-in/pydelphin | delphin/itsdb.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/itsdb.py#L2201-L2221 | def size(self, table=None):
"""
Return the size, in bytes, of the profile or *table*.
If *table* is `None`, this function returns the size of the
whole profile (i.e. the sum of the table sizes). Otherwise, it
returns the size of *table*.
Note: if the file is gzipped, it... | [
"def",
"size",
"(",
"self",
",",
"table",
"=",
"None",
")",
":",
"size",
"=",
"0",
"if",
"table",
"is",
"None",
":",
"for",
"table",
"in",
"self",
".",
"relations",
":",
"size",
"+=",
"self",
".",
"size",
"(",
"table",
")",
"else",
":",
"try",
... | Return the size, in bytes, of the profile or *table*.
If *table* is `None`, this function returns the size of the
whole profile (i.e. the sum of the table sizes). Otherwise, it
returns the size of *table*.
Note: if the file is gzipped, it returns the compressed size. | [
"Return",
"the",
"size",
"in",
"bytes",
"of",
"the",
"profile",
"or",
"*",
"table",
"*",
"."
] | python | train | 32.47619 |
scoutapp/scout_apm_python | src/scout_apm/django/instruments/sql.py | https://github.com/scoutapp/scout_apm_python/blob/e5539ee23b8129be9b75d5007c88b6158b51294f/src/scout_apm/django/instruments/sql.py#L53-L65 | def install():
"""
Installs ScoutApm SQL Instrumentation by monkeypatching the `cursor`
method of BaseDatabaseWrapper, to return a wrapper that instruments any
calls going through it.
"""
@monkeypatch_method(BaseDatabaseWrapper)
def cursor(original, self, *args, ... | [
"def",
"install",
"(",
")",
":",
"@",
"monkeypatch_method",
"(",
"BaseDatabaseWrapper",
")",
"def",
"cursor",
"(",
"original",
",",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"original",
"(",
"*",
"args",
",",
"*",
"*... | Installs ScoutApm SQL Instrumentation by monkeypatching the `cursor`
method of BaseDatabaseWrapper, to return a wrapper that instruments any
calls going through it. | [
"Installs",
"ScoutApm",
"SQL",
"Instrumentation",
"by",
"monkeypatching",
"the",
"cursor",
"method",
"of",
"BaseDatabaseWrapper",
"to",
"return",
"a",
"wrapper",
"that",
"instruments",
"any",
"calls",
"going",
"through",
"it",
"."
] | python | train | 36.307692 |
fumitoh/modelx | modelx/core/model.py | https://github.com/fumitoh/modelx/blob/0180da34d052c44fb94dab9e115e218bbebfc9c3/modelx/core/model.py#L67-L79 | def get_nodes_with(self, obj):
"""Return nodes with `obj`."""
result = set()
if nx.__version__[0] == "1":
nodes = self.nodes_iter()
else:
nodes = self.nodes
for node in nodes:
if node[OBJ] == obj:
result.add(node)
retu... | [
"def",
"get_nodes_with",
"(",
"self",
",",
"obj",
")",
":",
"result",
"=",
"set",
"(",
")",
"if",
"nx",
".",
"__version__",
"[",
"0",
"]",
"==",
"\"1\"",
":",
"nodes",
"=",
"self",
".",
"nodes_iter",
"(",
")",
"else",
":",
"nodes",
"=",
"self",
"... | Return nodes with `obj`. | [
"Return",
"nodes",
"with",
"obj",
"."
] | python | valid | 24.384615 |
saltstack/salt | salt/modules/gnomedesktop.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gnomedesktop.py#L284-L296 | def set_(schema=None, key=None, user=None, value=None, **kwargs):
'''
Set key in a particular GNOME schema
CLI Example:
.. code-block:: bash
salt '*' gnome.set user=<username> schema=org.gnome.desktop.screensaver key=idle-activation-enabled value=False
'''
_gsession = _GSettings(user... | [
"def",
"set_",
"(",
"schema",
"=",
"None",
",",
"key",
"=",
"None",
",",
"user",
"=",
"None",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"_gsession",
"=",
"_GSettings",
"(",
"user",
"=",
"user",
",",
"schema",
"=",
"schema",
",... | Set key in a particular GNOME schema
CLI Example:
.. code-block:: bash
salt '*' gnome.set user=<username> schema=org.gnome.desktop.screensaver key=idle-activation-enabled value=False | [
"Set",
"key",
"in",
"a",
"particular",
"GNOME",
"schema"
] | python | train | 28.538462 |
chrislit/abydos | abydos/stemmer/_porter.py | https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/stemmer/_porter.py#L49-L74 | def _m_degree(self, term):
"""Return Porter helper function _m_degree value.
m-degree is equal to the number of V to C transitions
Parameters
----------
term : str
The word for which to calculate the m-degree
Returns
-------
int
... | [
"def",
"_m_degree",
"(",
"self",
",",
"term",
")",
":",
"mdeg",
"=",
"0",
"last_was_vowel",
"=",
"False",
"for",
"letter",
"in",
"term",
":",
"if",
"letter",
"in",
"self",
".",
"_vowels",
":",
"last_was_vowel",
"=",
"True",
"else",
":",
"if",
"last_was... | Return Porter helper function _m_degree value.
m-degree is equal to the number of V to C transitions
Parameters
----------
term : str
The word for which to calculate the m-degree
Returns
-------
int
The m-degree as defined in the Porter ... | [
"Return",
"Porter",
"helper",
"function",
"_m_degree",
"value",
"."
] | python | valid | 25.346154 |
dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L122-L147 | def detect_gpt(self, filename, offset, fs_guid):
"""Used by rawdisk.session.Session to match gpt partitions agains
filesystem plugins.
Args:
filename: device or file that it will read in order to detect the
filesystem
fs_id: filesystem guid to match
... | [
"def",
"detect_gpt",
"(",
"self",
",",
"filename",
",",
"offset",
",",
"fs_guid",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Detecting GPT partition type'",
")",
"if",
"fs_guid",
"not",
"in",
"self",
".",
"__gpt_plugins",
":",
"return",
"None",
... | Used by rawdisk.session.Session to match gpt partitions agains
filesystem plugins.
Args:
filename: device or file that it will read in order to detect the
filesystem
fs_id: filesystem guid to match
(ex. {EBD0A0A2-B9E5-4433-87C0-68B6B72699C7})
... | [
"Used",
"by",
"rawdisk",
".",
"session",
".",
"Session",
"to",
"match",
"gpt",
"partitions",
"agains",
"filesystem",
"plugins",
"."
] | python | train | 34.769231 |
nicolas-van/mailflash | mailflash.py | https://github.com/nicolas-van/mailflash/blob/794598d9df0e343bb1f64b03d09a68a540229774/mailflash.py#L410-L424 | def attach(self,
filename=None,
content_type=None,
data=None,
disposition=None,
headers=None):
"""Adds an attachment to the message.
:param filename: filename of attachment
:param content_type: file mimetype
:par... | [
"def",
"attach",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"content_type",
"=",
"None",
",",
"data",
"=",
"None",
",",
"disposition",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"self",
".",
"attachments",
".",
"append",
"(",
"Attachment"... | Adds an attachment to the message.
:param filename: filename of attachment
:param content_type: file mimetype
:param data: the raw file data
:param disposition: content-disposition (if any) | [
"Adds",
"an",
"attachment",
"to",
"the",
"message",
"."
] | python | test | 34 |
tisimst/mcerp | mcerp/__init__.py | https://github.com/tisimst/mcerp/blob/2bb8260c9ad2d58a806847f1b627b6451e407de1/mcerp/__init__.py#L1065-L1083 | def Triangular(low, peak, high, tag=None):
"""
A triangular random variate
Parameters
----------
low : scalar
Lower bound of the distribution support
peak : scalar
The location of the triangle's peak (low <= peak <= high)
high : scalar
Upper bound of the distribu... | [
"def",
"Triangular",
"(",
"low",
",",
"peak",
",",
"high",
",",
"tag",
"=",
"None",
")",
":",
"assert",
"low",
"<=",
"peak",
"<=",
"high",
",",
"'Triangular \"peak\" must lie between \"low\" and \"high\"'",
"low",
",",
"peak",
",",
"high",
"=",
"[",
"float",... | A triangular random variate
Parameters
----------
low : scalar
Lower bound of the distribution support
peak : scalar
The location of the triangle's peak (low <= peak <= high)
high : scalar
Upper bound of the distribution support | [
"A",
"triangular",
"random",
"variate",
"Parameters",
"----------",
"low",
":",
"scalar",
"Lower",
"bound",
"of",
"the",
"distribution",
"support",
"peak",
":",
"scalar",
"The",
"location",
"of",
"the",
"triangle",
"s",
"peak",
"(",
"low",
"<",
"=",
"peak",
... | python | train | 31 |
ArduPilot/MAVProxy | MAVProxy/modules/lib/MacOS/backend_wx.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1254-L1265 | def draw_if_interactive():
"""
This should be overriden in a windowing environment if drawing
should be done in interactive python mode
"""
DEBUG_MSG("draw_if_interactive()", 1, None)
if matplotlib.is_interactive():
figManager = Gcf.get_active()
if figManager is not None:
... | [
"def",
"draw_if_interactive",
"(",
")",
":",
"DEBUG_MSG",
"(",
"\"draw_if_interactive()\"",
",",
"1",
",",
"None",
")",
"if",
"matplotlib",
".",
"is_interactive",
"(",
")",
":",
"figManager",
"=",
"Gcf",
".",
"get_active",
"(",
")",
"if",
"figManager",
"is",... | This should be overriden in a windowing environment if drawing
should be done in interactive python mode | [
"This",
"should",
"be",
"overriden",
"in",
"a",
"windowing",
"environment",
"if",
"drawing",
"should",
"be",
"done",
"in",
"interactive",
"python",
"mode"
] | python | train | 28.75 |
rapidpro/expressions | python/temba_expressions/functions/excel.py | https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/python/temba_expressions/functions/excel.py#L157-L161 | def date(ctx, year, month, day):
"""
Defines a date value
"""
return _date(conversions.to_integer(year, ctx), conversions.to_integer(month, ctx), conversions.to_integer(day, ctx)) | [
"def",
"date",
"(",
"ctx",
",",
"year",
",",
"month",
",",
"day",
")",
":",
"return",
"_date",
"(",
"conversions",
".",
"to_integer",
"(",
"year",
",",
"ctx",
")",
",",
"conversions",
".",
"to_integer",
"(",
"month",
",",
"ctx",
")",
",",
"conversion... | Defines a date value | [
"Defines",
"a",
"date",
"value"
] | python | train | 38.2 |
fredericklussier/Lifepo4weredPy | lifepo4weredPy/functions.py | https://github.com/fredericklussier/Lifepo4weredPy/blob/f5b3fedf896d0d616bf5ae603953e5541d493640/lifepo4weredPy/functions.py#L60-L81 | def write(variable, value):
"""
write an element to LiFePO4wered.
:param variable: the element.
:type variable: Lifepo4weredEnum
:param int value: the value to write.
:return: the written value
:rtype: int
:raises ValueError: if variable parameter is not a member of Lifepo4weredEnum
... | [
"def",
"write",
"(",
"variable",
",",
"value",
")",
":",
"if",
"variable",
"not",
"in",
"variablesEnum",
":",
"raise",
"ValueError",
"(",
"'Use a lifepo4wered enum element as write element.'",
")",
"if",
"isinstance",
"(",
"value",
",",
"int",
")",
"is",
"False"... | write an element to LiFePO4wered.
:param variable: the element.
:type variable: Lifepo4weredEnum
:param int value: the value to write.
:return: the written value
:rtype: int
:raises ValueError: if variable parameter is not a member of Lifepo4weredEnum
:raises ValueError: if value is not an ... | [
"write",
"an",
"element",
"to",
"LiFePO4wered",
"."
] | python | train | 34.818182 |
waqasbhatti/astrobase | astrobase/lcfit/nonphysical.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcfit/nonphysical.py#L491-L676 | def legendre_fit_magseries(times, mags, errs, period,
legendredeg=10,
sigclip=30.0,
plotfit=False,
magsarefluxes=False,
verbose=True):
'''Fit an arbitrary-order Legendre series, vi... | [
"def",
"legendre_fit_magseries",
"(",
"times",
",",
"mags",
",",
"errs",
",",
"period",
",",
"legendredeg",
"=",
"10",
",",
"sigclip",
"=",
"30.0",
",",
"plotfit",
"=",
"False",
",",
"magsarefluxes",
"=",
"False",
",",
"verbose",
"=",
"True",
")",
":",
... | Fit an arbitrary-order Legendre series, via least squares, to the
magnitude/flux time series.
This is a series of the form::
p(x) = c_0*L_0(x) + c_1*L_1(x) + c_2*L_2(x) + ... + c_n*L_n(x)
where L_i's are Legendre polynomials (also called "Legendre functions of the
first kind") and c_i's are t... | [
"Fit",
"an",
"arbitrary",
"-",
"order",
"Legendre",
"series",
"via",
"least",
"squares",
"to",
"the",
"magnitude",
"/",
"flux",
"time",
"series",
"."
] | python | valid | 36.580645 |
pricingassistant/mrq | mrq/queue_raw.py | https://github.com/pricingassistant/mrq/blob/d0a5a34de9cba38afa94fb7c9e17f9b570b79a50/mrq/queue_raw.py#L46-L50 | def get_known_subqueues(self):
""" Returns all known subqueues """
if not self.has_subqueues:
return set()
return set(context.connections.redis.smembers(self.redis_key_known_subqueues)) | [
"def",
"get_known_subqueues",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_subqueues",
":",
"return",
"set",
"(",
")",
"return",
"set",
"(",
"context",
".",
"connections",
".",
"redis",
".",
"smembers",
"(",
"self",
".",
"redis_key_known_subqueues",... | Returns all known subqueues | [
"Returns",
"all",
"known",
"subqueues"
] | python | train | 43.4 |
gaqzi/py-gocd | gocd/server.py | https://github.com/gaqzi/py-gocd/blob/6fe5b62dea51e665c11a343aba5fc98e130c5c63/gocd/server.py#L135-L158 | def request(self, path, data=None, headers=None, method=None):
"""Performs a HTTP request to the Go server
Args:
path (str): The full path on the Go server to request.
This includes any query string attributes.
data (str, dict, bool, optional): If any data is present thi... | [
"def",
"request",
"(",
"self",
",",
"path",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"method",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"data",
"=",
"data",
".",
"encode",
"(",
"'utf-8'",
")... | Performs a HTTP request to the Go server
Args:
path (str): The full path on the Go server to request.
This includes any query string attributes.
data (str, dict, bool, optional): If any data is present this
request will become a POST request.
headers (dict,... | [
"Performs",
"a",
"HTTP",
"request",
"to",
"the",
"Go",
"server"
] | python | valid | 35.666667 |
ssalentin/plip | plip/modules/chimeraplip.py | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/chimeraplip.py#L114-L139 | def show_cationpi(self):
"""Visualizes cation-pi interactions"""
grp = self.getPseudoBondGroup("Cation-Pi-%i" % self.tid, associateWith=[self.model])
grp.lineWidth = 3
grp.lineType = self.chimera.Dash
for i, cat in enumerate(self.plcomplex.pication):
m = self.model
... | [
"def",
"show_cationpi",
"(",
"self",
")",
":",
"grp",
"=",
"self",
".",
"getPseudoBondGroup",
"(",
"\"Cation-Pi-%i\"",
"%",
"self",
".",
"tid",
",",
"associateWith",
"=",
"[",
"self",
".",
"model",
"]",
")",
"grp",
".",
"lineWidth",
"=",
"3",
"grp",
".... | Visualizes cation-pi interactions | [
"Visualizes",
"cation",
"-",
"pi",
"interactions"
] | python | train | 39.923077 |
mardix/Mocha | mocha/core.py | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L445-L471 | def _get_action_endpoint(action):
"""
Return the endpoint base on the view's action
:param action:
:return:
"""
_endpoint = None
if is_method(action):
if hasattr(action, "_rule_cache"):
rc = action._rule_cache
if rc:
k = list(rc.keys())[0]
... | [
"def",
"_get_action_endpoint",
"(",
"action",
")",
":",
"_endpoint",
"=",
"None",
"if",
"is_method",
"(",
"action",
")",
":",
"if",
"hasattr",
"(",
"action",
",",
"\"_rule_cache\"",
")",
":",
"rc",
"=",
"action",
".",
"_rule_cache",
"if",
"rc",
":",
"k",... | Return the endpoint base on the view's action
:param action:
:return: | [
"Return",
"the",
"endpoint",
"base",
"on",
"the",
"view",
"s",
"action",
":",
"param",
"action",
":",
":",
"return",
":"
] | python | train | 37.148148 |
softlayer/softlayer-python | SoftLayer/CLI/ticket/create.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/ticket/create.py#L26-L48 | def cli(env, title, subject_id, body, hardware_identifier, virtual_identifier, priority):
"""Create a support ticket."""
ticket_mgr = SoftLayer.TicketManager(env.client)
if body is None:
body = click.edit('\n\n' + ticket.TEMPLATE_MSG)
created_ticket = ticket_mgr.create_ticket(
title=tit... | [
"def",
"cli",
"(",
"env",
",",
"title",
",",
"subject_id",
",",
"body",
",",
"hardware_identifier",
",",
"virtual_identifier",
",",
"priority",
")",
":",
"ticket_mgr",
"=",
"SoftLayer",
".",
"TicketManager",
"(",
"env",
".",
"client",
")",
"if",
"body",
"i... | Create a support ticket. | [
"Create",
"a",
"support",
"ticket",
"."
] | python | train | 40.782609 |
janpipek/physt | physt/binnings.py | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L154-L167 | def adapt(self, other: 'BinningBase'):
"""Adapt this binning so that it contains all bins of another binning.
Parameters
----------
other: BinningBase
"""
# TODO: in-place arg
if np.array_equal(self.bins, other.bins):
return None, None
elif no... | [
"def",
"adapt",
"(",
"self",
",",
"other",
":",
"'BinningBase'",
")",
":",
"# TODO: in-place arg",
"if",
"np",
".",
"array_equal",
"(",
"self",
".",
"bins",
",",
"other",
".",
"bins",
")",
":",
"return",
"None",
",",
"None",
"elif",
"not",
"self",
".",... | Adapt this binning so that it contains all bins of another binning.
Parameters
----------
other: BinningBase | [
"Adapt",
"this",
"binning",
"so",
"that",
"it",
"contains",
"all",
"bins",
"of",
"another",
"binning",
"."
] | python | train | 32.071429 |
pysathq/pysat | pysat/formula.py | https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/formula.py#L1293-L1335 | def to_fp(self, file_pointer, comments=None):
"""
The method can be used to save a CNF+ formula into a file pointer.
The file pointer is expected as an argument. Additionally,
supplementary comment lines can be specified in the ``comments``
parameter.
... | [
"def",
"to_fp",
"(",
"self",
",",
"file_pointer",
",",
"comments",
"=",
"None",
")",
":",
"# saving formula's internal comments",
"for",
"c",
"in",
"self",
".",
"comments",
":",
"print",
"(",
"c",
",",
"file",
"=",
"file_pointer",
")",
"# saving externally spe... | The method can be used to save a CNF+ formula into a file pointer.
The file pointer is expected as an argument. Additionally,
supplementary comment lines can be specified in the ``comments``
parameter.
:param fname: a file name where to store the formula.
:pa... | [
"The",
"method",
"can",
"be",
"used",
"to",
"save",
"a",
"CNF",
"+",
"formula",
"into",
"a",
"file",
"pointer",
".",
"The",
"file",
"pointer",
"is",
"expected",
"as",
"an",
"argument",
".",
"Additionally",
"supplementary",
"comment",
"lines",
"can",
"be",
... | python | train | 34.651163 |
treycucco/bidon | bidon/xml/stream_writer.py | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/xml/stream_writer.py#L150-L168 | def no_inner_space(self, *, outer=True):
"""Default spacing for all things written is ignored in this context.
:outer: boolean, if True the typical padding and newline are added before the first and after
the last things written
"""
if outer:
self._pad()
indent_was = self._indent... | [
"def",
"no_inner_space",
"(",
"self",
",",
"*",
",",
"outer",
"=",
"True",
")",
":",
"if",
"outer",
":",
"self",
".",
"_pad",
"(",
")",
"indent_was",
"=",
"self",
".",
"_indent",
"self",
".",
"_indent",
"=",
"None",
"try",
":",
"yield",
"finally",
... | Default spacing for all things written is ignored in this context.
:outer: boolean, if True the typical padding and newline are added before the first and after
the last things written | [
"Default",
"spacing",
"for",
"all",
"things",
"written",
"is",
"ignored",
"in",
"this",
"context",
"."
] | python | train | 22.631579 |
odlgroup/odl | odl/phantom/misc_phantoms.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/phantom/misc_phantoms.py#L48-L99 | def _submarine_2d_smooth(space, taper):
"""Return a 2d smooth 'submarine' phantom."""
def logistic(x, c):
"""Smoothed step function from 0 to 1, centered at 0."""
return 1. / (1 + np.exp(-c * x))
def blurred_ellipse(x):
"""Blurred characteristic function of an ellipse.
If ... | [
"def",
"_submarine_2d_smooth",
"(",
"space",
",",
"taper",
")",
":",
"def",
"logistic",
"(",
"x",
",",
"c",
")",
":",
"\"\"\"Smoothed step function from 0 to 1, centered at 0.\"\"\"",
"return",
"1.",
"/",
"(",
"1",
"+",
"np",
".",
"exp",
"(",
"-",
"c",
"*",
... | Return a 2d smooth 'submarine' phantom. | [
"Return",
"a",
"2d",
"smooth",
"submarine",
"phantom",
"."
] | python | train | 36.365385 |
bitcraze/crazyflie-lib-python | cflib/crazyflie/toccache.py | https://github.com/bitcraze/crazyflie-lib-python/blob/f6ebb4eb315bbe6e02db518936ac17fb615b2af8/cflib/crazyflie/toccache.py#L112-L123 | def _decoder(self, obj):
""" Decode a toc element leaf-node """
if '__class__' in obj:
elem = eval(obj['__class__'])()
elem.ident = obj['ident']
elem.group = str(obj['group'])
elem.name = str(obj['name'])
elem.ctype = str(obj['ctype'])
... | [
"def",
"_decoder",
"(",
"self",
",",
"obj",
")",
":",
"if",
"'__class__'",
"in",
"obj",
":",
"elem",
"=",
"eval",
"(",
"obj",
"[",
"'__class__'",
"]",
")",
"(",
")",
"elem",
".",
"ident",
"=",
"obj",
"[",
"'ident'",
"]",
"elem",
".",
"group",
"="... | Decode a toc element leaf-node | [
"Decode",
"a",
"toc",
"element",
"leaf",
"-",
"node"
] | python | train | 35.666667 |
openstates/billy | billy/web/public/views/bills.py | https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/bills.py#L428-L465 | def document(request, abbr, session, bill_id, doc_id):
'''
Context:
- abbr
- session
- bill
- version
- metadata
- nav_active
Templates:
- billy/web/public/document.html
'''
# get fixed version
fixed_bill_id = fix_bill_id(bill_id)
# re... | [
"def",
"document",
"(",
"request",
",",
"abbr",
",",
"session",
",",
"bill_id",
",",
"doc_id",
")",
":",
"# get fixed version",
"fixed_bill_id",
"=",
"fix_bill_id",
"(",
"bill_id",
")",
"# redirect if URL's id isn't fixed id without spaces",
"if",
"fixed_bill_id",
"."... | Context:
- abbr
- session
- bill
- version
- metadata
- nav_active
Templates:
- billy/web/public/document.html | [
"Context",
":",
"-",
"abbr",
"-",
"session",
"-",
"bill",
"-",
"version",
"-",
"metadata",
"-",
"nav_active"
] | python | train | 30.710526 |
camptocamp/marabunta | marabunta/core.py | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/core.py#L149-L154 | def main():
"""Parse the command line and run :func:`migrate`."""
parser = get_args_parser()
args = parser.parse_args()
config = Config.from_parse_args(args)
migrate(config) | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"get_args_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"config",
"=",
"Config",
".",
"from_parse_args",
"(",
"args",
")",
"migrate",
"(",
"config",
")"
] | Parse the command line and run :func:`migrate`. | [
"Parse",
"the",
"command",
"line",
"and",
"run",
":",
"func",
":",
"migrate",
"."
] | python | train | 31.333333 |
apache/incubator-mxnet | python/mxnet/gluon/data/dataloader.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L163-L170 | def worker_loop_v1(dataset, key_queue, data_queue, batchify_fn):
"""Worker loop for multiprocessing DataLoader."""
while True:
idx, samples = key_queue.get()
if idx is None:
break
batch = batchify_fn([dataset[i] for i in samples])
data_queue.put((idx, batch)) | [
"def",
"worker_loop_v1",
"(",
"dataset",
",",
"key_queue",
",",
"data_queue",
",",
"batchify_fn",
")",
":",
"while",
"True",
":",
"idx",
",",
"samples",
"=",
"key_queue",
".",
"get",
"(",
")",
"if",
"idx",
"is",
"None",
":",
"break",
"batch",
"=",
"bat... | Worker loop for multiprocessing DataLoader. | [
"Worker",
"loop",
"for",
"multiprocessing",
"DataLoader",
"."
] | python | train | 38 |
iterative/dvc | dvc/utils/__init__.py | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L288-L302 | def colorize(message, color=None):
"""Returns a message in a specified color."""
if not color:
return message
colors = {
"green": colorama.Fore.GREEN,
"yellow": colorama.Fore.YELLOW,
"blue": colorama.Fore.BLUE,
"red": colorama.Fore.RED,
}
return "{color}{mes... | [
"def",
"colorize",
"(",
"message",
",",
"color",
"=",
"None",
")",
":",
"if",
"not",
"color",
":",
"return",
"message",
"colors",
"=",
"{",
"\"green\"",
":",
"colorama",
".",
"Fore",
".",
"GREEN",
",",
"\"yellow\"",
":",
"colorama",
".",
"Fore",
".",
... | Returns a message in a specified color. | [
"Returns",
"a",
"message",
"in",
"a",
"specified",
"color",
"."
] | python | train | 27.133333 |
Hironsan/anago | anago/preprocessing.py | https://github.com/Hironsan/anago/blob/66a97f91c41f9613b736892e9762dccb9c28f623/anago/preprocessing.py#L130-L145 | def inverse_transform(self, y, lengths=None):
"""Return label strings.
Args:
y: label id matrix.
lengths: sentences length.
Returns:
list: list of list of strings.
"""
y = np.argmax(y, -1)
inverse_y = [self._label_vocab.id2doc(ids) fo... | [
"def",
"inverse_transform",
"(",
"self",
",",
"y",
",",
"lengths",
"=",
"None",
")",
":",
"y",
"=",
"np",
".",
"argmax",
"(",
"y",
",",
"-",
"1",
")",
"inverse_y",
"=",
"[",
"self",
".",
"_label_vocab",
".",
"id2doc",
"(",
"ids",
")",
"for",
"ids... | Return label strings.
Args:
y: label id matrix.
lengths: sentences length.
Returns:
list: list of list of strings. | [
"Return",
"label",
"strings",
"."
] | python | train | 27.75 |
NoviceLive/intellicoder | intellicoder/msbuild/locators.py | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/msbuild/locators.py#L61-L87 | def get_bin(self, arch='x86'):
"""
Get binaries of Visual C++.
"""
bin_dir = os.path.join(self.vc_dir, 'bin')
if arch == 'x86':
arch = ''
cl_path = os.path.join(bin_dir, arch, 'cl.exe')
link_path = os.path.join(bin_dir, arch, 'link.exe')
ml_nam... | [
"def",
"get_bin",
"(",
"self",
",",
"arch",
"=",
"'x86'",
")",
":",
"bin_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"vc_dir",
",",
"'bin'",
")",
"if",
"arch",
"==",
"'x86'",
":",
"arch",
"=",
"''",
"cl_path",
"=",
"os",
".",
"... | Get binaries of Visual C++. | [
"Get",
"binaries",
"of",
"Visual",
"C",
"++",
"."
] | python | train | 43.444444 |
materialsproject/pymatgen | pymatgen/core/tensors.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/tensors.py#L872-L889 | def refine_rotation(self):
"""
Helper method for refining rotation matrix by ensuring
that second and third rows are perpindicular to the first.
Gets new y vector from an orthogonal projection of x onto y
and the new z vector from a cross product of the new x and y
Args:... | [
"def",
"refine_rotation",
"(",
"self",
")",
":",
"new_x",
",",
"y",
"=",
"get_uvec",
"(",
"self",
"[",
"0",
"]",
")",
",",
"get_uvec",
"(",
"self",
"[",
"1",
"]",
")",
"# Get a projection on y",
"new_y",
"=",
"y",
"-",
"np",
".",
"dot",
"(",
"new_x... | Helper method for refining rotation matrix by ensuring
that second and third rows are perpindicular to the first.
Gets new y vector from an orthogonal projection of x onto y
and the new z vector from a cross product of the new x and y
Args:
tol to test for rotation
... | [
"Helper",
"method",
"for",
"refining",
"rotation",
"matrix",
"by",
"ensuring",
"that",
"second",
"and",
"third",
"rows",
"are",
"perpindicular",
"to",
"the",
"first",
".",
"Gets",
"new",
"y",
"vector",
"from",
"an",
"orthogonal",
"projection",
"of",
"x",
"on... | python | train | 34.722222 |
twilio/twilio-python | twilio/rest/api/v2010/account/incoming_phone_number/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/incoming_phone_number/__init__.py#L839-L903 | def update(self, account_sid=values.unset, api_version=values.unset,
friendly_name=values.unset, sms_application_sid=values.unset,
sms_fallback_method=values.unset, sms_fallback_url=values.unset,
sms_method=values.unset, sms_url=values.unset,
status_callback=v... | [
"def",
"update",
"(",
"self",
",",
"account_sid",
"=",
"values",
".",
"unset",
",",
"api_version",
"=",
"values",
".",
"unset",
",",
"friendly_name",
"=",
"values",
".",
"unset",
",",
"sms_application_sid",
"=",
"values",
".",
"unset",
",",
"sms_fallback_met... | Update the IncomingPhoneNumberInstance
:param unicode account_sid: The SID of the Account that created the resource to update
:param unicode api_version: The API version to use for incoming calls made to the phone number
:param unicode friendly_name: A string to describe the resource
:p... | [
"Update",
"the",
"IncomingPhoneNumberInstance"
] | python | train | 64.107692 |
saltstack/salt | salt/runners/fileserver.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L435-L474 | def lock(backend=None, remote=None):
'''
.. versionadded:: 2015.5.0
Set a fileserver update lock for VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`).
.. note::
This will only operate on enabled backends... | [
"def",
"lock",
"(",
"backend",
"=",
"None",
",",
"remote",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"locked",
",",
"errors",
"=",
"fileserver",
".",
"lock",
"(",
"back",
"=",
"backend... | .. versionadded:: 2015.5.0
Set a fileserver update lock for VCS fileserver backends (:mod:`git
<salt.fileserver.gitfs>`, :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn
<salt.fileserver.svnfs>`).
.. note::
This will only operate on enabled backends (those configured in
:conf_master:`files... | [
"..",
"versionadded",
"::",
"2015",
".",
"5",
".",
"0"
] | python | train | 29.85 |
apache/incubator-superset | superset/views/base.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/base.py#L286-L293 | def get_all_permissions(self):
"""Returns a set of tuples with the perm name and view menu name"""
perms = set()
for role in self.get_user_roles():
for perm_view in role.permissions:
t = (perm_view.permission.name, perm_view.view_menu.name)
perms.add(t... | [
"def",
"get_all_permissions",
"(",
"self",
")",
":",
"perms",
"=",
"set",
"(",
")",
"for",
"role",
"in",
"self",
".",
"get_user_roles",
"(",
")",
":",
"for",
"perm_view",
"in",
"role",
".",
"permissions",
":",
"t",
"=",
"(",
"perm_view",
".",
"permissi... | Returns a set of tuples with the perm name and view menu name | [
"Returns",
"a",
"set",
"of",
"tuples",
"with",
"the",
"perm",
"name",
"and",
"view",
"menu",
"name"
] | python | train | 41.875 |
pr-omethe-us/PyKED | pyked/converters.py | https://github.com/pr-omethe-us/PyKED/blob/d9341a068c1099049a3f1de41c512591f342bf64/pyked/converters.py#L318-L471 | def get_datapoints(root):
"""Parse datapoints with ignition delay from file.
Args:
root (`~xml.etree.ElementTree.Element`): Root of ReSpecTh XML file
Returns:
properties (`dict`): Dictionary with ignition delay data
"""
# Shock tube experiment will have one data group, while RCM ma... | [
"def",
"get_datapoints",
"(",
"root",
")",
":",
"# Shock tube experiment will have one data group, while RCM may have one",
"# or two (one for ignition delay, one for volume-history)",
"dataGroups",
"=",
"root",
".",
"findall",
"(",
"'dataGroup'",
")",
"if",
"not",
"dataGroups",
... | Parse datapoints with ignition delay from file.
Args:
root (`~xml.etree.ElementTree.Element`): Root of ReSpecTh XML file
Returns:
properties (`dict`): Dictionary with ignition delay data | [
"Parse",
"datapoints",
"with",
"ignition",
"delay",
"from",
"file",
"."
] | python | train | 44.688312 |
belbio/bel | bel/lang/bel_specification.py | https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/lang/bel_specification.py#L400-L448 | def add_functions(spec_dict: Mapping[str, Any]) -> Mapping[str, Any]:
"""Add function keys to spec_dict
Args:
spec_dict (Mapping[str, Any]): bel specification dictionary
Returns:
Mapping[str, Any]: bel specification dictionary with added function keys
"""
# Class 'Mapping' does no... | [
"def",
"add_functions",
"(",
"spec_dict",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Mapping",
"[",
"str",
",",
"Any",
"]",
":",
"# Class 'Mapping' does not define '__setitem__', so the '[]' operator cannot be used on its instances",
"spec_dict",
"[",
"\"f... | Add function keys to spec_dict
Args:
spec_dict (Mapping[str, Any]): bel specification dictionary
Returns:
Mapping[str, Any]: bel specification dictionary with added function keys | [
"Add",
"function",
"keys",
"to",
"spec_dict"
] | python | train | 40.102041 |
radjkarl/imgProcessor | imgProcessor/camera/flatField/vignettingFromRandomSteps.py | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L114-L167 | def addImg(self, img, maxShear=0.015, maxRot=100, minMatches=12,
borderWidth=3): # borderWidth=100
"""
Args:
img (path or array): image containing the same object as in the reference image
Kwargs:
maxShear (float): In order to define a good fit, refe... | [
"def",
"addImg",
"(",
"self",
",",
"img",
",",
"maxShear",
"=",
"0.015",
",",
"maxRot",
"=",
"100",
",",
"minMatches",
"=",
"12",
",",
"borderWidth",
"=",
"3",
")",
":",
"# borderWidth=100\r",
"try",
":",
"fit",
",",
"img",
",",
"H",
",",
"H_inv",
... | Args:
img (path or array): image containing the same object as in the reference image
Kwargs:
maxShear (float): In order to define a good fit, refect higher shear values between
this and the reference image
maxRot (float): Same for rotation
... | [
"Args",
":",
"img",
"(",
"path",
"or",
"array",
")",
":",
"image",
"containing",
"the",
"same",
"object",
"as",
"in",
"the",
"reference",
"image",
"Kwargs",
":",
"maxShear",
"(",
"float",
")",
":",
"In",
"order",
"to",
"define",
"a",
"good",
"fit",
"... | python | train | 38.018519 |
Azure/azure-cosmos-table-python | azure-cosmosdb-table/azure/cosmosdb/table/tablebatch.py | https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/azure/cosmosdb/table/tablebatch.py#L162-L178 | def insert_or_merge_entity(self, entity):
'''
Adds an insert or merge entity operation to the batch. See
:func:`~azure.storage.table.tableservice.TableService.insert_or_merge_entity` for more
information on insert or merge operations.
The operation will not be executed until t... | [
"def",
"insert_or_merge_entity",
"(",
"self",
",",
"entity",
")",
":",
"request",
"=",
"_insert_or_merge_entity",
"(",
"entity",
",",
"self",
".",
"_require_encryption",
",",
"self",
".",
"_key_encryption_key",
")",
"self",
".",
"_add_to_batch",
"(",
"entity",
"... | Adds an insert or merge entity operation to the batch. See
:func:`~azure.storage.table.tableservice.TableService.insert_or_merge_entity` for more
information on insert or merge operations.
The operation will not be executed until the batch is committed.
:param entity:
The... | [
"Adds",
"an",
"insert",
"or",
"merge",
"entity",
"operation",
"to",
"the",
"batch",
".",
"See",
":",
"func",
":",
"~azure",
".",
"storage",
".",
"table",
".",
"tableservice",
".",
"TableService",
".",
"insert_or_merge_entity",
"for",
"more",
"information",
"... | python | train | 46.705882 |
apache/incubator-heron | heron/tools/admin/src/python/standalone.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/admin/src/python/standalone.py#L641-L673 | def start_master_nodes(masters, cl_args):
'''
Start master nodes
'''
pids = []
for master in masters:
Log.info("Starting master on %s" % master)
cmd = "%s agent -config %s >> /tmp/nomad_server_log 2>&1 &" \
% (get_nomad_path(cl_args), get_nomad_master_config_file(cl_args))
if not is_self... | [
"def",
"start_master_nodes",
"(",
"masters",
",",
"cl_args",
")",
":",
"pids",
"=",
"[",
"]",
"for",
"master",
"in",
"masters",
":",
"Log",
".",
"info",
"(",
"\"Starting master on %s\"",
"%",
"master",
")",
"cmd",
"=",
"\"%s agent -config %s >> /tmp/nomad_server... | Start master nodes | [
"Start",
"master",
"nodes"
] | python | valid | 30.69697 |
openthread/openthread | tools/harness-automation/autothreadharness/pdu_controller.py | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/pdu_controller.py#L118-L123 | def until(self, regex):
"""Wait until the regex encountered
"""
logger.debug('waiting for %s', regex)
r = re.compile(regex, re.M)
self.tn.expect([r]) | [
"def",
"until",
"(",
"self",
",",
"regex",
")",
":",
"logger",
".",
"debug",
"(",
"'waiting for %s'",
",",
"regex",
")",
"r",
"=",
"re",
".",
"compile",
"(",
"regex",
",",
"re",
".",
"M",
")",
"self",
".",
"tn",
".",
"expect",
"(",
"[",
"r",
"]... | Wait until the regex encountered | [
"Wait",
"until",
"the",
"regex",
"encountered"
] | python | train | 30.666667 |
peerplays-network/python-peerplays | peerplays/peerplays.py | https://github.com/peerplays-network/python-peerplays/blob/188f04238e7e21d5f73e9b01099eea44289ef6b7/peerplays/peerplays.py#L1178-L1210 | def betting_market_rules_update(
self, rules_id, names, descriptions, account=None, **kwargs
):
""" Update betting market rules
:param str rules_id: Id of the betting market rules to update
:param list names: Internationalized names, e.g. ``[['de', 'Foo'],
['... | [
"def",
"betting_market_rules_update",
"(",
"self",
",",
"rules_id",
",",
"names",
",",
"descriptions",
",",
"account",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"isinstance",
"(",
"names",
",",
"list",
")",
"assert",
"isinstance",
"(",
"des... | Update betting market rules
:param str rules_id: Id of the betting market rules to update
:param list names: Internationalized names, e.g. ``[['de', 'Foo'],
['en', 'bar']]``
:param list descriptions: Internationalized descriptions, e.g.
``[['de', 'Foo... | [
"Update",
"betting",
"market",
"rules"
] | python | train | 40.424242 |
StackStorm/pybind | pybind/nos/v6_0_2f/rmon/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rmon/__init__.py#L94-L115 | def _set_event_entry(self, v, load=False):
"""
Setter method for event_entry, mapped from YANG variable /rmon/event_entry (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_event_entry is considered as a private
method. Backends looking to populate this variable ... | [
"def",
"_set_event_entry",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"ba... | Setter method for event_entry, mapped from YANG variable /rmon/event_entry (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_event_entry is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_event_entry()... | [
"Setter",
"method",
"for",
"event_entry",
"mapped",
"from",
"YANG",
"variable",
"/",
"rmon",
"/",
"event_entry",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
"YANG",
"file... | python | train | 131.772727 |
proycon/clam | clam/clamservice.py | https://github.com/proycon/clam/blob/09d15cfc26d7cbe0f5976cdd5424dc446d10dbf3/clam/clamservice.py#L1447-L1473 | def deleteinputfile(project, filename, credentials=None):
"""Delete an input file"""
user, oauth_access_token = parsecredentials(credentials) #pylint: disable=unused-variable
filename = filename.replace("..","") #Simple security
if len(filename) == 0:
#Deleting all input fi... | [
"def",
"deleteinputfile",
"(",
"project",
",",
"filename",
",",
"credentials",
"=",
"None",
")",
":",
"user",
",",
"oauth_access_token",
"=",
"parsecredentials",
"(",
"credentials",
")",
"#pylint: disable=unused-variable",
"filename",
"=",
"filename",
".",
"replace"... | Delete an input file | [
"Delete",
"an",
"input",
"file"
] | python | train | 43.592593 |
bsolomon1124/pyfinance | pyfinance/utils.py | https://github.com/bsolomon1124/pyfinance/blob/c95925209a809b4e648e79cbeaf7711d8e5ff1a6/pyfinance/utils.py#L382-L415 | def dropout(a, p=0.5, inplace=False):
"""Randomly set elements from `a` equal to zero, with proportion `p`.
Similar in concept to the dropout technique employed within
neural networks.
Parameters
----------
a: numpy.ndarray
Array to be modified.
p: float in [0, 1]
... | [
"def",
"dropout",
"(",
"a",
",",
"p",
"=",
"0.5",
",",
"inplace",
"=",
"False",
")",
":",
"dt",
"=",
"a",
".",
"dtype",
"if",
"p",
"==",
"0.5",
":",
"# Can't pass float dtype to `randint` directly.\r",
"rand",
"=",
"np",
".",
"random",
".",
"randint",
... | Randomly set elements from `a` equal to zero, with proportion `p`.
Similar in concept to the dropout technique employed within
neural networks.
Parameters
----------
a: numpy.ndarray
Array to be modified.
p: float in [0, 1]
Expected proportion of elements in the resul... | [
"Randomly",
"set",
"elements",
"from",
"a",
"equal",
"to",
"zero",
"with",
"proportion",
"p",
".",
"Similar",
"in",
"concept",
"to",
"the",
"dropout",
"technique",
"employed",
"within",
"neural",
"networks",
".",
"Parameters",
"----------",
"a",
":",
"numpy",
... | python | train | 27.029412 |
klahnakoski/pyLibrary | jx_elasticsearch/meta.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/meta.py#L307-L515 | def _update_cardinality(self, column):
"""
QUERY ES TO FIND CARDINALITY AND PARTITIONS FOR A SIMPLE COLUMN
"""
now = Date.now()
if column.es_index in self.index_does_not_exist:
return
if column.jx_type in STRUCT:
Log.error("not supported")
... | [
"def",
"_update_cardinality",
"(",
"self",
",",
"column",
")",
":",
"now",
"=",
"Date",
".",
"now",
"(",
")",
"if",
"column",
".",
"es_index",
"in",
"self",
".",
"index_does_not_exist",
":",
"return",
"if",
"column",
".",
"jx_type",
"in",
"STRUCT",
":",
... | QUERY ES TO FIND CARDINALITY AND PARTITIONS FOR A SIMPLE COLUMN | [
"QUERY",
"ES",
"TO",
"FIND",
"CARDINALITY",
"AND",
"PARTITIONS",
"FOR",
"A",
"SIMPLE",
"COLUMN"
] | python | train | 45.741627 |
samjabrahams/anchorhub | anchorhub/messages.py | https://github.com/samjabrahams/anchorhub/blob/5ade359b08297d4003a5f477389c01de9e634b54/anchorhub/messages.py#L34-L47 | def print_no_files_found(opts):
"""
Prints message that no files were found in the input directory with the
given list of extensions.
:param opts: Namespace object created from command-line arguments. Must
have the attributes 'extensions' and 'input'
"""
msg = "No files found with [" +', '... | [
"def",
"print_no_files_found",
"(",
"opts",
")",
":",
"msg",
"=",
"\"No files found with [\"",
"+",
"', '",
".",
"join",
"(",
"opts",
".",
"extensions",
")",
"+",
"\"] \"",
"msg",
"+=",
"\"extension\"",
"+",
"(",
"\"s \"",
"if",
"len",
"(",
"opts",
".",
... | Prints message that no files were found in the input directory with the
given list of extensions.
:param opts: Namespace object created from command-line arguments. Must
have the attributes 'extensions' and 'input' | [
"Prints",
"message",
"that",
"no",
"files",
"were",
"found",
"in",
"the",
"input",
"directory",
"with",
"the",
"given",
"list",
"of",
"extensions",
"."
] | python | train | 36.5 |
mcs07/PubChemPy | pubchempy.py | https://github.com/mcs07/PubChemPy/blob/e3c4f4a9b6120433e5cc3383464c7a79e9b2b86e/pubchempy.py#L780-L782 | def bonds(self):
"""List of :class:`Bonds <pubchempy.Bond>` between :class:`Atoms <pubchempy.Atom>` in this Compound."""
return sorted(self._bonds.values(), key=lambda x: (x.aid1, x.aid2)) | [
"def",
"bonds",
"(",
"self",
")",
":",
"return",
"sorted",
"(",
"self",
".",
"_bonds",
".",
"values",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"(",
"x",
".",
"aid1",
",",
"x",
".",
"aid2",
")",
")"
] | List of :class:`Bonds <pubchempy.Bond>` between :class:`Atoms <pubchempy.Atom>` in this Compound. | [
"List",
"of",
":",
"class",
":",
"Bonds",
"<pubchempy",
".",
"Bond",
">",
"between",
":",
"class",
":",
"Atoms",
"<pubchempy",
".",
"Atom",
">",
"in",
"this",
"Compound",
"."
] | python | train | 67.333333 |
kytos/kytos-utils | kytos/utils/client.py | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/client.py#L33-L51 | def make_request(endpoint, **kwargs):
"""Send a request to server."""
data = kwargs.get('json', [])
package = kwargs.get('package', None)
method = kwargs.get('method', 'GET')
function = getattr(requests, method.lower())
try:
if package:
respo... | [
"def",
"make_request",
"(",
"endpoint",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"get",
"(",
"'json'",
",",
"[",
"]",
")",
"package",
"=",
"kwargs",
".",
"get",
"(",
"'package'",
",",
"None",
")",
"method",
"=",
"kwargs",
".",... | Send a request to server. | [
"Send",
"a",
"request",
"to",
"server",
"."
] | python | train | 34 |
noahbenson/neuropythy | neuropythy/util/conf.py | https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/util/conf.py#L290-L310 | def str_to_credentials(s):
'''
str_to_credentials(s) yields (key, secret) if the given string is a valid representation of a
set of credentials. Valid representations include '<key>:<secret>' and '<key>\n<secret>'. All
initial and trailing whitespace is always stripped from both key and scret. If a ... | [
"def",
"str_to_credentials",
"(",
"s",
")",
":",
"if",
"not",
"pimms",
".",
"is_str",
"(",
"s",
")",
":",
"raise",
"ValueError",
"(",
"'str_to_credentials requires a string argument'",
")",
"s",
"=",
"s",
".",
"strip",
"(",
")",
"# First try a json object:",
"... | str_to_credentials(s) yields (key, secret) if the given string is a valid representation of a
set of credentials. Valid representations include '<key>:<secret>' and '<key>\n<secret>'. All
initial and trailing whitespace is always stripped from both key and scret. If a newline
appears in the string, th... | [
"str_to_credentials",
"(",
"s",
")",
"yields",
"(",
"key",
"secret",
")",
"if",
"the",
"given",
"string",
"is",
"a",
"valid",
"representation",
"of",
"a",
"set",
"of",
"credentials",
".",
"Valid",
"representations",
"include",
"<key",
">",
":",
"<secret",
... | python | train | 50 |
cloudendpoints/endpoints-python | endpoints/discovery_generator.py | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_generator.py#L706-L766 | def __resource_descriptor(self, resource_path, methods):
"""Describes a resource.
Args:
resource_path: string, the path of the resource (e.g., 'entries.items')
methods: list of tuples of type
(endpoints.Service, protorpc.remote._RemoteMethodInfo), the methods
that serve this resourc... | [
"def",
"__resource_descriptor",
"(",
"self",
",",
"resource_path",
",",
"methods",
")",
":",
"descriptor",
"=",
"{",
"}",
"method_map",
"=",
"{",
"}",
"sub_resource_index",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"sub_resource_map",
"=",
"{",... | Describes a resource.
Args:
resource_path: string, the path of the resource (e.g., 'entries.items')
methods: list of tuples of type
(endpoints.Service, protorpc.remote._RemoteMethodInfo), the methods
that serve this resource.
Returns:
Dictionary describing the resource. | [
"Describes",
"a",
"resource",
"."
] | python | train | 37.852459 |
senaite/senaite.core | bika/lims/content/worksheettemplate.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/worksheettemplate.py#L223-L235 | def _getMethodsVoc(self):
"""Return the registered methods as DisplayList
"""
methods = api.search({
"portal_type": "Method",
"is_active": True
}, "bika_setup_catalog")
items = map(lambda m: (api.get_uid(m), api.get_title(m)), methods)
items.sort(... | [
"def",
"_getMethodsVoc",
"(",
"self",
")",
":",
"methods",
"=",
"api",
".",
"search",
"(",
"{",
"\"portal_type\"",
":",
"\"Method\"",
",",
"\"is_active\"",
":",
"True",
"}",
",",
"\"bika_setup_catalog\"",
")",
"items",
"=",
"map",
"(",
"lambda",
"m",
":",
... | Return the registered methods as DisplayList | [
"Return",
"the",
"registered",
"methods",
"as",
"DisplayList"
] | python | train | 32.923077 |
blockstack/blockstack-core | blockstack/blockstackd.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L753-L780 | def get_name_DID_record(self, did):
"""
Given a DID for a name, return the name record.
Return {'record': ...} on success
Return {'error': ...} on error
"""
try:
did_info = parse_DID(did)
assert did_info['name_type'] == 'name'
except Except... | [
"def",
"get_name_DID_record",
"(",
"self",
",",
"did",
")",
":",
"try",
":",
"did_info",
"=",
"parse_DID",
"(",
"did",
")",
"assert",
"did_info",
"[",
"'name_type'",
"]",
"==",
"'name'",
"except",
"Exception",
"as",
"e",
":",
"if",
"BLOCKSTACK_DEBUG",
":",... | Given a DID for a name, return the name record.
Return {'record': ...} on success
Return {'error': ...} on error | [
"Given",
"a",
"DID",
"for",
"a",
"name",
"return",
"the",
"name",
"record",
".",
"Return",
"{",
"record",
":",
"...",
"}",
"on",
"success",
"Return",
"{",
"error",
":",
"...",
"}",
"on",
"error"
] | python | train | 31.892857 |
inasafe/inasafe | safe/metadata/base_metadata.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/base_metadata.py#L584-L600 | def write_to_file(self, destination_path):
"""
Writes the metadata json or xml to a file.
:param destination_path: the file path the file format is inferred
from the destination_path extension.
:type destination_path: str
:return: the written metadata
:rtype: str... | [
"def",
"write_to_file",
"(",
"self",
",",
"destination_path",
")",
":",
"file_format",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"destination_path",
")",
"[",
"1",
"]",
"[",
"1",
":",
"]",
"metadata",
"=",
"self",
".",
"get_writable_metadata",
"(",
"... | Writes the metadata json or xml to a file.
:param destination_path: the file path the file format is inferred
from the destination_path extension.
:type destination_path: str
:return: the written metadata
:rtype: str | [
"Writes",
"the",
"metadata",
"json",
"or",
"xml",
"to",
"a",
"file",
"."
] | python | train | 32.941176 |
census-instrumentation/opencensus-python | contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/stats_exporter/__init__.py | https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/stats_exporter/__init__.py#L193-L252 | def _convert_point(self, metric, ts, point, sd_point):
"""Convert an OC metric point to a SD point."""
if (metric.descriptor.type == metric_descriptor.MetricDescriptorType
.CUMULATIVE_DISTRIBUTION):
sd_dist_val = sd_point.value.distribution_value
sd_dist_val.coun... | [
"def",
"_convert_point",
"(",
"self",
",",
"metric",
",",
"ts",
",",
"point",
",",
"sd_point",
")",
":",
"if",
"(",
"metric",
".",
"descriptor",
".",
"type",
"==",
"metric_descriptor",
".",
"MetricDescriptorType",
".",
"CUMULATIVE_DISTRIBUTION",
")",
":",
"s... | Convert an OC metric point to a SD point. | [
"Convert",
"an",
"OC",
"metric",
"point",
"to",
"a",
"SD",
"point",
"."
] | python | train | 40.433333 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/reftrackitemdata.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/reftrackitemdata.py#L445-L457 | def set_forbidden_types(self, types):
"""Set all forbidden type values
:param typees: a list with forbidden type values
:type typees: list
:returns: None
:rtype: None
:raises: None
"""
if self._forbidden_types == types:
return
self._fo... | [
"def",
"set_forbidden_types",
"(",
"self",
",",
"types",
")",
":",
"if",
"self",
".",
"_forbidden_types",
"==",
"types",
":",
"return",
"self",
".",
"_forbidden_types",
"=",
"types",
"self",
".",
"invalidateFilter",
"(",
")"
] | Set all forbidden type values
:param typees: a list with forbidden type values
:type typees: list
:returns: None
:rtype: None
:raises: None | [
"Set",
"all",
"forbidden",
"type",
"values"
] | python | train | 27.769231 |
readbeyond/aeneas | aeneas/globalfunctions.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/globalfunctions.py#L180-L193 | def tmp_file(suffix=u"", root=None):
"""
Return a (handler, path) tuple
for a temporary file with given suffix created by ``tempfile``.
:param string suffix: the suffix (e.g., the extension) of the file
:param string root: path to the root temporary directory;
if ``None``, t... | [
"def",
"tmp_file",
"(",
"suffix",
"=",
"u\"\"",
",",
"root",
"=",
"None",
")",
":",
"if",
"root",
"is",
"None",
":",
"root",
"=",
"custom_tmp_dir",
"(",
")",
"return",
"tempfile",
".",
"mkstemp",
"(",
"suffix",
"=",
"suffix",
",",
"dir",
"=",
"root",... | Return a (handler, path) tuple
for a temporary file with given suffix created by ``tempfile``.
:param string suffix: the suffix (e.g., the extension) of the file
:param string root: path to the root temporary directory;
if ``None``, the default temporary directory
... | [
"Return",
"a",
"(",
"handler",
"path",
")",
"tuple",
"for",
"a",
"temporary",
"file",
"with",
"given",
"suffix",
"created",
"by",
"tempfile",
"."
] | python | train | 36.714286 |
timothydmorton/VESPA | vespa/populations.py | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/populations.py#L2206-L2213 | def constraints(self):
"""
Unique list of constraints among all populations in set.
"""
cs = []
for pop in self.poplist:
cs += [c for c in pop.constraints]
return list(set(cs)) | [
"def",
"constraints",
"(",
"self",
")",
":",
"cs",
"=",
"[",
"]",
"for",
"pop",
"in",
"self",
".",
"poplist",
":",
"cs",
"+=",
"[",
"c",
"for",
"c",
"in",
"pop",
".",
"constraints",
"]",
"return",
"list",
"(",
"set",
"(",
"cs",
")",
")"
] | Unique list of constraints among all populations in set. | [
"Unique",
"list",
"of",
"constraints",
"among",
"all",
"populations",
"in",
"set",
"."
] | python | train | 28.625 |
python-xlib/python-xlib | Xlib/display.py | https://github.com/python-xlib/python-xlib/blob/8901e831737e79fe5645f48089d70e1d1046d2f2/Xlib/display.py#L564-L582 | def warp_pointer(self, x, y, src_window = X.NONE, src_x = 0, src_y = 0,
src_width = 0, src_height = 0, onerror = None):
"""Move the pointer relative its current position by the offsets
(x, y). However, if src_window is a window the pointer is only
moved if the specified rect... | [
"def",
"warp_pointer",
"(",
"self",
",",
"x",
",",
"y",
",",
"src_window",
"=",
"X",
".",
"NONE",
",",
"src_x",
"=",
"0",
",",
"src_y",
"=",
"0",
",",
"src_width",
"=",
"0",
",",
"src_height",
"=",
"0",
",",
"onerror",
"=",
"None",
")",
":",
"r... | Move the pointer relative its current position by the offsets
(x, y). However, if src_window is a window the pointer is only
moved if the specified rectangle in src_window contains it. If
src_width is 0 it will be replaced with the width of src_window -
src_x. src_height is treated in a ... | [
"Move",
"the",
"pointer",
"relative",
"its",
"current",
"position",
"by",
"the",
"offsets",
"(",
"x",
"y",
")",
".",
"However",
"if",
"src_window",
"is",
"a",
"window",
"the",
"pointer",
"is",
"only",
"moved",
"if",
"the",
"specified",
"rectangle",
"in",
... | python | train | 53.631579 |
linuxwhatelse/mapper | mapper.py | https://github.com/linuxwhatelse/mapper/blob/3481715b2a36d2da8bf5e9c6da80ceaed0d7ca59/mapper.py#L108-L131 | def add(self, pattern, function, method=None, type_cast=None):
"""Function for registering a path pattern.
Args:
pattern (str): Regex pattern to match a certain path.
function (function): Function to associate with this path.
method (str, optional): Usually used to d... | [
"def",
"add",
"(",
"self",
",",
"pattern",
",",
"function",
",",
"method",
"=",
"None",
",",
"type_cast",
"=",
"None",
")",
":",
"if",
"not",
"type_cast",
":",
"type_cast",
"=",
"{",
"}",
"with",
"self",
".",
"_lock",
":",
"self",
".",
"_data_store",... | Function for registering a path pattern.
Args:
pattern (str): Regex pattern to match a certain path.
function (function): Function to associate with this path.
method (str, optional): Usually used to define one of GET, POST,
PUT, DELETE. You may use whatever ... | [
"Function",
"for",
"registering",
"a",
"path",
"pattern",
"."
] | python | test | 41 |
sorgerlab/indra | indra/tools/reading/readers.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L123-L129 | def change_id(self, new_id):
"""Change the id of this content."""
self._load_raw_content()
self._id = new_id
self.get_filename(renew=True)
self.get_filepath(renew=True)
return | [
"def",
"change_id",
"(",
"self",
",",
"new_id",
")",
":",
"self",
".",
"_load_raw_content",
"(",
")",
"self",
".",
"_id",
"=",
"new_id",
"self",
".",
"get_filename",
"(",
"renew",
"=",
"True",
")",
"self",
".",
"get_filepath",
"(",
"renew",
"=",
"True"... | Change the id of this content. | [
"Change",
"the",
"id",
"of",
"this",
"content",
"."
] | python | train | 31 |
softlayer/softlayer-python | SoftLayer/CLI/deprecated.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/deprecated.py#L11-L15 | def main():
"""Main function for the deprecated 'sl' command."""
print("ERROR: Use the 'slcli' command instead.", file=sys.stderr)
print("> slcli %s" % ' '.join(sys.argv[1:]), file=sys.stderr)
exit(-1) | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"\"ERROR: Use the 'slcli' command instead.\"",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"print",
"(",
"\"> slcli %s\"",
"%",
"' '",
".",
"join",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
",",
"fil... | Main function for the deprecated 'sl' command. | [
"Main",
"function",
"for",
"the",
"deprecated",
"sl",
"command",
"."
] | python | train | 42.6 |
evansde77/dockerstache | src/dockerstache/__main__.py | https://github.com/evansde77/dockerstache/blob/929c102e9fffde322dbf17f8e69533a00976aacb/src/dockerstache/__main__.py#L17-L65 | def build_parser():
"""
_build_parser_
Set up CLI parser options, parse the
CLI options an return the parsed results
"""
parser = argparse.ArgumentParser(
description='dockerstache templating util'
)
parser.add_argument(
'--output', '-o',
help='Working directory... | [
"def",
"build_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'dockerstache templating util'",
")",
"parser",
".",
"add_argument",
"(",
"'--output'",
",",
"'-o'",
",",
"help",
"=",
"'Working directory to render doc... | _build_parser_
Set up CLI parser options, parse the
CLI options an return the parsed results | [
"_build_parser_"
] | python | train | 26.44898 |
django-fluent/django-fluent-contents | fluent_contents/forms/widgets.py | https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/forms/widgets.py#L46-L64 | def render(self, name, value, attrs=None, renderer=None):
"""
Render the placeholder field.
"""
other_instance_languages = None
if value and value != "-DUMMY-":
if get_parent_language_code(self.parent_object):
# Parent is a multilingual object, provide... | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"None",
",",
"renderer",
"=",
"None",
")",
":",
"other_instance_languages",
"=",
"None",
"if",
"value",
"and",
"value",
"!=",
"\"-DUMMY-\"",
":",
"if",
"get_parent_language_code",
... | Render the placeholder field. | [
"Render",
"the",
"placeholder",
"field",
"."
] | python | train | 43.368421 |
PmagPy/PmagPy | pmagpy/pmagplotlib.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmagplotlib.py#L219-L239 | def qsnorm(p):
"""
rational approximation for x where q(x)=d, q being the cumulative
normal distribution function. taken from Abramowitz & Stegun p. 933
|error(x)| < 4.5*10**-4
"""
d = p
if d < 0. or d > 1.:
print('d not in (1,1) ')
sys.exit()
x = 0.
if (d - 0.5) > 0:... | [
"def",
"qsnorm",
"(",
"p",
")",
":",
"d",
"=",
"p",
"if",
"d",
"<",
"0.",
"or",
"d",
">",
"1.",
":",
"print",
"(",
"'d not in (1,1) '",
")",
"sys",
".",
"exit",
"(",
")",
"x",
"=",
"0.",
"if",
"(",
"d",
"-",
"0.5",
")",
">",
"0",
":",
"d"... | rational approximation for x where q(x)=d, q being the cumulative
normal distribution function. taken from Abramowitz & Stegun p. 933
|error(x)| < 4.5*10**-4 | [
"rational",
"approximation",
"for",
"x",
"where",
"q",
"(",
"x",
")",
"=",
"d",
"q",
"being",
"the",
"cumulative",
"normal",
"distribution",
"function",
".",
"taken",
"from",
"Abramowitz",
"&",
"Stegun",
"p",
".",
"933",
"|error",
"(",
"x",
")",
"|",
"... | python | train | 28.095238 |
saltstack/salt | salt/utils/vmware.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vmware.py#L2037-L2081 | def get_datastore_files(service_instance, directory, datastores, container_object, browser_spec):
'''
Get the files with a given browser specification from the datastore.
service_instance
The Service Instance Object from which to obtain datastores.
directory
The name of the directory w... | [
"def",
"get_datastore_files",
"(",
"service_instance",
",",
"directory",
",",
"datastores",
",",
"container_object",
",",
"browser_spec",
")",
":",
"files",
"=",
"[",
"]",
"datastore_objects",
"=",
"get_datastores",
"(",
"service_instance",
",",
"container_object",
... | Get the files with a given browser specification from the datastore.
service_instance
The Service Instance Object from which to obtain datastores.
directory
The name of the directory where we would like to search
datastores
Name of the datastores
container_object
The ... | [
"Get",
"the",
"files",
"with",
"a",
"given",
"browser",
"specification",
"from",
"the",
"datastore",
"."
] | python | train | 36.533333 |
joeferraro/mm | mm/sforce/partner.py | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/partner.py#L27-L127 | def _stringifyResultRecords(self, struct):
'''
The Partner WSDL defines result element not defined in the "SObject"
section of the Partner WSDL as <any/> elements, which get unmarshalled by
suds into single-element lists. We prefer that they are strings, so we'll
convert structures like
[(records... | [
"def",
"_stringifyResultRecords",
"(",
"self",
",",
"struct",
")",
":",
"if",
"not",
"isinstance",
"(",
"struct",
",",
"list",
")",
":",
"struct",
"=",
"[",
"struct",
"]",
"originallyList",
"=",
"False",
"else",
":",
"originallyList",
"=",
"True",
"for",
... | The Partner WSDL defines result element not defined in the "SObject"
section of the Partner WSDL as <any/> elements, which get unmarshalled by
suds into single-element lists. We prefer that they are strings, so we'll
convert structures like
[(records){
type = "Contact"
Id = "003000000000000000"
... | [
"The",
"Partner",
"WSDL",
"defines",
"result",
"element",
"not",
"defined",
"in",
"the",
"SObject",
"section",
"of",
"the",
"Partner",
"WSDL",
"as",
"<any",
"/",
">",
"elements",
"which",
"get",
"unmarshalled",
"by",
"suds",
"into",
"single",
"-",
"element",... | python | train | 26.683168 |
amaas-fintech/amaas-utils-python | amaasutils/case.py | https://github.com/amaas-fintech/amaas-utils-python/blob/5aa64ca65ce0c77b513482d943345d94c9ae58e8/amaasutils/case.py#L36-L62 | def dict_snake_to_camel_case(snake_dict, convert_keys=True, convert_subkeys=False):
"""
Recursively convert a snake_cased dict into a camelCased dict
:param snake_dict: Dictionary to convert
:param convert_keys: Whether the key should be converted
:param convert_subkeys: Whether to also convert the... | [
"def",
"dict_snake_to_camel_case",
"(",
"snake_dict",
",",
"convert_keys",
"=",
"True",
",",
"convert_subkeys",
"=",
"False",
")",
":",
"converted",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"snake_dict",
".",
"items",
"(",
")",
":",
"if",
"isinstan... | Recursively convert a snake_cased dict into a camelCased dict
:param snake_dict: Dictionary to convert
:param convert_keys: Whether the key should be converted
:param convert_subkeys: Whether to also convert the subkeys, in case they are named properties of the dict
:return: | [
"Recursively",
"convert",
"a",
"snake_cased",
"dict",
"into",
"a",
"camelCased",
"dict"
] | python | train | 43.62963 |
BlueBrain/NeuroM | neurom/fst/__init__.py | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/__init__.py#L147-L151 | def _indent(string, count):
'''indent `string` by `count` * INDENT'''
indent = _INDENT * count
ret = indent + string.replace('\n', '\n' + indent)
return ret.rstrip() | [
"def",
"_indent",
"(",
"string",
",",
"count",
")",
":",
"indent",
"=",
"_INDENT",
"*",
"count",
"ret",
"=",
"indent",
"+",
"string",
".",
"replace",
"(",
"'\\n'",
",",
"'\\n'",
"+",
"indent",
")",
"return",
"ret",
".",
"rstrip",
"(",
")"
] | indent `string` by `count` * INDENT | [
"indent",
"string",
"by",
"count",
"*",
"INDENT"
] | python | train | 35.4 |
inasafe/inasafe | safe/impact_function/postprocessors.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/postprocessors.py#L272-L308 | def should_run(keywords, post_processor):
"""
Check if the postprocessor should run for the current hazard and exposure
:param keywords: impact layer keywords
:type keywords: dict
:param post_processor: the post processor instance to check
:type post_processor: dict
:returns: Tuple with True... | [
"def",
"should_run",
"(",
"keywords",
",",
"post_processor",
")",
":",
"exposure",
"=",
"keywords",
"[",
"'exposure_keywords'",
"]",
"[",
"'exposure'",
"]",
"hazard",
"=",
"keywords",
"[",
"'hazard_keywords'",
"]",
"[",
"'hazard'",
"]",
"try",
":",
"run_filter... | Check if the postprocessor should run for the current hazard and exposure
:param keywords: impact layer keywords
:type keywords: dict
:param post_processor: the post processor instance to check
:type post_processor: dict
:returns: Tuple with True if success, else False with an error message.
:rt... | [
"Check",
"if",
"the",
"postprocessor",
"should",
"run",
"for",
"the",
"current",
"hazard",
"and",
"exposure",
":",
"param",
"keywords",
":",
"impact",
"layer",
"keywords",
":",
"type",
"keywords",
":",
"dict",
":",
"param",
"post_processor",
":",
"the",
"pos... | python | train | 37.378378 |
viveksck/changepoint | changepoint/mean_shift_model.py | https://github.com/viveksck/changepoint/blob/001792cb148c991ec704463d3213997ebb7171af/changepoint/mean_shift_model.py#L56-L65 | def compute_cusum_ts(self, ts):
""" Compute the Cumulative Sum at each point 't' of the time series. """
mean = np.mean(ts)
cusums = np.zeros(len(ts))
cusum[0] = (ts[0] - mean)
for i in np.arange(1, len(ts)):
cusums[i] = cusums[i - 1] + (ts[i] - mean)
assert(... | [
"def",
"compute_cusum_ts",
"(",
"self",
",",
"ts",
")",
":",
"mean",
"=",
"np",
".",
"mean",
"(",
"ts",
")",
"cusums",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"ts",
")",
")",
"cusum",
"[",
"0",
"]",
"=",
"(",
"ts",
"[",
"0",
"]",
"-",
"me... | Compute the Cumulative Sum at each point 't' of the time series. | [
"Compute",
"the",
"Cumulative",
"Sum",
"at",
"each",
"point",
"t",
"of",
"the",
"time",
"series",
"."
] | python | train | 36.1 |
gabstopper/smc-python | smc/core/interfaces.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/interfaces.py#L134-L141 | def set_auth_request(self, interface_id, address=None):
"""
Set the authentication request field for the specified
engine.
"""
self.interface.set_auth_request(interface_id, address)
self._engine.update() | [
"def",
"set_auth_request",
"(",
"self",
",",
"interface_id",
",",
"address",
"=",
"None",
")",
":",
"self",
".",
"interface",
".",
"set_auth_request",
"(",
"interface_id",
",",
"address",
")",
"self",
".",
"_engine",
".",
"update",
"(",
")"
] | Set the authentication request field for the specified
engine. | [
"Set",
"the",
"authentication",
"request",
"field",
"for",
"the",
"specified",
"engine",
"."
] | python | train | 31.625 |
portfors-lab/sparkle | sparkle/run/protocol_model.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/run/protocol_model.py#L13-L18 | def setReferenceVoltage(self, caldb, calv):
"""See :meth:`StimulusModel<sparkle.stim.stimulus_model.StimulusModel.setReferenceVoltage>`"""
self.caldb = caldb
self.calv = calv
for test in self._tests:
test.setReferenceVoltage(caldb, calv) | [
"def",
"setReferenceVoltage",
"(",
"self",
",",
"caldb",
",",
"calv",
")",
":",
"self",
".",
"caldb",
"=",
"caldb",
"self",
".",
"calv",
"=",
"calv",
"for",
"test",
"in",
"self",
".",
"_tests",
":",
"test",
".",
"setReferenceVoltage",
"(",
"caldb",
","... | See :meth:`StimulusModel<sparkle.stim.stimulus_model.StimulusModel.setReferenceVoltage>` | [
"See",
":",
"meth",
":",
"StimulusModel<sparkle",
".",
"stim",
".",
"stimulus_model",
".",
"StimulusModel",
".",
"setReferenceVoltage",
">"
] | python | train | 46 |
aws/aws-dynamodb-encryption-python | src/dynamodb_encryption_sdk/internal/formatting/deserialize/__init__.py | https://github.com/aws/aws-dynamodb-encryption-python/blob/8de3bbe13df39c59b21bf431010f7acfcf629a2f/src/dynamodb_encryption_sdk/internal/formatting/deserialize/__init__.py#L76-L89 | def decode_tag(stream):
"""Decode a tag value from a serialized stream.
:param stream: Source data stream
:type stream: io.BytesIO
:returns: Decoded tag
:rtype: bytes
"""
(reserved, tag) = unpack_value(">cc", stream)
if reserved != b"\x00":
raise DeserializationError("Invalid t... | [
"def",
"decode_tag",
"(",
"stream",
")",
":",
"(",
"reserved",
",",
"tag",
")",
"=",
"unpack_value",
"(",
"\">cc\"",
",",
"stream",
")",
"if",
"reserved",
"!=",
"b\"\\x00\"",
":",
"raise",
"DeserializationError",
"(",
"\"Invalid tag: reserved byte is not null\"",
... | Decode a tag value from a serialized stream.
:param stream: Source data stream
:type stream: io.BytesIO
:returns: Decoded tag
:rtype: bytes | [
"Decode",
"a",
"tag",
"value",
"from",
"a",
"serialized",
"stream",
"."
] | python | train | 25.285714 |
impact27/registrator | registrator/image.py | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L925-L961 | def gauss_fit(X, Y):
"""
Fit the function to a gaussian.
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
(The return from scipy.optimize.curve_fit)
popt : array
Optimal values for the parameters
pcov : 2d array
... | [
"def",
"gauss_fit",
"(",
"X",
",",
"Y",
")",
":",
"X",
"=",
"np",
".",
"asarray",
"(",
"X",
")",
"Y",
"=",
"np",
".",
"asarray",
"(",
"Y",
")",
"# Can not have negative values",
"Y",
"[",
"Y",
"<",
"0",
"]",
"=",
"0",
"# define gauss function",
"de... | Fit the function to a gaussian.
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
(The return from scipy.optimize.curve_fit)
popt : array
Optimal values for the parameters
pcov : 2d array
The estimated covariance of popt... | [
"Fit",
"the",
"function",
"to",
"a",
"gaussian",
"."
] | python | train | 23.594595 |
crackinglandia/pype32 | pype32/utils.py | https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/utils.py#L151-L162 | def setOffset(self, value):
"""
Sets the offset of the L{WriteData} stream object in wich the data is written.
@type value: int
@param value: Integer value that represent the offset we want to start writing in the L{WriteData} stream.
@raise WrongOffsetValue... | [
"def",
"setOffset",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
">=",
"len",
"(",
"self",
".",
"data",
".",
"getvalue",
"(",
")",
")",
":",
"raise",
"excep",
".",
"WrongOffsetValueException",
"(",
"\"Wrong offset value. Must be less than %d\"",
"%",
... | Sets the offset of the L{WriteData} stream object in wich the data is written.
@type value: int
@param value: Integer value that represent the offset we want to start writing in the L{WriteData} stream.
@raise WrongOffsetValueException: The value is beyond the total length ... | [
"Sets",
"the",
"offset",
"of",
"the",
"L",
"{",
"WriteData",
"}",
"stream",
"object",
"in",
"wich",
"the",
"data",
"is",
"written",
"."
] | python | train | 47.5 |
kejbaly2/metrique | metrique/result.py | https://github.com/kejbaly2/metrique/blob/a10b076097441b7dde687949139f702f5c1e1b35/metrique/result.py#L122-L132 | def to_datetime(self, column):
'''
This function converts epoch timestamps to datetimes.
:param column: column to convert from current state -> datetime
'''
if column in self:
if self[column].dtype in NUMPY_NUMERICAL:
self[column] = pd.to_datetime(sel... | [
"def",
"to_datetime",
"(",
"self",
",",
"column",
")",
":",
"if",
"column",
"in",
"self",
":",
"if",
"self",
"[",
"column",
"]",
".",
"dtype",
"in",
"NUMPY_NUMERICAL",
":",
"self",
"[",
"column",
"]",
"=",
"pd",
".",
"to_datetime",
"(",
"self",
"[",
... | This function converts epoch timestamps to datetimes.
:param column: column to convert from current state -> datetime | [
"This",
"function",
"converts",
"epoch",
"timestamps",
"to",
"datetimes",
"."
] | python | train | 38 |
vedvyas/doxytag2zealdb | doxytag2zealdb/zealdb.py | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/zealdb.py#L131-L155 | def insert(self, name, entry_type, filename):
'''Insert an entry into the Zeal database.
Args:
name: A string representing the name of the entry.
entry_type: A string representing the entry type.
filename: A string representing the filename of the documentation
... | [
"def",
"insert",
"(",
"self",
",",
"name",
",",
"entry_type",
",",
"filename",
")",
":",
"if",
"self",
".",
"cursor",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Open DB connection before attempting to call insert!'",
")",
"db_entry",
"=",
"(",
"name",
... | Insert an entry into the Zeal database.
Args:
name: A string representing the name of the entry.
entry_type: A string representing the entry type.
filename: A string representing the filename of the documentation
for the entry.
Raises:
Ru... | [
"Insert",
"an",
"entry",
"into",
"the",
"Zeal",
"database",
"."
] | python | train | 35.4 |
moonso/ped_parser | ped_parser/parser.py | https://github.com/moonso/ped_parser/blob/a7393e47139532782ea3c821aabea33d46f94323/ped_parser/parser.py#L403-L420 | def check_cmms_gender(self, ind_object):
"""
Check if the phenotype is correct.
Args:
ind_object : An Individuals object
Yields:
bool : True if phenotype status is correct
False otherwise
"""
ind_id = ind_obje... | [
"def",
"check_cmms_gender",
"(",
"self",
",",
"ind_object",
")",
":",
"ind_id",
"=",
"ind_object",
".",
"individual_id",
".",
"split",
"(",
"'-'",
")",
"sex",
"=",
"ind_object",
".",
"sex",
"sex_code",
"=",
"int",
"(",
"ind_id",
"[",
"-",
"1",
"]",
"["... | Check if the phenotype is correct.
Args:
ind_object : An Individuals object
Yields:
bool : True if phenotype status is correct
False otherwise | [
"Check",
"if",
"the",
"phenotype",
"is",
"correct",
".",
"Args",
":",
"ind_object",
":",
"An",
"Individuals",
"object",
"Yields",
":",
"bool",
":",
"True",
"if",
"phenotype",
"status",
"is",
"correct",
"False",
"otherwise"
] | python | train | 34.888889 |
biocore/burrito-fillings | bfillings/uclust.py | https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/uclust.py#L433-L482 | def uclust_cluster_from_sorted_fasta_filepath(
fasta_filepath,
uc_save_filepath=None,
percent_ID=0.97,
max_accepts=1,
max_rejects=8,
stepwords=8,
word_length=8,
optimal=False,
exact=False,
suppress_sort=False,
enable_rev_strand_matc... | [
"def",
"uclust_cluster_from_sorted_fasta_filepath",
"(",
"fasta_filepath",
",",
"uc_save_filepath",
"=",
"None",
",",
"percent_ID",
"=",
"0.97",
",",
"max_accepts",
"=",
"1",
",",
"max_rejects",
"=",
"8",
",",
"stepwords",
"=",
"8",
",",
"word_length",
"=",
"8",... | Returns clustered uclust file from sorted fasta | [
"Returns",
"clustered",
"uclust",
"file",
"from",
"sorted",
"fasta"
] | python | train | 32.6 |
webrecorder/warcio | warcio/archiveiterator.py | https://github.com/webrecorder/warcio/blob/c64c4394805e13256695f51af072c95389397ee9/warcio/archiveiterator.py#L133-L171 | def _consume_blanklines(self):
""" Consume blank lines that are between records
- For warcs, there are usually 2
- For arcs, may be 1 or 0
- For block gzipped files, these are at end of each gzip envelope
and are included in record length which is the full gzip envelope
... | [
"def",
"_consume_blanklines",
"(",
"self",
")",
":",
"empty_size",
"=",
"0",
"first_line",
"=",
"True",
"while",
"True",
":",
"line",
"=",
"self",
".",
"reader",
".",
"readline",
"(",
")",
"if",
"len",
"(",
"line",
")",
"==",
"0",
":",
"return",
"Non... | Consume blank lines that are between records
- For warcs, there are usually 2
- For arcs, may be 1 or 0
- For block gzipped files, these are at end of each gzip envelope
and are included in record length which is the full gzip envelope
- For uncompressed, they are between recor... | [
"Consume",
"blank",
"lines",
"that",
"are",
"between",
"records",
"-",
"For",
"warcs",
"there",
"are",
"usually",
"2",
"-",
"For",
"arcs",
"may",
"be",
"1",
"or",
"0",
"-",
"For",
"block",
"gzipped",
"files",
"these",
"are",
"at",
"end",
"of",
"each",
... | python | train | 35.25641 |
PythonCharmers/python-future | src/future/types/newdict.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/types/newdict.py#L69-L81 | def values(self):
"""
On Python 2.7+:
D.values() -> a set-like object providing a view on D's values
On Python 2.6:
D.values() -> an iterator over D's values
"""
if ver == (2, 7):
return self.viewvalues()
elif ver == (2, 6):
... | [
"def",
"values",
"(",
"self",
")",
":",
"if",
"ver",
"==",
"(",
"2",
",",
"7",
")",
":",
"return",
"self",
".",
"viewvalues",
"(",
")",
"elif",
"ver",
"==",
"(",
"2",
",",
"6",
")",
":",
"return",
"self",
".",
"itervalues",
"(",
")",
"elif",
... | On Python 2.7+:
D.values() -> a set-like object providing a view on D's values
On Python 2.6:
D.values() -> an iterator over D's values | [
"On",
"Python",
"2",
".",
"7",
"+",
":",
"D",
".",
"values",
"()",
"-",
">",
"a",
"set",
"-",
"like",
"object",
"providing",
"a",
"view",
"on",
"D",
"s",
"values",
"On",
"Python",
"2",
".",
"6",
":",
"D",
".",
"values",
"()",
"-",
">",
"an",
... | python | train | 30.307692 |
jcrobak/parquet-python | parquet/encoding.py | https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L46-L48 | def read_plain_int64(file_obj, count):
"""Read `count` 64-bit ints using the plain encoding."""
return struct.unpack("<{}q".format(count).encode("utf-8"), file_obj.read(8 * count)) | [
"def",
"read_plain_int64",
"(",
"file_obj",
",",
"count",
")",
":",
"return",
"struct",
".",
"unpack",
"(",
"\"<{}q\"",
".",
"format",
"(",
"count",
")",
".",
"encode",
"(",
"\"utf-8\"",
")",
",",
"file_obj",
".",
"read",
"(",
"8",
"*",
"count",
")",
... | Read `count` 64-bit ints using the plain encoding. | [
"Read",
"count",
"64",
"-",
"bit",
"ints",
"using",
"the",
"plain",
"encoding",
"."
] | python | train | 62 |
cltk/cltk | cltk/lemmatize/backoff.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/lemmatize/backoff.py#L193-L207 | def choose_tag(self: object, tokens: List[str], index: int, history: List[str]):
"""
Looks up token in ``lemmas`` dict and returns the corresponding
value as lemma.
:rtype: str
:type tokens: list
:param tokens: List of tokens to be lemmatized
:type index: int
... | [
"def",
"choose_tag",
"(",
"self",
":",
"object",
",",
"tokens",
":",
"List",
"[",
"str",
"]",
",",
"index",
":",
"int",
",",
"history",
":",
"List",
"[",
"str",
"]",
")",
":",
"keys",
"=",
"self",
".",
"lemmas",
".",
"keys",
"(",
")",
"if",
"to... | Looks up token in ``lemmas`` dict and returns the corresponding
value as lemma.
:rtype: str
:type tokens: list
:param tokens: List of tokens to be lemmatized
:type index: int
:param index: Int with current token
:type history: list
:param history: List wit... | [
"Looks",
"up",
"token",
"in",
"lemmas",
"dict",
"and",
"returns",
"the",
"corresponding",
"value",
"as",
"lemma",
".",
":",
"rtype",
":",
"str",
":",
"type",
"tokens",
":",
"list",
":",
"param",
"tokens",
":",
"List",
"of",
"tokens",
"to",
"be",
"lemma... | python | train | 39 |
soimort/you-get | src/you_get/extractors/ucas.py | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/ucas.py#L102-L117 | def ucas_download_single(url, output_dir = '.', merge = False, info_only = False, **kwargs):
'''video page'''
html = get_content(url)
# resourceID is UUID
resourceID = re.findall( r'resourceID":"([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})', html)[0]
assert resourceID != '', 'Canno... | [
"def",
"ucas_download_single",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"get_content",
"(",
"url",
")",
"# resourceID is UUID",
"resourceID",
"=",... | video page | [
"video",
"page"
] | python | test | 48.375 |
thebjorn/pydeps | pydeps/depgraph.py | https://github.com/thebjorn/pydeps/blob/1e6715b7bea47a40e8042821b57937deaaa0fdc3/pydeps/depgraph.py#L188-L204 | def dissimilarity_metric(self, a, b):
"""Return non-zero if references to this module are strange, and
should be drawn extra-long. The value defines the length, in
rank. This is also good for putting some vertical space between
seperate subsystems.
Returns an int bet... | [
"def",
"dissimilarity_metric",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"# if self._is_pylib(a) and self._is_pylib(b):",
"# return 1",
"res",
"=",
"4",
"for",
"an",
",",
"bn",
",",
"n",
"in",
"zip_longest",
"(",
"a",
".",
"name_parts",
",",
"b",
".",
... | Return non-zero if references to this module are strange, and
should be drawn extra-long. The value defines the length, in
rank. This is also good for putting some vertical space between
seperate subsystems.
Returns an int between 1 (default) and 4 (highly unrelated). | [
"Return",
"non",
"-",
"zero",
"if",
"references",
"to",
"this",
"module",
"are",
"strange",
"and",
"should",
"be",
"drawn",
"extra",
"-",
"long",
".",
"The",
"value",
"defines",
"the",
"length",
"in",
"rank",
".",
"This",
"is",
"also",
"good",
"for",
"... | python | train | 36.823529 |
priestc/moneywagon | moneywagon/tx.py | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L145-L160 | def add_output(self, address, value, unit='satoshi'):
"""
Add an output (a person who will receive funds via this tx).
If no unit is specified, satoshi is implied.
"""
value_satoshi = self.from_unit_to_satoshi(value, unit)
if self.verbose:
print("Adding outpu... | [
"def",
"add_output",
"(",
"self",
",",
"address",
",",
"value",
",",
"unit",
"=",
"'satoshi'",
")",
":",
"value_satoshi",
"=",
"self",
".",
"from_unit_to_satoshi",
"(",
"value",
",",
"unit",
")",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"\"Adding... | Add an output (a person who will receive funds via this tx).
If no unit is specified, satoshi is implied. | [
"Add",
"an",
"output",
"(",
"a",
"person",
"who",
"will",
"receive",
"funds",
"via",
"this",
"tx",
")",
".",
"If",
"no",
"unit",
"is",
"specified",
"satoshi",
"is",
"implied",
"."
] | python | train | 31.6875 |
wandb/client | wandb/vendor/prompt_toolkit/buffer_mapping.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/buffer_mapping.py#L78-L83 | def push_focus(self, cli, buffer_name):
"""
Push buffer on the focus stack.
"""
assert isinstance(buffer_name, six.text_type)
self.focus_stack.append(buffer_name) | [
"def",
"push_focus",
"(",
"self",
",",
"cli",
",",
"buffer_name",
")",
":",
"assert",
"isinstance",
"(",
"buffer_name",
",",
"six",
".",
"text_type",
")",
"self",
".",
"focus_stack",
".",
"append",
"(",
"buffer_name",
")"
] | Push buffer on the focus stack. | [
"Push",
"buffer",
"on",
"the",
"focus",
"stack",
"."
] | python | train | 32.833333 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.