repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
adrianliaw/PyCuber | pycuber/solver/cfop/f2l.py | https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L135-L147 | def combining_successors(state, last_action=()):
"""
Successors function for finding path of combining F2L pair.
"""
((corner, edge), (L, U, F, D, R, B)) = state
U_turns = [Formula("U"), Formula("U'"), Formula("U2")] if len(last_action) != 1 else []
R_turns = [Formula("R ... | [
"def",
"combining_successors",
"(",
"state",
",",
"last_action",
"=",
"(",
")",
")",
":",
"(",
"(",
"corner",
",",
"edge",
")",
",",
"(",
"L",
",",
"U",
",",
"F",
",",
"D",
",",
"R",
",",
"B",
")",
")",
"=",
"state",
"U_turns",
"=",
"[",
"For... | Successors function for finding path of combining F2L pair. | [
"Successors",
"function",
"for",
"finding",
"path",
"of",
"combining",
"F2L",
"pair",
"."
] | python | train |
glitchassassin/lackey | lackey/RegionMatching.py | https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/RegionMatching.py#L264-L269 | def morphTo(self, region):
""" Change shape of this region to match the given ``Region`` object """
if not region or not isinstance(region, Region):
raise TypeError("morphTo expected a Region object")
self.setROI(region)
return self | [
"def",
"morphTo",
"(",
"self",
",",
"region",
")",
":",
"if",
"not",
"region",
"or",
"not",
"isinstance",
"(",
"region",
",",
"Region",
")",
":",
"raise",
"TypeError",
"(",
"\"morphTo expected a Region object\"",
")",
"self",
".",
"setROI",
"(",
"region",
... | Change shape of this region to match the given ``Region`` object | [
"Change",
"shape",
"of",
"this",
"region",
"to",
"match",
"the",
"given",
"Region",
"object"
] | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L8349-L8359 | def serial_udb_extra_f13_encode(self, sue_week_no, sue_lat_origin, sue_lon_origin, sue_alt_origin):
'''
Backwards compatible version of SERIAL_UDB_EXTRA F13: format
sue_week_no : Serial UDB Extra GPS Week Number (int16_t)
sue_lat_origin ... | [
"def",
"serial_udb_extra_f13_encode",
"(",
"self",
",",
"sue_week_no",
",",
"sue_lat_origin",
",",
"sue_lon_origin",
",",
"sue_alt_origin",
")",
":",
"return",
"MAVLink_serial_udb_extra_f13_message",
"(",
"sue_week_no",
",",
"sue_lat_origin",
",",
"sue_lon_origin",
",",
... | Backwards compatible version of SERIAL_UDB_EXTRA F13: format
sue_week_no : Serial UDB Extra GPS Week Number (int16_t)
sue_lat_origin : Serial UDB Extra MP Origin Latitude (int32_t)
sue_lon_origin : Serial UDB Extra MP Origin Longitude ... | [
"Backwards",
"compatible",
"version",
"of",
"SERIAL_UDB_EXTRA",
"F13",
":",
"format"
] | python | train |
Qiskit/qiskit-terra | qiskit/extensions/simulator/snapshot.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/simulator/snapshot.py#L72-L84 | def label(self, name):
"""Set snapshot label to name
Args:
name (str or None): label to assign unitary
Raises:
TypeError: name is not string or None.
"""
if isinstance(name, str):
self._label = name
else:
raise TypeError('... | [
"def",
"label",
"(",
"self",
",",
"name",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"self",
".",
"_label",
"=",
"name",
"else",
":",
"raise",
"TypeError",
"(",
"'label expects a string'",
")"
] | Set snapshot label to name
Args:
name (str or None): label to assign unitary
Raises:
TypeError: name is not string or None. | [
"Set",
"snapshot",
"label",
"to",
"name"
] | python | test |
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#L412-L416 | def namespaced_view_name(view_name, metric_prefix):
""" create string to be used as metric type
"""
metric_prefix = metric_prefix or "custom.googleapis.com/opencensus"
return os.path.join(metric_prefix, view_name).replace('\\', '/') | [
"def",
"namespaced_view_name",
"(",
"view_name",
",",
"metric_prefix",
")",
":",
"metric_prefix",
"=",
"metric_prefix",
"or",
"\"custom.googleapis.com/opencensus\"",
"return",
"os",
".",
"path",
".",
"join",
"(",
"metric_prefix",
",",
"view_name",
")",
".",
"replace... | create string to be used as metric type | [
"create",
"string",
"to",
"be",
"used",
"as",
"metric",
"type"
] | python | train |
nanoporetech/ont_fast5_api | ont_fast5_api/fast5_file.py | https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L454-L468 | def get_analysis_config(self, group_name):
""" Gets any config data saved for the analysis.
:param group_name: The name of the analysis group.
:returns: A dictionary of dictionaries. Each key represents
an analysis step. Each value is a dictionary containing the
analysis... | [
"def",
"get_analysis_config",
"(",
"self",
",",
"group_name",
")",
":",
"self",
".",
"assert_open",
"(",
")",
"group",
"=",
"'Analyses/{}/Configuration'",
".",
"format",
"(",
"group_name",
")",
"config",
"=",
"None",
"if",
"group",
"in",
"self",
".",
"handle... | Gets any config data saved for the analysis.
:param group_name: The name of the analysis group.
:returns: A dictionary of dictionaries. Each key represents
an analysis step. Each value is a dictionary containing the
analysis parameters as key/value pairs. Returns None if no
... | [
"Gets",
"any",
"config",
"data",
"saved",
"for",
"the",
"analysis",
"."
] | python | train |
ewels/MultiQC | multiqc/modules/clipandmerge/clipandmerge.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/clipandmerge/clipandmerge.py#L78-L92 | def clipandmerge_general_stats_table(self):
""" Take the parsed stats from the ClipAndMerge report and add it to the
basic stats table at the top of the report """
headers = OrderedDict()
headers['percentage'] = {
'title': '% Merged',
'description': 'Percentage o... | [
"def",
"clipandmerge_general_stats_table",
"(",
"self",
")",
":",
"headers",
"=",
"OrderedDict",
"(",
")",
"headers",
"[",
"'percentage'",
"]",
"=",
"{",
"'title'",
":",
"'% Merged'",
",",
"'description'",
":",
"'Percentage of reads merged'",
",",
"'min'",
":",
... | Take the parsed stats from the ClipAndMerge report and add it to the
basic stats table at the top of the report | [
"Take",
"the",
"parsed",
"stats",
"from",
"the",
"ClipAndMerge",
"report",
"and",
"add",
"it",
"to",
"the",
"basic",
"stats",
"table",
"at",
"the",
"top",
"of",
"the",
"report"
] | python | train |
crytic/slither | slither/core/declarations/function.py | https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/declarations/function.py#L926-L938 | def get_summary(self):
"""
Return the function summary
Returns:
(str, str, str, list(str), list(str), listr(str), list(str), list(str);
contract_name, name, visibility, modifiers, vars read, vars written, internal_calls, external_calls_as_expressions
"""
... | [
"def",
"get_summary",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"contract",
".",
"name",
",",
"self",
".",
"full_name",
",",
"self",
".",
"visibility",
",",
"[",
"str",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"modifiers",
"]",
",",
... | Return the function summary
Returns:
(str, str, str, list(str), list(str), listr(str), list(str), list(str);
contract_name, name, visibility, modifiers, vars read, vars written, internal_calls, external_calls_as_expressions | [
"Return",
"the",
"function",
"summary",
"Returns",
":",
"(",
"str",
"str",
"str",
"list",
"(",
"str",
")",
"list",
"(",
"str",
")",
"listr",
"(",
"str",
")",
"list",
"(",
"str",
")",
"list",
"(",
"str",
")",
";",
"contract_name",
"name",
"visibility"... | python | train |
dmbee/seglearn | seglearn/split.py | https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/split.py#L92-L114 | def _ts_slice(self, Xt, y):
''' takes time series data, and splits each series into temporal folds '''
Ns = len(Xt)
Xt_new = []
for i in range(self.n_splits):
for j in range(Ns):
Njs = int(len(Xt[j]) / self.n_splits)
Xt_new.append(Xt[j][(Njs * ... | [
"def",
"_ts_slice",
"(",
"self",
",",
"Xt",
",",
"y",
")",
":",
"Ns",
"=",
"len",
"(",
"Xt",
")",
"Xt_new",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n_splits",
")",
":",
"for",
"j",
"in",
"range",
"(",
"Ns",
")",
":",
"N... | takes time series data, and splits each series into temporal folds | [
"takes",
"time",
"series",
"data",
"and",
"splits",
"each",
"series",
"into",
"temporal",
"folds"
] | python | train |
spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/dataframeeditor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L688-L712 | def headerData(self, section, orientation, role):
"""Get the information to put in the header."""
if role == Qt.TextAlignmentRole:
if orientation == Qt.Horizontal:
return Qt.AlignCenter | Qt.AlignBottom
else:
return Qt.AlignRight | Qt.AlignVC... | [
"def",
"headerData",
"(",
"self",
",",
"section",
",",
"orientation",
",",
"role",
")",
":",
"if",
"role",
"==",
"Qt",
".",
"TextAlignmentRole",
":",
"if",
"orientation",
"==",
"Qt",
".",
"Horizontal",
":",
"return",
"Qt",
".",
"AlignCenter",
"|",
"Qt",
... | Get the information to put in the header. | [
"Get",
"the",
"information",
"to",
"put",
"in",
"the",
"header",
"."
] | python | train |
Guake/guake | guake/guake_app.py | https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L870-L879 | def gen_accel_switch_tabN(self, N):
"""Generates callback (which called by accel key) to go to the Nth tab.
"""
def callback(*args):
if 0 <= N < self.get_notebook().get_n_pages():
self.get_notebook().set_current_page(N)
return True
return callbac... | [
"def",
"gen_accel_switch_tabN",
"(",
"self",
",",
"N",
")",
":",
"def",
"callback",
"(",
"*",
"args",
")",
":",
"if",
"0",
"<=",
"N",
"<",
"self",
".",
"get_notebook",
"(",
")",
".",
"get_n_pages",
"(",
")",
":",
"self",
".",
"get_notebook",
"(",
"... | Generates callback (which called by accel key) to go to the Nth tab. | [
"Generates",
"callback",
"(",
"which",
"called",
"by",
"accel",
"key",
")",
"to",
"go",
"to",
"the",
"Nth",
"tab",
"."
] | python | train |
HiPERCAM/hcam_widgets | hcam_widgets/gtc/corba.py | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/gtc/corba.py#L40-L44 | def get_object(self, binding_name, cls):
"""
Get a reference to a remote object using CORBA
"""
return self._state.get_object(self, binding_name, cls) | [
"def",
"get_object",
"(",
"self",
",",
"binding_name",
",",
"cls",
")",
":",
"return",
"self",
".",
"_state",
".",
"get_object",
"(",
"self",
",",
"binding_name",
",",
"cls",
")"
] | Get a reference to a remote object using CORBA | [
"Get",
"a",
"reference",
"to",
"a",
"remote",
"object",
"using",
"CORBA"
] | python | train |
pteichman/cobe | cobe/brain.py | https://github.com/pteichman/cobe/blob/b0dc2a707035035b9a689105c8f833894fb59eb7/cobe/brain.py#L80-L87 | def start_batch_learning(self):
"""Begin a series of batch learn operations. Data will not be
committed to the database until stop_batch_learning is
called. Learn text using the normal learn(text) method."""
self._learning = True
self.graph.cursor().execute("PRAGMA journal_mode=... | [
"def",
"start_batch_learning",
"(",
"self",
")",
":",
"self",
".",
"_learning",
"=",
"True",
"self",
".",
"graph",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"\"PRAGMA journal_mode=memory\"",
")",
"self",
".",
"graph",
".",
"drop_reply_indexes",
"(",
")"
... | Begin a series of batch learn operations. Data will not be
committed to the database until stop_batch_learning is
called. Learn text using the normal learn(text) method. | [
"Begin",
"a",
"series",
"of",
"batch",
"learn",
"operations",
".",
"Data",
"will",
"not",
"be",
"committed",
"to",
"the",
"database",
"until",
"stop_batch_learning",
"is",
"called",
".",
"Learn",
"text",
"using",
"the",
"normal",
"learn",
"(",
"text",
")",
... | python | train |
vanheeringen-lab/gimmemotifs | gimmemotifs/utils.py | https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/utils.py#L495-L562 | def determine_file_type(fname):
"""
Detect file type.
The following file types are supported:
BED, narrowPeak, FASTA, list of chr:start-end regions
If the extension is bed, fa, fasta or narrowPeak, we will believe this
without checking!
Parameters
----------
fname : str
Fil... | [
"def",
"determine_file_type",
"(",
"fname",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"fname",
",",
"str",
")",
"or",
"isinstance",
"(",
"fname",
",",
"unicode",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"{} is not a file name!\"",
",",
"fname",
")... | Detect file type.
The following file types are supported:
BED, narrowPeak, FASTA, list of chr:start-end regions
If the extension is bed, fa, fasta or narrowPeak, we will believe this
without checking!
Parameters
----------
fname : str
File name.
Returns
-------
filetyp... | [
"Detect",
"file",
"type",
"."
] | python | train |
KieranWynn/pyquaternion | pyquaternion/quaternion.py | https://github.com/KieranWynn/pyquaternion/blob/d2aad7f3fb0d4b9cc23aa72b390e9b2e1273eae9/pyquaternion/quaternion.py#L488-L495 | def _normalise(self):
"""Object is guaranteed to be a unit quaternion after calling this
operation UNLESS the object is equivalent to Quaternion(0)
"""
if not self.is_unit():
n = self.norm
if n > 0:
self.q = self.q / n | [
"def",
"_normalise",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_unit",
"(",
")",
":",
"n",
"=",
"self",
".",
"norm",
"if",
"n",
">",
"0",
":",
"self",
".",
"q",
"=",
"self",
".",
"q",
"/",
"n"
] | Object is guaranteed to be a unit quaternion after calling this
operation UNLESS the object is equivalent to Quaternion(0) | [
"Object",
"is",
"guaranteed",
"to",
"be",
"a",
"unit",
"quaternion",
"after",
"calling",
"this",
"operation",
"UNLESS",
"the",
"object",
"is",
"equivalent",
"to",
"Quaternion",
"(",
"0",
")"
] | python | train |
saltstack/salt | salt/utils/gitfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1640-L1666 | def init_remote(self):
'''
Initialize/attach to a remote using pygit2. Return a boolean which
will let the calling function know whether or not a new repo was
initialized by this function.
'''
# https://github.com/libgit2/pygit2/issues/339
# https://github.com/lib... | [
"def",
"init_remote",
"(",
"self",
")",
":",
"# https://github.com/libgit2/pygit2/issues/339",
"# https://github.com/libgit2/libgit2/issues/2122",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"pygit2",
".",
"settings",
".",
"search_path",
"[",
"... | Initialize/attach to a remote using pygit2. Return a boolean which
will let the calling function know whether or not a new repo was
initialized by this function. | [
"Initialize",
"/",
"attach",
"to",
"a",
"remote",
"using",
"pygit2",
".",
"Return",
"a",
"boolean",
"which",
"will",
"let",
"the",
"calling",
"function",
"know",
"whether",
"or",
"not",
"a",
"new",
"repo",
"was",
"initialized",
"by",
"this",
"function",
".... | python | train |
materialsproject/pymatgen | pymatgen/analysis/wulff.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/wulff.py#L271-L298 | def _get_simpx_plane(self):
"""
Locate the plane for simpx of on wulff_cv, by comparing the center of
the simpx triangle with the plane functions.
"""
on_wulff = [False] * len(self.miller_list)
surface_area = [0.0] * len(self.miller_list)
for simpx in self.wulff_c... | [
"def",
"_get_simpx_plane",
"(",
"self",
")",
":",
"on_wulff",
"=",
"[",
"False",
"]",
"*",
"len",
"(",
"self",
".",
"miller_list",
")",
"surface_area",
"=",
"[",
"0.0",
"]",
"*",
"len",
"(",
"self",
".",
"miller_list",
")",
"for",
"simpx",
"in",
"sel... | Locate the plane for simpx of on wulff_cv, by comparing the center of
the simpx triangle with the plane functions. | [
"Locate",
"the",
"plane",
"for",
"simpx",
"of",
"on",
"wulff_cv",
"by",
"comparing",
"the",
"center",
"of",
"the",
"simpx",
"triangle",
"with",
"the",
"plane",
"functions",
"."
] | python | train |
pytroll/posttroll | posttroll/subscriber.py | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/subscriber.py#L166-L172 | def _add_hook(self, socket, callback):
"""Generic hook. The passed socket has to be "receive only".
"""
self._hooks.append(socket)
self._hooks_cb[socket] = callback
if self.poller:
self.poller.register(socket, POLLIN) | [
"def",
"_add_hook",
"(",
"self",
",",
"socket",
",",
"callback",
")",
":",
"self",
".",
"_hooks",
".",
"append",
"(",
"socket",
")",
"self",
".",
"_hooks_cb",
"[",
"socket",
"]",
"=",
"callback",
"if",
"self",
".",
"poller",
":",
"self",
".",
"poller... | Generic hook. The passed socket has to be "receive only". | [
"Generic",
"hook",
".",
"The",
"passed",
"socket",
"has",
"to",
"be",
"receive",
"only",
"."
] | python | train |
ehansis/ozelot | ozelot/orm/base.py | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/orm/base.py#L187-L228 | def render_diagram(out_base):
"""Render a data model diagram
Included in the diagram are all classes from the model registry.
For your project, write a small script that imports all models that you would like to
have included and then calls this function.
.. note:: This function requires the 'dot'... | [
"def",
"render_diagram",
"(",
"out_base",
")",
":",
"import",
"codecs",
"import",
"subprocess",
"import",
"sadisplay",
"# generate class descriptions",
"desc",
"=",
"sadisplay",
".",
"describe",
"(",
"list",
"(",
"model_registry",
".",
"values",
"(",
")",
")",
"... | Render a data model diagram
Included in the diagram are all classes from the model registry.
For your project, write a small script that imports all models that you would like to
have included and then calls this function.
.. note:: This function requires the 'dot' executable from the GraphViz package... | [
"Render",
"a",
"data",
"model",
"diagram"
] | python | train |
soravux/scoop | scoop/utils.py | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L144-L157 | def getHosts(filename=None, hostlist=None):
"""Return a list of hosts depending on the environment"""
if filename:
return getHostsFromFile(filename)
elif hostlist:
return getHostsFromList(hostlist)
elif getEnv() == "SLURM":
return getHostsFromSLURM()
elif getEnv() == "PBS":
... | [
"def",
"getHosts",
"(",
"filename",
"=",
"None",
",",
"hostlist",
"=",
"None",
")",
":",
"if",
"filename",
":",
"return",
"getHostsFromFile",
"(",
"filename",
")",
"elif",
"hostlist",
":",
"return",
"getHostsFromList",
"(",
"hostlist",
")",
"elif",
"getEnv",... | Return a list of hosts depending on the environment | [
"Return",
"a",
"list",
"of",
"hosts",
"depending",
"on",
"the",
"environment"
] | python | train |
erinxocon/spotify-local | src/spotify_local/core.py | https://github.com/erinxocon/spotify-local/blob/8188eef221e3d8b9f408ff430d80e74560360459/src/spotify_local/core.py#L78-L84 | def emit(self, event, *args, **kwargs):
"""Send out an event and call it's associated functions
:param event: Name of the event to trigger
"""
for func in self._registered_events[event].values():
func(*args, **kwargs) | [
"def",
"emit",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"func",
"in",
"self",
".",
"_registered_events",
"[",
"event",
"]",
".",
"values",
"(",
")",
":",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kw... | Send out an event and call it's associated functions
:param event: Name of the event to trigger | [
"Send",
"out",
"an",
"event",
"and",
"call",
"it",
"s",
"associated",
"functions"
] | python | train |
junzis/pyModeS | pyModeS/decoder/bds/__init__.py | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/__init__.py#L30-L89 | def is50or60(msg, spd_ref, trk_ref, alt_ref):
"""Use reference ground speed and trk to determine BDS50 and DBS60.
Args:
msg (String): 28 bytes hexadecimal message string
spd_ref (float): reference speed (ADS-B ground speed), kts
trk_ref (float): reference track (ADS-B track angle), deg
... | [
"def",
"is50or60",
"(",
"msg",
",",
"spd_ref",
",",
"trk_ref",
",",
"alt_ref",
")",
":",
"def",
"vxy",
"(",
"v",
",",
"angle",
")",
":",
"vx",
"=",
"v",
"*",
"np",
".",
"sin",
"(",
"np",
".",
"radians",
"(",
"angle",
")",
")",
"vy",
"=",
"v",... | Use reference ground speed and trk to determine BDS50 and DBS60.
Args:
msg (String): 28 bytes hexadecimal message string
spd_ref (float): reference speed (ADS-B ground speed), kts
trk_ref (float): reference track (ADS-B track angle), deg
alt_ref (float): reference altitude (ADS-B al... | [
"Use",
"reference",
"ground",
"speed",
"and",
"trk",
"to",
"determine",
"BDS50",
"and",
"DBS60",
"."
] | python | train |
raphaelgyory/django-rest-messaging | rest_messaging/compat.py | https://github.com/raphaelgyory/django-rest-messaging/blob/c9d5405fed7db2d79ec5c93c721a8fe42ea86958/rest_messaging/compat.py#L67-L75 | def compat_get_paginated_response(view, page):
""" get_paginated_response is unknown to DRF 3.0 """
if DRFVLIST[0] == 3 and DRFVLIST[1] >= 1:
from rest_messaging.serializers import ComplexMessageSerializer # circular import
serializer = ComplexMessageSerializer(page, many=True)
return v... | [
"def",
"compat_get_paginated_response",
"(",
"view",
",",
"page",
")",
":",
"if",
"DRFVLIST",
"[",
"0",
"]",
"==",
"3",
"and",
"DRFVLIST",
"[",
"1",
"]",
">=",
"1",
":",
"from",
"rest_messaging",
".",
"serializers",
"import",
"ComplexMessageSerializer",
"# c... | get_paginated_response is unknown to DRF 3.0 | [
"get_paginated_response",
"is",
"unknown",
"to",
"DRF",
"3",
".",
"0"
] | python | train |
artisanofcode/python-broadway | broadway/errors.py | https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/broadway/errors.py#L40-L45 | def init_app(application):
"""
Associates the error handler
"""
for code in werkzeug.exceptions.default_exceptions:
application.register_error_handler(code, handle_http_exception) | [
"def",
"init_app",
"(",
"application",
")",
":",
"for",
"code",
"in",
"werkzeug",
".",
"exceptions",
".",
"default_exceptions",
":",
"application",
".",
"register_error_handler",
"(",
"code",
",",
"handle_http_exception",
")"
] | Associates the error handler | [
"Associates",
"the",
"error",
"handler"
] | python | train |
nuagenetworks/bambou | bambou/nurest_root_object.py | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_root_object.py#L118-L124 | def get_resource_url(self):
""" Get resource complete url """
name = self.__class__.resource_name
url = self.__class__.rest_base_url()
return "%s/%s" % (url, name) | [
"def",
"get_resource_url",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"__class__",
".",
"resource_name",
"url",
"=",
"self",
".",
"__class__",
".",
"rest_base_url",
"(",
")",
"return",
"\"%s/%s\"",
"%",
"(",
"url",
",",
"name",
")"
] | Get resource complete url | [
"Get",
"resource",
"complete",
"url"
] | python | train |
topic2k/pygcgen | pygcgen/generator.py | https://github.com/topic2k/pygcgen/blob/c41701815df2c8c3a57fd5f7b8babe702127c8a1/pygcgen/generator.py#L797-L813 | def get_filtered_pull_requests(self, pull_requests):
"""
This method fetches missing params for PR and filter them
by specified options. It include add all PR's with labels
from options.include_labels and exclude all from
options.exclude_labels.
:param list(dict) pull_re... | [
"def",
"get_filtered_pull_requests",
"(",
"self",
",",
"pull_requests",
")",
":",
"pull_requests",
"=",
"self",
".",
"filter_by_labels",
"(",
"pull_requests",
",",
"\"pull requests\"",
")",
"pull_requests",
"=",
"self",
".",
"filter_merged_pull_requests",
"(",
"pull_r... | This method fetches missing params for PR and filter them
by specified options. It include add all PR's with labels
from options.include_labels and exclude all from
options.exclude_labels.
:param list(dict) pull_requests: All pull requests.
:rtype: list(dict)
:return: Fi... | [
"This",
"method",
"fetches",
"missing",
"params",
"for",
"PR",
"and",
"filter",
"them",
"by",
"specified",
"options",
".",
"It",
"include",
"add",
"all",
"PR",
"s",
"with",
"labels",
"from",
"options",
".",
"include_labels",
"and",
"exclude",
"all",
"from",
... | python | valid |
rootpy/rootpy | rootpy/io/pickler.py | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/pickler.py#L272-L291 | def load(self, key=None):
"""Read a pickled object representation from the open file."""
if key is None:
key = '_pickle'
obj = None
if _compat_hooks:
save = _compat_hooks[0]()
try:
self.__n += 1
s = self.__file.Get(key + ';{0:d}'.fo... | [
"def",
"load",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"'_pickle'",
"obj",
"=",
"None",
"if",
"_compat_hooks",
":",
"save",
"=",
"_compat_hooks",
"[",
"0",
"]",
"(",
")",
"try",
":",
"self",
"."... | Read a pickled object representation from the open file. | [
"Read",
"a",
"pickled",
"object",
"representation",
"from",
"the",
"open",
"file",
"."
] | python | train |
mehmetg/streak_client | streak_client/streak_client.py | https://github.com/mehmetg/streak_client/blob/46575510b4e4163a4a3cc06f7283a1ae377cdce6/streak_client/streak_client.py#L925-L948 | def update_reminder(self, reminder):
'''Creates a reminder with the provided attributes.
Args:
reminder updated reminder of StreakReminder type
return (status code, reminder dict)
'''
uri = '/'.join([self.api_uri,
self.reminders_suffix,
])
#req sanity check
payload = None
if type(rem... | [
"def",
"update_reminder",
"(",
"self",
",",
"reminder",
")",
":",
"uri",
"=",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"api_uri",
",",
"self",
".",
"reminders_suffix",
",",
"]",
")",
"#req sanity check",
"payload",
"=",
"None",
"if",
"type",
"(",
"re... | Creates a reminder with the provided attributes.
Args:
reminder updated reminder of StreakReminder type
return (status code, reminder dict) | [
"Creates",
"a",
"reminder",
"with",
"the",
"provided",
"attributes",
".",
"Args",
":",
"reminder",
"updated",
"reminder",
"of",
"StreakReminder",
"type",
"return",
"(",
"status",
"code",
"reminder",
"dict",
")"
] | python | train |
tsnaomi/finnsyll | finnsyll/syllabifier.py | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/syllabifier.py#L114-L150 | def annotate(self, word):
'''Annotate 'word' for syllabification, stress, weights, and vowels.'''
info = [] # e.g., [ ('\'nak.su.`tus.ta', 'PUSU', 'HLHL', 'AUUA'), ]
for syllabification, _ in syllabify(self.normalize(word), stress=True):
stresses = ''
weights = ''
... | [
"def",
"annotate",
"(",
"self",
",",
"word",
")",
":",
"info",
"=",
"[",
"]",
"# e.g., [ ('\\'nak.su.`tus.ta', 'PUSU', 'HLHL', 'AUUA'), ]",
"for",
"syllabification",
",",
"_",
"in",
"syllabify",
"(",
"self",
".",
"normalize",
"(",
"word",
")",
",",
"stress",
"... | Annotate 'word' for syllabification, stress, weights, and vowels. | [
"Annotate",
"word",
"for",
"syllabification",
"stress",
"weights",
"and",
"vowels",
"."
] | python | train |
Miserlou/django-knockout-modeler | knockout_modeler/ko.py | https://github.com/Miserlou/django-knockout-modeler/blob/714d21cc5ed008f132cea01dbae9f214c2bf1b76/knockout_modeler/ko.py#L107-L123 | def ko_bindings(model):
"""
Given a model, returns the Knockout data bindings.
"""
try:
if isinstance(model, str):
modelName = model
else:
modelName = model.__class__.__name__
modelBindingsString = "ko.applyBindings(new " + modelName + "ViewModel(), $('#... | [
"def",
"ko_bindings",
"(",
"model",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"model",
",",
"str",
")",
":",
"modelName",
"=",
"model",
"else",
":",
"modelName",
"=",
"model",
".",
"__class__",
".",
"__name__",
"modelBindingsString",
"=",
"\"ko.applyB... | Given a model, returns the Knockout data bindings. | [
"Given",
"a",
"model",
"returns",
"the",
"Knockout",
"data",
"bindings",
"."
] | python | train |
timmahrt/ProMo | promo/morph_utils/modify_pitch_accent.py | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L149-L163 | def reintegrate(self, fullPointList):
'''
Integrates the pitch values of the accent into a larger pitch contour
'''
# Erase the original region of the accent
fullPointList = _deletePoints(fullPointList, self.minT, self.maxT)
# Erase the new region of the accent
... | [
"def",
"reintegrate",
"(",
"self",
",",
"fullPointList",
")",
":",
"# Erase the original region of the accent",
"fullPointList",
"=",
"_deletePoints",
"(",
"fullPointList",
",",
"self",
".",
"minT",
",",
"self",
".",
"maxT",
")",
"# Erase the new region of the accent",
... | Integrates the pitch values of the accent into a larger pitch contour | [
"Integrates",
"the",
"pitch",
"values",
"of",
"the",
"accent",
"into",
"a",
"larger",
"pitch",
"contour"
] | python | train |
Varkal/chuda | chuda/commands.py | https://github.com/Varkal/chuda/blob/0d93b716dede35231c21be97bcc19a656655983f/chuda/commands.py#L92-L109 | def setup(self, app):
'''
Setup properties from parent app on the command
'''
self.logger = app.logger
self.shell.logger = self.logger
if not self.command_name:
raise EmptyCommandNameException()
self.app = app
self.arguments_declaration = sel... | [
"def",
"setup",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"logger",
"=",
"app",
".",
"logger",
"self",
".",
"shell",
".",
"logger",
"=",
"self",
".",
"logger",
"if",
"not",
"self",
".",
"command_name",
":",
"raise",
"EmptyCommandNameException",
"... | Setup properties from parent app on the command | [
"Setup",
"properties",
"from",
"parent",
"app",
"on",
"the",
"command"
] | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/breakpoint.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/breakpoint.py#L1314-L1329 | def __callHandler(self, callback, event, *params):
"""
Calls a "pre" or "post" handler, if set.
@type callback: function
@param callback: Callback function to call.
@type event: L{ExceptionEvent}
@param event: Breakpoint hit event.
@type params: tuple
... | [
"def",
"__callHandler",
"(",
"self",
",",
"callback",
",",
"event",
",",
"*",
"params",
")",
":",
"if",
"callback",
"is",
"not",
"None",
":",
"event",
".",
"hook",
"=",
"self",
"callback",
"(",
"event",
",",
"*",
"params",
")"
] | Calls a "pre" or "post" handler, if set.
@type callback: function
@param callback: Callback function to call.
@type event: L{ExceptionEvent}
@param event: Breakpoint hit event.
@type params: tuple
@param params: Parameters for the callback function. | [
"Calls",
"a",
"pre",
"or",
"post",
"handler",
"if",
"set",
"."
] | python | train |
svasilev94/GraphLibrary | graphlibrary/paths.py | https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/paths.py#L6-L23 | def find_all_paths(G, start, end, path=[]):
"""
Find all paths between vertices start and end in graph.
"""
path = path + [start]
if start == end:
return [path]
if start not in G.vertices:
raise GraphInsertError("Vertex %s doesn't exist." % (start,))
if end not in G.... | [
"def",
"find_all_paths",
"(",
"G",
",",
"start",
",",
"end",
",",
"path",
"=",
"[",
"]",
")",
":",
"path",
"=",
"path",
"+",
"[",
"start",
"]",
"if",
"start",
"==",
"end",
":",
"return",
"[",
"path",
"]",
"if",
"start",
"not",
"in",
"G",
".",
... | Find all paths between vertices start and end in graph. | [
"Find",
"all",
"paths",
"between",
"vertices",
"start",
"and",
"end",
"in",
"graph",
"."
] | python | train |
Stewori/pytypes | pytypes/typechecker.py | https://github.com/Stewori/pytypes/blob/b814d38709e84c0e0825caf8b721c20eb5a8ab3b/pytypes/typechecker.py#L726-L741 | def typechecked_func(func, force = False, argType = None, resType = None, prop_getter = False):
"""Works like typechecked, but is only applicable to functions, methods and properties.
"""
if not pytypes.checking_enabled and not pytypes.do_logging_in_typechecked:
return func
assert(_check_as_func... | [
"def",
"typechecked_func",
"(",
"func",
",",
"force",
"=",
"False",
",",
"argType",
"=",
"None",
",",
"resType",
"=",
"None",
",",
"prop_getter",
"=",
"False",
")",
":",
"if",
"not",
"pytypes",
".",
"checking_enabled",
"and",
"not",
"pytypes",
".",
"do_l... | Works like typechecked, but is only applicable to functions, methods and properties. | [
"Works",
"like",
"typechecked",
"but",
"is",
"only",
"applicable",
"to",
"functions",
"methods",
"and",
"properties",
"."
] | python | train |
wal-e/wal-e | wal_e/worker/pg/wal_transfer.py | https://github.com/wal-e/wal-e/blob/027263860e72a403bc0e1497bb3e67523138e7a2/wal_e/worker/pg/wal_transfer.py#L146-L162 | def start(self, segment):
"""Begin transfer for an indicated wal segment."""
if self.closed:
raise UserCritical(msg='attempt to transfer wal after closing',
hint='report a bug')
g = gevent.Greenlet(self.transferer, segment)
g.link(self._comple... | [
"def",
"start",
"(",
"self",
",",
"segment",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"UserCritical",
"(",
"msg",
"=",
"'attempt to transfer wal after closing'",
",",
"hint",
"=",
"'report a bug'",
")",
"g",
"=",
"gevent",
".",
"Greenlet",
"(",
... | Begin transfer for an indicated wal segment. | [
"Begin",
"transfer",
"for",
"an",
"indicated",
"wal",
"segment",
"."
] | python | train |
edx/ecommerce-worker | ecommerce_worker/sailthru/v1/tasks.py | https://github.com/edx/ecommerce-worker/blob/55246961d805b1f64d661a5c0bae0a216589401f/ecommerce_worker/sailthru/v1/tasks.py#L22-L25 | def schedule_retry(self, config):
"""Schedule a retry"""
raise self.retry(countdown=config.get('SAILTHRU_RETRY_SECONDS'),
max_retries=config.get('SAILTHRU_RETRY_ATTEMPTS')) | [
"def",
"schedule_retry",
"(",
"self",
",",
"config",
")",
":",
"raise",
"self",
".",
"retry",
"(",
"countdown",
"=",
"config",
".",
"get",
"(",
"'SAILTHRU_RETRY_SECONDS'",
")",
",",
"max_retries",
"=",
"config",
".",
"get",
"(",
"'SAILTHRU_RETRY_ATTEMPTS'",
... | Schedule a retry | [
"Schedule",
"a",
"retry"
] | python | test |
adamrehn/slidingwindow | slidingwindow/SlidingWindow.py | https://github.com/adamrehn/slidingwindow/blob/17ea9395b48671e8cb7321b9510c6b25fec5e45f/slidingwindow/SlidingWindow.py#L100-L143 | def generateForSize(width, height, dimOrder, maxWindowSize, overlapPercent, transforms = []):
"""
Generates a set of sliding windows for a dataset with the specified dimensions and order.
"""
# If the input data is smaller than the specified window size,
# clip the window size to the input size on both dimension... | [
"def",
"generateForSize",
"(",
"width",
",",
"height",
",",
"dimOrder",
",",
"maxWindowSize",
",",
"overlapPercent",
",",
"transforms",
"=",
"[",
"]",
")",
":",
"# If the input data is smaller than the specified window size,",
"# clip the window size to the input size on both... | Generates a set of sliding windows for a dataset with the specified dimensions and order. | [
"Generates",
"a",
"set",
"of",
"sliding",
"windows",
"for",
"a",
"dataset",
"with",
"the",
"specified",
"dimensions",
"and",
"order",
"."
] | python | train |
apache/incubator-superset | superset/utils/decorators.py | https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/utils/decorators.py#L46-L118 | def etag_cache(max_age, check_perms=bool):
"""
A decorator for caching views and handling etag conditional requests.
The decorator adds headers to GET requests that help with caching: Last-
Modified, Expires and ETag. It also handles conditional requests, when the
client send an If-Matches header.
... | [
"def",
"etag_cache",
"(",
"max_age",
",",
"check_perms",
"=",
"bool",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# check if the user can access ... | A decorator for caching views and handling etag conditional requests.
The decorator adds headers to GET requests that help with caching: Last-
Modified, Expires and ETag. It also handles conditional requests, when the
client send an If-Matches header.
If a cache is set, the decorator will cache GET re... | [
"A",
"decorator",
"for",
"caching",
"views",
"and",
"handling",
"etag",
"conditional",
"requests",
"."
] | python | train |
AguaClara/aguaclara | aguaclara/design/floc.py | https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/design/floc.py#L129-L138 | def W_min_HS_ratio(self):
"""Calculate the minimum flocculator channel width, given the minimum
ratio between expansion height (H) and baffle spacing (S).
:returns: Minimum channel width given H_e/S
:rtype: float * centimeter
"""
return ((self.HS_RATIO_MIN * self.Q / self... | [
"def",
"W_min_HS_ratio",
"(",
"self",
")",
":",
"return",
"(",
"(",
"self",
".",
"HS_RATIO_MIN",
"*",
"self",
".",
"Q",
"/",
"self",
".",
"downstream_H",
")",
"*",
"(",
"self",
".",
"BAFFLE_K",
"/",
"(",
"2",
"*",
"self",
".",
"downstream_H",
"*",
... | Calculate the minimum flocculator channel width, given the minimum
ratio between expansion height (H) and baffle spacing (S).
:returns: Minimum channel width given H_e/S
:rtype: float * centimeter | [
"Calculate",
"the",
"minimum",
"flocculator",
"channel",
"width",
"given",
"the",
"minimum",
"ratio",
"between",
"expansion",
"height",
"(",
"H",
")",
"and",
"baffle",
"spacing",
"(",
"S",
")",
".",
":",
"returns",
":",
"Minimum",
"channel",
"width",
"given"... | python | train |
mitsei/dlkit | dlkit/filesystem_adapter/repository/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/filesystem_adapter/repository/objects.py#L1342-L1403 | def set_data(self, data=None):
"""Sets the content data.
arg: data (osid.transport.DataInputStream): the content data
raise: InvalidArgument - ``data`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
raise: NullArgument - ``data`` is ``null``
*co... | [
"def",
"set_data",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"def",
"has_secondary_storage",
"(",
")",
":",
"return",
"'secondary_data_store_path'",
"in",
"self",
".",
"_config_map",
"extension",
"=",
"data",
".",
"name",
".",
"split",
"(",
"'.'",
"... | Sets the content data.
arg: data (osid.transport.DataInputStream): the content data
raise: InvalidArgument - ``data`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
raise: NullArgument - ``data`` is ``null``
*compliance: mandatory -- This method must be... | [
"Sets",
"the",
"content",
"data",
"."
] | python | train |
juju/charm-helpers | charmhelpers/core/services/base.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/services/base.py#L213-L220 | def get_service(self, service_name):
"""
Given the name of a registered service, return its service definition.
"""
service = self.services.get(service_name)
if not service:
raise KeyError('Service not registered: %s' % service_name)
return service | [
"def",
"get_service",
"(",
"self",
",",
"service_name",
")",
":",
"service",
"=",
"self",
".",
"services",
".",
"get",
"(",
"service_name",
")",
"if",
"not",
"service",
":",
"raise",
"KeyError",
"(",
"'Service not registered: %s'",
"%",
"service_name",
")",
... | Given the name of a registered service, return its service definition. | [
"Given",
"the",
"name",
"of",
"a",
"registered",
"service",
"return",
"its",
"service",
"definition",
"."
] | python | train |
saltstack/salt | salt/modules/nova.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nova.py#L448-L463 | def lock(instance_id, profile=None, **kwargs):
'''
Lock an instance
instance_id
ID of the instance to be locked
CLI Example:
.. code-block:: bash
salt '*' nova.lock 1138
'''
conn = _auth(profile, **kwargs)
return conn.lock(instance_id) | [
"def",
"lock",
"(",
"instance_id",
",",
"profile",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"_auth",
"(",
"profile",
",",
"*",
"*",
"kwargs",
")",
"return",
"conn",
".",
"lock",
"(",
"instance_id",
")"
] | Lock an instance
instance_id
ID of the instance to be locked
CLI Example:
.. code-block:: bash
salt '*' nova.lock 1138 | [
"Lock",
"an",
"instance"
] | python | train |
PyCQA/pylint | pylint/config.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/config.py#L816-L825 | def load_defaults(self):
"""initialize the provider using default values"""
for opt, optdict in self.options:
action = optdict.get("action")
if action != "callback":
# callback action have no default
if optdict is None:
optdict ... | [
"def",
"load_defaults",
"(",
"self",
")",
":",
"for",
"opt",
",",
"optdict",
"in",
"self",
".",
"options",
":",
"action",
"=",
"optdict",
".",
"get",
"(",
"\"action\"",
")",
"if",
"action",
"!=",
"\"callback\"",
":",
"# callback action have no default",
"if"... | initialize the provider using default values | [
"initialize",
"the",
"provider",
"using",
"default",
"values"
] | python | test |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/message.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/message.py#L609-L613 | def _fail(self, request_id, failure, duration):
"""Publish a CommandFailedEvent."""
self.listeners.publish_command_failure(
duration, failure, self.name,
request_id, self.sock_info.address, self.op_id) | [
"def",
"_fail",
"(",
"self",
",",
"request_id",
",",
"failure",
",",
"duration",
")",
":",
"self",
".",
"listeners",
".",
"publish_command_failure",
"(",
"duration",
",",
"failure",
",",
"self",
".",
"name",
",",
"request_id",
",",
"self",
".",
"sock_info"... | Publish a CommandFailedEvent. | [
"Publish",
"a",
"CommandFailedEvent",
"."
] | python | train |
saltstack/salt | salt/modules/rh_ip.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L1263-L1291 | def build_network_settings(**settings):
'''
Build the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.build_network_settings <settings>
'''
# Read current configuration and store default values
current_network_settings = _parse_rh_config(_RH_NETWORK_FILE)
... | [
"def",
"build_network_settings",
"(",
"*",
"*",
"settings",
")",
":",
"# Read current configuration and store default values",
"current_network_settings",
"=",
"_parse_rh_config",
"(",
"_RH_NETWORK_FILE",
")",
"# Build settings",
"opts",
"=",
"_parse_network_settings",
"(",
"... | Build the global network script.
CLI Example:
.. code-block:: bash
salt '*' ip.build_network_settings <settings> | [
"Build",
"the",
"global",
"network",
"script",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/io/abinit/tasks.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L2477-L2485 | def start_and_wait(self, *args, **kwargs):
"""
Helper method to start the task and wait for completion.
Mainly used when we are submitting the task via the shell without passing through a queue manager.
"""
self.start(*args, **kwargs)
retcode = self.wait()
return... | [
"def",
"start_and_wait",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"start",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"retcode",
"=",
"self",
".",
"wait",
"(",
")",
"return",
"retcode"
] | Helper method to start the task and wait for completion.
Mainly used when we are submitting the task via the shell without passing through a queue manager. | [
"Helper",
"method",
"to",
"start",
"the",
"task",
"and",
"wait",
"for",
"completion",
"."
] | python | train |
konture/CloeePy | cloeepy/logger.py | https://github.com/konture/CloeePy/blob/dcb21284d2df405d92ac6868ea7215792c9323b9/cloeepy/logger.py#L59-L68 | def _set_log_level(self):
"""
Inspects config and sets the log level as instance attr. If not present
in config, default is "INFO".
"""
# set log level on logger
log_level = "INFO"
if hasattr(self._config, "level") and self._config.level.upper() in ["DEBUG", "INFO... | [
"def",
"_set_log_level",
"(",
"self",
")",
":",
"# set log level on logger",
"log_level",
"=",
"\"INFO\"",
"if",
"hasattr",
"(",
"self",
".",
"_config",
",",
"\"level\"",
")",
"and",
"self",
".",
"_config",
".",
"level",
".",
"upper",
"(",
")",
"in",
"[",
... | Inspects config and sets the log level as instance attr. If not present
in config, default is "INFO". | [
"Inspects",
"config",
"and",
"sets",
"the",
"log",
"level",
"as",
"instance",
"attr",
".",
"If",
"not",
"present",
"in",
"config",
"default",
"is",
"INFO",
"."
] | python | train |
flatangle/flatlib | flatlib/protocols/temperament.py | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/temperament.py#L211-L245 | def scores(factors):
""" Computes the score of temperaments
and elements.
"""
temperaments = {
const.CHOLERIC: 0,
const.MELANCHOLIC: 0,
const.SANGUINE: 0,
const.PHLEGMATIC: 0
}
qualities = {
const.HOT: 0,
const.COLD: 0,
... | [
"def",
"scores",
"(",
"factors",
")",
":",
"temperaments",
"=",
"{",
"const",
".",
"CHOLERIC",
":",
"0",
",",
"const",
".",
"MELANCHOLIC",
":",
"0",
",",
"const",
".",
"SANGUINE",
":",
"0",
",",
"const",
".",
"PHLEGMATIC",
":",
"0",
"}",
"qualities",... | Computes the score of temperaments
and elements. | [
"Computes",
"the",
"score",
"of",
"temperaments",
"and",
"elements",
"."
] | python | train |
cthoyt/onto2nx | src/onto2nx/utils.py | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/utils.py#L26-L35 | def get_uri_name(url):
"""Gets the file name from the end of the URL. Only useful for PyBEL's testing though since it looks specifically
if the file is from the weird owncloud resources distributed by Fraunhofer"""
url_parsed = urlparse(url)
url_parts = url_parsed.path.split('/')
log.info('url par... | [
"def",
"get_uri_name",
"(",
"url",
")",
":",
"url_parsed",
"=",
"urlparse",
"(",
"url",
")",
"url_parts",
"=",
"url_parsed",
".",
"path",
".",
"split",
"(",
"'/'",
")",
"log",
".",
"info",
"(",
"'url parts: %s'",
",",
"url_parts",
")",
"return",
"url_par... | Gets the file name from the end of the URL. Only useful for PyBEL's testing though since it looks specifically
if the file is from the weird owncloud resources distributed by Fraunhofer | [
"Gets",
"the",
"file",
"name",
"from",
"the",
"end",
"of",
"the",
"URL",
".",
"Only",
"useful",
"for",
"PyBEL",
"s",
"testing",
"though",
"since",
"it",
"looks",
"specifically",
"if",
"the",
"file",
"is",
"from",
"the",
"weird",
"owncloud",
"resources",
... | python | train |
jazzband/django-discover-jenkins | discover_jenkins/runner.py | https://github.com/jazzband/django-discover-jenkins/blob/c0c859dfdd571de6e8f63865dfc8ebac6bab1d07/discover_jenkins/runner.py#L13-L32 | def get_tasks():
"""Get the imported task classes for each task that will be run"""
task_classes = []
for task_path in TASKS:
try:
module, classname = task_path.rsplit('.', 1)
except ValueError:
raise ImproperlyConfigured('%s isn\'t a task module' % task_path)
... | [
"def",
"get_tasks",
"(",
")",
":",
"task_classes",
"=",
"[",
"]",
"for",
"task_path",
"in",
"TASKS",
":",
"try",
":",
"module",
",",
"classname",
"=",
"task_path",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"raise",
"Imprope... | Get the imported task classes for each task that will be run | [
"Get",
"the",
"imported",
"task",
"classes",
"for",
"each",
"task",
"that",
"will",
"be",
"run"
] | python | valid |
intiocean/pyinter | pyinter/interval.py | https://github.com/intiocean/pyinter/blob/fb6e904307477fa43123cc9ab326680aa1a8cd62/pyinter/interval.py#L28-L36 | def openclosed(lower_value, upper_value):
"""Helper function to construct an interval object with a open lower and closed upper.
For example:
>>> openclosed(100.2, 800.9)
(100.2, 800.9]
"""
return Interval(Interval.OPEN, lower_value, upper_value, Interval.CLOSED) | [
"def",
"openclosed",
"(",
"lower_value",
",",
"upper_value",
")",
":",
"return",
"Interval",
"(",
"Interval",
".",
"OPEN",
",",
"lower_value",
",",
"upper_value",
",",
"Interval",
".",
"CLOSED",
")"
] | Helper function to construct an interval object with a open lower and closed upper.
For example:
>>> openclosed(100.2, 800.9)
(100.2, 800.9] | [
"Helper",
"function",
"to",
"construct",
"an",
"interval",
"object",
"with",
"a",
"open",
"lower",
"and",
"closed",
"upper",
"."
] | python | train |
pybel/pybel | src/pybel/struct/query/query.py | https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/query/query.py#L111-L119 | def run(self, manager):
"""Run this query and returns the resulting BEL graph.
:param manager: A cache manager
:rtype: Optional[pybel.BELGraph]
"""
universe = self._get_universe(manager)
graph = self.seeding.run(universe)
return self.pipeline.run(graph, universe=... | [
"def",
"run",
"(",
"self",
",",
"manager",
")",
":",
"universe",
"=",
"self",
".",
"_get_universe",
"(",
"manager",
")",
"graph",
"=",
"self",
".",
"seeding",
".",
"run",
"(",
"universe",
")",
"return",
"self",
".",
"pipeline",
".",
"run",
"(",
"grap... | Run this query and returns the resulting BEL graph.
:param manager: A cache manager
:rtype: Optional[pybel.BELGraph] | [
"Run",
"this",
"query",
"and",
"returns",
"the",
"resulting",
"BEL",
"graph",
"."
] | python | train |
GeospatialPython/pyshp | shapefile.py | https://github.com/GeospatialPython/pyshp/blob/71231ddc5aa54f155d4f0563c56006fffbfc84e7/shapefile.py#L1041-L1045 | def iterShapeRecords(self):
"""Returns a generator of combination geometry/attribute records for
all records in a shapefile."""
for shape, record in izip(self.iterShapes(), self.iterRecords()):
yield ShapeRecord(shape=shape, record=record) | [
"def",
"iterShapeRecords",
"(",
"self",
")",
":",
"for",
"shape",
",",
"record",
"in",
"izip",
"(",
"self",
".",
"iterShapes",
"(",
")",
",",
"self",
".",
"iterRecords",
"(",
")",
")",
":",
"yield",
"ShapeRecord",
"(",
"shape",
"=",
"shape",
",",
"re... | Returns a generator of combination geometry/attribute records for
all records in a shapefile. | [
"Returns",
"a",
"generator",
"of",
"combination",
"geometry",
"/",
"attribute",
"records",
"for",
"all",
"records",
"in",
"a",
"shapefile",
"."
] | python | train |
PGower/PyCanvas | pycanvas/apis/pages.py | https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/pages.py#L53-L101 | def update_create_front_page_courses(self, course_id, wiki_page_body=None, wiki_page_editing_roles=None, wiki_page_notify_of_update=None, wiki_page_published=None, wiki_page_title=None):
"""
Update/create front page.
Update the title or contents of the front page
"""
path ... | [
"def",
"update_create_front_page_courses",
"(",
"self",
",",
"course_id",
",",
"wiki_page_body",
"=",
"None",
",",
"wiki_page_editing_roles",
"=",
"None",
",",
"wiki_page_notify_of_update",
"=",
"None",
",",
"wiki_page_published",
"=",
"None",
",",
"wiki_page_title",
... | Update/create front page.
Update the title or contents of the front page | [
"Update",
"/",
"create",
"front",
"page",
".",
"Update",
"the",
"title",
"or",
"contents",
"of",
"the",
"front",
"page"
] | python | train |
wummel/linkchecker | linkcheck/checker/httpurl.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/httpurl.py#L118-L152 | def check_connection (self):
"""
Check a URL with HTTP protocol.
Here is an excerpt from RFC 1945 with common response codes:
The first digit of the Status-Code defines the class of response. The
last two digits do not have any categorization role. There are 5
values for ... | [
"def",
"check_connection",
"(",
"self",
")",
":",
"self",
".",
"session",
"=",
"self",
".",
"aggregate",
".",
"get_request_session",
"(",
")",
"# set the proxy, so a 407 status after this is an error",
"self",
".",
"set_proxy",
"(",
"self",
".",
"aggregate",
".",
... | Check a URL with HTTP protocol.
Here is an excerpt from RFC 1945 with common response codes:
The first digit of the Status-Code defines the class of response. The
last two digits do not have any categorization role. There are 5
values for the first digit:
- 1xx: Informational -... | [
"Check",
"a",
"URL",
"with",
"HTTP",
"protocol",
".",
"Here",
"is",
"an",
"excerpt",
"from",
"RFC",
"1945",
"with",
"common",
"response",
"codes",
":",
"The",
"first",
"digit",
"of",
"the",
"Status",
"-",
"Code",
"defines",
"the",
"class",
"of",
"respons... | python | train |
facelessuser/wcmatch | wcmatch/_wcparse.py | https://github.com/facelessuser/wcmatch/blob/d153e7007cc73b994ae1ba553dc4584039f5c212/wcmatch/_wcparse.py#L756-L858 | def _sequence(self, i):
"""Handle character group."""
result = ['[']
end_range = 0
escape_hyphen = -1
removed = False
last_posix = False
c = next(i)
if c in ('!', '^'):
# Handle negate char
result.append('^')
c = next(... | [
"def",
"_sequence",
"(",
"self",
",",
"i",
")",
":",
"result",
"=",
"[",
"'['",
"]",
"end_range",
"=",
"0",
"escape_hyphen",
"=",
"-",
"1",
"removed",
"=",
"False",
"last_posix",
"=",
"False",
"c",
"=",
"next",
"(",
"i",
")",
"if",
"c",
"in",
"("... | Handle character group. | [
"Handle",
"character",
"group",
"."
] | python | train |
scidash/sciunit | sciunit/utils.py | https://github.com/scidash/sciunit/blob/41b2e38c45c0776727ab1f281a572b65be19cea1/sciunit/utils.py#L352-L376 | def import_all_modules(package, skip=None, verbose=False, prefix="", depth=0):
"""Recursively imports all subpackages, modules, and submodules of a
given package.
'package' should be an imported package, not a string.
'skip' is a list of modules or subpackages not to import.
"""
skip = [] if sk... | [
"def",
"import_all_modules",
"(",
"package",
",",
"skip",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
",",
"depth",
"=",
"0",
")",
":",
"skip",
"=",
"[",
"]",
"if",
"skip",
"is",
"None",
"else",
"skip",
"for",
"ff",
",",
... | Recursively imports all subpackages, modules, and submodules of a
given package.
'package' should be an imported package, not a string.
'skip' is a list of modules or subpackages not to import. | [
"Recursively",
"imports",
"all",
"subpackages",
"modules",
"and",
"submodules",
"of",
"a",
"given",
"package",
".",
"package",
"should",
"be",
"an",
"imported",
"package",
"not",
"a",
"string",
".",
"skip",
"is",
"a",
"list",
"of",
"modules",
"or",
"subpacka... | python | train |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_timeseries.py | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_timeseries.py#L154-L171 | def check_recommended_attributes(self, dataset):
'''
Feature type specific check of global recommended attributes.
:param netCDF4.Dataset dataset: An open netCDF dataset
'''
results = []
recommended_ctx = TestCtx(BaseCheck.MEDIUM, 'Recommended global attributes')
... | [
"def",
"check_recommended_attributes",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"recommended_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"MEDIUM",
",",
"'Recommended global attributes'",
")",
"# Check time_coverage_duration and resolution",
"for... | Feature type specific check of global recommended attributes.
:param netCDF4.Dataset dataset: An open netCDF dataset | [
"Feature",
"type",
"specific",
"check",
"of",
"global",
"recommended",
"attributes",
"."
] | python | train |
abakan-zz/napi | napi/transformers.py | https://github.com/abakan-zz/napi/blob/314da65bd78e2c716b7efb6deaf3816d8f38f7fd/napi/transformers.py#L160-L210 | def napi_and(values, **kwargs):
"""Perform element-wise logical *and* operation on arrays.
If *values* contains a non-array object with truth_ value **False**, the
outcome will be an array of **False**\s with suitable shape without arrays
being evaluated. Non-array objects with truth value **True** are... | [
"def",
"napi_and",
"(",
"values",
",",
"*",
"*",
"kwargs",
")",
":",
"arrays",
"=",
"[",
"]",
"result",
"=",
"None",
"shapes",
"=",
"set",
"(",
")",
"for",
"value",
"in",
"values",
":",
"if",
"isinstance",
"(",
"value",
",",
"ndarray",
")",
"and",
... | Perform element-wise logical *and* operation on arrays.
If *values* contains a non-array object with truth_ value **False**, the
outcome will be an array of **False**\s with suitable shape without arrays
being evaluated. Non-array objects with truth value **True** are omitted.
If array shapes do not m... | [
"Perform",
"element",
"-",
"wise",
"logical",
"*",
"and",
"*",
"operation",
"on",
"arrays",
"."
] | python | train |
trec-kba/streamcorpus-pipeline | streamcorpus_pipeline/_kvlayer.py | https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer.py#L249-L266 | def get_kvlayer_stream_ids_by_doc_id(client, doc_id):
'''Retrieve stream ids from :mod:`kvlayer`.
Namely, it returns an iterator over all stream ids with the given
docid. The docid should be an md5 hash of the document's abs_url.
:param client: kvlayer client object
:type client: :class:`kvlayer.A... | [
"def",
"get_kvlayer_stream_ids_by_doc_id",
"(",
"client",
",",
"doc_id",
")",
":",
"if",
"client",
"is",
"None",
":",
"client",
"=",
"kvlayer",
".",
"client",
"(",
")",
"client",
".",
"setup_namespace",
"(",
"STREAM_ITEM_TABLE_DEFS",
",",
"STREAM_ITEM_VALUE_DEFS",... | Retrieve stream ids from :mod:`kvlayer`.
Namely, it returns an iterator over all stream ids with the given
docid. The docid should be an md5 hash of the document's abs_url.
:param client: kvlayer client object
:type client: :class:`kvlayer.AbstractStorage`
:param str doc_id: doc id of documents to... | [
"Retrieve",
"stream",
"ids",
"from",
":",
"mod",
":",
"kvlayer",
"."
] | python | test |
sam-cox/pytides | pytides/tide.py | https://github.com/sam-cox/pytides/blob/63a2507299002f1979ea55a17a82561158d685f7/pytides/tide.py#L229-L239 | def _partition(hours, partition = 3600.0):
"""
Partition a sorted list of numbers (or in this case hours).
Arguments:
hours -- sorted ndarray of hours.
partition -- maximum partition length (default: 3600.0)
"""
partition = float(partition)
relative = hours - hours[0]
total_partitions = np.ceil(relati... | [
"def",
"_partition",
"(",
"hours",
",",
"partition",
"=",
"3600.0",
")",
":",
"partition",
"=",
"float",
"(",
"partition",
")",
"relative",
"=",
"hours",
"-",
"hours",
"[",
"0",
"]",
"total_partitions",
"=",
"np",
".",
"ceil",
"(",
"relative",
"[",
"-"... | Partition a sorted list of numbers (or in this case hours).
Arguments:
hours -- sorted ndarray of hours.
partition -- maximum partition length (default: 3600.0) | [
"Partition",
"a",
"sorted",
"list",
"of",
"numbers",
"(",
"or",
"in",
"this",
"case",
"hours",
")",
".",
"Arguments",
":",
"hours",
"--",
"sorted",
"ndarray",
"of",
"hours",
".",
"partition",
"--",
"maximum",
"partition",
"length",
"(",
"default",
":",
"... | python | train |
StellarCN/py-stellar-base | stellar_base/builder.py | https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/builder.py#L91-L105 | def append_op(self, operation):
"""Append an :class:`Operation <stellar_base.operation.Operation>` to
the list of operations.
Add the operation specified if it doesn't already exist in the list of
operations of this :class:`Builder` instance.
:param operation: The operation to ... | [
"def",
"append_op",
"(",
"self",
",",
"operation",
")",
":",
"if",
"operation",
"not",
"in",
"self",
".",
"ops",
":",
"self",
".",
"ops",
".",
"append",
"(",
"operation",
")",
"return",
"self"
] | Append an :class:`Operation <stellar_base.operation.Operation>` to
the list of operations.
Add the operation specified if it doesn't already exist in the list of
operations of this :class:`Builder` instance.
:param operation: The operation to append to the list of operations.
:... | [
"Append",
"an",
":",
"class",
":",
"Operation",
"<stellar_base",
".",
"operation",
".",
"Operation",
">",
"to",
"the",
"list",
"of",
"operations",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/controllers/state_editor/scoped_variable_list.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/state_editor/scoped_variable_list.py#L185-L196 | def apply_new_scoped_variable_default_value(self, path, new_default_value_str):
"""Applies the new default value of the scoped variable defined by path
:param str path: The path identifying the edited variable
:param str new_default_value_str: New default value as string
"""
dat... | [
"def",
"apply_new_scoped_variable_default_value",
"(",
"self",
",",
"path",
",",
"new_default_value_str",
")",
":",
"data_port_id",
"=",
"self",
".",
"get_list_store_row_from_cursor_selection",
"(",
")",
"[",
"self",
".",
"ID_STORAGE_ID",
"]",
"try",
":",
"if",
"str... | Applies the new default value of the scoped variable defined by path
:param str path: The path identifying the edited variable
:param str new_default_value_str: New default value as string | [
"Applies",
"the",
"new",
"default",
"value",
"of",
"the",
"scoped",
"variable",
"defined",
"by",
"path"
] | python | train |
pschmitt/pyteleloisirs | pyteleloisirs/pyteleloisirs.py | https://github.com/pschmitt/pyteleloisirs/blob/d63610fd3729862455ac42afca440469f8063fba/pyteleloisirs/pyteleloisirs.py#L128-L144 | def get_remaining_time(program):
'''
Get the remaining time in seconds of a program that is currently on.
'''
now = datetime.datetime.now()
program_start = program.get('start_time')
program_end = program.get('end_time')
if not program_start or not program_end:
_LOGGER.error('Could no... | [
"def",
"get_remaining_time",
"(",
"program",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"program_start",
"=",
"program",
".",
"get",
"(",
"'start_time'",
")",
"program_end",
"=",
"program",
".",
"get",
"(",
"'end_time'",
")",
... | Get the remaining time in seconds of a program that is currently on. | [
"Get",
"the",
"remaining",
"time",
"in",
"seconds",
"of",
"a",
"program",
"that",
"is",
"currently",
"on",
"."
] | python | train |
python-visualization/folium | folium/features.py | https://github.com/python-visualization/folium/blob/8595240517135d1637ca4cf7cc624045f1d911b3/folium/features.py#L469-L494 | def process_data(self, data):
"""Convert an unknown data input into a geojson dictionary."""
if isinstance(data, dict):
self.embed = True
return data
elif isinstance(data, str):
if data.lower().startswith(('http:', 'ftp:', 'https:')):
if not se... | [
"def",
"process_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"self",
".",
"embed",
"=",
"True",
"return",
"data",
"elif",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"if",
"data",
".",
"low... | Convert an unknown data input into a geojson dictionary. | [
"Convert",
"an",
"unknown",
"data",
"input",
"into",
"a",
"geojson",
"dictionary",
"."
] | python | train |
BerkeleyAutomation/visualization | visualization/visualizer3d.py | https://github.com/BerkeleyAutomation/visualization/blob/f8d038cc65c78f841ef27f99fb2a638f44fa72b6/visualization/visualizer3d.py#L76-L106 | def render(n_frames=1, axis=np.array([0.,0.,1.]), clf=True, **kwargs):
"""Render frames from the viewer.
Parameters
----------
n_frames : int
Number of frames to render. If more than one, the scene will animate.
axis : (3,) float or None
If present, the a... | [
"def",
"render",
"(",
"n_frames",
"=",
"1",
",",
"axis",
"=",
"np",
".",
"array",
"(",
"[",
"0.",
",",
"0.",
",",
"1.",
"]",
")",
",",
"clf",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"v",
"=",
"SceneViewer",
"(",
"Visualizer3D",
".",
"... | Render frames from the viewer.
Parameters
----------
n_frames : int
Number of frames to render. If more than one, the scene will animate.
axis : (3,) float or None
If present, the animation will rotate about the given axis in world coordinates.
Otherw... | [
"Render",
"frames",
"from",
"the",
"viewer",
"."
] | python | train |
marcomusy/vtkplotter | vtkplotter/actors.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/actors.py#L2387-L2397 | def getActors(self):
"""Unpack a list of ``vtkActor`` objects from a ``vtkAssembly``."""
cl = vtk.vtkPropCollection()
self.GetActors(cl)
self.actors = []
cl.InitTraversal()
for i in range(self.GetNumberOfPaths()):
act = vtk.vtkActor.SafeDownCast(cl.GetNextProp... | [
"def",
"getActors",
"(",
"self",
")",
":",
"cl",
"=",
"vtk",
".",
"vtkPropCollection",
"(",
")",
"self",
".",
"GetActors",
"(",
"cl",
")",
"self",
".",
"actors",
"=",
"[",
"]",
"cl",
".",
"InitTraversal",
"(",
")",
"for",
"i",
"in",
"range",
"(",
... | Unpack a list of ``vtkActor`` objects from a ``vtkAssembly``. | [
"Unpack",
"a",
"list",
"of",
"vtkActor",
"objects",
"from",
"a",
"vtkAssembly",
"."
] | python | train |
Azure/azure-sdk-for-python | azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/knowledgebase_operations.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/knowledgebase_operations.py#L285-L347 | def update(
self, kb_id, update_kb, custom_headers=None, raw=False, **operation_config):
"""Asynchronous operation to modify a knowledgebase.
:param kb_id: Knowledgebase id.
:type kb_id: str
:param update_kb: Post body of the request.
:type update_kb:
~azure... | [
"def",
"update",
"(",
"self",
",",
"kb_id",
",",
"update_kb",
",",
"custom_headers",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"*",
"*",
"operation_config",
")",
":",
"# Construct URL",
"url",
"=",
"self",
".",
"update",
".",
"metadata",
"[",
"'url'",
... | Asynchronous operation to modify a knowledgebase.
:param kb_id: Knowledgebase id.
:type kb_id: str
:param update_kb: Post body of the request.
:type update_kb:
~azure.cognitiveservices.knowledge.qnamaker.models.UpdateKbOperationDTO
:param dict custom_headers: headers th... | [
"Asynchronous",
"operation",
"to",
"modify",
"a",
"knowledgebase",
"."
] | python | test |
DocNow/twarc | twarc/decorators.py | https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/decorators.py#L81-L93 | def catch_timeout(f):
"""
A decorator to handle read timeouts from Twitter.
"""
def new_f(self, *args, **kwargs):
try:
return f(self, *args, **kwargs)
except (requests.exceptions.ReadTimeout,
requests.packages.urllib3.exceptions.ReadTimeoutError) as e:
... | [
"def",
"catch_timeout",
"(",
"f",
")",
":",
"def",
"new_f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"(",
"requests",
"."... | A decorator to handle read timeouts from Twitter. | [
"A",
"decorator",
"to",
"handle",
"read",
"timeouts",
"from",
"Twitter",
"."
] | python | train |
foremast/foremast | src/foremast/securitygroup/destroy_sg/destroy_sg.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/securitygroup/destroy_sg/destroy_sg.py#L27-L52 | def destroy_sg(app='', env='', region='', **_):
"""Destroy Security Group.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): Region name, e.g. us-east-1.
Returns:
True upon successful completion.
"""
vpc = get_vpc_id(accou... | [
"def",
"destroy_sg",
"(",
"app",
"=",
"''",
",",
"env",
"=",
"''",
",",
"region",
"=",
"''",
",",
"*",
"*",
"_",
")",
":",
"vpc",
"=",
"get_vpc_id",
"(",
"account",
"=",
"env",
",",
"region",
"=",
"region",
")",
"url",
"=",
"'{api}/securityGroups/{... | Destroy Security Group.
Args:
app (str): Spinnaker Application name.
env (str): Deployment environment.
region (str): Region name, e.g. us-east-1.
Returns:
True upon successful completion. | [
"Destroy",
"Security",
"Group",
"."
] | python | train |
Neurosim-lab/netpyne | netpyne/conversion/sonataImport.py | https://github.com/Neurosim-lab/netpyne/blob/edb67b5098b2e7923d55010ded59ad1bf75c0f18/netpyne/conversion/sonataImport.py#L103-L131 | def fix_axon_peri(hobj):
"""Replace reconstructed axon with a stub
:param hobj: hoc object
"""
for i,sec in enumerate(hobj.axon):
hobj.axon[i] = None
for i,sec in enumerate(hobj.all):
if 'axon' in sec.name():
hobj.all[i] = None
hobj.all = [sec for sec in hobj.all if... | [
"def",
"fix_axon_peri",
"(",
"hobj",
")",
":",
"for",
"i",
",",
"sec",
"in",
"enumerate",
"(",
"hobj",
".",
"axon",
")",
":",
"hobj",
".",
"axon",
"[",
"i",
"]",
"=",
"None",
"for",
"i",
",",
"sec",
"in",
"enumerate",
"(",
"hobj",
".",
"all",
"... | Replace reconstructed axon with a stub
:param hobj: hoc object | [
"Replace",
"reconstructed",
"axon",
"with",
"a",
"stub",
":",
"param",
"hobj",
":",
"hoc",
"object"
] | python | train |
haikuginger/beekeeper | beekeeper/comms.py | https://github.com/haikuginger/beekeeper/blob/b647d3add0b407ec5dc3a2a39c4f6dac31243b18/beekeeper/comms.py#L152-L160 | def mimetype(self):
"""
Get the Content-Type header from the response. Strip
the ";charset=xxxxx" portion if necessary. If we can't
find it, use the predefined format.
"""
if ';' in self.headers.get('Content-Type', ''):
return self.headers['Content-Type'].spli... | [
"def",
"mimetype",
"(",
"self",
")",
":",
"if",
"';'",
"in",
"self",
".",
"headers",
".",
"get",
"(",
"'Content-Type'",
",",
"''",
")",
":",
"return",
"self",
".",
"headers",
"[",
"'Content-Type'",
"]",
".",
"split",
"(",
"';'",
")",
"[",
"0",
"]",... | Get the Content-Type header from the response. Strip
the ";charset=xxxxx" portion if necessary. If we can't
find it, use the predefined format. | [
"Get",
"the",
"Content",
"-",
"Type",
"header",
"from",
"the",
"response",
".",
"Strip",
"the",
";",
"charset",
"=",
"xxxxx",
"portion",
"if",
"necessary",
".",
"If",
"we",
"can",
"t",
"find",
"it",
"use",
"the",
"predefined",
"format",
"."
] | python | train |
alfredodeza/remoto | remoto/connection.py | https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/connection.py#L10-L48 | def get(name, fallback='ssh'):
"""
Retrieve the matching backend class from a string. If no backend can be
matched, it raises an error.
>>> get('ssh')
<class 'remoto.backends.BaseConnection'>
>>> get()
<class 'remoto.backends.BaseConnection'>
>>> get('non-existent')
<class 'remoto.b... | [
"def",
"get",
"(",
"name",
",",
"fallback",
"=",
"'ssh'",
")",
":",
"mapping",
"=",
"{",
"'ssh'",
":",
"ssh",
".",
"SshConnection",
",",
"'oc'",
":",
"openshift",
".",
"OpenshiftConnection",
",",
"'openshift'",
":",
"openshift",
".",
"OpenshiftConnection",
... | Retrieve the matching backend class from a string. If no backend can be
matched, it raises an error.
>>> get('ssh')
<class 'remoto.backends.BaseConnection'>
>>> get()
<class 'remoto.backends.BaseConnection'>
>>> get('non-existent')
<class 'remoto.backends.BaseConnection'>
>>> get('non-e... | [
"Retrieve",
"the",
"matching",
"backend",
"class",
"from",
"a",
"string",
".",
"If",
"no",
"backend",
"can",
"be",
"matched",
"it",
"raises",
"an",
"error",
"."
] | python | train |
CalebBell/thermo | thermo/eos_mix.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/eos_mix.py#L330-L353 | def solve_T(self, P, V, quick=True):
r'''Generic method to calculate `T` from a specified `P` and `V`.
Provides SciPy's `newton` solver, and iterates to solve the general
equation for `P`, recalculating `a_alpha` as a function of temperature
using `a_alpha_and_derivatives` each iteration... | [
"def",
"solve_T",
"(",
"self",
",",
"P",
",",
"V",
",",
"quick",
"=",
"True",
")",
":",
"self",
".",
"Tc",
"=",
"sum",
"(",
"self",
".",
"Tcs",
")",
"/",
"self",
".",
"N",
"# -4 goes back from object, GCEOS",
"return",
"super",
"(",
"type",
"(",
"s... | r'''Generic method to calculate `T` from a specified `P` and `V`.
Provides SciPy's `newton` solver, and iterates to solve the general
equation for `P`, recalculating `a_alpha` as a function of temperature
using `a_alpha_and_derivatives` each iteration.
Parameters
----------
... | [
"r",
"Generic",
"method",
"to",
"calculate",
"T",
"from",
"a",
"specified",
"P",
"and",
"V",
".",
"Provides",
"SciPy",
"s",
"newton",
"solver",
"and",
"iterates",
"to",
"solve",
"the",
"general",
"equation",
"for",
"P",
"recalculating",
"a_alpha",
"as",
"a... | python | valid |
tmontaigu/pylas | pylas/lasreader.py | https://github.com/tmontaigu/pylas/blob/8335a1a7d7677f0e4bc391bb6fa3c75b42ed5b06/pylas/lasreader.py#L15-L21 | def _raise_if_wrong_file_signature(stream):
""" Reads the 4 first bytes of the stream to check that is LASF"""
file_sig = stream.read(len(headers.LAS_FILE_SIGNATURE))
if file_sig != headers.LAS_FILE_SIGNATURE:
raise errors.PylasError(
"File Signature ({}) is not {}".format(file_sig, head... | [
"def",
"_raise_if_wrong_file_signature",
"(",
"stream",
")",
":",
"file_sig",
"=",
"stream",
".",
"read",
"(",
"len",
"(",
"headers",
".",
"LAS_FILE_SIGNATURE",
")",
")",
"if",
"file_sig",
"!=",
"headers",
".",
"LAS_FILE_SIGNATURE",
":",
"raise",
"errors",
"."... | Reads the 4 first bytes of the stream to check that is LASF | [
"Reads",
"the",
"4",
"first",
"bytes",
"of",
"the",
"stream",
"to",
"check",
"that",
"is",
"LASF"
] | python | test |
ShawnClake/Apitax | apitax/ah/api/controllers/admins_controller.py | https://github.com/ShawnClake/Apitax/blob/2eb9c6990d4088b2503c7f13c2a76f8e59606e6d/apitax/ah/api/controllers/admins_controller.py#L54-L67 | def system_status(): # noqa: E501
"""Retrieve the system status
Retrieve the system status # noqa: E501
:rtype: Response
"""
if(not hasAccess()):
return redirectUnauthorized()
body = State.config.serialize(["driver", "log", "log-file", "log-colorize"])
body.update({'debug': Stat... | [
"def",
"system_status",
"(",
")",
":",
"# noqa: E501",
"if",
"(",
"not",
"hasAccess",
"(",
")",
")",
":",
"return",
"redirectUnauthorized",
"(",
")",
"body",
"=",
"State",
".",
"config",
".",
"serialize",
"(",
"[",
"\"driver\"",
",",
"\"log\"",
",",
"\"l... | Retrieve the system status
Retrieve the system status # noqa: E501
:rtype: Response | [
"Retrieve",
"the",
"system",
"status"
] | python | train |
hydpy-dev/hydpy | hydpy/core/netcdftools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/netcdftools.py#L700-L709 | def write(self) -> None:
"""Call method |NetCDFFile.write| of all handled |NetCDFFile| objects.
"""
if self.folders:
init = hydpy.pub.timegrids.init
timeunits = init.firstdate.to_cfunits('hours')
timepoints = init.to_timepoints('hours')
for folder ... | [
"def",
"write",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"folders",
":",
"init",
"=",
"hydpy",
".",
"pub",
".",
"timegrids",
".",
"init",
"timeunits",
"=",
"init",
".",
"firstdate",
".",
"to_cfunits",
"(",
"'hours'",
")",
"timepoints",
... | Call method |NetCDFFile.write| of all handled |NetCDFFile| objects. | [
"Call",
"method",
"|NetCDFFile",
".",
"write|",
"of",
"all",
"handled",
"|NetCDFFile|",
"objects",
"."
] | python | train |
allenai/allennlp | allennlp/common/checks.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/checks.py#L51-L71 | def parse_cuda_device(cuda_device: Union[str, int, List[int]]) -> Union[int, List[int]]:
"""
Disambiguates single GPU and multiple GPU settings for cuda_device param.
"""
def from_list(strings):
if len(strings) > 1:
return [int(d) for d in strings]
elif len(strings) == 1:
... | [
"def",
"parse_cuda_device",
"(",
"cuda_device",
":",
"Union",
"[",
"str",
",",
"int",
",",
"List",
"[",
"int",
"]",
"]",
")",
"->",
"Union",
"[",
"int",
",",
"List",
"[",
"int",
"]",
"]",
":",
"def",
"from_list",
"(",
"strings",
")",
":",
"if",
"... | Disambiguates single GPU and multiple GPU settings for cuda_device param. | [
"Disambiguates",
"single",
"GPU",
"and",
"multiple",
"GPU",
"settings",
"for",
"cuda_device",
"param",
"."
] | python | train |
saltstack/salt | salt/modules/keystone.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/keystone.py#L589-L605 | def service_list(profile=None, **connection_args):
'''
Return a list of available services (keystone services-list)
CLI Example:
.. code-block:: bash
salt '*' keystone.service_list
'''
kstone = auth(profile, **connection_args)
ret = {}
for service in kstone.services.list():
... | [
"def",
"service_list",
"(",
"profile",
"=",
"None",
",",
"*",
"*",
"connection_args",
")",
":",
"kstone",
"=",
"auth",
"(",
"profile",
",",
"*",
"*",
"connection_args",
")",
"ret",
"=",
"{",
"}",
"for",
"service",
"in",
"kstone",
".",
"services",
".",
... | Return a list of available services (keystone services-list)
CLI Example:
.. code-block:: bash
salt '*' keystone.service_list | [
"Return",
"a",
"list",
"of",
"available",
"services",
"(",
"keystone",
"services",
"-",
"list",
")"
] | python | train |
Arubacloud/pyArubaCloud | ArubaCloud/ReverseDns/ReverseDns.py | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L12-L21 | def get(self, addresses):
"""
:type addresses: list[str]
:param addresses: (list[str]) List of addresses to retrieve their reverse dns
Retrieve the current configured ReverseDns entries
:return: (list) List containing the current ReverseDns Addresses
"""
request =... | [
"def",
"get",
"(",
"self",
",",
"addresses",
")",
":",
"request",
"=",
"self",
".",
"_call",
"(",
"GetReverseDns",
".",
"GetReverseDns",
",",
"IPs",
"=",
"addresses",
")",
"response",
"=",
"request",
".",
"commit",
"(",
")",
"return",
"response",
"[",
... | :type addresses: list[str]
:param addresses: (list[str]) List of addresses to retrieve their reverse dns
Retrieve the current configured ReverseDns entries
:return: (list) List containing the current ReverseDns Addresses | [
":",
"type",
"addresses",
":",
"list",
"[",
"str",
"]",
":",
"param",
"addresses",
":",
"(",
"list",
"[",
"str",
"]",
")",
"List",
"of",
"addresses",
"to",
"retrieve",
"their",
"reverse",
"dns",
"Retrieve",
"the",
"current",
"configured",
"ReverseDns",
"... | python | train |
MakerReduxCorp/PLOD | PLOD/__init__.py | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/__init__.py#L195-L249 | def upsert(self, key, value, entry):
'''Update or Insert an entry into the list of dictionaries.
If a dictionary in the list is found where key matches the value, then
the FIRST matching list entry is replaced with entry
else
the entry is appended to the end of the list.
... | [
"def",
"upsert",
"(",
"self",
",",
"key",
",",
"value",
",",
"entry",
")",
":",
"index",
"=",
"internal",
".",
"get_index",
"(",
"self",
".",
"table",
",",
"key",
",",
"self",
".",
"EQUAL",
",",
"value",
")",
"if",
"index",
"is",
"None",
":",
"se... | Update or Insert an entry into the list of dictionaries.
If a dictionary in the list is found where key matches the value, then
the FIRST matching list entry is replaced with entry
else
the entry is appended to the end of the list.
The new entry is not examined in any way... | [
"Update",
"or",
"Insert",
"an",
"entry",
"into",
"the",
"list",
"of",
"dictionaries",
"."
] | python | train |
auth0/auth0-python | auth0/v3/management/users.py | https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L184-L193 | def get_guardian_enrollments(self, user_id):
"""Retrieves all Guardian enrollments.
Args:
user_id (str): The user_id of the user to retrieve
See: https://auth0.com/docs/api/management/v2#!/Users/get_enrollments
"""
url = self._url('{}/enrollments'.format(user_id))
... | [
"def",
"get_guardian_enrollments",
"(",
"self",
",",
"user_id",
")",
":",
"url",
"=",
"self",
".",
"_url",
"(",
"'{}/enrollments'",
".",
"format",
"(",
"user_id",
")",
")",
"return",
"self",
".",
"client",
".",
"get",
"(",
"url",
")"
] | Retrieves all Guardian enrollments.
Args:
user_id (str): The user_id of the user to retrieve
See: https://auth0.com/docs/api/management/v2#!/Users/get_enrollments | [
"Retrieves",
"all",
"Guardian",
"enrollments",
"."
] | python | train |
ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_misc.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_misc.py#L314-L320 | def cmd_devid(self, args):
'''decode device IDs from parameters'''
for p in self.mav_param.keys():
if p.startswith('COMPASS_DEV_ID'):
mp_util.decode_devid(self.mav_param[p], p)
if p.startswith('INS_') and p.endswith('_ID'):
mp_util.decode_devid(sel... | [
"def",
"cmd_devid",
"(",
"self",
",",
"args",
")",
":",
"for",
"p",
"in",
"self",
".",
"mav_param",
".",
"keys",
"(",
")",
":",
"if",
"p",
".",
"startswith",
"(",
"'COMPASS_DEV_ID'",
")",
":",
"mp_util",
".",
"decode_devid",
"(",
"self",
".",
"mav_pa... | decode device IDs from parameters | [
"decode",
"device",
"IDs",
"from",
"parameters"
] | python | train |
adewes/blitzdb | blitzdb/backends/file/index.py | https://github.com/adewes/blitzdb/blob/4b459e0bcde9e1f6224dd4e3bea74194586864b0/blitzdb/backends/file/index.py#L193-L210 | def save_to_data(self, in_place=False):
"""Save index to data structure.
:param in_place: Do not copy index value to a new list object
:type in_place: bool
:return: Index data structure
:rtype: list
"""
if in_place:
return [
list(self... | [
"def",
"save_to_data",
"(",
"self",
",",
"in_place",
"=",
"False",
")",
":",
"if",
"in_place",
":",
"return",
"[",
"list",
"(",
"self",
".",
"_index",
".",
"items",
"(",
")",
")",
",",
"list",
"(",
"self",
".",
"_undefined_keys",
".",
"keys",
"(",
... | Save index to data structure.
:param in_place: Do not copy index value to a new list object
:type in_place: bool
:return: Index data structure
:rtype: list | [
"Save",
"index",
"to",
"data",
"structure",
"."
] | python | train |
delph-in/pydelphin | delphin/mrs/vpm.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/vpm.py#L151-L173 | def _valmatch(vs, ss, op, varsort, semi, section):
"""
Return `True` if for every paired *v* and *s* from *vs* and *ss*:
v <> s (subsumption or equality if *semi* is `None`)
v == s (equality)
s == '*'
s == '!' and v == `None`
s == '[xyz]' and varsort == 'xyz'
"""
... | [
"def",
"_valmatch",
"(",
"vs",
",",
"ss",
",",
"op",
",",
"varsort",
",",
"semi",
",",
"section",
")",
":",
"if",
"op",
"in",
"_EQUAL_OPS",
"or",
"semi",
"is",
"None",
":",
"return",
"all",
"(",
"s",
"==",
"v",
"or",
"# value equality",
"(",
"s",
... | Return `True` if for every paired *v* and *s* from *vs* and *ss*:
v <> s (subsumption or equality if *semi* is `None`)
v == s (equality)
s == '*'
s == '!' and v == `None`
s == '[xyz]' and varsort == 'xyz' | [
"Return",
"True",
"if",
"for",
"every",
"paired",
"*",
"v",
"*",
"and",
"*",
"s",
"*",
"from",
"*",
"vs",
"*",
"and",
"*",
"ss",
"*",
":",
"v",
"<",
">",
"s",
"(",
"subsumption",
"or",
"equality",
"if",
"*",
"semi",
"*",
"is",
"None",
")",
"v... | python | train |
spdx/tools-python | spdx/parsers/tagvaluebuilders.py | https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/tagvaluebuilders.py#L1062-L1072 | def set_lic_id(self, doc, lic_id):
"""Adds a new extracted license to the document.
Raises SPDXValueError if data format is incorrect.
"""
# FIXME: this state does not make sense
self.reset_extr_lics()
if validations.validate_extracted_lic_id(lic_id):
doc.add_... | [
"def",
"set_lic_id",
"(",
"self",
",",
"doc",
",",
"lic_id",
")",
":",
"# FIXME: this state does not make sense",
"self",
".",
"reset_extr_lics",
"(",
")",
"if",
"validations",
".",
"validate_extracted_lic_id",
"(",
"lic_id",
")",
":",
"doc",
".",
"add_extr_lic",
... | Adds a new extracted license to the document.
Raises SPDXValueError if data format is incorrect. | [
"Adds",
"a",
"new",
"extracted",
"license",
"to",
"the",
"document",
".",
"Raises",
"SPDXValueError",
"if",
"data",
"format",
"is",
"incorrect",
"."
] | python | valid |
PythonicNinja/pydrill | pydrill/client/__init__.py | https://github.com/PythonicNinja/pydrill/blob/0713e78c84d44cd438018e4ba1588a8e242f78c4/pydrill/client/__init__.py#L68-L75 | def plan(self, sql, timeout=10):
"""
:param sql: string
:param timeout: int
:return: pydrill.client.ResultQuery
"""
sql = 'explain plan for ' + sql
return self.query(sql, timeout) | [
"def",
"plan",
"(",
"self",
",",
"sql",
",",
"timeout",
"=",
"10",
")",
":",
"sql",
"=",
"'explain plan for '",
"+",
"sql",
"return",
"self",
".",
"query",
"(",
"sql",
",",
"timeout",
")"
] | :param sql: string
:param timeout: int
:return: pydrill.client.ResultQuery | [
":",
"param",
"sql",
":",
"string",
":",
"param",
"timeout",
":",
"int",
":",
"return",
":",
"pydrill",
".",
"client",
".",
"ResultQuery"
] | python | train |
softlayer/softlayer-python | SoftLayer/managers/block.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L262-L304 | def order_duplicate_volume(self, origin_volume_id, origin_snapshot_id=None,
duplicate_size=None, duplicate_iops=None,
duplicate_tier_level=None,
duplicate_snapshot_size=None,
hourly_billing_flag=F... | [
"def",
"order_duplicate_volume",
"(",
"self",
",",
"origin_volume_id",
",",
"origin_snapshot_id",
"=",
"None",
",",
"duplicate_size",
"=",
"None",
",",
"duplicate_iops",
"=",
"None",
",",
"duplicate_tier_level",
"=",
"None",
",",
"duplicate_snapshot_size",
"=",
"Non... | Places an order for a duplicate block volume.
:param origin_volume_id: The ID of the origin volume to be duplicated
:param origin_snapshot_id: Origin snapshot ID to use for duplication
:param duplicate_size: Size/capacity for the duplicate volume
:param duplicate_iops: The IOPS per GB f... | [
"Places",
"an",
"order",
"for",
"a",
"duplicate",
"block",
"volume",
"."
] | python | train |
hyperledger/indy-plenum | plenum/server/node.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3134-L3140 | def lost_master_primary(self):
"""
Schedule an primary connection check which in turn can send a view
change message
"""
self.primaries_disconnection_times[self.master_replica.instId] = time.perf_counter()
self._schedule_view_change() | [
"def",
"lost_master_primary",
"(",
"self",
")",
":",
"self",
".",
"primaries_disconnection_times",
"[",
"self",
".",
"master_replica",
".",
"instId",
"]",
"=",
"time",
".",
"perf_counter",
"(",
")",
"self",
".",
"_schedule_view_change",
"(",
")"
] | Schedule an primary connection check which in turn can send a view
change message | [
"Schedule",
"an",
"primary",
"connection",
"check",
"which",
"in",
"turn",
"can",
"send",
"a",
"view",
"change",
"message"
] | python | train |
pazz/alot | alot/helper.py | https://github.com/pazz/alot/blob/d0297605c0ec1c6b65f541d0fd5b69ac5a0f4ded/alot/helper.py#L440-L488 | def mimewrap(path, filename=None, ctype=None):
"""Take the contents of the given path and wrap them into an email MIME
part according to the content type. The content type is auto detected from
the actual file contents and the file name if it is not given.
:param path: the path to the file contents
... | [
"def",
"mimewrap",
"(",
"path",
",",
"filename",
"=",
"None",
",",
"ctype",
"=",
"None",
")",
":",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"read",
"(",
")",
"if",
"not",
"ctype",
":",
"ctype",
"=... | Take the contents of the given path and wrap them into an email MIME
part according to the content type. The content type is auto detected from
the actual file contents and the file name if it is not given.
:param path: the path to the file contents
:type path: str
:param filename: the file name t... | [
"Take",
"the",
"contents",
"of",
"the",
"given",
"path",
"and",
"wrap",
"them",
"into",
"an",
"email",
"MIME",
"part",
"according",
"to",
"the",
"content",
"type",
".",
"The",
"content",
"type",
"is",
"auto",
"detected",
"from",
"the",
"actual",
"file",
... | python | train |
horazont/aioxmpp | aioxmpp/security_layer.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/security_layer.py#L541-L549 | def pin(self, hostname, x509):
"""
Pin an :class:`OpenSSL.crypto.X509` object `x509` for use with the
given `hostname`. Which information exactly is used to identify the
certificate depends :meth:`_x509_key`.
"""
key = self._x509_key(x509)
self._storage.setdefaul... | [
"def",
"pin",
"(",
"self",
",",
"hostname",
",",
"x509",
")",
":",
"key",
"=",
"self",
".",
"_x509_key",
"(",
"x509",
")",
"self",
".",
"_storage",
".",
"setdefault",
"(",
"hostname",
",",
"set",
"(",
")",
")",
".",
"add",
"(",
"key",
")"
] | Pin an :class:`OpenSSL.crypto.X509` object `x509` for use with the
given `hostname`. Which information exactly is used to identify the
certificate depends :meth:`_x509_key`. | [
"Pin",
"an",
":",
"class",
":",
"OpenSSL",
".",
"crypto",
".",
"X509",
"object",
"x509",
"for",
"use",
"with",
"the",
"given",
"hostname",
".",
"Which",
"information",
"exactly",
"is",
"used",
"to",
"identify",
"the",
"certificate",
"depends",
":",
"meth",... | python | train |
smarie/python-autoclass | autoclass/autoprops_.py | https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L281-L338 | def _get_setter_fun(object_type, # type: Type
parameter, # type: Parameter
private_property_name # type: str
):
"""
Utility method to find the overridden setter function for a given property, or generate a new one
:param obj... | [
"def",
"_get_setter_fun",
"(",
"object_type",
",",
"# type: Type",
"parameter",
",",
"# type: Parameter",
"private_property_name",
"# type: str",
")",
":",
"# the property will have the same name than the constructor argument",
"property_name",
"=",
"parameter",
".",
"name",
"o... | Utility method to find the overridden setter function for a given property, or generate a new one
:param object_type:
:param property_name:
:param property_type:
:param private_property_name:
:return: | [
"Utility",
"method",
"to",
"find",
"the",
"overridden",
"setter",
"function",
"for",
"a",
"given",
"property",
"or",
"generate",
"a",
"new",
"one"
] | python | train |
pantsbuild/pants | src/python/pants/build_graph/build_graph.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/build_graph/build_graph.py#L169-L180 | def dependents_of(self, address):
"""Returns the addresses of the targets that depend on the target at `address`.
This method asserts that the address given is actually in the BuildGraph.
:API: public
"""
assert address in self._target_by_address, (
'Cannot retrieve dependents of {address} b... | [
"def",
"dependents_of",
"(",
"self",
",",
"address",
")",
":",
"assert",
"address",
"in",
"self",
".",
"_target_by_address",
",",
"(",
"'Cannot retrieve dependents of {address} because it is not in the BuildGraph.'",
".",
"format",
"(",
"address",
"=",
"address",
")",
... | Returns the addresses of the targets that depend on the target at `address`.
This method asserts that the address given is actually in the BuildGraph.
:API: public | [
"Returns",
"the",
"addresses",
"of",
"the",
"targets",
"that",
"depend",
"on",
"the",
"target",
"at",
"address",
"."
] | python | train |
Jajcus/pyxmpp2 | pyxmpp2/stanzaprocessor.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/stanzaprocessor.py#L240-L275 | def __try_handlers(self, handler_list, stanza, stanza_type = None):
""" Search the handler list for handlers matching
given stanza type and payload namespace. Run the
handlers found ordering them by priority until
the first one which returns `True`.
:Parameters:
- `h... | [
"def",
"__try_handlers",
"(",
"self",
",",
"handler_list",
",",
"stanza",
",",
"stanza_type",
"=",
"None",
")",
":",
"# pylint: disable=W0212",
"if",
"stanza_type",
"is",
"None",
":",
"stanza_type",
"=",
"stanza",
".",
"stanza_type",
"payload",
"=",
"stanza",
... | Search the handler list for handlers matching
given stanza type and payload namespace. Run the
handlers found ordering them by priority until
the first one which returns `True`.
:Parameters:
- `handler_list`: list of available handlers
- `stanza`: the stanza to h... | [
"Search",
"the",
"handler",
"list",
"for",
"handlers",
"matching",
"given",
"stanza",
"type",
"and",
"payload",
"namespace",
".",
"Run",
"the",
"handlers",
"found",
"ordering",
"them",
"by",
"priority",
"until",
"the",
"first",
"one",
"which",
"returns",
"True... | python | valid |
MolSSI-BSE/basis_set_exchange | basis_set_exchange/cli/bse_handlers.py | https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/cli/bse_handlers.py#L75-L89 | def _bse_cli_get_basis(args):
'''Handles the get-basis subcommand'''
return api.get_basis(
name=args.basis,
elements=args.elements,
version=args.version,
fmt=args.fmt,
uncontract_general=args.unc_gen,
uncontract_spdf=args.unc_spdf,
uncontract_segmented=ar... | [
"def",
"_bse_cli_get_basis",
"(",
"args",
")",
":",
"return",
"api",
".",
"get_basis",
"(",
"name",
"=",
"args",
".",
"basis",
",",
"elements",
"=",
"args",
".",
"elements",
",",
"version",
"=",
"args",
".",
"version",
",",
"fmt",
"=",
"args",
".",
"... | Handles the get-basis subcommand | [
"Handles",
"the",
"get",
"-",
"basis",
"subcommand"
] | python | train |
bcbio/bcbio-nextgen | bcbio/cwl/hpc.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/hpc.py#L61-L69 | def _load_custom_config(run_config):
"""Load custom configuration input HOCON file for cromwell.
"""
from pyhocon import ConfigFactory, HOCONConverter, ConfigTree
conf = ConfigFactory.parse_file(run_config)
out = {}
if "database" in conf:
out["database"] = HOCONConverter.to_hocon(ConfigT... | [
"def",
"_load_custom_config",
"(",
"run_config",
")",
":",
"from",
"pyhocon",
"import",
"ConfigFactory",
",",
"HOCONConverter",
",",
"ConfigTree",
"conf",
"=",
"ConfigFactory",
".",
"parse_file",
"(",
"run_config",
")",
"out",
"=",
"{",
"}",
"if",
"\"database\""... | Load custom configuration input HOCON file for cromwell. | [
"Load",
"custom",
"configuration",
"input",
"HOCON",
"file",
"for",
"cromwell",
"."
] | python | train |
etcher-be/emiz | emiz/weather/mission_weather/mission_weather.py | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/mission_weather/mission_weather.py#L119-L130 | def _gauss(mean: int, sigma: int) -> int:
"""
Creates a variation from a base value
Args:
mean: base value
sigma: gaussian sigma
Returns: random value
"""
return int(random.gauss(mean, sigma)) | [
"def",
"_gauss",
"(",
"mean",
":",
"int",
",",
"sigma",
":",
"int",
")",
"->",
"int",
":",
"return",
"int",
"(",
"random",
".",
"gauss",
"(",
"mean",
",",
"sigma",
")",
")"
] | Creates a variation from a base value
Args:
mean: base value
sigma: gaussian sigma
Returns: random value | [
"Creates",
"a",
"variation",
"from",
"a",
"base",
"value"
] | python | train |
apache/incubator-mxnet | example/ssd/symbol/common.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/common.py#L21-L55 | def conv_act_layer(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \
stride=(1,1), act_type="relu", use_batchnorm=False):
"""
wrapper for a small Convolution group
Parameters:
----------
from_layer : mx.symbol
continue on which layer
name : str
base name of the new la... | [
"def",
"conv_act_layer",
"(",
"from_layer",
",",
"name",
",",
"num_filter",
",",
"kernel",
"=",
"(",
"1",
",",
"1",
")",
",",
"pad",
"=",
"(",
"0",
",",
"0",
")",
",",
"stride",
"=",
"(",
"1",
",",
"1",
")",
",",
"act_type",
"=",
"\"relu\"",
",... | wrapper for a small Convolution group
Parameters:
----------
from_layer : mx.symbol
continue on which layer
name : str
base name of the new layers
num_filter : int
how many filters to use in Convolution layer
kernel : tuple (int, int)
kernel size (h, w)
pad :... | [
"wrapper",
"for",
"a",
"small",
"Convolution",
"group"
] | python | train |
WhereSoftwareGoesToDie/pymarquise | marquise/marquise.py | https://github.com/WhereSoftwareGoesToDie/pymarquise/blob/67e52df70c50ed53ad315a64fea430a9567e2b1b/marquise/marquise.py#L64-L82 | def close(self):
"""Close the Marquise context, ensuring data is flushed and
spool files are closed.
This should always be closed explicitly, as there's no
guarantees that it will happen when the instance is deleted.
"""
if self.marquise_ctx is None:
self.__d... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"marquise_ctx",
"is",
"None",
":",
"self",
".",
"__debug",
"(",
"\"Marquise handle is already closed, will do nothing.\"",
")",
"# Multiple close() calls are okay.",
"return",
"self",
".",
"__debug",
"(",
"\"... | Close the Marquise context, ensuring data is flushed and
spool files are closed.
This should always be closed explicitly, as there's no
guarantees that it will happen when the instance is deleted. | [
"Close",
"the",
"Marquise",
"context",
"ensuring",
"data",
"is",
"flushed",
"and",
"spool",
"files",
"are",
"closed",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.