repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
dbrattli/OSlash | oslash/observable.py | https://github.com/dbrattli/OSlash/blob/ffdc714c5d454f7519f740254de89f70850929eb/oslash/observable.py#L47-L53 | def bind(self, fn: Callable[[Any], 'Observable']) -> 'Observable':
r"""Chain continuation passing functions.
Haskell: m >>= k = Cont $ \c -> runCont m $ \a -> runCont (k a) c
"""
source = self
return Observable(lambda on_next: source.subscribe(lambda a: fn(a).subscribe(on_next))... | [
"def",
"bind",
"(",
"self",
",",
"fn",
":",
"Callable",
"[",
"[",
"Any",
"]",
",",
"'Observable'",
"]",
")",
"->",
"'Observable'",
":",
"source",
"=",
"self",
"return",
"Observable",
"(",
"lambda",
"on_next",
":",
"source",
".",
"subscribe",
"(",
"lamb... | r"""Chain continuation passing functions.
Haskell: m >>= k = Cont $ \c -> runCont m $ \a -> runCont (k a) c | [
"r",
"Chain",
"continuation",
"passing",
"functions",
"."
] | python | train | 45 |
astropy/photutils | photutils/segmentation/properties.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/segmentation/properties.py#L1061-L1078 | def eccentricity(self):
"""
The eccentricity of the 2D Gaussian function that has the same
second-order moments as the source.
The eccentricity is the fraction of the distance along the
semimajor axis at which the focus lies.
.. math:: e = \\sqrt{1 - \\frac{b^2}{a^2}}
... | [
"def",
"eccentricity",
"(",
"self",
")",
":",
"l1",
",",
"l2",
"=",
"self",
".",
"covariance_eigvals",
"if",
"l1",
"==",
"0",
":",
"return",
"0.",
"# pragma: no cover",
"return",
"np",
".",
"sqrt",
"(",
"1.",
"-",
"(",
"l2",
"/",
"l1",
")",
")"
] | The eccentricity of the 2D Gaussian function that has the same
second-order moments as the source.
The eccentricity is the fraction of the distance along the
semimajor axis at which the focus lies.
.. math:: e = \\sqrt{1 - \\frac{b^2}{a^2}}
where :math:`a` and :math:`b` are th... | [
"The",
"eccentricity",
"of",
"the",
"2D",
"Gaussian",
"function",
"that",
"has",
"the",
"same",
"second",
"-",
"order",
"moments",
"as",
"the",
"source",
"."
] | python | train | 31.666667 |
the01/python-floscraper | floscraper/webscraper.py | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/webscraper.py#L642-L655 | def shrink(self, shrink):
"""
Remove unnecessary parts
:param shrink: Object to shringk
:type shrink: dict | list
:return: Shrunk object
:rtype: dict | list
"""
if isinstance(shrink, list):
return self._shrink_list(shrink)
if isinstanc... | [
"def",
"shrink",
"(",
"self",
",",
"shrink",
")",
":",
"if",
"isinstance",
"(",
"shrink",
",",
"list",
")",
":",
"return",
"self",
".",
"_shrink_list",
"(",
"shrink",
")",
"if",
"isinstance",
"(",
"shrink",
",",
"dict",
")",
":",
"return",
"self",
".... | Remove unnecessary parts
:param shrink: Object to shringk
:type shrink: dict | list
:return: Shrunk object
:rtype: dict | list | [
"Remove",
"unnecessary",
"parts"
] | python | train | 27.857143 |
googledatalab/pydatalab | google/datalab/ml/_job.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_job.py#L119-L151 | def submit_batch_prediction(job_request, job_id=None):
"""Submit a batch prediction job.
Args:
job_request: the arguments of the training job in a dict. For example,
{
'version_name': 'projects/my-project/models/my-model/versions/my-version',
'data_format': 'TEXT',
... | [
"def",
"submit_batch_prediction",
"(",
"job_request",
",",
"job_id",
"=",
"None",
")",
":",
"if",
"job_id",
"is",
"None",
":",
"job_id",
"=",
"'prediction_'",
"+",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%y%m%d_%H%M%S'",
... | Submit a batch prediction job.
Args:
job_request: the arguments of the training job in a dict. For example,
{
'version_name': 'projects/my-project/models/my-model/versions/my-version',
'data_format': 'TEXT',
'input_paths': ['gs://my_bucket/my_file.csv'],
... | [
"Submit",
"a",
"batch",
"prediction",
"job",
"."
] | python | train | 36.787879 |
chemlab/chemlab | chemlab/mviewer/api/selections.py | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/selections.py#L54-L69 | def select_connected_bonds():
'''Select the bonds connected to the currently selected atoms.'''
s = current_system()
start, end = s.bonds.transpose()
selected = np.zeros(s.n_bonds, 'bool')
for i in selected_atoms():
selected |= (i == start) | (i == end)
csel = current_selection()
bs... | [
"def",
"select_connected_bonds",
"(",
")",
":",
"s",
"=",
"current_system",
"(",
")",
"start",
",",
"end",
"=",
"s",
".",
"bonds",
".",
"transpose",
"(",
")",
"selected",
"=",
"np",
".",
"zeros",
"(",
"s",
".",
"n_bonds",
",",
"'bool'",
")",
"for",
... | Select the bonds connected to the currently selected atoms. | [
"Select",
"the",
"bonds",
"connected",
"to",
"the",
"currently",
"selected",
"atoms",
"."
] | python | train | 29.125 |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5943-L5953 | def setActionManifestPath(self, pchActionManifestPath):
"""
Sets the path to the action manifest JSON file that is used by this application. If this information
was set on the Steam partner site, calls to this function are ignored. If the Steam partner site
setting and the path provided ... | [
"def",
"setActionManifestPath",
"(",
"self",
",",
"pchActionManifestPath",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"setActionManifestPath",
"result",
"=",
"fn",
"(",
"pchActionManifestPath",
")",
"return",
"result"
] | Sets the path to the action manifest JSON file that is used by this application. If this information
was set on the Steam partner site, calls to this function are ignored. If the Steam partner site
setting and the path provided by this call are different, VRInputError_MismatchedActionManifest is returne... | [
"Sets",
"the",
"path",
"to",
"the",
"action",
"manifest",
"JSON",
"file",
"that",
"is",
"used",
"by",
"this",
"application",
".",
"If",
"this",
"information",
"was",
"set",
"on",
"the",
"Steam",
"partner",
"site",
"calls",
"to",
"this",
"function",
"are",
... | python | train | 56.818182 |
yunojuno/elasticsearch-django | elasticsearch_django/settings.py | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L29-L34 | def get_setting(key, *default):
"""Return specific search setting from Django conf."""
if default:
return get_settings().get(key, default[0])
else:
return get_settings()[key] | [
"def",
"get_setting",
"(",
"key",
",",
"*",
"default",
")",
":",
"if",
"default",
":",
"return",
"get_settings",
"(",
")",
".",
"get",
"(",
"key",
",",
"default",
"[",
"0",
"]",
")",
"else",
":",
"return",
"get_settings",
"(",
")",
"[",
"key",
"]"
... | Return specific search setting from Django conf. | [
"Return",
"specific",
"search",
"setting",
"from",
"Django",
"conf",
"."
] | python | train | 32.833333 |
XuShaohua/bcloud | bcloud/gutil.py | https://github.com/XuShaohua/bcloud/blob/4b54e0fdccf2b3013285fef05c97354cfa31697b/bcloud/gutil.py#L329-L340 | def tree_model_natsort(model, row1, row2, user_data=None):
'''用natural sorting算法对TreeModel的一个column进行排序'''
sort_column, sort_type = model.get_sort_column_id()
value1 = model.get_value(row1, sort_column)
value2 = model.get_value(row2, sort_column)
sort_list1 = util.natsort(value1)
sort_list2 = ut... | [
"def",
"tree_model_natsort",
"(",
"model",
",",
"row1",
",",
"row2",
",",
"user_data",
"=",
"None",
")",
":",
"sort_column",
",",
"sort_type",
"=",
"model",
".",
"get_sort_column_id",
"(",
")",
"value1",
"=",
"model",
".",
"get_value",
"(",
"row1",
",",
... | 用natural sorting算法对TreeModel的一个column进行排序 | [
"用natural",
"sorting算法对TreeModel的一个column进行排序"
] | python | train | 36.75 |
dougalsutherland/skl-groups | skl_groups/kernels/transform.py | https://github.com/dougalsutherland/skl-groups/blob/2584c10a413626c6d5f9078cdbf3dcc84e4e9a5b/skl_groups/kernels/transform.py#L259-L290 | def fit(self, X, y=None):
'''
Learn the linear transformation to clipped eigenvalues.
Note that if min_eig isn't zero and any of the original eigenvalues
were exactly zero, this will leave those eigenvalues as zero.
Parameters
----------
X : array, shape [n, n]
... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"n",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
"if",
"X",
".",
"shape",
"!=",
"(",
"n",
",",
"n",
")",
":",
"raise",
"TypeError",
"(",
"\"Input must be a square matrix.\"",
")",
... | Learn the linear transformation to clipped eigenvalues.
Note that if min_eig isn't zero and any of the original eigenvalues
were exactly zero, this will leave those eigenvalues as zero.
Parameters
----------
X : array, shape [n, n]
The *symmetric* input similarities... | [
"Learn",
"the",
"linear",
"transformation",
"to",
"clipped",
"eigenvalues",
"."
] | python | valid | 36.1875 |
saltstack/salt | salt/utils/openstack/nova.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L869-L875 | def keypair_delete(self, name):
'''
Delete a keypair
'''
nt_ks = self.compute_conn
nt_ks.keypairs.delete(name)
return 'Keypair deleted: {0}'.format(name) | [
"def",
"keypair_delete",
"(",
"self",
",",
"name",
")",
":",
"nt_ks",
"=",
"self",
".",
"compute_conn",
"nt_ks",
".",
"keypairs",
".",
"delete",
"(",
"name",
")",
"return",
"'Keypair deleted: {0}'",
".",
"format",
"(",
"name",
")"
] | Delete a keypair | [
"Delete",
"a",
"keypair"
] | python | train | 27.857143 |
TrafficSenseMSD/SumoTools | traci/_vehicle.py | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/traci/_vehicle.py#L896-L932 | def setEffort(self, vehID, edgeID, effort=None, begTime=None, endTime=None):
"""setEffort(string, string, double, int, int) -> None
Inserts the information about the effort of edge "edgeID" valid from
begin time to end time into the vehicle's internal edge weights
container.
If t... | [
"def",
"setEffort",
"(",
"self",
",",
"vehID",
",",
"edgeID",
",",
"effort",
"=",
"None",
",",
"begTime",
"=",
"None",
",",
"endTime",
"=",
"None",
")",
":",
"if",
"type",
"(",
"edgeID",
")",
"!=",
"str",
"and",
"type",
"(",
"begTime",
")",
"==",
... | setEffort(string, string, double, int, int) -> None
Inserts the information about the effort of edge "edgeID" valid from
begin time to end time into the vehicle's internal edge weights
container.
If the time is not specified, any previously set values for that edge
are removed.
... | [
"setEffort",
"(",
"string",
"string",
"double",
"int",
"int",
")",
"-",
">",
"None",
"Inserts",
"the",
"information",
"about",
"the",
"effort",
"of",
"edge",
"edgeID",
"valid",
"from",
"begin",
"time",
"to",
"end",
"time",
"into",
"the",
"vehicle",
"s",
... | python | train | 61.243243 |
note35/sinon | sinon/lib/base.py | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/base.py#L207-L227 | def wrap2stub(self, customfunc):
"""
Wrapping the inspector as a stub based on the type
Args:
customfunc: function that replaces the original
Returns:
function, the spy wrapper around the customfunc
"""
if self.args_type == "MODULE_FUNCTION":
... | [
"def",
"wrap2stub",
"(",
"self",
",",
"customfunc",
")",
":",
"if",
"self",
".",
"args_type",
"==",
"\"MODULE_FUNCTION\"",
":",
"wrapper",
"=",
"Wrapper",
".",
"wrap_spy",
"(",
"customfunc",
",",
"self",
".",
"obj",
")",
"setattr",
"(",
"self",
".",
"obj... | Wrapping the inspector as a stub based on the type
Args:
customfunc: function that replaces the original
Returns:
function, the spy wrapper around the customfunc | [
"Wrapping",
"the",
"inspector",
"as",
"a",
"stub",
"based",
"on",
"the",
"type",
"Args",
":",
"customfunc",
":",
"function",
"that",
"replaces",
"the",
"original",
"Returns",
":",
"function",
"the",
"spy",
"wrapper",
"around",
"the",
"customfunc"
] | python | train | 40.761905 |
QUANTAXIS/QUANTAXIS | QUANTAXIS/QAARP/QARisk.py | https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAARP/QARisk.py#L252-L266 | def max_dropback(self):
"""最大回撤
"""
return round(
float(
max(
[
(self.assets.iloc[idx] - self.assets.iloc[idx::].min())
/ self.assets.iloc[idx]
for idx in range(len(self.assets... | [
"def",
"max_dropback",
"(",
"self",
")",
":",
"return",
"round",
"(",
"float",
"(",
"max",
"(",
"[",
"(",
"self",
".",
"assets",
".",
"iloc",
"[",
"idx",
"]",
"-",
"self",
".",
"assets",
".",
"iloc",
"[",
"idx",
":",
":",
"]",
".",
"min",
"(",
... | 最大回撤 | [
"最大回撤"
] | python | train | 25.8 |
saltstack/salt | salt/states/tuned.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/tuned.py#L18-L86 | def profile(name):
'''
This state module allows you to modify system tuned parameters
Example tuned.sls file to set profile to virtual-guest
tuned:
tuned:
- profile
- name: virtual-guest
name
tuned profile name to set the system to
To see a valid list of states ... | [
"def",
"profile",
"(",
"name",
")",
":",
"# create data-structure to return with default value",
"ret",
"=",
"{",
"'name'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",
"ret",
"[",
"name",
"]"... | This state module allows you to modify system tuned parameters
Example tuned.sls file to set profile to virtual-guest
tuned:
tuned:
- profile
- name: virtual-guest
name
tuned profile name to set the system to
To see a valid list of states call execution module:
... | [
"This",
"state",
"module",
"allows",
"you",
"to",
"modify",
"system",
"tuned",
"parameters"
] | python | train | 27.913043 |
bspaans/python-mingus | mingus/midi/pyfluidsynth.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/pyfluidsynth.py#L41-L48 | def cfunc(name, result, *args):
"""Build and apply a ctypes prototype complete with parameter flags."""
atypes = []
aflags = []
for arg in args:
atypes.append(arg[1])
aflags.append((arg[2], arg[0]) + arg[3:])
return CFUNCTYPE(result, *atypes)((name, _fl), tuple(aflags)) | [
"def",
"cfunc",
"(",
"name",
",",
"result",
",",
"*",
"args",
")",
":",
"atypes",
"=",
"[",
"]",
"aflags",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"atypes",
".",
"append",
"(",
"arg",
"[",
"1",
"]",
")",
"aflags",
".",
"append",
"(",
... | Build and apply a ctypes prototype complete with parameter flags. | [
"Build",
"and",
"apply",
"a",
"ctypes",
"prototype",
"complete",
"with",
"parameter",
"flags",
"."
] | python | train | 37.375 |
slundberg/shap | shap/benchmark/metrics.py | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L225-L232 | def keep_absolute_resample__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 12
"""
return __run_measure(measures.keep_resample, X, y, model_generator, met... | [
"def",
"keep_absolute_resample__roc_auc",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_resample",
",",
"X",
",",
"y",
",",
"model_generator",
","... | Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 12 | [
"Keep",
"Absolute",
"(",
"resample",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"ROC",
"AUC",
"transform",
"=",
"identity",
"sort_order",
"=",
"12"
] | python | train | 46.125 |
saltstack/salt | salt/modules/pagerduty_util.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pagerduty_util.py#L106-L121 | def _list_items(action, key, profile=None, subdomain=None, api_key=None):
'''
List items belonging to an API call.
This method should be in utils.pagerduty.
'''
items = _query(
profile=profile,
subdomain=subdomain,
api_key=api_key,
action=action
)
ret = {}
... | [
"def",
"_list_items",
"(",
"action",
",",
"key",
",",
"profile",
"=",
"None",
",",
"subdomain",
"=",
"None",
",",
"api_key",
"=",
"None",
")",
":",
"items",
"=",
"_query",
"(",
"profile",
"=",
"profile",
",",
"subdomain",
"=",
"subdomain",
",",
"api_ke... | List items belonging to an API call.
This method should be in utils.pagerduty. | [
"List",
"items",
"belonging",
"to",
"an",
"API",
"call",
"."
] | python | train | 23.625 |
theodoregoetz/wernher | wernher/colorline.py | https://github.com/theodoregoetz/wernher/blob/ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e/wernher/colorline.py#L31-L40 | def make_segments(x, y):
"""
Create list of line segments from x and y coordinates, in the correct format
for LineCollection: an array of the form numlines x (points per line) x 2 (x
and y) array
"""
points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], point... | [
"def",
"make_segments",
"(",
"x",
",",
"y",
")",
":",
"points",
"=",
"np",
".",
"array",
"(",
"[",
"x",
",",
"y",
"]",
")",
".",
"T",
".",
"reshape",
"(",
"-",
"1",
",",
"1",
",",
"2",
")",
"segments",
"=",
"np",
".",
"concatenate",
"(",
"[... | Create list of line segments from x and y coordinates, in the correct format
for LineCollection: an array of the form numlines x (points per line) x 2 (x
and y) array | [
"Create",
"list",
"of",
"line",
"segments",
"from",
"x",
"and",
"y",
"coordinates",
"in",
"the",
"correct",
"format",
"for",
"LineCollection",
":",
"an",
"array",
"of",
"the",
"form",
"numlines",
"x",
"(",
"points",
"per",
"line",
")",
"x",
"2",
"(",
"... | python | train | 34.6 |
draperunner/fjlc | fjlc/utils/json_utils.py | https://github.com/draperunner/fjlc/blob/d2cc8cf1244984e7caf0bf95b11ed1677a94c994/fjlc/utils/json_utils.py#L18-L27 | def to_json_file(file, data, pretty):
"""
Writes object instance in JSON formatted String to file
:param file: File to write JSON string ot
:param data: Object to convert to JSON
:param pretty: Use pretty formatting or not
"""
json_string = to_json(data, pretty)
file_utils.write_to... | [
"def",
"to_json_file",
"(",
"file",
",",
"data",
",",
"pretty",
")",
":",
"json_string",
"=",
"to_json",
"(",
"data",
",",
"pretty",
")",
"file_utils",
".",
"write_to_file",
"(",
"file",
",",
"json_string",
")"
] | Writes object instance in JSON formatted String to file
:param file: File to write JSON string ot
:param data: Object to convert to JSON
:param pretty: Use pretty formatting or not | [
"Writes",
"object",
"instance",
"in",
"JSON",
"formatted",
"String",
"to",
"file",
":",
"param",
"file",
":",
"File",
"to",
"write",
"JSON",
"string",
"ot",
":",
"param",
"data",
":",
"Object",
"to",
"convert",
"to",
"JSON",
":",
"param",
"pretty",
":",
... | python | train | 33.5 |
estnltk/estnltk | estnltk/text.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/text.py#L954-L958 | def clause_annotations(self):
"""The list of clause annotations in ``words`` layer."""
if not self.is_tagged(CLAUSE_ANNOTATION):
self.tag_clause_annotations()
return [word.get(CLAUSE_ANNOTATION, None) for word in self[WORDS]] | [
"def",
"clause_annotations",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_tagged",
"(",
"CLAUSE_ANNOTATION",
")",
":",
"self",
".",
"tag_clause_annotations",
"(",
")",
"return",
"[",
"word",
".",
"get",
"(",
"CLAUSE_ANNOTATION",
",",
"None",
")",
"... | The list of clause annotations in ``words`` layer. | [
"The",
"list",
"of",
"clause",
"annotations",
"in",
"words",
"layer",
"."
] | python | train | 51.4 |
uwdata/draco | draco/helper.py | https://github.com/uwdata/draco/blob/b130b5ebdb369e18e046706c73dc9c29b8159f7f/draco/helper.py#L37-L56 | def read_data_to_asp(file: str) -> List[str]:
""" Reads the given JSON file and generates the ASP definition.
Args:
file: the json data file
Returns:
the asp definition.
"""
if file.endswith(".json"):
with open(file) as f:
data = json.load(f)
... | [
"def",
"read_data_to_asp",
"(",
"file",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"if",
"file",
".",
"endswith",
"(",
"\".json\"",
")",
":",
"with",
"open",
"(",
"file",
")",
"as",
"f",
":",
"data",
"=",
"json",
".",
"load",
"(",
"f",
... | Reads the given JSON file and generates the ASP definition.
Args:
file: the json data file
Returns:
the asp definition. | [
"Reads",
"the",
"given",
"JSON",
"file",
"and",
"generates",
"the",
"ASP",
"definition",
".",
"Args",
":",
"file",
":",
"the",
"json",
"data",
"file",
"Returns",
":",
"the",
"asp",
"definition",
"."
] | python | train | 32 |
kkroening/ffmpeg-python | examples/tensorflow_stream.py | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/tensorflow_stream.py#L199-L213 | def _calc_grad_tiled(self, img, t_grad, tile_size=512):
'''Compute the value of tensor t_grad over the image in a tiled way.
Random shifts are applied to the image to blur tile boundaries over
multiple iterations.'''
sz = tile_size
h, w = img.shape[:2]
sx, sy = np.random... | [
"def",
"_calc_grad_tiled",
"(",
"self",
",",
"img",
",",
"t_grad",
",",
"tile_size",
"=",
"512",
")",
":",
"sz",
"=",
"tile_size",
"h",
",",
"w",
"=",
"img",
".",
"shape",
"[",
":",
"2",
"]",
"sx",
",",
"sy",
"=",
"np",
".",
"random",
".",
"ran... | Compute the value of tensor t_grad over the image in a tiled way.
Random shifts are applied to the image to blur tile boundaries over
multiple iterations. | [
"Compute",
"the",
"value",
"of",
"tensor",
"t_grad",
"over",
"the",
"image",
"in",
"a",
"tiled",
"way",
".",
"Random",
"shifts",
"are",
"applied",
"to",
"the",
"image",
"to",
"blur",
"tile",
"boundaries",
"over",
"multiple",
"iterations",
"."
] | python | train | 48.266667 |
eandersson/amqpstorm | amqpstorm/connection.py | https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L145-L170 | def channel(self, rpc_timeout=60, lazy=False):
"""Open Channel.
:param int rpc_timeout: Timeout before we give up waiting for an RPC
response from the server.
:raises AMQPInvalidArgument: Invalid Parameters
:raises AMQPChannelError: Raises if the channel... | [
"def",
"channel",
"(",
"self",
",",
"rpc_timeout",
"=",
"60",
",",
"lazy",
"=",
"False",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'Opening a new Channel'",
")",
"if",
"not",
"compatibility",
".",
"is_integer",
"(",
"rpc_timeout",
")",
":",
"raise",
"AMQPInv... | Open Channel.
:param int rpc_timeout: Timeout before we give up waiting for an RPC
response from the server.
:raises AMQPInvalidArgument: Invalid Parameters
:raises AMQPChannelError: Raises if the channel encountered an error.
:raises AMQPConnectionError... | [
"Open",
"Channel",
"."
] | python | train | 43.730769 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/notification/notification_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/notification/notification_client.py#L186-L197 | def query_subscriptions(self, subscription_query):
"""QuerySubscriptions.
[Preview API] Query for subscriptions. A subscription is returned if it matches one or more of the specified conditions.
:param :class:`<SubscriptionQuery> <azure.devops.v5_0.notification.models.SubscriptionQuery>` subscri... | [
"def",
"query_subscriptions",
"(",
"self",
",",
"subscription_query",
")",
":",
"content",
"=",
"self",
".",
"_serialize",
".",
"body",
"(",
"subscription_query",
",",
"'SubscriptionQuery'",
")",
"response",
"=",
"self",
".",
"_send",
"(",
"http_method",
"=",
... | QuerySubscriptions.
[Preview API] Query for subscriptions. A subscription is returned if it matches one or more of the specified conditions.
:param :class:`<SubscriptionQuery> <azure.devops.v5_0.notification.models.SubscriptionQuery>` subscription_query:
:rtype: [NotificationSubscription] | [
"QuerySubscriptions",
".",
"[",
"Preview",
"API",
"]",
"Query",
"for",
"subscriptions",
".",
"A",
"subscription",
"is",
"returned",
"if",
"it",
"matches",
"one",
"or",
"more",
"of",
"the",
"specified",
"conditions",
".",
":",
"param",
":",
"class",
":",
"<... | python | train | 65.666667 |
fake-name/ChromeController | ChromeController/manager.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/manager.py#L352-L378 | def get_page_url_title(self):
'''
Get the title and current url from the remote session.
Return is a 2-tuple: (page_title, page_url).
'''
cr_tab_id = self.transport._get_cr_tab_meta_for_key(self.tab_id)['id']
targets = self.Target_getTargets()
assert 'result' in targets
assert 'targetInfos' in targe... | [
"def",
"get_page_url_title",
"(",
"self",
")",
":",
"cr_tab_id",
"=",
"self",
".",
"transport",
".",
"_get_cr_tab_meta_for_key",
"(",
"self",
".",
"tab_id",
")",
"[",
"'id'",
"]",
"targets",
"=",
"self",
".",
"Target_getTargets",
"(",
")",
"assert",
"'result... | Get the title and current url from the remote session.
Return is a 2-tuple: (page_title, page_url). | [
"Get",
"the",
"title",
"and",
"current",
"url",
"from",
"the",
"remote",
"session",
"."
] | python | train | 25.037037 |
croach/django-simple-rest | simple_rest/utils/serializers.py | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/utils/serializers.py#L53-L90 | def to_html(data):
"""
Serializes a python object as HTML
This method uses the to_json method to turn the given data object into
formatted JSON that is displayed in an HTML page. If pygments in installed,
syntax highlighting will also be applied to the JSON.
"""
base_html_template = Templat... | [
"def",
"to_html",
"(",
"data",
")",
":",
"base_html_template",
"=",
"Template",
"(",
"'''\n <html>\n <head>\n {% if style %}\n <style type=\"text/css\">\n {{ style }}\n </style>\n {% endif %}\n ... | Serializes a python object as HTML
This method uses the to_json method to turn the given data object into
formatted JSON that is displayed in an HTML page. If pygments in installed,
syntax highlighting will also be applied to the JSON. | [
"Serializes",
"a",
"python",
"object",
"as",
"HTML"
] | python | train | 29.552632 |
CalebBell/thermo | thermo/thermal_conductivity.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/thermal_conductivity.py#L2091-L2141 | def calculate(self, T, method):
r'''Method to calculate low-pressure gas thermal conductivity at
tempearture `T` with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperat... | [
"def",
"calculate",
"(",
"self",
",",
"T",
",",
"method",
")",
":",
"if",
"method",
"==",
"GHARAGHEIZI_G",
":",
"kg",
"=",
"Gharagheizi_gas",
"(",
"T",
",",
"self",
".",
"MW",
",",
"self",
".",
"Tb",
",",
"self",
".",
"Pc",
",",
"self",
".",
"ome... | r'''Method to calculate low-pressure gas thermal conductivity at
tempearture `T` with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature of the gas, [K]
method : str... | [
"r",
"Method",
"to",
"calculate",
"low",
"-",
"pressure",
"gas",
"thermal",
"conductivity",
"at",
"tempearture",
"T",
"with",
"a",
"given",
"method",
"."
] | python | valid | 43.980392 |
googleapis/google-cloud-python | bigquery/google/cloud/bigquery/job.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/job.py#L981-L994 | def destination_encryption_configuration(self):
"""google.cloud.bigquery.table.EncryptionConfiguration: Custom
encryption configuration for the destination table.
Custom encryption configuration (e.g., Cloud KMS keys) or :data:`None`
if using default encryption.
See
htt... | [
"def",
"destination_encryption_configuration",
"(",
"self",
")",
":",
"prop",
"=",
"self",
".",
"_get_sub_prop",
"(",
"\"destinationEncryptionConfiguration\"",
")",
"if",
"prop",
"is",
"not",
"None",
":",
"prop",
"=",
"EncryptionConfiguration",
".",
"from_api_repr",
... | google.cloud.bigquery.table.EncryptionConfiguration: Custom
encryption configuration for the destination table.
Custom encryption configuration (e.g., Cloud KMS keys) or :data:`None`
if using default encryption.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#... | [
"google",
".",
"cloud",
".",
"bigquery",
".",
"table",
".",
"EncryptionConfiguration",
":",
"Custom",
"encryption",
"configuration",
"for",
"the",
"destination",
"table",
"."
] | python | train | 43.928571 |
dcos/shakedown | shakedown/dcos/security.py | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L117-L135 | def remove_user_permission(rid, uid, action='full'):
""" Removes user permission on a given resource.
:param uid: user id
:type uid: str
:param rid: resource ID
:type rid: str
:param action: read, write, update, delete or full
:type action: str
"""
rid = rid.... | [
"def",
"remove_user_permission",
"(",
"rid",
",",
"uid",
",",
"action",
"=",
"'full'",
")",
":",
"rid",
"=",
"rid",
".",
"replace",
"(",
"'/'",
",",
"'%252F'",
")",
"try",
":",
"acl_url",
"=",
"urljoin",
"(",
"_acl_url",
"(",
")",
",",
"'acls/{}/users/... | Removes user permission on a given resource.
:param uid: user id
:type uid: str
:param rid: resource ID
:type rid: str
:param action: read, write, update, delete or full
:type action: str | [
"Removes",
"user",
"permission",
"on",
"a",
"given",
"resource",
"."
] | python | train | 30.684211 |
saltstack/salt | salt/modules/shadow.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/shadow.py#L53-L95 | def info(name, root=None):
'''
Return information for the specified user
name
User to get the information for
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' shadow.info root
'''
if root is not None:
getspnam = functools.parti... | [
"def",
"info",
"(",
"name",
",",
"root",
"=",
"None",
")",
":",
"if",
"root",
"is",
"not",
"None",
":",
"getspnam",
"=",
"functools",
".",
"partial",
"(",
"_getspnam",
",",
"root",
"=",
"root",
")",
"else",
":",
"getspnam",
"=",
"functools",
".",
"... | Return information for the specified user
name
User to get the information for
root
Directory to chroot into
CLI Example:
.. code-block:: bash
salt '*' shadow.info root | [
"Return",
"information",
"for",
"the",
"specified",
"user"
] | python | train | 24.186047 |
gwpy/gwpy | gwpy/timeseries/timeseries.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/timeseries/timeseries.py#L175-L257 | def average_fft(self, fftlength=None, overlap=0, window=None):
"""Compute the averaged one-dimensional DFT of this `TimeSeries`.
This method computes a number of FFTs of duration ``fftlength``
and ``overlap`` (both given in seconds), and returns the mean
average. This method is analogou... | [
"def",
"average_fft",
"(",
"self",
",",
"fftlength",
"=",
"None",
",",
"overlap",
"=",
"0",
",",
"window",
"=",
"None",
")",
":",
"from",
"gwpy",
".",
"spectrogram",
"import",
"Spectrogram",
"# format lengths",
"if",
"fftlength",
"is",
"None",
":",
"fftlen... | Compute the averaged one-dimensional DFT of this `TimeSeries`.
This method computes a number of FFTs of duration ``fftlength``
and ``overlap`` (both given in seconds), and returns the mean
average. This method is analogous to the Welch average method
for power spectra.
Paramete... | [
"Compute",
"the",
"averaged",
"one",
"-",
"dimensional",
"DFT",
"of",
"this",
"TimeSeries",
"."
] | python | train | 37 |
rene-aguirre/pywinusb | pywinusb/hid/core.py | https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1465-L1499 | def send(self, raw_data = None):
"""Prepare HID raw report (unless raw_data is provided) and send
it to HID device
"""
if self.__report_kind != HidP_Output \
and self.__report_kind != HidP_Feature:
raise HIDError("Only for output or feature reports")
... | [
"def",
"send",
"(",
"self",
",",
"raw_data",
"=",
"None",
")",
":",
"if",
"self",
".",
"__report_kind",
"!=",
"HidP_Output",
"and",
"self",
".",
"__report_kind",
"!=",
"HidP_Feature",
":",
"raise",
"HIDError",
"(",
"\"Only for output or feature reports\"",
")",
... | Prepare HID raw report (unless raw_data is provided) and send
it to HID device | [
"Prepare",
"HID",
"raw",
"report",
"(",
"unless",
"raw_data",
"is",
"provided",
")",
"and",
"send",
"it",
"to",
"HID",
"device"
] | python | train | 44.971429 |
ThreatConnect-Inc/tcex | tcex/tcex_resources.py | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_resources.py#L1045-L1100 | def victim_assets(self, asset_type=None, asset_id=None):
"""Victim Asset endpoint for this resource with optional asset type.
This method will set the resource endpoint for working with Victim Assets.
The HTTP GET method will return all Victim Assets associated with this
resource or if ... | [
"def",
"victim_assets",
"(",
"self",
",",
"asset_type",
"=",
"None",
",",
"asset_id",
"=",
"None",
")",
":",
"type_entity_map",
"=",
"{",
"'emailAddresses'",
":",
"'victimEmailAddress'",
",",
"'networkAccounts'",
":",
"'victimNetworkAccount'",
",",
"'phoneNumbers'",... | Victim Asset endpoint for this resource with optional asset type.
This method will set the resource endpoint for working with Victim Assets.
The HTTP GET method will return all Victim Assets associated with this
resource or if a asset type is provided it will return the provided asset
t... | [
"Victim",
"Asset",
"endpoint",
"for",
"this",
"resource",
"with",
"optional",
"asset",
"type",
"."
] | python | train | 68.589286 |
threeML/astromodels | astromodels/utils/angular_distance.py | https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/angular_distance.py#L61-L83 | def spherical_angle( ra0, dec0, ra1, dec1, ra2, dec2 ):
"""
Returns the spherical angle distance between two sets of great circles defined by (ra0, dec0), (ra1, dec1) and (ra0, dec0), (ra2, dec2)
:param ra0: array or float, longitude of intersection point(s)
:param dec0: array or float, latitude of int... | [
"def",
"spherical_angle",
"(",
"ra0",
",",
"dec0",
",",
"ra1",
",",
"dec1",
",",
"ra2",
",",
"dec2",
")",
":",
"a",
"=",
"np",
".",
"deg2rad",
"(",
"angular_distance",
"(",
"ra0",
",",
"dec0",
",",
"ra1",
",",
"dec1",
")",
")",
"b",
"=",
"np",
... | Returns the spherical angle distance between two sets of great circles defined by (ra0, dec0), (ra1, dec1) and (ra0, dec0), (ra2, dec2)
:param ra0: array or float, longitude of intersection point(s)
:param dec0: array or float, latitude of intersection point(s)
:param ra1: array or float, longitude of firs... | [
"Returns",
"the",
"spherical",
"angle",
"distance",
"between",
"two",
"sets",
"of",
"great",
"circles",
"defined",
"by",
"(",
"ra0",
"dec0",
")",
"(",
"ra1",
"dec1",
")",
"and",
"(",
"ra0",
"dec0",
")",
"(",
"ra2",
"dec2",
")"
] | python | train | 50.217391 |
wbond/certvalidator | certvalidator/context.py | https://github.com/wbond/certvalidator/blob/c62233a713bcc36963e9d82323ec8d84f8e01485/certvalidator/context.py#L433-L475 | def retrieve_crls(self, cert):
"""
:param cert:
An asn1crypto.x509.Certificate object
:param path:
A certvalidator.path.ValidationPath object for the cert
:return:
A list of asn1crypto.crl.CertificateList objects
"""
if not self._all... | [
"def",
"retrieve_crls",
"(",
"self",
",",
"cert",
")",
":",
"if",
"not",
"self",
".",
"_allow_fetching",
":",
"return",
"self",
".",
"_crls",
"if",
"cert",
".",
"issuer_serial",
"not",
"in",
"self",
".",
"_fetched_crls",
":",
"try",
":",
"crls",
"=",
"... | :param cert:
An asn1crypto.x509.Certificate object
:param path:
A certvalidator.path.ValidationPath object for the cert
:return:
A list of asn1crypto.crl.CertificateList objects | [
":",
"param",
"cert",
":",
"An",
"asn1crypto",
".",
"x509",
".",
"Certificate",
"object"
] | python | train | 36.651163 |
chimera0/accel-brain-code | Reinforcement-Learning/demo/demo_maze_deep_q_network.py | https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Reinforcement-Learning/demo/demo_maze_deep_q_network.py#L45-L79 | def inference(self, state_arr, limit=1000):
'''
Infernce.
Args:
state_arr: `np.ndarray` of state.
limit: The number of inferencing.
Returns:
`list of `np.ndarray` of an optimal route.
'''
agent_x, agent_y = n... | [
"def",
"inference",
"(",
"self",
",",
"state_arr",
",",
"limit",
"=",
"1000",
")",
":",
"agent_x",
",",
"agent_y",
"=",
"np",
".",
"where",
"(",
"state_arr",
"[",
"0",
"]",
"==",
"1",
")",
"agent_x",
",",
"agent_y",
"=",
"agent_x",
"[",
"0",
"]",
... | Infernce.
Args:
state_arr: `np.ndarray` of state.
limit: The number of inferencing.
Returns:
`list of `np.ndarray` of an optimal route. | [
"Infernce",
".",
"Args",
":",
"state_arr",
":",
"np",
".",
"ndarray",
"of",
"state",
".",
"limit",
":",
"The",
"number",
"of",
"inferencing",
".",
"Returns",
":",
"list",
"of",
"np",
".",
"ndarray",
"of",
"an",
"optimal",
"route",
"."
] | python | train | 33.228571 |
astropy/photutils | photutils/utils/misc.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/utils/misc.py#L15-L32 | def get_version_info():
"""
Return astropy and photutils versions.
Returns
-------
result : str
The astropy and photutils versions.
"""
from astropy import __version__
astropy_version = __version__
from photutils import __version__
photutils_version = __version__
... | [
"def",
"get_version_info",
"(",
")",
":",
"from",
"astropy",
"import",
"__version__",
"astropy_version",
"=",
"__version__",
"from",
"photutils",
"import",
"__version__",
"photutils_version",
"=",
"__version__",
"return",
"'astropy: {0}, photutils: {1}'",
".",
"format",
... | Return astropy and photutils versions.
Returns
-------
result : str
The astropy and photutils versions. | [
"Return",
"astropy",
"and",
"photutils",
"versions",
"."
] | python | train | 24 |
tensorflow/tensor2tensor | tensor2tensor/data_generators/text_encoder.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/text_encoder.py#L338-L351 | def _init_vocab_from_file(self, filename):
"""Load vocab from a file.
Args:
filename: The file to load vocabulary from.
"""
with tf.gfile.Open(filename) as f:
tokens = [token.strip() for token in f.readlines()]
def token_gen():
for token in tokens:
yield token
self._... | [
"def",
"_init_vocab_from_file",
"(",
"self",
",",
"filename",
")",
":",
"with",
"tf",
".",
"gfile",
".",
"Open",
"(",
"filename",
")",
"as",
"f",
":",
"tokens",
"=",
"[",
"token",
".",
"strip",
"(",
")",
"for",
"token",
"in",
"f",
".",
"readlines",
... | Load vocab from a file.
Args:
filename: The file to load vocabulary from. | [
"Load",
"vocab",
"from",
"a",
"file",
"."
] | python | train | 25.5 |
Nachtfeuer/pipeline | spline/tools/report/collector.py | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L115-L122 | def schema_event_items():
"""Schema for event items."""
return {
'timestamp': And(int, lambda n: n > 0),
Optional('information', default={}): {
Optional(Regex(r'([a-z][_a-z]*)')): object
}
} | [
"def",
"schema_event_items",
"(",
")",
":",
"return",
"{",
"'timestamp'",
":",
"And",
"(",
"int",
",",
"lambda",
"n",
":",
"n",
">",
"0",
")",
",",
"Optional",
"(",
"'information'",
",",
"default",
"=",
"{",
"}",
")",
":",
"{",
"Optional",
"(",
"Re... | Schema for event items. | [
"Schema",
"for",
"event",
"items",
"."
] | python | train | 32.375 |
saltstack/salt | salt/utils/vsan.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vsan.py#L158-L184 | def get_host_vsan_system(service_instance, host_ref, hostname=None):
'''
Returns a host's vsan system
service_instance
Service instance to the host or vCenter
host_ref
Refernce to ESXi host
hostname
Name of ESXi host. Default value is None.
'''
if not hostname:
... | [
"def",
"get_host_vsan_system",
"(",
"service_instance",
",",
"host_ref",
",",
"hostname",
"=",
"None",
")",
":",
"if",
"not",
"hostname",
":",
"hostname",
"=",
"salt",
".",
"utils",
".",
"vmware",
".",
"get_managed_object_name",
"(",
"host_ref",
")",
"traversa... | Returns a host's vsan system
service_instance
Service instance to the host or vCenter
host_ref
Refernce to ESXi host
hostname
Name of ESXi host. Default value is None. | [
"Returns",
"a",
"host",
"s",
"vsan",
"system"
] | python | train | 35.777778 |
watson-developer-cloud/python-sdk | ibm_watson/discovery_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/discovery_v1.py#L2318-L2375 | def add_training_data(self,
environment_id,
collection_id,
natural_language_query=None,
filter=None,
examples=None,
**kwargs):
"""
Add query to trai... | [
"def",
"add_training_data",
"(",
"self",
",",
"environment_id",
",",
"collection_id",
",",
"natural_language_query",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"examples",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"environment_id",
"is",
"None... | Add query to training data.
Adds a query to the training data for this collection. The query can contain a
filter and natural language query.
:param str environment_id: The ID of the environment.
:param str collection_id: The ID of the collection.
:param str natural_language_qu... | [
"Add",
"query",
"to",
"training",
"data",
"."
] | python | train | 36.965517 |
Diviyan-Kalainathan/CausalDiscoveryToolbox | cdt/independence/graph/model.py | https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/independence/graph/model.py#L83-L100 | def run_feature_selection(self, df_data, target, idx=0, **kwargs):
"""Run feature selection for one node: wrapper around
``self.predict_features``.
Args:
df_data (pandas.DataFrame): All the observational data
target (str): Name of the target variable
idx (int... | [
"def",
"run_feature_selection",
"(",
"self",
",",
"df_data",
",",
"target",
",",
"idx",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"list_features",
"=",
"list",
"(",
"df_data",
".",
"columns",
".",
"values",
")",
"list_features",
".",
"remove",
"(",
... | Run feature selection for one node: wrapper around
``self.predict_features``.
Args:
df_data (pandas.DataFrame): All the observational data
target (str): Name of the target variable
idx (int): (optional) For printing purposes
Returns:
list: scores... | [
"Run",
"feature",
"selection",
"for",
"one",
"node",
":",
"wrapper",
"around",
"self",
".",
"predict_features",
"."
] | python | valid | 39.888889 |
ARMmbed/mbed-connector-api-python | mbed_connector_api/mbed_connector_api.py | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L220-L245 | def putResourceValue(self,ep,res,data,cbfn=""):
"""
Put a value to a resource on an endpoint
:param str ep: name of endpoint
:param str res: name of resource
:param str data: data to send via PUT
:param fnptr cbfn: Optional - callback funtion to call when operation is completed
:return: successful ``.s... | [
"def",
"putResourceValue",
"(",
"self",
",",
"ep",
",",
"res",
",",
"data",
",",
"cbfn",
"=",
"\"\"",
")",
":",
"result",
"=",
"asyncResult",
"(",
"callback",
"=",
"cbfn",
")",
"result",
".",
"endpoint",
"=",
"ep",
"result",
".",
"resource",
"=",
"re... | Put a value to a resource on an endpoint
:param str ep: name of endpoint
:param str res: name of resource
:param str data: data to send via PUT
:param fnptr cbfn: Optional - callback funtion to call when operation is completed
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rty... | [
"Put",
"a",
"value",
"to",
"a",
"resource",
"on",
"an",
"endpoint",
":",
"param",
"str",
"ep",
":",
"name",
"of",
"endpoint",
":",
"param",
"str",
"res",
":",
"name",
"of",
"resource",
":",
"param",
"str",
"data",
":",
"data",
"to",
"send",
"via",
... | python | train | 35.346154 |
estnltk/estnltk | estnltk/wordnet/wn.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/wn.py#L258-L316 | def all_synsets(pos=None):
"""Return all the synsets which have the provided pos.
Notes
-----
Returns thousands or tens of thousands of synsets - first time will take significant time.
Useful for initializing synsets as each returned synset is also stored in a global dictionary for fast retrieval t... | [
"def",
"all_synsets",
"(",
"pos",
"=",
"None",
")",
":",
"def",
"_get_unique_synset_idxes",
"(",
"pos",
")",
":",
"idxes",
"=",
"[",
"]",
"with",
"codecs",
".",
"open",
"(",
"_LIT_POS_FILE",
",",
"'rb'",
",",
"'utf-8'",
")",
"as",
"fin",
":",
"if",
"... | Return all the synsets which have the provided pos.
Notes
-----
Returns thousands or tens of thousands of synsets - first time will take significant time.
Useful for initializing synsets as each returned synset is also stored in a global dictionary for fast retrieval the next time.
Parameters
... | [
"Return",
"all",
"the",
"synsets",
"which",
"have",
"the",
"provided",
"pos",
"."
] | python | train | 37.322034 |
llllllllll/codetransformer | codetransformer/decompiler/_343.py | https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/decompiler/_343.py#L1490-L1527 | def make_defaults_and_annotations(make_function_instr, builders):
"""
Get the AST expressions corresponding to the defaults, kwonly defaults, and
annotations for a function created by `make_function_instr`.
"""
# Integer counts.
n_defaults, n_kwonlydefaults, n_annotations = unpack_make_function_... | [
"def",
"make_defaults_and_annotations",
"(",
"make_function_instr",
",",
"builders",
")",
":",
"# Integer counts.",
"n_defaults",
",",
"n_kwonlydefaults",
",",
"n_annotations",
"=",
"unpack_make_function_arg",
"(",
"make_function_instr",
".",
"arg",
")",
"if",
"n_annotati... | Get the AST expressions corresponding to the defaults, kwonly defaults, and
annotations for a function created by `make_function_instr`. | [
"Get",
"the",
"AST",
"expressions",
"corresponding",
"to",
"the",
"defaults",
"kwonly",
"defaults",
"and",
"annotations",
"for",
"a",
"function",
"created",
"by",
"make_function_instr",
"."
] | python | train | 34.894737 |
awslabs/mxboard | python/mxboard/summary.py | https://github.com/awslabs/mxboard/blob/36057ff0f05325c9dc2fe046521325bf9d563a88/python/mxboard/summary.py#L169-L189 | def image_summary(tag, image):
"""Outputs a `Summary` protocol buffer with image(s).
Parameters
----------
tag : str
A name for the generated summary. Will also serve as a series name in TensorBoard.
image : MXNet `NDArray` or `numpy.ndarray`
Image data that is one o... | [
"def",
"image_summary",
"(",
"tag",
",",
"image",
")",
":",
"tag",
"=",
"_clean_tag",
"(",
"tag",
")",
"image",
"=",
"_prepare_image",
"(",
"image",
")",
"image",
"=",
"_make_image",
"(",
"image",
")",
"return",
"Summary",
"(",
"value",
"=",
"[",
"Summ... | Outputs a `Summary` protocol buffer with image(s).
Parameters
----------
tag : str
A name for the generated summary. Will also serve as a series name in TensorBoard.
image : MXNet `NDArray` or `numpy.ndarray`
Image data that is one of the following layout: (H, W), (C, H,... | [
"Outputs",
"a",
"Summary",
"protocol",
"buffer",
"with",
"image",
"(",
"s",
")",
"."
] | python | train | 38.619048 |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L171-L190 | def load_model_from_file(self, filename):
"""Load one parameter set from a file which contains one value per line
No row is skipped.
Parameters
----------
filename : string, file path
Filename to loaded data from
Returns
-------
pid : int
... | [
"def",
"load_model_from_file",
"(",
"self",
",",
"filename",
")",
":",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
"data",
"=",
"np",
".",
"loadtxt",
"(",
"filename",
")",
".",
"squeeze",
"(",
")",
"assert",
"len",
"(",
"data",
... | Load one parameter set from a file which contains one value per line
No row is skipped.
Parameters
----------
filename : string, file path
Filename to loaded data from
Returns
-------
pid : int
ID of parameter set | [
"Load",
"one",
"parameter",
"set",
"from",
"a",
"file",
"which",
"contains",
"one",
"value",
"per",
"line"
] | python | train | 25.85 |
dailymuse/oz | oz/sqlalchemy/middleware.py | https://github.com/dailymuse/oz/blob/4329f6a207dc9d2a8fbeb4d16d415dbe4570b5bd/oz/sqlalchemy/middleware.py#L55-L73 | def _sqlalchemy_on_connection_close(self):
"""
Rollsback and closes the active session, since the client disconnected before the request
could be completed.
"""
if hasattr(self, "_db_conns"):
try:
for db_conn in self._db_conns.values():
... | [
"def",
"_sqlalchemy_on_connection_close",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_db_conns\"",
")",
":",
"try",
":",
"for",
"db_conn",
"in",
"self",
".",
"_db_conns",
".",
"values",
"(",
")",
":",
"db_conn",
".",
"rollback",
"(",
")... | Rollsback and closes the active session, since the client disconnected before the request
could be completed. | [
"Rollsback",
"and",
"closes",
"the",
"active",
"session",
"since",
"the",
"client",
"disconnected",
"before",
"the",
"request",
"could",
"be",
"completed",
"."
] | python | train | 41.368421 |
LLNL/scraper | scraper/github/queryManager.py | https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/github/queryManager.py#L101-L139 | def _readGQL(self, filePath, verbose=False):
"""Read a 'pretty' formatted GraphQL query file into a one-line string.
Removes line breaks and comments. Condenses white space.
Args:
filePath (str): A relative or absolute path to a file containing
a GraphQL query.
... | [
"def",
"_readGQL",
"(",
"self",
",",
"filePath",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filePath",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Query file '%s' does not exist.\"",
"%",
"(",
"filePath",
")... | Read a 'pretty' formatted GraphQL query file into a one-line string.
Removes line breaks and comments. Condenses white space.
Args:
filePath (str): A relative or absolute path to a file containing
a GraphQL query.
File may use comments and multi-line formatt... | [
"Read",
"a",
"pretty",
"formatted",
"GraphQL",
"query",
"file",
"into",
"a",
"one",
"-",
"line",
"string",
"."
] | python | test | 44.615385 |
QUANTAXIS/QUANTAXIS | QUANTAXIS/QAFetch/QATdx.py | https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAFetch/QATdx.py#L1376-L1391 | def QA_fetch_get_macroindex_list(ip=None, port=None):
"""宏观指标列表
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
38 10 宏观指标 HG
"""
global extension_market_list
extension_market_list = QA... | [
"def",
"QA_fetch_get_macroindex_list",
"(",
"ip",
"=",
"None",
",",
"port",
"=",
"None",
")",
":",
"global",
"extension_market_list",
"extension_market_list",
"=",
"QA_fetch_get_extensionmarket_list",
"(",
")",
"if",
"extension_market_list",
"is",
"None",
"else",
"ext... | 宏观指标列表
Keyword Arguments:
ip {[type]} -- [description] (default: {None})
port {[type]} -- [description] (default: {None})
38 10 宏观指标 HG | [
"宏观指标列表"
] | python | train | 28.5625 |
CodeLineFi/maclookup-python | src/maclookup/api_client.py | https://github.com/CodeLineFi/maclookup-python/blob/0d87dc6cb1a8c8583c9d242fbb3e98d70d83664f/src/maclookup/api_client.py#L32-L48 | def get(self, mac):
"""Get data from API as instance of ResponseModel.
Keyword arguments:
mac -- MAC address or OUI for searching
"""
data = {
self._FORMAT_F: 'json',
self._SEARCH_F: mac
}
response = self.__decode_str(self.__call... | [
"def",
"get",
"(",
"self",
",",
"mac",
")",
":",
"data",
"=",
"{",
"self",
".",
"_FORMAT_F",
":",
"'json'",
",",
"self",
".",
"_SEARCH_F",
":",
"mac",
"}",
"response",
"=",
"self",
".",
"__decode_str",
"(",
"self",
".",
"__call_api",
"(",
"self",
"... | Get data from API as instance of ResponseModel.
Keyword arguments:
mac -- MAC address or OUI for searching | [
"Get",
"data",
"from",
"API",
"as",
"instance",
"of",
"ResponseModel",
"."
] | python | train | 26.352941 |
jhorman/pledge | pledge/__init__.py | https://github.com/jhorman/pledge/blob/062ba5b788aeb15e68c85a329374a50b4618544d/pledge/__init__.py#L78-L103 | def post(cond):
"""
Add a postcondition check to the annotated method. The condition
is passed the return value of the annotated method.
"""
source = inspect.getsource(cond).strip()
def inner(f):
if enabled:
# deal with the real function, not a wrapper
f = geta... | [
"def",
"post",
"(",
"cond",
")",
":",
"source",
"=",
"inspect",
".",
"getsource",
"(",
"cond",
")",
".",
"strip",
"(",
")",
"def",
"inner",
"(",
"f",
")",
":",
"if",
"enabled",
":",
"# deal with the real function, not a wrapper",
"f",
"=",
"getattr",
"("... | Add a postcondition check to the annotated method. The condition
is passed the return value of the annotated method. | [
"Add",
"a",
"postcondition",
"check",
"to",
"the",
"annotated",
"method",
".",
"The",
"condition",
"is",
"passed",
"the",
"return",
"value",
"of",
"the",
"annotated",
"method",
"."
] | python | train | 29.923077 |
mixer/beam-interactive-python | beam_interactive/proto/varint.py | https://github.com/mixer/beam-interactive-python/blob/e035bc45515dea9315b77648a24b5ae8685aa5cf/beam_interactive/proto/varint.py#L62-L86 | def _SignedVarintDecoder(mask):
"""Like _VarintDecoder() but decodes signed values."""
def DecodeVarint(buffer, pos):
result = 0
shift = 0
while 1:
if pos > len(buffer) -1:
raise NotEnoughDataException( "Not enough data to decode varint" )
b = local_ord(buffer[pos])
result |... | [
"def",
"_SignedVarintDecoder",
"(",
"mask",
")",
":",
"def",
"DecodeVarint",
"(",
"buffer",
",",
"pos",
")",
":",
"result",
"=",
"0",
"shift",
"=",
"0",
"while",
"1",
":",
"if",
"pos",
">",
"len",
"(",
"buffer",
")",
"-",
"1",
":",
"raise",
"NotEno... | Like _VarintDecoder() but decodes signed values. | [
"Like",
"_VarintDecoder",
"()",
"but",
"decodes",
"signed",
"values",
"."
] | python | train | 26.08 |
ReFirmLabs/binwalk | src/binwalk/plugins/unpfs.py | https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L10-L13 | def _make_short(self, data, endianness):
"""Returns a 2 byte integer."""
data = binwalk.core.compat.str2bytes(data)
return struct.unpack('%sH' % endianness, data)[0] | [
"def",
"_make_short",
"(",
"self",
",",
"data",
",",
"endianness",
")",
":",
"data",
"=",
"binwalk",
".",
"core",
".",
"compat",
".",
"str2bytes",
"(",
"data",
")",
"return",
"struct",
".",
"unpack",
"(",
"'%sH'",
"%",
"endianness",
",",
"data",
")",
... | Returns a 2 byte integer. | [
"Returns",
"a",
"2",
"byte",
"integer",
"."
] | python | train | 46.5 |
pymupdf/PyMuPDF | fitz/utils.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2136-L2203 | def drawSector(self, center, point, beta, fullSector=True):
"""Draw a circle sector.
"""
center = Point(center)
point = Point(point)
l3 = "%g %g m\n"
l4 = "%g %g %g %g %g %g c\n"
l5 = "%g %g l\n"
betar = math.radians(-beta)
w360 = math.radians(math... | [
"def",
"drawSector",
"(",
"self",
",",
"center",
",",
"point",
",",
"beta",
",",
"fullSector",
"=",
"True",
")",
":",
"center",
"=",
"Point",
"(",
"center",
")",
"point",
"=",
"Point",
"(",
"point",
")",
"l3",
"=",
"\"%g %g m\\n\"",
"l4",
"=",
"\"%g ... | Draw a circle sector. | [
"Draw",
"a",
"circle",
"sector",
"."
] | python | train | 50.441176 |
PythonCharmers/python-future | src/future/backports/xmlrpc/server.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/xmlrpc/server.py#L311-L340 | def system_methodHelp(self, method_name):
"""system.methodHelp('add') => "Adds two integers together"
Returns a string containing documentation for the specified method."""
method = None
if method_name in self.funcs:
method = self.funcs[method_name]
elif self.instan... | [
"def",
"system_methodHelp",
"(",
"self",
",",
"method_name",
")",
":",
"method",
"=",
"None",
"if",
"method_name",
"in",
"self",
".",
"funcs",
":",
"method",
"=",
"self",
".",
"funcs",
"[",
"method_name",
"]",
"elif",
"self",
".",
"instance",
"is",
"not"... | system.methodHelp('add') => "Adds two integers together"
Returns a string containing documentation for the specified method. | [
"system",
".",
"methodHelp",
"(",
"add",
")",
"=",
">",
"Adds",
"two",
"integers",
"together"
] | python | train | 40.4 |
horazont/aioxmpp | aioxmpp/stream.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L2509-L2542 | def send_iq_and_wait_for_reply(self, iq, *,
timeout=None):
"""
Send an IQ stanza `iq` and wait for the response. If `timeout` is not
:data:`None`, it must be the time in seconds for which to wait for a
response.
If the response is a ``"result"`... | [
"def",
"send_iq_and_wait_for_reply",
"(",
"self",
",",
"iq",
",",
"*",
",",
"timeout",
"=",
"None",
")",
":",
"warnings",
".",
"warn",
"(",
"r\"send_iq_and_wait_for_reply is deprecated and will be removed in\"",
"r\" 1.0\"",
",",
"DeprecationWarning",
",",
"stacklevel",... | Send an IQ stanza `iq` and wait for the response. If `timeout` is not
:data:`None`, it must be the time in seconds for which to wait for a
response.
If the response is a ``"result"`` IQ, the value of the
:attr:`~aioxmpp.IQ.payload` attribute is returned. Otherwise,
the exception... | [
"Send",
"an",
"IQ",
"stanza",
"iq",
"and",
"wait",
"for",
"the",
"response",
".",
"If",
"timeout",
"is",
"not",
":",
"data",
":",
"None",
"it",
"must",
"be",
"the",
"time",
"in",
"seconds",
"for",
"which",
"to",
"wait",
"for",
"a",
"response",
"."
] | python | train | 33.558824 |
mkoura/dump2polarion | dump2polarion/csv2sqlite_cli.py | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/csv2sqlite_cli.py#L80-L113 | def main(args=None):
"""Main function for cli."""
args = get_args(args)
utils.init_log(args.log_level)
if ".csv" not in args.input_file.lower():
logger.warning("Make sure the input file '%s' is in CSV format", args.input_file)
try:
records = csvtools.get_imported_data(args.input_f... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"args",
"=",
"get_args",
"(",
"args",
")",
"utils",
".",
"init_log",
"(",
"args",
".",
"log_level",
")",
"if",
"\".csv\"",
"not",
"in",
"args",
".",
"input_file",
".",
"lower",
"(",
")",
":",
"logg... | Main function for cli. | [
"Main",
"function",
"for",
"cli",
"."
] | python | train | 29.882353 |
log2timeline/plaso | plaso/storage/sqlite/sqlite_file.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/storage/sqlite/sqlite_file.py#L404-L423 | def _ReadAndCheckStorageMetadata(self, check_readable_only=False):
"""Reads storage metadata and checks that the values are valid.
Args:
check_readable_only (Optional[bool]): whether the store should only be
checked to see if it can be read. If False, the store will be checked
to see ... | [
"def",
"_ReadAndCheckStorageMetadata",
"(",
"self",
",",
"check_readable_only",
"=",
"False",
")",
":",
"query",
"=",
"'SELECT key, value FROM metadata'",
"self",
".",
"_cursor",
".",
"execute",
"(",
"query",
")",
"metadata_values",
"=",
"{",
"row",
"[",
"0",
"]... | Reads storage metadata and checks that the values are valid.
Args:
check_readable_only (Optional[bool]): whether the store should only be
checked to see if it can be read. If False, the store will be checked
to see if it can be read and written to. | [
"Reads",
"storage",
"metadata",
"and",
"checks",
"that",
"the",
"values",
"are",
"valid",
"."
] | python | train | 42.55 |
simonw/csvs-to-sqlite | csvs_to_sqlite/cli.py | https://github.com/simonw/csvs-to-sqlite/blob/0a014284eac75c1b06cbdaca362f2a66648c11d2/csvs_to_sqlite/cli.py#L120-L248 | def cli(
paths,
dbname,
separator,
quoting,
skip_errors,
replace_tables,
table,
extract_column,
date,
datetime,
datetime_format,
primary_key,
fts,
index,
shape,
filename_column,
no_index_fks,
no_fulltext_fks,
):
"""
PATHS: paths to individu... | [
"def",
"cli",
"(",
"paths",
",",
"dbname",
",",
"separator",
",",
"quoting",
",",
"skip_errors",
",",
"replace_tables",
",",
"table",
",",
"extract_column",
",",
"date",
",",
"datetime",
",",
"datetime_format",
",",
"primary_key",
",",
"fts",
",",
"index",
... | PATHS: paths to individual .csv files or to directories containing .csvs
DBNAME: name of the SQLite database file to create | [
"PATHS",
":",
"paths",
"to",
"individual",
".",
"csv",
"files",
"or",
"to",
"directories",
"containing",
".",
"csvs"
] | python | train | 30.147287 |
dwavesystems/dwave-system | dwave/system/composites/embedding.py | https://github.com/dwavesystems/dwave-system/blob/86a1698f15ccd8b0ece0ed868ee49292d3f67f5b/dwave/system/composites/embedding.py#L414-L429 | def _adjacency_to_edges(adjacency):
"""determine from an adjacency the list of edges
if (u, v) in edges, then (v, u) should not be"""
edges = set()
for u in adjacency:
for v in adjacency[u]:
try:
edge = (u, v) if u <= v else (v, u)
except TypeError:
... | [
"def",
"_adjacency_to_edges",
"(",
"adjacency",
")",
":",
"edges",
"=",
"set",
"(",
")",
"for",
"u",
"in",
"adjacency",
":",
"for",
"v",
"in",
"adjacency",
"[",
"u",
"]",
":",
"try",
":",
"edge",
"=",
"(",
"u",
",",
"v",
")",
"if",
"u",
"<=",
"... | determine from an adjacency the list of edges
if (u, v) in edges, then (v, u) should not be | [
"determine",
"from",
"an",
"adjacency",
"the",
"list",
"of",
"edges",
"if",
"(",
"u",
"v",
")",
"in",
"edges",
"then",
"(",
"v",
"u",
")",
"should",
"not",
"be"
] | python | train | 31.25 |
rytilahti/python-eq3bt | eq3bt/eq3btsmart.py | https://github.com/rytilahti/python-eq3bt/blob/595459d9885920cf13b7059a1edd2cf38cede1f0/eq3bt/eq3btsmart.py#L375-L378 | def activate_eco(self):
"""Activates the comfort temperature."""
value = struct.pack('B', PROP_ECO)
self._conn.make_request(PROP_WRITE_HANDLE, value) | [
"def",
"activate_eco",
"(",
"self",
")",
":",
"value",
"=",
"struct",
".",
"pack",
"(",
"'B'",
",",
"PROP_ECO",
")",
"self",
".",
"_conn",
".",
"make_request",
"(",
"PROP_WRITE_HANDLE",
",",
"value",
")"
] | Activates the comfort temperature. | [
"Activates",
"the",
"comfort",
"temperature",
"."
] | python | train | 42.5 |
mosesschwartz/scrypture | scrypture/scrypture_api.py | https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/scrypture_api.py#L70-L75 | def post(self, uri, params={}, data={}):
'''A generic method to make POST requests on the given URI.'''
return requests.post(
urlparse.urljoin(self.BASE_URL, uri),
params=params, data=json.dumps(data), verify=False,
auth=self.auth, headers = {'Content-type': 'applicat... | [
"def",
"post",
"(",
"self",
",",
"uri",
",",
"params",
"=",
"{",
"}",
",",
"data",
"=",
"{",
"}",
")",
":",
"return",
"requests",
".",
"post",
"(",
"urlparse",
".",
"urljoin",
"(",
"self",
".",
"BASE_URL",
",",
"uri",
")",
",",
"params",
"=",
"... | A generic method to make POST requests on the given URI. | [
"A",
"generic",
"method",
"to",
"make",
"POST",
"requests",
"on",
"the",
"given",
"URI",
"."
] | python | train | 58.333333 |
ming060/robotframework-uiautomatorlibrary | uiautomatorlibrary/Mobile.py | https://github.com/ming060/robotframework-uiautomatorlibrary/blob/b70202b6a8aa68b4efd9d029c2845407fb33451a/uiautomatorlibrary/Mobile.py#L592-L600 | def register_click_watcher(self, watcher_name, selectors, *condition_list):
"""
The watcher click on the object which has the *selectors* when conditions match.
"""
watcher = self.device.watcher(watcher_name)
for condition in condition_list:
watcher.when(**self.__unic... | [
"def",
"register_click_watcher",
"(",
"self",
",",
"watcher_name",
",",
"selectors",
",",
"*",
"condition_list",
")",
":",
"watcher",
"=",
"self",
".",
"device",
".",
"watcher",
"(",
"watcher_name",
")",
"for",
"condition",
"in",
"condition_list",
":",
"watche... | The watcher click on the object which has the *selectors* when conditions match. | [
"The",
"watcher",
"click",
"on",
"the",
"object",
"which",
"has",
"the",
"*",
"selectors",
"*",
"when",
"conditions",
"match",
"."
] | python | train | 47.666667 |
TheHive-Project/TheHive4py | thehive4py/api.py | https://github.com/TheHive-Project/TheHive4py/blob/35762bbd50d8376943268464326b59c752d6241b/thehive4py/api.py#L166-L189 | def create_task_log(self, task_id, case_task_log):
"""
:param task_id: Task identifier
:param case_task_log: TheHive log
:type case_task_log: CaseTaskLog defined in models.py
:return: TheHive log
:rtype: json
"""
req = self.url + "/api/case/task/{}/log".... | [
"def",
"create_task_log",
"(",
"self",
",",
"task_id",
",",
"case_task_log",
")",
":",
"req",
"=",
"self",
".",
"url",
"+",
"\"/api/case/task/{}/log\"",
".",
"format",
"(",
"task_id",
")",
"data",
"=",
"{",
"'_json'",
":",
"json",
".",
"dumps",
"(",
"{",... | :param task_id: Task identifier
:param case_task_log: TheHive log
:type case_task_log: CaseTaskLog defined in models.py
:return: TheHive log
:rtype: json | [
":",
"param",
"task_id",
":",
"Task",
"identifier",
":",
"param",
"case_task_log",
":",
"TheHive",
"log",
":",
"type",
"case_task_log",
":",
"CaseTaskLog",
"defined",
"in",
"models",
".",
"py",
":",
"return",
":",
"TheHive",
"log",
":",
"rtype",
":",
"json... | python | train | 51.083333 |
squaresLab/BugZoo | bugzoo/client/container.py | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L152-L162 | def ip_address(self,
container: Container
) -> Union[IPv4Address, IPv6Address]:
"""
The IP address used by a given container, or None if no IP address has
been assigned to that container.
"""
r = self.__api.get('containers/{}/ip'.format(conta... | [
"def",
"ip_address",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"Union",
"[",
"IPv4Address",
",",
"IPv6Address",
"]",
":",
"r",
"=",
"self",
".",
"__api",
".",
"get",
"(",
"'containers/{}/ip'",
".",
"format",
"(",
"container",
".",
"uid"... | The IP address used by a given container, or None if no IP address has
been assigned to that container. | [
"The",
"IP",
"address",
"used",
"by",
"a",
"given",
"container",
"or",
"None",
"if",
"no",
"IP",
"address",
"has",
"been",
"assigned",
"to",
"that",
"container",
"."
] | python | train | 39 |
gwastro/pycbc | pycbc/inject/inject.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inject/inject.py#L805-L855 | def write(filename, samples, write_params=None, static_args=None,
injtype=None, **metadata):
"""Writes the injection samples to the given hdf file.
Parameters
----------
filename : str
The name of the file to write to.
samples : io.FieldArray
... | [
"def",
"write",
"(",
"filename",
",",
"samples",
",",
"write_params",
"=",
"None",
",",
"static_args",
"=",
"None",
",",
"injtype",
"=",
"None",
",",
"*",
"*",
"metadata",
")",
":",
"# DELETE the following \"if\" once xml is dropped",
"ext",
"=",
"os",
".",
... | Writes the injection samples to the given hdf file.
Parameters
----------
filename : str
The name of the file to write to.
samples : io.FieldArray
FieldArray of parameters.
write_params : list, optional
Only write the given parameter names. Al... | [
"Writes",
"the",
"injection",
"samples",
"to",
"the",
"given",
"hdf",
"file",
"."
] | python | train | 50.156863 |
tsileo/globster | lazy_regex.py | https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/lazy_regex.py#L60-L65 | def _compile_and_collapse(self):
"""Actually compile the requested regex"""
self._real_regex = self._real_re_compile(*self._regex_args,
**self._regex_kwargs)
for attr in self._regex_attributes_to_copy:
setattr(self, attr, getattr(self.... | [
"def",
"_compile_and_collapse",
"(",
"self",
")",
":",
"self",
".",
"_real_regex",
"=",
"self",
".",
"_real_re_compile",
"(",
"*",
"self",
".",
"_regex_args",
",",
"*",
"*",
"self",
".",
"_regex_kwargs",
")",
"for",
"attr",
"in",
"self",
".",
"_regex_attri... | Actually compile the requested regex | [
"Actually",
"compile",
"the",
"requested",
"regex"
] | python | train | 55.666667 |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L1483-L1488 | def get_next_state(self, state, ret, oper):
"""Returns the next state for a create or delete operation. """
if oper == fw_const.FW_CR_OP:
return self.get_next_create_state(state, ret)
else:
return self.get_next_del_state(state, ret) | [
"def",
"get_next_state",
"(",
"self",
",",
"state",
",",
"ret",
",",
"oper",
")",
":",
"if",
"oper",
"==",
"fw_const",
".",
"FW_CR_OP",
":",
"return",
"self",
".",
"get_next_create_state",
"(",
"state",
",",
"ret",
")",
"else",
":",
"return",
"self",
"... | Returns the next state for a create or delete operation. | [
"Returns",
"the",
"next",
"state",
"for",
"a",
"create",
"or",
"delete",
"operation",
"."
] | python | train | 45.833333 |
spyder-ide/spyder | spyder/plugins/editor/widgets/base.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/base.py#L336-L352 | def set_palette(self, background, foreground):
"""
Set text editor palette colors:
background color and caret (text cursor) color
"""
palette = QPalette()
palette.setColor(QPalette.Base, background)
palette.setColor(QPalette.Text, foreground)
self.... | [
"def",
"set_palette",
"(",
"self",
",",
"background",
",",
"foreground",
")",
":",
"palette",
"=",
"QPalette",
"(",
")",
"palette",
".",
"setColor",
"(",
"QPalette",
".",
"Base",
",",
"background",
")",
"palette",
".",
"setColor",
"(",
"QPalette",
".",
"... | Set text editor palette colors:
background color and caret (text cursor) color | [
"Set",
"text",
"editor",
"palette",
"colors",
":",
"background",
"color",
"and",
"caret",
"(",
"text",
"cursor",
")",
"color"
] | python | train | 42.647059 |
sosreport/sos | sos/__init__.py | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/__init__.py#L214-L230 | def _opt_to_args(cls, opt, val):
"""Convert a named option and optional value to command line
argument notation, correctly handling options that take
no value or that have special representations (e.g. verify
and verbose).
"""
no_value = (
"allopti... | [
"def",
"_opt_to_args",
"(",
"cls",
",",
"opt",
",",
"val",
")",
":",
"no_value",
"=",
"(",
"\"alloptions\"",
",",
"\"all-logs\"",
",",
"\"batch\"",
",",
"\"build\"",
",",
"\"debug\"",
",",
"\"experimental\"",
",",
"\"list-plugins\"",
",",
"\"list-presets\"",
"... | Convert a named option and optional value to command line
argument notation, correctly handling options that take
no value or that have special representations (e.g. verify
and verbose). | [
"Convert",
"a",
"named",
"option",
"and",
"optional",
"value",
"to",
"command",
"line",
"argument",
"notation",
"correctly",
"handling",
"options",
"that",
"take",
"no",
"value",
"or",
"that",
"have",
"special",
"representations",
"(",
"e",
".",
"g",
".",
"v... | python | train | 40.882353 |
devassistant/devassistant | devassistant/dapi/__init__.py | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L604-L611 | def _report_problem(self, problem, level=logging.ERROR):
'''Report a given problem'''
problem = self.basename + ': ' + problem
if self._logger.isEnabledFor(level):
self._problematic = True
if self._check_raises:
raise DapInvalid(problem)
self._logger.log(l... | [
"def",
"_report_problem",
"(",
"self",
",",
"problem",
",",
"level",
"=",
"logging",
".",
"ERROR",
")",
":",
"problem",
"=",
"self",
".",
"basename",
"+",
"': '",
"+",
"problem",
"if",
"self",
".",
"_logger",
".",
"isEnabledFor",
"(",
"level",
")",
":"... | Report a given problem | [
"Report",
"a",
"given",
"problem"
] | python | train | 40.875 |
Tanganelli/CoAPthon3 | coapthon/messages/request.py | https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/messages/request.py#L147-L159 | def if_match(self, values):
"""
Set the If-Match option of a request.
:param values: the If-Match values
:type values : list
"""
assert isinstance(values, list)
for v in values:
option = Option()
option.number = defines.OptionRegistry.IF_M... | [
"def",
"if_match",
"(",
"self",
",",
"values",
")",
":",
"assert",
"isinstance",
"(",
"values",
",",
"list",
")",
"for",
"v",
"in",
"values",
":",
"option",
"=",
"Option",
"(",
")",
"option",
".",
"number",
"=",
"defines",
".",
"OptionRegistry",
".",
... | Set the If-Match option of a request.
:param values: the If-Match values
:type values : list | [
"Set",
"the",
"If",
"-",
"Match",
"option",
"of",
"a",
"request",
"."
] | python | train | 29.538462 |
timothycrosley/connectable | connectable/base.py | https://github.com/timothycrosley/connectable/blob/d5958d974c04b16f410c602786809d0e2a6665d2/connectable/base.py#L98-L117 | def accept_arguments(method, number_of_arguments=1):
"""Returns True if the given method will accept the given number of arguments
method: the method to perform introspection on
number_of_arguments: the number_of_arguments
"""
if 'method' in method.__class__.__name__:
number_of_argume... | [
"def",
"accept_arguments",
"(",
"method",
",",
"number_of_arguments",
"=",
"1",
")",
":",
"if",
"'method'",
"in",
"method",
".",
"__class__",
".",
"__name__",
":",
"number_of_arguments",
"+=",
"1",
"func",
"=",
"getattr",
"(",
"method",
",",
"'im_func'",
","... | Returns True if the given method will accept the given number of arguments
method: the method to perform introspection on
number_of_arguments: the number_of_arguments | [
"Returns",
"True",
"if",
"the",
"given",
"method",
"will",
"accept",
"the",
"given",
"number",
"of",
"arguments"
] | python | train | 48.8 |
amaas-fintech/amaas-core-sdk-python | amaascore/assets/interface.py | https://github.com/amaas-fintech/amaas-core-sdk-python/blob/347b71f8e776b2dde582b015e31b4802d91e8040/amaascore/assets/interface.py#L248-L261 | def clear(self, asset_manager_id):
""" This method deletes all the data for an asset_manager_id.
It should be used with extreme caution. In production it
is almost always better to Inactivate rather than delete. """
self.logger.info('Clear Assets - Asset Manager: %s', asset_mana... | [
"def",
"clear",
"(",
"self",
",",
"asset_manager_id",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Clear Assets - Asset Manager: %s'",
",",
"asset_manager_id",
")",
"url",
"=",
"'%s/clear/%s'",
"%",
"(",
"self",
".",
"endpoint",
",",
"asset_manager_id",
... | This method deletes all the data for an asset_manager_id.
It should be used with extreme caution. In production it
is almost always better to Inactivate rather than delete. | [
"This",
"method",
"deletes",
"all",
"the",
"data",
"for",
"an",
"asset_manager_id",
".",
"It",
"should",
"be",
"used",
"with",
"extreme",
"caution",
".",
"In",
"production",
"it",
"is",
"almost",
"always",
"better",
"to",
"Inactivate",
"rather",
"than",
"del... | python | train | 49.142857 |
spyder-ide/spyder | spyder/utils/workers.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/workers.py#L151-L157 | def _communicate(self):
"""Callback for communicate."""
if (not self._communicate_first and
self._process.state() == QProcess.NotRunning):
self.communicate()
elif self._fired:
self._timer.stop() | [
"def",
"_communicate",
"(",
"self",
")",
":",
"if",
"(",
"not",
"self",
".",
"_communicate_first",
"and",
"self",
".",
"_process",
".",
"state",
"(",
")",
"==",
"QProcess",
".",
"NotRunning",
")",
":",
"self",
".",
"communicate",
"(",
")",
"elif",
"sel... | Callback for communicate. | [
"Callback",
"for",
"communicate",
"."
] | python | train | 36 |
eternnoir/pyTelegramBotAPI | telebot/apihelper.py | https://github.com/eternnoir/pyTelegramBotAPI/blob/47b53b88123097f1b9562a6cd5d4e080b86185d1/telebot/apihelper.py#L828-L841 | def answer_pre_checkout_query(token, pre_checkout_query_id, ok, error_message=None):
"""
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. O... | [
"def",
"answer_pre_checkout_query",
"(",
"token",
",",
"pre_checkout_query_id",
",",
"ok",
",",
"error_message",
"=",
"None",
")",
":",
"method_url",
"=",
"'answerPreCheckoutQuery'",
"payload",
"=",
"{",
"'pre_checkout_query_id'",
":",
"pre_checkout_query_id",
",",
"'... | Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the... | [
"Once",
"the",
"user",
"has",
"confirmed",
"their",
"payment",
"and",
"shipping",
"details",
"the",
"Bot",
"API",
"sends",
"the",
"final",
"confirmation",
"in",
"the",
"form",
"of",
"an",
"Update",
"with",
"the",
"field",
"pre_checkout_query",
".",
"Use",
"t... | python | train | 98.928571 |
dbader/schedule | schedule/__init__.py | https://github.com/dbader/schedule/blob/5d2653c28b1029f1e9ddc85cd9ef26c29a79fcea/schedule/__init__.py#L364-L376 | def tag(self, *tags):
"""
Tags the job with one or more unique indentifiers.
Tags must be hashable. Duplicate tags are discarded.
:param tags: A unique list of ``Hashable`` tags.
:return: The invoked job instance
"""
if not all(isinstance(tag, collections.Hashab... | [
"def",
"tag",
"(",
"self",
",",
"*",
"tags",
")",
":",
"if",
"not",
"all",
"(",
"isinstance",
"(",
"tag",
",",
"collections",
".",
"Hashable",
")",
"for",
"tag",
"in",
"tags",
")",
":",
"raise",
"TypeError",
"(",
"'Tags must be hashable'",
")",
"self",... | Tags the job with one or more unique indentifiers.
Tags must be hashable. Duplicate tags are discarded.
:param tags: A unique list of ``Hashable`` tags.
:return: The invoked job instance | [
"Tags",
"the",
"job",
"with",
"one",
"or",
"more",
"unique",
"indentifiers",
"."
] | python | train | 33.307692 |
gmr/tinman | tinman/auth/ldapauth.py | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/ldapauth.py#L24-L54 | def auth_user_ldap(uname, pwd):
"""
Attempts to bind using the uname/pwd combo passed in.
If that works, returns true. Otherwise returns false.
"""
if not uname or not pwd:
logging.error("Username or password not supplied")
return False
ld = ldap.initialize(LDAP_URL)
if LDA... | [
"def",
"auth_user_ldap",
"(",
"uname",
",",
"pwd",
")",
":",
"if",
"not",
"uname",
"or",
"not",
"pwd",
":",
"logging",
".",
"error",
"(",
"\"Username or password not supplied\"",
")",
"return",
"False",
"ld",
"=",
"ldap",
".",
"initialize",
"(",
"LDAP_URL",
... | Attempts to bind using the uname/pwd combo passed in.
If that works, returns true. Otherwise returns false. | [
"Attempts",
"to",
"bind",
"using",
"the",
"uname",
"/",
"pwd",
"combo",
"passed",
"in",
".",
"If",
"that",
"works",
"returns",
"true",
".",
"Otherwise",
"returns",
"false",
"."
] | python | train | 33.645161 |
honsiorovskyi/codeharvester | src/codeharvester/harvester.py | https://github.com/honsiorovskyi/codeharvester/blob/301b907b32ef9bbdb7099657100fbd3829c3ecc8/src/codeharvester/harvester.py#L56-L105 | def parse_requirements(self, filename):
"""
Recursively find all the requirements needed
storing them in req_parents, req_paths, req_linenos
"""
cwd = os.path.dirname(filename)
try:
fd = open(filename, 'r')
for i, line in enumerate(fd.readlines()... | [
"def",
"parse_requirements",
"(",
"self",
",",
"filename",
")",
":",
"cwd",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"filename",
")",
"try",
":",
"fd",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"for",
"i",
",",
"line",
"in",
"enumerate",
"... | Recursively find all the requirements needed
storing them in req_parents, req_paths, req_linenos | [
"Recursively",
"find",
"all",
"the",
"requirements",
"needed",
"storing",
"them",
"in",
"req_parents",
"req_paths",
"req_linenos"
] | python | train | 37.64 |
pip-services3-python/pip-services3-components-python | pip_services3_components/cache/CacheEntry.py | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/cache/CacheEntry.py#L36-L45 | def set_value(self, value, timeout):
"""
Sets a new value and extends its expiration.
:param value: a new cached value.
:param timeout: a expiration timeout in milliseconds.
"""
self.value = value
self.expiration = time.perf_counter() * 1000 + timeout | [
"def",
"set_value",
"(",
"self",
",",
"value",
",",
"timeout",
")",
":",
"self",
".",
"value",
"=",
"value",
"self",
".",
"expiration",
"=",
"time",
".",
"perf_counter",
"(",
")",
"*",
"1000",
"+",
"timeout"
] | Sets a new value and extends its expiration.
:param value: a new cached value.
:param timeout: a expiration timeout in milliseconds. | [
"Sets",
"a",
"new",
"value",
"and",
"extends",
"its",
"expiration",
"."
] | python | train | 30 |
mozilla-b2g/fxos-certsuite | mcts/utils/handlers/adb_b2g.py | https://github.com/mozilla-b2g/fxos-certsuite/blob/152a76c7c4c9d908524cf6e6fc25a498058f363d/mcts/utils/handlers/adb_b2g.py#L246-L259 | def reboot(self, timeout=None, wait_polling_interval=None):
"""Reboot the device, waiting for the adb connection to become stable.
:param timeout: Maximum time to wait for reboot.
:param wait_polling_interval: Interval at which to poll for device readiness.
"""
if timeout is Non... | [
"def",
"reboot",
"(",
"self",
",",
"timeout",
"=",
"None",
",",
"wait_polling_interval",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"self",
".",
"_timeout",
"if",
"wait_polling_interval",
"is",
"None",
":",
"wait_polling_inter... | Reboot the device, waiting for the adb connection to become stable.
:param timeout: Maximum time to wait for reboot.
:param wait_polling_interval: Interval at which to poll for device readiness. | [
"Reboot",
"the",
"device",
"waiting",
"for",
"the",
"adb",
"connection",
"to",
"become",
"stable",
"."
] | python | train | 44.928571 |
googleapis/google-cloud-python | firestore/google/cloud/firestore_v1beta1/_helpers.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/_helpers.py#L204-L215 | def encode_dict(values_dict):
"""Encode a dictionary into protobuf ``Value``-s.
Args:
values_dict (dict): The dictionary to encode as protobuf fields.
Returns:
Dict[str, ~google.cloud.firestore_v1beta1.types.Value]: A
dictionary of string keys and ``Value`` protobufs as dictionary
... | [
"def",
"encode_dict",
"(",
"values_dict",
")",
":",
"return",
"{",
"key",
":",
"encode_value",
"(",
"value",
")",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"values_dict",
")",
"}"
] | Encode a dictionary into protobuf ``Value``-s.
Args:
values_dict (dict): The dictionary to encode as protobuf fields.
Returns:
Dict[str, ~google.cloud.firestore_v1beta1.types.Value]: A
dictionary of string keys and ``Value`` protobufs as dictionary
values. | [
"Encode",
"a",
"dictionary",
"into",
"protobuf",
"Value",
"-",
"s",
"."
] | python | train | 34.583333 |
saltstack/salt | salt/modules/libcloud_storage.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/libcloud_storage.py#L116-L149 | def list_container_objects(container_name, profile, **libcloud_kwargs):
'''
List container objects (e.g. files) for the given container_id on the given profile
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:par... | [
"def",
"list_container_objects",
"(",
"container_name",
",",
"profile",
",",
"*",
"*",
"libcloud_kwargs",
")",
":",
"conn",
"=",
"_get_driver",
"(",
"profile",
"=",
"profile",
")",
"container",
"=",
"conn",
".",
"get_container",
"(",
"container_name",
")",
"li... | List container objects (e.g. files) for the given container_id on the given profile
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's list_container_objects method
... | [
"List",
"container",
"objects",
"(",
"e",
".",
"g",
".",
"files",
")",
"for",
"the",
"given",
"container_id",
"on",
"the",
"given",
"profile"
] | python | train | 31.235294 |
Calysto/calysto | calysto/ai/conx.py | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4678-L4682 | def addSRNLayers(self, inc, hidc, outc):
"""
Wraps SRN.addThreeLayers() for compatibility.
"""
self.addThreeLayers(inc, hidc, outc) | [
"def",
"addSRNLayers",
"(",
"self",
",",
"inc",
",",
"hidc",
",",
"outc",
")",
":",
"self",
".",
"addThreeLayers",
"(",
"inc",
",",
"hidc",
",",
"outc",
")"
] | Wraps SRN.addThreeLayers() for compatibility. | [
"Wraps",
"SRN",
".",
"addThreeLayers",
"()",
"for",
"compatibility",
"."
] | python | train | 31.8 |
ZELLMECHANIK-DRESDEN/dclab | dclab/isoelastics/__init__.py | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/isoelastics/__init__.py#L312-L346 | def get_with_rtdcbase(self, col1, col2, method, dataset,
viscosity=None, add_px_err=False):
"""Convenience method that extracts the metadata from RTDCBase
Parameters
----------
col1: str
Name of the first feature of all isoelastics
(e.g.... | [
"def",
"get_with_rtdcbase",
"(",
"self",
",",
"col1",
",",
"col2",
",",
"method",
",",
"dataset",
",",
"viscosity",
"=",
"None",
",",
"add_px_err",
"=",
"False",
")",
":",
"cfg",
"=",
"dataset",
".",
"config",
"return",
"self",
".",
"get",
"(",
"col1",... | Convenience method that extracts the metadata from RTDCBase
Parameters
----------
col1: str
Name of the first feature of all isoelastics
(e.g. isoel[0][:,0])
col2: str
Name of the second feature of all isoelastics
(e.g. isoel[0][:,1])
... | [
"Convenience",
"method",
"that",
"extracts",
"the",
"metadata",
"from",
"RTDCBase"
] | python | train | 41.914286 |
matthewdeanmartin/jiggle_version | jiggle_version/file_opener.py | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/file_opener.py#L104-L114 | def read_metadata(self, file_path): # type: (str) ->str
"""
Get version out of a .ini file (or .cfg)
:return:
"""
config = configparser.ConfigParser()
config.read(file_path)
try:
return unicode(config["metadata"]["version"])
except KeyError:
... | [
"def",
"read_metadata",
"(",
"self",
",",
"file_path",
")",
":",
"# type: (str) ->str",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"config",
".",
"read",
"(",
"file_path",
")",
"try",
":",
"return",
"unicode",
"(",
"config",
"[",
"\"metada... | Get version out of a .ini file (or .cfg)
:return: | [
"Get",
"version",
"out",
"of",
"a",
".",
"ini",
"file",
"(",
"or",
".",
"cfg",
")",
":",
"return",
":"
] | python | train | 30 |
riptano/ccm | ccmlib/node.py | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L150-L194 | def load(path, name, cluster):
"""
Load a node from from the path on disk to the config files, the node name and the
cluster the node is part of.
"""
node_path = os.path.join(path, name)
filename = os.path.join(node_path, 'node.conf')
with open(filename, 'r') as f... | [
"def",
"load",
"(",
"path",
",",
"name",
",",
"cluster",
")",
":",
"node_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"name",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"node_path",
",",
"'node.conf'",
")",
"with",
... | Load a node from from the path on disk to the config files, the node name and the
cluster the node is part of. | [
"Load",
"a",
"node",
"from",
"from",
"the",
"path",
"on",
"disk",
"to",
"the",
"config",
"files",
"the",
"node",
"name",
"and",
"the",
"cluster",
"the",
"node",
"is",
"part",
"of",
"."
] | python | train | 50.711111 |
timofurrer/colorful | colorful/__init__.py | https://github.com/timofurrer/colorful/blob/919fa6da17865cc5e01e6b16119193a97d180dc9/colorful/__init__.py#L42-L54 | def with_setup(self, colormode=None, colorpalette=None, extend_colors=False):
"""
Return a new Colorful object with the given color config.
"""
colorful = Colorful(
colormode=self.colorful.colormode,
colorpalette=copy.copy(self.colorful.colorpalette)
)
... | [
"def",
"with_setup",
"(",
"self",
",",
"colormode",
"=",
"None",
",",
"colorpalette",
"=",
"None",
",",
"extend_colors",
"=",
"False",
")",
":",
"colorful",
"=",
"Colorful",
"(",
"colormode",
"=",
"self",
".",
"colorful",
".",
"colormode",
",",
"colorpalet... | Return a new Colorful object with the given color config. | [
"Return",
"a",
"new",
"Colorful",
"object",
"with",
"the",
"given",
"color",
"config",
"."
] | python | valid | 34.615385 |
quantopian/zipline | zipline/utils/sharedoc.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/sharedoc.py#L85-L101 | def templated_docstring(**docs):
"""
Decorator allowing the use of templated docstrings.
Examples
--------
>>> @templated_docstring(foo='bar')
... def my_func(self, foo):
... '''{foo}'''
...
>>> my_func.__doc__
'bar'
"""
def decorator(f):
f.__doc__ = format_d... | [
"def",
"templated_docstring",
"(",
"*",
"*",
"docs",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"f",
".",
"__doc__",
"=",
"format_docstring",
"(",
"f",
".",
"__name__",
",",
"f",
".",
"__doc__",
",",
"docs",
")",
"return",
"f",
"return",
"deco... | Decorator allowing the use of templated docstrings.
Examples
--------
>>> @templated_docstring(foo='bar')
... def my_func(self, foo):
... '''{foo}'''
...
>>> my_func.__doc__
'bar' | [
"Decorator",
"allowing",
"the",
"use",
"of",
"templated",
"docstrings",
"."
] | python | train | 22.294118 |
numenta/htmresearch | projects/speech_commands/analyze_experiment.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/speech_commands/analyze_experiment.py#L189-L216 | def findOptimalResults(expName, suite, outFile):
"""
Go through every experiment in the specified folder. For each experiment, find
the iteration with the best validation score, and return the metrics
associated with that iteration.
"""
writer = csv.writer(outFile)
headers = ["testAccuracy", "bgAccuracy",... | [
"def",
"findOptimalResults",
"(",
"expName",
",",
"suite",
",",
"outFile",
")",
":",
"writer",
"=",
"csv",
".",
"writer",
"(",
"outFile",
")",
"headers",
"=",
"[",
"\"testAccuracy\"",
",",
"\"bgAccuracy\"",
",",
"\"maxTotalAccuracy\"",
",",
"\"experiment path\""... | Go through every experiment in the specified folder. For each experiment, find
the iteration with the best validation score, and return the metrics
associated with that iteration. | [
"Go",
"through",
"every",
"experiment",
"in",
"the",
"specified",
"folder",
".",
"For",
"each",
"experiment",
"find",
"the",
"iteration",
"with",
"the",
"best",
"validation",
"score",
"and",
"return",
"the",
"metrics",
"associated",
"with",
"that",
"iteration",
... | python | train | 40 |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/input_readers.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/input_readers.py#L2115-L2133 | def from_json(cls, json):
"""Creates an instance of the InputReader for the given input shard's state.
Args:
json: The InputReader state as a dict-like object.
Returns:
An instance of the InputReader configured using the given JSON parameters.
"""
# Strip out unrecognized parameters, a... | [
"def",
"from_json",
"(",
"cls",
",",
"json",
")",
":",
"# Strip out unrecognized parameters, as introduced by b/5960884.",
"params",
"=",
"dict",
"(",
"(",
"str",
"(",
"k",
")",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"json",
".",
"iteritems",
"(",
")",... | Creates an instance of the InputReader for the given input shard's state.
Args:
json: The InputReader state as a dict-like object.
Returns:
An instance of the InputReader configured using the given JSON parameters. | [
"Creates",
"an",
"instance",
"of",
"the",
"InputReader",
"for",
"the",
"given",
"input",
"shard",
"s",
"state",
"."
] | python | train | 39.947368 |
odlgroup/odl | odl/util/numerics.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/util/numerics.py#L557-L603 | def _padding_slices_inner(lhs_arr, rhs_arr, axis, offset, pad_mode):
"""Return slices into the inner array part for a given ``pad_mode``.
When performing padding, these slices yield the values from the inner
part of a larger array that are to be assigned to the excess part
of the same array. Slices for... | [
"def",
"_padding_slices_inner",
"(",
"lhs_arr",
",",
"rhs_arr",
",",
"axis",
",",
"offset",
",",
"pad_mode",
")",
":",
"# Calculate the start and stop indices for the inner part",
"istart_inner",
"=",
"offset",
"[",
"axis",
"]",
"n_large",
"=",
"max",
"(",
"lhs_arr"... | Return slices into the inner array part for a given ``pad_mode``.
When performing padding, these slices yield the values from the inner
part of a larger array that are to be assigned to the excess part
of the same array. Slices for both sides ("left", "right") of
the arrays in a given ``axis`` are retu... | [
"Return",
"slices",
"into",
"the",
"inner",
"array",
"part",
"for",
"a",
"given",
"pad_mode",
"."
] | python | train | 44.276596 |
kragniz/python-etcd3 | etcd3/client.py | https://github.com/kragniz/python-etcd3/blob/0adb14840d4a6011a2023a13f07e247e4c336a80/etcd3/client.py#L895-L910 | def update_member(self, member_id, peer_urls):
"""
Update the configuration of an existing member in the cluster.
:param member_id: ID of the member to update
:param peer_urls: new list of peer urls the member will use to
communicate with the cluster
""... | [
"def",
"update_member",
"(",
"self",
",",
"member_id",
",",
"peer_urls",
")",
":",
"member_update_request",
"=",
"etcdrpc",
".",
"MemberUpdateRequest",
"(",
"ID",
"=",
"member_id",
",",
"peerURLs",
"=",
"peer_urls",
")",
"self",
".",
"clusterstub",
".",
"Membe... | Update the configuration of an existing member in the cluster.
:param member_id: ID of the member to update
:param peer_urls: new list of peer urls the member will use to
communicate with the cluster | [
"Update",
"the",
"configuration",
"of",
"an",
"existing",
"member",
"in",
"the",
"cluster",
"."
] | python | train | 40.75 |
tango-controls/pytango | tango/utils.py | https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/utils.py#L1242-L1262 | def index(self, item, minindex=0, maxindex=None):
"""Provide an index of first occurence of item in the list. (or raise
a ValueError if item not present)
If item is not a string, will raise a TypeError.
minindex and maxindex are also optional arguments
s.index(x[, i[, j]]) return... | [
"def",
"index",
"(",
"self",
",",
"item",
",",
"minindex",
"=",
"0",
",",
"maxindex",
"=",
"None",
")",
":",
"if",
"maxindex",
"is",
"None",
":",
"maxindex",
"=",
"len",
"(",
"self",
")",
"minindex",
"=",
"max",
"(",
"0",
",",
"minindex",
")",
"-... | Provide an index of first occurence of item in the list. (or raise
a ValueError if item not present)
If item is not a string, will raise a TypeError.
minindex and maxindex are also optional arguments
s.index(x[, i[, j]]) return smallest k such that s[k] == x and i <= k < j | [
"Provide",
"an",
"index",
"of",
"first",
"occurence",
"of",
"item",
"in",
"the",
"list",
".",
"(",
"or",
"raise",
"a",
"ValueError",
"if",
"item",
"not",
"present",
")",
"If",
"item",
"is",
"not",
"a",
"string",
"will",
"raise",
"a",
"TypeError",
".",
... | python | train | 42.952381 |
uw-it-aca/uw-restclients | restclients/bridge/user.py | https://github.com/uw-it-aca/uw-restclients/blob/e12dcd32bf5296b6ebdf71798031594afb7852cb/restclients/bridge/user.py#L118-L127 | def get_user_by_id(bridge_id, include_course_summary=True):
"""
:param bridge_id: integer
Return a list of BridgeUsers objects with custom fields
"""
url = author_id_url(bridge_id) + "?%s" % CUSTOM_FIELD
if include_course_summary:
url = "%s&%s" % (url, COURSE_SUMMARY)
resp = get_reso... | [
"def",
"get_user_by_id",
"(",
"bridge_id",
",",
"include_course_summary",
"=",
"True",
")",
":",
"url",
"=",
"author_id_url",
"(",
"bridge_id",
")",
"+",
"\"?%s\"",
"%",
"CUSTOM_FIELD",
"if",
"include_course_summary",
":",
"url",
"=",
"\"%s&%s\"",
"%",
"(",
"u... | :param bridge_id: integer
Return a list of BridgeUsers objects with custom fields | [
":",
"param",
"bridge_id",
":",
"integer",
"Return",
"a",
"list",
"of",
"BridgeUsers",
"objects",
"with",
"custom",
"fields"
] | python | train | 36.1 |
apache/spark | python/pyspark/mllib/evaluation.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/evaluation.py#L514-L521 | def recall(self, label=None):
"""
Returns recall or recall for a given label (category) if specified.
"""
if label is None:
return self.call("recall")
else:
return self.call("recall", float(label)) | [
"def",
"recall",
"(",
"self",
",",
"label",
"=",
"None",
")",
":",
"if",
"label",
"is",
"None",
":",
"return",
"self",
".",
"call",
"(",
"\"recall\"",
")",
"else",
":",
"return",
"self",
".",
"call",
"(",
"\"recall\"",
",",
"float",
"(",
"label",
"... | Returns recall or recall for a given label (category) if specified. | [
"Returns",
"recall",
"or",
"recall",
"for",
"a",
"given",
"label",
"(",
"category",
")",
"if",
"specified",
"."
] | python | train | 31.75 |
DarkEnergySurvey/ugali | ugali/analysis/results.py | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/results.py#L100-L113 | def estimate_position_angle(self,param='position_angle',burn=None,clip=10.0,alpha=0.32):
""" Estimate the position angle from the posterior dealing
with periodicity.
"""
# Transform so peak in the middle of the distribution
pa = self.samples.get(param,burn=burn,clip=clip)
... | [
"def",
"estimate_position_angle",
"(",
"self",
",",
"param",
"=",
"'position_angle'",
",",
"burn",
"=",
"None",
",",
"clip",
"=",
"10.0",
",",
"alpha",
"=",
"0.32",
")",
":",
"# Transform so peak in the middle of the distribution",
"pa",
"=",
"self",
".",
"sampl... | Estimate the position angle from the posterior dealing
with periodicity. | [
"Estimate",
"the",
"position",
"angle",
"from",
"the",
"posterior",
"dealing",
"with",
"periodicity",
"."
] | python | train | 42.928571 |
hugapi/hug | hug/authentication.py | https://github.com/hugapi/hug/blob/080901c81576657f82e2432fd4a82f1d0d2f370c/hug/authentication.py#L68-L98 | def basic(request, response, verify_user, realm='simple', context=None, **kwargs):
"""Basic HTTP Authentication"""
http_auth = request.auth
response.set_header('WWW-Authenticate', 'Basic')
if http_auth is None:
return
if isinstance(http_auth, bytes):
http_auth = http_auth.decode('ut... | [
"def",
"basic",
"(",
"request",
",",
"response",
",",
"verify_user",
",",
"realm",
"=",
"'simple'",
",",
"context",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"http_auth",
"=",
"request",
".",
"auth",
"response",
".",
"set_header",
"(",
"'WWW-Authen... | Basic HTTP Authentication | [
"Basic",
"HTTP",
"Authentication"
] | python | train | 42.774194 |
tamasgal/km3pipe | km3pipe/db.py | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L645-L648 | def unit(self, parameter):
"Get the unit for given parameter"
parameter = self._get_parameter_name(parameter).lower()
return self._parameters[parameter]['Unit'] | [
"def",
"unit",
"(",
"self",
",",
"parameter",
")",
":",
"parameter",
"=",
"self",
".",
"_get_parameter_name",
"(",
"parameter",
")",
".",
"lower",
"(",
")",
"return",
"self",
".",
"_parameters",
"[",
"parameter",
"]",
"[",
"'Unit'",
"]"
] | Get the unit for given parameter | [
"Get",
"the",
"unit",
"for",
"given",
"parameter"
] | python | train | 45.25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.