repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
hydraplatform/hydra-base | hydra_base/db/model.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/db/model.py#L860-L882 | def add_link(self, name, desc, layout, node_1, node_2):
"""
Add a link to a network. Links are what effectively
define the network topology, by associating two already
existing nodes.
"""
existing_link = get_session().query(Link).filter(Link.name==name, Link.... | [
"def",
"add_link",
"(",
"self",
",",
"name",
",",
"desc",
",",
"layout",
",",
"node_1",
",",
"node_2",
")",
":",
"existing_link",
"=",
"get_session",
"(",
")",
".",
"query",
"(",
"Link",
")",
".",
"filter",
"(",
"Link",
".",
"name",
"==",
"name",
"... | Add a link to a network. Links are what effectively
define the network topology, by associating two already
existing nodes. | [
"Add",
"a",
"link",
"to",
"a",
"network",
".",
"Links",
"are",
"what",
"effectively",
"define",
"the",
"network",
"topology",
"by",
"associating",
"two",
"already",
"existing",
"nodes",
"."
] | python | train | 33.26087 |
awslabs/aws-sam-cli | samcli/commands/local/lib/sam_api_provider.py | https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L301-L314 | def _normalize_http_methods(http_method):
"""
Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all
supported Http Methods on Api Gateway.
:param str http_method: Http method
:yield str: Either the input http_method or one of the... | [
"def",
"_normalize_http_methods",
"(",
"http_method",
")",
":",
"if",
"http_method",
".",
"upper",
"(",
")",
"==",
"'ANY'",
":",
"for",
"method",
"in",
"SamApiProvider",
".",
"_ANY_HTTP_METHODS",
":",
"yield",
"method",
".",
"upper",
"(",
")",
"else",
":",
... | Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all
supported Http Methods on Api Gateway.
:param str http_method: Http method
:yield str: Either the input http_method or one of the _ANY_HTTP_METHODS (normalized Http Methods) | [
"Normalizes",
"Http",
"Methods",
".",
"Api",
"Gateway",
"allows",
"a",
"Http",
"Methods",
"of",
"ANY",
".",
"This",
"is",
"a",
"special",
"verb",
"to",
"denote",
"all",
"supported",
"Http",
"Methods",
"on",
"Api",
"Gateway",
"."
] | python | train | 39.571429 |
EUDAT-B2SAFE/B2HANDLE | b2handle/handleclient.py | https://github.com/EUDAT-B2SAFE/B2HANDLE/blob/a6d216d459644e01fbdfd5b318a535950bc5cdbb/b2handle/handleclient.py#L934-L973 | def search_handle(self, URL=None, prefix=None, **key_value_pairs):
'''
Search for handles containing the specified key with the specified
value. The search terms are passed on to the reverse lookup servlet
as-is. The servlet is supposed to be case-insensitive, but if it
isn't, th... | [
"def",
"search_handle",
"(",
"self",
",",
"URL",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"*",
"*",
"key_value_pairs",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'search_handle...'",
")",
"list_of_handles",
"=",
"self",
".",
"__searcher",
".",
"search_ha... | Search for handles containing the specified key with the specified
value. The search terms are passed on to the reverse lookup servlet
as-is. The servlet is supposed to be case-insensitive, but if it
isn't, the wrong case will cause a :exc:`~b2handle.handleexceptions.ReverseLookupException`.
... | [
"Search",
"for",
"handles",
"containing",
"the",
"specified",
"key",
"with",
"the",
"specified",
"value",
".",
"The",
"search",
"terms",
"are",
"passed",
"on",
"to",
"the",
"reverse",
"lookup",
"servlet",
"as",
"-",
"is",
".",
"The",
"servlet",
"is",
"supp... | python | train | 50.975 |
spyder-ide/spyder | spyder/widgets/github/backend.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/github/backend.py#L205-L220 | def _store_token(self, token, remember=False):
"""Store token for future use."""
if token and remember:
try:
keyring.set_password('github', 'token', token)
except Exception:
if self._show_msgbox:
QMessageBox.warning(self.parent_... | [
"def",
"_store_token",
"(",
"self",
",",
"token",
",",
"remember",
"=",
"False",
")",
":",
"if",
"token",
"and",
"remember",
":",
"try",
":",
"keyring",
".",
"set_password",
"(",
"'github'",
",",
"'token'",
",",
"token",
")",
"except",
"Exception",
":",
... | Store token for future use. | [
"Store",
"token",
"for",
"future",
"use",
"."
] | python | train | 52.25 |
cloudera/cm_api | python/src/cm_shell/cmps.py | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_shell/cmps.py#L277-L292 | def service_action(self, service, action):
"Perform given action on service for the selected cluster"
try:
service = api.get_cluster(self.cluster).get_service(service)
except ApiException:
print("Service not found")
return None
if action == "start":
... | [
"def",
"service_action",
"(",
"self",
",",
"service",
",",
"action",
")",
":",
"try",
":",
"service",
"=",
"api",
".",
"get_cluster",
"(",
"self",
".",
"cluster",
")",
".",
"get_service",
"(",
"service",
")",
"except",
"ApiException",
":",
"print",
"(",
... | Perform given action on service for the selected cluster | [
"Perform",
"given",
"action",
"on",
"service",
"for",
"the",
"selected",
"cluster"
] | python | train | 29.375 |
gwastro/pycbc | pycbc/workflow/segment.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/segment.py#L286-L340 | def get_cumulative_veto_group_files(workflow, option, cat_files,
out_dir, execute_now=True, tags=None):
"""
Get the cumulative veto files that define the different backgrounds
we want to analyze, defined by groups of vetos.
Parameters
-----------
workflow : W... | [
"def",
"get_cumulative_veto_group_files",
"(",
"workflow",
",",
"option",
",",
"cat_files",
",",
"out_dir",
",",
"execute_now",
"=",
"True",
",",
"tags",
"=",
"None",
")",
":",
"if",
"tags",
"is",
"None",
":",
"tags",
"=",
"[",
"]",
"logging",
".",
"info... | Get the cumulative veto files that define the different backgrounds
we want to analyze, defined by groups of vetos.
Parameters
-----------
workflow : Workflow object
Instance of the workflow object
option : str
ini file option to use to get the veto groups
cat_files : FileList o... | [
"Get",
"the",
"cumulative",
"veto",
"files",
"that",
"define",
"the",
"different",
"backgrounds",
"we",
"want",
"to",
"analyze",
"defined",
"by",
"groups",
"of",
"vetos",
"."
] | python | train | 37.054545 |
limodou/uliweb | uliweb/lib/werkzeug/wrappers.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wrappers.py#L402-L411 | def args(self):
"""The parsed URL parameters. By default an
:class:`~werkzeug.datastructures.ImmutableMultiDict`
is returned from this function. This can be changed by setting
:attr:`parameter_storage_class` to a different type. This might
be necessary if the order of the form... | [
"def",
"args",
"(",
"self",
")",
":",
"return",
"url_decode",
"(",
"wsgi_get_bytes",
"(",
"self",
".",
"environ",
".",
"get",
"(",
"'QUERY_STRING'",
",",
"''",
")",
")",
",",
"self",
".",
"url_charset",
",",
"errors",
"=",
"self",
".",
"encoding_errors",... | The parsed URL parameters. By default an
:class:`~werkzeug.datastructures.ImmutableMultiDict`
is returned from this function. This can be changed by setting
:attr:`parameter_storage_class` to a different type. This might
be necessary if the order of the form data is important. | [
"The",
"parsed",
"URL",
"parameters",
".",
"By",
"default",
"an",
":",
"class",
":",
"~werkzeug",
".",
"datastructures",
".",
"ImmutableMultiDict",
"is",
"returned",
"from",
"this",
"function",
".",
"This",
"can",
"be",
"changed",
"by",
"setting",
":",
"attr... | python | train | 55.5 |
AtteqCom/zsl | src/zsl/task/task_decorator.py | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/task/task_decorator.py#L490-L505 | def forbid_web_access(f):
"""
Forbids running task using http request.
:param f: Callable
:return Callable
"""
@wraps(f)
def wrapper_fn(*args, **kwargs):
if isinstance(JobContext.get_current_context(), WebJobContext):
raise ForbiddenError('Access forbidden from web.')
... | [
"def",
"forbid_web_access",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper_fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"JobContext",
".",
"get_current_context",
"(",
")",
",",
"WebJobContext",
")... | Forbids running task using http request.
:param f: Callable
:return Callable | [
"Forbids",
"running",
"task",
"using",
"http",
"request",
"."
] | python | train | 22.5625 |
pypa/setuptools | setuptools/command/easy_install.py | https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2145-L2149 | def get_header(cls, script_text="", executable=None):
"""Create a #! line, getting options (if any) from script_text"""
cmd = cls.command_spec_class.best().from_param(executable)
cmd.install_options(script_text)
return cmd.as_header() | [
"def",
"get_header",
"(",
"cls",
",",
"script_text",
"=",
"\"\"",
",",
"executable",
"=",
"None",
")",
":",
"cmd",
"=",
"cls",
".",
"command_spec_class",
".",
"best",
"(",
")",
".",
"from_param",
"(",
"executable",
")",
"cmd",
".",
"install_options",
"("... | Create a #! line, getting options (if any) from script_text | [
"Create",
"a",
"#!",
"line",
"getting",
"options",
"(",
"if",
"any",
")",
"from",
"script_text"
] | python | train | 52.4 |
Jaymon/captain | captain/__main__.py | https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__main__.py#L15-L65 | def main(path):
'''scan path directory and any subdirectories for valid captain scripts'''
basepath = os.path.abspath(os.path.expanduser(str(path)))
echo.h2("Available scripts in {}".format(basepath))
echo.br()
for root_dir, dirs, files in os.walk(basepath, topdown=True):
for f in fnmatch.f... | [
"def",
"main",
"(",
"path",
")",
":",
"basepath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"str",
"(",
"path",
")",
")",
")",
"echo",
".",
"h2",
"(",
"\"Available scripts in {}\"",
".",
"format",
"(",
... | scan path directory and any subdirectories for valid captain scripts | [
"scan",
"path",
"directory",
"and",
"any",
"subdirectories",
"for",
"valid",
"captain",
"scripts"
] | python | valid | 38.313725 |
cisco-sas/kitty | kitty/model/low_level/container.py | https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/model/low_level/container.py#L280-L292 | def get_info(self):
'''
Get info regarding the current fuzzed enclosed node
:return: info dictionary
'''
field = self._current_field()
if field:
info = field.get_info()
info['path'] = '%s/%s' % (self.name if self.name else '<no name>', info['path'... | [
"def",
"get_info",
"(",
"self",
")",
":",
"field",
"=",
"self",
".",
"_current_field",
"(",
")",
"if",
"field",
":",
"info",
"=",
"field",
".",
"get_info",
"(",
")",
"info",
"[",
"'path'",
"]",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"name",
"if",
... | Get info regarding the current fuzzed enclosed node
:return: info dictionary | [
"Get",
"info",
"regarding",
"the",
"current",
"fuzzed",
"enclosed",
"node"
] | python | train | 30.538462 |
pydata/xarray | xarray/core/dataarray.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L817-L828 | def isel(self, indexers=None, drop=False, **indexers_kwargs):
"""Return a new DataArray whose dataset is given by integer indexing
along the specified dimension(s).
See Also
--------
Dataset.isel
DataArray.sel
"""
indexers = either_dict_or_kwargs(indexers... | [
"def",
"isel",
"(",
"self",
",",
"indexers",
"=",
"None",
",",
"drop",
"=",
"False",
",",
"*",
"*",
"indexers_kwargs",
")",
":",
"indexers",
"=",
"either_dict_or_kwargs",
"(",
"indexers",
",",
"indexers_kwargs",
",",
"'isel'",
")",
"ds",
"=",
"self",
"."... | Return a new DataArray whose dataset is given by integer indexing
along the specified dimension(s).
See Also
--------
Dataset.isel
DataArray.sel | [
"Return",
"a",
"new",
"DataArray",
"whose",
"dataset",
"is",
"given",
"by",
"integer",
"indexing",
"along",
"the",
"specified",
"dimension",
"(",
"s",
")",
"."
] | python | train | 37.5 |
grantmcconnaughey/Lintly | lintly/patch.py | https://github.com/grantmcconnaughey/Lintly/blob/73c1ee36740ac5bb2a32d3f24fca2a27f4d4e466/lintly/patch.py#L26-L70 | def changed_lines(self):
"""
A list of dicts in the format:
{
'file_name': str,
'content': str,
'line_number': int,
'position': int
}
"""
lines = []
file_name = ''
line_number = 0
... | [
"def",
"changed_lines",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"file_name",
"=",
"''",
"line_number",
"=",
"0",
"patch_position",
"=",
"-",
"1",
"found_first_information_line",
"=",
"False",
"for",
"i",
",",
"content",
"in",
"enumerate",
"(",
"self... | A list of dicts in the format:
{
'file_name': str,
'content': str,
'line_number': int,
'position': int
} | [
"A",
"list",
"of",
"dicts",
"in",
"the",
"format",
":",
"{",
"file_name",
":",
"str",
"content",
":",
"str",
"line_number",
":",
"int",
"position",
":",
"int",
"}"
] | python | train | 35.288889 |
googleapis/google-cloud-python | dns/google/cloud/dns/zone.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/zone.py#L138-L148 | def description(self, value):
"""Update description of the zone.
:type value: str
:param value: (Optional) new description
:raises: ValueError for invalid value types.
"""
if not isinstance(value, six.string_types) and value is not None:
raise ValueError("Pa... | [
"def",
"description",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
"and",
"value",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"\"Pass a string, or None\"",
")",
"self",
".",
... | Update description of the zone.
:type value: str
:param value: (Optional) new description
:raises: ValueError for invalid value types. | [
"Update",
"description",
"of",
"the",
"zone",
"."
] | python | train | 34.545455 |
klavinslab/coral | coral/analysis/_structure/nupack.py | https://github.com/klavinslab/coral/blob/17f59591211562a59a051f474cd6cecba4829df9/coral/analysis/_structure/nupack.py#L216-L290 | def pairs_multi(self, strands, cutoff=0.001, permutation=None, temp=37.0,
pseudo=False, material=None, dangles='some', sodium=1.0,
magnesium=0.0):
'''Compute the pair probabilities for an ordered complex of strands.
Runs the \'pairs\' command.
:param stra... | [
"def",
"pairs_multi",
"(",
"self",
",",
"strands",
",",
"cutoff",
"=",
"0.001",
",",
"permutation",
"=",
"None",
",",
"temp",
"=",
"37.0",
",",
"pseudo",
"=",
"False",
",",
"material",
"=",
"None",
",",
"dangles",
"=",
"'some'",
",",
"sodium",
"=",
"... | Compute the pair probabilities for an ordered complex of strands.
Runs the \'pairs\' command.
:param strands: List of strands to use as inputs to pairs -multi.
:type strands: list
:param permutation: The circular permutation of strands to test in
complex. e.g... | [
"Compute",
"the",
"pair",
"probabilities",
"for",
"an",
"ordered",
"complex",
"of",
"strands",
".",
"Runs",
"the",
"\\",
"pairs",
"\\",
"command",
"."
] | python | train | 49.093333 |
shaiguitar/snowclient.py | snowclient/snowrecord.py | https://github.com/shaiguitar/snowclient.py/blob/6bb513576d3b37612a7a4da225140d134f3e1c82/snowclient/snowrecord.py#L10-L17 | def tablename_from_link(klass, link):
"""
Helper method for URL's that look like /api/now/v1/table/FOO/sys_id etc.
"""
arr = link.split("/")
i = arr.index("table")
tn = arr[i+1]
return tn | [
"def",
"tablename_from_link",
"(",
"klass",
",",
"link",
")",
":",
"arr",
"=",
"link",
".",
"split",
"(",
"\"/\"",
")",
"i",
"=",
"arr",
".",
"index",
"(",
"\"table\"",
")",
"tn",
"=",
"arr",
"[",
"i",
"+",
"1",
"]",
"return",
"tn"
] | Helper method for URL's that look like /api/now/v1/table/FOO/sys_id etc. | [
"Helper",
"method",
"for",
"URL",
"s",
"that",
"look",
"like",
"/",
"api",
"/",
"now",
"/",
"v1",
"/",
"table",
"/",
"FOO",
"/",
"sys_id",
"etc",
"."
] | python | train | 29.5 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py#L34-L43 | def local_node_swbd_number(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
local_node = ET.SubElement(config, "local-node", xmlns="urn:brocade.com:mgmt:brocade-vcs")
swbd_number = ET.SubElement(local_node, "swbd-number")
swbd_number.text = kwargs... | [
"def",
"local_node_swbd_number",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"local_node",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"local-node\"",
",",
"xmlns",
"=",
"\"urn:brocad... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 42.1 |
materialsproject/pymatgen | pymatgen/analysis/structure_prediction/substitutor.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_prediction/substitutor.py#L69-L161 | def pred_from_structures(self, target_species, structures_list,
remove_duplicates=True, remove_existing=False):
"""
performs a structure prediction targeting compounds containing all of
the target_species, based on a list of structure (those structures
can fo... | [
"def",
"pred_from_structures",
"(",
"self",
",",
"target_species",
",",
"structures_list",
",",
"remove_duplicates",
"=",
"True",
",",
"remove_existing",
"=",
"False",
")",
":",
"target_species",
"=",
"get_el_sp",
"(",
"target_species",
")",
"result",
"=",
"[",
... | performs a structure prediction targeting compounds containing all of
the target_species, based on a list of structure (those structures
can for instance come from a database like the ICSD). It will return
all the structures formed by ionic substitutions with a probability
higher than th... | [
"performs",
"a",
"structure",
"prediction",
"targeting",
"compounds",
"containing",
"all",
"of",
"the",
"target_species",
"based",
"on",
"a",
"list",
"of",
"structure",
"(",
"those",
"structures",
"can",
"for",
"instance",
"come",
"from",
"a",
"database",
"like"... | python | train | 46.204301 |
kata198/indexedredis | IndexedRedis/__init__.py | https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/__init__.py#L538-L558 | def getUpdatedFields(self, cascadeObjects=False):
'''
getUpdatedFields - See changed fields.
@param cascadeObjects <bool> default False, if True will check if any foreign linked objects themselves have unsaved changes (recursively).
Otherwise, will just check if the pk has changed.
@return - a dicti... | [
"def",
"getUpdatedFields",
"(",
"self",
",",
"cascadeObjects",
"=",
"False",
")",
":",
"updatedFields",
"=",
"{",
"}",
"for",
"thisField",
"in",
"self",
".",
"FIELDS",
":",
"thisVal",
"=",
"object",
".",
"__getattribute__",
"(",
"self",
",",
"thisField",
"... | getUpdatedFields - See changed fields.
@param cascadeObjects <bool> default False, if True will check if any foreign linked objects themselves have unsaved changes (recursively).
Otherwise, will just check if the pk has changed.
@return - a dictionary of fieldName : tuple(old, new).
fieldName may be ... | [
"getUpdatedFields",
"-",
"See",
"changed",
"fields",
".",
"@param",
"cascadeObjects",
"<bool",
">",
"default",
"False",
"if",
"True",
"will",
"check",
"if",
"any",
"foreign",
"linked",
"objects",
"themselves",
"have",
"unsaved",
"changes",
"(",
"recursively",
")... | python | valid | 43.333333 |
saltstack/salt | salt/modules/azurearm_network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/azurearm_network.py#L1864-L1897 | def public_ip_address_get(name, resource_group, **kwargs):
'''
.. versionadded:: 2019.2.0
Get details about a specific public IP address.
:param name: The name of the public IP address to query.
:param resource_group: The resource group name assigned to the
public IP address.
CLI Exa... | [
"def",
"public_ip_address_get",
"(",
"name",
",",
"resource_group",
",",
"*",
"*",
"kwargs",
")",
":",
"expand",
"=",
"kwargs",
".",
"get",
"(",
"'expand'",
")",
"netconn",
"=",
"__utils__",
"[",
"'azurearm.get_client'",
"]",
"(",
"'network'",
",",
"*",
"*... | .. versionadded:: 2019.2.0
Get details about a specific public IP address.
:param name: The name of the public IP address to query.
:param resource_group: The resource group name assigned to the
public IP address.
CLI Example:
.. code-block:: bash
salt-call azurearm_network.pub... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train | 26.235294 |
nickmckay/LiPD-utilities | Python/lipd/timeseries.py | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/timeseries.py#L196-L236 | def _extract_pc(d, root, pc, whichtables):
"""
Extract all data from a PaleoData dictionary.
:param dict d: PaleoData dictionary
:param dict root: Time series root data
:param str pc: paleoData or chronData
:param str whichtables: all, meas, summ, or ens
:return list _ts: Time series
"""... | [
"def",
"_extract_pc",
"(",
"d",
",",
"root",
",",
"pc",
",",
"whichtables",
")",
":",
"logger_ts",
".",
"info",
"(",
"\"enter extract_pc\"",
")",
"_ts",
"=",
"[",
"]",
"try",
":",
"# For each table in pc",
"for",
"k",
",",
"v",
"in",
"d",
"[",
"pc",
... | Extract all data from a PaleoData dictionary.
:param dict d: PaleoData dictionary
:param dict root: Time series root data
:param str pc: paleoData or chronData
:param str whichtables: all, meas, summ, or ens
:return list _ts: Time series | [
"Extract",
"all",
"data",
"from",
"a",
"PaleoData",
"dictionary",
".",
":",
"param",
"dict",
"d",
":",
"PaleoData",
"dictionary",
":",
"param",
"dict",
"root",
":",
"Time",
"series",
"root",
"data",
":",
"param",
"str",
"pc",
":",
"paleoData",
"or",
"chr... | python | train | 53.268293 |
mfcloud/python-zvm-sdk | zvmsdk/utils.py | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/utils.py#L365-L379 | def wrap_invalid_resp_data_error(function):
"""Catch exceptions when using zvm client response data."""
@functools.wraps(function)
def decorated_function(*arg, **kwargs):
try:
return function(*arg, **kwargs)
except (ValueError, TypeError, IndexError, AttributeError,
... | [
"def",
"wrap_invalid_resp_data_error",
"(",
"function",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"function",
")",
"def",
"decorated_function",
"(",
"*",
"arg",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"function",
"(",
"*",
"arg",
",... | Catch exceptions when using zvm client response data. | [
"Catch",
"exceptions",
"when",
"using",
"zvm",
"client",
"response",
"data",
"."
] | python | train | 35.866667 |
ChrisCummins/labm8 | jsonutil.py | https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/jsonutil.py#L75-L87 | def write_file(path, data, format=True):
"""
Write JSON data to file.
Arguments:
path (str): Destination.
data (dict or list): JSON serializable data.
format (bool, optional): Pretty-print JSON data.
"""
if format:
fs.write_file(path, format_json(data))
else:
... | [
"def",
"write_file",
"(",
"path",
",",
"data",
",",
"format",
"=",
"True",
")",
":",
"if",
"format",
":",
"fs",
".",
"write_file",
"(",
"path",
",",
"format_json",
"(",
"data",
")",
")",
"else",
":",
"fs",
".",
"write_file",
"(",
"path",
",",
"json... | Write JSON data to file.
Arguments:
path (str): Destination.
data (dict or list): JSON serializable data.
format (bool, optional): Pretty-print JSON data. | [
"Write",
"JSON",
"data",
"to",
"file",
"."
] | python | train | 26.923077 |
VIVelev/PyDojoML | dojo/base/preprocessor.py | https://github.com/VIVelev/PyDojoML/blob/773fdce6866aa6decd306a5a85f94129fed816eb/dojo/base/preprocessor.py#L32-L50 | def get_params(self, *keys):
"""Returns the specified parameters for the current preprocessor.
Parameters:
-----------
keys : variable sized list, containing the names of the requested parameters
Returns:
--------
values : list or dictionary, if any `keys` are s... | [
"def",
"get_params",
"(",
"self",
",",
"*",
"keys",
")",
":",
"if",
"len",
"(",
"keys",
")",
"==",
"0",
":",
"return",
"vars",
"(",
"self",
")",
"else",
":",
"return",
"[",
"vars",
"(",
"self",
")",
"[",
"k",
"]",
"for",
"k",
"in",
"keys",
"]... | Returns the specified parameters for the current preprocessor.
Parameters:
-----------
keys : variable sized list, containing the names of the requested parameters
Returns:
--------
values : list or dictionary, if any `keys` are specified
those named parameters'... | [
"Returns",
"the",
"specified",
"parameters",
"for",
"the",
"current",
"preprocessor",
"."
] | python | train | 29.842105 |
NikolayDachev/jadm | lib/tabulate-0.7.2/tabulate.py | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/tabulate-0.7.2/tabulate.py#L466-L537 | def _normalize_tabular_data(tabular_data, headers):
"""Transform a supported data type to a list of lists, and a list of headers.
Supported tabular data types:
* list-of-lists or another iterable of iterables
* list of named tuples (usually used with headers="keys")
* 2D NumPy arrays
* NumP... | [
"def",
"_normalize_tabular_data",
"(",
"tabular_data",
",",
"headers",
")",
":",
"if",
"hasattr",
"(",
"tabular_data",
",",
"\"keys\"",
")",
"and",
"hasattr",
"(",
"tabular_data",
",",
"\"values\"",
")",
":",
"# dict-like and pandas.DataFrame?",
"if",
"hasattr",
"... | Transform a supported data type to a list of lists, and a list of headers.
Supported tabular data types:
* list-of-lists or another iterable of iterables
* list of named tuples (usually used with headers="keys")
* 2D NumPy arrays
* NumPy record arrays (usually used with headers="keys")
* d... | [
"Transform",
"a",
"supported",
"data",
"type",
"to",
"a",
"list",
"of",
"lists",
"and",
"a",
"list",
"of",
"headers",
"."
] | python | train | 37.25 |
vmware/pyvmomi | pyVmomi/VmomiSupport.py | https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVmomi/VmomiSupport.py#L1702-L1710 | def _GetActualName(name):
""" Note: Must be holding the _lazyLock """
if _allowCapitalizedNames:
name = UncapitalizeVmodlName(name)
for defMap in _dataDefMap, _managedDefMap, _enumDefMap:
dic = defMap.get(name)
if dic:
return dic[0]
return None | [
"def",
"_GetActualName",
"(",
"name",
")",
":",
"if",
"_allowCapitalizedNames",
":",
"name",
"=",
"UncapitalizeVmodlName",
"(",
"name",
")",
"for",
"defMap",
"in",
"_dataDefMap",
",",
"_managedDefMap",
",",
"_enumDefMap",
":",
"dic",
"=",
"defMap",
".",
"get",... | Note: Must be holding the _lazyLock | [
"Note",
":",
"Must",
"be",
"holding",
"the",
"_lazyLock"
] | python | train | 30.555556 |
ebroecker/canmatrix | src/canmatrix/formats/arxml.py | https://github.com/ebroecker/canmatrix/blob/d6150b7a648350f051a11c431e9628308c8d5593/src/canmatrix/formats/arxml.py#L1349-L1361 | def get_element_desc(element, ar_tree, ns):
# type: (_Element, _DocRoot, str) -> str
"""Get element description from XML."""
desc = get_child(element, "DESC", ar_tree, ns)
txt = get_child(desc, 'L-2[@L="DE"]', ar_tree, ns)
if txt is None:
txt = get_child(desc, 'L-2[@L="EN"]', ar_tree, ns)
... | [
"def",
"get_element_desc",
"(",
"element",
",",
"ar_tree",
",",
"ns",
")",
":",
"# type: (_Element, _DocRoot, str) -> str",
"desc",
"=",
"get_child",
"(",
"element",
",",
"\"DESC\"",
",",
"ar_tree",
",",
"ns",
")",
"txt",
"=",
"get_child",
"(",
"desc",
",",
... | Get element description from XML. | [
"Get",
"element",
"description",
"from",
"XML",
"."
] | python | train | 34.692308 |
materialsproject/pymatgen | pymatgen/analysis/chemenv/coordination_environments/structure_environments.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/chemenv/coordination_environments/structure_environments.py#L936-L963 | def as_dict(self):
"""
Bson-serializable dict representation of the StructureEnvironments object.
:return: Bson-serializable dict representation of the StructureEnvironments object.
"""
ce_list_dict = [{str(cn): [ce.as_dict() if ce is not None else None for ce in ce_dict[cn]]
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"ce_list_dict",
"=",
"[",
"{",
"str",
"(",
"cn",
")",
":",
"[",
"ce",
".",
"as_dict",
"(",
")",
"if",
"ce",
"is",
"not",
"None",
"else",
"None",
"for",
"ce",
"in",
"ce_dict",
"[",
"cn",
"]",
"]",
"for",
... | Bson-serializable dict representation of the StructureEnvironments object.
:return: Bson-serializable dict representation of the StructureEnvironments object. | [
"Bson",
"-",
"serializable",
"dict",
"representation",
"of",
"the",
"StructureEnvironments",
"object",
".",
":",
"return",
":",
"Bson",
"-",
"serializable",
"dict",
"representation",
"of",
"the",
"StructureEnvironments",
"object",
"."
] | python | train | 63.357143 |
UDST/urbansim | urbansim/models/dcm.py | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L1119-L1156 | def summed_probabilities(self, choosers, alternatives):
"""
Returns the sum of probabilities for alternatives across all
chooser segments.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
... | [
"def",
"summed_probabilities",
"(",
"self",
",",
"choosers",
",",
"alternatives",
")",
":",
"if",
"len",
"(",
"alternatives",
")",
"==",
"0",
"or",
"len",
"(",
"choosers",
")",
"==",
"0",
":",
"return",
"pd",
".",
"Series",
"(",
")",
"logger",
".",
"... | Returns the sum of probabilities for alternatives across all
chooser segments.
Parameters
----------
choosers : pandas.DataFrame
Table describing the agents making choices, e.g. households.
Must have a column matching the .segmentation_col attribute.
alte... | [
"Returns",
"the",
"sum",
"of",
"probabilities",
"for",
"alternatives",
"across",
"all",
"chooser",
"segments",
"."
] | python | train | 32.342105 |
theislab/scanpy | scanpy/readwrite.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/readwrite.py#L622-L637 | def get_used_files():
"""Get files used by processes with name scanpy."""
import psutil
loop_over_scanpy_processes = (proc for proc in psutil.process_iter()
if proc.name() == 'scanpy')
filenames = []
for proc in loop_over_scanpy_processes:
try:
f... | [
"def",
"get_used_files",
"(",
")",
":",
"import",
"psutil",
"loop_over_scanpy_processes",
"=",
"(",
"proc",
"for",
"proc",
"in",
"psutil",
".",
"process_iter",
"(",
")",
"if",
"proc",
".",
"name",
"(",
")",
"==",
"'scanpy'",
")",
"filenames",
"=",
"[",
"... | Get files used by processes with name scanpy. | [
"Get",
"files",
"used",
"by",
"processes",
"with",
"name",
"scanpy",
"."
] | python | train | 36.875 |
estnltk/estnltk | estnltk/text.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/text.py#L1180-L1184 | def spellcheck_results(self):
"""The list of True/False values denoting the correct spelling of words."""
if not self.is_tagged(WORDS):
self.tokenize_words()
return vabamorf.spellcheck(self.word_texts, suggestions=True) | [
"def",
"spellcheck_results",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_tagged",
"(",
"WORDS",
")",
":",
"self",
".",
"tokenize_words",
"(",
")",
"return",
"vabamorf",
".",
"spellcheck",
"(",
"self",
".",
"word_texts",
",",
"suggestions",
"=",
... | The list of True/False values denoting the correct spelling of words. | [
"The",
"list",
"of",
"True",
"/",
"False",
"values",
"denoting",
"the",
"correct",
"spelling",
"of",
"words",
"."
] | python | train | 50.2 |
CitrineInformatics/python-citrination-client | citrination_client/data/client.py | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L136-L151 | def get_ingest_status(self, dataset_id):
"""
Returns the current status of dataset ingestion. If any file uploaded to a dataset is in an error/failure state
this endpoint will return error/failure. If any files are still processing, will return processing.
:param dataset_id: Dataset i... | [
"def",
"get_ingest_status",
"(",
"self",
",",
"dataset_id",
")",
":",
"failure_message",
"=",
"\"Failed to create dataset ingest status for dataset {}\"",
".",
"format",
"(",
"dataset_id",
")",
"response",
"=",
"self",
".",
"_get_success_json",
"(",
"self",
".",
"_get... | Returns the current status of dataset ingestion. If any file uploaded to a dataset is in an error/failure state
this endpoint will return error/failure. If any files are still processing, will return processing.
:param dataset_id: Dataset identifier
:return: Status of dataset ingestion as a s... | [
"Returns",
"the",
"current",
"status",
"of",
"dataset",
"ingestion",
".",
"If",
"any",
"file",
"uploaded",
"to",
"a",
"dataset",
"is",
"in",
"an",
"error",
"/",
"failure",
"state",
"this",
"endpoint",
"will",
"return",
"error",
"/",
"failure",
".",
"If",
... | python | valid | 47.625 |
jrief/django-sass-processor | sass_processor/management/commands/compilescss.py | https://github.com/jrief/django-sass-processor/blob/3ca746258432b1428daee9a2b2f7e05a1e327492/sass_processor/management/commands/compilescss.py#L180-L197 | def find_sources(self):
"""
Look for Python sources available for the current configuration.
"""
app_configs = apps.get_app_configs()
for app_config in app_configs:
ignore_dirs = []
for root, dirs, files in os.walk(app_config.path):
if [Tru... | [
"def",
"find_sources",
"(",
"self",
")",
":",
"app_configs",
"=",
"apps",
".",
"get_app_configs",
"(",
")",
"for",
"app_config",
"in",
"app_configs",
":",
"ignore_dirs",
"=",
"[",
"]",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
... | Look for Python sources available for the current configuration. | [
"Look",
"for",
"Python",
"sources",
"available",
"for",
"the",
"current",
"configuration",
"."
] | python | train | 41.611111 |
statueofmike/rtsp | scripts/others/rts2.py | https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L221-L233 | def recvRtspReply(self):
"""Receive RTSP reply from the server."""
while True:
reply = self.rtspSocket.recv(1024)
if reply:
self.parseRtspReply(reply)
# Close the RTSP socket upon requesting Teardown
if self.requestSent == self.TEARDOWN:
self.rtspSocket.shutdown(socket.... | [
"def",
"recvRtspReply",
"(",
"self",
")",
":",
"while",
"True",
":",
"reply",
"=",
"self",
".",
"rtspSocket",
".",
"recv",
"(",
"1024",
")",
"if",
"reply",
":",
"self",
".",
"parseRtspReply",
"(",
"reply",
")",
"# Close the RTSP socket upon requesting Teardown... | Receive RTSP reply from the server. | [
"Receive",
"RTSP",
"reply",
"from",
"the",
"server",
"."
] | python | train | 28 |
akesterson/dpath-python | dpath/util.py | https://github.com/akesterson/dpath-python/blob/2d9117c5fc6870d546aadefb5bf3ab194f4c7411/dpath/util.py#L35-L47 | def new(obj, path, value, separator="/"):
"""
Set the element at the terminus of path to value, and create
it if it does not exist (as opposed to 'set' that can only
change existing keys).
path will NOT be treated like a glob. If it has globbing
characters in it, they will become part of the re... | [
"def",
"new",
"(",
"obj",
",",
"path",
",",
"value",
",",
"separator",
"=",
"\"/\"",
")",
":",
"pathlist",
"=",
"__safe_path__",
"(",
"path",
",",
"separator",
")",
"pathobj",
"=",
"dpath",
".",
"path",
".",
"path_types",
"(",
"obj",
",",
"pathlist",
... | Set the element at the terminus of path to value, and create
it if it does not exist (as opposed to 'set' that can only
change existing keys).
path will NOT be treated like a glob. If it has globbing
characters in it, they will become part of the resulting
keys | [
"Set",
"the",
"element",
"at",
"the",
"terminus",
"of",
"path",
"to",
"value",
"and",
"create",
"it",
"if",
"it",
"does",
"not",
"exist",
"(",
"as",
"opposed",
"to",
"set",
"that",
"can",
"only",
"change",
"existing",
"keys",
")",
"."
] | python | train | 38.230769 |
jelmer/python-fastimport | fastimport/parser.py | https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/parser.py#L587-L600 | def _path_pair(self, s):
"""Parse two paths separated by a space."""
# TODO: handle a space in the first path
if s.startswith(b'"'):
parts = s[1:].split(b'" ', 1)
else:
parts = s.split(b' ', 1)
if len(parts) != 2:
self.abort(errors.BadFormat, '... | [
"def",
"_path_pair",
"(",
"self",
",",
"s",
")",
":",
"# TODO: handle a space in the first path",
"if",
"s",
".",
"startswith",
"(",
"b'\"'",
")",
":",
"parts",
"=",
"s",
"[",
"1",
":",
"]",
".",
"split",
"(",
"b'\" '",
",",
"1",
")",
"else",
":",
"p... | Parse two paths separated by a space. | [
"Parse",
"two",
"paths",
"separated",
"by",
"a",
"space",
"."
] | python | train | 42.714286 |
jedie/DragonPy | dragonpy/utils/srecord_utils.py | https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L161-L172 | def parse_srec(srec):
"""
Extract the data portion of a given S-Record (without checksum)
Returns: the record type, the lenght of the data section, the write address, the data itself and the checksum
"""
record_type = srec[0:2]
data_len = srec[2:4]
addr_len = __ADDR_LEN.get(record_ty... | [
"def",
"parse_srec",
"(",
"srec",
")",
":",
"record_type",
"=",
"srec",
"[",
"0",
":",
"2",
"]",
"data_len",
"=",
"srec",
"[",
"2",
":",
"4",
"]",
"addr_len",
"=",
"__ADDR_LEN",
".",
"get",
"(",
"record_type",
")",
"*",
"2",
"addr",
"=",
"srec",
... | Extract the data portion of a given S-Record (without checksum)
Returns: the record type, the lenght of the data section, the write address, the data itself and the checksum | [
"Extract",
"the",
"data",
"portion",
"of",
"a",
"given",
"S",
"-",
"Record",
"(",
"without",
"checksum",
")",
"Returns",
":",
"the",
"record",
"type",
"the",
"lenght",
"of",
"the",
"data",
"section",
"the",
"write",
"address",
"the",
"data",
"itself",
"a... | python | train | 40.083333 |
thebigmunch/google-music | src/google_music/clients/mobileclient.py | https://github.com/thebigmunch/google-music/blob/d8a94dab462a1f063fbc1152187a73dc2f0e2a85/src/google_music/clients/mobileclient.py#L1512-L1525 | def situations(self, *, tz_offset=None):
"""Get a listing of situations.
Parameters:
tz_offset (int, Optional): A time zone offset from UTC in seconds.
"""
response = self._call(
mc_calls.ListenNowSituations,
tz_offset
)
situation_list = response.body.get('situations', [])
return situation_lis... | [
"def",
"situations",
"(",
"self",
",",
"*",
",",
"tz_offset",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_call",
"(",
"mc_calls",
".",
"ListenNowSituations",
",",
"tz_offset",
")",
"situation_list",
"=",
"response",
".",
"body",
".",
"get",
"(... | Get a listing of situations.
Parameters:
tz_offset (int, Optional): A time zone offset from UTC in seconds. | [
"Get",
"a",
"listing",
"of",
"situations",
"."
] | python | train | 22 |
hotdoc/hotdoc | hotdoc/extensions/c/clang/cindex.py | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/extensions/c/clang/cindex.py#L1974-L2010 | def argument_types(self):
"""Retrieve a container for the non-variadic arguments for this type.
The returned object is iterable and indexable. Each item in the
container is a Type instance.
"""
class ArgumentsIterator(collections.Sequence):
def __init__(self, parent)... | [
"def",
"argument_types",
"(",
"self",
")",
":",
"class",
"ArgumentsIterator",
"(",
"collections",
".",
"Sequence",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"parent",
")",
":",
"self",
".",
"parent",
"=",
"parent",
"self",
".",
"length",
"=",
"None"... | Retrieve a container for the non-variadic arguments for this type.
The returned object is iterable and indexable. Each item in the
container is a Type instance. | [
"Retrieve",
"a",
"container",
"for",
"the",
"non",
"-",
"variadic",
"arguments",
"for",
"this",
"type",
"."
] | python | train | 36.648649 |
apache/incubator-mxnet | python/mxnet/context.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/context.py#L244-L259 | def num_gpus():
"""Query CUDA for the number of GPUs present.
Raises
------
Will raise an exception on any CUDA error.
Returns
-------
count : int
The number of GPUs.
"""
count = ctypes.c_int()
check_call(_LIB.MXGetGPUCount(ctypes.byref(count)))
return count.value | [
"def",
"num_gpus",
"(",
")",
":",
"count",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXGetGPUCount",
"(",
"ctypes",
".",
"byref",
"(",
"count",
")",
")",
")",
"return",
"count",
".",
"value"
] | Query CUDA for the number of GPUs present.
Raises
------
Will raise an exception on any CUDA error.
Returns
-------
count : int
The number of GPUs. | [
"Query",
"CUDA",
"for",
"the",
"number",
"of",
"GPUs",
"present",
"."
] | python | train | 19 |
bhmm/bhmm | bhmm/api.py | https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/api.py#L97-L127 | def gaussian_hmm(pi, P, means, sigmas):
""" Initializes a 1D-Gaussian HMM
Parameters
----------
pi : ndarray(nstates, )
Initial distribution.
P : ndarray(nstates,nstates)
Hidden transition matrix
means : ndarray(nstates, )
Means of Gaussian output distributions
sigma... | [
"def",
"gaussian_hmm",
"(",
"pi",
",",
"P",
",",
"means",
",",
"sigmas",
")",
":",
"from",
"bhmm",
".",
"hmm",
".",
"gaussian_hmm",
"import",
"GaussianHMM",
"from",
"bhmm",
".",
"output_models",
".",
"gaussian",
"import",
"GaussianOutputModel",
"# count states... | Initializes a 1D-Gaussian HMM
Parameters
----------
pi : ndarray(nstates, )
Initial distribution.
P : ndarray(nstates,nstates)
Hidden transition matrix
means : ndarray(nstates, )
Means of Gaussian output distributions
sigmas : ndarray(nstates, )
Standard deviatio... | [
"Initializes",
"a",
"1D",
"-",
"Gaussian",
"HMM"
] | python | train | 35.580645 |
gwastro/pycbc | pycbc/conversions.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/conversions.py#L1274-L1313 | def nltides_coefs(amplitude, n, m1, m2):
"""Calculate the coefficents needed to compute the
shift in t(f) and phi(f) due to non-linear tides.
Parameters
----------
amplitude: float
Amplitude of effect
n: float
Growth dependence of effect
m1: float
Mass of component 1... | [
"def",
"nltides_coefs",
"(",
"amplitude",
",",
"n",
",",
"m1",
",",
"m2",
")",
":",
"# Use 100.0 Hz as a reference frequency",
"f_ref",
"=",
"100.0",
"# Calculate chirp mass",
"mc",
"=",
"mchirp_from_mass1_mass2",
"(",
"m1",
",",
"m2",
")",
"mc",
"*=",
"lal",
... | Calculate the coefficents needed to compute the
shift in t(f) and phi(f) due to non-linear tides.
Parameters
----------
amplitude: float
Amplitude of effect
n: float
Growth dependence of effect
m1: float
Mass of component 1
m2: float
Mass of component 2
... | [
"Calculate",
"the",
"coefficents",
"needed",
"to",
"compute",
"the",
"shift",
"in",
"t",
"(",
"f",
")",
"and",
"phi",
"(",
"f",
")",
"due",
"to",
"non",
"-",
"linear",
"tides",
"."
] | python | train | 26.375 |
angr/angr | angr/exploration_techniques/tracer.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/exploration_techniques/tracer.py#L459-L470 | def _grab_concretization_results(cls, state):
"""
Grabs the concretized result so we can add the constraint ourselves.
"""
# only grab ones that match the constrained addrs
if cls._should_add_constraints(state):
addr = state.inspect.address_concretization_expr
... | [
"def",
"_grab_concretization_results",
"(",
"cls",
",",
"state",
")",
":",
"# only grab ones that match the constrained addrs",
"if",
"cls",
".",
"_should_add_constraints",
"(",
"state",
")",
":",
"addr",
"=",
"state",
".",
"inspect",
".",
"address_concretization_expr",... | Grabs the concretized result so we can add the constraint ourselves. | [
"Grabs",
"the",
"concretized",
"result",
"so",
"we",
"can",
"add",
"the",
"constraint",
"ourselves",
"."
] | python | train | 46.916667 |
apache/spark | python/pyspark/rdd.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2052-L2063 | def subtract(self, other, numPartitions=None):
"""
Return each value in C{self} that is not contained in C{other}.
>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 3)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.subtract(y).collect())
[('a', ... | [
"def",
"subtract",
"(",
"self",
",",
"other",
",",
"numPartitions",
"=",
"None",
")",
":",
"# note: here 'True' is just a placeholder",
"rdd",
"=",
"other",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"x",
",",
"True",
")",
")",
"return",
"self",
".",
"map... | Return each value in C{self} that is not contained in C{other}.
>>> x = sc.parallelize([("a", 1), ("b", 4), ("b", 5), ("a", 3)])
>>> y = sc.parallelize([("a", 3), ("c", None)])
>>> sorted(x.subtract(y).collect())
[('a', 1), ('b', 4), ('b', 5)] | [
"Return",
"each",
"value",
"in",
"C",
"{",
"self",
"}",
"that",
"is",
"not",
"contained",
"in",
"C",
"{",
"other",
"}",
"."
] | python | train | 43.75 |
jobovy/galpy | galpy/df/quasiisothermaldf.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/quasiisothermaldf.py#L2530-L2532 | def _vmomentsurfaceMCIntegrand(vz,vR,vT,R,z,df,sigmaR1,gamma,sigmaz1,mvT,n,m,o):
"""Internal function that is the integrand for the vmomentsurface mass integration"""
return vR**n*vT**m*vz**o*df(R,vR*sigmaR1,vT*sigmaR1*gamma,z,vz*sigmaz1,use_physical=False)*numpy.exp(vR**2./2.+(vT-mvT)**2./2.+vz**2./2.) | [
"def",
"_vmomentsurfaceMCIntegrand",
"(",
"vz",
",",
"vR",
",",
"vT",
",",
"R",
",",
"z",
",",
"df",
",",
"sigmaR1",
",",
"gamma",
",",
"sigmaz1",
",",
"mvT",
",",
"n",
",",
"m",
",",
"o",
")",
":",
"return",
"vR",
"**",
"n",
"*",
"vT",
"**",
... | Internal function that is the integrand for the vmomentsurface mass integration | [
"Internal",
"function",
"that",
"is",
"the",
"integrand",
"for",
"the",
"vmomentsurface",
"mass",
"integration"
] | python | train | 103.333333 |
Tanganelli/CoAPthon3 | coapthon/messages/response.py | https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/messages/response.py#L55-L66 | def location_query(self):
"""
Return the Location-Query of the response.
:rtype : String
:return: the Location-Query option
"""
value = []
for option in self.options:
if option.number == defines.OptionRegistry.LOCATION_QUERY.number:
va... | [
"def",
"location_query",
"(",
"self",
")",
":",
"value",
"=",
"[",
"]",
"for",
"option",
"in",
"self",
".",
"options",
":",
"if",
"option",
".",
"number",
"==",
"defines",
".",
"OptionRegistry",
".",
"LOCATION_QUERY",
".",
"number",
":",
"value",
".",
... | Return the Location-Query of the response.
:rtype : String
:return: the Location-Query option | [
"Return",
"the",
"Location",
"-",
"Query",
"of",
"the",
"response",
"."
] | python | train | 29.5 |
rmorshea/spectate | spectate/core.py | https://github.com/rmorshea/spectate/blob/79bd84dd8d00889015ce1d1e190db865a02cdb93/spectate/core.py#L74-L117 | def callback(self, name, before=None, after=None):
"""Add a callback pair to this spectator.
You can specify, with keywords, whether each callback should be triggered
before, and/or or after a given method is called - hereafter refered to as
"beforebacks" and "afterbacks" respectively.
... | [
"def",
"callback",
"(",
"self",
",",
"name",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"for",
"name",
"in",
"name",
":",
"self",
".",
"callback... | Add a callback pair to this spectator.
You can specify, with keywords, whether each callback should be triggered
before, and/or or after a given method is called - hereafter refered to as
"beforebacks" and "afterbacks" respectively.
Parameters
----------
name: str
... | [
"Add",
"a",
"callback",
"pair",
"to",
"this",
"spectator",
"."
] | python | train | 51.954545 |
jobovy/galpy | galpy/util/multi.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/util/multi.py#L82-L126 | def run_tasks(procs, err_q, out_q, num):
"""
A function that executes populated processes and processes
the resultant array. Checks error queue for any exceptions.
:param procs: list of Process objects
:param out_q: thread-safe output queue
:param err_q: thread-safe queue to populate on exception
:param ... | [
"def",
"run_tasks",
"(",
"procs",
",",
"err_q",
",",
"out_q",
",",
"num",
")",
":",
"# function to terminate processes that are still running.",
"die",
"=",
"(",
"lambda",
"vals",
":",
"[",
"val",
".",
"terminate",
"(",
")",
"for",
"val",
"in",
"vals",
"if",... | A function that executes populated processes and processes
the resultant array. Checks error queue for any exceptions.
:param procs: list of Process objects
:param out_q: thread-safe output queue
:param err_q: thread-safe queue to populate on exception
:param num : length of resultant array | [
"A",
"function",
"that",
"executes",
"populated",
"processes",
"and",
"processes",
"the",
"resultant",
"array",
".",
"Checks",
"error",
"queue",
"for",
"any",
"exceptions",
"."
] | python | train | 24.755556 |
pywbem/pywbem | pywbem_mock/_wbemconnection_mock.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem_mock/_wbemconnection_mock.py#L846-L905 | def add_method_callback(self, classname, methodname, method_callback,
namespace=None,):
"""
Register a callback function for a CIM method that will be called when
the CIM method is invoked via `InvokeMethod`.
If the namespace does not exist, :exc:`~pywbem.CIM... | [
"def",
"add_method_callback",
"(",
"self",
",",
"classname",
",",
"methodname",
",",
"method_callback",
",",
"namespace",
"=",
"None",
",",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"self",
".",
"default_namespace",
"# Validate namespace"... | Register a callback function for a CIM method that will be called when
the CIM method is invoked via `InvokeMethod`.
If the namespace does not exist, :exc:`~pywbem.CIMError` with status
CIM_ERR_INVALID_NAMESPACE is raised.
Parameters:
classname (:term:`string`):
... | [
"Register",
"a",
"callback",
"function",
"for",
"a",
"CIM",
"method",
"that",
"will",
"be",
"called",
"when",
"the",
"CIM",
"method",
"is",
"invoked",
"via",
"InvokeMethod",
"."
] | python | train | 37.033333 |
razor-x/scipy-data_fitting | scipy_data_fitting/fit.py | https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/fit.py#L167-L189 | def limits(self):
"""
Limits to use for the independent variable whenever
creating a linespace, plot, etc.
Defaults to `(-x, x)` where `x` is the largest absolute value
of the data corresponding to the independent variable.
If no such values are negative, defaults to `(0... | [
"def",
"limits",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_limits'",
")",
":",
"xmax",
"=",
"max",
"(",
"abs",
"(",
"self",
".",
"data",
".",
"array",
"[",
"0",
"]",
")",
")",
"xmin",
"=",
"min",
"(",
"self",
".",
"d... | Limits to use for the independent variable whenever
creating a linespace, plot, etc.
Defaults to `(-x, x)` where `x` is the largest absolute value
of the data corresponding to the independent variable.
If no such values are negative, defaults to `(0, x)` instead. | [
"Limits",
"to",
"use",
"for",
"the",
"independent",
"variable",
"whenever",
"creating",
"a",
"linespace",
"plot",
"etc",
"."
] | python | train | 33.391304 |
Xion/taipan | taipan/objective/base.py | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/objective/base.py#L140-L172 | def _get_override_base(self, override_wrapper):
"""Retrieve the override base class from the
:class:`_OverriddenMethod` wrapper.
"""
base = override_wrapper.modifier.base
if not base:
return None
if is_class(base):
return base
# resolve th... | [
"def",
"_get_override_base",
"(",
"self",
",",
"override_wrapper",
")",
":",
"base",
"=",
"override_wrapper",
".",
"modifier",
".",
"base",
"if",
"not",
"base",
":",
"return",
"None",
"if",
"is_class",
"(",
"base",
")",
":",
"return",
"base",
"# resolve the ... | Retrieve the override base class from the
:class:`_OverriddenMethod` wrapper. | [
"Retrieve",
"the",
"override",
"base",
"class",
"from",
"the",
":",
"class",
":",
"_OverriddenMethod",
"wrapper",
"."
] | python | train | 38.333333 |
nickoala/telepot | telepot/__init__.py | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L728-L731 | def sendChatAction(self, chat_id, action):
""" See: https://core.telegram.org/bots/api#sendchataction """
p = _strip(locals())
return self._api_request('sendChatAction', _rectify(p)) | [
"def",
"sendChatAction",
"(",
"self",
",",
"chat_id",
",",
"action",
")",
":",
"p",
"=",
"_strip",
"(",
"locals",
"(",
")",
")",
"return",
"self",
".",
"_api_request",
"(",
"'sendChatAction'",
",",
"_rectify",
"(",
"p",
")",
")"
] | See: https://core.telegram.org/bots/api#sendchataction | [
"See",
":",
"https",
":",
"//",
"core",
".",
"telegram",
".",
"org",
"/",
"bots",
"/",
"api#sendchataction"
] | python | train | 50.75 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L356-L377 | def fault_zone(self, zone, simulate_wire_problem=False):
"""
Faults a zone if we are emulating a zone expander.
:param zone: zone to fault
:type zone: int
:param simulate_wire_problem: Whether or not to simulate a wire fault
:type simulate_wire_problem: bool
"""
... | [
"def",
"fault_zone",
"(",
"self",
",",
"zone",
",",
"simulate_wire_problem",
"=",
"False",
")",
":",
"# Allow ourselves to also be passed an address/channel combination",
"# for zone expanders.",
"#",
"# Format (expander index, channel)",
"if",
"isinstance",
"(",
"zone",
",",... | Faults a zone if we are emulating a zone expander.
:param zone: zone to fault
:type zone: int
:param simulate_wire_problem: Whether or not to simulate a wire fault
:type simulate_wire_problem: bool | [
"Faults",
"a",
"zone",
"if",
"we",
"are",
"emulating",
"a",
"zone",
"expander",
"."
] | python | train | 32.727273 |
aetros/aetros-cli | aetros/backend.py | https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1311-L1327 | def load_job_from_ref(self):
"""
Loads the job.json into self.job
"""
if not self.job_id:
raise Exception('Job not loaded yet. Use load(id) first.')
if not os.path.exists(self.git.work_tree + '/aetros/job.json'):
raise Exception('Could not load aetros/job... | [
"def",
"load_job_from_ref",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"job_id",
":",
"raise",
"Exception",
"(",
"'Job not loaded yet. Use load(id) first.'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"git",
".",
"work_tree",... | Loads the job.json into self.job | [
"Loads",
"the",
"job",
".",
"json",
"into",
"self",
".",
"job"
] | python | train | 43.823529 |
paylogic/pip-accel | pip_accel/__init__.py | https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/__init__.py#L414-L506 | def get_pip_requirement_set(self, arguments, use_remote_index, use_wheels=False):
"""
Get the unpacked requirement(s) specified by the caller by running pip.
:param arguments: The command line arguments to ``pip install ...`` (a
list of strings).
:param use_rem... | [
"def",
"get_pip_requirement_set",
"(",
"self",
",",
"arguments",
",",
"use_remote_index",
",",
"use_wheels",
"=",
"False",
")",
":",
"# Compose the pip command line arguments. This is where a lot of the",
"# core logic of pip-accel is hidden and it uses some esoteric features",
"# of... | Get the unpacked requirement(s) specified by the caller by running pip.
:param arguments: The command line arguments to ``pip install ...`` (a
list of strings).
:param use_remote_index: A boolean indicating whether pip is allowed to
connect to ... | [
"Get",
"the",
"unpacked",
"requirement",
"(",
"s",
")",
"specified",
"by",
"the",
"caller",
"by",
"running",
"pip",
"."
] | python | train | 61.537634 |
ClericPy/torequests | torequests/dummy.py | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/dummy.py#L287-L290 | def done_tasks(self):
"""Return tasks in loop which its state is not pending."""
tasks = [task for task in self.all_tasks if task._state != NewTask._PENDING]
return tasks | [
"def",
"done_tasks",
"(",
"self",
")",
":",
"tasks",
"=",
"[",
"task",
"for",
"task",
"in",
"self",
".",
"all_tasks",
"if",
"task",
".",
"_state",
"!=",
"NewTask",
".",
"_PENDING",
"]",
"return",
"tasks"
] | Return tasks in loop which its state is not pending. | [
"Return",
"tasks",
"in",
"loop",
"which",
"its",
"state",
"is",
"not",
"pending",
"."
] | python | train | 47.75 |
Jajcus/pyxmpp2 | pyxmpp2/xmppstringprep.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/xmppstringprep.py#L173-L180 | def prohibit(self, data):
"""Checks for prohibited characters."""
for char in data:
for lookup in self.prohibited:
if lookup(char):
raise StringprepError("Prohibited character: {0!r}"
.format(... | [
"def",
"prohibit",
"(",
"self",
",",
"data",
")",
":",
"for",
"char",
"in",
"data",
":",
"for",
"lookup",
"in",
"self",
".",
"prohibited",
":",
"if",
"lookup",
"(",
"char",
")",
":",
"raise",
"StringprepError",
"(",
"\"Prohibited character: {0!r}\"",
".",
... | Checks for prohibited characters. | [
"Checks",
"for",
"prohibited",
"characters",
"."
] | python | valid | 42.375 |
google/grr | grr/server/grr_response_server/hunts/implementation.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunts/implementation.py#L465-L508 | def _CallFlowRelational(self,
flow_name=None,
args=None,
runner_args=None,
client_id=None,
**kwargs):
"""Creates a new flow and send its responses to a state.
This creates a new flo... | [
"def",
"_CallFlowRelational",
"(",
"self",
",",
"flow_name",
"=",
"None",
",",
"args",
"=",
"None",
",",
"runner_args",
"=",
"None",
",",
"client_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"client_id",
",",
"rdfvalue",
... | Creates a new flow and send its responses to a state.
This creates a new flow. The flow may send back many responses which will be
queued by the framework until the flow terminates. The final status message
will cause the entire transaction to be committed to the specified state.
Args:
flow_nam... | [
"Creates",
"a",
"new",
"flow",
"and",
"send",
"its",
"responses",
"to",
"a",
"state",
"."
] | python | train | 34.818182 |
SBRG/ssbio | ssbio/protein/sequence/properties/cctop.py | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/cctop.py#L39-L58 | def cctop_save_xml(jobid, outpath):
"""Save the CCTOP results file in XML format.
Args:
jobid (str): Job ID obtained when job was submitted
outpath (str): Path to output filename
Returns:
str: Path to output filename
"""
status = cctop_check_status(jobid=jobid)
if stat... | [
"def",
"cctop_save_xml",
"(",
"jobid",
",",
"outpath",
")",
":",
"status",
"=",
"cctop_check_status",
"(",
"jobid",
"=",
"jobid",
")",
"if",
"status",
"==",
"'Finished'",
":",
"result",
"=",
"'http://cctop.enzim.ttk.mta.hu/php/result.php?jobId={}'",
".",
"format",
... | Save the CCTOP results file in XML format.
Args:
jobid (str): Job ID obtained when job was submitted
outpath (str): Path to output filename
Returns:
str: Path to output filename | [
"Save",
"the",
"CCTOP",
"results",
"file",
"in",
"XML",
"format",
"."
] | python | train | 32.5 |
andrewramsay/sk8-drivers | pysk8/pysk8/util.py | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/pysk8/util.py#L14-L32 | def fmt_addr_raw(addr, reverse=True):
"""Given a string containing a xx:xx:xx:xx:xx:xx address, return as a byte sequence.
Args:
addr (str): Bluetooth address in xx:xx:xx:xx:xx:xx format.
reverse (bool): True if the byte ordering should be reversed in the output.
Returns:
A bytearr... | [
"def",
"fmt_addr_raw",
"(",
"addr",
",",
"reverse",
"=",
"True",
")",
":",
"addr",
"=",
"addr",
".",
"replace",
"(",
"':'",
",",
"''",
")",
"raw_addr",
"=",
"[",
"int",
"(",
"addr",
"[",
"i",
":",
"i",
"+",
"2",
"]",
",",
"16",
")",
"for",
"i... | Given a string containing a xx:xx:xx:xx:xx:xx address, return as a byte sequence.
Args:
addr (str): Bluetooth address in xx:xx:xx:xx:xx:xx format.
reverse (bool): True if the byte ordering should be reversed in the output.
Returns:
A bytearray containing the converted address. | [
"Given",
"a",
"string",
"containing",
"a",
"xx",
":",
"xx",
":",
"xx",
":",
"xx",
":",
"xx",
":",
"xx",
"address",
"return",
"as",
"a",
"byte",
"sequence",
"."
] | python | train | 35.052632 |
spotify/luigi | luigi/contrib/hive.py | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hive.py#L335-L352 | def prepare_outputs(self, job):
"""
Called before job is started.
If output is a `FileSystemTarget`, create parent directories so the hive command won't fail
"""
outputs = flatten(job.output())
for o in outputs:
if isinstance(o, FileSystemTarget):
... | [
"def",
"prepare_outputs",
"(",
"self",
",",
"job",
")",
":",
"outputs",
"=",
"flatten",
"(",
"job",
".",
"output",
"(",
")",
")",
"for",
"o",
"in",
"outputs",
":",
"if",
"isinstance",
"(",
"o",
",",
"FileSystemTarget",
")",
":",
"parent_dir",
"=",
"o... | Called before job is started.
If output is a `FileSystemTarget`, create parent directories so the hive command won't fail | [
"Called",
"before",
"job",
"is",
"started",
"."
] | python | train | 41.555556 |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L73-L80 | def availability_zone_list(request):
"""Utility method to retrieve a list of availability zones."""
try:
return api.nova.availability_zone_list(request)
except Exception:
exceptions.handle(request,
_('Unable to retrieve Nova availability zones.'))
return [] | [
"def",
"availability_zone_list",
"(",
"request",
")",
":",
"try",
":",
"return",
"api",
".",
"nova",
".",
"availability_zone_list",
"(",
"request",
")",
"except",
"Exception",
":",
"exceptions",
".",
"handle",
"(",
"request",
",",
"_",
"(",
"'Unable to retriev... | Utility method to retrieve a list of availability zones. | [
"Utility",
"method",
"to",
"retrieve",
"a",
"list",
"of",
"availability",
"zones",
"."
] | python | train | 39 |
trailofbits/manticore | manticore/platforms/linux.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/linux.py#L1672-L1674 | def sys_mmap_pgoff(self, address, size, prot, flags, fd, offset):
"""Wrapper for mmap2"""
return self.sys_mmap2(address, size, prot, flags, fd, offset) | [
"def",
"sys_mmap_pgoff",
"(",
"self",
",",
"address",
",",
"size",
",",
"prot",
",",
"flags",
",",
"fd",
",",
"offset",
")",
":",
"return",
"self",
".",
"sys_mmap2",
"(",
"address",
",",
"size",
",",
"prot",
",",
"flags",
",",
"fd",
",",
"offset",
... | Wrapper for mmap2 | [
"Wrapper",
"for",
"mmap2"
] | python | valid | 55 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/zmq/__init__.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/zmq/__init__.py#L16-L46 | def patch_pyzmq():
"""backport a few patches from newer pyzmq
These can be removed as we bump our minimum pyzmq version
"""
import zmq
# ioloop.install, introduced in pyzmq 2.1.7
from zmq.eventloop import ioloop
def install():
import tornado.ioloop
tornado... | [
"def",
"patch_pyzmq",
"(",
")",
":",
"import",
"zmq",
"# ioloop.install, introduced in pyzmq 2.1.7",
"from",
"zmq",
".",
"eventloop",
"import",
"ioloop",
"def",
"install",
"(",
")",
":",
"import",
"tornado",
".",
"ioloop",
"tornado",
".",
"ioloop",
".",
"IOLoop"... | backport a few patches from newer pyzmq
These can be removed as we bump our minimum pyzmq version | [
"backport",
"a",
"few",
"patches",
"from",
"newer",
"pyzmq",
"These",
"can",
"be",
"removed",
"as",
"we",
"bump",
"our",
"minimum",
"pyzmq",
"version"
] | python | test | 27.870968 |
candango/firenado | firenado/config.py | https://github.com/candango/firenado/blob/4b1f628e485b521e161d64169c46a9818f26949f/firenado/config.py#L172-L223 | def process_app_config_section(config, app_config):
""" Processes the app section from a configuration data dict.
:param config: The config reference of the object that will hold the
configuration data from the config_data.
:param app_config: App section from a config data dict.
"""
if 'address... | [
"def",
"process_app_config_section",
"(",
"config",
",",
"app_config",
")",
":",
"if",
"'addresses'",
"in",
"app_config",
":",
"config",
".",
"app",
"[",
"'addresses'",
"]",
"=",
"app_config",
"[",
"'addresses'",
"]",
"if",
"'component'",
"in",
"app_config",
"... | Processes the app section from a configuration data dict.
:param config: The config reference of the object that will hold the
configuration data from the config_data.
:param app_config: App section from a config data dict. | [
"Processes",
"the",
"app",
"section",
"from",
"a",
"configuration",
"data",
"dict",
"."
] | python | train | 44.25 |
gem/oq-engine | openquake/hazardlib/site.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/site.py#L345-L370 | def filter(self, mask):
"""
Create a SiteCollection with only a subset of sites.
:param mask:
Numpy array of boolean values of the same length as the site
collection. ``True`` values should indicate that site with that
index should be included into the filter... | [
"def",
"filter",
"(",
"self",
",",
"mask",
")",
":",
"assert",
"len",
"(",
"mask",
")",
"==",
"len",
"(",
"self",
")",
",",
"(",
"len",
"(",
"mask",
")",
",",
"len",
"(",
"self",
")",
")",
"if",
"mask",
".",
"all",
"(",
")",
":",
"# all sites... | Create a SiteCollection with only a subset of sites.
:param mask:
Numpy array of boolean values of the same length as the site
collection. ``True`` values should indicate that site with that
index should be included into the filtered collection.
:returns:
... | [
"Create",
"a",
"SiteCollection",
"with",
"only",
"a",
"subset",
"of",
"sites",
"."
] | python | train | 43.615385 |
googledatalab/pydatalab | google/datalab/ml/_cloud_models.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_cloud_models.py#L224-L234 | def delete(self, version_name):
"""Delete a version of model.
Args:
version_name: the name of the version in short form, such as "v1".
"""
name = ('%s/versions/%s' % (self._full_model_name, version_name))
response = self._api.projects().models().versions().delete(name=name).execute()
if '... | [
"def",
"delete",
"(",
"self",
",",
"version_name",
")",
":",
"name",
"=",
"(",
"'%s/versions/%s'",
"%",
"(",
"self",
".",
"_full_model_name",
",",
"version_name",
")",
")",
"response",
"=",
"self",
".",
"_api",
".",
"projects",
"(",
")",
".",
"models",
... | Delete a version of model.
Args:
version_name: the name of the version in short form, such as "v1". | [
"Delete",
"a",
"version",
"of",
"model",
"."
] | python | train | 42.636364 |
OCR-D/core | ocrd_models/ocrd_models/ocrd_page_generateds.py | https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd_models/ocrd_models/ocrd_page_generateds.py#L9470-L9493 | def parseString(inString, silence=False):
'''Parse a string, create the object tree, and export it.
Arguments:
- inString -- A string. This XML fragment should not start
with an XML declaration containing an encoding.
- silence -- A boolean. If False, export the object.
Returns -- The root ... | [
"def",
"parseString",
"(",
"inString",
",",
"silence",
"=",
"False",
")",
":",
"parser",
"=",
"None",
"rootNode",
"=",
"parsexmlstring_",
"(",
"inString",
",",
"parser",
")",
"rootTag",
",",
"rootClass",
"=",
"get_root_tag",
"(",
"rootNode",
")",
"if",
"ro... | Parse a string, create the object tree, and export it.
Arguments:
- inString -- A string. This XML fragment should not start
with an XML declaration containing an encoding.
- silence -- A boolean. If False, export the object.
Returns -- The root object in the tree. | [
"Parse",
"a",
"string",
"create",
"the",
"object",
"tree",
"and",
"export",
"it",
"."
] | python | train | 37.416667 |
saltstack/salt | salt/modules/dig.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dig.py#L171-L223 | def SPF(domain, record='SPF', nameserver=None):
'''
Return the allowed IPv4 ranges in the SPF record for ``domain``.
If record is ``SPF`` and the SPF record is empty, the TXT record will be
searched automatically. If you know the domain uses TXT and not SPF,
specifying that will save a lookup.
... | [
"def",
"SPF",
"(",
"domain",
",",
"record",
"=",
"'SPF'",
",",
"nameserver",
"=",
"None",
")",
":",
"spf_re",
"=",
"re",
".",
"compile",
"(",
"r'(?:\\+|~)?(ip[46]|include):(.+)'",
")",
"cmd",
"=",
"[",
"'dig'",
",",
"'+short'",
",",
"six",
".",
"text_typ... | Return the allowed IPv4 ranges in the SPF record for ``domain``.
If record is ``SPF`` and the SPF record is empty, the TXT record will be
searched automatically. If you know the domain uses TXT and not SPF,
specifying that will save a lookup.
CLI Example:
.. code-block:: bash
salt ns1 di... | [
"Return",
"the",
"allowed",
"IPv4",
"ranges",
"in",
"the",
"SPF",
"record",
"for",
"domain",
"."
] | python | train | 32.886792 |
openstax/cnx-epub | cnxepub/models.py | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L108-L127 | def model_to_tree(model, title=None, lucent_id=TRANSLUCENT_BINDER_ID):
"""Given an model, build the tree::
{'id': <id>|'subcol', 'title': <title>, 'contents': [<tree>, ...]}
"""
id = model.ident_hash
if id is None and isinstance(model, TranslucentBinder):
id = lucent_id
md = model.... | [
"def",
"model_to_tree",
"(",
"model",
",",
"title",
"=",
"None",
",",
"lucent_id",
"=",
"TRANSLUCENT_BINDER_ID",
")",
":",
"id",
"=",
"model",
".",
"ident_hash",
"if",
"id",
"is",
"None",
"and",
"isinstance",
"(",
"model",
",",
"TranslucentBinder",
")",
":... | Given an model, build the tree::
{'id': <id>|'subcol', 'title': <title>, 'contents': [<tree>, ...]} | [
"Given",
"an",
"model",
"build",
"the",
"tree",
"::"
] | python | train | 38.35 |
python-diamond/Diamond | src/collectors/jcollectd/collectd_network.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L83-L111 | def decode_network_values(ptype, plen, buf):
"""Decodes a list of DS values in collectd network format
"""
nvalues = short.unpack_from(buf, header.size)[0]
off = header.size + short.size + nvalues
valskip = double.size
# Check whether our expected packet size is the reported one
assert ((va... | [
"def",
"decode_network_values",
"(",
"ptype",
",",
"plen",
",",
"buf",
")",
":",
"nvalues",
"=",
"short",
".",
"unpack_from",
"(",
"buf",
",",
"header",
".",
"size",
")",
"[",
"0",
"]",
"off",
"=",
"header",
".",
"size",
"+",
"short",
".",
"size",
... | Decodes a list of DS values in collectd network format | [
"Decodes",
"a",
"list",
"of",
"DS",
"values",
"in",
"collectd",
"network",
"format"
] | python | train | 38.310345 |
tensorflow/probability | tensorflow_probability/python/layers/distribution_layer.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L563-L583 | def new(params, event_size, num_components,
dtype=None, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'CategoricalMixtureOfOneHotCategorical',
[params, event_size, num_components]):
... | [
"def",
"new",
"(",
"params",
",",
"event_size",
",",
"num_components",
",",
"dtype",
"=",
"None",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'C... | Create the distribution instance from a `params` vector. | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | python | test | 42.380952 |
abarmat/python-oembed | oembed/__init__.py | https://github.com/abarmat/python-oembed/blob/bb3d14213e0ac91aa998af67182826b6f1529fe6/oembed/__init__.py#L339-L369 | def fetch(self, url):
'''
Fetch url and create a response object according to the mime-type.
Args:
url: The url to fetch data from
Returns:
OEmbedResponse object according to data fetched
'''
opener = self._urllib.build_opener()
opener.ad... | [
"def",
"fetch",
"(",
"self",
",",
"url",
")",
":",
"opener",
"=",
"self",
".",
"_urllib",
".",
"build_opener",
"(",
")",
"opener",
".",
"addheaders",
"=",
"self",
".",
"_requestHeaders",
".",
"items",
"(",
")",
"response",
"=",
"opener",
".",
"open",
... | Fetch url and create a response object according to the mime-type.
Args:
url: The url to fetch data from
Returns:
OEmbedResponse object according to data fetched | [
"Fetch",
"url",
"and",
"create",
"a",
"response",
"object",
"according",
"to",
"the",
"mime",
"-",
"type",
"."
] | python | train | 37 |
DataBiosphere/toil | src/toil/jobStores/aws/jobStore.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/jobStores/aws/jobStore.py#L746-L779 | def _bindDomain(self, domain_name, create=False, block=True):
"""
Return the Boto Domain object representing the SDB domain of the given name. If the
domain does not exist and `create` is True, it will be created.
:param str domain_name: the name of the domain to bind to
:param... | [
"def",
"_bindDomain",
"(",
"self",
",",
"domain_name",
",",
"create",
"=",
"False",
",",
"block",
"=",
"True",
")",
":",
"log",
".",
"debug",
"(",
"\"Binding to job store domain '%s'.\"",
",",
"domain_name",
")",
"retryargs",
"=",
"dict",
"(",
"predicate",
"... | Return the Boto Domain object representing the SDB domain of the given name. If the
domain does not exist and `create` is True, it will be created.
:param str domain_name: the name of the domain to bind to
:param bool create: True if domain should be created if it doesn't exist
:param... | [
"Return",
"the",
"Boto",
"Domain",
"object",
"representing",
"the",
"SDB",
"domain",
"of",
"the",
"given",
"name",
".",
"If",
"the",
"domain",
"does",
"not",
"exist",
"and",
"create",
"is",
"True",
"it",
"will",
"be",
"created",
"."
] | python | train | 43.235294 |
meyersj/geotweet | geotweet/twitter/stream_steps.py | https://github.com/meyersj/geotweet/blob/1a6b55f98adf34d1b91f172d9187d599616412d9/geotweet/twitter/stream_steps.py#L53-L58 | def validate_geotweet(self, record):
""" check that stream record is actual tweet with coordinates """
if record and self._validate('user', record) \
and self._validate('coordinates', record):
return True
return False | [
"def",
"validate_geotweet",
"(",
"self",
",",
"record",
")",
":",
"if",
"record",
"and",
"self",
".",
"_validate",
"(",
"'user'",
",",
"record",
")",
"and",
"self",
".",
"_validate",
"(",
"'coordinates'",
",",
"record",
")",
":",
"return",
"True",
"retur... | check that stream record is actual tweet with coordinates | [
"check",
"that",
"stream",
"record",
"is",
"actual",
"tweet",
"with",
"coordinates"
] | python | train | 44.166667 |
3DLIRIOUS/MeshLabXML | meshlabxml/transform.py | https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/transform.py#L363-L413 | def function(script, x_func='x', y_func='y', z_func='z'):
"""Geometric function using muparser lib to generate new Coordinates
You can change x, y, z for every vertex according to the function specified.
See help(mlx.muparser_ref) for muparser reference documentation.
It's possible to use the followin... | [
"def",
"function",
"(",
"script",
",",
"x_func",
"=",
"'x'",
",",
"y_func",
"=",
"'y'",
",",
"z_func",
"=",
"'z'",
")",
":",
"filter_xml",
"=",
"''",
".",
"join",
"(",
"[",
"' <filter name=\"Geometric Function\">\\n'",
",",
"' <Param name=\"x\" '",
",",
... | Geometric function using muparser lib to generate new Coordinates
You can change x, y, z for every vertex according to the function specified.
See help(mlx.muparser_ref) for muparser reference documentation.
It's possible to use the following per-vertex variables in the expression:
Variables (per ver... | [
"Geometric",
"function",
"using",
"muparser",
"lib",
"to",
"generate",
"new",
"Coordinates"
] | python | test | 33.882353 |
hannes-brt/hebel | hebel/pycuda_ops/cublas.py | https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2387-L2398 | def cublasDger(handle, m, n, alpha, x, incx, y, incy, A, lda):
"""
Rank-1 operation on real general matrix.
"""
status = _libcublas.cublasDger_v2(handle,
m, n,
ctypes.byref(ctypes.c_double(alpha)),
... | [
"def",
"cublasDger",
"(",
"handle",
",",
"m",
",",
"n",
",",
"alpha",
",",
"x",
",",
"incx",
",",
"y",
",",
"incy",
",",
"A",
",",
"lda",
")",
":",
"status",
"=",
"_libcublas",
".",
"cublasDger_v2",
"(",
"handle",
",",
"m",
",",
"n",
",",
"ctyp... | Rank-1 operation on real general matrix. | [
"Rank",
"-",
"1",
"operation",
"on",
"real",
"general",
"matrix",
"."
] | python | train | 35.916667 |
JohnVinyard/zounds | zounds/timeseries/audiosamples.py | https://github.com/JohnVinyard/zounds/blob/337b3f98753d09eaab1c72dcd37bb852a3fa5ac6/zounds/timeseries/audiosamples.py#L149-L158 | def mono(self):
"""
Return this instance summed to mono. If the instance is already mono,
this is a no-op.
"""
if self.channels == 1:
return self
x = self.sum(axis=1) * 0.5
y = x * 0.5
return AudioSamples(y, self.samplerate) | [
"def",
"mono",
"(",
"self",
")",
":",
"if",
"self",
".",
"channels",
"==",
"1",
":",
"return",
"self",
"x",
"=",
"self",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
"*",
"0.5",
"y",
"=",
"x",
"*",
"0.5",
"return",
"AudioSamples",
"(",
"y",
",",
"... | Return this instance summed to mono. If the instance is already mono,
this is a no-op. | [
"Return",
"this",
"instance",
"summed",
"to",
"mono",
".",
"If",
"the",
"instance",
"is",
"already",
"mono",
"this",
"is",
"a",
"no",
"-",
"op",
"."
] | python | train | 29.2 |
pydot/pydot-ng | pydot_ng/__init__.py | https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L402-L454 | def __find_executables(path):
"""Used by find_graphviz
path - single directory as a string
If any of the executables are found, it will return a dictionary
containing the program names as keys and their paths as values.
Otherwise returns None
"""
success = False
progs = {
"do... | [
"def",
"__find_executables",
"(",
"path",
")",
":",
"success",
"=",
"False",
"progs",
"=",
"{",
"\"dot\"",
":",
"\"\"",
",",
"\"twopi\"",
":",
"\"\"",
",",
"\"neato\"",
":",
"\"\"",
",",
"\"circo\"",
":",
"\"\"",
",",
"\"fdp\"",
":",
"\"\"",
",",
"\"sf... | Used by find_graphviz
path - single directory as a string
If any of the executables are found, it will return a dictionary
containing the program names as keys and their paths as values.
Otherwise returns None | [
"Used",
"by",
"find_graphviz"
] | python | train | 22.09434 |
funilrys/PyFunceble | PyFunceble/config.py | https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/config.py#L195-L225 | def _set_path_to_configs(cls, path_to_config):
"""
Set the paths to the configuration files.
:param path_to_config: The possible path to the config to load.
:type path_to_config: str
:return:
The path to the config to read (0), the path to the default
co... | [
"def",
"_set_path_to_configs",
"(",
"cls",
",",
"path_to_config",
")",
":",
"if",
"not",
"path_to_config",
".",
"endswith",
"(",
"PyFunceble",
".",
"directory_separator",
")",
":",
"# The path to the config does not ends with the directory separator.",
"# We initiate the defa... | Set the paths to the configuration files.
:param path_to_config: The possible path to the config to load.
:type path_to_config: str
:return:
The path to the config to read (0), the path to the default
configuration to read as fallback.(1)
:rtype: tuple | [
"Set",
"the",
"paths",
"to",
"the",
"configuration",
"files",
"."
] | python | test | 40.677419 |
paramiko/paramiko | paramiko/transport.py | https://github.com/paramiko/paramiko/blob/cf7d49d66f3b1fbc8b0853518a54050182b3b5eb/paramiko/transport.py#L1509-L1560 | def auth_interactive(self, username, handler, submethods=""):
"""
Authenticate to the server interactively. A handler is used to answer
arbitrary questions from the server. On many servers, this is just a
dumb wrapper around PAM.
This method will block until the authentication... | [
"def",
"auth_interactive",
"(",
"self",
",",
"username",
",",
"handler",
",",
"submethods",
"=",
"\"\"",
")",
":",
"if",
"(",
"not",
"self",
".",
"active",
")",
"or",
"(",
"not",
"self",
".",
"initial_kex_done",
")",
":",
"# we should never try to authentica... | Authenticate to the server interactively. A handler is used to answer
arbitrary questions from the server. On many servers, this is just a
dumb wrapper around PAM.
This method will block until the authentication succeeds or fails,
peroidically calling the handler asynchronously to get... | [
"Authenticate",
"to",
"the",
"server",
"interactively",
".",
"A",
"handler",
"is",
"used",
"to",
"answer",
"arbitrary",
"questions",
"from",
"the",
"server",
".",
"On",
"many",
"servers",
"this",
"is",
"just",
"a",
"dumb",
"wrapper",
"around",
"PAM",
"."
] | python | train | 48.269231 |
theiviaxx/python-perforce | perforce/models.py | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L585-L601 | def remove(self, rev, permanent=False):
"""Removes a revision from this changelist
:param rev: Revision to remove
:type rev: :class:`.Revision`
:param permanent: Whether or not we need to set the changelist to default
:type permanent: bool
"""
if not isinstance(r... | [
"def",
"remove",
"(",
"self",
",",
"rev",
",",
"permanent",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"rev",
",",
"Revision",
")",
":",
"raise",
"TypeError",
"(",
"'argument needs to be an instance of Revision'",
")",
"if",
"rev",
"not",
"in",
... | Removes a revision from this changelist
:param rev: Revision to remove
:type rev: :class:`.Revision`
:param permanent: Whether or not we need to set the changelist to default
:type permanent: bool | [
"Removes",
"a",
"revision",
"from",
"this",
"changelist"
] | python | train | 35.352941 |
consbio/parserutils | parserutils/urls.py | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/urls.py#L59-L77 | def url_to_parts(url):
""" Split url urlsplit style, but return path as a list and query as a dict """
if not url:
return None
scheme, netloc, path, query, fragment = _urlsplit(url)
if not path or path == '/':
path = []
else:
path = path.strip('/').split('/')
if not q... | [
"def",
"url_to_parts",
"(",
"url",
")",
":",
"if",
"not",
"url",
":",
"return",
"None",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
",",
"fragment",
"=",
"_urlsplit",
"(",
"url",
")",
"if",
"not",
"path",
"or",
"path",
"==",
"'/'",
":",
"pa... | Split url urlsplit style, but return path as a list and query as a dict | [
"Split",
"url",
"urlsplit",
"style",
"but",
"return",
"path",
"as",
"a",
"list",
"and",
"query",
"as",
"a",
"dict"
] | python | train | 23.473684 |
saltstack/salt | salt/modules/localemod.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L231-L251 | def avail(locale):
'''
Check if a locale is available.
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' locale.avail 'en_US.UTF-8'
'''
try:
normalized_locale = salt.utils.locales.normalize_locale(locale)
except IndexError:
log.error('Unabl... | [
"def",
"avail",
"(",
"locale",
")",
":",
"try",
":",
"normalized_locale",
"=",
"salt",
".",
"utils",
".",
"locales",
".",
"normalize_locale",
"(",
"locale",
")",
"except",
"IndexError",
":",
"log",
".",
"error",
"(",
"'Unable to validate locale \"%s\"'",
",",
... | Check if a locale is available.
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' locale.avail 'en_US.UTF-8' | [
"Check",
"if",
"a",
"locale",
"is",
"available",
"."
] | python | train | 28.238095 |
spacetelescope/drizzlepac | drizzlepac/util.py | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/util.py#L920-L935 | def update_input(filelist, ivmlist=None, removed_files=None):
"""
Removes files flagged to be removed from the input filelist.
Removes the corresponding ivm files if present.
"""
newfilelist = []
if removed_files == []:
return filelist, ivmlist
else:
sci_ivm = list(zip(filel... | [
"def",
"update_input",
"(",
"filelist",
",",
"ivmlist",
"=",
"None",
",",
"removed_files",
"=",
"None",
")",
":",
"newfilelist",
"=",
"[",
"]",
"if",
"removed_files",
"==",
"[",
"]",
":",
"return",
"filelist",
",",
"ivmlist",
"else",
":",
"sci_ivm",
"=",... | Removes files flagged to be removed from the input filelist.
Removes the corresponding ivm files if present. | [
"Removes",
"files",
"flagged",
"to",
"be",
"removed",
"from",
"the",
"input",
"filelist",
".",
"Removes",
"the",
"corresponding",
"ivm",
"files",
"if",
"present",
"."
] | python | train | 34.3125 |
briancappello/flask-unchained | flask_unchained/bundles/security/services/security_service.py | https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/security/services/security_service.py#L209-L227 | def send_email_confirmation_instructions(self, user):
"""
Sends the confirmation instructions email for the specified user.
Sends signal `confirm_instructions_sent`.
:param user: The user to send the instructions to.
"""
token = self.security_utils_service.generate_conf... | [
"def",
"send_email_confirmation_instructions",
"(",
"self",
",",
"user",
")",
":",
"token",
"=",
"self",
".",
"security_utils_service",
".",
"generate_confirmation_token",
"(",
"user",
")",
"confirmation_link",
"=",
"url_for",
"(",
"'security_controller.confirm_email'",
... | Sends the confirmation instructions email for the specified user.
Sends signal `confirm_instructions_sent`.
:param user: The user to send the instructions to. | [
"Sends",
"the",
"confirmation",
"instructions",
"email",
"for",
"the",
"specified",
"user",
"."
] | python | train | 46.578947 |
rix0rrr/gcl | gcl/util.py | https://github.com/rix0rrr/gcl/blob/4e3bccc978a9c60aaaffd20f6f291c4d23775cdf/gcl/util.py#L99-L149 | def walk(value, walker, path=None, seen=None):
"""Walks the _evaluated_ tree of the given GCL tuple.
The appropriate methods of walker will be invoked for every element in the
tree.
"""
seen = seen or set()
path = path or []
# Recursion
if id(value) in seen:
walker.visitRecursion(path)
return
... | [
"def",
"walk",
"(",
"value",
",",
"walker",
",",
"path",
"=",
"None",
",",
"seen",
"=",
"None",
")",
":",
"seen",
"=",
"seen",
"or",
"set",
"(",
")",
"path",
"=",
"path",
"or",
"[",
"]",
"# Recursion",
"if",
"id",
"(",
"value",
")",
"in",
"seen... | Walks the _evaluated_ tree of the given GCL tuple.
The appropriate methods of walker will be invoked for every element in the
tree. | [
"Walks",
"the",
"_evaluated_",
"tree",
"of",
"the",
"given",
"GCL",
"tuple",
"."
] | python | train | 24.411765 |
tensorlayer/tensorlayer | tensorlayer/prepro.py | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1009-L1041 | def shift_multi(
x, wrg=0.1, hrg=0.1, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shift images with the same arguments, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Par... | [
"def",
"shift_multi",
"(",
"x",
",",
"wrg",
"=",
"0.1",
",",
"hrg",
"=",
"0.1",
",",
"is_random",
"=",
"False",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
"=",
"'nearest'",
",",
"cval",
... | Shift images with the same arguments, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others : args
Se... | [
"Shift",
"images",
"with",
"the",
"same",
"arguments",
"randomly",
"or",
"non",
"-",
"randomly",
".",
"Usually",
"be",
"used",
"for",
"image",
"segmentation",
"which",
"x",
"=",
"[",
"X",
"Y",
"]",
"X",
"and",
"Y",
"should",
"be",
"matched",
"."
] | python | valid | 32.636364 |
Parsl/parsl | parsl/app/app.py | https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/app/app.py#L154-L186 | def bash_app(function=None, data_flow_kernel=None, walltime=60, cache=False, executors='all'):
"""Decorator function for making bash apps.
Parameters
----------
function : function
Do not pass this keyword argument directly. This is needed in order to allow for omitted parenthesis,
for ... | [
"def",
"bash_app",
"(",
"function",
"=",
"None",
",",
"data_flow_kernel",
"=",
"None",
",",
"walltime",
"=",
"60",
",",
"cache",
"=",
"False",
",",
"executors",
"=",
"'all'",
")",
":",
"from",
"parsl",
".",
"app",
".",
"bash",
"import",
"BashApp",
"def... | Decorator function for making bash apps.
Parameters
----------
function : function
Do not pass this keyword argument directly. This is needed in order to allow for omitted parenthesis,
for example, `@bash_app` if using all defaults or `@bash_app(walltime=120)`. If the
decorator is u... | [
"Decorator",
"function",
"for",
"making",
"bash",
"apps",
"."
] | python | valid | 45.121212 |
UDST/orca | orca/orca.py | https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1866-L1902 | def write_tables(fname, table_names=None, prefix=None, compress=False, local=False):
"""
Writes tables to a pandas.HDFStore file.
Parameters
----------
fname : str
File name for HDFStore. Will be opened in append mode and closed
at the end of this function.
table_names: list of ... | [
"def",
"write_tables",
"(",
"fname",
",",
"table_names",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"compress",
"=",
"False",
",",
"local",
"=",
"False",
")",
":",
"if",
"table_names",
"is",
"None",
":",
"table_names",
"=",
"list_tables",
"(",
")",
... | Writes tables to a pandas.HDFStore file.
Parameters
----------
fname : str
File name for HDFStore. Will be opened in append mode and closed
at the end of this function.
table_names: list of str, optional, default None
List of tables to write. If None, all registered tables will
... | [
"Writes",
"tables",
"to",
"a",
"pandas",
".",
"HDFStore",
"file",
"."
] | python | train | 36.891892 |
bachya/pyopenuv | example.py | https://github.com/bachya/pyopenuv/blob/f7c2f9dd99dd4e3b8b1f9e501ea17ce62a7ace46/example.py#L16-L41 | async def run(websession: ClientSession):
"""Run."""
try:
# Create a client:
client = Client(
'<API_KEY>',
39.7974509,
-104.8887227,
websession,
altitude=1609.3)
# Get current UV info:
print('CURRENT UV DATA:')
... | [
"async",
"def",
"run",
"(",
"websession",
":",
"ClientSession",
")",
":",
"try",
":",
"# Create a client:",
"client",
"=",
"Client",
"(",
"'<API_KEY>'",
",",
"39.7974509",
",",
"-",
"104.8887227",
",",
"websession",
",",
"altitude",
"=",
"1609.3",
")",
"# Ge... | Run. | [
"Run",
"."
] | python | train | 24.923077 |
troeger/opensubmit | executor/opensubmitexec/running.py | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L67-L75 | def get_exitstatus(self):
"""Get the exit status of the program execution.
Returns:
int: Exit status as reported by the operating system,
or None if it is not available.
"""
logger.debug("Exit status is {0}".format(self._spawn.exitstatus))
return sel... | [
"def",
"get_exitstatus",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Exit status is {0}\"",
".",
"format",
"(",
"self",
".",
"_spawn",
".",
"exitstatus",
")",
")",
"return",
"self",
".",
"_spawn",
".",
"exitstatus"
] | Get the exit status of the program execution.
Returns:
int: Exit status as reported by the operating system,
or None if it is not available. | [
"Get",
"the",
"exit",
"status",
"of",
"the",
"program",
"execution",
"."
] | python | train | 36.777778 |
bcbio/bcbio-nextgen | bcbio/structural/gatkcnv.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/gatkcnv.py#L34-L54 | def _run_paired(paired):
"""Run somatic variant calling pipeline.
"""
from bcbio.structural import titancna
work_dir = _sv_workdir(paired.tumor_data)
seg_files = model_segments(tz.get_in(["depth", "bins", "normalized"], paired.tumor_data),
work_dir, paired)
call_fi... | [
"def",
"_run_paired",
"(",
"paired",
")",
":",
"from",
"bcbio",
".",
"structural",
"import",
"titancna",
"work_dir",
"=",
"_sv_workdir",
"(",
"paired",
".",
"tumor_data",
")",
"seg_files",
"=",
"model_segments",
"(",
"tz",
".",
"get_in",
"(",
"[",
"\"depth\"... | Run somatic variant calling pipeline. | [
"Run",
"somatic",
"variant",
"calling",
"pipeline",
"."
] | python | train | 50.761905 |
aheadley/python-crunchyroll | crunchyroll/apis/meta.py | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L251-L256 | def list_manga_series(self, filter=None, content_type='jp_manga'):
"""Get a list of manga series
"""
result = self._manga_api.list_series(filter, content_type)
return result | [
"def",
"list_manga_series",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"content_type",
"=",
"'jp_manga'",
")",
":",
"result",
"=",
"self",
".",
"_manga_api",
".",
"list_series",
"(",
"filter",
",",
"content_type",
")",
"return",
"result"
] | Get a list of manga series | [
"Get",
"a",
"list",
"of",
"manga",
"series"
] | python | train | 33.5 |
ewels/MultiQC | multiqc/plots/table.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/plots/table.py#L52-L345 | def make_table (dt):
"""
Build the HTML needed for a MultiQC table.
:param data: MultiQC datatable object
"""
table_id = dt.pconfig.get('id', 'table_{}'.format(''.join(random.sample(letters, 4))) )
table_id = report.save_htmlid(table_id)
t_headers = OrderedDict()
t_modal_headers = Order... | [
"def",
"make_table",
"(",
"dt",
")",
":",
"table_id",
"=",
"dt",
".",
"pconfig",
".",
"get",
"(",
"'id'",
",",
"'table_{}'",
".",
"format",
"(",
"''",
".",
"join",
"(",
"random",
".",
"sample",
"(",
"letters",
",",
"4",
")",
")",
")",
")",
"table... | Build the HTML needed for a MultiQC table.
:param data: MultiQC datatable object | [
"Build",
"the",
"HTML",
"needed",
"for",
"a",
"MultiQC",
"table",
".",
":",
"param",
"data",
":",
"MultiQC",
"datatable",
"object"
] | python | train | 46.204082 |
itamarst/crochet | crochet/_eventloop.py | https://github.com/itamarst/crochet/blob/ecfc22cefa90f3dfbafa71883c1470e7294f2b6d/crochet/_eventloop.py#L365-L375 | def _common_setup(self):
"""
The minimal amount of setup done by both setup() and no_setup().
"""
self._started = True
self._reactor = self._reactorFactory()
self._registry = ResultRegistry()
# We want to unblock EventualResult regardless of how the reactor is
... | [
"def",
"_common_setup",
"(",
"self",
")",
":",
"self",
".",
"_started",
"=",
"True",
"self",
".",
"_reactor",
"=",
"self",
".",
"_reactorFactory",
"(",
")",
"self",
".",
"_registry",
"=",
"ResultRegistry",
"(",
")",
"# We want to unblock EventualResult regardles... | The minimal amount of setup done by both setup() and no_setup(). | [
"The",
"minimal",
"amount",
"of",
"setup",
"done",
"by",
"both",
"setup",
"()",
"and",
"no_setup",
"()",
"."
] | python | train | 40.818182 |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L218-L287 | def read_char_lengths(self, filename, electrode_filename):
"""Read characteristic lengths from the given file.
The file is expected to have either 1 or 4 entries/lines with
characteristic lengths > 0 (floats). If only one value is encountered,
it is used for all four entities. If four v... | [
"def",
"read_char_lengths",
"(",
"self",
",",
"filename",
",",
"electrode_filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"data",
"=",
"np",
".",
"atleast_1d",
"(",
"np",
".",
"loadtxt",
"(",
"filename",
")",
")"... | Read characteristic lengths from the given file.
The file is expected to have either 1 or 4 entries/lines with
characteristic lengths > 0 (floats). If only one value is encountered,
it is used for all four entities. If four values are encountered, they
are assigned, in order, to:
... | [
"Read",
"characteristic",
"lengths",
"from",
"the",
"given",
"file",
"."
] | python | train | 41.8 |
campbellr/smashrun-client | smashrun/client.py | https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L76-L102 | def get_activities(self, count=10, since=None, style='summary',
limit=None):
"""Iterate over all activities, from newest to oldest.
:param count: The number of results to retrieve per page. If set to
``None``, pagination is disabled.
:param since: R... | [
"def",
"get_activities",
"(",
"self",
",",
"count",
"=",
"10",
",",
"since",
"=",
"None",
",",
"style",
"=",
"'summary'",
",",
"limit",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"since",
":",
"params",
".",
"update",
"(",
"fromDate",
"=... | Iterate over all activities, from newest to oldest.
:param count: The number of results to retrieve per page. If set to
``None``, pagination is disabled.
:param since: Return only activities since this date. Can be either
a timestamp or a datetime object.
... | [
"Iterate",
"over",
"all",
"activities",
"from",
"newest",
"to",
"oldest",
"."
] | python | train | 41.296296 |
bitesofcode/projexui | projexui/widgets/xtreewidget/xtreewidgetdelegate.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidgetdelegate.py#L217-L251 | def drawDisplay(self, painter, option, rect, text):
"""
Overloads the drawDisplay method to render HTML if the rich text \
information is set to true.
:param painter | <QtGui.QPainter>
option | <QtGui.QStyleOptionItem>
rect ... | [
"def",
"drawDisplay",
"(",
"self",
",",
"painter",
",",
"option",
",",
"rect",
",",
"text",
")",
":",
"if",
"self",
".",
"showRichText",
"(",
")",
":",
"# create the document\r",
"doc",
"=",
"QtGui",
".",
"QTextDocument",
"(",
")",
"doc",
".",
"setTextWi... | Overloads the drawDisplay method to render HTML if the rich text \
information is set to true.
:param painter | <QtGui.QPainter>
option | <QtGui.QStyleOptionItem>
rect | <QtCore.QRect>
text | <str> | [
"Overloads",
"the",
"drawDisplay",
"method",
"to",
"render",
"HTML",
"if",
"the",
"rich",
"text",
"\\",
"information",
"is",
"set",
"to",
"true",
".",
":",
"param",
"painter",
"|",
"<QtGui",
".",
"QPainter",
">",
"option",
"|",
"<QtGui",
".",
"QStyleOption... | python | train | 43.428571 |
gamechanger/confluent_schema_registry_client | confluent_schema_registry_client/__init__.py | https://github.com/gamechanger/confluent_schema_registry_client/blob/ac9196e366724eeb2f19f1a169fd2f9a0c8d68ae/confluent_schema_registry_client/__init__.py#L68-L75 | def get_subject_version_ids(self, subject):
"""
Return the list of schema version ids which have been registered
under the given subject.
"""
res = requests.get(self._url('/subjects/{}/versions', subject))
raise_if_failed(res)
return res.json() | [
"def",
"get_subject_version_ids",
"(",
"self",
",",
"subject",
")",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"_url",
"(",
"'/subjects/{}/versions'",
",",
"subject",
")",
")",
"raise_if_failed",
"(",
"res",
")",
"return",
"res",
".",
"json... | Return the list of schema version ids which have been registered
under the given subject. | [
"Return",
"the",
"list",
"of",
"schema",
"version",
"ids",
"which",
"have",
"been",
"registered",
"under",
"the",
"given",
"subject",
"."
] | python | train | 36.625 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.