repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
balloob/pychromecast | pychromecast/controllers/multizone.py | https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L135-L137 | def deregister_listener(self, member_uuid, listener):
""" Deregister listener for audio group changes of cast uuid."""
self._casts[str(member_uuid)]['listeners'].remove(listener) | [
"def",
"deregister_listener",
"(",
"self",
",",
"member_uuid",
",",
"listener",
")",
":",
"self",
".",
"_casts",
"[",
"str",
"(",
"member_uuid",
")",
"]",
"[",
"'listeners'",
"]",
".",
"remove",
"(",
"listener",
")"
] | Deregister listener for audio group changes of cast uuid. | [
"Deregister",
"listener",
"for",
"audio",
"group",
"changes",
"of",
"cast",
"uuid",
"."
] | python | train |
connectordb/connectordb-python | connectordb/_connection.py | https://github.com/connectordb/connectordb-python/blob/2092b0cb30898139a247176bcf433d5a4abde7cb/connectordb/_connection.py#L129-L134 | def create(self, path, data=None):
"""Send a POST CRUD API request to the given path using the given data which will be converted
to json"""
return self.handleresult(self.r.post(urljoin(self.url + CRUD_PATH,
path),
... | [
"def",
"create",
"(",
"self",
",",
"path",
",",
"data",
"=",
"None",
")",
":",
"return",
"self",
".",
"handleresult",
"(",
"self",
".",
"r",
".",
"post",
"(",
"urljoin",
"(",
"self",
".",
"url",
"+",
"CRUD_PATH",
",",
"path",
")",
",",
"data",
"=... | Send a POST CRUD API request to the given path using the given data which will be converted
to json | [
"Send",
"a",
"POST",
"CRUD",
"API",
"request",
"to",
"the",
"given",
"path",
"using",
"the",
"given",
"data",
"which",
"will",
"be",
"converted",
"to",
"json"
] | python | test |
casastorta/python-sar | sar/parser.py | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/parser.py#L310-L403 | def __split_info(self, info_part, patternsname, patterns):
"""
Splits info from SAR parts into logical stuff :-)
:param info_part: Part of SAR output we want to split into usable data
:param patternsname: ???
:param patterns: ???
:return: ``List``-style info from SAR file... | [
"def",
"__split_info",
"(",
"self",
",",
"info_part",
",",
"patternsname",
",",
"patterns",
")",
":",
"pattern",
"=",
"patterns",
"[",
"'PATTERN'",
"]",
"if",
"pattern",
"==",
"''",
":",
"return",
"False",
"return_dict",
"=",
"{",
"}",
"pattern_re",
"=",
... | Splits info from SAR parts into logical stuff :-)
:param info_part: Part of SAR output we want to split into usable data
:param patternsname: ???
:param patterns: ???
:return: ``List``-style info from SAR files, now finally \
completely parsed into meaningful data for further... | [
"Splits",
"info",
"from",
"SAR",
"parts",
"into",
"logical",
"stuff",
":",
"-",
")",
":",
"param",
"info_part",
":",
"Part",
"of",
"SAR",
"output",
"we",
"want",
"to",
"split",
"into",
"usable",
"data",
":",
"param",
"patternsname",
":",
"???",
":",
"p... | python | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L535-L554 | def getFrameNumber(g):
"""
Polls the data server to find the current frame number.
Throws an exceotion if it cannot determine it.
"""
if not g.cpars['hcam_server_on']:
raise DriverError('getRunNumber error: servers are not active')
url = g.cpars['hipercam_server'] + 'status/DET.FRAM2.NO... | [
"def",
"getFrameNumber",
"(",
"g",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"raise",
"DriverError",
"(",
"'getRunNumber error: servers are not active'",
")",
"url",
"=",
"g",
".",
"cpars",
"[",
"'hipercam_server'",
"]",
"+",... | Polls the data server to find the current frame number.
Throws an exceotion if it cannot determine it. | [
"Polls",
"the",
"data",
"server",
"to",
"find",
"the",
"current",
"frame",
"number",
"."
] | python | train |
sandwichcloud/ingredients.db | ingredients_db/database.py | https://github.com/sandwichcloud/ingredients.db/blob/e91602fbece74290e051016439346fd4a3f1524e/ingredients_db/database.py#L53-L76 | def _add_process_guards(self, engine):
"""Add multiprocessing guards.
Forces a connection to be reconnected if it is detected
as having been shared to a sub-process.
"""
@sqlalchemy.event.listens_for(engine, "connect")
def connect(dbapi_connection, connection_record):
... | [
"def",
"_add_process_guards",
"(",
"self",
",",
"engine",
")",
":",
"@",
"sqlalchemy",
".",
"event",
".",
"listens_for",
"(",
"engine",
",",
"\"connect\"",
")",
"def",
"connect",
"(",
"dbapi_connection",
",",
"connection_record",
")",
":",
"connection_record",
... | Add multiprocessing guards.
Forces a connection to be reconnected if it is detected
as having been shared to a sub-process. | [
"Add",
"multiprocessing",
"guards",
"."
] | python | train |
bpython/curtsies | curtsies/formatstring.py | https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/formatstring.py#L557-L576 | def width_aware_slice(self, index):
"""Slice based on the number of columns it would take to display the substring."""
if wcswidth(self.s) == -1:
raise ValueError('bad values for width aware slicing')
index = normalize_slice(self.width, index)
counter = 0
parts = []
... | [
"def",
"width_aware_slice",
"(",
"self",
",",
"index",
")",
":",
"if",
"wcswidth",
"(",
"self",
".",
"s",
")",
"==",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"'bad values for width aware slicing'",
")",
"index",
"=",
"normalize_slice",
"(",
"self",
".",
... | Slice based on the number of columns it would take to display the substring. | [
"Slice",
"based",
"on",
"the",
"number",
"of",
"columns",
"it",
"would",
"take",
"to",
"display",
"the",
"substring",
"."
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/utils/support_types.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/utils/support_types.py#L154-L168 | def cVectorToPython(x):
"""
Convert the c vector data into the correct python data type
(numpy arrays or strings)
:param x:
:return:
"""
if isinstance(x[0], bool):
return numpy.frombuffer(x, dtype=numpy.bool).copy()
elif isinstance(x[0], int):
return numpy.frombuffer(x, d... | [
"def",
"cVectorToPython",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
"[",
"0",
"]",
",",
"bool",
")",
":",
"return",
"numpy",
".",
"frombuffer",
"(",
"x",
",",
"dtype",
"=",
"numpy",
".",
"bool",
")",
".",
"copy",
"(",
")",
"elif",
"isinst... | Convert the c vector data into the correct python data type
(numpy arrays or strings)
:param x:
:return: | [
"Convert",
"the",
"c",
"vector",
"data",
"into",
"the",
"correct",
"python",
"data",
"type",
"(",
"numpy",
"arrays",
"or",
"strings",
")",
":",
"param",
"x",
":",
":",
"return",
":"
] | python | train |
buriburisuri/sugartensor | sugartensor/sg_main.py | https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_main.py#L360-L443 | def sg_rnn_layer_func(func):
r"""Decorates function as sg_rnn_layer functions.
Args:
func: function to decorate
"""
@wraps(func)
def wrapper(tensor, **kwargs):
r"""Manages arguments of `tf.sg_opt`.
Args:
tensor: automatically passed by decorator
kwargs:
... | [
"def",
"sg_rnn_layer_func",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"tensor",
",",
"*",
"*",
"kwargs",
")",
":",
"r\"\"\"Manages arguments of `tf.sg_opt`.\n\n Args:\n tensor: automatically passed by decorator\n ... | r"""Decorates function as sg_rnn_layer functions.
Args:
func: function to decorate | [
"r",
"Decorates",
"function",
"as",
"sg_rnn_layer",
"functions",
".",
"Args",
":",
"func",
":",
"function",
"to",
"decorate"
] | python | train |
jim-easterbrook/pywws | src/pywws/weatherstation.py | https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L713-L723 | def current_pos(self):
"""Get circular buffer location where current data is being written."""
new_ptr = _decode(
self._read_fixed_block(0x0020), self.lo_fix_format['current_pos'])
if new_ptr == self._current_ptr:
return self._current_ptr
if self._current_ptr and ... | [
"def",
"current_pos",
"(",
"self",
")",
":",
"new_ptr",
"=",
"_decode",
"(",
"self",
".",
"_read_fixed_block",
"(",
"0x0020",
")",
",",
"self",
".",
"lo_fix_format",
"[",
"'current_pos'",
"]",
")",
"if",
"new_ptr",
"==",
"self",
".",
"_current_ptr",
":",
... | Get circular buffer location where current data is being written. | [
"Get",
"circular",
"buffer",
"location",
"where",
"current",
"data",
"is",
"being",
"written",
"."
] | python | train |
pennlabs/penn-sdk-python | penn/studyspaces.py | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L268-L286 | def get_room_info(self, room_ids):
"""Gets room information for a given list of ids.
:param room_ids: a room id or a list of room ids (comma separated).
:type room_ids: string
"""
try:
resp = self._request("GET", "/1.1/space/item/{}".format(room_ids))
roo... | [
"def",
"get_room_info",
"(",
"self",
",",
"room_ids",
")",
":",
"try",
":",
"resp",
"=",
"self",
".",
"_request",
"(",
"\"GET\"",
",",
"\"/1.1/space/item/{}\"",
".",
"format",
"(",
"room_ids",
")",
")",
"rooms",
"=",
"resp",
".",
"json",
"(",
")",
"for... | Gets room information for a given list of ids.
:param room_ids: a room id or a list of room ids (comma separated).
:type room_ids: string | [
"Gets",
"room",
"information",
"for",
"a",
"given",
"list",
"of",
"ids",
"."
] | python | train |
onicagroup/runway | runway/commands/runway/gen_sample.py | https://github.com/onicagroup/runway/blob/3f3549ec3bf6e39b9f27d9738a1847f3a4369e7f/runway/commands/runway/gen_sample.py#L279-L296 | def execute(self):
"""Run selected module generator."""
if self._cli_arguments['cfn']:
generate_sample_cfn_module(self.env_root)
elif self._cli_arguments['sls']:
generate_sample_sls_module(self.env_root)
elif self._cli_arguments['sls-tsc']:
generate_sa... | [
"def",
"execute",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cli_arguments",
"[",
"'cfn'",
"]",
":",
"generate_sample_cfn_module",
"(",
"self",
".",
"env_root",
")",
"elif",
"self",
".",
"_cli_arguments",
"[",
"'sls'",
"]",
":",
"generate_sample_sls_module",
... | Run selected module generator. | [
"Run",
"selected",
"module",
"generator",
"."
] | python | train |
ramrod-project/database-brain | schema/brain/controller/verification.py | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/controller/verification.py#L9-L25 | def verify_port_map(plugin):
"""
extra validation /
PB2 sees empty lists the same as non-existant lists
:param plugin:
:return:
"""
result = True
ex_ports = plugin.get(EX_PORTS_KEY)
result &= isinstance(ex_ports, list) and verify_ports(ex_ports)
in_ports = plugin.get(IN_PORTS_KEY... | [
"def",
"verify_port_map",
"(",
"plugin",
")",
":",
"result",
"=",
"True",
"ex_ports",
"=",
"plugin",
".",
"get",
"(",
"EX_PORTS_KEY",
")",
"result",
"&=",
"isinstance",
"(",
"ex_ports",
",",
"list",
")",
"and",
"verify_ports",
"(",
"ex_ports",
")",
"in_por... | extra validation /
PB2 sees empty lists the same as non-existant lists
:param plugin:
:return: | [
"extra",
"validation",
"/",
"PB2",
"sees",
"empty",
"lists",
"the",
"same",
"as",
"non",
"-",
"existant",
"lists",
":",
"param",
"plugin",
":",
":",
"return",
":"
] | python | train |
googleapis/google-cloud-python | dlp/google/cloud/dlp_v2/gapic/dlp_service_client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dlp/google/cloud/dlp_v2/gapic/dlp_service_client.py#L151-L157 | def organization_stored_info_type_path(cls, organization, stored_info_type):
"""Return a fully-qualified organization_stored_info_type string."""
return google.api_core.path_template.expand(
"organizations/{organization}/storedInfoTypes/{stored_info_type}",
organization=organizat... | [
"def",
"organization_stored_info_type_path",
"(",
"cls",
",",
"organization",
",",
"stored_info_type",
")",
":",
"return",
"google",
".",
"api_core",
".",
"path_template",
".",
"expand",
"(",
"\"organizations/{organization}/storedInfoTypes/{stored_info_type}\"",
",",
"organ... | Return a fully-qualified organization_stored_info_type string. | [
"Return",
"a",
"fully",
"-",
"qualified",
"organization_stored_info_type",
"string",
"."
] | python | train |
blink1073/oct2py | oct2py/core.py | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L695-L698 | def _get_user_class(self, name):
"""Get or create a user class of the given type."""
self._user_classes.setdefault(name, _make_user_class(self, name))
return self._user_classes[name] | [
"def",
"_get_user_class",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_user_classes",
".",
"setdefault",
"(",
"name",
",",
"_make_user_class",
"(",
"self",
",",
"name",
")",
")",
"return",
"self",
".",
"_user_classes",
"[",
"name",
"]"
] | Get or create a user class of the given type. | [
"Get",
"or",
"create",
"a",
"user",
"class",
"of",
"the",
"given",
"type",
"."
] | python | valid |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L187-L195 | def create_channel(self, channel):
"""
Method to create a channel.
:param channel: List containing channel's desired to be created on database.
:return: Id.
"""
data = {'channels': channel}
return super(ApiInterfaceRequest, self).post('api/v3/channel/', data) | [
"def",
"create_channel",
"(",
"self",
",",
"channel",
")",
":",
"data",
"=",
"{",
"'channels'",
":",
"channel",
"}",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"post",
"(",
"'api/v3/channel/'",
",",
"data",
")"
] | Method to create a channel.
:param channel: List containing channel's desired to be created on database.
:return: Id. | [
"Method",
"to",
"create",
"a",
"channel",
".",
":",
"param",
"channel",
":",
"List",
"containing",
"channel",
"s",
"desired",
"to",
"be",
"created",
"on",
"database",
".",
":",
"return",
":",
"Id",
"."
] | python | train |
rrwen/search_google | search_google/api.py | https://github.com/rrwen/search_google/blob/e647868ba5da2803e787a3c06b32e09452068736/search_google/api.py#L134-L172 | def preview(self, n=10, k='items', kheader='displayLink', klink='link', kdescription='snippet'):
"""Print a preview of the search results.
Args:
n (int):
Maximum number of search results to preview
k (str):
Key in :class:`api.results`.metadata to preview
kheader (str):
... | [
"def",
"preview",
"(",
"self",
",",
"n",
"=",
"10",
",",
"k",
"=",
"'items'",
",",
"kheader",
"=",
"'displayLink'",
",",
"klink",
"=",
"'link'",
",",
"kdescription",
"=",
"'snippet'",
")",
":",
"if",
"'searchType'",
"in",
"self",
".",
"cseargs",
":",
... | Print a preview of the search results.
Args:
n (int):
Maximum number of search results to preview
k (str):
Key in :class:`api.results`.metadata to preview
kheader (str):
Key in :class:`api.results`.metadata[``k``] to use as the header
klink (str):
Key in ... | [
"Print",
"a",
"preview",
"of",
"the",
"search",
"results",
".",
"Args",
":",
"n",
"(",
"int",
")",
":",
"Maximum",
"number",
"of",
"search",
"results",
"to",
"preview",
"k",
"(",
"str",
")",
":",
"Key",
"in",
":",
"class",
":",
"api",
".",
"results... | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py#L706-L720 | def get_interface_detail_input_request_type_get_next_request_last_rcvd_interface_interface_name(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_interface_detail = ET.Element("get_interface_detail")
config = get_interface_detail
input = ET.Sub... | [
"def",
"get_interface_detail_input_request_type_get_next_request_last_rcvd_interface_interface_name",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_interface_detail",
"=",
"ET",
".",
"Element",
"(",
"... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
user-cont/conu | conu/backend/nspawn/image.py | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L345-L403 | def run_via_binary(self, command=None, foreground=False, volumes=None,
additional_opts=None, default_options=None, name=None, *args, **kwargs):
"""
Create new instance NspawnContianer in case of not running at foreground, in case foreground run, return process
object
:param ... | [
"def",
"run_via_binary",
"(",
"self",
",",
"command",
"=",
"None",
",",
"foreground",
"=",
"False",
",",
"volumes",
"=",
"None",
",",
"additional_opts",
"=",
"None",
",",
"default_options",
"=",
"None",
",",
"name",
"=",
"None",
",",
"*",
"args",
",",
... | Create new instance NspawnContianer in case of not running at foreground, in case foreground run, return process
object
:param command: list - command to run
:param foreground: bool - run process at foreground
:param volumes: list - put additional bind mounts
:param additional_o... | [
"Create",
"new",
"instance",
"NspawnContianer",
"in",
"case",
"of",
"not",
"running",
"at",
"foreground",
"in",
"case",
"foreground",
"run",
"return",
"process",
"object"
] | python | train |
crossbario/txaio-etcd | txaioetcd/_client_tx.py | https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L237-L253 | def status(self, timeout=None):
"""
Get etcd status.
:param timeout: Request timeout in seconds.
:type timeout: int
:returns: The current etcd cluster status.
:rtype: instance of :class:`txaioetcd.Status`
"""
assembler = commons.StatusRequestAssembler(se... | [
"def",
"status",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"assembler",
"=",
"commons",
".",
"StatusRequestAssembler",
"(",
"self",
".",
"_url",
")",
"obj",
"=",
"yield",
"self",
".",
"_post",
"(",
"assembler",
".",
"url",
",",
"assembler",
"... | Get etcd status.
:param timeout: Request timeout in seconds.
:type timeout: int
:returns: The current etcd cluster status.
:rtype: instance of :class:`txaioetcd.Status` | [
"Get",
"etcd",
"status",
"."
] | python | train |
tjomasc/snekbol | snekbol/document.py | https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L460-L481 | def _extend_module_definitions(self, graph):
"""
Using collected module definitions extend linkages
"""
for mod_id in self._modules:
mod_identity = self._get_triplet_value(graph, URIRef(mod_id), SBOL.module)
modules = []
for mod in graph.triples((mod_i... | [
"def",
"_extend_module_definitions",
"(",
"self",
",",
"graph",
")",
":",
"for",
"mod_id",
"in",
"self",
".",
"_modules",
":",
"mod_identity",
"=",
"self",
".",
"_get_triplet_value",
"(",
"graph",
",",
"URIRef",
"(",
"mod_id",
")",
",",
"SBOL",
".",
"modul... | Using collected module definitions extend linkages | [
"Using",
"collected",
"module",
"definitions",
"extend",
"linkages"
] | python | train |
lmcinnes/umap | umap/umap_.py | https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/umap_.py#L535-L559 | def reset_local_connectivity(simplicial_set):
"""Reset the local connectivity requirement -- each data sample should
have complete confidence in at least one 1-simplex in the simplicial set.
We can enforce this by locally rescaling confidences, and then remerging the
different local simplicial sets toge... | [
"def",
"reset_local_connectivity",
"(",
"simplicial_set",
")",
":",
"simplicial_set",
"=",
"normalize",
"(",
"simplicial_set",
",",
"norm",
"=",
"\"max\"",
")",
"transpose",
"=",
"simplicial_set",
".",
"transpose",
"(",
")",
"prod_matrix",
"=",
"simplicial_set",
"... | Reset the local connectivity requirement -- each data sample should
have complete confidence in at least one 1-simplex in the simplicial set.
We can enforce this by locally rescaling confidences, and then remerging the
different local simplicial sets together.
Parameters
----------
simplicial_s... | [
"Reset",
"the",
"local",
"connectivity",
"requirement",
"--",
"each",
"data",
"sample",
"should",
"have",
"complete",
"confidence",
"in",
"at",
"least",
"one",
"1",
"-",
"simplex",
"in",
"the",
"simplicial",
"set",
".",
"We",
"can",
"enforce",
"this",
"by",
... | python | train |
hbldh/sudokuextract | sudokuextract/imgproc/geometry.py | https://github.com/hbldh/sudokuextract/blob/0dff3b46b9896a8bedfc474c61a089e7901f720c/sudokuextract/imgproc/geometry.py#L28-L56 | def warp_image_by_corner_points_projection(corner_points, image):
"""Given corner points of a Sudoku, warps original selection to a square image.
:param corner_points:
:type: corner_points: list
:param image:
:type image:
:return:
:rtype:
"""
# Clarify by storing in named variables... | [
"def",
"warp_image_by_corner_points_projection",
"(",
"corner_points",
",",
"image",
")",
":",
"# Clarify by storing in named variables.",
"top_left",
",",
"top_right",
",",
"bottom_left",
",",
"bottom_right",
"=",
"np",
".",
"array",
"(",
"corner_points",
")",
"top_edg... | Given corner points of a Sudoku, warps original selection to a square image.
:param corner_points:
:type: corner_points: list
:param image:
:type image:
:return:
:rtype: | [
"Given",
"corner",
"points",
"of",
"a",
"Sudoku",
"warps",
"original",
"selection",
"to",
"a",
"square",
"image",
"."
] | python | train |
cackharot/suds-py3 | suds/xsd/schema.py | https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/xsd/schema.py#L60-L74 | def add(self, schema):
"""
Add a schema node to the collection. Schema(s) within the same target
namespace are consolidated.
@param schema: A schema object.
@type schema: (L{Schema})
"""
key = schema.tns[1]
existing = self.namespaces.get(key)
if e... | [
"def",
"add",
"(",
"self",
",",
"schema",
")",
":",
"key",
"=",
"schema",
".",
"tns",
"[",
"1",
"]",
"existing",
"=",
"self",
".",
"namespaces",
".",
"get",
"(",
"key",
")",
"if",
"existing",
"is",
"None",
":",
"self",
".",
"children",
".",
"appe... | Add a schema node to the collection. Schema(s) within the same target
namespace are consolidated.
@param schema: A schema object.
@type schema: (L{Schema}) | [
"Add",
"a",
"schema",
"node",
"to",
"the",
"collection",
".",
"Schema",
"(",
"s",
")",
"within",
"the",
"same",
"target",
"namespace",
"are",
"consolidated",
"."
] | python | train |
dhylands/rshell | rshell/main.py | https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L2390-L2427 | def repl_serial_to_stdout(self, dev):
"""Runs as a thread which has a sole purpose of readding bytes from
the serial port and writing them to stdout. Used by do_repl.
"""
with self.serial_reader_running:
try:
save_timeout = dev.timeout
# Set... | [
"def",
"repl_serial_to_stdout",
"(",
"self",
",",
"dev",
")",
":",
"with",
"self",
".",
"serial_reader_running",
":",
"try",
":",
"save_timeout",
"=",
"dev",
".",
"timeout",
"# Set a timeout so that the read returns periodically with no data",
"# and allows us to check whet... | Runs as a thread which has a sole purpose of readding bytes from
the serial port and writing them to stdout. Used by do_repl. | [
"Runs",
"as",
"a",
"thread",
"which",
"has",
"a",
"sole",
"purpose",
"of",
"readding",
"bytes",
"from",
"the",
"serial",
"port",
"and",
"writing",
"them",
"to",
"stdout",
".",
"Used",
"by",
"do_repl",
"."
] | python | train |
henzk/ape | ape/__init__.py | https://github.com/henzk/ape/blob/a1b7ea5e5b25c42beffeaaa5c32d94ad82634819/ape/__init__.py#L145-L161 | def print_task_help(self, task, name):
"""
Prints the help for the passed task with the passed name.
:param task: the task function object
:param name: the name of the module.
:return: None
"""
TerminalColor.set('GREEN')
print(get_signature(name, task))
... | [
"def",
"print_task_help",
"(",
"self",
",",
"task",
",",
"name",
")",
":",
"TerminalColor",
".",
"set",
"(",
"'GREEN'",
")",
"print",
"(",
"get_signature",
"(",
"name",
",",
"task",
")",
")",
"# TODO: print the location does not work properly and sometimes returns N... | Prints the help for the passed task with the passed name.
:param task: the task function object
:param name: the name of the module.
:return: None | [
"Prints",
"the",
"help",
"for",
"the",
"passed",
"task",
"with",
"the",
"passed",
"name",
".",
":",
"param",
"task",
":",
"the",
"task",
"function",
"object",
":",
"param",
"name",
":",
"the",
"name",
"of",
"the",
"module",
".",
":",
"return",
":",
"... | python | train |
bitshares/python-bitshares | bitshares/bitshares.py | https://github.com/bitshares/python-bitshares/blob/8a3b5954a6abcaaff7c6a5c41d910e58eea3142f/bitshares/bitshares.py#L989-L1062 | def publish_price_feed(
self, symbol, settlement_price, cer=None, mssr=110, mcr=200, account=None
):
""" Publish a price feed for a market-pegged asset
:param str symbol: Symbol of the asset to publish feed for
:param bitshares.price.Price settlement_price: Price for settlem... | [
"def",
"publish_price_feed",
"(",
"self",
",",
"symbol",
",",
"settlement_price",
",",
"cer",
"=",
"None",
",",
"mssr",
"=",
"110",
",",
"mcr",
"=",
"200",
",",
"account",
"=",
"None",
")",
":",
"assert",
"mcr",
">",
"100",
"assert",
"mssr",
">",
"10... | Publish a price feed for a market-pegged asset
:param str symbol: Symbol of the asset to publish feed for
:param bitshares.price.Price settlement_price: Price for settlement
:param bitshares.price.Price cer: Core exchange Rate (default
``settlement_price + 5%``)
... | [
"Publish",
"a",
"price",
"feed",
"for",
"a",
"market",
"-",
"pegged",
"asset"
] | python | train |
saltstack/salt | salt/modules/useradd.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/useradd.py#L96-L120 | def _update_gecos(name, key, value, root=None):
'''
Common code to change a user's GECOS information
'''
if value is None:
value = ''
elif not isinstance(value, six.string_types):
value = six.text_type(value)
else:
value = salt.utils.stringutils.to_unicode(value)
pre_... | [
"def",
"_update_gecos",
"(",
"name",
",",
"key",
",",
"value",
",",
"root",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"''",
"elif",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"value",
... | Common code to change a user's GECOS information | [
"Common",
"code",
"to",
"change",
"a",
"user",
"s",
"GECOS",
"information"
] | python | train |
google/apitools | apitools/base/protorpclite/protojson.py | https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/protorpclite/protojson.py#L178-L193 | def encode_message(self, message):
"""Encode Message instance to JSON string.
Args:
Message instance to encode in to JSON string.
Returns:
String encoding of Message instance in protocol JSON format.
Raises:
messages.ValidationError if message is not init... | [
"def",
"encode_message",
"(",
"self",
",",
"message",
")",
":",
"message",
".",
"check_initialized",
"(",
")",
"return",
"json",
".",
"dumps",
"(",
"message",
",",
"cls",
"=",
"MessageJSONEncoder",
",",
"protojson_protocol",
"=",
"self",
")"
] | Encode Message instance to JSON string.
Args:
Message instance to encode in to JSON string.
Returns:
String encoding of Message instance in protocol JSON format.
Raises:
messages.ValidationError if message is not initialized. | [
"Encode",
"Message",
"instance",
"to",
"JSON",
"string",
"."
] | python | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/encoder.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/encoder.py#L409-L415 | def _VarintBytes(value):
"""Encode the given integer as a varint and return the bytes. This is only
called at startup time so it doesn't need to be fast."""
pieces = []
_EncodeVarint(pieces.append, value)
return b"".join(pieces) | [
"def",
"_VarintBytes",
"(",
"value",
")",
":",
"pieces",
"=",
"[",
"]",
"_EncodeVarint",
"(",
"pieces",
".",
"append",
",",
"value",
")",
"return",
"b\"\"",
".",
"join",
"(",
"pieces",
")"
] | Encode the given integer as a varint and return the bytes. This is only
called at startup time so it doesn't need to be fast. | [
"Encode",
"the",
"given",
"integer",
"as",
"a",
"varint",
"and",
"return",
"the",
"bytes",
".",
"This",
"is",
"only",
"called",
"at",
"startup",
"time",
"so",
"it",
"doesn",
"t",
"need",
"to",
"be",
"fast",
"."
] | python | train |
ulule/django-linguist | linguist/utils.py | https://github.com/ulule/django-linguist/blob/d2b95a6ab921039d56d5eeb352badfe5be9e8f77/linguist/utils.py#L185-L212 | def get_model_string(model_name):
"""
Returns the model string notation Django uses for lazily loaded ForeignKeys
(eg 'auth.User') to prevent circular imports.
This is needed to allow our crazy custom model usage.
"""
setting_name = "LINGUIST_%s_MODEL" % model_name.upper().replace("_", "")
c... | [
"def",
"get_model_string",
"(",
"model_name",
")",
":",
"setting_name",
"=",
"\"LINGUIST_%s_MODEL\"",
"%",
"model_name",
".",
"upper",
"(",
")",
".",
"replace",
"(",
"\"_\"",
",",
"\"\"",
")",
"class_path",
"=",
"getattr",
"(",
"settings",
",",
"setting_name",... | Returns the model string notation Django uses for lazily loaded ForeignKeys
(eg 'auth.User') to prevent circular imports.
This is needed to allow our crazy custom model usage. | [
"Returns",
"the",
"model",
"string",
"notation",
"Django",
"uses",
"for",
"lazily",
"loaded",
"ForeignKeys",
"(",
"eg",
"auth",
".",
"User",
")",
"to",
"prevent",
"circular",
"imports",
".",
"This",
"is",
"needed",
"to",
"allow",
"our",
"crazy",
"custom",
... | python | train |
mikekatz04/BOWIE | snr_calculator_folder/gwsnrcalc/utils/sensitivity.py | https://github.com/mikekatz04/BOWIE/blob/a941342a3536cb57c817a1643896d99a3f354a86/snr_calculator_folder/gwsnrcalc/utils/sensitivity.py#L61-L136 | def _prep_noise_interpolants(self):
"""Construct interpolated sensitivity curves
This will construct the interpolated sensitivity curves
using scipy.interpolate.interp1d. It will add wd noise
if that is requested.
Raises:
ValueError: ``len(noise_type_in) != len(sens... | [
"def",
"_prep_noise_interpolants",
"(",
"self",
")",
":",
"noise_lists",
"=",
"{",
"}",
"self",
".",
"noise_interpolants",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"self",
".",
"sensitivity_curves",
",",
"str",
")",
":",
"self",
".",
"sensitivity_curves",
"="... | Construct interpolated sensitivity curves
This will construct the interpolated sensitivity curves
using scipy.interpolate.interp1d. It will add wd noise
if that is requested.
Raises:
ValueError: ``len(noise_type_in) != len(sensitivity_curves)``
ValueError: Issue... | [
"Construct",
"interpolated",
"sensitivity",
"curves"
] | python | train |
pandas-dev/pandas | pandas/core/indexes/base.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L153-L163 | def _new_Index(cls, d):
"""
This is called upon unpickling, rather than the default which doesn't
have arguments and breaks __new__.
"""
# required for backward compat, because PI can't be instantiated with
# ordinals through __new__ GH #13277
if issubclass(cls, ABCPeriodIndex):
from... | [
"def",
"_new_Index",
"(",
"cls",
",",
"d",
")",
":",
"# required for backward compat, because PI can't be instantiated with",
"# ordinals through __new__ GH #13277",
"if",
"issubclass",
"(",
"cls",
",",
"ABCPeriodIndex",
")",
":",
"from",
"pandas",
".",
"core",
".",
"in... | This is called upon unpickling, rather than the default which doesn't
have arguments and breaks __new__. | [
"This",
"is",
"called",
"upon",
"unpickling",
"rather",
"than",
"the",
"default",
"which",
"doesn",
"t",
"have",
"arguments",
"and",
"breaks",
"__new__",
"."
] | python | train |
djaodjin/djaodjin-deployutils | src/djd.py | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/src/djd.py#L100-L103 | def pub_upload(args, location=None, prefix=""):
"""Upload theme packages to the stage *location*.
"""
upload(location, remotes=args, prefix=prefix) | [
"def",
"pub_upload",
"(",
"args",
",",
"location",
"=",
"None",
",",
"prefix",
"=",
"\"\"",
")",
":",
"upload",
"(",
"location",
",",
"remotes",
"=",
"args",
",",
"prefix",
"=",
"prefix",
")"
] | Upload theme packages to the stage *location*. | [
"Upload",
"theme",
"packages",
"to",
"the",
"stage",
"*",
"location",
"*",
"."
] | python | train |
osrg/ryu | ryu/services/protocols/bgp/core_managers/table_manager.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/core_managers/table_manager.py#L433-L449 | def re_install_net_ctrl_paths(self, vrf_table):
"""Re-installs paths from NC with current BGP policy.
Iterates over known paths from NC installed in `vrf4_table` and
adds new path with path attributes as per current VRF configuration.
"""
assert vrf_table
for dest in vrf... | [
"def",
"re_install_net_ctrl_paths",
"(",
"self",
",",
"vrf_table",
")",
":",
"assert",
"vrf_table",
"for",
"dest",
"in",
"vrf_table",
".",
"values",
"(",
")",
":",
"for",
"path",
"in",
"dest",
".",
"known_path_list",
":",
"if",
"path",
".",
"source",
"is",... | Re-installs paths from NC with current BGP policy.
Iterates over known paths from NC installed in `vrf4_table` and
adds new path with path attributes as per current VRF configuration. | [
"Re",
"-",
"installs",
"paths",
"from",
"NC",
"with",
"current",
"BGP",
"policy",
"."
] | python | train |
BerkeleyAutomation/perception | perception/video_recorder.py | https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/video_recorder.py#L142-L153 | def stop(self):
""" Stop the camera process. """
if not self._started:
raise Exception("Cannot stop a video recorder before starting it!")
self._started = False
if self._actual_camera.is_running:
self._actual_camera.stop()
if self._camera is not None:
... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_started",
":",
"raise",
"Exception",
"(",
"\"Cannot stop a video recorder before starting it!\"",
")",
"self",
".",
"_started",
"=",
"False",
"if",
"self",
".",
"_actual_camera",
".",
"is_running"... | Stop the camera process. | [
"Stop",
"the",
"camera",
"process",
"."
] | python | train |
kurtbrose/faststat | faststat/faststat.py | https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L325-L347 | def pformat(self, prefix=()):
'''
Makes a pretty ASCII format of the data, suitable for
displaying in a console or saving to a text file.
Returns a list of lines.
'''
nan = float("nan")
def sformat(segment, stat):
FMT = "n={0}, mean={1}, p50/... | [
"def",
"pformat",
"(",
"self",
",",
"prefix",
"=",
"(",
")",
")",
":",
"nan",
"=",
"float",
"(",
"\"nan\"",
")",
"def",
"sformat",
"(",
"segment",
",",
"stat",
")",
":",
"FMT",
"=",
"\"n={0}, mean={1}, p50/95={2}/{3}, max={4}\"",
"line_segs",
"=",
"[",
"... | Makes a pretty ASCII format of the data, suitable for
displaying in a console or saving to a text file.
Returns a list of lines. | [
"Makes",
"a",
"pretty",
"ASCII",
"format",
"of",
"the",
"data",
"suitable",
"for",
"displaying",
"in",
"a",
"console",
"or",
"saving",
"to",
"a",
"text",
"file",
".",
"Returns",
"a",
"list",
"of",
"lines",
"."
] | python | train |
openstack/python-monascaclient | monascaclient/v2_0/shell.py | https://github.com/openstack/python-monascaclient/blob/03b07534145928eb2debad938da033c232dda105/monascaclient/v2_0/shell.py#L1014-L1047 | def do_alarm_definition_patch(mc, args):
'''Patch the alarm definition.'''
fields = {}
fields['alarm_id'] = args.id
if args.name:
fields['name'] = args.name
if args.description:
fields['description'] = args.description
if args.expression:
fields['expression'] = args.expre... | [
"def",
"do_alarm_definition_patch",
"(",
"mc",
",",
"args",
")",
":",
"fields",
"=",
"{",
"}",
"fields",
"[",
"'alarm_id'",
"]",
"=",
"args",
".",
"id",
"if",
"args",
".",
"name",
":",
"fields",
"[",
"'name'",
"]",
"=",
"args",
".",
"name",
"if",
"... | Patch the alarm definition. | [
"Patch",
"the",
"alarm",
"definition",
"."
] | python | train |
adafruit/Adafruit_Python_GPIO | Adafruit_GPIO/I2C.py | https://github.com/adafruit/Adafruit_Python_GPIO/blob/a92a23d6b5869663b2bc1ccf78bb11585076a9c4/Adafruit_GPIO/I2C.py#L68-L82 | def require_repeated_start():
"""Enable repeated start conditions for I2C register reads. This is the
normal behavior for I2C, however on some platforms like the Raspberry Pi
there are bugs which disable repeated starts unless explicitly enabled with
this function. See this thread for more details:
... | [
"def",
"require_repeated_start",
"(",
")",
":",
"plat",
"=",
"Platform",
".",
"platform_detect",
"(",
")",
"if",
"plat",
"==",
"Platform",
".",
"RASPBERRY_PI",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"'/sys/module/i2c_bcm2708/parameters/combined'",
")",
":... | Enable repeated start conditions for I2C register reads. This is the
normal behavior for I2C, however on some platforms like the Raspberry Pi
there are bugs which disable repeated starts unless explicitly enabled with
this function. See this thread for more details:
http://www.raspberrypi.org/forums... | [
"Enable",
"repeated",
"start",
"conditions",
"for",
"I2C",
"register",
"reads",
".",
"This",
"is",
"the",
"normal",
"behavior",
"for",
"I2C",
"however",
"on",
"some",
"platforms",
"like",
"the",
"Raspberry",
"Pi",
"there",
"are",
"bugs",
"which",
"disable",
... | python | valid |
sirfoga/pyhal | hal/files/models/system.py | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/system.py#L201-L213 | def ls_dir(path, include_hidden=False):
"""Finds content of folder
:param path: directory to get list of files and folders
:param include_hidden: True iff include hidden files in list
:return: List of paths in given directory
"""
lst = []
for file in os.listdir(path):
hidden_file = ... | [
"def",
"ls_dir",
"(",
"path",
",",
"include_hidden",
"=",
"False",
")",
":",
"lst",
"=",
"[",
"]",
"for",
"file",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"hidden_file",
"=",
"FileSystem",
"(",
"file",
")",
".",
"is_hidden",
"(",
")",
"if... | Finds content of folder
:param path: directory to get list of files and folders
:param include_hidden: True iff include hidden files in list
:return: List of paths in given directory | [
"Finds",
"content",
"of",
"folder"
] | python | train |
kevinconway/venvctrl | venvctrl/cli/relocate.py | https://github.com/kevinconway/venvctrl/blob/36d4e0e4d5ebced6385a6ade1198f4769ff2df41/venvctrl/cli/relocate.py#L31-L54 | def main():
"""Relocate a virtual environment."""
parser = argparse.ArgumentParser(
description='Relocate a virtual environment.'
)
parser.add_argument(
'--source',
help='The existing virtual environment.',
required=True,
)
parser.add_argument(
'--destinat... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Relocate a virtual environment.'",
")",
"parser",
".",
"add_argument",
"(",
"'--source'",
",",
"help",
"=",
"'The existing virtual environment.'",
",",
"requir... | Relocate a virtual environment. | [
"Relocate",
"a",
"virtual",
"environment",
"."
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L9162-L9182 | def orderd(array, ndim=None):
"""
Determine the order of elements in a double precision array.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/orderd_c.html
:param array: Input array.
:type array: Array of floats
:param ndim: Optional Length of input array
:type ndim: int
:retu... | [
"def",
"orderd",
"(",
"array",
",",
"ndim",
"=",
"None",
")",
":",
"if",
"ndim",
"is",
"None",
":",
"ndim",
"=",
"ctypes",
".",
"c_int",
"(",
"len",
"(",
"array",
")",
")",
"else",
":",
"ndim",
"=",
"ctypes",
".",
"c_int",
"(",
"ndim",
")",
"ar... | Determine the order of elements in a double precision array.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/orderd_c.html
:param array: Input array.
:type array: Array of floats
:param ndim: Optional Length of input array
:type ndim: int
:return: Order vector for array.
:rtype: ar... | [
"Determine",
"the",
"order",
"of",
"elements",
"in",
"a",
"double",
"precision",
"array",
"."
] | python | train |
scidash/sciunit | sciunit/models/runnable.py | https://github.com/scidash/sciunit/blob/41b2e38c45c0776727ab1f281a572b65be19cea1/sciunit/models/runnable.py#L33-L64 | def set_backend(self, backend):
"""Set the simulation backend."""
if isinstance(backend, str):
name = backend
args = []
kwargs = {}
elif isinstance(backend, (tuple, list)):
name = ''
args = []
kwargs = {}
for i i... | [
"def",
"set_backend",
"(",
"self",
",",
"backend",
")",
":",
"if",
"isinstance",
"(",
"backend",
",",
"str",
")",
":",
"name",
"=",
"backend",
"args",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"backend",
",",
"(",
"tuple",
... | Set the simulation backend. | [
"Set",
"the",
"simulation",
"backend",
"."
] | python | train |
MostAwesomeDude/gentleman | gentleman/base.py | https://github.com/MostAwesomeDude/gentleman/blob/17fb8ffb922aa4af9d8bcab85e452c9311d41805/gentleman/base.py#L405-L422 | def DeleteInstanceTags(r, instance, tags, dry_run=False):
"""
Deletes tags from an instance.
@type instance: str
@param instance: instance to delete tags from
@type tags: list of str
@param tags: tags to delete
@type dry_run: bool
@param dry_run: whether to perform a dry run
"""
... | [
"def",
"DeleteInstanceTags",
"(",
"r",
",",
"instance",
",",
"tags",
",",
"dry_run",
"=",
"False",
")",
":",
"query",
"=",
"{",
"\"tag\"",
":",
"tags",
",",
"\"dry-run\"",
":",
"dry_run",
",",
"}",
"return",
"r",
".",
"request",
"(",
"\"delete\"",
",",... | Deletes tags from an instance.
@type instance: str
@param instance: instance to delete tags from
@type tags: list of str
@param tags: tags to delete
@type dry_run: bool
@param dry_run: whether to perform a dry run | [
"Deletes",
"tags",
"from",
"an",
"instance",
"."
] | python | train |
fermiPy/fermipy | fermipy/jobs/analysis_utils.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/analysis_utils.py#L67-L127 | def add_source_get_correlated(gta, name, src_dict, correl_thresh=0.25, non_null_src=False):
"""Add a source and get the set of correlated sources
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
name : str
Name of the source we are adding
src_d... | [
"def",
"add_source_get_correlated",
"(",
"gta",
",",
"name",
",",
"src_dict",
",",
"correl_thresh",
"=",
"0.25",
",",
"non_null_src",
"=",
"False",
")",
":",
"if",
"gta",
".",
"roi",
".",
"has_source",
"(",
"name",
")",
":",
"gta",
".",
"zero_source",
"(... | Add a source and get the set of correlated sources
Parameters
----------
gta : `fermipy.gtaanalysis.GTAnalysis`
The analysis object
name : str
Name of the source we are adding
src_dict : dict
Dictionary of the source parameters
correl_thresh : float
Threshold... | [
"Add",
"a",
"source",
"and",
"get",
"the",
"set",
"of",
"correlated",
"sources"
] | python | train |
rbarrois/confutils | confutils/configfile.py | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L448-L460 | def remove_line(self, section, line):
"""Remove all instances of a line.
Returns:
int: the number of lines removed
"""
try:
s = self._get_section(section, create=False)
except KeyError:
# No such section, skip.
return 0
re... | [
"def",
"remove_line",
"(",
"self",
",",
"section",
",",
"line",
")",
":",
"try",
":",
"s",
"=",
"self",
".",
"_get_section",
"(",
"section",
",",
"create",
"=",
"False",
")",
"except",
"KeyError",
":",
"# No such section, skip.",
"return",
"0",
"return",
... | Remove all instances of a line.
Returns:
int: the number of lines removed | [
"Remove",
"all",
"instances",
"of",
"a",
"line",
"."
] | python | train |
pandas-dev/pandas | pandas/core/groupby/ops.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/ops.py#L257-L264 | def groups(self):
""" dict {group name -> group labels} """
if len(self.groupings) == 1:
return self.groupings[0].groups
else:
to_groupby = lzip(*(ping.grouper for ping in self.groupings))
to_groupby = Index(to_groupby)
return self.axis.groupby(to_... | [
"def",
"groups",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"groupings",
")",
"==",
"1",
":",
"return",
"self",
".",
"groupings",
"[",
"0",
"]",
".",
"groups",
"else",
":",
"to_groupby",
"=",
"lzip",
"(",
"*",
"(",
"ping",
".",
"groupe... | dict {group name -> group labels} | [
"dict",
"{",
"group",
"name",
"-",
">",
"group",
"labels",
"}"
] | python | train |
budacom/trading-bots | trading_bots/core/management/__init__.py | https://github.com/budacom/trading-bots/blob/8cb68bb8d0b5f822108db1cc5dae336e3d3c3452/trading_bots/core/management/__init__.py#L89-L94 | def abort(bot, config, settings):
"""Run the abort command of a specified BOT by label e.g. 'MyBot'"""
print_options(bot, config, settings)
click.echo()
bot_task = BotTask(bot, config)
bot_task.abort() | [
"def",
"abort",
"(",
"bot",
",",
"config",
",",
"settings",
")",
":",
"print_options",
"(",
"bot",
",",
"config",
",",
"settings",
")",
"click",
".",
"echo",
"(",
")",
"bot_task",
"=",
"BotTask",
"(",
"bot",
",",
"config",
")",
"bot_task",
".",
"abor... | Run the abort command of a specified BOT by label e.g. 'MyBot | [
"Run",
"the",
"abort",
"command",
"of",
"a",
"specified",
"BOT",
"by",
"label",
"e",
".",
"g",
".",
"MyBot"
] | python | train |
googleapis/google-cloud-python | spanner/google/cloud/spanner_v1/snapshot.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/spanner/google/cloud/spanner_v1/snapshot.py#L308-L381 | def partition_query(
self,
sql,
params=None,
param_types=None,
partition_size_bytes=None,
max_partitions=None,
):
"""Perform a ``ParitionQuery`` API request.
:type sql: str
:param sql: SQL query statement
:type params: dict, {str -> c... | [
"def",
"partition_query",
"(",
"self",
",",
"sql",
",",
"params",
"=",
"None",
",",
"param_types",
"=",
"None",
",",
"partition_size_bytes",
"=",
"None",
",",
"max_partitions",
"=",
"None",
",",
")",
":",
"if",
"not",
"self",
".",
"_multi_use",
":",
"rai... | Perform a ``ParitionQuery`` API request.
:type sql: str
:param sql: SQL query statement
:type params: dict, {str -> column value}
:param params: values for parameter replacement. Keys must match
the names used in ``sql``.
:type param_types: dict[str -> ... | [
"Perform",
"a",
"ParitionQuery",
"API",
"request",
"."
] | python | train |
fedora-infra/fedora-messaging | fedora_messaging/message.py | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L646-L659 | def _dump(self):
"""
Dump message attributes.
Returns:
dict: A dictionary of message attributes.
"""
return {
"topic": self.topic,
"headers": self._headers,
"id": self.id,
"body": self.body,
"queue": self.qu... | [
"def",
"_dump",
"(",
"self",
")",
":",
"return",
"{",
"\"topic\"",
":",
"self",
".",
"topic",
",",
"\"headers\"",
":",
"self",
".",
"_headers",
",",
"\"id\"",
":",
"self",
".",
"id",
",",
"\"body\"",
":",
"self",
".",
"body",
",",
"\"queue\"",
":",
... | Dump message attributes.
Returns:
dict: A dictionary of message attributes. | [
"Dump",
"message",
"attributes",
"."
] | python | train |
RedFantom/ttkwidgets | ttkwidgets/font/sizedropdown.py | https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/font/sizedropdown.py#L38-L45 | def _on_click(self, event):
"""
Function bound to event of selection in the Combobox, calls callback if callable
:param event: Tkinter event
"""
if callable(self.__callback):
self.__callback(self.selection) | [
"def",
"_on_click",
"(",
"self",
",",
"event",
")",
":",
"if",
"callable",
"(",
"self",
".",
"__callback",
")",
":",
"self",
".",
"__callback",
"(",
"self",
".",
"selection",
")"
] | Function bound to event of selection in the Combobox, calls callback if callable
:param event: Tkinter event | [
"Function",
"bound",
"to",
"event",
"of",
"selection",
"in",
"the",
"Combobox",
"calls",
"callback",
"if",
"callable",
":",
"param",
"event",
":",
"Tkinter",
"event"
] | python | train |
saltstack/salt | salt/modules/boto3_sns.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto3_sns.py#L220-L240 | def list_subscriptions_by_topic(TopicArn, region=None, key=None, keyid=None, profile=None):
'''
Returns a list of the subscriptions to a specific topic
CLI example::
salt myminion boto3_sns.list_subscriptions_by_topic mytopic region=us-east-1
'''
conn = _get_conn(region=region, key=key, ke... | [
"def",
"list_subscriptions_by_topic",
"(",
"TopicArn",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key"... | Returns a list of the subscriptions to a specific topic
CLI example::
salt myminion boto3_sns.list_subscriptions_by_topic mytopic region=us-east-1 | [
"Returns",
"a",
"list",
"of",
"the",
"subscriptions",
"to",
"a",
"specific",
"topic"
] | python | train |
bspaans/python-mingus | mingus/midi/midi_file_out.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/midi_file_out.py#L71-L86 | def write_Note(file, note, bpm=120, repeat=0, verbose=False):
"""Expect a Note object from mingus.containers and save it into a MIDI
file, specified in file.
You can set the velocity and channel in Note.velocity and Note.channel.
"""
m = MidiFile()
t = MidiTrack(bpm)
m.tracks = [t]
whil... | [
"def",
"write_Note",
"(",
"file",
",",
"note",
",",
"bpm",
"=",
"120",
",",
"repeat",
"=",
"0",
",",
"verbose",
"=",
"False",
")",
":",
"m",
"=",
"MidiFile",
"(",
")",
"t",
"=",
"MidiTrack",
"(",
"bpm",
")",
"m",
".",
"tracks",
"=",
"[",
"t",
... | Expect a Note object from mingus.containers and save it into a MIDI
file, specified in file.
You can set the velocity and channel in Note.velocity and Note.channel. | [
"Expect",
"a",
"Note",
"object",
"from",
"mingus",
".",
"containers",
"and",
"save",
"it",
"into",
"a",
"MIDI",
"file",
"specified",
"in",
"file",
"."
] | python | train |
fhamborg/news-please | newsplease/__init__.py | https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/__init__.py#L36-L70 | def from_html(html, url=None, download_date=None):
"""
Extracts relevant information from an HTML page given as a string. This function does not invoke scrapy but only
uses the article extractor. If you have the original URL make sure to provide it as this helps NewsPlease
to extract the... | [
"def",
"from_html",
"(",
"html",
",",
"url",
"=",
"None",
",",
"download_date",
"=",
"None",
")",
":",
"extractor",
"=",
"article_extractor",
".",
"Extractor",
"(",
"[",
"'newspaper_extractor'",
",",
"'readability_extractor'",
",",
"'date_extractor'",
",",
"'lan... | Extracts relevant information from an HTML page given as a string. This function does not invoke scrapy but only
uses the article extractor. If you have the original URL make sure to provide it as this helps NewsPlease
to extract the publishing date and title.
:param html:
:param url:
... | [
"Extracts",
"relevant",
"information",
"from",
"an",
"HTML",
"page",
"given",
"as",
"a",
"string",
".",
"This",
"function",
"does",
"not",
"invoke",
"scrapy",
"but",
"only",
"uses",
"the",
"article",
"extractor",
".",
"If",
"you",
"have",
"the",
"original",
... | python | train |
Azure/azure-uamqp-python | uamqp/address.py | https://github.com/Azure/azure-uamqp-python/blob/b67e4fcaf2e8a337636947523570239c10a58ae2/uamqp/address.py#L134-L146 | def _validate_address(self, address):
"""Confirm that supplied address is a valid URL and
has an `amqp` or `amqps` scheme.
:param address: The endpiont URL.
:type address: str
:rtype: ~urllib.parse.ParseResult
"""
parsed = compat.urlparse(address)
if not ... | [
"def",
"_validate_address",
"(",
"self",
",",
"address",
")",
":",
"parsed",
"=",
"compat",
".",
"urlparse",
"(",
"address",
")",
"if",
"not",
"parsed",
".",
"path",
":",
"raise",
"ValueError",
"(",
"\"Invalid {} address: {}\"",
".",
"format",
"(",
"self",
... | Confirm that supplied address is a valid URL and
has an `amqp` or `amqps` scheme.
:param address: The endpiont URL.
:type address: str
:rtype: ~urllib.parse.ParseResult | [
"Confirm",
"that",
"supplied",
"address",
"is",
"a",
"valid",
"URL",
"and",
"has",
"an",
"amqp",
"or",
"amqps",
"scheme",
"."
] | python | train |
Gscorreia89/pyChemometrics | pyChemometrics/ChemometricsScaler.py | https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsScaler.py#L138-L169 | def transform(self, X, y=None, copy=None):
"""
Perform standardization by centering and scaling using the parameters.
:param X: Data matrix to scale.
:type X: numpy.ndarray, shape [n_samples, n_features]
:param y: Passthrough for scikit-learn ``Pipeline`` compatibility.
... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"copy",
"=",
"None",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"'scale_'",
")",
"copy",
"=",
"copy",
"if",
"copy",
"is",
"not",
"None",
"else",
"self",
".",
"copy",
"X",
... | Perform standardization by centering and scaling using the parameters.
:param X: Data matrix to scale.
:type X: numpy.ndarray, shape [n_samples, n_features]
:param y: Passthrough for scikit-learn ``Pipeline`` compatibility.
:type y: None
:param bool copy: Copy the X matrix.
... | [
"Perform",
"standardization",
"by",
"centering",
"and",
"scaling",
"using",
"the",
"parameters",
"."
] | python | train |
reingart/gui2py | gui/doc/ext/autosummary/__init__.py | https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/doc/ext/autosummary/__init__.py#L342-L375 | def mangle_signature(sig, max_chars=30):
"""Reformat a function signature to a more compact form."""
s = re.sub(r"^\((.*)\)$", r"\1", sig).strip()
# Strip strings (which can contain things that confuse the code below)
s = re.sub(r"\\\\", "", s)
s = re.sub(r"\\'", "", s)
s = re.sub(r"'[^']*'", "... | [
"def",
"mangle_signature",
"(",
"sig",
",",
"max_chars",
"=",
"30",
")",
":",
"s",
"=",
"re",
".",
"sub",
"(",
"r\"^\\((.*)\\)$\"",
",",
"r\"\\1\"",
",",
"sig",
")",
".",
"strip",
"(",
")",
"# Strip strings (which can contain things that confuse the code below)",
... | Reformat a function signature to a more compact form. | [
"Reformat",
"a",
"function",
"signature",
"to",
"a",
"more",
"compact",
"form",
"."
] | python | test |
Carreau/Love | love/flit.py | https://github.com/Carreau/Love/blob/a85d1139b32ee926b3bee73447e32e89b86983ba/love/flit.py#L11-L28 | def modify_config(path):
"""
Context manager to modify a flit config file.
Will read the config file, validate the config, yield the config object,
validate and write back the config to the file on exit
"""
if isinstance(path, str):
path = Path(path)
config = _read_pkg_ini(path)
... | [
"def",
"modify_config",
"(",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"path",
"=",
"Path",
"(",
"path",
")",
"config",
"=",
"_read_pkg_ini",
"(",
"path",
")",
"_validate_config",
"(",
"config",
",",
"path",
")",
"# don't... | Context manager to modify a flit config file.
Will read the config file, validate the config, yield the config object,
validate and write back the config to the file on exit | [
"Context",
"manager",
"to",
"modify",
"a",
"flit",
"config",
"file",
"."
] | python | train |
globocom/GloboNetworkAPI-client-python | networkapiclient/Ip.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Ip.py#L275-L304 | def get_available_ip6(self, id_network6):
"""
Get a available IP in Network ipv6
:param id_network6: Network ipv6 identifier. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'ip6': {'ip6': < available_ip6 >}}
:ra... | [
"def",
"get_available_ip6",
"(",
"self",
",",
"id_network6",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_network6",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Network ipv6 identifier is invalid or was not informed.'",
")",
"url",
"=",
"'ip/availableip6/... | Get a available IP in Network ipv6
:param id_network6: Network ipv6 identifier. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'ip6': {'ip6': < available_ip6 >}}
:raise IpNotAvailableError: Network dont have available IP.
... | [
"Get",
"a",
"available",
"IP",
"in",
"Network",
"ipv6"
] | python | train |
NLeSC/scriptcwl | scriptcwl/library.py | https://github.com/NLeSC/scriptcwl/blob/33bb847a875379da3a5702c7a98dfa585306b960/scriptcwl/library.py#L83-L131 | def load_steps(working_dir=None, steps_dir=None, step_file=None,
step_list=None):
"""Return a dictionary containing Steps read from file.
Args:
steps_dir (str, optional): path to directory containing CWL files.
step_file (str, optional): path or http(s) url to a single CWL file.
... | [
"def",
"load_steps",
"(",
"working_dir",
"=",
"None",
",",
"steps_dir",
"=",
"None",
",",
"step_file",
"=",
"None",
",",
"step_list",
"=",
"None",
")",
":",
"if",
"steps_dir",
"is",
"not",
"None",
":",
"step_files",
"=",
"glob",
".",
"glob",
"(",
"os",... | Return a dictionary containing Steps read from file.
Args:
steps_dir (str, optional): path to directory containing CWL files.
step_file (str, optional): path or http(s) url to a single CWL file.
step_list (list, optional): a list of directories, urls or local file
paths to CWL f... | [
"Return",
"a",
"dictionary",
"containing",
"Steps",
"read",
"from",
"file",
"."
] | python | train |
google/grr | grr/server/grr_response_server/artifact_registry.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact_registry.py#L760-L774 | def GetArtifactParserDependencies(rdf_artifact):
"""Return the set of knowledgebase path dependencies required by the parser.
Args:
rdf_artifact: RDF artifact object.
Returns:
A set of strings for the required kb objects e.g.
["users.appdata", "systemroot"]
"""
deps = set()
processors = parser... | [
"def",
"GetArtifactParserDependencies",
"(",
"rdf_artifact",
")",
":",
"deps",
"=",
"set",
"(",
")",
"processors",
"=",
"parser",
".",
"Parser",
".",
"GetClassesByArtifact",
"(",
"rdf_artifact",
".",
"name",
")",
"for",
"p",
"in",
"processors",
":",
"deps",
... | Return the set of knowledgebase path dependencies required by the parser.
Args:
rdf_artifact: RDF artifact object.
Returns:
A set of strings for the required kb objects e.g.
["users.appdata", "systemroot"] | [
"Return",
"the",
"set",
"of",
"knowledgebase",
"path",
"dependencies",
"required",
"by",
"the",
"parser",
"."
] | python | train |
dls-controls/pymalcolm | malcolm/core/future.py | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/future.py#L50-L68 | def exception(self, timeout=None):
"""Return the exception raised by the call that the future represents.
Args:
timeout: The number of seconds to wait for the exception if the
future isn't done. If None, then there is no limit on the wait
time.
Retur... | [
"def",
"exception",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"_state",
"==",
"self",
".",
"RUNNING",
":",
"self",
".",
"_context",
".",
"wait_all_futures",
"(",
"[",
"self",
"]",
",",
"timeout",
")",
"return",
"self",
".... | Return the exception raised by the call that the future represents.
Args:
timeout: The number of seconds to wait for the exception if the
future isn't done. If None, then there is no limit on the wait
time.
Returns:
The exception raised by the ca... | [
"Return",
"the",
"exception",
"raised",
"by",
"the",
"call",
"that",
"the",
"future",
"represents",
"."
] | python | train |
exa-analytics/exa | exa/core/numerical.py | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/numerical.py#L371-L391 | def check_key(data_object, key, cardinal=False):
"""
Update the value of an index key by matching values or getting positionals.
"""
itype = (int, np.int32, np.int64)
if not isinstance(key, itype + (slice, tuple, list, np.ndarray)):
raise KeyError("Unknown key type {} for key {}".format(type... | [
"def",
"check_key",
"(",
"data_object",
",",
"key",
",",
"cardinal",
"=",
"False",
")",
":",
"itype",
"=",
"(",
"int",
",",
"np",
".",
"int32",
",",
"np",
".",
"int64",
")",
"if",
"not",
"isinstance",
"(",
"key",
",",
"itype",
"+",
"(",
"slice",
... | Update the value of an index key by matching values or getting positionals. | [
"Update",
"the",
"value",
"of",
"an",
"index",
"key",
"by",
"matching",
"values",
"or",
"getting",
"positionals",
"."
] | python | train |
flowersteam/explauto | explauto/interest_model/tree.py | https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/interest_model/tree.py#L736-L743 | def fold_up(self, f_inter, f_leaf):
"""
Apply recursively the function f_inter from leaves to root, begining with function f_leaf on leaves.
"""
return f_leaf(self) if self.leafnode else f_inter(self,
self.lower.fold_up(f... | [
"def",
"fold_up",
"(",
"self",
",",
"f_inter",
",",
"f_leaf",
")",
":",
"return",
"f_leaf",
"(",
"self",
")",
"if",
"self",
".",
"leafnode",
"else",
"f_inter",
"(",
"self",
",",
"self",
".",
"lower",
".",
"fold_up",
"(",
"f_inter",
",",
"f_leaf",
")"... | Apply recursively the function f_inter from leaves to root, begining with function f_leaf on leaves. | [
"Apply",
"recursively",
"the",
"function",
"f_inter",
"from",
"leaves",
"to",
"root",
"begining",
"with",
"function",
"f_leaf",
"on",
"leaves",
"."
] | python | train |
openstack/python-scciclient | scciclient/irmc/ipmi.py | https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/ipmi.py#L75-L109 | def get_tpm_status(d_info):
"""Get the TPM support status.
Get the TPM support status of the node.
:param d_info: the list of ipmitool parameters for accessing a node.
:returns: TPM support status
"""
# note:
# Get TPM support status : ipmi cmd '0xF5', valid flags '0xC0'
#
# $ ipm... | [
"def",
"get_tpm_status",
"(",
"d_info",
")",
":",
"# note:",
"# Get TPM support status : ipmi cmd '0xF5', valid flags '0xC0'",
"#",
"# $ ipmitool raw 0x2E 0xF5 0x80 0x28 0x00 0x81 0xC0",
"#",
"# Raw response:",
"# 80 28 00 C0 C0: True",
"# 80 28 00 -- --: False (other values than 'C0 C0')"... | Get the TPM support status.
Get the TPM support status of the node.
:param d_info: the list of ipmitool parameters for accessing a node.
:returns: TPM support status | [
"Get",
"the",
"TPM",
"support",
"status",
"."
] | python | train |
bunq/sdk_python | bunq/sdk/security.py | https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/security.py#L147-L163 | def encrypt(api_context, request_bytes, custom_headers):
"""
:type api_context: bunq.sdk.context.ApiContext
:type request_bytes: bytes
:type custom_headers: dict[str, str]
:rtype: bytes
"""
key = Random.get_random_bytes(_AES_KEY_SIZE)
iv = Random.get_random_bytes(_BLOCK_SIZE)
_add_... | [
"def",
"encrypt",
"(",
"api_context",
",",
"request_bytes",
",",
"custom_headers",
")",
":",
"key",
"=",
"Random",
".",
"get_random_bytes",
"(",
"_AES_KEY_SIZE",
")",
"iv",
"=",
"Random",
".",
"get_random_bytes",
"(",
"_BLOCK_SIZE",
")",
"_add_header_client_encryp... | :type api_context: bunq.sdk.context.ApiContext
:type request_bytes: bytes
:type custom_headers: dict[str, str]
:rtype: bytes | [
":",
"type",
"api_context",
":",
"bunq",
".",
"sdk",
".",
"context",
".",
"ApiContext",
":",
"type",
"request_bytes",
":",
"bytes",
":",
"type",
"custom_headers",
":",
"dict",
"[",
"str",
"str",
"]"
] | python | train |
phaethon/kamene | kamene/contrib/gsm_um.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L868-L882 | def pagingRequestType2(MobileId_presence=0):
"""PAGING REQUEST TYPE 2 Section 9.1.23"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x22) # 00100010
d = PageModeAndChannelNeeded()
f = MobileId()
g = MobileId()
packet = a / b / c / d / f / g
if MobileId_presence is... | [
"def",
"pagingRequestType2",
"(",
"MobileId_presence",
"=",
"0",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x22",
")",
"# 00100010",
"d",
"=",
"PageModeA... | PAGING REQUEST TYPE 2 Section 9.1.23 | [
"PAGING",
"REQUEST",
"TYPE",
"2",
"Section",
"9",
".",
"1",
".",
"23"
] | python | train |
theelous3/asks | asks/request_object.py | https://github.com/theelous3/asks/blob/ea522ea971ecb031d488a6301dc2718516cadcd6/asks/request_object.py#L641-L657 | async def _auth_handler_post_get_auth(self):
'''
If the user supplied auth does rely on a response
(is a PostResponseAuth object) then we call the auth's __call__
returning a dict to update the request's headers with, as long
as there is an appropriate 401'd response object to ca... | [
"async",
"def",
"_auth_handler_post_get_auth",
"(",
"self",
")",
":",
"# pylint: disable=not-callable",
"if",
"isinstance",
"(",
"self",
".",
"auth",
",",
"PostResponseAuth",
")",
":",
"if",
"self",
".",
"history_objects",
":",
"authable_resp",
"=",
"self",
".",
... | If the user supplied auth does rely on a response
(is a PostResponseAuth object) then we call the auth's __call__
returning a dict to update the request's headers with, as long
as there is an appropriate 401'd response object to calculate auth
details from. | [
"If",
"the",
"user",
"supplied",
"auth",
"does",
"rely",
"on",
"a",
"response",
"(",
"is",
"a",
"PostResponseAuth",
"object",
")",
"then",
"we",
"call",
"the",
"auth",
"s",
"__call__",
"returning",
"a",
"dict",
"to",
"update",
"the",
"request",
"s",
"hea... | python | train |
dcramer/logan | logan/runner.py | https://github.com/dcramer/logan/blob/8b18456802d631a822e2823bf9a4e9810a15a20e/logan/runner.py#L63-L141 | def configure_app(config_path=None, project=None, default_config_path=None,
default_settings=None, settings_initializer=None,
settings_envvar=None, initializer=None, allow_extras=True,
config_module_name=None, runner_name=None, on_configure=None):
"""
:param... | [
"def",
"configure_app",
"(",
"config_path",
"=",
"None",
",",
"project",
"=",
"None",
",",
"default_config_path",
"=",
"None",
",",
"default_settings",
"=",
"None",
",",
"settings_initializer",
"=",
"None",
",",
"settings_envvar",
"=",
"None",
",",
"initializer"... | :param project: should represent the canonical name for the project, generally
the same name it assigned in distutils.
:param default_config_path: the default location for the configuration file.
:param default_settings: default settings to load (think inheritence).
:param settings_initializer: a ca... | [
":",
"param",
"project",
":",
"should",
"represent",
"the",
"canonical",
"name",
"for",
"the",
"project",
"generally",
"the",
"same",
"name",
"it",
"assigned",
"in",
"distutils",
".",
":",
"param",
"default_config_path",
":",
"the",
"default",
"location",
"for... | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/video/base_vae.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/base_vae.py#L97-L118 | def construct_latent_tower(self, images, time_axis):
"""Create the latent tower."""
# No latent in the first phase
first_phase = tf.less(
self.get_iteration_num(), self.hparams.num_iterations_1st_stage)
# use all frames by default but this allows more
# predicted frames at inference time
... | [
"def",
"construct_latent_tower",
"(",
"self",
",",
"images",
",",
"time_axis",
")",
":",
"# No latent in the first phase",
"first_phase",
"=",
"tf",
".",
"less",
"(",
"self",
".",
"get_iteration_num",
"(",
")",
",",
"self",
".",
"hparams",
".",
"num_iterations_1... | Create the latent tower. | [
"Create",
"the",
"latent",
"tower",
"."
] | python | train |
opencobra/memote | memote/support/annotation.py | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/annotation.py#L125-L143 | def find_components_without_annotation(model, components):
"""
Find model components with empty annotation attributes.
Parameters
----------
model : cobra.Model
A cobrapy metabolic model.
components : {"metabolites", "reactions", "genes"}
A string denoting `cobra.Model` componen... | [
"def",
"find_components_without_annotation",
"(",
"model",
",",
"components",
")",
":",
"return",
"[",
"elem",
"for",
"elem",
"in",
"getattr",
"(",
"model",
",",
"components",
")",
"if",
"elem",
".",
"annotation",
"is",
"None",
"or",
"len",
"(",
"elem",
".... | Find model components with empty annotation attributes.
Parameters
----------
model : cobra.Model
A cobrapy metabolic model.
components : {"metabolites", "reactions", "genes"}
A string denoting `cobra.Model` components.
Returns
-------
list
The components without an... | [
"Find",
"model",
"components",
"with",
"empty",
"annotation",
"attributes",
"."
] | python | train |
bwohlberg/sporco | sporco/dictlrn/cbpdndl.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/dictlrn/cbpdndl.py#L43-L57 | def ConvBPDNOptionsDefaults(method='admm'):
"""Get defaults dict for the ConvBPDN class specified by the ``method``
parameter.
"""
dflt = copy.deepcopy(cbpdn_class_label_lookup(method).Options.defaults)
if method == 'admm':
dflt.update({'MaxMainIter': 1, 'AutoRho':
{'Pe... | [
"def",
"ConvBPDNOptionsDefaults",
"(",
"method",
"=",
"'admm'",
")",
":",
"dflt",
"=",
"copy",
".",
"deepcopy",
"(",
"cbpdn_class_label_lookup",
"(",
"method",
")",
".",
"Options",
".",
"defaults",
")",
"if",
"method",
"==",
"'admm'",
":",
"dflt",
".",
"up... | Get defaults dict for the ConvBPDN class specified by the ``method``
parameter. | [
"Get",
"defaults",
"dict",
"for",
"the",
"ConvBPDN",
"class",
"specified",
"by",
"the",
"method",
"parameter",
"."
] | python | train |
SolutionsCloud/apidoc | apidoc/service/template.py | https://github.com/SolutionsCloud/apidoc/blob/1ee25d886a5bea11dc744c2f3d0abb0b55d942e1/apidoc/service/template.py#L19-L84 | def render(self, sources, config, out=sys.stdout):
"""Render the documentation as defined in config Object
"""
logger = logging.getLogger()
template = self.env.get_template(self.input)
output = template.render(sources=sources, layout=config["output"]["layout"], config=config["out... | [
"def",
"render",
"(",
"self",
",",
"sources",
",",
"config",
",",
"out",
"=",
"sys",
".",
"stdout",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"template",
"=",
"self",
".",
"env",
".",
"get_template",
"(",
"self",
".",
"input",
... | Render the documentation as defined in config Object | [
"Render",
"the",
"documentation",
"as",
"defined",
"in",
"config",
"Object"
] | python | train |
mosdef-hub/mbuild | mbuild/coordinate_transform.py | https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/coordinate_transform.py#L256-L262 | def angle(u, v, w=None):
"""Returns the angle in radians between two vectors. """
if w is not None:
u = u - v
v = w - v
c = np.dot(u, v) / norm(u) / norm(v)
return np.arccos(np.clip(c, -1, 1)) | [
"def",
"angle",
"(",
"u",
",",
"v",
",",
"w",
"=",
"None",
")",
":",
"if",
"w",
"is",
"not",
"None",
":",
"u",
"=",
"u",
"-",
"v",
"v",
"=",
"w",
"-",
"v",
"c",
"=",
"np",
".",
"dot",
"(",
"u",
",",
"v",
")",
"/",
"norm",
"(",
"u",
... | Returns the angle in radians between two vectors. | [
"Returns",
"the",
"angle",
"in",
"radians",
"between",
"two",
"vectors",
"."
] | python | train |
atztogo/phono3py | phono3py/phonon3/displacement_fc3.py | https://github.com/atztogo/phono3py/blob/edfcf36cdc7c5392906a9df57d3ee0f3141404df/phono3py/phonon3/displacement_fc3.py#L52-L148 | def get_third_order_displacements(cell,
symmetry,
is_plusminus='auto',
is_diagonal=False):
"""Create dispalcement dataset
Note
----
Atoms 1, 2, and 3 are defined as follows:
Atom 1: The first disp... | [
"def",
"get_third_order_displacements",
"(",
"cell",
",",
"symmetry",
",",
"is_plusminus",
"=",
"'auto'",
",",
"is_diagonal",
"=",
"False",
")",
":",
"positions",
"=",
"cell",
".",
"get_scaled_positions",
"(",
")",
"lattice",
"=",
"cell",
".",
"get_cell",
"(",... | Create dispalcement dataset
Note
----
Atoms 1, 2, and 3 are defined as follows:
Atom 1: The first displaced atom. Third order force constant
between Atoms 1, 2, and 3 is calculated.
Atom 2: The second displaced atom. Second order force constant
between Atoms 2 and 3 is calc... | [
"Create",
"dispalcement",
"dataset"
] | python | train |
gem/oq-engine | openquake/hazardlib/geo/mesh.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L395-L455 | def _get_proj_enclosing_polygon(self):
"""
See :meth:`Mesh._get_proj_enclosing_polygon`.
:class:`RectangularMesh` contains an information about relative
positions of points, so it allows to define the minimum polygon,
containing the projection of the mesh, which doesn't necessar... | [
"def",
"_get_proj_enclosing_polygon",
"(",
"self",
")",
":",
"if",
"self",
".",
"lons",
".",
"size",
"<",
"4",
":",
"# the mesh doesn't contain even a single cell",
"return",
"self",
".",
"_get_proj_convex_hull",
"(",
")",
"proj",
"=",
"geo_utils",
".",
"Orthograp... | See :meth:`Mesh._get_proj_enclosing_polygon`.
:class:`RectangularMesh` contains an information about relative
positions of points, so it allows to define the minimum polygon,
containing the projection of the mesh, which doesn't necessarily
have to be convex (in contrast to :class:`Mesh`... | [
"See",
":",
"meth",
":",
"Mesh",
".",
"_get_proj_enclosing_polygon",
"."
] | python | train |
linuxsoftware/ls.joyous | ls/joyous/models/calendar.py | https://github.com/linuxsoftware/ls.joyous/blob/316283140ca5171a68ad3170a5964fdc89be0b56/ls/joyous/models/calendar.py#L462-L465 | def _getPastEvents(self, request):
"""Return the past events in this site."""
home = request.site.root_page
return getAllPastEvents(request, home=home) | [
"def",
"_getPastEvents",
"(",
"self",
",",
"request",
")",
":",
"home",
"=",
"request",
".",
"site",
".",
"root_page",
"return",
"getAllPastEvents",
"(",
"request",
",",
"home",
"=",
"home",
")"
] | Return the past events in this site. | [
"Return",
"the",
"past",
"events",
"in",
"this",
"site",
"."
] | python | train |
mmerickel/subparse | src/subparse/__init__.py | https://github.com/mmerickel/subparse/blob/a4bb94b709c0776ccf81f6dcb47922fa5910c19f/src/subparse/__init__.py#L256-L271 | def parse_docstring(docstring):
"""
Parse a PEP-257 docstring.
SHORT -> blank line -> LONG
"""
short_desc = long_desc = ''
if docstring:
docstring = trim(docstring.lstrip('\n'))
lines = docstring.split('\n\n', 1)
short_desc = lines[0].strip().replace('\n', ' ')
... | [
"def",
"parse_docstring",
"(",
"docstring",
")",
":",
"short_desc",
"=",
"long_desc",
"=",
"''",
"if",
"docstring",
":",
"docstring",
"=",
"trim",
"(",
"docstring",
".",
"lstrip",
"(",
"'\\n'",
")",
")",
"lines",
"=",
"docstring",
".",
"split",
"(",
"'\\... | Parse a PEP-257 docstring.
SHORT -> blank line -> LONG | [
"Parse",
"a",
"PEP",
"-",
"257",
"docstring",
"."
] | python | train |
ejeschke/ginga | ginga/rv/plugins/PixTable.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/PixTable.py#L711-L717 | def set_mode_cb(self, mode, tf):
"""Called when one of the Move/Draw/Edit radio buttons is selected."""
if tf:
self.canvas.set_draw_mode(mode)
if mode == 'edit':
self.edit_select_mark()
return True | [
"def",
"set_mode_cb",
"(",
"self",
",",
"mode",
",",
"tf",
")",
":",
"if",
"tf",
":",
"self",
".",
"canvas",
".",
"set_draw_mode",
"(",
"mode",
")",
"if",
"mode",
"==",
"'edit'",
":",
"self",
".",
"edit_select_mark",
"(",
")",
"return",
"True"
] | Called when one of the Move/Draw/Edit radio buttons is selected. | [
"Called",
"when",
"one",
"of",
"the",
"Move",
"/",
"Draw",
"/",
"Edit",
"radio",
"buttons",
"is",
"selected",
"."
] | python | train |
gwpy/gwpy | gwpy/signal/spectral/_lal.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/signal/spectral/_lal.py#L89-L133 | def generate_window(length, window=None, dtype='float64'):
"""Generate a time-domain window for use in a LAL FFT
Parameters
----------
length : `int`
length of window in samples.
window : `str`, `tuple`
name of window to generate, default: ``('kaiser', 24)``. Give
`str` for... | [
"def",
"generate_window",
"(",
"length",
",",
"window",
"=",
"None",
",",
"dtype",
"=",
"'float64'",
")",
":",
"from",
".",
".",
".",
"utils",
".",
"lal",
"import",
"(",
"find_typed_function",
",",
"to_lal_type_str",
")",
"if",
"window",
"is",
"None",
":... | Generate a time-domain window for use in a LAL FFT
Parameters
----------
length : `int`
length of window in samples.
window : `str`, `tuple`
name of window to generate, default: ``('kaiser', 24)``. Give
`str` for simple windows, or tuple of ``(name, *args)`` for
compli... | [
"Generate",
"a",
"time",
"-",
"domain",
"window",
"for",
"use",
"in",
"a",
"LAL",
"FFT"
] | python | train |
ulule/django-badgify | badgify/recipe.py | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/recipe.py#L200-L216 | def get_obsolete_user_ids(self, db_read=None):
"""
Returns obsolete users IDs to unaward.
"""
db_read = db_read or self.db_read
already_awarded_ids = self.get_already_awarded_user_ids(db_read=db_read, show_log=False)
current_ids = self.get_current_user_ids(db_read=db_rea... | [
"def",
"get_obsolete_user_ids",
"(",
"self",
",",
"db_read",
"=",
"None",
")",
":",
"db_read",
"=",
"db_read",
"or",
"self",
".",
"db_read",
"already_awarded_ids",
"=",
"self",
".",
"get_already_awarded_user_ids",
"(",
"db_read",
"=",
"db_read",
",",
"show_log",... | Returns obsolete users IDs to unaward. | [
"Returns",
"obsolete",
"users",
"IDs",
"to",
"unaward",
"."
] | python | train |
has2k1/plotnine | plotnine/facets/facet_wrap.py | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet_wrap.py#L217-L233 | def draw_label(self, layout_info, ax):
"""
Draw facet label onto the axes.
This function will only draw labels if they are needed.
Parameters
----------
layout_info : dict-like
facet information
ax : axes
Axes to label
"""
... | [
"def",
"draw_label",
"(",
"self",
",",
"layout_info",
",",
"ax",
")",
":",
"label_info",
"=",
"layout_info",
"[",
"list",
"(",
"self",
".",
"vars",
")",
"]",
"label_info",
".",
"_meta",
"=",
"{",
"'dimension'",
":",
"'cols'",
"}",
"label_info",
"=",
"s... | Draw facet label onto the axes.
This function will only draw labels if they are needed.
Parameters
----------
layout_info : dict-like
facet information
ax : axes
Axes to label | [
"Draw",
"facet",
"label",
"onto",
"the",
"axes",
"."
] | python | train |
SeabornGames/RequestClient | seaborn/request_client/endpoint.py | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/endpoint.py#L126-L146 | def _parse_function_return_types_from_doc(cls, doc):
"""
This will extract the return type for list of lists so that the
repr can display the header.
:param doc: str of the function doc
:return dict of {func.__name__:{'api_type':'type','col_name':[],
... | [
"def",
"_parse_function_return_types_from_doc",
"(",
"cls",
",",
"doc",
")",
":",
"data",
"=",
"dict",
"(",
"name",
"=",
"''",
",",
"col_types",
"=",
"[",
"]",
",",
"col_names",
"=",
"[",
"]",
",",
"_type",
"=",
"None",
")",
"if",
"doc",
":",
"return... | This will extract the return type for list of lists so that the
repr can display the header.
:param doc: str of the function doc
:return dict of {func.__name__:{'api_type':'type','col_name':[],
'col_type':[],'repr_type':None}} | [
"This",
"will",
"extract",
"the",
"return",
"type",
"for",
"list",
"of",
"lists",
"so",
"that",
"the",
"repr",
"can",
"display",
"the",
"header",
".",
":",
"param",
"doc",
":",
"str",
"of",
"the",
"function",
"doc",
":",
"return",
"dict",
"of",
"{",
... | python | train |
Fantomas42/django-blog-zinnia | zinnia/views/trackback.py | https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/views/trackback.py#L27-L31 | def dispatch(self, *args, **kwargs):
"""
Decorate the view dispatcher with csrf_exempt.
"""
return super(EntryTrackback, self).dispatch(*args, **kwargs) | [
"def",
"dispatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"EntryTrackback",
",",
"self",
")",
".",
"dispatch",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Decorate the view dispatcher with csrf_exempt. | [
"Decorate",
"the",
"view",
"dispatcher",
"with",
"csrf_exempt",
"."
] | python | train |
adafruit/Adafruit_Python_BluefruitLE | Adafruit_BluefruitLE/corebluetooth/metadata.py | https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/corebluetooth/metadata.py#L81-L86 | def remove(self, cbobject):
"""Remove any metadata associated with the provided CoreBluetooth object.
"""
with self._lock:
if cbobject in self._metadata:
del self._metadata[cbobject] | [
"def",
"remove",
"(",
"self",
",",
"cbobject",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"cbobject",
"in",
"self",
".",
"_metadata",
":",
"del",
"self",
".",
"_metadata",
"[",
"cbobject",
"]"
] | Remove any metadata associated with the provided CoreBluetooth object. | [
"Remove",
"any",
"metadata",
"associated",
"with",
"the",
"provided",
"CoreBluetooth",
"object",
"."
] | python | valid |
saltstack/salt | salt/modules/config.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/config.py#L446-L463 | def gather_bootstrap_script(bootstrap=None):
'''
Download the salt-bootstrap script, and return its location
bootstrap
URL of alternate bootstrap script
CLI Example:
.. code-block:: bash
salt '*' config.gather_bootstrap_script
'''
if not HAS_CLOUD:
return False, '... | [
"def",
"gather_bootstrap_script",
"(",
"bootstrap",
"=",
"None",
")",
":",
"if",
"not",
"HAS_CLOUD",
":",
"return",
"False",
",",
"'config.gather_bootstrap_script is unavailable'",
"ret",
"=",
"salt",
".",
"utils",
".",
"cloud",
".",
"update_bootstrap",
"(",
"__op... | Download the salt-bootstrap script, and return its location
bootstrap
URL of alternate bootstrap script
CLI Example:
.. code-block:: bash
salt '*' config.gather_bootstrap_script | [
"Download",
"the",
"salt",
"-",
"bootstrap",
"script",
"and",
"return",
"its",
"location"
] | python | train |
lowandrew/OLCTools | databasesetup/database_setup.py | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/databasesetup/database_setup.py#L103-L112 | def sipprverse_targets(self, databasepath, database_name='sipprverse', download_id='13699538'):
"""
Download OLC-specific sipprverse targets
:param databasepath: path to use to save the database
:param database_name: name of current database
:param download_id: figshare identifie... | [
"def",
"sipprverse_targets",
"(",
"self",
",",
"databasepath",
",",
"database_name",
"=",
"'sipprverse'",
",",
"download_id",
"=",
"'13699538'",
")",
":",
"self",
".",
"custom_databases",
"(",
"databasepath",
"=",
"databasepath",
",",
"database_name",
"=",
"databa... | Download OLC-specific sipprverse targets
:param databasepath: path to use to save the database
:param database_name: name of current database
:param download_id: figshare identifier of .tar.gz file | [
"Download",
"OLC",
"-",
"specific",
"sipprverse",
"targets",
":",
"param",
"databasepath",
":",
"path",
"to",
"use",
"to",
"save",
"the",
"database",
":",
"param",
"database_name",
":",
"name",
"of",
"current",
"database",
":",
"param",
"download_id",
":",
"... | python | train |
contentful/contentful.py | contentful/errors.py | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/errors.py#L203-L221 | def get_error(response):
"""Gets Error by HTTP Status Code"""
errors = {
400: BadRequestError,
401: UnauthorizedError,
403: AccessDeniedError,
404: NotFoundError,
429: RateLimitExceededError,
500: ServerError,
502: BadGatewayError,
503: ServiceUna... | [
"def",
"get_error",
"(",
"response",
")",
":",
"errors",
"=",
"{",
"400",
":",
"BadRequestError",
",",
"401",
":",
"UnauthorizedError",
",",
"403",
":",
"AccessDeniedError",
",",
"404",
":",
"NotFoundError",
",",
"429",
":",
"RateLimitExceededError",
",",
"5... | Gets Error by HTTP Status Code | [
"Gets",
"Error",
"by",
"HTTP",
"Status",
"Code"
] | python | train |
jtwhite79/pyemu | pyemu/utils/helpers.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/utils/helpers.py#L151-L286 | def geostatistical_draws(pst, struct_dict,num_reals=100,sigma_range=4,verbose=True):
""" a helper function to construct a parameter ensenble from a full prior covariance matrix
implied by the geostatistical structure(s) in struct_dict. This function is much more efficient
for problems with lots of pars (>2... | [
"def",
"geostatistical_draws",
"(",
"pst",
",",
"struct_dict",
",",
"num_reals",
"=",
"100",
",",
"sigma_range",
"=",
"4",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"pst",
",",
"str",
")",
":",
"pst",
"=",
"pyemu",
".",
"Pst",
"... | a helper function to construct a parameter ensenble from a full prior covariance matrix
implied by the geostatistical structure(s) in struct_dict. This function is much more efficient
for problems with lots of pars (>200K).
Parameters
----------
pst : pyemu.Pst
a control file (or the name ... | [
"a",
"helper",
"function",
"to",
"construct",
"a",
"parameter",
"ensenble",
"from",
"a",
"full",
"prior",
"covariance",
"matrix",
"implied",
"by",
"the",
"geostatistical",
"structure",
"(",
"s",
")",
"in",
"struct_dict",
".",
"This",
"function",
"is",
"much",
... | python | train |
wavycloud/pyboto3 | pyboto3/codedeploy.py | https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/codedeploy.py#L821-L1019 | def create_deployment_group(applicationName=None, deploymentGroupName=None, deploymentConfigName=None, ec2TagFilters=None, onPremisesInstanceTagFilters=None, autoScalingGroups=None, serviceRoleArn=None, triggerConfigurations=None, alarmConfiguration=None, autoRollbackConfiguration=None, deploymentStyle=None, blueGreenD... | [
"def",
"create_deployment_group",
"(",
"applicationName",
"=",
"None",
",",
"deploymentGroupName",
"=",
"None",
",",
"deploymentConfigName",
"=",
"None",
",",
"ec2TagFilters",
"=",
"None",
",",
"onPremisesInstanceTagFilters",
"=",
"None",
",",
"autoScalingGroups",
"="... | Creates a deployment group to which application revisions will be deployed.
See also: AWS API Documentation
:example: response = client.create_deployment_group(
applicationName='string',
deploymentGroupName='string',
deploymentConfigName='string',
ec2TagFilters=[
... | [
"Creates",
"a",
"deployment",
"group",
"to",
"which",
"application",
"revisions",
"will",
"be",
"deployed",
".",
"See",
"also",
":",
"AWS",
"API",
"Documentation",
":",
"example",
":",
"response",
"=",
"client",
".",
"create_deployment_group",
"(",
"applicationN... | python | train |
TUT-ARG/sed_eval | sed_eval/audio_tag.py | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/audio_tag.py#L597-L656 | def results_class_wise_average_metrics(self):
"""Class-wise averaged metrics
Returns
-------
dict
results in a dictionary format
"""
class_wise_results = self.results_class_wise_metrics()
class_wise_eer = []
class_wise_fmeasure = []
... | [
"def",
"results_class_wise_average_metrics",
"(",
"self",
")",
":",
"class_wise_results",
"=",
"self",
".",
"results_class_wise_metrics",
"(",
")",
"class_wise_eer",
"=",
"[",
"]",
"class_wise_fmeasure",
"=",
"[",
"]",
"class_wise_precision",
"=",
"[",
"]",
"class_w... | Class-wise averaged metrics
Returns
-------
dict
results in a dictionary format | [
"Class",
"-",
"wise",
"averaged",
"metrics"
] | python | train |
numenta/nupic | src/nupic/frameworks/opf/helpers.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/helpers.py#L64-L75 | def getExperimentDescriptionInterfaceFromModule(module):
"""
:param module: imported description.py module
:returns: (:class:`nupic.frameworks.opf.exp_description_api.DescriptionIface`)
represents the experiment description
"""
result = module.descriptionInterface
assert isinstance(result, exp_... | [
"def",
"getExperimentDescriptionInterfaceFromModule",
"(",
"module",
")",
":",
"result",
"=",
"module",
".",
"descriptionInterface",
"assert",
"isinstance",
"(",
"result",
",",
"exp_description_api",
".",
"DescriptionIface",
")",
",",
"\"expected DescriptionIface-based inst... | :param module: imported description.py module
:returns: (:class:`nupic.frameworks.opf.exp_description_api.DescriptionIface`)
represents the experiment description | [
":",
"param",
"module",
":",
"imported",
"description",
".",
"py",
"module"
] | python | valid |
ejeschke/ginga | ginga/util/io_asdf.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/io_asdf.py#L69-L86 | def loader(filepath, logger=None, **kwargs):
"""
Load an object from an ASDF file.
See :func:`ginga.util.loader` for more info.
TODO: kwargs may contain info about what part of the file to load
"""
# see ginga.util.loader module
# TODO: return an AstroTable if loading a table, etc.
# ... | [
"def",
"loader",
"(",
"filepath",
",",
"logger",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# see ginga.util.loader module",
"# TODO: return an AstroTable if loading a table, etc.",
"# for now, assume always an image",
"from",
"ginga",
"import",
"AstroImage",
"image... | Load an object from an ASDF file.
See :func:`ginga.util.loader` for more info.
TODO: kwargs may contain info about what part of the file to load | [
"Load",
"an",
"object",
"from",
"an",
"ASDF",
"file",
".",
"See",
":",
"func",
":",
"ginga",
".",
"util",
".",
"loader",
"for",
"more",
"info",
"."
] | python | train |
aewallin/allantools | allantools/allantools.py | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L515-L566 | def calc_hdev_phase(phase, rate, mj, stride):
""" main calculation fungtion for HDEV and OHDEV
Parameters
----------
phase: np.array
Phase data in seconds.
rate: float
The sampling rate for phase or frequency, in Hz
mj: int
M index value for stride
stride: int
... | [
"def",
"calc_hdev_phase",
"(",
"phase",
",",
"rate",
",",
"mj",
",",
"stride",
")",
":",
"tau0",
"=",
"1.0",
"/",
"float",
"(",
"rate",
")",
"mj",
"=",
"int",
"(",
"mj",
")",
"stride",
"=",
"int",
"(",
"stride",
")",
"d3",
"=",
"phase",
"[",
"3... | main calculation fungtion for HDEV and OHDEV
Parameters
----------
phase: np.array
Phase data in seconds.
rate: float
The sampling rate for phase or frequency, in Hz
mj: int
M index value for stride
stride: int
Size of stride
Returns
-------
(dev, de... | [
"main",
"calculation",
"fungtion",
"for",
"HDEV",
"and",
"OHDEV"
] | python | train |
apache/incubator-mxnet | python/mxnet/metric.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L112-L133 | def update_dict(self, label, pred):
"""Update the internal evaluation with named label and pred
Parameters
----------
labels : OrderedDict of str -> NDArray
name to array mapping for labels.
preds : OrderedDict of str -> NDArray
name to array mapping of ... | [
"def",
"update_dict",
"(",
"self",
",",
"label",
",",
"pred",
")",
":",
"if",
"self",
".",
"output_names",
"is",
"not",
"None",
":",
"pred",
"=",
"[",
"pred",
"[",
"name",
"]",
"for",
"name",
"in",
"self",
".",
"output_names",
"]",
"else",
":",
"pr... | Update the internal evaluation with named label and pred
Parameters
----------
labels : OrderedDict of str -> NDArray
name to array mapping for labels.
preds : OrderedDict of str -> NDArray
name to array mapping of predicted outputs. | [
"Update",
"the",
"internal",
"evaluation",
"with",
"named",
"label",
"and",
"pred"
] | python | train |
benedictpaten/sonLib | tree.py | https://github.com/benedictpaten/sonLib/blob/1decb75bb439b70721ec776f685ce98e25217d26/tree.py#L543-L554 | def annotateTree(bT, fn):
"""
annotate a tree in an external array using the given function
"""
l = [None]*bT.traversalID.midEnd
def fn2(bT):
l[bT.traversalID.mid] = fn(bT)
if bT.internal:
fn2(bT.left)
fn2(bT.right)
fn2(bT)
return l | [
"def",
"annotateTree",
"(",
"bT",
",",
"fn",
")",
":",
"l",
"=",
"[",
"None",
"]",
"*",
"bT",
".",
"traversalID",
".",
"midEnd",
"def",
"fn2",
"(",
"bT",
")",
":",
"l",
"[",
"bT",
".",
"traversalID",
".",
"mid",
"]",
"=",
"fn",
"(",
"bT",
")"... | annotate a tree in an external array using the given function | [
"annotate",
"a",
"tree",
"in",
"an",
"external",
"array",
"using",
"the",
"given",
"function"
] | python | train |
pyfca/pyfca | pyfca/implications.py | https://github.com/pyfca/pyfca/blob/cf8cea9e76076dbf4bb3f38996dcb5491b0eb0b0/pyfca/implications.py#L170-L191 | def omega(imps):
"""
Calculates a measure for the size of the implication basis: \sum |U||V|
"""
if isinstance(imps,v_Us_dict):
return sum([omega(V) for U,V in imps.items()])#|V|=1
if isinstance(imps,list):
return sum([omega(x) for x in imps])
if isinstance(imps,str):
#im... | [
"def",
"omega",
"(",
"imps",
")",
":",
"if",
"isinstance",
"(",
"imps",
",",
"v_Us_dict",
")",
":",
"return",
"sum",
"(",
"[",
"omega",
"(",
"V",
")",
"for",
"U",
",",
"V",
"in",
"imps",
".",
"items",
"(",
")",
"]",
")",
"#|V|=1",
"if",
"isinst... | Calculates a measure for the size of the implication basis: \sum |U||V| | [
"Calculates",
"a",
"measure",
"for",
"the",
"size",
"of",
"the",
"implication",
"basis",
":",
"\\",
"sum",
"|U||V|"
] | python | train |
regebro/hovercraft | hovercraft/position.py | https://github.com/regebro/hovercraft/blob/d9f63bfdfe1519c4d7a81697ee066e49dc26a30b/hovercraft/position.py#L239-L244 | def position_slides(tree):
"""Position the slides in the tree"""
positions = gather_positions(tree)
positions = calculate_positions(positions)
update_positions(tree, positions) | [
"def",
"position_slides",
"(",
"tree",
")",
":",
"positions",
"=",
"gather_positions",
"(",
"tree",
")",
"positions",
"=",
"calculate_positions",
"(",
"positions",
")",
"update_positions",
"(",
"tree",
",",
"positions",
")"
] | Position the slides in the tree | [
"Position",
"the",
"slides",
"in",
"the",
"tree"
] | python | train |
gem/oq-engine | openquake/hazardlib/gsim/bindi_2011.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bindi_2011.py#L200-L207 | def _get_mechanism(self, rup, C):
"""
Compute the fifth term of the equation 1 described on paragraph :
Get fault type dummy variables, see Table 1
"""
U, SS, NS, RS = self._get_fault_type_dummy_variables(rup)
return C['f1'] * NS + C['f2'] * RS + C['f3'] * SS | [
"def",
"_get_mechanism",
"(",
"self",
",",
"rup",
",",
"C",
")",
":",
"U",
",",
"SS",
",",
"NS",
",",
"RS",
"=",
"self",
".",
"_get_fault_type_dummy_variables",
"(",
"rup",
")",
"return",
"C",
"[",
"'f1'",
"]",
"*",
"NS",
"+",
"C",
"[",
"'f2'",
"... | Compute the fifth term of the equation 1 described on paragraph :
Get fault type dummy variables, see Table 1 | [
"Compute",
"the",
"fifth",
"term",
"of",
"the",
"equation",
"1",
"described",
"on",
"paragraph",
":",
"Get",
"fault",
"type",
"dummy",
"variables",
"see",
"Table",
"1"
] | python | train |
letuananh/chirptext | chirptext/texttaglib.py | https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/texttaglib.py#L588-L598 | def get(self, sent_id, **kwargs):
''' If sent_id exists, remove and return the associated sentence object else return default.
If no default is provided, KeyError will be raised.'''
if sent_id is not None and not isinstance(sent_id, int):
sent_id = int(sent_id)
if sent_id is ... | [
"def",
"get",
"(",
"self",
",",
"sent_id",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"sent_id",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"sent_id",
",",
"int",
")",
":",
"sent_id",
"=",
"int",
"(",
"sent_id",
")",
"if",
"sent_id",
"is",... | If sent_id exists, remove and return the associated sentence object else return default.
If no default is provided, KeyError will be raised. | [
"If",
"sent_id",
"exists",
"remove",
"and",
"return",
"the",
"associated",
"sentence",
"object",
"else",
"return",
"default",
".",
"If",
"no",
"default",
"is",
"provided",
"KeyError",
"will",
"be",
"raised",
"."
] | python | train |
flukso/tmpo-py | tmpo/__init__.py | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L399-L424 | def first_timestamp(self, sid, epoch=False):
"""
Get the first available timestamp for a sensor
Parameters
----------
sid : str
SensorID
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
... | [
"def",
"first_timestamp",
"(",
"self",
",",
"sid",
",",
"epoch",
"=",
"False",
")",
":",
"first_block",
"=",
"self",
".",
"dbcur",
".",
"execute",
"(",
"SQL_TMPO_FIRST",
",",
"(",
"sid",
",",
")",
")",
".",
"fetchone",
"(",
")",
"if",
"first_block",
... | Get the first available timestamp for a sensor
Parameters
----------
sid : str
SensorID
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
Returns
-------
pd.Timestamp | int | [
"Get",
"the",
"first",
"available",
"timestamp",
"for",
"a",
"sensor"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.