repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
majerteam/sqla_inspect | sqla_inspect/csv.py | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/csv.py#L178-L194 | def add_extra_datas(self, extra_datas):
"""
Add extra datas to the last row
headers : [col1, col2, col3, col4, col5]
row : {col1: a1, col2: a2, col3: a3}
extra_datas : [a4, a5]
row becomes : {col1: a1, col2: a2, col3: a3, col4: a4, col5: a5}
in case of longer ex... | [
"def",
"add_extra_datas",
"(",
"self",
",",
"extra_datas",
")",
":",
"# we will add datas starting from the last index",
"for",
"index",
",",
"data",
"in",
"enumerate",
"(",
"extra_datas",
")",
":",
"header",
"=",
"self",
".",
"extra_headers",
"[",
"index",
"]",
... | Add extra datas to the last row
headers : [col1, col2, col3, col4, col5]
row : {col1: a1, col2: a2, col3: a3}
extra_datas : [a4, a5]
row becomes : {col1: a1, col2: a2, col3: a3, col4: a4, col5: a5}
in case of longer extra_datas, the last columns will be overriden
:para... | [
"Add",
"extra",
"datas",
"to",
"the",
"last",
"row",
"headers",
":",
"[",
"col1",
"col2",
"col3",
"col4",
"col5",
"]",
"row",
":",
"{",
"col1",
":",
"a1",
"col2",
":",
"a2",
"col3",
":",
"a3",
"}",
"extra_datas",
":",
"[",
"a4",
"a5",
"]"
] | python | train |
PlaidWeb/Publ | publ/image/local.py | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L23-L55 | def fix_orientation(image):
""" adapted from https://stackoverflow.com/a/30462851/318857
Apply Image.transpose to ensure 0th row of pixels is at the visual
top of the image, and 0th column is the visual left-hand side.
Return the original image if unable to determine the orientation.
... | [
"def",
"fix_orientation",
"(",
"image",
")",
":",
"exif_orientation_tag",
"=",
"0x0112",
"exif_transpose_sequences",
"=",
"[",
"[",
"]",
",",
"[",
"]",
",",
"[",
"PIL",
".",
"Image",
".",
"FLIP_LEFT_RIGHT",
"]",
",",
"[",
"PIL",
".",
"Image",
".",
"ROTAT... | adapted from https://stackoverflow.com/a/30462851/318857
Apply Image.transpose to ensure 0th row of pixels is at the visual
top of the image, and 0th column is the visual left-hand side.
Return the original image if unable to determine the orientation.
As per CIPA DC-008-2012, the orie... | [
"adapted",
"from",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"30462851",
"/",
"318857"
] | python | train |
dotzero/tilda-api-python | tilda/client.py | https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/client.py#L137-L144 | def get_page_full_export(self, page_id):
""" Get full page info for export and body html code """
try:
result = self._request('/getpagefullexport/',
{'pageid': page_id})
return TildaPage(**result)
except NetworkError:
return ... | [
"def",
"get_page_full_export",
"(",
"self",
",",
"page_id",
")",
":",
"try",
":",
"result",
"=",
"self",
".",
"_request",
"(",
"'/getpagefullexport/'",
",",
"{",
"'pageid'",
":",
"page_id",
"}",
")",
"return",
"TildaPage",
"(",
"*",
"*",
"result",
")",
"... | Get full page info for export and body html code | [
"Get",
"full",
"page",
"info",
"for",
"export",
"and",
"body",
"html",
"code"
] | python | train |
lemieuxl/pyGenClean | pyGenClean/DupSNPs/duplicated_snps.py | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSNPs/duplicated_snps.py#L564-L623 | def computeFrequency(prefix, outPrefix):
"""Computes the frequency of the SNPs using Plink.
:param prefix: the prefix of the input files.
:param outPrefix: the prefix of the output files.
:type prefix: str
:type outPrefix: str
:returns: a :py:class:`dict` containing the frequency of each mark... | [
"def",
"computeFrequency",
"(",
"prefix",
",",
"outPrefix",
")",
":",
"# The plink command",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--tfile\"",
",",
"prefix",
",",
"\"--freq\"",
",",
"\"--out\"",
",",
"outPrefix",
"+",
"\".duplicated_sn... | Computes the frequency of the SNPs using Plink.
:param prefix: the prefix of the input files.
:param outPrefix: the prefix of the output files.
:type prefix: str
:type outPrefix: str
:returns: a :py:class:`dict` containing the frequency of each marker.
Start by computing the frequency of all... | [
"Computes",
"the",
"frequency",
"of",
"the",
"SNPs",
"using",
"Plink",
"."
] | python | train |
facelessuser/backrefs | backrefs/bre.py | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bre.py#L419-L431 | def sub(pattern, repl, string, *args, **kwargs):
"""Apply `sub` after applying backrefs."""
flags = args[4] if len(args) > 4 else kwargs.get('flags', 0)
is_replace = _is_replace(repl)
is_string = isinstance(repl, (str, bytes))
if is_replace and repl.use_format:
raise ValueError("Compiled re... | [
"def",
"sub",
"(",
"pattern",
",",
"repl",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"flags",
"=",
"args",
"[",
"4",
"]",
"if",
"len",
"(",
"args",
")",
">",
"4",
"else",
"kwargs",
".",
"get",
"(",
"'flags'",
",",
"0... | Apply `sub` after applying backrefs. | [
"Apply",
"sub",
"after",
"applying",
"backrefs",
"."
] | python | train |
coursera-dl/coursera-dl | coursera/api.py | https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1349-L1392 | def extract_links_from_reference(self, short_id):
"""
Return a dictionary with supplement files (pdf, csv, zip, ipynb, html
and so on) extracted from supplement page.
@return: @see CourseraOnDemand._extract_links_from_text
"""
logging.debug('Gathering resource URLs for s... | [
"def",
"extract_links_from_reference",
"(",
"self",
",",
"short_id",
")",
":",
"logging",
".",
"debug",
"(",
"'Gathering resource URLs for short_id <%s>.'",
",",
"short_id",
")",
"try",
":",
"dom",
"=",
"get_page",
"(",
"self",
".",
"_session",
",",
"OPENCOURSE_RE... | Return a dictionary with supplement files (pdf, csv, zip, ipynb, html
and so on) extracted from supplement page.
@return: @see CourseraOnDemand._extract_links_from_text | [
"Return",
"a",
"dictionary",
"with",
"supplement",
"files",
"(",
"pdf",
"csv",
"zip",
"ipynb",
"html",
"and",
"so",
"on",
")",
"extracted",
"from",
"supplement",
"page",
"."
] | python | train |
hollenstein/maspy | maspy/inference.py | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/inference.py#L738-L811 | def _findRedundantProteins(protToPeps, pepToProts, proteins=None):
"""Returns a set of proteins with redundant peptide evidence.
After removing the redundant proteins from the "protToPeps" and "pepToProts"
mapping, all remaining proteins have at least one unique peptide. The
remaining proteins are a "m... | [
"def",
"_findRedundantProteins",
"(",
"protToPeps",
",",
"pepToProts",
",",
"proteins",
"=",
"None",
")",
":",
"if",
"proteins",
"is",
"None",
":",
"proteins",
"=",
"viewkeys",
"(",
"protToPeps",
")",
"pepFrequency",
"=",
"_getValueCounts",
"(",
"pepToProts",
... | Returns a set of proteins with redundant peptide evidence.
After removing the redundant proteins from the "protToPeps" and "pepToProts"
mapping, all remaining proteins have at least one unique peptide. The
remaining proteins are a "minimal" set of proteins that are able to explain
all peptides. However... | [
"Returns",
"a",
"set",
"of",
"proteins",
"with",
"redundant",
"peptide",
"evidence",
"."
] | python | train |
iotile/coretools | iotileemulate/iotile/emulate/reference/controller_features/config_database.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/config_database.py#L156-L172 | def add_data(self, data):
"""Add data to the currently in progress entry.
Args:
data (bytes): The data that we want to add.
Returns:
int: An error code
"""
if self.data_size - self.data_index < len(data):
return Error.DESTINATION_BUFFER_TOO_... | [
"def",
"add_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"data_size",
"-",
"self",
".",
"data_index",
"<",
"len",
"(",
"data",
")",
":",
"return",
"Error",
".",
"DESTINATION_BUFFER_TOO_SMALL",
"if",
"self",
".",
"in_progress",
"is",
"not... | Add data to the currently in progress entry.
Args:
data (bytes): The data that we want to add.
Returns:
int: An error code | [
"Add",
"data",
"to",
"the",
"currently",
"in",
"progress",
"entry",
"."
] | python | train |
ianepperson/pyredminews | redmine/redmine.py | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L278-L280 | def resolve(self, notes=None):
'''Save all changes and resolve this issue'''
self.set_status(self._redmine.ISSUE_STATUS_ID_RESOLVED, notes=notes) | [
"def",
"resolve",
"(",
"self",
",",
"notes",
"=",
"None",
")",
":",
"self",
".",
"set_status",
"(",
"self",
".",
"_redmine",
".",
"ISSUE_STATUS_ID_RESOLVED",
",",
"notes",
"=",
"notes",
")"
] | Save all changes and resolve this issue | [
"Save",
"all",
"changes",
"and",
"resolve",
"this",
"issue"
] | python | train |
openmeteo/pd2hts | pd2hts/__init__.py | https://github.com/openmeteo/pd2hts/blob/b8f982046e2b99680445298b63a488dd76f6e104/pd2hts/__init__.py#L238-L245 | def read_minutes_months(self, s):
"""Return a (minutes, months) tuple after parsing a "M,N" string.
"""
try:
(minutes, months) = [int(x.strip()) for x in s.split(',')]
return minutes, months
except Exception:
raise ParsingError(('Value should be "minut... | [
"def",
"read_minutes_months",
"(",
"self",
",",
"s",
")",
":",
"try",
":",
"(",
"minutes",
",",
"months",
")",
"=",
"[",
"int",
"(",
"x",
".",
"strip",
"(",
")",
")",
"for",
"x",
"in",
"s",
".",
"split",
"(",
"','",
")",
"]",
"return",
"minutes... | Return a (minutes, months) tuple after parsing a "M,N" string. | [
"Return",
"a",
"(",
"minutes",
"months",
")",
"tuple",
"after",
"parsing",
"a",
"M",
"N",
"string",
"."
] | python | train |
vintasoftware/django-role-permissions | rolepermissions/permissions.py | https://github.com/vintasoftware/django-role-permissions/blob/28924361e689e994e0c3575e18104a1a5abd8de6/rolepermissions/permissions.py#L41-L56 | def available_perm_status(user):
"""
Get a boolean map of the permissions available to a user
based on that user's roles.
"""
roles = get_user_roles(user)
permission_hash = {}
for role in roles:
permission_names = role.permission_names_list()
for permission_name in permissi... | [
"def",
"available_perm_status",
"(",
"user",
")",
":",
"roles",
"=",
"get_user_roles",
"(",
"user",
")",
"permission_hash",
"=",
"{",
"}",
"for",
"role",
"in",
"roles",
":",
"permission_names",
"=",
"role",
".",
"permission_names_list",
"(",
")",
"for",
"per... | Get a boolean map of the permissions available to a user
based on that user's roles. | [
"Get",
"a",
"boolean",
"map",
"of",
"the",
"permissions",
"available",
"to",
"a",
"user",
"based",
"on",
"that",
"user",
"s",
"roles",
"."
] | python | train |
linnarsson-lab/loompy | loompy/loompy.py | https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L547-L654 | def scan(self, *, items: np.ndarray = None, axis: int = None, layers: Iterable = None, key: str = None, batch_size: int = 8 * 64) -> Iterable[Tuple[int, np.ndarray, loompy.LoomView]]:
"""
Scan across one axis and return batches of rows (columns) as LoomView objects
Args
----
items: np.ndarray
the indexes ... | [
"def",
"scan",
"(",
"self",
",",
"*",
",",
"items",
":",
"np",
".",
"ndarray",
"=",
"None",
",",
"axis",
":",
"int",
"=",
"None",
",",
"layers",
":",
"Iterable",
"=",
"None",
",",
"key",
":",
"str",
"=",
"None",
",",
"batch_size",
":",
"int",
"... | Scan across one axis and return batches of rows (columns) as LoomView objects
Args
----
items: np.ndarray
the indexes [0, 2, 13, ... ,973] of the rows/cols to include along the axis
OR: boolean mask array giving the rows/cols to include
axis: int
0:rows or 1:cols
batch_size: int
the chuncks retur... | [
"Scan",
"across",
"one",
"axis",
"and",
"return",
"batches",
"of",
"rows",
"(",
"columns",
")",
"as",
"LoomView",
"objects"
] | python | train |
mardix/Mocha | mocha/render.py | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L104-L118 | def json(func):
"""
Decorator to render as JSON
:param func:
:return:
"""
if inspect.isclass(func):
apply_function_to_members(func, json)
return func
else:
@functools.wraps(func)
def decorated_view(*args, **kwargs):
data = func(*args, **kwargs)
... | [
"def",
"json",
"(",
"func",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"func",
")",
":",
"apply_function_to_members",
"(",
"func",
",",
"json",
")",
"return",
"func",
"else",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"decorated... | Decorator to render as JSON
:param func:
:return: | [
"Decorator",
"to",
"render",
"as",
"JSON",
":",
"param",
"func",
":",
":",
"return",
":"
] | python | train |
google/mobly | mobly/controllers/android_device_lib/service_manager.py | https://github.com/google/mobly/blob/38ba2cf7d29a20e6a2fca1718eecb337df38db26/mobly/controllers/android_device_lib/service_manager.py#L105-L112 | def unregister_all(self):
"""Safely unregisters all active instances.
Errors occurred here will be recorded but not raised.
"""
aliases = list(self._service_objects.keys())
for alias in aliases:
self.unregister(alias) | [
"def",
"unregister_all",
"(",
"self",
")",
":",
"aliases",
"=",
"list",
"(",
"self",
".",
"_service_objects",
".",
"keys",
"(",
")",
")",
"for",
"alias",
"in",
"aliases",
":",
"self",
".",
"unregister",
"(",
"alias",
")"
] | Safely unregisters all active instances.
Errors occurred here will be recorded but not raised. | [
"Safely",
"unregisters",
"all",
"active",
"instances",
"."
] | python | train |
HazyResearch/metal | metal/contrib/info_extraction/utils.py | https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/contrib/info_extraction/utils.py#L1-L76 | def mark_entities(tokens, positions, markers=[], style="insert"):
"""Adds special markers around tokens at specific positions (e.g., entities)
Args:
tokens: A list of tokens (the sentence)
positions:
1) A list of inclusive ranges (tuples) corresponding to the
token range... | [
"def",
"mark_entities",
"(",
"tokens",
",",
"positions",
",",
"markers",
"=",
"[",
"]",
",",
"style",
"=",
"\"insert\"",
")",
":",
"if",
"markers",
"and",
"len",
"(",
"markers",
")",
"!=",
"2",
"*",
"len",
"(",
"positions",
")",
":",
"msg",
"=",
"(... | Adds special markers around tokens at specific positions (e.g., entities)
Args:
tokens: A list of tokens (the sentence)
positions:
1) A list of inclusive ranges (tuples) corresponding to the
token ranges of the entities in order. (Assumes each entity
has only one... | [
"Adds",
"special",
"markers",
"around",
"tokens",
"at",
"specific",
"positions",
"(",
"e",
".",
"g",
".",
"entities",
")"
] | python | train |
casastorta/python-sar | sar/parser.py | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/parser.py#L39-L62 | def load_file(self):
"""
Loads SAR format logfile in ASCII format (sarXX).
:return: ``True`` if loading and parsing of file went fine, \
``False`` if it failed (at any point)
"""
# We first split file into pieces
searchunks = self._split_file()
i... | [
"def",
"load_file",
"(",
"self",
")",
":",
"# We first split file into pieces",
"searchunks",
"=",
"self",
".",
"_split_file",
"(",
")",
"if",
"searchunks",
":",
"# And then we parse pieces into meaningful data",
"usage",
"=",
"self",
".",
"_parse_file",
"(",
"searchu... | Loads SAR format logfile in ASCII format (sarXX).
:return: ``True`` if loading and parsing of file went fine, \
``False`` if it failed (at any point) | [
"Loads",
"SAR",
"format",
"logfile",
"in",
"ASCII",
"format",
"(",
"sarXX",
")",
".",
":",
"return",
":",
"True",
"if",
"loading",
"and",
"parsing",
"of",
"file",
"went",
"fine",
"\\",
"False",
"if",
"it",
"failed",
"(",
"at",
"any",
"point",
")"
] | python | train |
openstack/horizon | openstack_auth/utils.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L182-L257 | def get_websso_url(request, auth_url, websso_auth):
"""Return the keystone endpoint for initiating WebSSO.
Generate the keystone WebSSO endpoint that will redirect the user
to the login page of the federated identity provider.
Based on the authentication type selected by the user in the login
form... | [
"def",
"get_websso_url",
"(",
"request",
",",
"auth_url",
",",
"websso_auth",
")",
":",
"origin",
"=",
"build_absolute_uri",
"(",
"request",
",",
"'/auth/websso/'",
")",
"idp_mapping",
"=",
"getattr",
"(",
"settings",
",",
"'WEBSSO_IDP_MAPPING'",
",",
"{",
"}",
... | Return the keystone endpoint for initiating WebSSO.
Generate the keystone WebSSO endpoint that will redirect the user
to the login page of the federated identity provider.
Based on the authentication type selected by the user in the login
form, it will construct the keystone WebSSO endpoint.
:par... | [
"Return",
"the",
"keystone",
"endpoint",
"for",
"initiating",
"WebSSO",
"."
] | python | train |
gem/oq-engine | openquake/hmtk/plotting/mapping.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/mapping.py#L177-L184 | def savemap(self, filename, filetype='png', papertype="a4"):
"""
Save the figure
"""
self.fig.savefig(filename,
dpi=self.dpi,
format=filetype,
papertype=papertype) | [
"def",
"savemap",
"(",
"self",
",",
"filename",
",",
"filetype",
"=",
"'png'",
",",
"papertype",
"=",
"\"a4\"",
")",
":",
"self",
".",
"fig",
".",
"savefig",
"(",
"filename",
",",
"dpi",
"=",
"self",
".",
"dpi",
",",
"format",
"=",
"filetype",
",",
... | Save the figure | [
"Save",
"the",
"figure"
] | python | train |
pypa/pipenv | pipenv/vendor/passa/internals/_pip.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/_pip.py#L113-L130 | def _convert_hashes(values):
"""Convert Pipfile.lock hash lines into InstallRequirement option format.
The option format uses a str-list mapping. Keys are hash algorithms, and
the list contains all values of that algorithm.
"""
hashes = {}
if not values:
return hashes
for value in v... | [
"def",
"_convert_hashes",
"(",
"values",
")",
":",
"hashes",
"=",
"{",
"}",
"if",
"not",
"values",
":",
"return",
"hashes",
"for",
"value",
"in",
"values",
":",
"try",
":",
"name",
",",
"value",
"=",
"value",
".",
"split",
"(",
"\":\"",
",",
"1",
"... | Convert Pipfile.lock hash lines into InstallRequirement option format.
The option format uses a str-list mapping. Keys are hash algorithms, and
the list contains all values of that algorithm. | [
"Convert",
"Pipfile",
".",
"lock",
"hash",
"lines",
"into",
"InstallRequirement",
"option",
"format",
"."
] | python | train |
nion-software/nionswift | nion/typeshed/API_1_0.py | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/typeshed/API_1_0.py#L1094-L1108 | def create_data_and_metadata(self, data: numpy.ndarray, intensity_calibration: Calibration.Calibration=None, dimensional_calibrations: typing.List[Calibration.Calibration]=None, metadata: dict=None, timestamp: str=None, data_descriptor: DataAndMetadata.DataDescriptor=None) -> DataAndMetadata.DataAndMetadata:
""... | [
"def",
"create_data_and_metadata",
"(",
"self",
",",
"data",
":",
"numpy",
".",
"ndarray",
",",
"intensity_calibration",
":",
"Calibration",
".",
"Calibration",
"=",
"None",
",",
"dimensional_calibrations",
":",
"typing",
".",
"List",
"[",
"Calibration",
".",
"C... | Create a data_and_metadata object from data.
:param data: an ndarray of data.
:param intensity_calibration: An optional calibration object.
:param dimensional_calibrations: An optional list of calibration objects.
:param metadata: A dict of metadata.
:param timestamp: A datetime... | [
"Create",
"a",
"data_and_metadata",
"object",
"from",
"data",
"."
] | python | train |
saltstack/salt | salt/modules/glassfish.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glassfish.py#L361-L386 | def create_connector_resource(name, server=None, **kwargs):
'''
Create a connection resource
'''
defaults = {
'description': '',
'enabled': True,
'id': name,
'poolName': '',
'objectType': 'user',
'target': 'server'
}
# Data = defaults + merge kwar... | [
"def",
"create_connector_resource",
"(",
"name",
",",
"server",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"'description'",
":",
"''",
",",
"'enabled'",
":",
"True",
",",
"'id'",
":",
"name",
",",
"'poolName'",
":",
"''",
","... | Create a connection resource | [
"Create",
"a",
"connection",
"resource"
] | python | train |
jjgomera/iapws | iapws/humidAir.py | https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/humidAir.py#L729-L761 | def _eq(self, T, P):
"""Procedure for calculate the composition in saturation state
Parameters
----------
T : float
Temperature [K]
P : float
Pressure [MPa]
Returns
-------
Asat : float
Saturation mass fraction of dry ... | [
"def",
"_eq",
"(",
"self",
",",
"T",
",",
"P",
")",
":",
"if",
"T",
"<=",
"273.16",
":",
"ice",
"=",
"_Ice",
"(",
"T",
",",
"P",
")",
"gw",
"=",
"ice",
"[",
"\"g\"",
"]",
"else",
":",
"water",
"=",
"IAPWS95",
"(",
"T",
"=",
"T",
",",
"P",... | Procedure for calculate the composition in saturation state
Parameters
----------
T : float
Temperature [K]
P : float
Pressure [MPa]
Returns
-------
Asat : float
Saturation mass fraction of dry air in humid air [kg/kg] | [
"Procedure",
"for",
"calculate",
"the",
"composition",
"in",
"saturation",
"state"
] | python | train |
toomore/goristock | grs/all_portf.py | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L110-L112 | def B4PB(self):
''' 判斷是否為四大買點 '''
return self.ckMinsGLI and (self.B1 or self.B2 or self.B3 or self.B4) | [
"def",
"B4PB",
"(",
"self",
")",
":",
"return",
"self",
".",
"ckMinsGLI",
"and",
"(",
"self",
".",
"B1",
"or",
"self",
".",
"B2",
"or",
"self",
".",
"B3",
"or",
"self",
".",
"B4",
")"
] | 判斷是否為四大買點 | [
"判斷是否為四大買點"
] | python | train |
diux-dev/ncluster | ncluster/aws_util.py | https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L415-L420 | def validate_aws_name(name):
"""Validate resource name using AWS name restrictions from # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions"""
assert len(name) <= 127
# disallow unicode characters to avoid pain
assert name == name.encode('ascii').decode('ascii')
assert aws_na... | [
"def",
"validate_aws_name",
"(",
"name",
")",
":",
"assert",
"len",
"(",
"name",
")",
"<=",
"127",
"# disallow unicode characters to avoid pain",
"assert",
"name",
"==",
"name",
".",
"encode",
"(",
"'ascii'",
")",
".",
"decode",
"(",
"'ascii'",
")",
"assert",
... | Validate resource name using AWS name restrictions from # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions | [
"Validate",
"resource",
"name",
"using",
"AWS",
"name",
"restrictions",
"from",
"#",
"http",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"AWSEC2",
"/",
"latest",
"/",
"UserGuide",
"/",
"Using_Tags",
".",
"html#tag",
"-",
"restrictions"
] | python | train |
ray-project/ray | python/ray/actor.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L869-L884 | def get_checkpoints_for_actor(actor_id):
"""Get the available checkpoints for the given actor ID, return a list
sorted by checkpoint timestamp in descending order.
"""
checkpoint_info = ray.worker.global_state.actor_checkpoint_info(actor_id)
if checkpoint_info is None:
return []
checkpoi... | [
"def",
"get_checkpoints_for_actor",
"(",
"actor_id",
")",
":",
"checkpoint_info",
"=",
"ray",
".",
"worker",
".",
"global_state",
".",
"actor_checkpoint_info",
"(",
"actor_id",
")",
"if",
"checkpoint_info",
"is",
"None",
":",
"return",
"[",
"]",
"checkpoints",
"... | Get the available checkpoints for the given actor ID, return a list
sorted by checkpoint timestamp in descending order. | [
"Get",
"the",
"available",
"checkpoints",
"for",
"the",
"given",
"actor",
"ID",
"return",
"a",
"list",
"sorted",
"by",
"checkpoint",
"timestamp",
"in",
"descending",
"order",
"."
] | python | train |
spyder-ide/spyder | spyder/plugins/console/widgets/shell.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/widgets/shell.py#L768-L777 | def _key_question(self, text):
"""Action for '?'"""
if self.get_current_line_to_cursor():
last_obj = self.get_last_obj()
if last_obj and not last_obj.isdigit():
self.show_object_info(last_obj)
self.insert_text(text)
# In case calltip and com... | [
"def",
"_key_question",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"get_current_line_to_cursor",
"(",
")",
":",
"last_obj",
"=",
"self",
".",
"get_last_obj",
"(",
")",
"if",
"last_obj",
"and",
"not",
"last_obj",
".",
"isdigit",
"(",
")",
":",... | Action for '? | [
"Action",
"for",
"?"
] | python | train |
davidmogar/cucco | cucco/batch.py | https://github.com/davidmogar/cucco/blob/e2a0ff3342e4a9f25a65c486206a5a2ae1a4dbd4/cucco/batch.py#L200-L208 | def on_modified(self, event):
"""Function called everytime a new file is modified.
Args:
event: Event to process.
"""
self._logger.debug('Detected modify event on watched path: %s', event.src_path)
self._process_event(event) | [
"def",
"on_modified",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Detected modify event on watched path: %s'",
",",
"event",
".",
"src_path",
")",
"self",
".",
"_process_event",
"(",
"event",
")"
] | Function called everytime a new file is modified.
Args:
event: Event to process. | [
"Function",
"called",
"everytime",
"a",
"new",
"file",
"is",
"modified",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/provenance/system.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L77-L99 | def _torque_info(queue):
"""Return machine information for a torque job scheduler using pbsnodes.
To identify which host to use it tries to parse available hosts
from qstat -Qf `acl_hosts`. If found, it uses these and gets the
first node from pbsnodes matching to the list. If no attached
hosts are ... | [
"def",
"_torque_info",
"(",
"queue",
")",
":",
"nodes",
"=",
"_torque_queue_nodes",
"(",
"queue",
")",
"pbs_out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"pbsnodes\"",
"]",
")",
".",
"decode",
"(",
")",
"info",
"=",
"{",
"}",
"for",
"i",
",... | Return machine information for a torque job scheduler using pbsnodes.
To identify which host to use it tries to parse available hosts
from qstat -Qf `acl_hosts`. If found, it uses these and gets the
first node from pbsnodes matching to the list. If no attached
hosts are available, it uses the first hos... | [
"Return",
"machine",
"information",
"for",
"a",
"torque",
"job",
"scheduler",
"using",
"pbsnodes",
"."
] | python | train |
clalancette/pycdlib | pycdlib/udf.py | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2383-L2412 | def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Integrity Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Int... | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Integrity Descriptor already initialized'",
")",
"self",
".",
"desc_tag",
"=",
"UDFTag"... | A method to create a new UDF Logical Volume Integrity Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Integrity",
"Descriptor",
"."
] | python | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L137-L173 | def parse(self, limit=None):
"""
:param limit:
:return:
"""
if limit is not None:
LOG.info("Only parsing first %s rows fo each file", str(limit))
LOG.info("Parsing files...")
if self.test_only:
self.test_mode = True
self._proces... | [
"def",
"parse",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"not",
"None",
":",
"LOG",
".",
"info",
"(",
"\"Only parsing first %s rows fo each file\"",
",",
"str",
"(",
"limit",
")",
")",
"LOG",
".",
"info",
"(",
"\"Parsing fil... | :param limit:
:return: | [
":",
"param",
"limit",
":",
":",
"return",
":"
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/rbridge_id/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/__init__.py#L236-L257 | def _set_network(self, v, load=False):
"""
Setter method for network, mapped from YANG variable /rbridge_id/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/network (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_network is considered as a private
... | [
"def",
"_set_network",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",... | Setter method for network, mapped from YANG variable /rbridge_id/router/router_bgp/address_family/ipv4/ipv4_unicast/default_vrf/network (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_network is considered as a private
method. Backends looking to populate this variabl... | [
"Setter",
"method",
"for",
"network",
"mapped",
"from",
"YANG",
"variable",
"/",
"rbridge_id",
"/",
"router",
"/",
"router_bgp",
"/",
"address_family",
"/",
"ipv4",
"/",
"ipv4_unicast",
"/",
"default_vrf",
"/",
"network",
"(",
"list",
")",
"If",
"this",
"var... | python | train |
F5Networks/f5-common-python | f5/multi_device/device_group.py | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/device_group.py#L104-L116 | def _set_attributes(self, **kwargs):
'''Set instance attributes based on kwargs
:param kwargs: dict -- kwargs to set as attributes
'''
try:
self.devices = kwargs['devices'][:]
self.name = kwargs['device_group_name']
self.type = kwargs['device_group_t... | [
"def",
"_set_attributes",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"devices",
"=",
"kwargs",
"[",
"'devices'",
"]",
"[",
":",
"]",
"self",
".",
"name",
"=",
"kwargs",
"[",
"'device_group_name'",
"]",
"self",
".",
"type... | Set instance attributes based on kwargs
:param kwargs: dict -- kwargs to set as attributes | [
"Set",
"instance",
"attributes",
"based",
"on",
"kwargs"
] | python | train |
sendgrid/sendgrid-python | sendgrid/helpers/mail/mail.py | https://github.com/sendgrid/sendgrid-python/blob/266c2abde7a35dfcce263e06bedc6a0bbdebeac9/sendgrid/helpers/mail/mail.py#L714-L733 | def add_content(self, content, mime_type=None):
"""Add content to the email
:param contents: Content to be added to the email
:type contents: Content
:param mime_type: Override the mime type
:type mime_type: MimeType, str
"""
if isinstance(content, str):
... | [
"def",
"add_content",
"(",
"self",
",",
"content",
",",
"mime_type",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"content",
",",
"str",
")",
":",
"content",
"=",
"Content",
"(",
"mime_type",
",",
"content",
")",
"# Content of mime type text/plain must alwa... | Add content to the email
:param contents: Content to be added to the email
:type contents: Content
:param mime_type: Override the mime type
:type mime_type: MimeType, str | [
"Add",
"content",
"to",
"the",
"email"
] | python | train |
apache/incubator-mxnet | python/mxnet/ndarray/ndarray.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2050-L2094 | def copyto(self, other):
"""Copies the value of this array to another array.
If ``other`` is a ``NDArray`` object, then ``other.shape`` and
``self.shape`` should be the same. This function copies the value from
``self`` to ``other``.
If ``other`` is a context, a new ``NDArray``... | [
"def",
"copyto",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"NDArray",
")",
":",
"if",
"other",
".",
"handle",
"is",
"self",
".",
"handle",
":",
"warnings",
".",
"warn",
"(",
"'You are attempting to copy an array to itself'",... | Copies the value of this array to another array.
If ``other`` is a ``NDArray`` object, then ``other.shape`` and
``self.shape`` should be the same. This function copies the value from
``self`` to ``other``.
If ``other`` is a context, a new ``NDArray`` will be first created on
th... | [
"Copies",
"the",
"value",
"of",
"this",
"array",
"to",
"another",
"array",
"."
] | python | train |
pyviz/holoviews | holoviews/core/io.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/io.py#L124-L129 | def _filename(self_or_cls, filename):
"Add the file extension if not already present"
if not filename.endswith(self_or_cls.file_ext):
return '%s.%s' % (filename, self_or_cls.file_ext)
else:
return filename | [
"def",
"_filename",
"(",
"self_or_cls",
",",
"filename",
")",
":",
"if",
"not",
"filename",
".",
"endswith",
"(",
"self_or_cls",
".",
"file_ext",
")",
":",
"return",
"'%s.%s'",
"%",
"(",
"filename",
",",
"self_or_cls",
".",
"file_ext",
")",
"else",
":",
... | Add the file extension if not already present | [
"Add",
"the",
"file",
"extension",
"if",
"not",
"already",
"present"
] | python | train |
StagPython/StagPy | stagpy/stagyyparsers.py | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/stagyyparsers.py#L576-L582 | def _get_field(xdmf_file, data_item):
"""Extract field from data item."""
shp = _get_dim(data_item)
h5file, group = data_item.text.strip().split(':/', 1)
icore = int(group.split('_')[-2]) - 1
fld = _read_group_h5(xdmf_file.parent / h5file, group).reshape(shp)
return icore, fld | [
"def",
"_get_field",
"(",
"xdmf_file",
",",
"data_item",
")",
":",
"shp",
"=",
"_get_dim",
"(",
"data_item",
")",
"h5file",
",",
"group",
"=",
"data_item",
".",
"text",
".",
"strip",
"(",
")",
".",
"split",
"(",
"':/'",
",",
"1",
")",
"icore",
"=",
... | Extract field from data item. | [
"Extract",
"field",
"from",
"data",
"item",
"."
] | python | train |
casacore/python-casacore | casacore/images/image.py | https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/images/image.py#L237-L239 | def attrget(self, groupname, attrname, rownr):
"""Get the value of an attribute in the given row in a group."""
return self._attrget(groupname, attrname, rownr) | [
"def",
"attrget",
"(",
"self",
",",
"groupname",
",",
"attrname",
",",
"rownr",
")",
":",
"return",
"self",
".",
"_attrget",
"(",
"groupname",
",",
"attrname",
",",
"rownr",
")"
] | Get the value of an attribute in the given row in a group. | [
"Get",
"the",
"value",
"of",
"an",
"attribute",
"in",
"the",
"given",
"row",
"in",
"a",
"group",
"."
] | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/breakpoint.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/breakpoint.py#L3908-L3936 | def break_at(self, pid, address, action = None):
"""
Sets a code breakpoint at the given process and address.
If instead of an address you pass a label, the breakpoint may be
deferred until the DLL it points to is loaded.
@see: L{stalk_at}, L{dont_break_at}
@type pid:... | [
"def",
"break_at",
"(",
"self",
",",
"pid",
",",
"address",
",",
"action",
"=",
"None",
")",
":",
"bp",
"=",
"self",
".",
"__set_break",
"(",
"pid",
",",
"address",
",",
"action",
",",
"oneshot",
"=",
"False",
")",
"return",
"bp",
"is",
"not",
"Non... | Sets a code breakpoint at the given process and address.
If instead of an address you pass a label, the breakpoint may be
deferred until the DLL it points to is loaded.
@see: L{stalk_at}, L{dont_break_at}
@type pid: int
@param pid: Process global ID.
@type address: ... | [
"Sets",
"a",
"code",
"breakpoint",
"at",
"the",
"given",
"process",
"and",
"address",
"."
] | python | train |
mpg-age-bioinformatics/AGEpy | AGEpy/rbiom.py | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/rbiom.py#L16-L26 | def RdatabasesBM(host=rbiomart_host):
"""
Lists BioMart databases through a RPY2 connection.
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing
"""
biomaRt = importr("biomaRt")
print(biomaRt.listMarts(host=host)) | [
"def",
"RdatabasesBM",
"(",
"host",
"=",
"rbiomart_host",
")",
":",
"biomaRt",
"=",
"importr",
"(",
"\"biomaRt\"",
")",
"print",
"(",
"biomaRt",
".",
"listMarts",
"(",
"host",
"=",
"host",
")",
")"
] | Lists BioMart databases through a RPY2 connection.
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing | [
"Lists",
"BioMart",
"databases",
"through",
"a",
"RPY2",
"connection",
"."
] | python | train |
Netuitive/netuitive-client-python | netuitive/client.py | https://github.com/Netuitive/netuitive-client-python/blob/16426ade6a5dc0888ce978c97b02663a9713fc16/netuitive/client.py#L159-L195 | def post_check(self, check):
"""
:param check: Check to post to Metricly
:type check: object
"""
if self.disabled is True:
logging.error('Posting has been disabled. '
'See previous errors for details.')
return(False)
... | [
"def",
"post_check",
"(",
"self",
",",
"check",
")",
":",
"if",
"self",
".",
"disabled",
"is",
"True",
":",
"logging",
".",
"error",
"(",
"'Posting has been disabled. '",
"'See previous errors for details.'",
")",
"return",
"(",
"False",
")",
"url",
"=",
"self... | :param check: Check to post to Metricly
:type check: object | [
":",
"param",
"check",
":",
"Check",
"to",
"post",
"to",
"Metricly",
":",
"type",
"check",
":",
"object"
] | python | train |
gvanderheide/discreteMarkovChain | discreteMarkovChain/markovChain.py | https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L341-L349 | def convertToRateMatrix(self, Q):
"""
Converts the initial matrix to a rate matrix.
We make all rows in Q sum to zero by subtracting the row sums from the diagonal.
"""
rowSums = Q.sum(axis=1).getA1()
idxRange = np.arange(Q.shape[0])
Qdiag ... | [
"def",
"convertToRateMatrix",
"(",
"self",
",",
"Q",
")",
":",
"rowSums",
"=",
"Q",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
".",
"getA1",
"(",
")",
"idxRange",
"=",
"np",
".",
"arange",
"(",
"Q",
".",
"shape",
"[",
"0",
"]",
")",
"Qdiag",
"=",
... | Converts the initial matrix to a rate matrix.
We make all rows in Q sum to zero by subtracting the row sums from the diagonal. | [
"Converts",
"the",
"initial",
"matrix",
"to",
"a",
"rate",
"matrix",
".",
"We",
"make",
"all",
"rows",
"in",
"Q",
"sum",
"to",
"zero",
"by",
"subtracting",
"the",
"row",
"sums",
"from",
"the",
"diagonal",
"."
] | python | train |
ianmiell/shutit | shutit_class.py | https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L4646-L4658 | def is_ready(self, shutit_module_obj):
"""Returns true if this module is ready to be built.
Caches the result (as it's assumed not to change during the build).
"""
shutit_global.shutit_global_object.yield_to_draw()
if shutit_module_obj.module_id in self.get_current_shutit_pexpect_session_environment().modules... | [
"def",
"is_ready",
"(",
"self",
",",
"shutit_module_obj",
")",
":",
"shutit_global",
".",
"shutit_global_object",
".",
"yield_to_draw",
"(",
")",
"if",
"shutit_module_obj",
".",
"module_id",
"in",
"self",
".",
"get_current_shutit_pexpect_session_environment",
"(",
")"... | Returns true if this module is ready to be built.
Caches the result (as it's assumed not to change during the build). | [
"Returns",
"true",
"if",
"this",
"module",
"is",
"ready",
"to",
"be",
"built",
".",
"Caches",
"the",
"result",
"(",
"as",
"it",
"s",
"assumed",
"not",
"to",
"change",
"during",
"the",
"build",
")",
"."
] | python | train |
myint/rstcheck | rstcheck.py | https://github.com/myint/rstcheck/blob/2f975906b75f3b88d501ef3b13d213815cf7079a/rstcheck.py#L736-L741 | def visit_paragraph(self, node):
"""Check syntax of reStructuredText."""
find = re.search(r'\[[^\]]+\]\([^\)]+\)', node.rawsource)
if find is not None:
self.document.reporter.warning(
'(rst) Link is formatted in Markdown style.', base_node=node) | [
"def",
"visit_paragraph",
"(",
"self",
",",
"node",
")",
":",
"find",
"=",
"re",
".",
"search",
"(",
"r'\\[[^\\]]+\\]\\([^\\)]+\\)'",
",",
"node",
".",
"rawsource",
")",
"if",
"find",
"is",
"not",
"None",
":",
"self",
".",
"document",
".",
"reporter",
".... | Check syntax of reStructuredText. | [
"Check",
"syntax",
"of",
"reStructuredText",
"."
] | python | train |
Yubico/python-pyhsm | pyhsm/util.py | https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/util.py#L38-L55 | def key_handle_to_int(this):
"""
Turn "123" into 123 and "KSM1" into 827151179
(0x314d534b, 'K' = 0x4b, S = '0x53', M = 0x4d).
YHSM is little endian, so this makes the bytes KSM1 appear
in the most human readable form in packet traces.
"""
try:
num = int(this)
return num
... | [
"def",
"key_handle_to_int",
"(",
"this",
")",
":",
"try",
":",
"num",
"=",
"int",
"(",
"this",
")",
"return",
"num",
"except",
"ValueError",
":",
"if",
"this",
"[",
":",
"2",
"]",
"==",
"\"0x\"",
":",
"return",
"int",
"(",
"this",
",",
"16",
")",
... | Turn "123" into 123 and "KSM1" into 827151179
(0x314d534b, 'K' = 0x4b, S = '0x53', M = 0x4d).
YHSM is little endian, so this makes the bytes KSM1 appear
in the most human readable form in packet traces. | [
"Turn",
"123",
"into",
"123",
"and",
"KSM1",
"into",
"827151179",
"(",
"0x314d534b",
"K",
"=",
"0x4b",
"S",
"=",
"0x53",
"M",
"=",
"0x4d",
")",
"."
] | python | train |
sony/nnabla | python/src/nnabla/utils/image_utils/pil_utils.py | https://github.com/sony/nnabla/blob/aaf3d33b7cbb38f2a03aa754178ba8f7c8481320/python/src/nnabla/utils/image_utils/pil_utils.py#L74-L115 | def imread(path, grayscale=False, size=None, interpolate="bilinear",
channel_first=False, as_uint16=False, num_channels=-1):
"""
Read image by PIL module.
Notice that PIL only supports uint8 for RGB (not uint16).
So this imread function returns only uint8 array for both RGB and gray-scale.
... | [
"def",
"imread",
"(",
"path",
",",
"grayscale",
"=",
"False",
",",
"size",
"=",
"None",
",",
"interpolate",
"=",
"\"bilinear\"",
",",
"channel_first",
"=",
"False",
",",
"as_uint16",
"=",
"False",
",",
"num_channels",
"=",
"-",
"1",
")",
":",
"if",
"as... | Read image by PIL module.
Notice that PIL only supports uint8 for RGB (not uint16).
So this imread function returns only uint8 array for both RGB and gray-scale.
(Currently ignore "I" mode for gray-scale (32bit integer).)
Args:
path (str or 'file object'): File path or object to read.
g... | [
"Read",
"image",
"by",
"PIL",
"module",
".",
"Notice",
"that",
"PIL",
"only",
"supports",
"uint8",
"for",
"RGB",
"(",
"not",
"uint16",
")",
".",
"So",
"this",
"imread",
"function",
"returns",
"only",
"uint8",
"array",
"for",
"both",
"RGB",
"and",
"gray",... | python | train |
PredixDev/predixpy | predix/security/uaa.py | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L226-L239 | def logout(self):
"""
Log currently authenticated user out, invalidating any existing tokens.
"""
# Remove token from local cache
# MAINT: need to expire token on server
data = self._read_uaa_cache()
if self.uri in data:
for client in data[self.uri]:
... | [
"def",
"logout",
"(",
"self",
")",
":",
"# Remove token from local cache",
"# MAINT: need to expire token on server",
"data",
"=",
"self",
".",
"_read_uaa_cache",
"(",
")",
"if",
"self",
".",
"uri",
"in",
"data",
":",
"for",
"client",
"in",
"data",
"[",
"self",
... | Log currently authenticated user out, invalidating any existing tokens. | [
"Log",
"currently",
"authenticated",
"user",
"out",
"invalidating",
"any",
"existing",
"tokens",
"."
] | python | train |
limix/glimix-core | glimix_core/lmm/_lmm.py | https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/lmm/_lmm.py#L530-L547 | def _lml_arbitrary_scale(self):
"""
Log of the marginal likelihood for arbitrary scale.
Returns
-------
lml : float
Log of the marginal likelihood.
"""
s = self.scale
D = self._D
n = len(self._y)
lml = -self._df * log2pi - n * ... | [
"def",
"_lml_arbitrary_scale",
"(",
"self",
")",
":",
"s",
"=",
"self",
".",
"scale",
"D",
"=",
"self",
".",
"_D",
"n",
"=",
"len",
"(",
"self",
".",
"_y",
")",
"lml",
"=",
"-",
"self",
".",
"_df",
"*",
"log2pi",
"-",
"n",
"*",
"log",
"(",
"s... | Log of the marginal likelihood for arbitrary scale.
Returns
-------
lml : float
Log of the marginal likelihood. | [
"Log",
"of",
"the",
"marginal",
"likelihood",
"for",
"arbitrary",
"scale",
"."
] | python | valid |
J535D165/recordlinkage | recordlinkage/algorithms/nb_sklearn.py | https://github.com/J535D165/recordlinkage/blob/87a5f4af904e0834047cd07ff1c70146b1e6d693/recordlinkage/algorithms/nb_sklearn.py#L458-L490 | def _init_parameters_random(self, X_bin):
"""Initialise parameters for unsupervised learning.
"""
_, n_features = X_bin.shape
# The parameter class_log_prior_ has shape (2,). The values represent
# 'match' and 'non-match'.
rand_vals = np.random.rand(2)
class_pr... | [
"def",
"_init_parameters_random",
"(",
"self",
",",
"X_bin",
")",
":",
"_",
",",
"n_features",
"=",
"X_bin",
".",
"shape",
"# The parameter class_log_prior_ has shape (2,). The values represent",
"# 'match' and 'non-match'.",
"rand_vals",
"=",
"np",
".",
"random",
".",
... | Initialise parameters for unsupervised learning. | [
"Initialise",
"parameters",
"for",
"unsupervised",
"learning",
"."
] | python | train |
blink1073/oct2py | oct2py/core.py | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L505-L521 | def restart(self):
"""Restart an Octave session in a clean state
"""
if self._engine:
self._engine.repl.terminate()
executable = self._executable
if executable:
os.environ['OCTAVE_EXECUTABLE'] = executable
if 'OCTAVE_EXECUTABLE' not in os... | [
"def",
"restart",
"(",
"self",
")",
":",
"if",
"self",
".",
"_engine",
":",
"self",
".",
"_engine",
".",
"repl",
".",
"terminate",
"(",
")",
"executable",
"=",
"self",
".",
"_executable",
"if",
"executable",
":",
"os",
".",
"environ",
"[",
"'OCTAVE_EXE... | Restart an Octave session in a clean state | [
"Restart",
"an",
"Octave",
"session",
"in",
"a",
"clean",
"state"
] | python | valid |
TheHive-Project/Cortex-Analyzers | analyzers/BackscatterIO/backscatter-io.py | https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/BackscatterIO/backscatter-io.py#L52-L97 | def summary(self, raw):
"""Use the Backscatter.io summary data to create a view."""
taxonomies = list()
level = 'info'
namespace = 'Backscatter.io'
if self.service == 'observations':
summary = raw.get('results', dict()).get('summary', dict())
taxonomies =... | [
"def",
"summary",
"(",
"self",
",",
"raw",
")",
":",
"taxonomies",
"=",
"list",
"(",
")",
"level",
"=",
"'info'",
"namespace",
"=",
"'Backscatter.io'",
"if",
"self",
".",
"service",
"==",
"'observations'",
":",
"summary",
"=",
"raw",
".",
"get",
"(",
"... | Use the Backscatter.io summary data to create a view. | [
"Use",
"the",
"Backscatter",
".",
"io",
"summary",
"data",
"to",
"create",
"a",
"view",
"."
] | python | train |
hyperledger/sawtooth-core | cli/sawtooth_cli/format_utils.py | https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/format_utils.py#L62-L88 | def print_terminal_table(headers, data_list, parse_row_fn):
"""Uses a set of headers, raw data, and a row parsing function, to print
data to the terminal in a table of rows and columns.
Args:
headers (tuple of strings): The headers for each column of data
data_list (list of dicts): Raw resp... | [
"def",
"print_terminal_table",
"(",
"headers",
",",
"data_list",
",",
"parse_row_fn",
")",
":",
"data_iter",
"=",
"iter",
"(",
"data_list",
")",
"try",
":",
"example",
"=",
"next",
"(",
"data_iter",
")",
"example_row",
"=",
"parse_row_fn",
"(",
"example",
")... | Uses a set of headers, raw data, and a row parsing function, to print
data to the terminal in a table of rows and columns.
Args:
headers (tuple of strings): The headers for each column of data
data_list (list of dicts): Raw response data from the validator
parse_row_fn (function): Parse... | [
"Uses",
"a",
"set",
"of",
"headers",
"raw",
"data",
"and",
"a",
"row",
"parsing",
"function",
"to",
"print",
"data",
"to",
"the",
"terminal",
"in",
"a",
"table",
"of",
"rows",
"and",
"columns",
"."
] | python | train |
bitcraze/crazyflie-lib-python | cflib/crazyflie/high_level_commander.py | https://github.com/bitcraze/crazyflie-lib-python/blob/f6ebb4eb315bbe6e02db518936ac17fb615b2af8/cflib/crazyflie/high_level_commander.py#L88-L101 | def land(self, absolute_height_m, duration_s, group_mask=ALL_GROUPS):
"""
vertical land from current x-y position to given height
:param absolute_height_m: absolut (m)
:param duration_s: time it should take until target height is
reached (s)
:param gro... | [
"def",
"land",
"(",
"self",
",",
"absolute_height_m",
",",
"duration_s",
",",
"group_mask",
"=",
"ALL_GROUPS",
")",
":",
"self",
".",
"_send_packet",
"(",
"struct",
".",
"pack",
"(",
"'<BBff'",
",",
"self",
".",
"COMMAND_LAND",
",",
"group_mask",
",",
"abs... | vertical land from current x-y position to given height
:param absolute_height_m: absolut (m)
:param duration_s: time it should take until target height is
reached (s)
:param group_mask: mask for which CFs this should apply to | [
"vertical",
"land",
"from",
"current",
"x",
"-",
"y",
"position",
"to",
"given",
"height"
] | python | train |
ynop/audiomate | audiomate/corpus/subset/utils.py | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/subset/utils.py#L75-L173 | def get_identifiers_splitted_by_weights(identifiers={}, proportions={}):
"""
Divide the given identifiers based on the given proportions. But instead of randomly split
the identifiers it is based on category weights. Every identifier has a weight for any
number of categories. The target is, to split the... | [
"def",
"get_identifiers_splitted_by_weights",
"(",
"identifiers",
"=",
"{",
"}",
",",
"proportions",
"=",
"{",
"}",
")",
":",
"# Get total weight per category",
"sum_per_category",
"=",
"collections",
".",
"defaultdict",
"(",
"int",
")",
"for",
"identifier",
",",
... | Divide the given identifiers based on the given proportions. But instead of randomly split
the identifiers it is based on category weights. Every identifier has a weight for any
number of categories. The target is, to split the identifiers in a way, so the sum of
category k within part x is proportional to ... | [
"Divide",
"the",
"given",
"identifiers",
"based",
"on",
"the",
"given",
"proportions",
".",
"But",
"instead",
"of",
"randomly",
"split",
"the",
"identifiers",
"it",
"is",
"based",
"on",
"category",
"weights",
".",
"Every",
"identifier",
"has",
"a",
"weight",
... | python | train |
Tanganelli/CoAPthon3 | coapthon/messages/message.py | https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/messages/message.py#L149-L159 | def options(self, value):
"""
Set the options of the CoAP message.
:type value: list
:param value: list of options
"""
if value is None:
value = []
assert isinstance(value, list)
self._options = value | [
"def",
"options",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"[",
"]",
"assert",
"isinstance",
"(",
"value",
",",
"list",
")",
"self",
".",
"_options",
"=",
"value"
] | Set the options of the CoAP message.
:type value: list
:param value: list of options | [
"Set",
"the",
"options",
"of",
"the",
"CoAP",
"message",
"."
] | python | train |
totalgood/twip | docs/notebooks/shakescorpus.py | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/docs/notebooks/shakescorpus.py#L52-L62 | def generate_lines(input_file,
start=0,
stop=float('inf')):
"""Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time"""
with gzip.GzipFile(input_file, 'rU') as f:
for i, line in enumerate(f):
if i < start:
continue
... | [
"def",
"generate_lines",
"(",
"input_file",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"float",
"(",
"'inf'",
")",
")",
":",
"with",
"gzip",
".",
"GzipFile",
"(",
"input_file",
",",
"'rU'",
")",
"as",
"f",
":",
"for",
"i",
",",
"line",
"in",
"enumer... | Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time | [
"Generate",
"(",
"yield",
")",
"lines",
"in",
"a",
"gzipped",
"file",
"(",
"*",
".",
"txt",
".",
"gz",
")",
"one",
"line",
"at",
"a",
"time"
] | python | train |
wuher/devil | devil/docs/resource.py | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/docs/resource.py#L97-L104 | def _get_method_doc(self):
""" Return method documentations. """
ret = {}
for method_name in self.methods:
method = getattr(self, method_name, None)
if method:
ret[method_name] = method.__doc__
return ret | [
"def",
"_get_method_doc",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"method_name",
"in",
"self",
".",
"methods",
":",
"method",
"=",
"getattr",
"(",
"self",
",",
"method_name",
",",
"None",
")",
"if",
"method",
":",
"ret",
"[",
"method_name",... | Return method documentations. | [
"Return",
"method",
"documentations",
"."
] | python | train |
brunato/lograptor | lograptor/timedate.py | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/timedate.py#L181-L203 | def strftimegen(start_dt, end_dt):
"""
Return a generator function for datetime format strings.
The generator produce a day-by-day sequence starting from the first datetime
to the second datetime argument.
"""
if start_dt > end_dt:
raise ValueError("the start datetime is after the end da... | [
"def",
"strftimegen",
"(",
"start_dt",
",",
"end_dt",
")",
":",
"if",
"start_dt",
">",
"end_dt",
":",
"raise",
"ValueError",
"(",
"\"the start datetime is after the end datetime: (%r,%r)\"",
"%",
"(",
"start_dt",
",",
"end_dt",
")",
")",
"def",
"iterftime",
"(",
... | Return a generator function for datetime format strings.
The generator produce a day-by-day sequence starting from the first datetime
to the second datetime argument. | [
"Return",
"a",
"generator",
"function",
"for",
"datetime",
"format",
"strings",
".",
"The",
"generator",
"produce",
"a",
"day",
"-",
"by",
"-",
"day",
"sequence",
"starting",
"from",
"the",
"first",
"datetime",
"to",
"the",
"second",
"datetime",
"argument",
... | python | train |
librosa/librosa | librosa/util/utils.py | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/util/utils.py#L209-L233 | def valid_intervals(intervals):
'''Ensure that an array is a valid representation of time intervals:
- intervals.ndim == 2
- intervals.shape[1] == 2
- intervals[i, 0] <= intervals[i, 1] for all i
Parameters
----------
intervals : np.ndarray [shape=(n, 2)]
set of time in... | [
"def",
"valid_intervals",
"(",
"intervals",
")",
":",
"if",
"intervals",
".",
"ndim",
"!=",
"2",
"or",
"intervals",
".",
"shape",
"[",
"-",
"1",
"]",
"!=",
"2",
":",
"raise",
"ParameterError",
"(",
"'intervals must have shape (n, 2)'",
")",
"if",
"np",
"."... | Ensure that an array is a valid representation of time intervals:
- intervals.ndim == 2
- intervals.shape[1] == 2
- intervals[i, 0] <= intervals[i, 1] for all i
Parameters
----------
intervals : np.ndarray [shape=(n, 2)]
set of time intervals
Returns
-------
va... | [
"Ensure",
"that",
"an",
"array",
"is",
"a",
"valid",
"representation",
"of",
"time",
"intervals",
":"
] | python | test |
chriskiehl/Gooey | gooey/python_bindings/gooey_decorator.py | https://github.com/chriskiehl/Gooey/blob/e598573c6519b953e0ccfc1f3663f827f8cd7e22/gooey/python_bindings/gooey_decorator.py#L22-L99 | def Gooey(f=None,
advanced=True,
language='english',
auto_start=False, # TODO: add this to the docs. Used to be `show_config=True`
target=None,
program_name=None,
program_description=None,
default_size=(610, 530),
use_legacy_titles... | [
"def",
"Gooey",
"(",
"f",
"=",
"None",
",",
"advanced",
"=",
"True",
",",
"language",
"=",
"'english'",
",",
"auto_start",
"=",
"False",
",",
"# TODO: add this to the docs. Used to be `show_config=True`\r",
"target",
"=",
"None",
",",
"program_name",
"=",
"None",
... | Decorator for client code's main function.
Serializes argparse data to JSON for use with the Gooey front end | [
"Decorator",
"for",
"client",
"code",
"s",
"main",
"function",
".",
"Serializes",
"argparse",
"data",
"to",
"JSON",
"for",
"use",
"with",
"the",
"Gooey",
"front",
"end"
] | python | train |
ethereum/eth-abi | eth_abi/codec.py | https://github.com/ethereum/eth-abi/blob/0a5cab0bdeae30b77efa667379427581784f1707/eth_abi/codec.py#L155-L179 | def decode_abi(self, types: Iterable[TypeStr], data: Decodable) -> Tuple[Any, ...]:
"""
Decodes the binary value ``data`` as a sequence of values of the ABI types
in ``types`` via the head-tail mechanism into a tuple of equivalent python
values.
:param types: An iterable of stri... | [
"def",
"decode_abi",
"(",
"self",
",",
"types",
":",
"Iterable",
"[",
"TypeStr",
"]",
",",
"data",
":",
"Decodable",
")",
"->",
"Tuple",
"[",
"Any",
",",
"...",
"]",
":",
"if",
"not",
"is_bytes",
"(",
"data",
")",
":",
"raise",
"TypeError",
"(",
"\... | Decodes the binary value ``data`` as a sequence of values of the ABI types
in ``types`` via the head-tail mechanism into a tuple of equivalent python
values.
:param types: An iterable of string representations of the ABI types that
will be used for decoding e.g. ``('uint256', 'bytes... | [
"Decodes",
"the",
"binary",
"value",
"data",
"as",
"a",
"sequence",
"of",
"values",
"of",
"the",
"ABI",
"types",
"in",
"types",
"via",
"the",
"head",
"-",
"tail",
"mechanism",
"into",
"a",
"tuple",
"of",
"equivalent",
"python",
"values",
"."
] | python | train |
sashs/filebytes | filebytes/pe.py | https://github.com/sashs/filebytes/blob/41ee009832aba19603f33d1fd3483b84d6684ebf/filebytes/pe.py#L603-L629 | def _parseDataDirectoryImport(self, dataDirectoryEntry, importSection):
"""Parses the ImportDataDirectory and returns a list of ImportDescriptorData"""
if not importSection:
return
raw_bytes = (c_ubyte * dataDirectoryEntry.Size).from_buffer(importSection.raw, to_offset(dataDirector... | [
"def",
"_parseDataDirectoryImport",
"(",
"self",
",",
"dataDirectoryEntry",
",",
"importSection",
")",
":",
"if",
"not",
"importSection",
":",
"return",
"raw_bytes",
"=",
"(",
"c_ubyte",
"*",
"dataDirectoryEntry",
".",
"Size",
")",
".",
"from_buffer",
"(",
"impo... | Parses the ImportDataDirectory and returns a list of ImportDescriptorData | [
"Parses",
"the",
"ImportDataDirectory",
"and",
"returns",
"a",
"list",
"of",
"ImportDescriptorData"
] | python | train |
pjuren/pyokit | src/pyokit/datastruct/genomicInterval.py | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/genomicInterval.py#L410-L443 | def parseBEDString(line, scoreType=int, dropAfter=None):
"""
Parse a string in BED format and return a GenomicInterval object.
:param line: the string to be parsed
:param dropAfter: an int indicating that any fields after and including
this field should be ignored as they don't conform to
... | [
"def",
"parseBEDString",
"(",
"line",
",",
"scoreType",
"=",
"int",
",",
"dropAfter",
"=",
"None",
")",
":",
"peices",
"=",
"line",
".",
"split",
"(",
"\"\\t\"",
")",
"if",
"dropAfter",
"is",
"not",
"None",
":",
"peices",
"=",
"peices",
"[",
"0",
":"... | Parse a string in BED format and return a GenomicInterval object.
:param line: the string to be parsed
:param dropAfter: an int indicating that any fields after and including
this field should be ignored as they don't conform to
the BED format. By default, None, meaning we u... | [
"Parse",
"a",
"string",
"in",
"BED",
"format",
"and",
"return",
"a",
"GenomicInterval",
"object",
"."
] | python | train |
google-research/batch-ppo | agents/tools/loop.py | https://github.com/google-research/batch-ppo/blob/3d09705977bae4e7c3eb20339a3b384d2a5531e4/agents/tools/loop.py#L108-L152 | def run(self, sess, saver, max_step=None):
"""Run the loop schedule for a specified number of steps.
Call the operation of the current phase until the global step reaches the
specified maximum step. Phases are repeated over and over in the order they
were added.
Args:
sess: Session to use to... | [
"def",
"run",
"(",
"self",
",",
"sess",
",",
"saver",
",",
"max_step",
"=",
"None",
")",
":",
"global_step",
"=",
"sess",
".",
"run",
"(",
"self",
".",
"_step",
")",
"steps_made",
"=",
"1",
"while",
"True",
":",
"if",
"max_step",
"and",
"global_step"... | Run the loop schedule for a specified number of steps.
Call the operation of the current phase until the global step reaches the
specified maximum step. Phases are repeated over and over in the order they
were added.
Args:
sess: Session to use to run the phase operation.
saver: Saver used ... | [
"Run",
"the",
"loop",
"schedule",
"for",
"a",
"specified",
"number",
"of",
"steps",
"."
] | python | train |
dustinmm80/healthy | checks.py | https://github.com/dustinmm80/healthy/blob/b59016c3f578ca45b6ce857a2d5c4584b8542288/checks.py#L33-L46 | def check_license(package_info, *args):
"""
Does the package have a license classifier?
:param package_info: package_info dictionary
:return: Tuple (is the condition True or False?, reason if it is False else None, score to be applied)
"""
classifiers = package_info.get('classifiers')
reason... | [
"def",
"check_license",
"(",
"package_info",
",",
"*",
"args",
")",
":",
"classifiers",
"=",
"package_info",
".",
"get",
"(",
"'classifiers'",
")",
"reason",
"=",
"\"No License\"",
"result",
"=",
"False",
"if",
"len",
"(",
"[",
"c",
"for",
"c",
"in",
"cl... | Does the package have a license classifier?
:param package_info: package_info dictionary
:return: Tuple (is the condition True or False?, reason if it is False else None, score to be applied) | [
"Does",
"the",
"package",
"have",
"a",
"license",
"classifier?",
":",
"param",
"package_info",
":",
"package_info",
"dictionary",
":",
"return",
":",
"Tuple",
"(",
"is",
"the",
"condition",
"True",
"or",
"False?",
"reason",
"if",
"it",
"is",
"False",
"else",... | python | train |
google/grr | grr/server/grr_response_server/databases/db.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L1248-L1265 | def IterateAllClientSnapshots(self, min_last_ping=None, batch_size=50000):
"""Iterates over all available clients and yields client snapshot objects.
Args:
min_last_ping: If provided, only snapshots for clients with last-ping
timestamps newer than (or equal to) the given value will be returned.
... | [
"def",
"IterateAllClientSnapshots",
"(",
"self",
",",
"min_last_ping",
"=",
"None",
",",
"batch_size",
"=",
"50000",
")",
":",
"all_client_ids",
"=",
"self",
".",
"ReadAllClientIDs",
"(",
"min_last_ping",
"=",
"min_last_ping",
")",
"for",
"batch",
"in",
"collect... | Iterates over all available clients and yields client snapshot objects.
Args:
min_last_ping: If provided, only snapshots for clients with last-ping
timestamps newer than (or equal to) the given value will be returned.
batch_size: Always reads <batch_size> snapshots at a time.
Yields:
... | [
"Iterates",
"over",
"all",
"available",
"clients",
"and",
"yields",
"client",
"snapshot",
"objects",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/commenting/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/commenting/objects.py#L569-L580 | def get_book(self):
"""Gets the ``Book`` at this node.
return: (osid.commenting.Book) - the book represented by this
node
*compliance: mandatory -- This method must be implemented.*
"""
if self._lookup_session is None:
mgr = get_provider_manager('COM... | [
"def",
"get_book",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lookup_session",
"is",
"None",
":",
"mgr",
"=",
"get_provider_manager",
"(",
"'COMMENTING'",
",",
"runtime",
"=",
"self",
".",
"_runtime",
",",
"proxy",
"=",
"self",
".",
"_proxy",
")",
"self... | Gets the ``Book`` at this node.
return: (osid.commenting.Book) - the book represented by this
node
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"Book",
"at",
"this",
"node",
"."
] | python | train |
JarryShaw/PyPCAPKit | src/const/ipv4/tos_pre.py | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/const/ipv4/tos_pre.py#L22-L28 | def get(key, default=-1):
"""Backport support for original codes."""
if isinstance(key, int):
return TOS_PRE(key)
if key not in TOS_PRE._member_map_:
extend_enum(TOS_PRE, key, default)
return TOS_PRE[key] | [
"def",
"get",
"(",
"key",
",",
"default",
"=",
"-",
"1",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"int",
")",
":",
"return",
"TOS_PRE",
"(",
"key",
")",
"if",
"key",
"not",
"in",
"TOS_PRE",
".",
"_member_map_",
":",
"extend_enum",
"(",
"TOS_P... | Backport support for original codes. | [
"Backport",
"support",
"for",
"original",
"codes",
"."
] | python | train |
neon-jungle/wagtailmodelchooser | wagtailmodelchooser/utils.py | https://github.com/neon-jungle/wagtailmodelchooser/blob/8dd1e33dd61418a726ff3acf67a956626c8b7ba1/wagtailmodelchooser/utils.py#L32-L42 | def signature_matches(func, args=(), kwargs={}):
"""
Work out if a function is callable with some args or not.
"""
try:
sig = inspect.signature(func)
sig.bind(*args, **kwargs)
except TypeError:
return False
else:
return True | [
"def",
"signature_matches",
"(",
"func",
",",
"args",
"=",
"(",
")",
",",
"kwargs",
"=",
"{",
"}",
")",
":",
"try",
":",
"sig",
"=",
"inspect",
".",
"signature",
"(",
"func",
")",
"sig",
".",
"bind",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
"... | Work out if a function is callable with some args or not. | [
"Work",
"out",
"if",
"a",
"function",
"is",
"callable",
"with",
"some",
"args",
"or",
"not",
"."
] | python | valid |
saltstack/salt | salt/utils/hashutils.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/hashutils.py#L38-L49 | def base64_b64decode(instr):
'''
Decode a base64-encoded string using the "modern" Python interface.
'''
decoded = base64.b64decode(salt.utils.stringutils.to_bytes(instr))
try:
return salt.utils.stringutils.to_unicode(
decoded,
encoding='utf8' if salt.utils.platform.i... | [
"def",
"base64_b64decode",
"(",
"instr",
")",
":",
"decoded",
"=",
"base64",
".",
"b64decode",
"(",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_bytes",
"(",
"instr",
")",
")",
"try",
":",
"return",
"salt",
".",
"utils",
".",
"stringutils",
".",
... | Decode a base64-encoded string using the "modern" Python interface. | [
"Decode",
"a",
"base64",
"-",
"encoded",
"string",
"using",
"the",
"modern",
"Python",
"interface",
"."
] | python | train |
s0lst1c3/grey_harvest | grey_harvest.py | https://github.com/s0lst1c3/grey_harvest/blob/811e5787ce7e613bc489b8e5e475eaa8790f4d66/grey_harvest.py#L111-L156 | def _extract_proxies(self, ajax_endpoint):
''' request the xml object '''
proxy_xml = requests.get(ajax_endpoint)
print(proxy_xml.content)
root = etree.XML(proxy_xml.content)
quote = root.xpath('quote')[0]
''' extract the raw text from the body of the quote ... | [
"def",
"_extract_proxies",
"(",
"self",
",",
"ajax_endpoint",
")",
":",
"proxy_xml",
"=",
"requests",
".",
"get",
"(",
"ajax_endpoint",
")",
"print",
"(",
"proxy_xml",
".",
"content",
")",
"root",
"=",
"etree",
".",
"XML",
"(",
"proxy_xml",
".",
"content",... | request the xml object | [
"request",
"the",
"xml",
"object"
] | python | train |
klen/muffin-peewee | muffin_peewee/debugtoolbar.py | https://github.com/klen/muffin-peewee/blob/8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e/muffin_peewee/debugtoolbar.py#L44-L47 | def wrap_handler(self, handler, context_switcher):
"""Enable/Disable handler."""
context_switcher.add_context_in(lambda: LOGGER.addHandler(self.handler))
context_switcher.add_context_out(lambda: LOGGER.removeHandler(self.handler)) | [
"def",
"wrap_handler",
"(",
"self",
",",
"handler",
",",
"context_switcher",
")",
":",
"context_switcher",
".",
"add_context_in",
"(",
"lambda",
":",
"LOGGER",
".",
"addHandler",
"(",
"self",
".",
"handler",
")",
")",
"context_switcher",
".",
"add_context_out",
... | Enable/Disable handler. | [
"Enable",
"/",
"Disable",
"handler",
"."
] | python | valid |
estnltk/estnltk | estnltk/disambiguator.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L306-L322 | def __remove_redundant_proper_names(self, docs, lemma_set):
""" Eemaldame yleliigsed pärisnimeanalüüsid etteantud sõnalemmade
loendi (hulga) põhjal;
"""
for doc in docs:
for word in doc[WORDS]:
# Vaatame vaid s6nu, millele on pakutud rohkem kui yks analyys... | [
"def",
"__remove_redundant_proper_names",
"(",
"self",
",",
"docs",
",",
"lemma_set",
")",
":",
"for",
"doc",
"in",
"docs",
":",
"for",
"word",
"in",
"doc",
"[",
"WORDS",
"]",
":",
"# Vaatame vaid s6nu, millele on pakutud rohkem kui yks analyys:",
"if",
"len",
"("... | Eemaldame yleliigsed pärisnimeanalüüsid etteantud sõnalemmade
loendi (hulga) põhjal; | [
"Eemaldame",
"yleliigsed",
"pärisnimeanalüüsid",
"etteantud",
"sõnalemmade",
"loendi",
"(",
"hulga",
")",
"põhjal",
";"
] | python | train |
Qiskit/qiskit-terra | qiskit/tools/events/progressbar.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/events/progressbar.py#L60-L68 | def start(self, iterations):
"""Start the progress bar.
Parameters:
iterations (int): Number of iterations.
"""
self.touched = True
self.iter = int(iterations)
self.t_start = time.time() | [
"def",
"start",
"(",
"self",
",",
"iterations",
")",
":",
"self",
".",
"touched",
"=",
"True",
"self",
".",
"iter",
"=",
"int",
"(",
"iterations",
")",
"self",
".",
"t_start",
"=",
"time",
".",
"time",
"(",
")"
] | Start the progress bar.
Parameters:
iterations (int): Number of iterations. | [
"Start",
"the",
"progress",
"bar",
"."
] | python | test |
EpistasisLab/tpot | tpot/builtins/one_hot_encoder.py | https://github.com/EpistasisLab/tpot/blob/b626271e6b5896a73fb9d7d29bebc7aa9100772e/tpot/builtins/one_hot_encoder.py#L399-L479 | def _transform(self, X):
"""Asssume X contains only categorical features.
Parameters
----------
X : array-like or sparse matrix, shape=(n_samples, n_features)
Dense array or sparse matrix.
"""
X = self._matrix_adjust(X)
X = check_array(X, accept_spar... | [
"def",
"_transform",
"(",
"self",
",",
"X",
")",
":",
"X",
"=",
"self",
".",
"_matrix_adjust",
"(",
"X",
")",
"X",
"=",
"check_array",
"(",
"X",
",",
"accept_sparse",
"=",
"'csc'",
",",
"force_all_finite",
"=",
"False",
",",
"dtype",
"=",
"int",
")",... | Asssume X contains only categorical features.
Parameters
----------
X : array-like or sparse matrix, shape=(n_samples, n_features)
Dense array or sparse matrix. | [
"Asssume",
"X",
"contains",
"only",
"categorical",
"features",
"."
] | python | train |
spookey/photon | photon/tools/ping.py | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/ping.py#L95-L144 | def probe(self, hosts):
'''
.. seealso:: :attr:`probe`
'''
def __send_probe(host):
ping = self.m(
'',
cmdd=dict(
cmd=' '.join([
self.__ping_cmd,
self.__num,
... | [
"def",
"probe",
"(",
"self",
",",
"hosts",
")",
":",
"def",
"__send_probe",
"(",
"host",
")",
":",
"ping",
"=",
"self",
".",
"m",
"(",
"''",
",",
"cmdd",
"=",
"dict",
"(",
"cmd",
"=",
"' '",
".",
"join",
"(",
"[",
"self",
".",
"__ping_cmd",
","... | .. seealso:: :attr:`probe` | [
"..",
"seealso",
"::",
":",
"attr",
":",
"probe"
] | python | train |
duniter/duniter-python-api | duniterpy/api/endpoint.py | https://github.com/duniter/duniter-python-api/blob/3a1e5d61a2f72f5afaf29d010c6cf4dff3648165/duniterpy/api/endpoint.py#L270-L283 | def conn_handler(self, session: ClientSession, proxy: str = None) -> ConnectionHandler:
"""
Return connection handler instance for the endpoint
:param session: AIOHTTP client session instance
:param proxy: Proxy url
:return:
"""
if self.server:
return... | [
"def",
"conn_handler",
"(",
"self",
",",
"session",
":",
"ClientSession",
",",
"proxy",
":",
"str",
"=",
"None",
")",
"->",
"ConnectionHandler",
":",
"if",
"self",
".",
"server",
":",
"return",
"ConnectionHandler",
"(",
"\"https\"",
",",
"\"wss\"",
",",
"s... | Return connection handler instance for the endpoint
:param session: AIOHTTP client session instance
:param proxy: Proxy url
:return: | [
"Return",
"connection",
"handler",
"instance",
"for",
"the",
"endpoint"
] | python | train |
numenta/htmresearch | htmresearch/support/csv_helper.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/support/csv_helper.py#L119-L144 | def readDir(dirPath, numLabels, modify=False):
"""
Reads in data from a directory of CSV files; assumes the directory only
contains CSV files.
@param dirPath (str) Path to the directory.
@param numLabels (int) Number of columns of category labels.
@param modify ... | [
"def",
"readDir",
"(",
"dirPath",
",",
"numLabels",
",",
"modify",
"=",
"False",
")",
":",
"samplesDict",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"_",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"dirPath",
")",
":",
"for",
"f",
"in",... | Reads in data from a directory of CSV files; assumes the directory only
contains CSV files.
@param dirPath (str) Path to the directory.
@param numLabels (int) Number of columns of category labels.
@param modify (bool) Map the unix friendly category name... | [
"Reads",
"in",
"data",
"from",
"a",
"directory",
"of",
"CSV",
"files",
";",
"assumes",
"the",
"directory",
"only",
"contains",
"CSV",
"files",
"."
] | python | train |
stanfordnlp/stanza | stanza/research/iterators.py | https://github.com/stanfordnlp/stanza/blob/920c55d8eaa1e7105971059c66eb448a74c100d6/stanza/research/iterators.py#L138-L157 | def sized_imap(func, iterable, strict=False):
'''
Return an iterable whose elements are the result of applying the callable `func`
to each element of `iterable`. If `iterable` has a `len()`, then the iterable returned
by this function will have the same `len()`. Otherwise calling `len()` on the
retu... | [
"def",
"sized_imap",
"(",
"func",
",",
"iterable",
",",
"strict",
"=",
"False",
")",
":",
"try",
":",
"length",
"=",
"len",
"(",
"iterable",
")",
"except",
"TypeError",
":",
"if",
"strict",
":",
"raise",
"else",
":",
"return",
"imap",
"(",
"func",
",... | Return an iterable whose elements are the result of applying the callable `func`
to each element of `iterable`. If `iterable` has a `len()`, then the iterable returned
by this function will have the same `len()`. Otherwise calling `len()` on the
returned iterable will raise `TypeError`.
:param func: Th... | [
"Return",
"an",
"iterable",
"whose",
"elements",
"are",
"the",
"result",
"of",
"applying",
"the",
"callable",
"func",
"to",
"each",
"element",
"of",
"iterable",
".",
"If",
"iterable",
"has",
"a",
"len",
"()",
"then",
"the",
"iterable",
"returned",
"by",
"t... | python | train |
quantmind/pulsar | pulsar/utils/context.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/context.py#L40-L48 | def set(self, key, value):
"""Set a value in the task context
"""
task = Task.current_task()
try:
context = task._context
except AttributeError:
task._context = context = {}
context[key] = value | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"task",
"=",
"Task",
".",
"current_task",
"(",
")",
"try",
":",
"context",
"=",
"task",
".",
"_context",
"except",
"AttributeError",
":",
"task",
".",
"_context",
"=",
"context",
"=",
"{"... | Set a value in the task context | [
"Set",
"a",
"value",
"in",
"the",
"task",
"context"
] | python | train |
Contraz/demosys-py | demosys/loaders/scene/gltf.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/loaders/scene/gltf.py#L340-L348 | def buffers_exist(self):
"""Checks if the bin files referenced exist"""
for buff in self.buffers:
if not buff.is_separate_file:
continue
path = self.path.parent / buff.uri
if not os.path.exists(path):
raise FileNotFoundError("Buffer {}... | [
"def",
"buffers_exist",
"(",
"self",
")",
":",
"for",
"buff",
"in",
"self",
".",
"buffers",
":",
"if",
"not",
"buff",
".",
"is_separate_file",
":",
"continue",
"path",
"=",
"self",
".",
"path",
".",
"parent",
"/",
"buff",
".",
"uri",
"if",
"not",
"os... | Checks if the bin files referenced exist | [
"Checks",
"if",
"the",
"bin",
"files",
"referenced",
"exist"
] | python | valid |
martinmcbride/pysound | pysound/oscillators.py | https://github.com/martinmcbride/pysound/blob/253c8f712ad475318350e5a8ba21f6fefd7a3de2/pysound/oscillators.py#L90-L100 | def sine_wave(params, frequency=400, amplitude=1, offset=0):
'''
Generate a sine wave
Convenience function, table_wave generates a sine wave by default
:param params: buffer parameters, controls length of signal created
:param frequency: wave frequency (array or value)
:param amplitude: wave amp... | [
"def",
"sine_wave",
"(",
"params",
",",
"frequency",
"=",
"400",
",",
"amplitude",
"=",
"1",
",",
"offset",
"=",
"0",
")",
":",
"return",
"table_wave",
"(",
"params",
",",
"frequency",
",",
"amplitude",
",",
"offset",
")"
] | Generate a sine wave
Convenience function, table_wave generates a sine wave by default
:param params: buffer parameters, controls length of signal created
:param frequency: wave frequency (array or value)
:param amplitude: wave amplitude (array or value)
:param offset: offset of wave mean from zero ... | [
"Generate",
"a",
"sine",
"wave",
"Convenience",
"function",
"table_wave",
"generates",
"a",
"sine",
"wave",
"by",
"default",
":",
"param",
"params",
":",
"buffer",
"parameters",
"controls",
"length",
"of",
"signal",
"created",
":",
"param",
"frequency",
":",
"... | python | train |
angr/angr | angr/analyses/ddg.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/ddg.py#L1299-L1314 | def _data_graph_add_edge(self, src, dst, **edge_labels):
"""
Add an edge in the data dependence graph.
:param ProgramVariable src: Source node.
:param ProgramVariable dst: Destination node.
:param edge_labels: All labels associated with the edge.
:return: None
""... | [
"def",
"_data_graph_add_edge",
"(",
"self",
",",
"src",
",",
"dst",
",",
"*",
"*",
"edge_labels",
")",
":",
"if",
"src",
"in",
"self",
".",
"_data_graph",
"and",
"dst",
"in",
"self",
".",
"_data_graph",
"[",
"src",
"]",
":",
"return",
"self",
".",
"_... | Add an edge in the data dependence graph.
:param ProgramVariable src: Source node.
:param ProgramVariable dst: Destination node.
:param edge_labels: All labels associated with the edge.
:return: None | [
"Add",
"an",
"edge",
"in",
"the",
"data",
"dependence",
"graph",
"."
] | python | train |
datakortet/dkfileutils | dkfileutils/path.py | https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/path.py#L329-L333 | def list(self, filterfn=lambda x: True):
"""Return all direct descendands of directory `self` for which
`filterfn` returns True.
"""
return [self / p for p in self.listdir() if filterfn(self / p)] | [
"def",
"list",
"(",
"self",
",",
"filterfn",
"=",
"lambda",
"x",
":",
"True",
")",
":",
"return",
"[",
"self",
"/",
"p",
"for",
"p",
"in",
"self",
".",
"listdir",
"(",
")",
"if",
"filterfn",
"(",
"self",
"/",
"p",
")",
"]"
] | Return all direct descendands of directory `self` for which
`filterfn` returns True. | [
"Return",
"all",
"direct",
"descendands",
"of",
"directory",
"self",
"for",
"which",
"filterfn",
"returns",
"True",
"."
] | python | train |
jtwhite79/pyemu | pyemu/en.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/en.py#L110-L155 | def draw(self,cov,num_reals=1,names=None):
""" draw random realizations from a multivariate
Gaussian distribution
Parameters
----------
cov: pyemu.Cov
covariance structure to draw from
num_reals: int
number of realizations to generate
... | [
"def",
"draw",
"(",
"self",
",",
"cov",
",",
"num_reals",
"=",
"1",
",",
"names",
"=",
"None",
")",
":",
"real_names",
"=",
"np",
".",
"arange",
"(",
"num_reals",
",",
"dtype",
"=",
"np",
".",
"int64",
")",
"# make sure everything is cool WRT ordering",
... | draw random realizations from a multivariate
Gaussian distribution
Parameters
----------
cov: pyemu.Cov
covariance structure to draw from
num_reals: int
number of realizations to generate
names : list
list of columns names to d... | [
"draw",
"random",
"realizations",
"from",
"a",
"multivariate",
"Gaussian",
"distribution"
] | python | train |
gpagliuca/pyfas | build/lib/pyfas/tab.py | https://github.com/gpagliuca/pyfas/blob/5daa1199bd124d315d02bef0ad3888a8f58355b2/build/lib/pyfas/tab.py#L134-L152 | def _export_all_fixed(self):
"""
Exports all the properties for a fixed-type tab file
"""
array_ts = []
array_ps = []
for array_t, array_p in it.product(self.metadata["t_array"][0],
self.metadata["p_array"][0]):
... | [
"def",
"_export_all_fixed",
"(",
"self",
")",
":",
"array_ts",
"=",
"[",
"]",
"array_ps",
"=",
"[",
"]",
"for",
"array_t",
",",
"array_p",
"in",
"it",
".",
"product",
"(",
"self",
".",
"metadata",
"[",
"\"t_array\"",
"]",
"[",
"0",
"]",
",",
"self",
... | Exports all the properties for a fixed-type tab file | [
"Exports",
"all",
"the",
"properties",
"for",
"a",
"fixed",
"-",
"type",
"tab",
"file"
] | python | train |
nerdvegas/rez | src/rez/solver.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L1167-L1366 | def solve(self):
"""Attempt to solve the phase."""
if self.status != SolverStatus.pending:
return self
scopes = self.scopes[:]
failure_reason = None
extractions = {}
changed_scopes_i = self.changed_scopes_i.copy()
def _create_phase(status=None):
... | [
"def",
"solve",
"(",
"self",
")",
":",
"if",
"self",
".",
"status",
"!=",
"SolverStatus",
".",
"pending",
":",
"return",
"self",
"scopes",
"=",
"self",
".",
"scopes",
"[",
":",
"]",
"failure_reason",
"=",
"None",
"extractions",
"=",
"{",
"}",
"changed_... | Attempt to solve the phase. | [
"Attempt",
"to",
"solve",
"the",
"phase",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/jinja2/filters.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/filters.py#L536-L574 | def do_indent(
s, width=4, first=False, blank=False, indentfirst=None
):
"""Return a copy of the string with each line indented by 4 spaces. The
first line and blank lines are not indented by default.
:param width: Number of spaces to indent by.
:param first: Don't skip indenting the first line.
... | [
"def",
"do_indent",
"(",
"s",
",",
"width",
"=",
"4",
",",
"first",
"=",
"False",
",",
"blank",
"=",
"False",
",",
"indentfirst",
"=",
"None",
")",
":",
"if",
"indentfirst",
"is",
"not",
"None",
":",
"warnings",
".",
"warn",
"(",
"DeprecationWarning",
... | Return a copy of the string with each line indented by 4 spaces. The
first line and blank lines are not indented by default.
:param width: Number of spaces to indent by.
:param first: Don't skip indenting the first line.
:param blank: Don't skip indenting empty lines.
.. versionchanged:: 2.10
... | [
"Return",
"a",
"copy",
"of",
"the",
"string",
"with",
"each",
"line",
"indented",
"by",
"4",
"spaces",
".",
"The",
"first",
"line",
"and",
"blank",
"lines",
"are",
"not",
"indented",
"by",
"default",
"."
] | python | train |
ktbyers/netmiko | netmiko/_textfsm/_texttable.py | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L213-L228 | def _SetColour(self, value_list):
"""Sets row's colour attributes to a list of values in terminal.SGR."""
if value_list is None:
self._color = None
return
colors = []
for color in value_list:
if color in terminal.SGR:
colors.append(colo... | [
"def",
"_SetColour",
"(",
"self",
",",
"value_list",
")",
":",
"if",
"value_list",
"is",
"None",
":",
"self",
".",
"_color",
"=",
"None",
"return",
"colors",
"=",
"[",
"]",
"for",
"color",
"in",
"value_list",
":",
"if",
"color",
"in",
"terminal",
".",
... | Sets row's colour attributes to a list of values in terminal.SGR. | [
"Sets",
"row",
"s",
"colour",
"attributes",
"to",
"a",
"list",
"of",
"values",
"in",
"terminal",
".",
"SGR",
"."
] | python | train |
dlintott/gns3-converter | gns3converter/node.py | https://github.com/dlintott/gns3-converter/blob/acbc55da51de86388dc5b5f6da55809b3c86b7ca/gns3converter/node.py#L376-L395 | def calc_link(self, src_id, src_port, src_port_name, destination):
"""
Add a link item for processing later
:param int src_id: Source node ID
:param int src_port: Source port ID
:param str src_port_name: Source port name
:param dict destination: Destination
"""
... | [
"def",
"calc_link",
"(",
"self",
",",
"src_id",
",",
"src_port",
",",
"src_port_name",
",",
"destination",
")",
":",
"if",
"destination",
"[",
"'device'",
"]",
"==",
"'NIO'",
":",
"destination",
"[",
"'port'",
"]",
"=",
"destination",
"[",
"'port'",
"]",
... | Add a link item for processing later
:param int src_id: Source node ID
:param int src_port: Source port ID
:param str src_port_name: Source port name
:param dict destination: Destination | [
"Add",
"a",
"link",
"item",
"for",
"processing",
"later"
] | python | train |
liip/taxi | taxi/commands/alias.py | https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/commands/alias.py#L50-L63 | def add(ctx, alias, mapping, backend):
"""
Add a new alias to your configuration file.
"""
if not backend:
backends_list = ctx.obj['settings'].get_backends()
if len(backends_list) > 1:
raise click.UsageError(
"You're using more than 1 backend. Please set the b... | [
"def",
"add",
"(",
"ctx",
",",
"alias",
",",
"mapping",
",",
"backend",
")",
":",
"if",
"not",
"backend",
":",
"backends_list",
"=",
"ctx",
".",
"obj",
"[",
"'settings'",
"]",
".",
"get_backends",
"(",
")",
"if",
"len",
"(",
"backends_list",
")",
">"... | Add a new alias to your configuration file. | [
"Add",
"a",
"new",
"alias",
"to",
"your",
"configuration",
"file",
"."
] | python | train |
saltstack/salt | salt/modules/win_system.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_system.py#L1297-L1332 | def get_pending_domain_join():
'''
Determine whether there is a pending domain join action that requires a
reboot.
.. versionadded:: 2016.11.0
Returns:
bool: ``True`` if there is a pending domain join action, otherwise
``False``
CLI Example:
.. code-block:: bash
... | [
"def",
"get_pending_domain_join",
"(",
")",
":",
"base_key",
"=",
"r'SYSTEM\\CurrentControlSet\\Services\\Netlogon'",
"avoid_key",
"=",
"r'{0}\\AvoidSpnSet'",
".",
"format",
"(",
"base_key",
")",
"join_key",
"=",
"r'{0}\\JoinDomain'",
".",
"format",
"(",
"base_key",
")"... | Determine whether there is a pending domain join action that requires a
reboot.
.. versionadded:: 2016.11.0
Returns:
bool: ``True`` if there is a pending domain join action, otherwise
``False``
CLI Example:
.. code-block:: bash
salt '*' system.get_pending_domain_join | [
"Determine",
"whether",
"there",
"is",
"a",
"pending",
"domain",
"join",
"action",
"that",
"requires",
"a",
"reboot",
"."
] | python | train |
juicer/juicer | juicer/utils/texttable.py | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/texttable.py#L373-L397 | def _compute_cols_width(self):
"""Return an array with the width of each column
If a specific width has been specified, exit. If the total of the
columns width exceed the table desired width, another width will be
computed to fit, and cells will be wrapped.
"""
if hasat... | [
"def",
"_compute_cols_width",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_width\"",
")",
":",
"return",
"maxi",
"=",
"[",
"]",
"if",
"self",
".",
"_header",
":",
"maxi",
"=",
"[",
"self",
".",
"_len_cell",
"(",
"x",
")",
"for",
"x... | Return an array with the width of each column
If a specific width has been specified, exit. If the total of the
columns width exceed the table desired width, another width will be
computed to fit, and cells will be wrapped. | [
"Return",
"an",
"array",
"with",
"the",
"width",
"of",
"each",
"column"
] | python | train |
pycontribs/jira | jira/resources.py | https://github.com/pycontribs/jira/blob/397db5d78441ed6a680a9b7db4c62030ade1fd8a/jira/resources.py#L573-L580 | def delete(self, deleteSubtasks=False):
"""Delete this issue from the server.
:param deleteSubtasks: if the issue has subtasks, this argument must be set to true for the call to succeed.
:type deleteSubtasks: bool
"""
super(Issue, self).delete(params={'deleteSubtasks': deleteSu... | [
"def",
"delete",
"(",
"self",
",",
"deleteSubtasks",
"=",
"False",
")",
":",
"super",
"(",
"Issue",
",",
"self",
")",
".",
"delete",
"(",
"params",
"=",
"{",
"'deleteSubtasks'",
":",
"deleteSubtasks",
"}",
")"
] | Delete this issue from the server.
:param deleteSubtasks: if the issue has subtasks, this argument must be set to true for the call to succeed.
:type deleteSubtasks: bool | [
"Delete",
"this",
"issue",
"from",
"the",
"server",
"."
] | python | train |
d0ugal/python-rfxcom | rfxcom/protocol/elec.py | https://github.com/d0ugal/python-rfxcom/blob/2eb87f85e5f5a04d00f32f25e0f010edfefbde0d/rfxcom/protocol/elec.py#L77-L129 | def parse(self, data):
"""Parse a 18 bytes packet in the Electricity format and return a
dictionary containing the data extracted. An example of a return value
would be:
.. code-block:: python
{
'count': 3,
'current_watts': 692,
... | [
"def",
"parse",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"validate_packet",
"(",
"data",
")",
"TOTAL_DIVISOR",
"=",
"223.666",
"id_",
"=",
"self",
".",
"dump_hex",
"(",
"data",
"[",
"4",
":",
"6",
"]",
")",
"count",
"=",
"data",
"[",
"6",
... | Parse a 18 bytes packet in the Electricity format and return a
dictionary containing the data extracted. An example of a return value
would be:
.. code-block:: python
{
'count': 3,
'current_watts': 692,
'id': "0x2EB2",
... | [
"Parse",
"a",
"18",
"bytes",
"packet",
"in",
"the",
"Electricity",
"format",
"and",
"return",
"a",
"dictionary",
"containing",
"the",
"data",
"extracted",
".",
"An",
"example",
"of",
"a",
"return",
"value",
"would",
"be",
":"
] | python | train |
adamziel/python_translate | python_translate/loaders.py | https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/loaders.py#L79-L92 | def read_file(self, path):
"""
Reads a file into memory and returns it's contents
@type path: str
@param path: path to load
"""
self.assert_valid_path(path)
with open(path, 'rb') as file:
contents = file.read().decode('UTF-8')
return conten... | [
"def",
"read_file",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"assert_valid_path",
"(",
"path",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"file",
":",
"contents",
"=",
"file",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'UTF-... | Reads a file into memory and returns it's contents
@type path: str
@param path: path to load | [
"Reads",
"a",
"file",
"into",
"memory",
"and",
"returns",
"it",
"s",
"contents"
] | python | train |
nedbat/django_coverage_plugin | django_coverage_plugin/plugin.py | https://github.com/nedbat/django_coverage_plugin/blob/0072737c0ea5a1ca6b9f046af4947de191f13804/django_coverage_plugin/plugin.py#L397-L418 | def dump_frame(frame, label=""):
"""Dump interesting information about this frame."""
locals = dict(frame.f_locals)
self = locals.get('self', None)
context = locals.get('context', None)
if "__builtins__" in locals:
del locals["__builtins__"]
if label:
label = " ( %s ) " % label
... | [
"def",
"dump_frame",
"(",
"frame",
",",
"label",
"=",
"\"\"",
")",
":",
"locals",
"=",
"dict",
"(",
"frame",
".",
"f_locals",
")",
"self",
"=",
"locals",
".",
"get",
"(",
"'self'",
",",
"None",
")",
"context",
"=",
"locals",
".",
"get",
"(",
"'cont... | Dump interesting information about this frame. | [
"Dump",
"interesting",
"information",
"about",
"this",
"frame",
"."
] | python | train |
oanda/v20-python | src/v20/order.py | https://github.com/oanda/v20-python/blob/f28192f4a31bce038cf6dfa302f5878bec192fe5/src/v20/order.py#L3730-L3855 | def list(
self,
accountID,
**kwargs
):
"""
Get a list of Orders for an Account
Args:
accountID:
Account Identifier
ids:
List of Order IDs to retrieve
state:
The state to filter the re... | [
"def",
"list",
"(",
"self",
",",
"accountID",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
"=",
"Request",
"(",
"'GET'",
",",
"'/v3/accounts/{accountID}/orders'",
")",
"request",
".",
"set_path_param",
"(",
"'accountID'",
",",
"accountID",
")",
"request",
"... | Get a list of Orders for an Account
Args:
accountID:
Account Identifier
ids:
List of Order IDs to retrieve
state:
The state to filter the requested Orders by
instrument:
The instrument to filter the ... | [
"Get",
"a",
"list",
"of",
"Orders",
"for",
"an",
"Account"
] | python | train |
fermiPy/fermipy | fermipy/merge_utils.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/merge_utils.py#L39-L50 | def update_image(hdu_in, hdu=None):
""" 'Update' an image HDU
This checks hdu exists and creates it from hdu_in if it does not.
If hdu does exist, this adds the data in hdu_in to hdu
"""
if hdu is None:
hdu = fits.ImageHDU(
data=hdu_in.data, header=hdu_in.header, name=hdu_in.nam... | [
"def",
"update_image",
"(",
"hdu_in",
",",
"hdu",
"=",
"None",
")",
":",
"if",
"hdu",
"is",
"None",
":",
"hdu",
"=",
"fits",
".",
"ImageHDU",
"(",
"data",
"=",
"hdu_in",
".",
"data",
",",
"header",
"=",
"hdu_in",
".",
"header",
",",
"name",
"=",
... | 'Update' an image HDU
This checks hdu exists and creates it from hdu_in if it does not.
If hdu does exist, this adds the data in hdu_in to hdu | [
"Update",
"an",
"image",
"HDU"
] | python | train |
numenta/nupic | examples/tm/tm_overlapping_sequences.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/tm/tm_overlapping_sequences.py#L113-L176 | def buildOverlappedSequences( numSequences = 2,
seqLen = 5,
sharedElements = [3,4],
numOnBitsPerPattern = 3,
patternOverlap = 0,
seqOverlap = 0,
... | [
"def",
"buildOverlappedSequences",
"(",
"numSequences",
"=",
"2",
",",
"seqLen",
"=",
"5",
",",
"sharedElements",
"=",
"[",
"3",
",",
"4",
"]",
",",
"numOnBitsPerPattern",
"=",
"3",
",",
"patternOverlap",
"=",
"0",
",",
"seqOverlap",
"=",
"0",
",",
"*",
... | Create training sequences that share some elements in the middle.
Parameters:
-----------------------------------------------------
numSequences: Number of unique training sequences to generate
seqLen: Overall length of each sequence
sharedElements: Which element indices of each s... | [
"Create",
"training",
"sequences",
"that",
"share",
"some",
"elements",
"in",
"the",
"middle",
"."
] | python | valid |
rigetti/pyquil | pyquil/latex/latex_generation.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/latex/latex_generation.py#L358-L379 | def _cz_gate(self, lines):
"""
Return the TikZ code for an n-controlled Z-gate.
:param lines: List of all qubits involved.
:type: list[int]
"""
line = lines[0]
delta_pos = self._gate_offset(Z)
gate_width = self._gate_width(Z)
gate_str = self._phas... | [
"def",
"_cz_gate",
"(",
"self",
",",
"lines",
")",
":",
"line",
"=",
"lines",
"[",
"0",
"]",
"delta_pos",
"=",
"self",
".",
"_gate_offset",
"(",
"Z",
")",
"gate_width",
"=",
"self",
".",
"_gate_width",
"(",
"Z",
")",
"gate_str",
"=",
"self",
".",
"... | Return the TikZ code for an n-controlled Z-gate.
:param lines: List of all qubits involved.
:type: list[int] | [
"Return",
"the",
"TikZ",
"code",
"for",
"an",
"n",
"-",
"controlled",
"Z",
"-",
"gate",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.