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 |
|---|---|---|---|---|---|---|---|---|
hbldh/dlxsudoku | dlxsudoku/sudoku.py | https://github.com/hbldh/dlxsudoku/blob/8d774e0883eb615533d04f07e58a95db716226e0/dlxsudoku/sudoku.py#L147-L150 | def row_iter(self):
"""Get an iterator over all rows in the Sudoku"""
for k in utils.range_(self.side):
yield self.row(k) | [
"def",
"row_iter",
"(",
"self",
")",
":",
"for",
"k",
"in",
"utils",
".",
"range_",
"(",
"self",
".",
"side",
")",
":",
"yield",
"self",
".",
"row",
"(",
"k",
")"
] | Get an iterator over all rows in the Sudoku | [
"Get",
"an",
"iterator",
"over",
"all",
"rows",
"in",
"the",
"Sudoku"
] | python | train |
inspirehep/refextract | refextract/references/text.py | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/text.py#L145-L152 | def match_pagination(ref_line):
"""Remove footer pagination from references lines"""
pattern = ur'\(?\[?(\d{1,4})\]?\)?\.?\s*$'
re_footer = re.compile(pattern, re.UNICODE)
match = re_footer.match(ref_line)
if match:
return int(match.group(1))
return None | [
"def",
"match_pagination",
"(",
"ref_line",
")",
":",
"pattern",
"=",
"ur'\\(?\\[?(\\d{1,4})\\]?\\)?\\.?\\s*$'",
"re_footer",
"=",
"re",
".",
"compile",
"(",
"pattern",
",",
"re",
".",
"UNICODE",
")",
"match",
"=",
"re_footer",
".",
"match",
"(",
"ref_line",
"... | Remove footer pagination from references lines | [
"Remove",
"footer",
"pagination",
"from",
"references",
"lines"
] | python | train |
blockstack/blockstack-core | blockstack/lib/operations/namespacepreorder.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/namespacepreorder.py#L137-L159 | def get_namespace_preorder_burn_info( outputs ):
"""
Given the set of outputs, find the fee sent
to our burn address.
Return the fee and burn address on success as {'op_fee': ..., 'burn_address': ...}
Return None if not found
"""
if len(outputs) < 3:
# not a well-formed preorde... | [
"def",
"get_namespace_preorder_burn_info",
"(",
"outputs",
")",
":",
"if",
"len",
"(",
"outputs",
")",
"<",
"3",
":",
"# not a well-formed preorder ",
"return",
"None",
"op_fee",
"=",
"outputs",
"[",
"2",
"]",
"[",
"'value'",
"]",
"burn_address",
"=",
"None",
... | Given the set of outputs, find the fee sent
to our burn address.
Return the fee and burn address on success as {'op_fee': ..., 'burn_address': ...}
Return None if not found | [
"Given",
"the",
"set",
"of",
"outputs",
"find",
"the",
"fee",
"sent",
"to",
"our",
"burn",
"address",
".",
"Return",
"the",
"fee",
"and",
"burn",
"address",
"on",
"success",
"as",
"{",
"op_fee",
":",
"...",
"burn_address",
":",
"...",
"}",
"Return",
"N... | python | train |
digi604/django-smart-selects | smart_selects/views.py | https://github.com/digi604/django-smart-selects/blob/05dcc4a3de2874499ff3b9a3dfac5c623206e3e5/smart_selects/views.py#L94-L130 | def filterchain_all(request, app, model, field, foreign_key_app_name,
foreign_key_model_name, foreign_key_field_name, value):
"""Returns filtered results followed by excluded results below."""
model_class = get_model(app, model)
keywords = get_keywords(field, value)
# SECURITY: Make... | [
"def",
"filterchain_all",
"(",
"request",
",",
"app",
",",
"model",
",",
"field",
",",
"foreign_key_app_name",
",",
"foreign_key_model_name",
",",
"foreign_key_field_name",
",",
"value",
")",
":",
"model_class",
"=",
"get_model",
"(",
"app",
",",
"model",
")",
... | Returns filtered results followed by excluded results below. | [
"Returns",
"filtered",
"results",
"followed",
"by",
"excluded",
"results",
"below",
"."
] | python | valid |
dfm/george | george/solvers/basic.py | https://github.com/dfm/george/blob/44819680036387625ee89f81c55104f3c1600759/george/solvers/basic.py#L51-L70 | def compute(self, x, yerr):
"""
Compute and factorize the covariance matrix.
Args:
x (ndarray[nsamples, ndim]): The independent coordinates of the
data points.
yerr (ndarray[nsamples] or float): The Gaussian uncertainties on
the data point... | [
"def",
"compute",
"(",
"self",
",",
"x",
",",
"yerr",
")",
":",
"# Compute the kernel matrix.",
"K",
"=",
"self",
".",
"kernel",
".",
"get_value",
"(",
"x",
")",
"K",
"[",
"np",
".",
"diag_indices_from",
"(",
"K",
")",
"]",
"+=",
"yerr",
"**",
"2",
... | Compute and factorize the covariance matrix.
Args:
x (ndarray[nsamples, ndim]): The independent coordinates of the
data points.
yerr (ndarray[nsamples] or float): The Gaussian uncertainties on
the data points at coordinates ``x``. These values will be
... | [
"Compute",
"and",
"factorize",
"the",
"covariance",
"matrix",
"."
] | python | train |
mozilla/build-mar | src/mardor/reader.py | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L79-L95 | def signature_type(self):
"""Return the signature type used in this MAR.
Returns:
One of None, 'unknown', 'sha1', or 'sha384'
"""
if not self.mardata.signatures:
return None
for sig in self.mardata.signatures.sigs:
if sig.algorithm_id == 1:
... | [
"def",
"signature_type",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"mardata",
".",
"signatures",
":",
"return",
"None",
"for",
"sig",
"in",
"self",
".",
"mardata",
".",
"signatures",
".",
"sigs",
":",
"if",
"sig",
".",
"algorithm_id",
"==",
"1",... | Return the signature type used in this MAR.
Returns:
One of None, 'unknown', 'sha1', or 'sha384' | [
"Return",
"the",
"signature",
"type",
"used",
"in",
"this",
"MAR",
"."
] | python | train |
Azure/azure-sdk-for-python | azure-servicebus/azure/servicebus/control_client/_common_serialization.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/control_client/_common_serialization.py#L254-L280 | def get_entry_properties_from_element(element, include_id, id_prefix_to_skip=None, use_title_as_id=False):
''' get properties from element tree element '''
properties = {}
etag = element.attrib.get(_make_etree_ns_attr_name(_etree_entity_feed_namespaces['m'], 'etag'), None)
if etag is no... | [
"def",
"get_entry_properties_from_element",
"(",
"element",
",",
"include_id",
",",
"id_prefix_to_skip",
"=",
"None",
",",
"use_title_as_id",
"=",
"False",
")",
":",
"properties",
"=",
"{",
"}",
"etag",
"=",
"element",
".",
"attrib",
".",
"get",
"(",
"_make_et... | get properties from element tree element | [
"get",
"properties",
"from",
"element",
"tree",
"element"
] | python | test |
python-diamond/Diamond | src/collectors/memory/memory.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memory/memory.py#L59-L72 | def get_default_config(self):
"""
Returns the default collector settings
"""
config = super(MemoryCollector, self).get_default_config()
config.update({
'path': 'memory',
'method': 'Threaded',
'force_psutil': 'False'
# Collect all th... | [
"def",
"get_default_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"MemoryCollector",
",",
"self",
")",
".",
"get_default_config",
"(",
")",
"config",
".",
"update",
"(",
"{",
"'path'",
":",
"'memory'",
",",
"'method'",
":",
"'Threaded'",
","... | Returns the default collector settings | [
"Returns",
"the",
"default",
"collector",
"settings"
] | python | train |
python-diamond/Diamond | src/diamond/handler/cloudwatch.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/cloudwatch.py#L125-L142 | def get_default_config_help(self):
"""
Returns the help text for the configuration options for this handler
"""
config = super(cloudwatchHandler, self).get_default_config_help()
config.update({
'region': 'AWS region',
'metric': 'Diamond metric name',
... | [
"def",
"get_default_config_help",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"cloudwatchHandler",
",",
"self",
")",
".",
"get_default_config_help",
"(",
")",
"config",
".",
"update",
"(",
"{",
"'region'",
":",
"'AWS region'",
",",
"'metric'",
":",
"... | Returns the help text for the configuration options for this handler | [
"Returns",
"the",
"help",
"text",
"for",
"the",
"configuration",
"options",
"for",
"this",
"handler"
] | python | train |
PrefPy/prefpy | prefpy/mov.py | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mov.py#L533-L556 | def MoV_SNTV(profile, K):
"""
Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile.
"""
# Currently, we expect the profile to contain compl... | [
"def",
"MoV_SNTV",
"(",
"profile",
",",
"K",
")",
":",
"# Currently, we expect the profile to contain complete ordering over candidates.",
"elecType",
"=",
"profile",
".",
"getElecType",
"(",
")",
"if",
"elecType",
"!=",
"\"soc\"",
"and",
"elecType",
"!=",
"\"toc\"",
... | Returns an integer that represents the winning candidate given an election profile.
Tie-breaking rule: numerically increasing order
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"an",
"integer",
"that",
"represents",
"the",
"winning",
"candidate",
"given",
"an",
"election",
"profile",
".",
"Tie",
"-",
"breaking",
"rule",
":",
"numerically",
"increasing",
"order"
] | python | train |
mcash/merchant-api-python-sdk | mcash/mapi_client/mapi_client.py | https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/mapi_client.py#L101-L109 | def _depaginate_all(self, url):
"""GETs the url provided and traverses the 'next' url that's
returned while storing the data in a list. Returns a single list of all
items.
"""
items = []
for x in self._depagination_generator(url):
items += x
return ite... | [
"def",
"_depaginate_all",
"(",
"self",
",",
"url",
")",
":",
"items",
"=",
"[",
"]",
"for",
"x",
"in",
"self",
".",
"_depagination_generator",
"(",
"url",
")",
":",
"items",
"+=",
"x",
"return",
"items"
] | GETs the url provided and traverses the 'next' url that's
returned while storing the data in a list. Returns a single list of all
items. | [
"GETs",
"the",
"url",
"provided",
"and",
"traverses",
"the",
"next",
"url",
"that",
"s",
"returned",
"while",
"storing",
"the",
"data",
"in",
"a",
"list",
".",
"Returns",
"a",
"single",
"list",
"of",
"all",
"items",
"."
] | python | train |
koordinates/python-client | koordinates/publishing.py | https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/publishing.py#L29-L35 | def create(self, publish):
"""
Creates a new publish group.
"""
target_url = self.client.get_url('PUBLISH', 'POST', 'create')
r = self.client.request('POST', target_url, json=publish._serialize())
return self.create_from_result(r.json()) | [
"def",
"create",
"(",
"self",
",",
"publish",
")",
":",
"target_url",
"=",
"self",
".",
"client",
".",
"get_url",
"(",
"'PUBLISH'",
",",
"'POST'",
",",
"'create'",
")",
"r",
"=",
"self",
".",
"client",
".",
"request",
"(",
"'POST'",
",",
"target_url",
... | Creates a new publish group. | [
"Creates",
"a",
"new",
"publish",
"group",
"."
] | python | train |
LionelAuroux/pyrser | pyrser/type_system/symbol.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/type_system/symbol.py#L51-L61 | def get_scope_names(self) -> list:
"""
Return the list of all contained scope from global to local
"""
# allow global scope to have an None string instance
lscope = []
for scope in reversed(self.get_scope_list()):
if scope.name is not None:
# h... | [
"def",
"get_scope_names",
"(",
"self",
")",
"->",
"list",
":",
"# allow global scope to have an None string instance",
"lscope",
"=",
"[",
"]",
"for",
"scope",
"in",
"reversed",
"(",
"self",
".",
"get_scope_list",
"(",
")",
")",
":",
"if",
"scope",
".",
"name"... | Return the list of all contained scope from global to local | [
"Return",
"the",
"list",
"of",
"all",
"contained",
"scope",
"from",
"global",
"to",
"local"
] | python | test |
andersinno/python-database-sanitizer | database_sanitizer/dump/mysql.py | https://github.com/andersinno/python-database-sanitizer/blob/742bc1f43526b60f322a48f18c900f94fd446ed4/database_sanitizer/dump/mysql.py#L42-L66 | def sanitize(url, config):
"""
Obtains dump of MySQL database by executing `mysqldump` command and
sanitizes it output.
:param url: URL to the database which is going to be sanitized, parsed by
Python's URL parser.
:type url: urllib.urlparse.ParseResult
:param config: Optional ... | [
"def",
"sanitize",
"(",
"url",
",",
"config",
")",
":",
"if",
"url",
".",
"scheme",
"!=",
"\"mysql\"",
":",
"raise",
"ValueError",
"(",
"\"Unsupported database type: '%s'\"",
"%",
"(",
"url",
".",
"scheme",
",",
")",
")",
"args",
",",
"env",
"=",
"get_my... | Obtains dump of MySQL database by executing `mysqldump` command and
sanitizes it output.
:param url: URL to the database which is going to be sanitized, parsed by
Python's URL parser.
:type url: urllib.urlparse.ParseResult
:param config: Optional sanitizer configuration to be used for ... | [
"Obtains",
"dump",
"of",
"MySQL",
"database",
"by",
"executing",
"mysqldump",
"command",
"and",
"sanitizes",
"it",
"output",
"."
] | python | train |
dereneaton/ipyrad | ipyrad/analysis/structure.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/structure.py#L147-L151 | def result_files(self):
""" returns a list of files that have finished structure """
reps = OPJ(self.workdir, self.name+"-K-*-rep-*_f")
repfiles = glob.glob(reps)
return repfiles | [
"def",
"result_files",
"(",
"self",
")",
":",
"reps",
"=",
"OPJ",
"(",
"self",
".",
"workdir",
",",
"self",
".",
"name",
"+",
"\"-K-*-rep-*_f\"",
")",
"repfiles",
"=",
"glob",
".",
"glob",
"(",
"reps",
")",
"return",
"repfiles"
] | returns a list of files that have finished structure | [
"returns",
"a",
"list",
"of",
"files",
"that",
"have",
"finished",
"structure"
] | python | valid |
HPENetworking/PYHPEIMC | build/lib/pyhpimc/auth.py | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpimc/auth.py#L55-L73 | def get_auth(self):
"""
This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object
:return:
"""
url = self.h_url + self.server + ":" + self.port
auth = requests.auth.HTTPDigestAuth(self.username,self.password)
auth_url... | [
"def",
"get_auth",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"h_url",
"+",
"self",
".",
"server",
"+",
"\":\"",
"+",
"self",
".",
"port",
"auth",
"=",
"requests",
".",
"auth",
".",
"HTTPDigestAuth",
"(",
"self",
".",
"username",
",",
"self",
... | This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object
:return: | [
"This",
"method",
"requests",
"an",
"authentication",
"object",
"from",
"the",
"HPE",
"IMC",
"NMS",
"and",
"returns",
"an",
"HTTPDigest",
"Auth",
"Object",
":",
"return",
":"
] | python | train |
objectrocket/python-client | objectrocket/instances/redis.py | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/instances/redis.py#L36-L53 | def get_connection(self, internal=False):
"""Get a live connection to this instance.
:param bool internal: Whether or not to use a DC internal network connection.
:rtype: :py:class:`redis.client.StrictRedis`
"""
# Determine the connection string to use.
connect_string =... | [
"def",
"get_connection",
"(",
"self",
",",
"internal",
"=",
"False",
")",
":",
"# Determine the connection string to use.",
"connect_string",
"=",
"self",
".",
"connect_string",
"if",
"internal",
":",
"connect_string",
"=",
"self",
".",
"internal_connect_string",
"# S... | Get a live connection to this instance.
:param bool internal: Whether or not to use a DC internal network connection.
:rtype: :py:class:`redis.client.StrictRedis` | [
"Get",
"a",
"live",
"connection",
"to",
"this",
"instance",
"."
] | python | train |
chaosmail/python-fs | fs/fs.py | https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L307-L309 | def add_suffix(path, suffix=""):
"""Adds a suffix to a filename *path*"""
return join(dirname(path), basename(path, ext=False) + suffix + extname(path)) | [
"def",
"add_suffix",
"(",
"path",
",",
"suffix",
"=",
"\"\"",
")",
":",
"return",
"join",
"(",
"dirname",
"(",
"path",
")",
",",
"basename",
"(",
"path",
",",
"ext",
"=",
"False",
")",
"+",
"suffix",
"+",
"extname",
"(",
"path",
")",
")"
] | Adds a suffix to a filename *path* | [
"Adds",
"a",
"suffix",
"to",
"a",
"filename",
"*",
"path",
"*"
] | python | train |
globocom/GloboNetworkAPI-client-python | networkapiclient/Ip.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Ip.py#L142-L170 | def get_available_ip4(self, id_network):
"""
Get a available IP in the network ipv4
:param id_network: Network identifier. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'ip': {'ip': < available_ip >}}
:raise Ip... | [
"def",
"get_available_ip4",
"(",
"self",
",",
"id_network",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_network",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Network identifier is invalid or was not informed.'",
")",
"url",
"=",
"'ip/availableip4/'",
"... | Get a available IP in the network ipv4
:param id_network: Network identifier. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'ip': {'ip': < available_ip >}}
:raise IpNotAvailableError: Network dont have available IP for insert ... | [
"Get",
"a",
"available",
"IP",
"in",
"the",
"network",
"ipv4"
] | python | train |
delph-in/pydelphin | delphin/mrs/query.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/query.py#L257-L290 | def find_subgraphs_by_preds(xmrs, preds, connected=None):
"""
Yield subgraphs matching a list of predicates.
Predicates may match multiple EPs/nodes in the *xmrs*, meaning that
more than one subgraph is possible. Also, predicates in *preds*
match in number, so if a predicate appears twice in *preds... | [
"def",
"find_subgraphs_by_preds",
"(",
"xmrs",
",",
"preds",
",",
"connected",
"=",
"None",
")",
":",
"preds",
"=",
"list",
"(",
"preds",
")",
"count",
"=",
"len",
"(",
"preds",
")",
"# find all lists of nodeids such that the lists have no repeated nids;",
"# keep t... | Yield subgraphs matching a list of predicates.
Predicates may match multiple EPs/nodes in the *xmrs*, meaning that
more than one subgraph is possible. Also, predicates in *preds*
match in number, so if a predicate appears twice in *preds*, there
will be two matching EPs/nodes in each subgraph.
Arg... | [
"Yield",
"subgraphs",
"matching",
"a",
"list",
"of",
"predicates",
"."
] | python | train |
collectiveacuity/labPack | labpack/platforms/docker.py | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/docker.py#L537-L562 | def command(self, sys_command):
'''
a method to run a system command in a separate shell
:param sys_command: string with docker command
:return: string output from docker
'''
title = '%s.command' % self.__class__.__name__
# validate inputs
... | [
"def",
"command",
"(",
"self",
",",
"sys_command",
")",
":",
"title",
"=",
"'%s.command'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs\r",
"input_fields",
"=",
"{",
"'sys_command'",
":",
"sys_command",
"}",
"for",
"key",
",",
"value",
... | a method to run a system command in a separate shell
:param sys_command: string with docker command
:return: string output from docker | [
"a",
"method",
"to",
"run",
"a",
"system",
"command",
"in",
"a",
"separate",
"shell",
":",
"param",
"sys_command",
":",
"string",
"with",
"docker",
"command",
":",
"return",
":",
"string",
"output",
"from",
"docker"
] | python | train |
horazont/aioxmpp | aioxmpp/xml.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/xml.py#L459-L476 | def endElementNS(self, name, qname):
"""
End a previously started element. `name` must be a ``(namespace_uri,
localname)`` tuple and `qname` is ignored.
"""
if self._ns_prefixes_floating_out:
raise RuntimeError("namespace prefix has not been closed")
if self.... | [
"def",
"endElementNS",
"(",
"self",
",",
"name",
",",
"qname",
")",
":",
"if",
"self",
".",
"_ns_prefixes_floating_out",
":",
"raise",
"RuntimeError",
"(",
"\"namespace prefix has not been closed\"",
")",
"if",
"self",
".",
"_pending_start_element",
"==",
"name",
... | End a previously started element. `name` must be a ``(namespace_uri,
localname)`` tuple and `qname` is ignored. | [
"End",
"a",
"previously",
"started",
"element",
".",
"name",
"must",
"be",
"a",
"(",
"namespace_uri",
"localname",
")",
"tuple",
"and",
"qname",
"is",
"ignored",
"."
] | python | train |
wbond/oscrypto | oscrypto/_osx/util.py | https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_osx/util.py#L42-L60 | def _extract_error():
"""
Extracts the last OS error message into a python unicode string
:return:
A unicode string error message
"""
error_num = errno()
try:
error_string = os.strerror(error_num)
except (ValueError):
return str_cls(error_num)
if isinstance(er... | [
"def",
"_extract_error",
"(",
")",
":",
"error_num",
"=",
"errno",
"(",
")",
"try",
":",
"error_string",
"=",
"os",
".",
"strerror",
"(",
"error_num",
")",
"except",
"(",
"ValueError",
")",
":",
"return",
"str_cls",
"(",
"error_num",
")",
"if",
"isinstan... | Extracts the last OS error message into a python unicode string
:return:
A unicode string error message | [
"Extracts",
"the",
"last",
"OS",
"error",
"message",
"into",
"a",
"python",
"unicode",
"string"
] | python | valid |
caseyjlaw/rtpipe | rtpipe/calpipe.py | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/calpipe.py#L132-L323 | def run(self, refant=[], antsel=[], uvrange='', fluxname='', fluxname_full='', band='', spw0='', spw1='', flaglist=[]):
""" Run calibration pipeline. Assumes L-band.
refant is list of antenna name strings (e.g., ['ea10']). default is to calculate based on distance from array center.
antsel is li... | [
"def",
"run",
"(",
"self",
",",
"refant",
"=",
"[",
"]",
",",
"antsel",
"=",
"[",
"]",
",",
"uvrange",
"=",
"''",
",",
"fluxname",
"=",
"''",
",",
"fluxname_full",
"=",
"''",
",",
"band",
"=",
"''",
",",
"spw0",
"=",
"''",
",",
"spw1",
"=",
"... | Run calibration pipeline. Assumes L-band.
refant is list of antenna name strings (e.g., ['ea10']). default is to calculate based on distance from array center.
antsel is list of ants to use (or reject) (e.g., ['!ea08'])
uvrange is string giving uvrange (e.g., '<5klambda')
fluxname, fluxn... | [
"Run",
"calibration",
"pipeline",
".",
"Assumes",
"L",
"-",
"band",
".",
"refant",
"is",
"list",
"of",
"antenna",
"name",
"strings",
"(",
"e",
".",
"g",
".",
"[",
"ea10",
"]",
")",
".",
"default",
"is",
"to",
"calculate",
"based",
"on",
"distance",
"... | python | train |
lowandrew/OLCTools | coreGenome/coretyper.py | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/coreGenome/coretyper.py#L100-L139 | def annotatethreads(self):
"""
Use prokka to annotate each strain
"""
# Move the files to subfolders and create objects
self.runmetadata = createobject.ObjectCreation(self)
# Fix headers
self.headers()
printtime('Performing prokka analyses', self.start)
... | [
"def",
"annotatethreads",
"(",
"self",
")",
":",
"# Move the files to subfolders and create objects",
"self",
".",
"runmetadata",
"=",
"createobject",
".",
"ObjectCreation",
"(",
"self",
")",
"# Fix headers",
"self",
".",
"headers",
"(",
")",
"printtime",
"(",
"'Per... | Use prokka to annotate each strain | [
"Use",
"prokka",
"to",
"annotate",
"each",
"strain"
] | python | train |
project-ncl/pnc-cli | pnc_cli/productversions.py | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/productversions.py#L117-L123 | def update_product_version(id, **kwargs):
"""
Update the ProductVersion with ID id with new values.
"""
content = update_product_version_raw(id, **kwargs)
if content:
return utils.format_json(content) | [
"def",
"update_product_version",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"content",
"=",
"update_product_version_raw",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Update the ProductVersion with ID id with new values. | [
"Update",
"the",
"ProductVersion",
"with",
"ID",
"id",
"with",
"new",
"values",
"."
] | python | train |
raghakot/keras-vis | docs/md_autogen.py | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/docs/md_autogen.py#L327-L392 | def module2md(self, module):
"""Takes an imported module object and create a Markdown string containing functions and classes.
"""
modname = module.__name__
path = self.get_src_path(module, append_base=False)
path = "[{}]({})".format(path, os.path.join(self.github_link, path))
... | [
"def",
"module2md",
"(",
"self",
",",
"module",
")",
":",
"modname",
"=",
"module",
".",
"__name__",
"path",
"=",
"self",
".",
"get_src_path",
"(",
"module",
",",
"append_base",
"=",
"False",
")",
"path",
"=",
"\"[{}]({})\"",
".",
"format",
"(",
"path",
... | Takes an imported module object and create a Markdown string containing functions and classes. | [
"Takes",
"an",
"imported",
"module",
"object",
"and",
"create",
"a",
"Markdown",
"string",
"containing",
"functions",
"and",
"classes",
"."
] | python | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L674-L710 | def atlasdb_get_zonefiles_by_block( from_block, to_block, offset, count, name=None, con=None, path=None ):
"""
Look up all zonefile hashes in a block range. Optionally filter by name.
Returns [{'name': ..., 'zonefile_hash': ..., 'block_height': ..., 'txid': ..., 'inv_index': ...}]
"""
ret = None
... | [
"def",
"atlasdb_get_zonefiles_by_block",
"(",
"from_block",
",",
"to_block",
",",
"offset",
",",
"count",
",",
"name",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"ret",
"=",
"None",
"if",
"count",
">",
"100",
":",
"return... | Look up all zonefile hashes in a block range. Optionally filter by name.
Returns [{'name': ..., 'zonefile_hash': ..., 'block_height': ..., 'txid': ..., 'inv_index': ...}] | [
"Look",
"up",
"all",
"zonefile",
"hashes",
"in",
"a",
"block",
"range",
".",
"Optionally",
"filter",
"by",
"name",
".",
"Returns",
"[",
"{",
"name",
":",
"...",
"zonefile_hash",
":",
"...",
"block_height",
":",
"...",
"txid",
":",
"...",
"inv_index",
":"... | python | train |
Azure/azure-sdk-for-python | azure-servicemanagement-legacy/azure/servicemanagement/sqldatabasemanagementservice.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/sqldatabasemanagementservice.py#L218-L246 | def update_firewall_rule(self, server_name, name, start_ip_address,
end_ip_address):
'''
Update a firewall rule for an Azure SQL Database server.
server_name:
Name of the server to set the firewall rule on.
name:
The name of the fire... | [
"def",
"update_firewall_rule",
"(",
"self",
",",
"server_name",
",",
"name",
",",
"start_ip_address",
",",
"end_ip_address",
")",
":",
"_validate_not_none",
"(",
"'server_name'",
",",
"server_name",
")",
"_validate_not_none",
"(",
"'name'",
",",
"name",
")",
"_val... | Update a firewall rule for an Azure SQL Database server.
server_name:
Name of the server to set the firewall rule on.
name:
The name of the firewall rule to update.
start_ip_address:
The lowest IP address in the range of the server-level firewall
... | [
"Update",
"a",
"firewall",
"rule",
"for",
"an",
"Azure",
"SQL",
"Database",
"server",
"."
] | python | test |
ray-project/ray | python/ray/utils.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L32-L51 | def format_error_message(exception_message, task_exception=False):
"""Improve the formatting of an exception thrown by a remote function.
This method takes a traceback from an exception and makes it nicer by
removing a few uninformative lines and adding some space to indent the
remaining lines nicely.
... | [
"def",
"format_error_message",
"(",
"exception_message",
",",
"task_exception",
"=",
"False",
")",
":",
"lines",
"=",
"exception_message",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"task_exception",
":",
"# For errors that occur inside of tasks, remove lines 1 and 2 which ar... | Improve the formatting of an exception thrown by a remote function.
This method takes a traceback from an exception and makes it nicer by
removing a few uninformative lines and adding some space to indent the
remaining lines nicely.
Args:
exception_message (str): A message generated by traceba... | [
"Improve",
"the",
"formatting",
"of",
"an",
"exception",
"thrown",
"by",
"a",
"remote",
"function",
"."
] | python | train |
astropy/photutils | photutils/isophote/geometry.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/geometry.py#L509-L537 | def reset_sma(self, step):
"""
Change the direction of semimajor axis growth, from outwards to
inwards.
Parameters
----------
step : float
The current step value.
Returns
-------
sma, new_step : float
The new semimajor axi... | [
"def",
"reset_sma",
"(",
"self",
",",
"step",
")",
":",
"if",
"self",
".",
"linear_growth",
":",
"sma",
"=",
"self",
".",
"sma",
"-",
"step",
"step",
"=",
"-",
"step",
"else",
":",
"aux",
"=",
"1.",
"/",
"(",
"1.",
"+",
"step",
")",
"sma",
"=",... | Change the direction of semimajor axis growth, from outwards to
inwards.
Parameters
----------
step : float
The current step value.
Returns
-------
sma, new_step : float
The new semimajor axis length and the new step value to
... | [
"Change",
"the",
"direction",
"of",
"semimajor",
"axis",
"growth",
"from",
"outwards",
"to",
"inwards",
"."
] | python | train |
dropbox/stone | stone/frontend/ir_generator.py | https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/frontend/ir_generator.py#L805-L839 | def _populate_field_defaults(self):
"""
Populate the defaults of each field. This is done in a separate pass
because defaults that specify a union tag require the union to have
been defined.
"""
for namespace in self.api.namespaces.values():
for data_type in n... | [
"def",
"_populate_field_defaults",
"(",
"self",
")",
":",
"for",
"namespace",
"in",
"self",
".",
"api",
".",
"namespaces",
".",
"values",
"(",
")",
":",
"for",
"data_type",
"in",
"namespace",
".",
"data_types",
":",
"# Only struct fields can have default",
"if",... | Populate the defaults of each field. This is done in a separate pass
because defaults that specify a union tag require the union to have
been defined. | [
"Populate",
"the",
"defaults",
"of",
"each",
"field",
".",
"This",
"is",
"done",
"in",
"a",
"separate",
"pass",
"because",
"defaults",
"that",
"specify",
"a",
"union",
"tag",
"require",
"the",
"union",
"to",
"have",
"been",
"defined",
"."
] | python | train |
aleju/imgaug | imgaug/external/poly_point_isect_py2py3.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/external/poly_point_isect_py2py3.py#L796-L805 | def clear(self):
"""T.clear() -> None. Remove all items from T."""
def _clear(node):
if node is not None:
_clear(node.left)
_clear(node.right)
node.free()
_clear(self._root)
self._count = 0
self._root = None | [
"def",
"clear",
"(",
"self",
")",
":",
"def",
"_clear",
"(",
"node",
")",
":",
"if",
"node",
"is",
"not",
"None",
":",
"_clear",
"(",
"node",
".",
"left",
")",
"_clear",
"(",
"node",
".",
"right",
")",
"node",
".",
"free",
"(",
")",
"_clear",
"... | T.clear() -> None. Remove all items from T. | [
"T",
".",
"clear",
"()",
"-",
">",
"None",
".",
"Remove",
"all",
"items",
"from",
"T",
"."
] | python | valid |
hyperledger/indy-sdk | wrappers/python/indy/anoncreds.py | https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/anoncreds.py#L635-L672 | async def prover_get_credential(wallet_handle: int,
cred_id: str) -> str:
"""
Gets human readable credential by the given id.
:param wallet_handle: wallet handler (created by open_wallet).
:param cred_id: Identifier by which requested credential is stored in the wallet
... | [
"async",
"def",
"prover_get_credential",
"(",
"wallet_handle",
":",
"int",
",",
"cred_id",
":",
"str",
")",
"->",
"str",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"prover_get_credential: >>> wallet_hand... | Gets human readable credential by the given id.
:param wallet_handle: wallet handler (created by open_wallet).
:param cred_id: Identifier by which requested credential is stored in the wallet
:return: credential json
{
"referent": string, // cred_id in the wallet
"attrs": {"key1":"r... | [
"Gets",
"human",
"readable",
"credential",
"by",
"the",
"given",
"id",
"."
] | python | train |
pypa/pipenv | pipenv/core.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L1003-L1105 | def do_lock(
ctx=None,
system=False,
clear=False,
pre=False,
keep_outdated=False,
write=True,
pypi_mirror=None,
):
"""Executes the freeze functionality."""
cached_lockfile = {}
if not pre:
pre = project.settings.get("allow_prereleases")
if keep_outdated:
if n... | [
"def",
"do_lock",
"(",
"ctx",
"=",
"None",
",",
"system",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"pre",
"=",
"False",
",",
"keep_outdated",
"=",
"False",
",",
"write",
"=",
"True",
",",
"pypi_mirror",
"=",
"None",
",",
")",
":",
"cached_lockf... | Executes the freeze functionality. | [
"Executes",
"the",
"freeze",
"functionality",
"."
] | python | train |
ihgazni2/elist | elist/elist.py | https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4807-L4818 | def same_values(l1,l2):
'''
from elist.elist import *
l1 = [1,2,3,5]
l2 = [0,2,3,4]
same_values(l1,l2)
'''
rslt = []
for i in range(0,l1.__len__()):
if(l1[i]==l2[i]):
rslt.append(l1[i])
return(rslt) | [
"def",
"same_values",
"(",
"l1",
",",
"l2",
")",
":",
"rslt",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"l1",
".",
"__len__",
"(",
")",
")",
":",
"if",
"(",
"l1",
"[",
"i",
"]",
"==",
"l2",
"[",
"i",
"]",
")",
":",
"rslt",
... | from elist.elist import *
l1 = [1,2,3,5]
l2 = [0,2,3,4]
same_values(l1,l2) | [
"from",
"elist",
".",
"elist",
"import",
"*",
"l1",
"=",
"[",
"1",
"2",
"3",
"5",
"]",
"l2",
"=",
"[",
"0",
"2",
"3",
"4",
"]",
"same_values",
"(",
"l1",
"l2",
")"
] | python | valid |
funilrys/PyFunceble | PyFunceble/core.py | https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/core.py#L199-L215 | def _entry_management_url(self):
"""
Manage the loading of the url system.
"""
if (
self.url_file # pylint: disable=no-member
and not self._entry_management_url_download(
self.url_file # pylint: disable=no-member
)
): # pyli... | [
"def",
"_entry_management_url",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"url_file",
"# pylint: disable=no-member",
"and",
"not",
"self",
".",
"_entry_management_url_download",
"(",
"self",
".",
"url_file",
"# pylint: disable=no-member",
")",
")",
":",
"# pyli... | Manage the loading of the url system. | [
"Manage",
"the",
"loading",
"of",
"the",
"url",
"system",
"."
] | python | test |
Alignak-monitoring/alignak | alignak/action.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/action.py#L245-L262 | def get_local_environnement(self):
"""
Mix the environment and the environment variables into a new local
environment dictionary
Note: We cannot just update the global os.environ because this
would effect all other checks.
:return: local environment variables
:r... | [
"def",
"get_local_environnement",
"(",
"self",
")",
":",
"# Do not use copy.copy() here, as the resulting copy still",
"# changes the real environment (it is still a os._Environment",
"# instance).",
"local_env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"for",
"local_v... | Mix the environment and the environment variables into a new local
environment dictionary
Note: We cannot just update the global os.environ because this
would effect all other checks.
:return: local environment variables
:rtype: dict | [
"Mix",
"the",
"environment",
"and",
"the",
"environment",
"variables",
"into",
"a",
"new",
"local",
"environment",
"dictionary"
] | python | train |
kamicut/tilepie | tilepie/proj.py | https://github.com/kamicut/tilepie/blob/103ae2be1c3c4e6f7ec4a3bdd265ffcddee92b96/tilepie/proj.py#L73-L82 | def tile_bbox(self, tile_indices):
"""
Returns the WGS84 bbox of the specified tile
"""
(z, x, y) = tile_indices
topleft = (x * self.tilesize, (y + 1) * self.tilesize)
bottomright = ((x + 1) * self.tilesize, y * self.tilesize)
nw = self.unproject_pixels(topleft, z... | [
"def",
"tile_bbox",
"(",
"self",
",",
"tile_indices",
")",
":",
"(",
"z",
",",
"x",
",",
"y",
")",
"=",
"tile_indices",
"topleft",
"=",
"(",
"x",
"*",
"self",
".",
"tilesize",
",",
"(",
"y",
"+",
"1",
")",
"*",
"self",
".",
"tilesize",
")",
"bo... | Returns the WGS84 bbox of the specified tile | [
"Returns",
"the",
"WGS84",
"bbox",
"of",
"the",
"specified",
"tile"
] | python | train |
jasonrbriggs/stomp.py | stomp/transport.py | https://github.com/jasonrbriggs/stomp.py/blob/643843c5fbf25fd24339dd0e69a9411c3d8b94c7/stomp/transport.py#L720-L807 | def attempt_connection(self):
"""
Try connecting to the (host, port) tuples specified at construction time.
"""
self.connection_error = False
sleep_exp = 1
connect_count = 0
while self.running and self.socket is None and (
connect_count < self.__recon... | [
"def",
"attempt_connection",
"(",
"self",
")",
":",
"self",
".",
"connection_error",
"=",
"False",
"sleep_exp",
"=",
"1",
"connect_count",
"=",
"0",
"while",
"self",
".",
"running",
"and",
"self",
".",
"socket",
"is",
"None",
"and",
"(",
"connect_count",
"... | Try connecting to the (host, port) tuples specified at construction time. | [
"Try",
"connecting",
"to",
"the",
"(",
"host",
"port",
")",
"tuples",
"specified",
"at",
"construction",
"time",
"."
] | python | train |
pylast/pylast | src/pylast/__init__.py | https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L1919-L1927 | def get_top_artists(self, limit=None, cacheable=True):
"""Returns a sequence of the most played artists."""
params = self._get_params()
if limit:
params["limit"] = limit
doc = self._request("geo.getTopArtists", cacheable, params)
return _extract_top_artists(doc, sel... | [
"def",
"get_top_artists",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"cacheable",
"=",
"True",
")",
":",
"params",
"=",
"self",
".",
"_get_params",
"(",
")",
"if",
"limit",
":",
"params",
"[",
"\"limit\"",
"]",
"=",
"limit",
"doc",
"=",
"self",
"."... | Returns a sequence of the most played artists. | [
"Returns",
"a",
"sequence",
"of",
"the",
"most",
"played",
"artists",
"."
] | python | train |
zarr-developers/zarr | zarr/core.py | https://github.com/zarr-developers/zarr/blob/fb8e6d5ea6bc26e451e5cf0eaaee36977556d5b5/zarr/core.py#L2027-L2062 | def append(self, data, axis=0):
"""Append `data` to `axis`.
Parameters
----------
data : array_like
Data to be appended.
axis : int
Axis along which to append.
Returns
-------
new_shape : tuple
Notes
-----
... | [
"def",
"append",
"(",
"self",
",",
"data",
",",
"axis",
"=",
"0",
")",
":",
"return",
"self",
".",
"_write_op",
"(",
"self",
".",
"_append_nosync",
",",
"data",
",",
"axis",
"=",
"axis",
")"
] | Append `data` to `axis`.
Parameters
----------
data : array_like
Data to be appended.
axis : int
Axis along which to append.
Returns
-------
new_shape : tuple
Notes
-----
The size of all dimensions other than `axi... | [
"Append",
"data",
"to",
"axis",
"."
] | python | train |
bxlab/bx-python | lib/bx/motif/pwm.py | https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/pwm.py#L95-L107 | def to_logodds_scoring_matrix( self, background=None, correction=DEFAULT_CORRECTION ):
"""
Create a standard logodds scoring matrix.
"""
alphabet_size = len( self.alphabet )
if background is None:
background = ones( alphabet_size, float32 ) / alphabet_size
# R... | [
"def",
"to_logodds_scoring_matrix",
"(",
"self",
",",
"background",
"=",
"None",
",",
"correction",
"=",
"DEFAULT_CORRECTION",
")",
":",
"alphabet_size",
"=",
"len",
"(",
"self",
".",
"alphabet",
")",
"if",
"background",
"is",
"None",
":",
"background",
"=",
... | Create a standard logodds scoring matrix. | [
"Create",
"a",
"standard",
"logodds",
"scoring",
"matrix",
"."
] | python | train |
fumitoh/modelx | modelx/core/space.py | https://github.com/fumitoh/modelx/blob/0180da34d052c44fb94dab9e115e218bbebfc9c3/modelx/core/space.py#L1241-L1265 | def set_attr(self, name, value):
"""Implementation of attribute setting
``space.name = value`` by user script
Called from ``Space.__setattr__``
"""
if not is_valid_name(name):
raise ValueError("Invalid name '%s'" % name)
if name in self.namespace:
... | [
"def",
"set_attr",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"not",
"is_valid_name",
"(",
"name",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid name '%s'\"",
"%",
"name",
")",
"if",
"name",
"in",
"self",
".",
"namespace",
":",
"if",
"n... | Implementation of attribute setting
``space.name = value`` by user script
Called from ``Space.__setattr__`` | [
"Implementation",
"of",
"attribute",
"setting"
] | python | valid |
explosion/spaCy | spacy/util.py | https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/spacy/util.py#L484-L504 | def stepping(start, stop, steps):
"""Yield an infinite series of values that step from a start value to a
final value over some number of steps. Each step is (stop-start)/steps.
After the final value is reached, the generator continues yielding that
value.
EXAMPLE:
>>> sizes = stepping(1., 2... | [
"def",
"stepping",
"(",
"start",
",",
"stop",
",",
"steps",
")",
":",
"def",
"clip",
"(",
"value",
")",
":",
"return",
"max",
"(",
"value",
",",
"stop",
")",
"if",
"(",
"start",
">",
"stop",
")",
"else",
"min",
"(",
"value",
",",
"stop",
")",
"... | Yield an infinite series of values that step from a start value to a
final value over some number of steps. Each step is (stop-start)/steps.
After the final value is reached, the generator continues yielding that
value.
EXAMPLE:
>>> sizes = stepping(1., 200., 100)
>>> assert next(sizes) ==... | [
"Yield",
"an",
"infinite",
"series",
"of",
"values",
"that",
"step",
"from",
"a",
"start",
"value",
"to",
"a",
"final",
"value",
"over",
"some",
"number",
"of",
"steps",
".",
"Each",
"step",
"is",
"(",
"stop",
"-",
"start",
")",
"/",
"steps",
"."
] | python | train |
Clinical-Genomics/scout | scout/server/utils.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/utils.py#L33-L59 | def institute_and_case(store, institute_id, case_name=None):
"""Fetch insitiute and case objects."""
institute_obj = store.institute(institute_id)
if institute_obj is None and institute_id != 'favicon.ico':
flash("Can't find institute: {}".format(institute_id), 'warning')
return abort(404)
... | [
"def",
"institute_and_case",
"(",
"store",
",",
"institute_id",
",",
"case_name",
"=",
"None",
")",
":",
"institute_obj",
"=",
"store",
".",
"institute",
"(",
"institute_id",
")",
"if",
"institute_obj",
"is",
"None",
"and",
"institute_id",
"!=",
"'favicon.ico'",... | Fetch insitiute and case objects. | [
"Fetch",
"insitiute",
"and",
"case",
"objects",
"."
] | python | test |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/work_item_tracking/work_item_tracking_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/work_item_tracking/work_item_tracking_client.py#L399-L417 | def get_fields(self, project=None, expand=None):
"""GetFields.
Returns information for all fields.
:param str project: Project ID or project name
:param str expand: Use ExtensionFields to include extension fields, otherwise exclude them. Unless the feature flag for this parameter is enab... | [
"def",
"get_fields",
"(",
"self",
",",
"project",
"=",
"None",
",",
"expand",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'",
"]",
"=",
"self",
".",
"_serialize",
".",
... | GetFields.
Returns information for all fields.
:param str project: Project ID or project name
:param str expand: Use ExtensionFields to include extension fields, otherwise exclude them. Unless the feature flag for this parameter is enabled, extension fields are always included.
:rtype: [... | [
"GetFields",
".",
"Returns",
"information",
"for",
"all",
"fields",
".",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
"str",
"expand",
":",
"Use",
"ExtensionFields",
"to",
"include",
"extension",
"fields",
"oth... | python | train |
raamana/hiwenet | hiwenet/more_metrics.py | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/more_metrics.py#L52-L78 | def diff_medians_abs(array_one, array_two):
"""
Computes the absolute (symmetric) difference in medians between two arrays of values.
Given arrays will be flattened (to 1D array) regardless of dimension,
and any non-finite/NaN values will be ignored.
Parameters
----------
array_one, ar... | [
"def",
"diff_medians_abs",
"(",
"array_one",
",",
"array_two",
")",
":",
"abs_diff_medians",
"=",
"np",
".",
"abs",
"(",
"diff_medians",
"(",
"array_one",
",",
"array_two",
")",
")",
"return",
"abs_diff_medians"
] | Computes the absolute (symmetric) difference in medians between two arrays of values.
Given arrays will be flattened (to 1D array) regardless of dimension,
and any non-finite/NaN values will be ignored.
Parameters
----------
array_one, array_two : iterable
Two arrays of values, possibl... | [
"Computes",
"the",
"absolute",
"(",
"symmetric",
")",
"difference",
"in",
"medians",
"between",
"two",
"arrays",
"of",
"values",
"."
] | python | train |
wtsi-hgi/python-common | hgicommon/threading/counting_lock.py | https://github.com/wtsi-hgi/python-common/blob/0376a6b574ff46e82e509e90b6cb3693a3dbb577/hgicommon/threading/counting_lock.py#L55-L61 | def release(self):
""" Wraps Lock.release """
self._lock.release()
with self._stat_lock:
self._locked = False
self._last_released = datetime.now() | [
"def",
"release",
"(",
"self",
")",
":",
"self",
".",
"_lock",
".",
"release",
"(",
")",
"with",
"self",
".",
"_stat_lock",
":",
"self",
".",
"_locked",
"=",
"False",
"self",
".",
"_last_released",
"=",
"datetime",
".",
"now",
"(",
")"
] | Wraps Lock.release | [
"Wraps",
"Lock",
".",
"release"
] | python | valid |
zhmcclient/python-zhmcclient | zhmcclient/_manager.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_manager.py#L457-L524 | def _matches_prop(self, obj, prop_name, prop_match):
"""
Return a boolean indicating whether a resource object matches with
a single property against a property match value.
This is used for client-side filtering.
Depending on the specified property, this method retrieves the re... | [
"def",
"_matches_prop",
"(",
"self",
",",
"obj",
",",
"prop_name",
",",
"prop_match",
")",
":",
"if",
"isinstance",
"(",
"prop_match",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"# List items are logically ORed, so one matching item suffices.",
"for",
"pm",
... | Return a boolean indicating whether a resource object matches with
a single property against a property match value.
This is used for client-side filtering.
Depending on the specified property, this method retrieves the resource
properties from the HMC.
Parameters:
o... | [
"Return",
"a",
"boolean",
"indicating",
"whether",
"a",
"resource",
"object",
"matches",
"with",
"a",
"single",
"property",
"against",
"a",
"property",
"match",
"value",
".",
"This",
"is",
"used",
"for",
"client",
"-",
"side",
"filtering",
"."
] | python | train |
matthew-brett/delocate | delocate/wheeltools.py | https://github.com/matthew-brett/delocate/blob/ed48de15fce31c3f52f1a9f32cae1b02fc55aa60/delocate/wheeltools.py#L35-L81 | def rewrite_record(bdist_dir):
""" Rewrite RECORD file with hashes for all files in `wheel_sdir`
Copied from :method:`wheel.bdist_wheel.bdist_wheel.write_record`
Will also unsign wheel
Parameters
----------
bdist_dir : str
Path of unpacked wheel file
"""
info_dirs = glob.glob(... | [
"def",
"rewrite_record",
"(",
"bdist_dir",
")",
":",
"info_dirs",
"=",
"glob",
".",
"glob",
"(",
"pjoin",
"(",
"bdist_dir",
",",
"'*.dist-info'",
")",
")",
"if",
"len",
"(",
"info_dirs",
")",
"!=",
"1",
":",
"raise",
"WheelToolsError",
"(",
"\"Should be ex... | Rewrite RECORD file with hashes for all files in `wheel_sdir`
Copied from :method:`wheel.bdist_wheel.bdist_wheel.write_record`
Will also unsign wheel
Parameters
----------
bdist_dir : str
Path of unpacked wheel file | [
"Rewrite",
"RECORD",
"file",
"with",
"hashes",
"for",
"all",
"files",
"in",
"wheel_sdir"
] | python | train |
DataBiosphere/toil | src/toil/utils/toilStats.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/utils/toilStats.py#L226-L235 | def refineData(root, options):
""" walk down from the root and gather up the important bits.
"""
worker = root.worker
job = root.jobs
jobTypesTree = root.job_types
jobTypes = []
for childName in jobTypesTree:
jobTypes.append(jobTypesTree[childName])
return root, worker, job, jobT... | [
"def",
"refineData",
"(",
"root",
",",
"options",
")",
":",
"worker",
"=",
"root",
".",
"worker",
"job",
"=",
"root",
".",
"jobs",
"jobTypesTree",
"=",
"root",
".",
"job_types",
"jobTypes",
"=",
"[",
"]",
"for",
"childName",
"in",
"jobTypesTree",
":",
... | walk down from the root and gather up the important bits. | [
"walk",
"down",
"from",
"the",
"root",
"and",
"gather",
"up",
"the",
"important",
"bits",
"."
] | python | train |
DataBiosphere/dsub | dsub/providers/google_v2.py | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2.py#L577-L583 | def _build_user_environment(self, envs, inputs, outputs, mounts):
"""Returns a dictionary of for the user container environment."""
envs = {env.name: env.value for env in envs}
envs.update(providers_util.get_file_environment_variables(inputs))
envs.update(providers_util.get_file_environment_variables(ou... | [
"def",
"_build_user_environment",
"(",
"self",
",",
"envs",
",",
"inputs",
",",
"outputs",
",",
"mounts",
")",
":",
"envs",
"=",
"{",
"env",
".",
"name",
":",
"env",
".",
"value",
"for",
"env",
"in",
"envs",
"}",
"envs",
".",
"update",
"(",
"provider... | Returns a dictionary of for the user container environment. | [
"Returns",
"a",
"dictionary",
"of",
"for",
"the",
"user",
"container",
"environment",
"."
] | python | valid |
realestate-com-au/dashmat | dashmat/core_modules/splunk/splunk-sdk-1.3.0/splunklib/binding.py | https://github.com/realestate-com-au/dashmat/blob/433886e52698f0ddb9956f087b76041966c3bcd1/dashmat/core_modules/splunk/splunk-sdk-1.3.0/splunklib/binding.py#L533-L587 | def get(self, path_segment, owner=None, app=None, sharing=None, **query):
"""Performs a GET operation from the REST path segment with the given
namespace and query.
This method is named to match the HTTP method. ``get`` makes at least
one round trip to the server, one additional round t... | [
"def",
"get",
"(",
"self",
",",
"path_segment",
",",
"owner",
"=",
"None",
",",
"app",
"=",
"None",
",",
"sharing",
"=",
"None",
",",
"*",
"*",
"query",
")",
":",
"path",
"=",
"self",
".",
"authority",
"+",
"self",
".",
"_abspath",
"(",
"path_segme... | Performs a GET operation from the REST path segment with the given
namespace and query.
This method is named to match the HTTP method. ``get`` makes at least
one round trip to the server, one additional round trip for each 303
status returned, and at most two additional round trips if
... | [
"Performs",
"a",
"GET",
"operation",
"from",
"the",
"REST",
"path",
"segment",
"with",
"the",
"given",
"namespace",
"and",
"query",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_mac_address_table.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_mac_address_table.py#L56-L76 | def mac_address_table_static_interface_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
mac_address_table = ET.SubElement(config, "mac-address-table", xmlns="urn:brocade.com:mgmt:brocade-mac-address-table")
static = ET.SubElement(mac_address_table, "... | [
"def",
"mac_address_table_static_interface_type",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"mac_address_table",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"mac-address-table\"",
",",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
sawcordwell/pymdptoolbox | src/experimental/mdpsql.py | https://github.com/sawcordwell/pymdptoolbox/blob/7c96789cc80e280437005c12065cf70266c11636/src/experimental/mdpsql.py#L50-L88 | def exampleRand(S, A):
"""WARNING: This will delete a database with the same name as 'db'."""
db = "MDP-%sx%s.db" % (S, A)
if os.path.exists(db):
os.remove(db)
conn = sqlite3.connect(db)
with conn:
c = conn.cursor()
cmd = '''
CREATE TABLE info (name TEXT, value IN... | [
"def",
"exampleRand",
"(",
"S",
",",
"A",
")",
":",
"db",
"=",
"\"MDP-%sx%s.db\"",
"%",
"(",
"S",
",",
"A",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"db",
")",
":",
"os",
".",
"remove",
"(",
"db",
")",
"conn",
"=",
"sqlite3",
".",
"c... | WARNING: This will delete a database with the same name as 'db'. | [
"WARNING",
":",
"This",
"will",
"delete",
"a",
"database",
"with",
"the",
"same",
"name",
"as",
"db",
"."
] | python | train |
adamhajari/spyre | spyre/server.py | https://github.com/adamhajari/spyre/blob/5dd9f6de072e99af636ab7e7393d249761c56e69/spyre/server.py#L469-L480 | def launch_in_notebook(self, port=9095, width=900, height=600):
"""launch the app within an iframe in ipython notebook"""
from IPython.lib import backgroundjobs as bg
from IPython.display import HTML
jobs = bg.BackgroundJobManager()
jobs.new(self.launch, kw=dict(port=port))
... | [
"def",
"launch_in_notebook",
"(",
"self",
",",
"port",
"=",
"9095",
",",
"width",
"=",
"900",
",",
"height",
"=",
"600",
")",
":",
"from",
"IPython",
".",
"lib",
"import",
"backgroundjobs",
"as",
"bg",
"from",
"IPython",
".",
"display",
"import",
"HTML",... | launch the app within an iframe in ipython notebook | [
"launch",
"the",
"app",
"within",
"an",
"iframe",
"in",
"ipython",
"notebook"
] | python | train |
materialsproject/pymatgen | pymatgen/core/structure.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/structure.py#L1377-L1400 | def get_miller_index_from_site_indexes(self, site_ids, round_dp=4,
verbose=True):
"""
Get the Miller index of a plane from a set of sites indexes.
A minimum of 3 sites are required. If more than 3 sites are given
the best plane that minimises t... | [
"def",
"get_miller_index_from_site_indexes",
"(",
"self",
",",
"site_ids",
",",
"round_dp",
"=",
"4",
",",
"verbose",
"=",
"True",
")",
":",
"return",
"self",
".",
"lattice",
".",
"get_miller_index_from_coords",
"(",
"self",
".",
"frac_coords",
"[",
"site_ids",
... | Get the Miller index of a plane from a set of sites indexes.
A minimum of 3 sites are required. If more than 3 sites are given
the best plane that minimises the distance to all points will be
calculated.
Args:
site_ids (list of int): A list of site indexes to consider. A
... | [
"Get",
"the",
"Miller",
"index",
"of",
"a",
"plane",
"from",
"a",
"set",
"of",
"sites",
"indexes",
"."
] | python | train |
DataKitchen/DKCloudCommand | DKCloudCommand/modules/DKCloudAPIMock.py | https://github.com/DataKitchen/DKCloudCommand/blob/1cf9cb08ab02f063eef6b5c4b327af142991daa3/DKCloudCommand/modules/DKCloudAPIMock.py#L37-L48 | def delete_orderrun(self, orderrun_id):
"""
:param self: self
:param orderrun_id: string ; 'good' return a good value ; 'bad' return a bad value
:rtype: DKReturnCode
"""
rc = DKReturnCode()
if orderrun_id == 'good':
rc.set(rc.DK_SUCCESS, None, None)
... | [
"def",
"delete_orderrun",
"(",
"self",
",",
"orderrun_id",
")",
":",
"rc",
"=",
"DKReturnCode",
"(",
")",
"if",
"orderrun_id",
"==",
"'good'",
":",
"rc",
".",
"set",
"(",
"rc",
".",
"DK_SUCCESS",
",",
"None",
",",
"None",
")",
"else",
":",
"rc",
".",... | :param self: self
:param orderrun_id: string ; 'good' return a good value ; 'bad' return a bad value
:rtype: DKReturnCode | [
":",
"param",
"self",
":",
"self",
":",
"param",
"orderrun_id",
":",
"string",
";",
"good",
"return",
"a",
"good",
"value",
";",
"bad",
"return",
"a",
"bad",
"value",
":",
"rtype",
":",
"DKReturnCode"
] | python | train |
adaptive-learning/proso-apps | proso_models/models.py | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L577-L603 | def get_item_type_id_from_identifier(self, identifier, item_types=None):
"""
Get an ID of item type for the given identifier. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
... | [
"def",
"get_item_type_id_from_identifier",
"(",
"self",
",",
"identifier",
",",
"item_types",
"=",
"None",
")",
":",
"if",
"item_types",
"is",
"None",
":",
"item_types",
"=",
"ItemType",
".",
"objects",
".",
"get_all_types",
"(",
")",
"identifier_type",
",",
"... | Get an ID of item type for the given identifier. Identifier is a string of
the following form:
<model_prefix>/<model_identifier>
where <model_prefix> is any suffix of database table of the given model
which uniquely specifies the table, and <model_identifier> is
identifier of t... | [
"Get",
"an",
"ID",
"of",
"item",
"type",
"for",
"the",
"given",
"identifier",
".",
"Identifier",
"is",
"a",
"string",
"of",
"the",
"following",
"form",
":"
] | python | train |
dade-ai/snipy | snipy/io/fileutil.py | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L92-L103 | def loadfile(filepath, mmap_mode=None):
"""
:param filepath:
:param mmap_mode: {None, ‘r+’, ‘r’, ‘w+’, ‘c’} see. joblib.load
:return:
"""
import joblib
try:
return joblib.load(filepath, mmap_mode=mmap_mode)
except IOError:
return None | [
"def",
"loadfile",
"(",
"filepath",
",",
"mmap_mode",
"=",
"None",
")",
":",
"import",
"joblib",
"try",
":",
"return",
"joblib",
".",
"load",
"(",
"filepath",
",",
"mmap_mode",
"=",
"mmap_mode",
")",
"except",
"IOError",
":",
"return",
"None"
] | :param filepath:
:param mmap_mode: {None, ‘r+’, ‘r’, ‘w+’, ‘c’} see. joblib.load
:return: | [
":",
"param",
"filepath",
":",
":",
"param",
"mmap_mode",
":",
"{",
"None",
"‘r",
"+",
"’",
"‘r’",
"‘w",
"+",
"’",
"‘c’",
"}",
"see",
".",
"joblib",
".",
"load",
":",
"return",
":"
] | python | valid |
celiao/rtsimple | rtsimple/lists.py | https://github.com/celiao/rtsimple/blob/91f82cbd61a745bbe3a2cca54dfbb6b0ac123b86/rtsimple/lists.py#L58-L73 | def movies_box_office(self, **kwargs):
"""Gets the top box office earning movies from the API.
Sorted by most recent weekend gross ticket sales.
Args:
limit (optional): limits the number of movies returned, default=10
country (optional): localized data for selected countr... | [
"def",
"movies_box_office",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"self",
".",
"_get_path",
"(",
"'movies_box_office'",
")",
"response",
"=",
"self",
".",
"_GET",
"(",
"path",
",",
"kwargs",
")",
"self",
".",
"_set_attrs_to_values",
... | Gets the top box office earning movies from the API.
Sorted by most recent weekend gross ticket sales.
Args:
limit (optional): limits the number of movies returned, default=10
country (optional): localized data for selected country, default="us"
Returns:
A dict... | [
"Gets",
"the",
"top",
"box",
"office",
"earning",
"movies",
"from",
"the",
"API",
".",
"Sorted",
"by",
"most",
"recent",
"weekend",
"gross",
"ticket",
"sales",
"."
] | python | train |
estnltk/estnltk | estnltk/syntax/syntax_preprocessing.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/syntax/syntax_preprocessing.py#L95-L153 | def convert_vm_json_to_mrf( vabamorf_json ):
''' Converts from vabamorf's JSON output, given as dict, into pre-syntactic mrf
format, given as a list of lines, as in the output of etmrf.
The aimed format looks something like this:
<s>
Kolmandaks
kolmandaks+0 //_D_ //
... | [
"def",
"convert_vm_json_to_mrf",
"(",
"vabamorf_json",
")",
":",
"if",
"not",
"isinstance",
"(",
"vabamorf_json",
",",
"dict",
")",
":",
"raise",
"Exception",
"(",
"' Expected dict as an input argument! '",
")",
"json_sentences",
"=",
"[",
"]",
"# 1) flatten paragraph... | Converts from vabamorf's JSON output, given as dict, into pre-syntactic mrf
format, given as a list of lines, as in the output of etmrf.
The aimed format looks something like this:
<s>
Kolmandaks
kolmandaks+0 //_D_ //
kolmas+ks //_O_ sg tr //
kihutas
... | [
"Converts",
"from",
"vabamorf",
"s",
"JSON",
"output",
"given",
"as",
"dict",
"into",
"pre",
"-",
"syntactic",
"mrf",
"format",
"given",
"as",
"a",
"list",
"of",
"lines",
"as",
"in",
"the",
"output",
"of",
"etmrf",
".",
"The",
"aimed",
"format",
"looks",... | python | train |
johnnoone/aioconsul | aioconsul/client/kv_endpoint.py | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L70-L120 | async def get(self, key, *, dc=None, watch=None, consistency=None):
"""Returns the specified key
Parameters:
key (str): Key to fetch
watch (Blocking): Do a blocking query
consistency (Consistency): Force consistency
Returns:
ObjectMeta: where valu... | [
"async",
"def",
"get",
"(",
"self",
",",
"key",
",",
"*",
",",
"dc",
"=",
"None",
",",
"watch",
"=",
"None",
",",
"consistency",
"=",
"None",
")",
":",
"response",
"=",
"await",
"self",
".",
"_read",
"(",
"key",
",",
"dc",
"=",
"dc",
",",
"watc... | Returns the specified key
Parameters:
key (str): Key to fetch
watch (Blocking): Do a blocking query
consistency (Consistency): Force consistency
Returns:
ObjectMeta: where value is the queried kv value
Object will look like::
{
... | [
"Returns",
"the",
"specified",
"key"
] | python | train |
pypa/pipenv | pipenv/environment.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environment.py#L51-L71 | def safe_import(self, name):
"""Helper utility for reimporting previously imported modules while inside the env"""
module = None
if name not in self._modules:
self._modules[name] = importlib.import_module(name)
module = self._modules[name]
if not module:
d... | [
"def",
"safe_import",
"(",
"self",
",",
"name",
")",
":",
"module",
"=",
"None",
"if",
"name",
"not",
"in",
"self",
".",
"_modules",
":",
"self",
".",
"_modules",
"[",
"name",
"]",
"=",
"importlib",
".",
"import_module",
"(",
"name",
")",
"module",
"... | Helper utility for reimporting previously imported modules while inside the env | [
"Helper",
"utility",
"for",
"reimporting",
"previously",
"imported",
"modules",
"while",
"inside",
"the",
"env"
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/json/serialize.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/json/serialize.py#L626-L633 | def json_encode(obj: Instance, **kwargs) -> str:
"""
Encodes an object to JSON using our custom encoder.
The ``**kwargs`` can be used to pass things like ``'indent'``, for
formatting.
"""
return json.dumps(obj, cls=JsonClassEncoder, **kwargs) | [
"def",
"json_encode",
"(",
"obj",
":",
"Instance",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"return",
"json",
".",
"dumps",
"(",
"obj",
",",
"cls",
"=",
"JsonClassEncoder",
",",
"*",
"*",
"kwargs",
")"
] | Encodes an object to JSON using our custom encoder.
The ``**kwargs`` can be used to pass things like ``'indent'``, for
formatting. | [
"Encodes",
"an",
"object",
"to",
"JSON",
"using",
"our",
"custom",
"encoder",
"."
] | python | train |
dpkp/kafka-python | kafka/admin/client.py | https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L208-L217 | def close(self):
"""Close the KafkaAdminClient connection to the Kafka broker."""
if not hasattr(self, '_closed') or self._closed:
log.info("KafkaAdminClient already closed.")
return
self._metrics.close()
self._client.close()
self._closed = True
l... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_closed'",
")",
"or",
"self",
".",
"_closed",
":",
"log",
".",
"info",
"(",
"\"KafkaAdminClient already closed.\"",
")",
"return",
"self",
".",
"_metrics",
".",
"close",
"... | Close the KafkaAdminClient connection to the Kafka broker. | [
"Close",
"the",
"KafkaAdminClient",
"connection",
"to",
"the",
"Kafka",
"broker",
"."
] | python | train |
tjcsl/ion | intranet/apps/polls/models.py | https://github.com/tjcsl/ion/blob/5d722b0725d572039bb0929fd5715a4070c82c72/intranet/apps/polls/models.py#L17-L20 | def this_year(self):
""" Get AnnouncementRequests from this school year only. """
start_date, end_date = get_date_range_this_year()
return self.filter(start_time__gte=start_date, start_time__lte=end_date) | [
"def",
"this_year",
"(",
"self",
")",
":",
"start_date",
",",
"end_date",
"=",
"get_date_range_this_year",
"(",
")",
"return",
"self",
".",
"filter",
"(",
"start_time__gte",
"=",
"start_date",
",",
"start_time__lte",
"=",
"end_date",
")"
] | Get AnnouncementRequests from this school year only. | [
"Get",
"AnnouncementRequests",
"from",
"this",
"school",
"year",
"only",
"."
] | python | train |
BlueBrain/hpcbench | hpcbench/benchmark/standard.py | https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/benchmark/standard.py#L296-L303 | def froms(self):
"""Group metrics according to the `from` property.
"""
eax = {}
for name, config in six.iteritems(self._metrics):
from_ = self._get_property(config, 'from', default=self.stdout)
eax.setdefault(from_, {})[name] = config
return eax | [
"def",
"froms",
"(",
"self",
")",
":",
"eax",
"=",
"{",
"}",
"for",
"name",
",",
"config",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_metrics",
")",
":",
"from_",
"=",
"self",
".",
"_get_property",
"(",
"config",
",",
"'from'",
",",
"defaul... | Group metrics according to the `from` property. | [
"Group",
"metrics",
"according",
"to",
"the",
"from",
"property",
"."
] | python | train |
annoviko/pyclustering | pyclustering/core/som_wrapper.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/core/som_wrapper.py#L148-L158 | def som_get_winner_number(som_pointer):
"""!
@brief Returns of number of winner at the last step of learning process.
@param[in] som_pointer (c_pointer): pointer to object of self-organized map.
"""
ccore = ccore_library.get()
ccore.som_get_winner_number.restype = c_size_... | [
"def",
"som_get_winner_number",
"(",
"som_pointer",
")",
":",
"ccore",
"=",
"ccore_library",
".",
"get",
"(",
")",
"ccore",
".",
"som_get_winner_number",
".",
"restype",
"=",
"c_size_t",
"return",
"ccore",
".",
"som_get_winner_number",
"(",
"som_pointer",
")"
] | !
@brief Returns of number of winner at the last step of learning process.
@param[in] som_pointer (c_pointer): pointer to object of self-organized map. | [
"!"
] | python | valid |
gem/oq-engine | openquake/hazardlib/geo/point.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/point.py#L122-L137 | def azimuth(self, point):
"""
Compute the azimuth (in decimal degrees) between this point
and the given point.
:param point:
Destination point.
:type point:
Instance of :class:`Point`
:returns:
The azimuth, value in a range ``[0, 360)`... | [
"def",
"azimuth",
"(",
"self",
",",
"point",
")",
":",
"return",
"geodetic",
".",
"azimuth",
"(",
"self",
".",
"longitude",
",",
"self",
".",
"latitude",
",",
"point",
".",
"longitude",
",",
"point",
".",
"latitude",
")"
] | Compute the azimuth (in decimal degrees) between this point
and the given point.
:param point:
Destination point.
:type point:
Instance of :class:`Point`
:returns:
The azimuth, value in a range ``[0, 360)``.
:rtype:
float | [
"Compute",
"the",
"azimuth",
"(",
"in",
"decimal",
"degrees",
")",
"between",
"this",
"point",
"and",
"the",
"given",
"point",
"."
] | python | train |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/FwTabWidget.py | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/FwTabWidget.py#L70-L81 | def _mkAddBtnVisible(self):
"""
Ensure that the Add button is visible also when there are no tabs
"""
if not self._btn_add_height:
# self._btn_add_height = self.cornerWidget().height()
self._btn_add_height = self._cwBtn.height()
if self.count() == 0:
... | [
"def",
"_mkAddBtnVisible",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_btn_add_height",
":",
"# self._btn_add_height = self.cornerWidget().height()",
"self",
".",
"_btn_add_height",
"=",
"self",
".",
"_cwBtn",
".",
"height",
"(",
")",
"if",
"self"... | Ensure that the Add button is visible also when there are no tabs | [
"Ensure",
"that",
"the",
"Add",
"button",
"is",
"visible",
"also",
"when",
"there",
"are",
"no",
"tabs"
] | python | train |
waqasbhatti/astrobase | astrobase/lcproc/lcsfeatures.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcproc/lcsfeatures.py#L332-L483 | def serial_starfeatures(lclist,
outdir,
lc_catalog_pickle,
neighbor_radius_arcsec,
maxobjects=None,
deredden=True,
custom_bandpasses=None,
lcformat='hat... | [
"def",
"serial_starfeatures",
"(",
"lclist",
",",
"outdir",
",",
"lc_catalog_pickle",
",",
"neighbor_radius_arcsec",
",",
"maxobjects",
"=",
"None",
",",
"deredden",
"=",
"True",
",",
"custom_bandpasses",
"=",
"None",
",",
"lcformat",
"=",
"'hat-sql'",
",",
"lcf... | This drives the `get_starfeatures` function for a collection of LCs.
Parameters
----------
lclist : list of str
The list of light curve file names to process.
outdir : str
The output directory where the results will be placed.
lc_catalog_pickle : str
The path to a catalog... | [
"This",
"drives",
"the",
"get_starfeatures",
"function",
"for",
"a",
"collection",
"of",
"LCs",
"."
] | python | valid |
NYUCCL/psiTurk | psiturk/amt_services.py | https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/amt_services.py#L436-L453 | def setup_mturk_connection(self):
''' Connect to turk '''
if ((self.aws_access_key_id == 'YourAccessKeyId') or
(self.aws_secret_access_key == 'YourSecretAccessKey')):
print "AWS access key not set in ~/.psiturkconfig; please enter a valid access key."
assert False... | [
"def",
"setup_mturk_connection",
"(",
"self",
")",
":",
"if",
"(",
"(",
"self",
".",
"aws_access_key_id",
"==",
"'YourAccessKeyId'",
")",
"or",
"(",
"self",
".",
"aws_secret_access_key",
"==",
"'YourSecretAccessKey'",
")",
")",
":",
"print",
"\"AWS access key not ... | Connect to turk | [
"Connect",
"to",
"turk"
] | python | train |
gusutabopb/aioinflux | aioinflux/iterutils.py | https://github.com/gusutabopb/aioinflux/blob/2e4b7b3e13604e7618c686d89a0673f0bc70b24e/aioinflux/iterutils.py#L6-L48 | def iterpoints(resp: dict, parser: Optional[Callable] = None) -> Iterator[Any]:
"""Iterates a response JSON yielding data point by point.
Can be used with both regular and chunked responses.
By default, returns just a plain list of values representing each point,
without column names, or other metadata... | [
"def",
"iterpoints",
"(",
"resp",
":",
"dict",
",",
"parser",
":",
"Optional",
"[",
"Callable",
"]",
"=",
"None",
")",
"->",
"Iterator",
"[",
"Any",
"]",
":",
"for",
"statement",
"in",
"resp",
"[",
"'results'",
"]",
":",
"if",
"'series'",
"not",
"in"... | Iterates a response JSON yielding data point by point.
Can be used with both regular and chunked responses.
By default, returns just a plain list of values representing each point,
without column names, or other metadata.
In case a specific format is needed, an optional ``parser`` argument can be pass... | [
"Iterates",
"a",
"response",
"JSON",
"yielding",
"data",
"point",
"by",
"point",
"."
] | python | train |
Stufinite/djangoApiDec | djangoApiDec/djangoApiDec.py | https://github.com/Stufinite/djangoApiDec/blob/8b2d5776b3413b1b850df12a92f30526c05c0a46/djangoApiDec/djangoApiDec.py#L101-L112 | def getJsonFromApi(view, request):
"""Return json from querying Web Api
Args:
view: django view function.
request: http request object got from django.
Returns: json format dictionary
"""
jsonText = view(request)
jsonText = json.loads(jsonText.content.decode('utf-8'))
return jsonText | [
"def",
"getJsonFromApi",
"(",
"view",
",",
"request",
")",
":",
"jsonText",
"=",
"view",
"(",
"request",
")",
"jsonText",
"=",
"json",
".",
"loads",
"(",
"jsonText",
".",
"content",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"return",
"jsonText"
] | Return json from querying Web Api
Args:
view: django view function.
request: http request object got from django.
Returns: json format dictionary | [
"Return",
"json",
"from",
"querying",
"Web",
"Api"
] | python | valid |
rosenbrockc/acorn | acorn/logging/database.py | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/database.py#L306-L321 | def record(ekey, entry, diff=False):
"""Records the specified entry to the key-value store under the specified
entity key.
Args:
ekey (str): fqdn/uuid of the method/object to store the entry for.
entry (dict): attributes and values gleaned from the execution.
diff (bool): when True,... | [
"def",
"record",
"(",
"ekey",
",",
"entry",
",",
"diff",
"=",
"False",
")",
":",
"taskdb",
"=",
"active_db",
"(",
")",
"taskdb",
".",
"record",
"(",
"ekey",
",",
"entry",
",",
"diff",
")",
"# The task database save method makes sure that we only save as often as... | Records the specified entry to the key-value store under the specified
entity key.
Args:
ekey (str): fqdn/uuid of the method/object to store the entry for.
entry (dict): attributes and values gleaned from the execution.
diff (bool): when True, the "c" element of `entry` will be diffed
... | [
"Records",
"the",
"specified",
"entry",
"to",
"the",
"key",
"-",
"value",
"store",
"under",
"the",
"specified",
"entity",
"key",
"."
] | python | train |
GNS3/gns3-server | gns3server/ubridge/hypervisor.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/ubridge/hypervisor.py#L155-L183 | def start(self):
"""
Starts the uBridge hypervisor process.
"""
env = os.environ.copy()
if sys.platform.startswith("win"):
# add the Npcap directory to $PATH to force uBridge to use npcap DLL instead of Winpcap (if installed)
system_root = os.path.join(os... | [
"def",
"start",
"(",
"self",
")",
":",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"# add the Npcap directory to $PATH to force uBridge to use npcap DLL instead of Winpcap (if in... | Starts the uBridge hypervisor process. | [
"Starts",
"the",
"uBridge",
"hypervisor",
"process",
"."
] | python | train |
wummel/linkchecker | linkcheck/bookmarks/safari.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/bookmarks/safari.py#L34-L49 | def find_bookmark_file ():
"""Return the bookmark file of the Default profile.
Returns absolute filename if found, or empty string if no bookmark file
could be found.
"""
if sys.platform != 'darwin':
return u""
try:
dirname = get_profile_dir()
if os.path.isdir(dirname):
... | [
"def",
"find_bookmark_file",
"(",
")",
":",
"if",
"sys",
".",
"platform",
"!=",
"'darwin'",
":",
"return",
"u\"\"",
"try",
":",
"dirname",
"=",
"get_profile_dir",
"(",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"dirname",
")",
":",
"fname",
"=",
... | Return the bookmark file of the Default profile.
Returns absolute filename if found, or empty string if no bookmark file
could be found. | [
"Return",
"the",
"bookmark",
"file",
"of",
"the",
"Default",
"profile",
".",
"Returns",
"absolute",
"filename",
"if",
"found",
"or",
"empty",
"string",
"if",
"no",
"bookmark",
"file",
"could",
"be",
"found",
"."
] | python | train |
agile-geoscience/striplog | striplog/striplog.py | https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1869-L1900 | def merge_overlaps(self):
"""
Merges overlaps by merging overlapping Intervals.
The function takes no arguments and returns ``None``. It operates on
the striplog 'in place'
TODO: This function will not work if any interval overlaps more than
one other intervals at e... | [
"def",
"merge_overlaps",
"(",
"self",
")",
":",
"overlaps",
"=",
"np",
".",
"array",
"(",
"self",
".",
"find_overlaps",
"(",
"index",
"=",
"True",
")",
")",
"if",
"not",
"overlaps",
".",
"any",
"(",
")",
":",
"return",
"for",
"overlap",
"in",
"overla... | Merges overlaps by merging overlapping Intervals.
The function takes no arguments and returns ``None``. It operates on
the striplog 'in place'
TODO: This function will not work if any interval overlaps more than
one other intervals at either its base or top. | [
"Merges",
"overlaps",
"by",
"merging",
"overlapping",
"Intervals",
"."
] | python | test |
genialis/resolwe | resolwe/elastic/pagination.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/pagination.py#L47-L54 | def get_offset(self, request):
"""Return offset parameter."""
try:
return _positive_int(
get_query_param(request, self.offset_query_param),
)
except (KeyError, ValueError):
return 0 | [
"def",
"get_offset",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"return",
"_positive_int",
"(",
"get_query_param",
"(",
"request",
",",
"self",
".",
"offset_query_param",
")",
",",
")",
"except",
"(",
"KeyError",
",",
"ValueError",
")",
":",
"retur... | Return offset parameter. | [
"Return",
"offset",
"parameter",
"."
] | python | train |
nickmilon/Hellas | Hellas/Sparta.py | https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L308-L317 | def chunks_str(str, n, separator="\n", fill_blanks_last=True):
"""returns lines with max n characters
:Example:
>>> print (chunks_str('123456X', 3))
123
456
X
"""
return separator.join(chunks(str, n)) | [
"def",
"chunks_str",
"(",
"str",
",",
"n",
",",
"separator",
"=",
"\"\\n\"",
",",
"fill_blanks_last",
"=",
"True",
")",
":",
"return",
"separator",
".",
"join",
"(",
"chunks",
"(",
"str",
",",
"n",
")",
")"
] | returns lines with max n characters
:Example:
>>> print (chunks_str('123456X', 3))
123
456
X | [
"returns",
"lines",
"with",
"max",
"n",
"characters"
] | python | train |
wonambi-python/wonambi | wonambi/widgets/traces.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/traces.py#L400-L414 | def create_chan_labels(self):
"""Create the channel labels, but don't plot them yet.
Notes
-----
It's necessary to have the width of the labels, so that we can adjust
the main scene.
"""
self.idx_label = []
for one_grp in self.parent.channels.groups:
... | [
"def",
"create_chan_labels",
"(",
"self",
")",
":",
"self",
".",
"idx_label",
"=",
"[",
"]",
"for",
"one_grp",
"in",
"self",
".",
"parent",
".",
"channels",
".",
"groups",
":",
"for",
"one_label",
"in",
"one_grp",
"[",
"'chan_to_plot'",
"]",
":",
"item",... | Create the channel labels, but don't plot them yet.
Notes
-----
It's necessary to have the width of the labels, so that we can adjust
the main scene. | [
"Create",
"the",
"channel",
"labels",
"but",
"don",
"t",
"plot",
"them",
"yet",
"."
] | python | train |
yunojuno/elasticsearch-django | elasticsearch_django/models.py | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L350-L369 | def index_search_document(self, *, index):
"""
Create or replace search document in named index.
Checks the local cache to see if the document has changed,
and if not aborts the update, else pushes to ES, and then
resets the local cache. Cache timeout is set as "cache_expiry"
... | [
"def",
"index_search_document",
"(",
"self",
",",
"*",
",",
"index",
")",
":",
"cache_key",
"=",
"self",
".",
"search_document_cache_key",
"new_doc",
"=",
"self",
".",
"as_search_document",
"(",
"index",
"=",
"index",
")",
"cached_doc",
"=",
"cache",
".",
"g... | Create or replace search document in named index.
Checks the local cache to see if the document has changed,
and if not aborts the update, else pushes to ES, and then
resets the local cache. Cache timeout is set as "cache_expiry"
in the settings, and defaults to 60s. | [
"Create",
"or",
"replace",
"search",
"document",
"in",
"named",
"index",
"."
] | python | train |
infothrill/python-dyndnsc | dyndnsc/common/load.py | https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/common/load.py#L9-L24 | def load_class(module_name, class_name):
"""Return class object specified by module name and class name.
Return None if module failed to be imported.
:param module_name: string module name
:param class_name: string class name
"""
try:
plugmod = import_module(module_name)
except Exc... | [
"def",
"load_class",
"(",
"module_name",
",",
"class_name",
")",
":",
"try",
":",
"plugmod",
"=",
"import_module",
"(",
"module_name",
")",
"except",
"Exception",
"as",
"exc",
":",
"warn",
"(",
"\"Importing built-in plugin %s.%s raised an exception: %r\"",
"%",
"(",... | Return class object specified by module name and class name.
Return None if module failed to be imported.
:param module_name: string module name
:param class_name: string class name | [
"Return",
"class",
"object",
"specified",
"by",
"module",
"name",
"and",
"class",
"name",
"."
] | python | train |
JoelBender/bacpypes | py34/bacpypes/primitivedata.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py34/bacpypes/primitivedata.py#L377-L385 | def Pop(self):
"""Remove the tag from the front of the list and return it."""
if self.tagList:
tag = self.tagList[0]
del self.tagList[0]
else:
tag = None
return tag | [
"def",
"Pop",
"(",
"self",
")",
":",
"if",
"self",
".",
"tagList",
":",
"tag",
"=",
"self",
".",
"tagList",
"[",
"0",
"]",
"del",
"self",
".",
"tagList",
"[",
"0",
"]",
"else",
":",
"tag",
"=",
"None",
"return",
"tag"
] | Remove the tag from the front of the list and return it. | [
"Remove",
"the",
"tag",
"from",
"the",
"front",
"of",
"the",
"list",
"and",
"return",
"it",
"."
] | python | train |
ejhigson/nestcheck | nestcheck/write_polychord_output.py | https://github.com/ejhigson/nestcheck/blob/29151c314deb89746fd674f27f6ce54b77603189/nestcheck/write_polychord_output.py#L118-L154 | def run_dead_birth_array(run, **kwargs):
"""Converts input run into an array of the format of a PolyChord
<root>_dead-birth.txt file. Note that this in fact includes live points
remaining at termination as well as dead points.
Parameters
----------
ns_run: dict
Nested sampling run dict ... | [
"def",
"run_dead_birth_array",
"(",
"run",
",",
"*",
"*",
"kwargs",
")",
":",
"nestcheck",
".",
"ns_run_utils",
".",
"check_ns_run",
"(",
"run",
",",
"*",
"*",
"kwargs",
")",
"threads",
"=",
"nestcheck",
".",
"ns_run_utils",
".",
"get_run_threads",
"(",
"r... | Converts input run into an array of the format of a PolyChord
<root>_dead-birth.txt file. Note that this in fact includes live points
remaining at termination as well as dead points.
Parameters
----------
ns_run: dict
Nested sampling run dict (see data_processing module docstring for more
... | [
"Converts",
"input",
"run",
"into",
"an",
"array",
"of",
"the",
"format",
"of",
"a",
"PolyChord",
"<root",
">",
"_dead",
"-",
"birth",
".",
"txt",
"file",
".",
"Note",
"that",
"this",
"in",
"fact",
"includes",
"live",
"points",
"remaining",
"at",
"termin... | python | train |
vinci1it2000/schedula | schedula/utils/blue.py | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/blue.py#L49-L87 | def register(self, obj=None, memo=None):
"""
Creates a :class:`Blueprint.cls` and calls each deferred operation.
:param obj:
The initialized object with which to call all deferred operations.
:type obj: object
:param memo:
A dictionary to cache registere... | [
"def",
"register",
"(",
"self",
",",
"obj",
"=",
"None",
",",
"memo",
"=",
"None",
")",
":",
"if",
"memo",
"and",
"self",
"in",
"memo",
":",
"obj",
"=",
"memo",
"[",
"self",
"]",
"if",
"obj",
"is",
"not",
"None",
":",
"return",
"obj",
"if",
"ob... | Creates a :class:`Blueprint.cls` and calls each deferred operation.
:param obj:
The initialized object with which to call all deferred operations.
:type obj: object
:param memo:
A dictionary to cache registered Blueprints.
:type memo: dict[Blueprint,T]
... | [
"Creates",
"a",
":",
"class",
":",
"Blueprint",
".",
"cls",
"and",
"calls",
"each",
"deferred",
"operation",
"."
] | python | train |
edx/edx-enterprise | enterprise/api/v1/serializers.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L438-L459 | def to_representation(self, instance):
"""
Return the updated program data dictionary.
Arguments:
instance (dict): The program data.
Returns:
dict: The updated program data.
"""
updated_program = copy.deepcopy(instance)
enterprise_custome... | [
"def",
"to_representation",
"(",
"self",
",",
"instance",
")",
":",
"updated_program",
"=",
"copy",
".",
"deepcopy",
"(",
"instance",
")",
"enterprise_customer_catalog",
"=",
"self",
".",
"context",
"[",
"'enterprise_customer_catalog'",
"]",
"updated_program",
"[",
... | Return the updated program data dictionary.
Arguments:
instance (dict): The program data.
Returns:
dict: The updated program data. | [
"Return",
"the",
"updated",
"program",
"data",
"dictionary",
"."
] | python | valid |
angr/angr | angr/analyses/binary_optimizer.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/binary_optimizer.py#L616-L648 | def _dead_assignment_elimination(self, function, data_graph): #pylint:disable=unused-argument
"""
Remove assignments to registers that has no consumers, but immediately killed.
BROKEN - DO NOT USE IT
:param angr.knowledge.Function function:
:param networkx.MultiDiGraph data_gr... | [
"def",
"_dead_assignment_elimination",
"(",
"self",
",",
"function",
",",
"data_graph",
")",
":",
"#pylint:disable=unused-argument",
"register_pvs",
"=",
"set",
"(",
")",
"for",
"node",
"in",
"data_graph",
".",
"nodes",
"(",
")",
":",
"if",
"isinstance",
"(",
... | Remove assignments to registers that has no consumers, but immediately killed.
BROKEN - DO NOT USE IT
:param angr.knowledge.Function function:
:param networkx.MultiDiGraph data_graph:
:return: None | [
"Remove",
"assignments",
"to",
"registers",
"that",
"has",
"no",
"consumers",
"but",
"immediately",
"killed",
"."
] | python | train |
MrKiven/Todo.py | Todos/todo.py | https://github.com/MrKiven/Todo.py/blob/945090ce29daad740b9adf34ac8e859026fed3d5/Todos/todo.py#L54-L73 | def init(self):
"""init `todo` file
if file exists, then initialization self.todos
and record current max index of todos
: when add a new todo, the `idx` via only `self.current_max_idx + 1`
"""
if os.path.isdir(self.path):
raise InvalidTodoFile
if os.p... | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"path",
")",
":",
"raise",
"InvalidTodoFile",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"with",
"open",
"(",
"self",
... | init `todo` file
if file exists, then initialization self.todos
and record current max index of todos
: when add a new todo, the `idx` via only `self.current_max_idx + 1` | [
"init",
"todo",
"file",
"if",
"file",
"exists",
"then",
"initialization",
"self",
".",
"todos",
"and",
"record",
"current",
"max",
"index",
"of",
"todos",
":",
"when",
"add",
"a",
"new",
"todo",
"the",
"idx",
"via",
"only",
"self",
".",
"current_max_idx",
... | python | train |
ccubed/PyMoe | Pymoe/Kitsu/user.py | https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/user.py#L11-L29 | def search(self, term):
"""
Search for a user by name.
:param str term: What to search for.
:return: The results as a SearchWrapper iterator or None if no results.
:rtype: SearchWrapper or None
"""
r = requests.get(self.apiurl + "/users", params={"filter[name]": ... | [
"def",
"search",
"(",
"self",
",",
"term",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"apiurl",
"+",
"\"/users\"",
",",
"params",
"=",
"{",
"\"filter[name]\"",
":",
"term",
"}",
",",
"headers",
"=",
"self",
".",
"header",
")",
"i... | Search for a user by name.
:param str term: What to search for.
:return: The results as a SearchWrapper iterator or None if no results.
:rtype: SearchWrapper or None | [
"Search",
"for",
"a",
"user",
"by",
"name",
"."
] | python | train |
serge-sans-paille/pythran | pythran/tables.py | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/tables.py#L161-L170 | def update_effects(self, node):
"""
Combiner when we update the first argument of a function.
It turn type of first parameter in combination of all others
parameters types.
"""
return [self.combine(node.args[0], node_args_k, register=True,
aliasing_type=True)
... | [
"def",
"update_effects",
"(",
"self",
",",
"node",
")",
":",
"return",
"[",
"self",
".",
"combine",
"(",
"node",
".",
"args",
"[",
"0",
"]",
",",
"node_args_k",
",",
"register",
"=",
"True",
",",
"aliasing_type",
"=",
"True",
")",
"for",
"node_args_k",... | Combiner when we update the first argument of a function.
It turn type of first parameter in combination of all others
parameters types. | [
"Combiner",
"when",
"we",
"update",
"the",
"first",
"argument",
"of",
"a",
"function",
"."
] | python | train |
phaethon/kamene | kamene/contrib/gsm_um.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L941-L951 | def rrInitialisationRequest():
"""RR Initialisation Request Section 9.1.28.a"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x3c) # 00111100
c = CiphKeySeqNrAndMacModeAndChannelCodingRequest()
e = MobileStationClassmark2()
f = Tlli()
g = ChannelRequestDescription()
h = GprsMeasurementResul... | [
"def",
"rrInitialisationRequest",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x3c",
")",
"# 00111100",
"c",
"=",
"CiphKeySeqNrAndMacModeAndChannelCodingRequest",
"(",
")",
"e",
"=",
"MobileStat... | RR Initialisation Request Section 9.1.28.a | [
"RR",
"Initialisation",
"Request",
"Section",
"9",
".",
"1",
".",
"28",
".",
"a"
] | python | train |
annoviko/pyclustering | pyclustering/nnet/hysteresis.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/hysteresis.py#L347-L367 | def _calculate_states(self, solution, t, step, int_step):
"""!
@brief Calculates new states for neurons using differential calculus. Returns new states for neurons.
@param[in] solution (solve_type): Type solver of the differential equation.
@param[in] t (double): Current ti... | [
"def",
"_calculate_states",
"(",
"self",
",",
"solution",
",",
"t",
",",
"step",
",",
"int_step",
")",
":",
"next_states",
"=",
"[",
"0",
"]",
"*",
"self",
".",
"_num_osc",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"self",
".",
"_num_osc",
",",
... | !
@brief Calculates new states for neurons using differential calculus. Returns new states for neurons.
@param[in] solution (solve_type): Type solver of the differential equation.
@param[in] t (double): Current time of simulation.
@param[in] step (double): Step of solution ... | [
"!"
] | python | valid |
RiotGames/cloud-inquisitor | plugins/public/cinq-collector-dns/cinq_collector_dns/__init__.py | https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/plugins/public/cinq-collector-dns/cinq_collector_dns/__init__.py#L233-L263 | def __cloudflare_request(self, *, account, path, args=None):
"""Helper function to interact with the CloudFlare API.
Args:
account (:obj:`CloudFlareAccount`): CloudFlare Account object
path (`str`): URL endpoint to communicate with
args (:obj:`dict` of `str`: `str`):... | [
"def",
"__cloudflare_request",
"(",
"self",
",",
"*",
",",
"account",
",",
"path",
",",
"args",
"=",
"None",
")",
":",
"if",
"not",
"args",
":",
"args",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"cloudflare_initialized",
"[",
"account",
".",
"account_id... | Helper function to interact with the CloudFlare API.
Args:
account (:obj:`CloudFlareAccount`): CloudFlare Account object
path (`str`): URL endpoint to communicate with
args (:obj:`dict` of `str`: `str`): A dictionary of arguments for the endpoint to consume
Returns:... | [
"Helper",
"function",
"to",
"interact",
"with",
"the",
"CloudFlare",
"API",
"."
] | python | train |
wbond/certvalidator | certvalidator/ocsp_client.py | https://github.com/wbond/certvalidator/blob/c62233a713bcc36963e9d82323ec8d84f8e01485/certvalidator/ocsp_client.py#L14-L109 | def fetch(cert, issuer, hash_algo='sha1', nonce=True, user_agent=None, timeout=10):
"""
Fetches an OCSP response for a certificate
:param cert:
An asn1cyrpto.x509.Certificate object to get an OCSP reponse for
:param issuer:
An asn1crypto.x509.Certificate object that is the issuer of ce... | [
"def",
"fetch",
"(",
"cert",
",",
"issuer",
",",
"hash_algo",
"=",
"'sha1'",
",",
"nonce",
"=",
"True",
",",
"user_agent",
"=",
"None",
",",
"timeout",
"=",
"10",
")",
":",
"if",
"not",
"isinstance",
"(",
"cert",
",",
"x509",
".",
"Certificate",
")",... | Fetches an OCSP response for a certificate
:param cert:
An asn1cyrpto.x509.Certificate object to get an OCSP reponse for
:param issuer:
An asn1crypto.x509.Certificate object that is the issuer of cert
:param hash_algo:
A unicode string of "sha1" or "sha256"
:param nonce:
... | [
"Fetches",
"an",
"OCSP",
"response",
"for",
"a",
"certificate"
] | python | train |
cloudbase/python-hnvclient | hnv/client.py | https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/client.py#L167-L176 | def _get(cls, resource_id, parent_id, grandparent_id):
""""Retrieves the required resource."""
client = cls._get_client()
endpoint = cls._endpoint.format(resource_id=resource_id or "",
parent_id=parent_id or "",
gran... | [
"def",
"_get",
"(",
"cls",
",",
"resource_id",
",",
"parent_id",
",",
"grandparent_id",
")",
":",
"client",
"=",
"cls",
".",
"_get_client",
"(",
")",
"endpoint",
"=",
"cls",
".",
"_endpoint",
".",
"format",
"(",
"resource_id",
"=",
"resource_id",
"or",
"... | Retrieves the required resource. | [
"Retrieves",
"the",
"required",
"resource",
"."
] | python | train |
trailofbits/manticore | manticore/platforms/linux.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/linux.py#L1127-L1141 | def _open(self, f):
"""
Adds a file descriptor to the current file descriptor list
:rtype: int
:param f: the file descriptor to add.
:return: the index of the file descriptor in the file descr. list
"""
if None in self.files:
fd = self.files.index(Non... | [
"def",
"_open",
"(",
"self",
",",
"f",
")",
":",
"if",
"None",
"in",
"self",
".",
"files",
":",
"fd",
"=",
"self",
".",
"files",
".",
"index",
"(",
"None",
")",
"self",
".",
"files",
"[",
"fd",
"]",
"=",
"f",
"else",
":",
"fd",
"=",
"len",
... | Adds a file descriptor to the current file descriptor list
:rtype: int
:param f: the file descriptor to add.
:return: the index of the file descriptor in the file descr. list | [
"Adds",
"a",
"file",
"descriptor",
"to",
"the",
"current",
"file",
"descriptor",
"list"
] | python | valid |
ldomic/lintools | lintools/data.py | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/data.py#L130-L152 | def find_the_closest_atoms(self,topology):
"""
This function defines the ligand atoms that are closest to the residues that will be plotted
in the final graph.
"""
# The measurements are made to ligand molecule without hydrogen atoms (ligand_noH) because the
# hydrogen a... | [
"def",
"find_the_closest_atoms",
"(",
"self",
",",
"topology",
")",
":",
"# The measurements are made to ligand molecule without hydrogen atoms (ligand_noH) because the",
"# hydrogen atoms are not plotted in the final graph",
"self",
".",
"universe",
".",
"load_new",
"(",
"topology",... | This function defines the ligand atoms that are closest to the residues that will be plotted
in the final graph. | [
"This",
"function",
"defines",
"the",
"ligand",
"atoms",
"that",
"are",
"closest",
"to",
"the",
"residues",
"that",
"will",
"be",
"plotted",
"in",
"the",
"final",
"graph",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.