repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
AnalogJ/lexicon | lexicon/parser.py | https://github.com/AnalogJ/lexicon/blob/9330b871988753cad44fe2876a217b4c67b1fa0e/lexicon/parser.py#L9-L33 | def generate_base_provider_parser():
"""Function that generates the base provider to be used by all dns providers."""
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('action', help='specify the action to take', default='list',
choices=['create', 'list', 'update',... | [
"def",
"generate_base_provider_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"add_help",
"=",
"False",
")",
"parser",
".",
"add_argument",
"(",
"'action'",
",",
"help",
"=",
"'specify the action to take'",
",",
"default",
"=",
"'... | Function that generates the base provider to be used by all dns providers. | [
"Function",
"that",
"generates",
"the",
"base",
"provider",
"to",
"be",
"used",
"by",
"all",
"dns",
"providers",
"."
] | python | train | 63.76 |
google/textfsm | textfsm/terminal.py | https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/terminal.py#L406-L426 | def _AskUser(self):
"""Prompt the user for the next action.
Returns:
A string, the character entered by the user.
"""
if self._show_percent:
progress = int(self._displayed*100 / (len(self._text.splitlines())))
progress_text = ' (%d%%)' % progress
else:
progress_text = ''
... | [
"def",
"_AskUser",
"(",
"self",
")",
":",
"if",
"self",
".",
"_show_percent",
":",
"progress",
"=",
"int",
"(",
"self",
".",
"_displayed",
"*",
"100",
"/",
"(",
"len",
"(",
"self",
".",
"_text",
".",
"splitlines",
"(",
")",
")",
")",
")",
"progress... | Prompt the user for the next action.
Returns:
A string, the character entered by the user. | [
"Prompt",
"the",
"user",
"for",
"the",
"next",
"action",
"."
] | python | train | 28.857143 |
astroswego/plotypus | src/plotypus/preprocessing.py | https://github.com/astroswego/plotypus/blob/b1162194ca1d4f6c00e79afe3e6fb40f0eaffcb9/src/plotypus/preprocessing.py#L204-L260 | def design_matrix(phases, degree):
r"""
Constructs an :math:`N \times 2n+1` matrix of the form:
.. math::
\begin{bmatrix}
1
& \sin(1 \cdot 2\pi \cdot \phi_0)
& \cos(1 \cdot 2\pi \cdot \phi_0)
& \ldots
& \sin(n \cdot 2\pi... | [
"def",
"design_matrix",
"(",
"phases",
",",
"degree",
")",
":",
"n_samples",
"=",
"phases",
".",
"size",
"# initialize coefficient matrix",
"M",
"=",
"numpy",
".",
"empty",
"(",
"(",
"n_samples",
",",
"2",
"*",
"degree",
"+",
"1",
")",
")",
"# indices",
... | r"""
Constructs an :math:`N \times 2n+1` matrix of the form:
.. math::
\begin{bmatrix}
1
& \sin(1 \cdot 2\pi \cdot \phi_0)
& \cos(1 \cdot 2\pi \cdot \phi_0)
& \ldots
& \sin(n \cdot 2\pi \cdot \phi_0)
& \cos(n \cdot 2... | [
"r",
"Constructs",
"an",
":",
"math",
":",
"N",
"\\",
"times",
"2n",
"+",
"1",
"matrix",
"of",
"the",
"form",
":"
] | python | train | 31.842105 |
FutunnOpen/futuquant | futuquant/common/handler_context.py | https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/common/handler_context.py#L72-L83 | def set_pre_handler(self, handler):
'''pre handler push
return: ret_error or ret_ok
'''
set_flag = False
for protoc in self._pre_handler_table:
if isinstance(handler, self._pre_handler_table[protoc]["type"]):
self._pre_handler_table[protoc]["obj"] = ha... | [
"def",
"set_pre_handler",
"(",
"self",
",",
"handler",
")",
":",
"set_flag",
"=",
"False",
"for",
"protoc",
"in",
"self",
".",
"_pre_handler_table",
":",
"if",
"isinstance",
"(",
"handler",
",",
"self",
".",
"_pre_handler_table",
"[",
"protoc",
"]",
"[",
"... | pre handler push
return: ret_error or ret_ok | [
"pre",
"handler",
"push",
"return",
":",
"ret_error",
"or",
"ret_ok"
] | python | train | 33.666667 |
dhylands/rshell | rshell/main.py | https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L1506-L1511 | def sync_time(self):
"""Sets the time on the pyboard to match the time on the host."""
now = time.localtime(time.time())
self.remote(set_time, (now.tm_year, now.tm_mon, now.tm_mday, now.tm_wday + 1,
now.tm_hour, now.tm_min, now.tm_sec, 0))
return now | [
"def",
"sync_time",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"localtime",
"(",
"time",
".",
"time",
"(",
")",
")",
"self",
".",
"remote",
"(",
"set_time",
",",
"(",
"now",
".",
"tm_year",
",",
"now",
".",
"tm_mon",
",",
"now",
".",
"tm_mda... | Sets the time on the pyboard to match the time on the host. | [
"Sets",
"the",
"time",
"on",
"the",
"pyboard",
"to",
"match",
"the",
"time",
"on",
"the",
"host",
"."
] | python | train | 51.333333 |
casacore/python-casacore | casacore/measures/__init__.py | https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/measures/__init__.py#L448-L467 | def torestfrequency(self, f0, d0):
"""Convert a frequency measure and a doppler measure (e.g.
obtained from another spectral line with a known rest frequency) to
a rest frequency.
:param f0: frequency reference code (see :meth:`frequency`)
:param v0: a doppler measure
E... | [
"def",
"torestfrequency",
"(",
"self",
",",
"f0",
",",
"d0",
")",
":",
"if",
"is_measure",
"(",
"f0",
")",
"and",
"f0",
"[",
"'type'",
"]",
"==",
"'frequency'",
"and",
"is_measure",
"(",
"d0",
")",
"and",
"d0",
"[",
"'type'",
"]",
"==",
"'doppler'",
... | Convert a frequency measure and a doppler measure (e.g.
obtained from another spectral line with a known rest frequency) to
a rest frequency.
:param f0: frequency reference code (see :meth:`frequency`)
:param v0: a doppler measure
Example::
dp = dm.doppler('radio',... | [
"Convert",
"a",
"frequency",
"measure",
"and",
"a",
"doppler",
"measure",
"(",
"e",
".",
"g",
".",
"obtained",
"from",
"another",
"spectral",
"line",
"with",
"a",
"known",
"rest",
"frequency",
")",
"to",
"a",
"rest",
"frequency",
"."
] | python | train | 40.45 |
mitsei/dlkit | dlkit/json_/repository/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L2391-L2412 | def get_repository_ids_by_asset(self, asset_id):
"""Gets the list of ``Repository`` ``Ids`` mapped to an ``Asset``.
arg: asset_id (osid.id.Id): ``Id`` of an ``Asset``
return: (osid.id.IdList) - list of repository ``Ids``
raise: NotFound - ``asset_id`` is not found
raise: N... | [
"def",
"get_repository_ids_by_asset",
"(",
"self",
",",
"asset_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceBinSession.get_bin_ids_by_resource",
"mgr",
"=",
"self",
".",
"_get_provider_manager",
"(",
"'REPOSITORY'",
",",
"local",
"=",
"True",
"... | Gets the list of ``Repository`` ``Ids`` mapped to an ``Asset``.
arg: asset_id (osid.id.Id): ``Id`` of an ``Asset``
return: (osid.id.IdList) - list of repository ``Ids``
raise: NotFound - ``asset_id`` is not found
raise: NullArgument - ``asset_id`` is ``null``
raise: Opera... | [
"Gets",
"the",
"list",
"of",
"Repository",
"Ids",
"mapped",
"to",
"an",
"Asset",
"."
] | python | train | 47.272727 |
ejeschke/ginga | ginga/rv/plugins/SaveImage.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/SaveImage.py#L395-L422 | def _write_mosaic(self, key, outfile):
"""Write out mosaic data (or any new data generated within Ginga)
to single-extension FITS.
"""
maxsize = self.settings.get('max_mosaic_size', 1e8) # Default 10k x 10k
channel = self.fv.get_channel(self.chname)
image = channel.data... | [
"def",
"_write_mosaic",
"(",
"self",
",",
"key",
",",
"outfile",
")",
":",
"maxsize",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"'max_mosaic_size'",
",",
"1e8",
")",
"# Default 10k x 10k",
"channel",
"=",
"self",
".",
"fv",
".",
"get_channel",
"(",
... | Write out mosaic data (or any new data generated within Ginga)
to single-extension FITS. | [
"Write",
"out",
"mosaic",
"data",
"(",
"or",
"any",
"new",
"data",
"generated",
"within",
"Ginga",
")",
"to",
"single",
"-",
"extension",
"FITS",
"."
] | python | train | 34 |
mongodb/mongo-python-driver | pymongo/bulk.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/bulk.py#L432-L497 | def execute_no_results(self, sock_info, generator):
"""Execute all operations, returning no results (w=0).
"""
if self.uses_collation:
raise ConfigurationError(
'Collation is unsupported for unacknowledged writes.')
if self.uses_array_filters:
rais... | [
"def",
"execute_no_results",
"(",
"self",
",",
"sock_info",
",",
"generator",
")",
":",
"if",
"self",
".",
"uses_collation",
":",
"raise",
"ConfigurationError",
"(",
"'Collation is unsupported for unacknowledged writes.'",
")",
"if",
"self",
".",
"uses_array_filters",
... | Execute all operations, returning no results (w=0). | [
"Execute",
"all",
"operations",
"returning",
"no",
"results",
"(",
"w",
"=",
"0",
")",
"."
] | python | train | 44.681818 |
maxfischer2781/chainlet | chainlet/chainsend.py | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/chainsend.py#L29-L50 | def eager_send(chainlet, chunks):
"""
Eager version of `lazy_send` evaluating the return value immediately
:note: The return value by an ``n`` to ``m`` link is considered fully evaluated.
:param chainlet: the chainlet to receive and return data
:type chainlet: chainlink.ChainLink
:param chunks... | [
"def",
"eager_send",
"(",
"chainlet",
",",
"chunks",
")",
":",
"fork",
",",
"join",
"=",
"chainlet",
".",
"chain_fork",
",",
"chainlet",
".",
"chain_join",
"if",
"fork",
"and",
"join",
":",
"return",
"_send_n_get_m",
"(",
"chainlet",
",",
"chunks",
")",
... | Eager version of `lazy_send` evaluating the return value immediately
:note: The return value by an ``n`` to ``m`` link is considered fully evaluated.
:param chainlet: the chainlet to receive and return data
:type chainlet: chainlink.ChainLink
:param chunks: the stream slice of data to pass to ``chainl... | [
"Eager",
"version",
"of",
"lazy_send",
"evaluating",
"the",
"return",
"value",
"immediately"
] | python | train | 37.363636 |
vingd/encrypted-pickle-python | encryptedpickle/utils.py | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/utils.py#L17-L25 | def urlsafe_nopadding_b64decode(data):
'''URL safe Base64 decode without padding (=)'''
padding = len(data) % 4
if padding != 0:
padding = 4 - padding
padding = '=' * padding
data = data + padding
return urlsafe_b64decode(data) | [
"def",
"urlsafe_nopadding_b64decode",
"(",
"data",
")",
":",
"padding",
"=",
"len",
"(",
"data",
")",
"%",
"4",
"if",
"padding",
"!=",
"0",
":",
"padding",
"=",
"4",
"-",
"padding",
"padding",
"=",
"'='",
"*",
"padding",
"data",
"=",
"data",
"+",
"pa... | URL safe Base64 decode without padding (=) | [
"URL",
"safe",
"Base64",
"decode",
"without",
"padding",
"(",
"=",
")"
] | python | valid | 28 |
secdev/scapy | scapy/layers/inet6.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3916-L3994 | def NDP_Attack_Fake_Router(ra, iface=None, mac_src_filter=None,
ip_src_filter=None):
"""
The purpose of this function is to send provided RA message at layer 2
(i.e. providing a packet starting with IPv6 will not work) in response
to received RS messages. In the end, the funct... | [
"def",
"NDP_Attack_Fake_Router",
"(",
"ra",
",",
"iface",
"=",
"None",
",",
"mac_src_filter",
"=",
"None",
",",
"ip_src_filter",
"=",
"None",
")",
":",
"def",
"is_request",
"(",
"req",
",",
"mac_src_filter",
",",
"ip_src_filter",
")",
":",
"\"\"\"\n Che... | The purpose of this function is to send provided RA message at layer 2
(i.e. providing a packet starting with IPv6 will not work) in response
to received RS messages. In the end, the function is a simple wrapper
around sendp() that monitor the link for RS messages.
It is probably better explained with ... | [
"The",
"purpose",
"of",
"this",
"function",
"is",
"to",
"send",
"provided",
"RA",
"message",
"at",
"layer",
"2",
"(",
"i",
".",
"e",
".",
"providing",
"a",
"packet",
"starting",
"with",
"IPv6",
"will",
"not",
"work",
")",
"in",
"response",
"to",
"recei... | python | train | 37.443038 |
mbj4668/pyang | pyang/translators/dsdl.py | https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L882-L915 | def handle_stmt(self, stmt, p_elem, pset={}):
"""
Run handler method for statement `stmt`.
`p_elem` is the parent node in the output schema. `pset` is
the current "patch set" - a dictionary with keys being QNames
of schema nodes at the current level of hierarchy for which
... | [
"def",
"handle_stmt",
"(",
"self",
",",
"stmt",
",",
"p_elem",
",",
"pset",
"=",
"{",
"}",
")",
":",
"if",
"self",
".",
"debug",
">",
"0",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"Handling '%s %s'\\n\"",
"%",
"(",
"util",
".",
"keyword_to_str... | Run handler method for statement `stmt`.
`p_elem` is the parent node in the output schema. `pset` is
the current "patch set" - a dictionary with keys being QNames
of schema nodes at the current level of hierarchy for which
(or descendants thereof) any pending patches exist. The values
... | [
"Run",
"handler",
"method",
"for",
"statement",
"stmt",
"."
] | python | train | 43.264706 |
patarapolw/AnkiTools | AnkiTools/ankiconnect.py | https://github.com/patarapolw/AnkiTools/blob/fab6836dfd9cf5171d9cbff5c55fbb14d2786f05/AnkiTools/ankiconnect.py#L14-L32 | def post(action, params=None, version=6):
"""
For the documentation, see https://foosoft.net/projects/anki-connect/
:param str action:
:param dict params:
:param int version:
:return:
"""
if params is None:
params = dict()
to_send = {
... | [
"def",
"post",
"(",
"action",
",",
"params",
"=",
"None",
",",
"version",
"=",
"6",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"dict",
"(",
")",
"to_send",
"=",
"{",
"'action'",
":",
"action",
",",
"'version'",
":",
"version",
",",... | For the documentation, see https://foosoft.net/projects/anki-connect/
:param str action:
:param dict params:
:param int version:
:return: | [
"For",
"the",
"documentation",
"see",
"https",
":",
"//",
"foosoft",
".",
"net",
"/",
"projects",
"/",
"anki",
"-",
"connect",
"/"
] | python | train | 25.473684 |
peterwittek/ncpol2sdpa | ncpol2sdpa/mosek_utils.py | https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/mosek_utils.py#L158-L208 | def convert_to_mosek(sdp):
"""Convert an SDP relaxation to a MOSEK task.
:param sdp: The SDP relaxation to convert.
:type sdp: :class:`ncpol2sdpa.sdp`.
:returns: :class:`mosek.Task`.
"""
import mosek
# Cheat when variables are complex and convert with PICOS
if sdp.complex_matrix:
... | [
"def",
"convert_to_mosek",
"(",
"sdp",
")",
":",
"import",
"mosek",
"# Cheat when variables are complex and convert with PICOS",
"if",
"sdp",
".",
"complex_matrix",
":",
"from",
".",
"picos_utils",
"import",
"convert_to_picos",
"Problem",
"=",
"convert_to_picos",
"(",
"... | Convert an SDP relaxation to a MOSEK task.
:param sdp: The SDP relaxation to convert.
:type sdp: :class:`ncpol2sdpa.sdp`.
:returns: :class:`mosek.Task`. | [
"Convert",
"an",
"SDP",
"relaxation",
"to",
"a",
"MOSEK",
"task",
"."
] | python | train | 30.745098 |
ascribe/pyspool | spool/spool.py | https://github.com/ascribe/pyspool/blob/f8b10df1e7d2ea7950dde433c1cb6d5225112f4f/spool/spool.py#L477-L502 | def select_inputs(self, address, nfees, ntokens, min_confirmations=6):
"""
Selects the inputs for the spool transaction.
Args:
address (str): bitcoin address to select inputs for
nfees (int): number of fees
ntokens (int): number of tokens
min_conf... | [
"def",
"select_inputs",
"(",
"self",
",",
"address",
",",
"nfees",
",",
"ntokens",
",",
"min_confirmations",
"=",
"6",
")",
":",
"unspents",
"=",
"self",
".",
"_t",
".",
"get",
"(",
"address",
",",
"min_confirmations",
"=",
"min_confirmations",
")",
"[",
... | Selects the inputs for the spool transaction.
Args:
address (str): bitcoin address to select inputs for
nfees (int): number of fees
ntokens (int): number of tokens
min_confirmations (Optional[int]): minimum number of required
confirmations; defaul... | [
"Selects",
"the",
"inputs",
"for",
"the",
"spool",
"transaction",
"."
] | python | train | 49.115385 |
MartinThoma/geocodertools | geocodertools/reverse.py | https://github.com/MartinThoma/geocodertools/blob/d590dbde7b03497df713bd9ae17d739319e87096/geocodertools/reverse.py#L97-L124 | def find_closest(db, pos):
"""Find the closest point in db to pos.
:returns: Closest dataset as well as the distance in meters.
"""
def get_dist(d1, d2):
"""Get distance between d1 and d2 in meters."""
lat1, lon1 = d1['latitude'], d1['longitude']
lat2, lon2 = d2['latitude'], d2['... | [
"def",
"find_closest",
"(",
"db",
",",
"pos",
")",
":",
"def",
"get_dist",
"(",
"d1",
",",
"d2",
")",
":",
"\"\"\"Get distance between d1 and d2 in meters.\"\"\"",
"lat1",
",",
"lon1",
"=",
"d1",
"[",
"'latitude'",
"]",
",",
"d1",
"[",
"'longitude'",
"]",
... | Find the closest point in db to pos.
:returns: Closest dataset as well as the distance in meters. | [
"Find",
"the",
"closest",
"point",
"in",
"db",
"to",
"pos",
".",
":",
"returns",
":",
"Closest",
"dataset",
"as",
"well",
"as",
"the",
"distance",
"in",
"meters",
"."
] | python | train | 36.714286 |
chimera0/accel-brain-code | Automatic-Summarization/pysummarization/readablewebpdf/web_pdf_reading.py | https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Automatic-Summarization/pysummarization/readablewebpdf/web_pdf_reading.py#L16-L28 | def url_to_text(self, url):
'''
Download PDF file and transform its document to string.
Args:
url: PDF url.
Returns:
string.
'''
path, headers = urllib.request.urlretrieve(url)
return self.path_to_text(path) | [
"def",
"url_to_text",
"(",
"self",
",",
"url",
")",
":",
"path",
",",
"headers",
"=",
"urllib",
".",
"request",
".",
"urlretrieve",
"(",
"url",
")",
"return",
"self",
".",
"path_to_text",
"(",
"path",
")"
] | Download PDF file and transform its document to string.
Args:
url: PDF url.
Returns:
string. | [
"Download",
"PDF",
"file",
"and",
"transform",
"its",
"document",
"to",
"string",
"."
] | python | train | 21.538462 |
senaite/senaite.core | bika/lims/browser/worksheet/views/referencesamples.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/worksheet/views/referencesamples.py#L150-L154 | def is_manage_allowed(self):
"""Check if manage is allowed
"""
checkPermission = self.context.portal_membership.checkPermission
return checkPermission(ManageWorksheets, self.context) | [
"def",
"is_manage_allowed",
"(",
"self",
")",
":",
"checkPermission",
"=",
"self",
".",
"context",
".",
"portal_membership",
".",
"checkPermission",
"return",
"checkPermission",
"(",
"ManageWorksheets",
",",
"self",
".",
"context",
")"
] | Check if manage is allowed | [
"Check",
"if",
"manage",
"is",
"allowed"
] | python | train | 42 |
DataBiosphere/toil | src/toil/worker.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/worker.py#L46-L100 | def nextChainableJobGraph(jobGraph, jobStore):
"""Returns the next chainable jobGraph after this jobGraph if one
exists, or None if the chain must terminate.
"""
#If no more jobs to run or services not finished, quit
if len(jobGraph.stack) == 0 or len(jobGraph.services) > 0 or jobGraph.checkpoint !=... | [
"def",
"nextChainableJobGraph",
"(",
"jobGraph",
",",
"jobStore",
")",
":",
"#If no more jobs to run or services not finished, quit",
"if",
"len",
"(",
"jobGraph",
".",
"stack",
")",
"==",
"0",
"or",
"len",
"(",
"jobGraph",
".",
"services",
")",
">",
"0",
"or",
... | Returns the next chainable jobGraph after this jobGraph if one
exists, or None if the chain must terminate. | [
"Returns",
"the",
"next",
"chainable",
"jobGraph",
"after",
"this",
"jobGraph",
"if",
"one",
"exists",
"or",
"None",
"if",
"the",
"chain",
"must",
"terminate",
"."
] | python | train | 41.581818 |
fastai/fastai | fastai/callbacks/tensorboard.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/callbacks/tensorboard.py#L325-L328 | def _write_avg_gradient(self)->None:
"Writes the average of the gradients to Tensorboard."
avg_gradient = sum(x.data.mean() for x in self.gradients)/len(self.gradients)
self._add_gradient_scalar('avg_gradient', scalar_value=avg_gradient) | [
"def",
"_write_avg_gradient",
"(",
"self",
")",
"->",
"None",
":",
"avg_gradient",
"=",
"sum",
"(",
"x",
".",
"data",
".",
"mean",
"(",
")",
"for",
"x",
"in",
"self",
".",
"gradients",
")",
"/",
"len",
"(",
"self",
".",
"gradients",
")",
"self",
".... | Writes the average of the gradients to Tensorboard. | [
"Writes",
"the",
"average",
"of",
"the",
"gradients",
"to",
"Tensorboard",
"."
] | python | train | 64.5 |
xenadevel/PyXenaManager | xenamanager/api/xena_rest.py | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_rest.py#L80-L90 | def send_command_return_multilines(self, obj, command, *arguments):
""" Send command with no output.
:param obj: requested object.
:param command: command to send.
:param arguments: list of command arguments.
:return: list of command output lines.
:rtype: list(str)
... | [
"def",
"send_command_return_multilines",
"(",
"self",
",",
"obj",
",",
"command",
",",
"*",
"arguments",
")",
":",
"return",
"self",
".",
"_perform_command",
"(",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"session_url",
",",
"obj",
".",
"ref",
")",
",",
... | Send command with no output.
:param obj: requested object.
:param command: command to send.
:param arguments: list of command arguments.
:return: list of command output lines.
:rtype: list(str) | [
"Send",
"command",
"with",
"no",
"output",
"."
] | python | train | 44.909091 |
dhylands/rshell | rshell/main.py | https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L2888-L2904 | def main():
"""This main function saves the stdin termios settings, calls real_main,
and restores stdin termios settings when it returns.
"""
save_settings = None
stdin_fd = -1
try:
import termios
stdin_fd = sys.stdin.fileno()
save_settings = termios.tcgetattr(stdin_fd... | [
"def",
"main",
"(",
")",
":",
"save_settings",
"=",
"None",
"stdin_fd",
"=",
"-",
"1",
"try",
":",
"import",
"termios",
"stdin_fd",
"=",
"sys",
".",
"stdin",
".",
"fileno",
"(",
")",
"save_settings",
"=",
"termios",
".",
"tcgetattr",
"(",
"stdin_fd",
"... | This main function saves the stdin termios settings, calls real_main,
and restores stdin termios settings when it returns. | [
"This",
"main",
"function",
"saves",
"the",
"stdin",
"termios",
"settings",
"calls",
"real_main",
"and",
"restores",
"stdin",
"termios",
"settings",
"when",
"it",
"returns",
"."
] | python | train | 27.647059 |
CalebBell/thermo | thermo/utils.py | https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/utils.py#L3332-L3366 | def calculate_derivative_T(self, T, P, zs, ws, method, order=1):
r'''Method to calculate a derivative of a mixture property with respect
to temperature at constant pressure and composition
of a given order using a specified method. Uses SciPy's derivative
function, with a delta of 1E-... | [
"def",
"calculate_derivative_T",
"(",
"self",
",",
"T",
",",
"P",
",",
"zs",
",",
"ws",
",",
"method",
",",
"order",
"=",
"1",
")",
":",
"return",
"derivative",
"(",
"self",
".",
"calculate",
",",
"T",
",",
"dx",
"=",
"1e-6",
",",
"args",
"=",
"[... | r'''Method to calculate a derivative of a mixture property with respect
to temperature at constant pressure and composition
of a given order using a specified method. Uses SciPy's derivative
function, with a delta of 1E-6 K and a number of points equal to
2*order + 1.
This m... | [
"r",
"Method",
"to",
"calculate",
"a",
"derivative",
"of",
"a",
"mixture",
"property",
"with",
"respect",
"to",
"temperature",
"at",
"constant",
"pressure",
"and",
"composition",
"of",
"a",
"given",
"order",
"using",
"a",
"specified",
"method",
".",
"Uses",
... | python | valid | 39.457143 |
edx/edx-enterprise | enterprise/api/v1/serializers.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L677-L692 | def validate_course_run_id(self, value):
"""
Validates that the course run id is part of the Enterprise Customer's catalog.
"""
enterprise_customer = self.context.get('enterprise_customer')
if not enterprise_customer.catalog_contains_course(value):
raise serializers.... | [
"def",
"validate_course_run_id",
"(",
"self",
",",
"value",
")",
":",
"enterprise_customer",
"=",
"self",
".",
"context",
".",
"get",
"(",
"'enterprise_customer'",
")",
"if",
"not",
"enterprise_customer",
".",
"catalog_contains_course",
"(",
"value",
")",
":",
"... | Validates that the course run id is part of the Enterprise Customer's catalog. | [
"Validates",
"that",
"the",
"course",
"run",
"id",
"is",
"part",
"of",
"the",
"Enterprise",
"Customer",
"s",
"catalog",
"."
] | python | valid | 39.3125 |
kowalpy/Robot-Framework-FTP-Library | FtpLibrary.py | https://github.com/kowalpy/Robot-Framework-FTP-Library/blob/90794be0a12af489ac98e8ae3b4ff450c83e2f3d/FtpLibrary.py#L319-L356 | def upload_file(self, localFileName, remoteFileName=None, connId='default'):
"""
Sends file from local drive to current directory on FTP server in binary mode.
Returns server output.
Parameters:
- localFileName - file name or path to a file on a local drive.
- remoteFileN... | [
"def",
"upload_file",
"(",
"self",
",",
"localFileName",
",",
"remoteFileName",
"=",
"None",
",",
"connId",
"=",
"'default'",
")",
":",
"thisConn",
"=",
"self",
".",
"__getConnection",
"(",
"connId",
")",
"outputMsg",
"=",
"\"\"",
"remoteFileName_",
"=",
"\"... | Sends file from local drive to current directory on FTP server in binary mode.
Returns server output.
Parameters:
- localFileName - file name or path to a file on a local drive.
- remoteFileName (optional) - a name or path containing name under which file should be saved.
- connI... | [
"Sends",
"file",
"from",
"local",
"drive",
"to",
"current",
"directory",
"on",
"FTP",
"server",
"in",
"binary",
"mode",
".",
"Returns",
"server",
"output",
".",
"Parameters",
":",
"-",
"localFileName",
"-",
"file",
"name",
"or",
"path",
"to",
"a",
"file",
... | python | train | 44.578947 |
bitcraft/pyscroll | pyscroll/isometric.py | https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/isometric.py#L86-L127 | def center(self, coords):
""" center the map on a "map pixel"
"""
x, y = [round(i, 0) for i in coords]
self.view_rect.center = x, y
tw, th = self.data.tile_size
left, ox = divmod(x, tw)
top, oy = divmod(y, th)
vec = int(ox / 2), int(oy)
iso = v... | [
"def",
"center",
"(",
"self",
",",
"coords",
")",
":",
"x",
",",
"y",
"=",
"[",
"round",
"(",
"i",
",",
"0",
")",
"for",
"i",
"in",
"coords",
"]",
"self",
".",
"view_rect",
".",
"center",
"=",
"x",
",",
"y",
"tw",
",",
"th",
"=",
"self",
".... | center the map on a "map pixel" | [
"center",
"the",
"map",
"on",
"a",
"map",
"pixel"
] | python | train | 32.833333 |
spacetelescope/stsci.tools | lib/stsci/tools/minmatch.py | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L67-L80 | def _mmInit(self):
"""Create the minimum match dictionary of keys"""
# cache references to speed up loop a bit
mmkeys = {}
mmkeysGet = mmkeys.setdefault
minkeylength = self.minkeylength
for key in self.data.keys():
# add abbreviations as short as minkeylength
... | [
"def",
"_mmInit",
"(",
"self",
")",
":",
"# cache references to speed up loop a bit",
"mmkeys",
"=",
"{",
"}",
"mmkeysGet",
"=",
"mmkeys",
".",
"setdefault",
"minkeylength",
"=",
"self",
".",
"minkeylength",
"for",
"key",
"in",
"self",
".",
"data",
".",
"keys"... | Create the minimum match dictionary of keys | [
"Create",
"the",
"minimum",
"match",
"dictionary",
"of",
"keys"
] | python | train | 40.5 |
smarie/python-parsyfiles | parsyfiles/plugins_optional/support_for_attrs.py | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/plugins_optional/support_for_attrs.py#L58-L82 | def get_attrs_declarations(item_type):
"""
Helper method to return a dictionary of tuples. Each key is attr_name, and value is (attr_type, attr_is_optional)
:param item_type:
:return:
"""
# this will raise an error if the type is not an attr-created type
attribs = fields(item_type)
re... | [
"def",
"get_attrs_declarations",
"(",
"item_type",
")",
":",
"# this will raise an error if the type is not an attr-created type",
"attribs",
"=",
"fields",
"(",
"item_type",
")",
"res",
"=",
"dict",
"(",
")",
"for",
"attr",
"in",
"attribs",
":",
"attr_name",
"=",
"... | Helper method to return a dictionary of tuples. Each key is attr_name, and value is (attr_type, attr_is_optional)
:param item_type:
:return: | [
"Helper",
"method",
"to",
"return",
"a",
"dictionary",
"of",
"tuples",
".",
"Each",
"key",
"is",
"attr_name",
"and",
"value",
"is",
"(",
"attr_type",
"attr_is_optional",
")"
] | python | train | 25.48 |
dagster-io/dagster | examples/toys/log_spew.py | https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/examples/toys/log_spew.py#L14-L60 | def nonce_solid(name, n_inputs, n_outputs):
"""Creates a solid with the given number of (meaningless) inputs and outputs.
Config controls the behavior of the nonce solid."""
@solid(
name=name,
inputs=[
InputDefinition(name='input_{}'.format(i)) for i in range(n_inputs)
... | [
"def",
"nonce_solid",
"(",
"name",
",",
"n_inputs",
",",
"n_outputs",
")",
":",
"@",
"solid",
"(",
"name",
"=",
"name",
",",
"inputs",
"=",
"[",
"InputDefinition",
"(",
"name",
"=",
"'input_{}'",
".",
"format",
"(",
"i",
")",
")",
"for",
"i",
"in",
... | Creates a solid with the given number of (meaningless) inputs and outputs.
Config controls the behavior of the nonce solid. | [
"Creates",
"a",
"solid",
"with",
"the",
"given",
"number",
"of",
"(",
"meaningless",
")",
"inputs",
"and",
"outputs",
"."
] | python | test | 31.765957 |
log2timeline/dfvfs | dfvfs/vfs/apfs_file_entry.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/apfs_file_entry.py#L124-L149 | def _GetStat(self):
"""Retrieves information about the file entry.
Returns:
VFSStat: a stat object.
"""
stat_object = super(APFSFileEntry, self)._GetStat()
# File data stat information.
stat_object.size = self._fsapfs_file_entry.size
# Ownership and permissions stat information.
... | [
"def",
"_GetStat",
"(",
"self",
")",
":",
"stat_object",
"=",
"super",
"(",
"APFSFileEntry",
",",
"self",
")",
".",
"_GetStat",
"(",
")",
"# File data stat information.",
"stat_object",
".",
"size",
"=",
"self",
".",
"_fsapfs_file_entry",
".",
"size",
"# Owner... | Retrieves information about the file entry.
Returns:
VFSStat: a stat object. | [
"Retrieves",
"information",
"about",
"the",
"file",
"entry",
"."
] | python | train | 28.653846 |
GPflow/GPflow | gpflow/expectations.py | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L282-L316 | def _expectation(p, mean, none, kern, feat, nghp=None):
"""
Compute the expectation:
expectation[n] = <x_n K_{x_n, Z}>_p(x_n)
- K_{.,.} :: RBF kernel
:return: NxDxM
"""
Xmu, Xcov = p.mu, p.cov
with tf.control_dependencies([tf.assert_equal(
tf.shape(Xmu)[1], tf.constant(... | [
"def",
"_expectation",
"(",
"p",
",",
"mean",
",",
"none",
",",
"kern",
",",
"feat",
",",
"nghp",
"=",
"None",
")",
":",
"Xmu",
",",
"Xcov",
"=",
"p",
".",
"mu",
",",
"p",
".",
"cov",
"with",
"tf",
".",
"control_dependencies",
"(",
"[",
"tf",
"... | Compute the expectation:
expectation[n] = <x_n K_{x_n, Z}>_p(x_n)
- K_{.,.} :: RBF kernel
:return: NxDxM | [
"Compute",
"the",
"expectation",
":",
"expectation",
"[",
"n",
"]",
"=",
"<x_n",
"K_",
"{",
"x_n",
"Z",
"}",
">",
"_p",
"(",
"x_n",
")",
"-",
"K_",
"{",
".",
".",
"}",
"::",
"RBF",
"kernel"
] | python | train | 44.057143 |
cloudera/cm_api | python/src/cm_api/endpoints/hosts.py | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/hosts.py#L126-L159 | def get_metrics(self, from_time=None, to_time=None, metrics=None,
ifs=[], storageIds=[], view=None):
"""
This endpoint is not supported as of v6. Use the timeseries API
instead. To get all metrics for a host with the timeseries API use
the query:
'select * where hostId = $HOST_ID'.
To ge... | [
"def",
"get_metrics",
"(",
"self",
",",
"from_time",
"=",
"None",
",",
"to_time",
"=",
"None",
",",
"metrics",
"=",
"None",
",",
"ifs",
"=",
"[",
"]",
",",
"storageIds",
"=",
"[",
"]",
",",
"view",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
... | This endpoint is not supported as of v6. Use the timeseries API
instead. To get all metrics for a host with the timeseries API use
the query:
'select * where hostId = $HOST_ID'.
To get specific metrics for a host use a comma-separated list of
the metric names as follows:
'select $METRIC_NAME1... | [
"This",
"endpoint",
"is",
"not",
"supported",
"as",
"of",
"v6",
".",
"Use",
"the",
"timeseries",
"API",
"instead",
".",
"To",
"get",
"all",
"metrics",
"for",
"a",
"host",
"with",
"the",
"timeseries",
"API",
"use",
"the",
"query",
":"
] | python | train | 40.176471 |
pypa/pipenv | pipenv/patched/notpip/_internal/wheel.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/wheel.py#L263-L296 | def get_csv_rows_for_installed(
old_csv_rows, # type: Iterable[List[str]]
installed, # type: Dict[str, str]
changed, # type: set
generated, # type: List[str]
lib_dir, # type: str
):
# type: (...) -> List[InstalledCSVRow]
"""
:param installed: A map from archive RECORD path to instal... | [
"def",
"get_csv_rows_for_installed",
"(",
"old_csv_rows",
",",
"# type: Iterable[List[str]]",
"installed",
",",
"# type: Dict[str, str]",
"changed",
",",
"# type: set",
"generated",
",",
"# type: List[str]",
"lib_dir",
",",
"# type: str",
")",
":",
"# type: (...) -> List[Inst... | :param installed: A map from archive RECORD path to installation RECORD
path. | [
":",
"param",
"installed",
":",
"A",
"map",
"from",
"archive",
"RECORD",
"path",
"to",
"installation",
"RECORD",
"path",
"."
] | python | train | 33.705882 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/parallel/util.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/util.py#L207-L220 | def disambiguate_url(url, location=None):
"""turn multi-ip interfaces '0.0.0.0' and '*' into connectable
ones, based on the location (default interpretation is localhost).
This is for zeromq urls, such as tcp://*:10101."""
try:
proto,ip,port = split_url(url)
except AssertionError:
... | [
"def",
"disambiguate_url",
"(",
"url",
",",
"location",
"=",
"None",
")",
":",
"try",
":",
"proto",
",",
"ip",
",",
"port",
"=",
"split_url",
"(",
"url",
")",
"except",
"AssertionError",
":",
"# probably not tcp url; could be ipc, etc.",
"return",
"url",
"ip",... | turn multi-ip interfaces '0.0.0.0' and '*' into connectable
ones, based on the location (default interpretation is localhost).
This is for zeromq urls, such as tcp://*:10101. | [
"turn",
"multi",
"-",
"ip",
"interfaces",
"0",
".",
"0",
".",
"0",
".",
"0",
"and",
"*",
"into",
"connectable",
"ones",
"based",
"on",
"the",
"location",
"(",
"default",
"interpretation",
"is",
"localhost",
")",
".",
"This",
"is",
"for",
"zeromq",
"url... | python | test | 33.357143 |
apache/incubator-mxnet | example/rcnn/symdata/image.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/image.py#L60-L76 | def resize(im, short, max_size):
"""
only resize input image to target size and return scale
:param im: BGR image input by opencv
:param short: one dimensional size (the short side)
:param max_size: one dimensional max size (the long side)
:return: resized image (NDArray) and scale (float)
"... | [
"def",
"resize",
"(",
"im",
",",
"short",
",",
"max_size",
")",
":",
"im_shape",
"=",
"im",
".",
"shape",
"im_size_min",
"=",
"np",
".",
"min",
"(",
"im_shape",
"[",
"0",
":",
"2",
"]",
")",
"im_size_max",
"=",
"np",
".",
"max",
"(",
"im_shape",
... | only resize input image to target size and return scale
:param im: BGR image input by opencv
:param short: one dimensional size (the short side)
:param max_size: one dimensional max size (the long side)
:return: resized image (NDArray) and scale (float) | [
"only",
"resize",
"input",
"image",
"to",
"target",
"size",
"and",
"return",
"scale",
":",
"param",
"im",
":",
"BGR",
"image",
"input",
"by",
"opencv",
":",
"param",
"short",
":",
"one",
"dimensional",
"size",
"(",
"the",
"short",
"side",
")",
":",
"pa... | python | train | 43.647059 |
lucuma/Clay | clay/manage.py | https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/manage.py#L44-L49 | def run(host=DEFAULT_HOST, port=DEFAULT_PORT, path='.'):
"""Run the development server
"""
path = abspath(path)
c = Clay(path)
c.run(host=host, port=port) | [
"def",
"run",
"(",
"host",
"=",
"DEFAULT_HOST",
",",
"port",
"=",
"DEFAULT_PORT",
",",
"path",
"=",
"'.'",
")",
":",
"path",
"=",
"abspath",
"(",
"path",
")",
"c",
"=",
"Clay",
"(",
"path",
")",
"c",
".",
"run",
"(",
"host",
"=",
"host",
",",
"... | Run the development server | [
"Run",
"the",
"development",
"server"
] | python | train | 28.166667 |
Diaoul/pyjulius | pyjulius/models.py | https://github.com/Diaoul/pyjulius/blob/48f2752ff4e0f3bd7b578754b1c583cabdc24b09/pyjulius/models.py#L86-L95 | def from_whypo(cls, xml, encoding='utf-8'):
"""Constructor from xml element *WHYPO*
:param xml.etree.ElementTree xml: the xml *WHYPO* element
:param string encoding: encoding of the xml
"""
word = unicode(xml.get('WORD'), encoding)
confidence = float(xml.get('CM'))
... | [
"def",
"from_whypo",
"(",
"cls",
",",
"xml",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"word",
"=",
"unicode",
"(",
"xml",
".",
"get",
"(",
"'WORD'",
")",
",",
"encoding",
")",
"confidence",
"=",
"float",
"(",
"xml",
".",
"get",
"(",
"'CM'",
")",
... | Constructor from xml element *WHYPO*
:param xml.etree.ElementTree xml: the xml *WHYPO* element
:param string encoding: encoding of the xml | [
"Constructor",
"from",
"xml",
"element",
"*",
"WHYPO",
"*"
] | python | valid | 34.3 |
marshmallow-code/marshmallow | src/marshmallow/utils.py | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L242-L255 | def from_iso_time(timestring, use_dateutil=True):
"""Parse an ISO8601-formatted datetime string and return a datetime.time
object.
"""
if not _iso8601_time_re.match(timestring):
raise ValueError('Not a valid ISO8601-formatted time string')
if dateutil_available and use_dateutil:
retu... | [
"def",
"from_iso_time",
"(",
"timestring",
",",
"use_dateutil",
"=",
"True",
")",
":",
"if",
"not",
"_iso8601_time_re",
".",
"match",
"(",
"timestring",
")",
":",
"raise",
"ValueError",
"(",
"'Not a valid ISO8601-formatted time string'",
")",
"if",
"dateutil_availab... | Parse an ISO8601-formatted datetime string and return a datetime.time
object. | [
"Parse",
"an",
"ISO8601",
"-",
"formatted",
"datetime",
"string",
"and",
"return",
"a",
"datetime",
".",
"time",
"object",
"."
] | python | train | 38.857143 |
pavlin-policar/openTSNE | openTSNE/affinity.py | https://github.com/pavlin-policar/openTSNE/blob/28513a0d669f2f20e7b971c0c6373dc375f72771/openTSNE/affinity.py#L284-L366 | def joint_probabilities_nn(
neighbors,
distances,
perplexities,
symmetrize=True,
normalization="pair-wise",
n_reference_samples=None,
n_jobs=1,
):
"""Compute the conditional probability matrix P_{j|i}.
This method computes an approximation to P using the nearest neighbors.
Para... | [
"def",
"joint_probabilities_nn",
"(",
"neighbors",
",",
"distances",
",",
"perplexities",
",",
"symmetrize",
"=",
"True",
",",
"normalization",
"=",
"\"pair-wise\"",
",",
"n_reference_samples",
"=",
"None",
",",
"n_jobs",
"=",
"1",
",",
")",
":",
"assert",
"no... | Compute the conditional probability matrix P_{j|i}.
This method computes an approximation to P using the nearest neighbors.
Parameters
----------
neighbors: np.ndarray
A `n_samples * k_neighbors` matrix containing the indices to each
points" nearest neighbors in descending order.
d... | [
"Compute",
"the",
"conditional",
"probability",
"matrix",
"P_",
"{",
"j|i",
"}",
"."
] | python | train | 33.638554 |
Brazelton-Lab/bio_utils | bio_utils/iterators/sam.py | https://github.com/Brazelton-Lab/bio_utils/blob/5a7ddf13ee0bf4baaaeb6b2b99e01bf74aa132b7/bio_utils/iterators/sam.py#L104-L219 | def sam_iter(handle, start_line=None, headers=False):
"""Iterate over SAM file and return SAM entries
Args:
handle (file): SAM file handle, can be any iterator so long as it
it returns subsequent "lines" of a SAM entry
start_line (str): Next SAM entry, if 'handle' has been partiall... | [
"def",
"sam_iter",
"(",
"handle",
",",
"start_line",
"=",
"None",
",",
"headers",
"=",
"False",
")",
":",
"# Speed tricks: reduces function calls",
"split",
"=",
"str",
".",
"split",
"strip",
"=",
"str",
".",
"strip",
"next_line",
"=",
"next",
"if",
"start_l... | Iterate over SAM file and return SAM entries
Args:
handle (file): SAM file handle, can be any iterator so long as it
it returns subsequent "lines" of a SAM entry
start_line (str): Next SAM entry, if 'handle' has been partially read
and you want to start iterating at the nex... | [
"Iterate",
"over",
"SAM",
"file",
"and",
"return",
"SAM",
"entries"
] | python | train | 40.758621 |
batiste/django-page-cms | pages/phttp.py | https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/phttp.py#L8-L23 | def get_request_mock():
"""Build a ``request`` mock up for tests"""
from django.test.client import RequestFactory
from django.core.handlers.base import BaseHandler
factory = RequestFactory()
request = factory.get('/')
class FakeUser():
is_authenticated = False
is_staff = Fa... | [
"def",
"get_request_mock",
"(",
")",
":",
"from",
"django",
".",
"test",
".",
"client",
"import",
"RequestFactory",
"from",
"django",
".",
"core",
".",
"handlers",
".",
"base",
"import",
"BaseHandler",
"factory",
"=",
"RequestFactory",
"(",
")",
"request",
"... | Build a ``request`` mock up for tests | [
"Build",
"a",
"request",
"mock",
"up",
"for",
"tests"
] | python | train | 24 |
openvax/pyensembl | pyensembl/transcript.py | https://github.com/openvax/pyensembl/blob/4b995fb72e848206d6fbf11950cf30964cd9b3aa/pyensembl/transcript.py#L433-L452 | def coding_sequence(self):
"""
cDNA coding sequence (from start codon to stop codon, without
any introns)
"""
if self.sequence is None:
return None
start = self.first_start_codon_spliced_offset
end = self.last_stop_codon_spliced_offset
# If s... | [
"def",
"coding_sequence",
"(",
"self",
")",
":",
"if",
"self",
".",
"sequence",
"is",
"None",
":",
"return",
"None",
"start",
"=",
"self",
".",
"first_start_codon_spliced_offset",
"end",
"=",
"self",
".",
"last_stop_codon_spliced_offset",
"# If start codon is the at... | cDNA coding sequence (from start codon to stop codon, without
any introns) | [
"cDNA",
"coding",
"sequence",
"(",
"from",
"start",
"codon",
"to",
"stop",
"codon",
"without",
"any",
"introns",
")"
] | python | train | 34.95 |
Microsoft/nni | examples/tuners/weight_sharing/ga_customer_tuner/customer_tuner.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/tuners/weight_sharing/ga_customer_tuner/customer_tuner.py#L199-L222 | def receive_trial_result(self, parameter_id, parameters, value):
'''
Record an observation of the objective function
parameter_id : int
parameters : dict of parameters
value: final metrics of the trial, including reward
'''
logger.debug('acquiring lock for param {... | [
"def",
"receive_trial_result",
"(",
"self",
",",
"parameter_id",
",",
"parameters",
",",
"value",
")",
":",
"logger",
".",
"debug",
"(",
"'acquiring lock for param {}'",
".",
"format",
"(",
"parameter_id",
")",
")",
"self",
".",
"thread_lock",
".",
"acquire",
... | Record an observation of the objective function
parameter_id : int
parameters : dict of parameters
value: final metrics of the trial, including reward | [
"Record",
"an",
"observation",
"of",
"the",
"objective",
"function",
"parameter_id",
":",
"int",
"parameters",
":",
"dict",
"of",
"parameters",
"value",
":",
"final",
"metrics",
"of",
"the",
"trial",
"including",
"reward"
] | python | train | 41.041667 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/zmq/eventloops.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/zmq/eventloops.py#L209-L223 | def enable_gui(gui, kernel=None):
"""Enable integration with a given GUI"""
if gui not in loop_map:
raise ValueError("GUI %r not supported" % gui)
if kernel is None:
if Application.initialized():
kernel = getattr(Application.instance(), 'kernel', None)
if kernel is None:
... | [
"def",
"enable_gui",
"(",
"gui",
",",
"kernel",
"=",
"None",
")",
":",
"if",
"gui",
"not",
"in",
"loop_map",
":",
"raise",
"ValueError",
"(",
"\"GUI %r not supported\"",
"%",
"gui",
")",
"if",
"kernel",
"is",
"None",
":",
"if",
"Application",
".",
"initi... | Enable integration with a given GUI | [
"Enable",
"integration",
"with",
"a",
"given",
"GUI"
] | python | test | 43.8 |
eqcorrscan/EQcorrscan | eqcorrscan/utils/synth_seis.py | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/synth_seis.py#L101-L137 | def SVD_sim(sp, lowcut, highcut, samp_rate,
amp_range=np.arange(-10, 10, 0.01)):
"""
Generate basis vectors of a set of simulated seismograms.
Inputs should have a range of S-P amplitude ratios, in theory to simulate \
a range of focal mechanisms.
:type sp: int
:param sp: S-P time ... | [
"def",
"SVD_sim",
"(",
"sp",
",",
"lowcut",
",",
"highcut",
",",
"samp_rate",
",",
"amp_range",
"=",
"np",
".",
"arange",
"(",
"-",
"10",
",",
"10",
",",
"0.01",
")",
")",
":",
"# Convert SP to samples",
"sp",
"=",
"int",
"(",
"sp",
"*",
"samp_rate",... | Generate basis vectors of a set of simulated seismograms.
Inputs should have a range of S-P amplitude ratios, in theory to simulate \
a range of focal mechanisms.
:type sp: int
:param sp: S-P time in seconds - will be converted to samples according \
to samp_rate.
:type lowcut: float
:... | [
"Generate",
"basis",
"vectors",
"of",
"a",
"set",
"of",
"simulated",
"seismograms",
"."
] | python | train | 36.945946 |
nitipit/appkit | appkit/api/v0_2_4/app.py | https://github.com/nitipit/appkit/blob/08eeaf45a9ca884bf5fe105d47a81269d44b1412/appkit/api/v0_2_4/app.py#L222-L243 | def _init_ui(self):
"""Initial the first UI page.
- load html from '/' endpoint
- if <title> is defined, use as windows title
"""
(content, mimetype) = make_response(self._url_map_to_function('/'))
try:
beautifulsoup = BeautifulSoup(content)
self.w... | [
"def",
"_init_ui",
"(",
"self",
")",
":",
"(",
"content",
",",
"mimetype",
")",
"=",
"make_response",
"(",
"self",
".",
"_url_map_to_function",
"(",
"'/'",
")",
")",
"try",
":",
"beautifulsoup",
"=",
"BeautifulSoup",
"(",
"content",
")",
"self",
".",
"wi... | Initial the first UI page.
- load html from '/' endpoint
- if <title> is defined, use as windows title | [
"Initial",
"the",
"first",
"UI",
"page",
".",
"-",
"load",
"html",
"from",
"/",
"endpoint",
"-",
"if",
"<title",
">",
"is",
"defined",
"use",
"as",
"windows",
"title"
] | python | train | 30.909091 |
ionelmc/python-cogen | examples/static-serve.py | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/static-serve.py#L56-L74 | def generate_xhtml(path, dirs, files):
"""Return a XHTML document listing the directories and files."""
# Prepare the path to display.
if path != '/':
dirs.insert(0, '..')
if not path.endswith('/'):
path += '/'
def itemize(item):
return '<a href="%s">%s</a>' % (item... | [
"def",
"generate_xhtml",
"(",
"path",
",",
"dirs",
",",
"files",
")",
":",
"# Prepare the path to display.\r",
"if",
"path",
"!=",
"'/'",
":",
"dirs",
".",
"insert",
"(",
"0",
",",
"'..'",
")",
"if",
"not",
"path",
".",
"endswith",
"(",
"'/'",
")",
":"... | Return a XHTML document listing the directories and files. | [
"Return",
"a",
"XHTML",
"document",
"listing",
"the",
"directories",
"and",
"files",
"."
] | python | train | 29.789474 |
ihmeuw/vivarium | src/vivarium/config_tree.py | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L425-L445 | def metadata(self, name):
"""Return value and metadata associated with the named value
Parameters
----------
name : str
name to retrieve. If the name contains '.'s it will be retrieved recursively
Raises
------
KeyError
if name is not def... | [
"def",
"metadata",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_children",
":",
"return",
"self",
".",
"_children",
"[",
"name",
"]",
".",
"metadata",
"(",
")",
"else",
":",
"head",
",",
"_",
",",
"tail",
"=",
"name",
".... | Return value and metadata associated with the named value
Parameters
----------
name : str
name to retrieve. If the name contains '.'s it will be retrieved recursively
Raises
------
KeyError
if name is not defined in the ConfigTree | [
"Return",
"value",
"and",
"metadata",
"associated",
"with",
"the",
"named",
"value"
] | python | train | 30.428571 |
odlgroup/odl | odl/operator/oputils.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/operator/oputils.py#L382-L429 | def as_proximal_lang_operator(op, norm_bound=None):
"""Wrap ``op`` as a ``proximal.BlackBox``.
This is intended to be used with the `ProxImaL language solvers.
<https://github.com/comp-imaging/proximal>`_
For documentation on the proximal language (ProxImaL) see [Hei+2016].
Parameters
-------... | [
"def",
"as_proximal_lang_operator",
"(",
"op",
",",
"norm_bound",
"=",
"None",
")",
":",
"# TODO: use out parameter once \"as editable array\" is added",
"def",
"forward",
"(",
"inp",
",",
"out",
")",
":",
"out",
"[",
":",
"]",
"=",
"op",
"(",
"inp",
")",
".",... | Wrap ``op`` as a ``proximal.BlackBox``.
This is intended to be used with the `ProxImaL language solvers.
<https://github.com/comp-imaging/proximal>`_
For documentation on the proximal language (ProxImaL) see [Hei+2016].
Parameters
----------
op : `Operator`
Linear operator to be wrapp... | [
"Wrap",
"op",
"as",
"a",
"proximal",
".",
"BlackBox",
"."
] | python | train | 35.291667 |
apache/incubator-mxnet | example/ssd/symbol/symbol_factory.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/symbol_factory.py#L22-L101 | def get_config(network, data_shape, **kwargs):
"""Configuration factory for various networks
Parameters
----------
network : str
base network name, such as vgg_reduced, inceptionv3, resnet...
data_shape : int
input data dimension
kwargs : dict
extra arguments
"""
... | [
"def",
"get_config",
"(",
"network",
",",
"data_shape",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"network",
"==",
"'vgg16_reduced'",
":",
"if",
"data_shape",
">=",
"448",
":",
"from_layers",
"=",
"[",
"'relu4_3'",
",",
"'relu7'",
",",
"''",
",",
"''",
... | Configuration factory for various networks
Parameters
----------
network : str
base network name, such as vgg_reduced, inceptionv3, resnet...
data_shape : int
input data dimension
kwargs : dict
extra arguments | [
"Configuration",
"factory",
"for",
"various",
"networks"
] | python | train | 44.85 |
prompt-toolkit/ptpython | ptpython/key_bindings.py | https://github.com/prompt-toolkit/ptpython/blob/b1bba26a491324cd65e0ef46c7b818c4b88fd993/ptpython/key_bindings.py#L34-L175 | def load_python_bindings(python_input):
"""
Custom key bindings.
"""
bindings = KeyBindings()
sidebar_visible = Condition(lambda: python_input.show_sidebar)
handle = bindings.add
@handle('c-l')
def _(event):
"""
Clear whole screen and render again -- also when the sideb... | [
"def",
"load_python_bindings",
"(",
"python_input",
")",
":",
"bindings",
"=",
"KeyBindings",
"(",
")",
"sidebar_visible",
"=",
"Condition",
"(",
"lambda",
":",
"python_input",
".",
"show_sidebar",
")",
"handle",
"=",
"bindings",
".",
"add",
"@",
"handle",
"("... | Custom key bindings. | [
"Custom",
"key",
"bindings",
"."
] | python | train | 30.598592 |
piotr-rusin/spam-lists | spam_lists/structures.py | https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/structures.py#L190-L216 | def create_host(factories, value):
"""Use the factories to create a host object.
:param factories: a list of functions that return host objects
(Hostname, IPv4Address, IPv6Address) for valid arguments
:param value: a value to be passed as argument to factories
:returns: an object representing the v... | [
"def",
"create_host",
"(",
"factories",
",",
"value",
")",
":",
"data",
"=",
"[",
"value",
"]",
"for",
"func",
"in",
"factories",
":",
"try",
":",
"return",
"func",
"(",
"value",
")",
"except",
"InvalidHostError",
"as",
"ex",
":",
"data",
".",
"append"... | Use the factories to create a host object.
:param factories: a list of functions that return host objects
(Hostname, IPv4Address, IPv6Address) for valid arguments
:param value: a value to be passed as argument to factories
:returns: an object representing the value, created by one of
the factories.... | [
"Use",
"the",
"factories",
"to",
"create",
"a",
"host",
"object",
"."
] | python | train | 33.592593 |
mjirik/io3d | io3d/dcmreaddata.py | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmreaddata.py#L767-L815 | def get_sorted_series_files(self, startpath="", series_number=None, return_files_with_info=False,
sort_keys="SliceLocation", return_files=True, remove_doubled_slice_locations=True):
"""
Function returns sorted list of dicom files. File paths are organized
by Serie... | [
"def",
"get_sorted_series_files",
"(",
"self",
",",
"startpath",
"=",
"\"\"",
",",
"series_number",
"=",
"None",
",",
"return_files_with_info",
"=",
"False",
",",
"sort_keys",
"=",
"\"SliceLocation\"",
",",
"return_files",
"=",
"True",
",",
"remove_doubled_slice_loc... | Function returns sorted list of dicom files. File paths are organized
by SeriesUID, StudyUID and FrameUID
:param startpath: path prefix. E.g. "~/data"
:param series_number: ID of series used for filtering the data
:param return_files_with_info: return more complex information about sor... | [
"Function",
"returns",
"sorted",
"list",
"of",
"dicom",
"files",
".",
"File",
"paths",
"are",
"organized",
"by",
"SeriesUID",
"StudyUID",
"and",
"FrameUID"
] | python | train | 35.632653 |
LonamiWebs/Telethon | telethon/tl/custom/button.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/button.py#L99-L119 | def text(cls, text, *, resize=None, single_use=None, selective=None):
"""
Creates a new button with the given text.
Args:
resize (`bool`):
If present, the entire keyboard will be reconfigured to
be resized and be smaller if there are not many buttons.... | [
"def",
"text",
"(",
"cls",
",",
"text",
",",
"*",
",",
"resize",
"=",
"None",
",",
"single_use",
"=",
"None",
",",
"selective",
"=",
"None",
")",
":",
"return",
"cls",
"(",
"types",
".",
"KeyboardButton",
"(",
"text",
")",
",",
"resize",
"=",
"resi... | Creates a new button with the given text.
Args:
resize (`bool`):
If present, the entire keyboard will be reconfigured to
be resized and be smaller if there are not many buttons.
single_use (`bool`):
If present, the entire keyboard will be... | [
"Creates",
"a",
"new",
"button",
"with",
"the",
"given",
"text",
"."
] | python | train | 44.619048 |
tanghaibao/jcvi | jcvi/annotation/qc.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/annotation/qc.py#L34-L80 | def uniq(args):
"""
%prog uniq gffile cdsfasta
Remove overlapping gene models. Similar to formats.gff.uniq(), overlapping
'piles' are processed, one by one.
Here, we use a different algorithm, that retains the best non-overlapping
subset witin each pile, rather than single best model. Scoring ... | [
"def",
"uniq",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"uniq",
".",
"__doc__",
")",
"p",
".",
"set_outfile",
"(",
")",
"opts",
",",
"args",
"=",
"p",
".",
"parse_args",
"(",
"args",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
"... | %prog uniq gffile cdsfasta
Remove overlapping gene models. Similar to formats.gff.uniq(), overlapping
'piles' are processed, one by one.
Here, we use a different algorithm, that retains the best non-overlapping
subset witin each pile, rather than single best model. Scoring function is
also differe... | [
"%prog",
"uniq",
"gffile",
"cdsfasta"
] | python | train | 30.531915 |
lago-project/lago | lago/export.py | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/export.py#L331-L345 | def export(self):
"""
Run the export process
Returns:
(list of str): The path of the exported disks.
"""
if self._with_threads:
utils.invoke_different_funcs_in_parallel(
*map(lambda mgr: mgr.export, self._get_export_mgr())
)
... | [
"def",
"export",
"(",
"self",
")",
":",
"if",
"self",
".",
"_with_threads",
":",
"utils",
".",
"invoke_different_funcs_in_parallel",
"(",
"*",
"map",
"(",
"lambda",
"mgr",
":",
"mgr",
".",
"export",
",",
"self",
".",
"_get_export_mgr",
"(",
")",
")",
")"... | Run the export process
Returns:
(list of str): The path of the exported disks. | [
"Run",
"the",
"export",
"process",
"Returns",
":",
"(",
"list",
"of",
"str",
")",
":",
"The",
"path",
"of",
"the",
"exported",
"disks",
"."
] | python | train | 29.066667 |
Clinical-Genomics/scout | scout/commands/export/hpo.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/commands/export/hpo.py#L10-L25 | def hpo_genes(context, hpo_term):
"""Export a list of genes based on hpo terms"""
LOG.info("Running scout export hpo_genes")
adapter = context.obj['adapter']
header = ["#Gene_id\tCount"]
if not hpo_term:
LOG.warning("Please use at least one hpo term")
context.abort()
for l... | [
"def",
"hpo_genes",
"(",
"context",
",",
"hpo_term",
")",
":",
"LOG",
".",
"info",
"(",
"\"Running scout export hpo_genes\"",
")",
"adapter",
"=",
"context",
".",
"obj",
"[",
"'adapter'",
"]",
"header",
"=",
"[",
"\"#Gene_id\\tCount\"",
"]",
"if",
"not",
"hp... | Export a list of genes based on hpo terms | [
"Export",
"a",
"list",
"of",
"genes",
"based",
"on",
"hpo",
"terms"
] | python | test | 28.75 |
Kortemme-Lab/pull_into_place | pull_into_place/commands/09_compare_best_designs.py | https://github.com/Kortemme-Lab/pull_into_place/blob/247f303100a612cc90cf31c86e4fe5052eb28c8d/pull_into_place/commands/09_compare_best_designs.py#L688-L715 | def report_score_vs_rmsd_funnels(designs, path):
"""
Create a PDF showing the score vs. RMSD funnels for all the reasonable
designs. This method was copied from an old version of this script, and
does not currently work.
"""
from matplotlib.backends.backend_pdf import PdfPages
import matplo... | [
"def",
"report_score_vs_rmsd_funnels",
"(",
"designs",
",",
"path",
")",
":",
"from",
"matplotlib",
".",
"backends",
".",
"backend_pdf",
"import",
"PdfPages",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"print",
"\"Reporting score vs RMSD funnels...\"",
"pdf",... | Create a PDF showing the score vs. RMSD funnels for all the reasonable
designs. This method was copied from an old version of this script, and
does not currently work. | [
"Create",
"a",
"PDF",
"showing",
"the",
"score",
"vs",
".",
"RMSD",
"funnels",
"for",
"all",
"the",
"reasonable",
"designs",
".",
"This",
"method",
"was",
"copied",
"from",
"an",
"old",
"version",
"of",
"this",
"script",
"and",
"does",
"not",
"currently",
... | python | train | 30.464286 |
tnkteja/myhelp | virtualEnvironment/lib/python2.7/site-packages/coverage/execfile.py | https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/execfile.py#L23-L70 | def run_python_module(modulename, args):
"""Run a python module, as though with ``python -m name args...``.
`modulename` is the name of the module, possibly a dot-separated name.
`args` is the argument array to present as sys.argv, including the first
element naming the module being executed.
"""
... | [
"def",
"run_python_module",
"(",
"modulename",
",",
"args",
")",
":",
"openfile",
"=",
"None",
"glo",
",",
"loc",
"=",
"globals",
"(",
")",
",",
"locals",
"(",
")",
"try",
":",
"try",
":",
"# Search for the module - inside its parent package, if any - using",
"#... | Run a python module, as though with ``python -m name args...``.
`modulename` is the name of the module, possibly a dot-separated name.
`args` is the argument array to present as sys.argv, including the first
element naming the module being executed. | [
"Run",
"a",
"python",
"module",
"as",
"though",
"with",
"python",
"-",
"m",
"name",
"args",
"...",
"."
] | python | test | 40.8125 |
lsanomaly/lsanomaly | lsanomaly/__init__.py | https://github.com/lsanomaly/lsanomaly/blob/7680ccbd6eedc14ccdd84d11be56edb6f9fdca2e/lsanomaly/__init__.py#L166-L192 | def predict(self, X):
"""
Assign classes to test data.
Parameters
----------
X : array
Test data, of dimension N times d (rows are examples, columns
are data dimensions)
Returns
-------
y_predicted : array
A vector of ... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"predictions_proba",
"=",
"self",
".",
"predict_proba",
"(",
"X",
")",
"predictions",
"=",
"[",
"]",
"allclasses",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"classes",
")",
"allclasses",
".",
"append... | Assign classes to test data.
Parameters
----------
X : array
Test data, of dimension N times d (rows are examples, columns
are data dimensions)
Returns
-------
y_predicted : array
A vector of length N containing assigned classes. If n... | [
"Assign",
"classes",
"to",
"test",
"data",
"."
] | python | train | 36.555556 |
UCBerkeleySETI/blimpy | blimpy/calib_utils/stokescal.py | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/calib_utils/stokescal.py#L124-L181 | def apply_Mueller(I,Q,U,V, gain_offsets, phase_offsets, chan_per_coarse, feedtype='l'):
'''
Returns calibrated Stokes parameters for an observation given an array
of differential gains and phase differences.
'''
#Find shape of data arrays and calculate number of coarse channels
shape = I.shape
... | [
"def",
"apply_Mueller",
"(",
"I",
",",
"Q",
",",
"U",
",",
"V",
",",
"gain_offsets",
",",
"phase_offsets",
",",
"chan_per_coarse",
",",
"feedtype",
"=",
"'l'",
")",
":",
"#Find shape of data arrays and calculate number of coarse channels",
"shape",
"=",
"I",
".",
... | Returns calibrated Stokes parameters for an observation given an array
of differential gains and phase differences. | [
"Returns",
"calibrated",
"Stokes",
"parameters",
"for",
"an",
"observation",
"given",
"an",
"array",
"of",
"differential",
"gains",
"and",
"phase",
"differences",
"."
] | python | test | 33.758621 |
trevisanj/a99 | a99/textinterface.py | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/textinterface.py#L168-L202 | def yesno(question, default=None):
"""Asks a yes/no question
Args:
question: string **without** the question mark and without the options.
Example: 'Create links'
default: default option. Accepted values are 'Y', 'YES', 'N', 'NO' or lowercase versions of
these val... | [
"def",
"yesno",
"(",
"question",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"default",
",",
"bool",
")",
":",
"pass",
"else",
":",
"default_",
"=",
"default",
".",
"upper",
"(",
")",
"... | Asks a yes/no question
Args:
question: string **without** the question mark and without the options.
Example: 'Create links'
default: default option. Accepted values are 'Y', 'YES', 'N', 'NO' or lowercase versions of
these valus (this argument is case-insensitive)
... | [
"Asks",
"a",
"yes",
"/",
"no",
"question",
"Args",
":",
"question",
":",
"string",
"**",
"without",
"**",
"the",
"question",
"mark",
"and",
"without",
"the",
"options",
".",
"Example",
":",
"Create",
"links",
"default",
":",
"default",
"option",
".",
"Ac... | python | train | 34.085714 |
lrq3000/pyFileFixity | pyFileFixity/lib/aux_funcs.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/aux_funcs.py#L160-L182 | def copy_any(src, dst, only_missing=False): # pragma: no cover
"""Copy a file or a directory tree, deleting the destination before processing"""
if not only_missing:
remove_if_exist(dst)
if os.path.exists(src):
if os.path.isdir(src):
if not only_missing:
shutil.c... | [
"def",
"copy_any",
"(",
"src",
",",
"dst",
",",
"only_missing",
"=",
"False",
")",
":",
"# pragma: no cover",
"if",
"not",
"only_missing",
":",
"remove_if_exist",
"(",
"dst",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"src",
")",
":",
"if",
"os"... | Copy a file or a directory tree, deleting the destination before processing | [
"Copy",
"a",
"file",
"or",
"a",
"directory",
"tree",
"deleting",
"the",
"destination",
"before",
"processing"
] | python | train | 46.217391 |
iotile/coretools | iotilecore/iotile/core/hw/transport/adapterstream.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/adapterstream.py#L562-L570 | def _clear_queue(to_clear):
"""Clear all items from a queue safely."""
while not to_clear.empty():
try:
to_clear.get(False)
to_clear.task_done()
except queue.Empty:
continue | [
"def",
"_clear_queue",
"(",
"to_clear",
")",
":",
"while",
"not",
"to_clear",
".",
"empty",
"(",
")",
":",
"try",
":",
"to_clear",
".",
"get",
"(",
"False",
")",
"to_clear",
".",
"task_done",
"(",
")",
"except",
"queue",
".",
"Empty",
":",
"continue"
] | Clear all items from a queue safely. | [
"Clear",
"all",
"items",
"from",
"a",
"queue",
"safely",
"."
] | python | train | 25.111111 |
marl/jams | jams/core.py | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/core.py#L155-L218 | def load(path_or_file, validate=True, strict=True, fmt='auto'):
r"""Load a JAMS Annotation from a file.
Parameters
----------
path_or_file : str or file-like
Path to the JAMS file to load
OR
An open file handle to load from.
validate : bool
Attempt to validate the ... | [
"def",
"load",
"(",
"path_or_file",
",",
"validate",
"=",
"True",
",",
"strict",
"=",
"True",
",",
"fmt",
"=",
"'auto'",
")",
":",
"with",
"_open",
"(",
"path_or_file",
",",
"mode",
"=",
"'r'",
",",
"fmt",
"=",
"fmt",
")",
"as",
"fdesc",
":",
"jam"... | r"""Load a JAMS Annotation from a file.
Parameters
----------
path_or_file : str or file-like
Path to the JAMS file to load
OR
An open file handle to load from.
validate : bool
Attempt to validate the JAMS object
strict : bool
if `validate == True`, enforc... | [
"r",
"Load",
"a",
"JAMS",
"Annotation",
"from",
"a",
"file",
"."
] | python | valid | 21.578125 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/slugs.py#L7883-L7899 | def slugs_navigation_encode(self, u_m, phi_c, theta_c, psiDot_c, ay_body, totalDist, dist2Go, fromWP, toWP, h_c):
'''
Data used in the navigation algorithm.
u_m : Measured Airspeed prior to the nav filter in m/s (float)
phi_c ... | [
"def",
"slugs_navigation_encode",
"(",
"self",
",",
"u_m",
",",
"phi_c",
",",
"theta_c",
",",
"psiDot_c",
",",
"ay_body",
",",
"totalDist",
",",
"dist2Go",
",",
"fromWP",
",",
"toWP",
",",
"h_c",
")",
":",
"return",
"MAVLink_slugs_navigation_message",
"(",
"... | Data used in the navigation algorithm.
u_m : Measured Airspeed prior to the nav filter in m/s (float)
phi_c : Commanded Roll (float)
theta_c : Commanded Pitch (float)
psiDot_c : ... | [
"Data",
"used",
"in",
"the",
"navigation",
"algorithm",
"."
] | python | train | 67.411765 |
saltstack/salt | salt/thorium/check.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/check.py#L182-L212 | def ne(name, value):
'''
Only succeed if the value in the given register location is not equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.ne:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... | [
"def",
"ne",
"(",
"name",
",",
"value",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"if",
"name",
"not",
"in",
"__reg__",
":",
"ret",
"[",
"... | Only succeed if the value in the given register location is not equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.ne:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | [
"Only",
"succeed",
"if",
"the",
"value",
"in",
"the",
"given",
"register",
"location",
"is",
"not",
"equal",
"to",
"the",
"given",
"value"
] | python | train | 21.83871 |
admiralobvious/vyper | vyper/vyper.py | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L508-L515 | def in_config(self, key):
"""Check to see if the given key (or an alias) is in the config file.
"""
# if the requested key is an alias, then return the proper key
key = self._real_key(key)
exists = self._config.get(key)
return exists | [
"def",
"in_config",
"(",
"self",
",",
"key",
")",
":",
"# if the requested key is an alias, then return the proper key",
"key",
"=",
"self",
".",
"_real_key",
"(",
"key",
")",
"exists",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"key",
")",
"return",
"exist... | Check to see if the given key (or an alias) is in the config file. | [
"Check",
"to",
"see",
"if",
"the",
"given",
"key",
"(",
"or",
"an",
"alias",
")",
"is",
"in",
"the",
"config",
"file",
"."
] | python | train | 34.375 |
Alignak-monitoring/alignak | alignak/external_command.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L2452-L2466 | def disable_svc_event_handler(self, service):
"""Disable event handlers for a service
Format of the line that triggers function call::
DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
:param service: service to edit
:type service: alignak.objects.service.Service
... | [
"def",
"disable_svc_event_handler",
"(",
"self",
",",
"service",
")",
":",
"if",
"service",
".",
"event_handler_enabled",
":",
"service",
".",
"modified_attributes",
"|=",
"DICT_MODATTR",
"[",
"\"MODATTR_EVENT_HANDLER_ENABLED\"",
"]",
".",
"value",
"service",
".",
"... | Disable event handlers for a service
Format of the line that triggers function call::
DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
:param service: service to edit
:type service: alignak.objects.service.Service
:return: None | [
"Disable",
"event",
"handlers",
"for",
"a",
"service",
"Format",
"of",
"the",
"line",
"that",
"triggers",
"function",
"call",
"::"
] | python | train | 40.466667 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py#L565-L577 | def get_vcs_details_output_vcs_details_principal_switch_wwn(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_vcs_details = ET.Element("get_vcs_details")
config = get_vcs_details
output = ET.SubElement(get_vcs_details, "output")
vcs_det... | [
"def",
"get_vcs_details_output_vcs_details_principal_switch_wwn",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_vcs_details",
"=",
"ET",
".",
"Element",
"(",
"\"get_vcs_details\"",
")",
"config",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 45.769231 |
TissueMAPS/TmClient | src/python/tmclient/api.py | https://github.com/TissueMAPS/TmClient/blob/6fb40622af19142cb5169a64b8c2965993a25ab1/src/python/tmclient/api.py#L1662-L1712 | def download_segmentation_image_file(self, mapobject_type_name,
plate_name, well_name, well_pos_y, well_pos_x, tpoint, zplane, align,
directory):
'''Downloads a segmentation image and writes it to a *PNG* file on disk.
Parameters
----------
mapobject_type_name: s... | [
"def",
"download_segmentation_image_file",
"(",
"self",
",",
"mapobject_type_name",
",",
"plate_name",
",",
"well_name",
",",
"well_pos_y",
",",
"well_pos_x",
",",
"tpoint",
",",
"zplane",
",",
"align",
",",
"directory",
")",
":",
"response",
"=",
"self",
".",
... | Downloads a segmentation image and writes it to a *PNG* file on disk.
Parameters
----------
mapobject_type_name: str
name of the segmented objects
plate_name: str
name of the plate
well_name: str
name of the well in which the image is located
... | [
"Downloads",
"a",
"segmentation",
"image",
"and",
"writes",
"it",
"to",
"a",
"*",
"PNG",
"*",
"file",
"on",
"disk",
"."
] | python | train | 38.156863 |
rcarmo/pngcanvas | pngcanvas.py | https://github.com/rcarmo/pngcanvas/blob/e2eaa0d5ba353005b3b658f6ee453c1956340670/pngcanvas.py#L164-L172 | def blend_rect(self, x0, y0, x1, y1, dx, dy, destination, alpha=0xff):
"""Blend a rectangle onto the image"""
x0, y0, x1, y1 = self.rect_helper(x0, y0, x1, y1)
for x in range(x0, x1 + 1):
for y in range(y0, y1 + 1):
o = self._offset(x, y)
rgba = self.c... | [
"def",
"blend_rect",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"dx",
",",
"dy",
",",
"destination",
",",
"alpha",
"=",
"0xff",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"self",
".",
"rect_helper",
"(",
"x0",
",... | Blend a rectangle onto the image | [
"Blend",
"a",
"rectangle",
"onto",
"the",
"image"
] | python | train | 47.111111 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/identity/identity_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/identity/identity_client.py#L315-L331 | def add_member(self, container_id, member_id):
"""AddMember.
[Preview API]
:param str container_id:
:param str member_id:
:rtype: bool
"""
route_values = {}
if container_id is not None:
route_values['containerId'] = self._serialize.url('contain... | [
"def",
"add_member",
"(",
"self",
",",
"container_id",
",",
"member_id",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"container_id",
"is",
"not",
"None",
":",
"route_values",
"[",
"'containerId'",
"]",
"=",
"self",
".",
"_serialize",
".",
"url",
"(",
... | AddMember.
[Preview API]
:param str container_id:
:param str member_id:
:rtype: bool | [
"AddMember",
".",
"[",
"Preview",
"API",
"]",
":",
"param",
"str",
"container_id",
":",
":",
"param",
"str",
"member_id",
":",
":",
"rtype",
":",
"bool"
] | python | train | 44.117647 |
what-studio/smartformat | smartformat/builtin.py | https://github.com/what-studio/smartformat/blob/5731203cbf29617ab8d42542f9dac03d5e34b217/smartformat/builtin.py#L56-L63 | def get_choice(value):
"""Gets a key to choose a choice from any value."""
if value is None:
return 'null'
for attr in ['__name__', 'name']:
if hasattr(value, attr):
return getattr(value, attr)
return str(value) | [
"def",
"get_choice",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"'null'",
"for",
"attr",
"in",
"[",
"'__name__'",
",",
"'name'",
"]",
":",
"if",
"hasattr",
"(",
"value",
",",
"attr",
")",
":",
"return",
"getattr",
"(",
"value... | Gets a key to choose a choice from any value. | [
"Gets",
"a",
"key",
"to",
"choose",
"a",
"choice",
"from",
"any",
"value",
"."
] | python | train | 31 |
tomasbasham/dominos | dominos/api.py | https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L129-L145 | def add_item_to_basket(self, item, variant=VARIANT.MEDIUM, quantity=1):
'''
Add an item to the current basket.
:param Item item: Item from menu.
:param int variant: Item SKU id. Ignored if the item is a side.
:param int quantity: The quantity of item to be added.
:return... | [
"def",
"add_item_to_basket",
"(",
"self",
",",
"item",
",",
"variant",
"=",
"VARIANT",
".",
"MEDIUM",
",",
"quantity",
"=",
"1",
")",
":",
"item_type",
"=",
"item",
".",
"type",
"if",
"item_type",
"==",
"'Pizza'",
":",
"return",
"self",
".",
"add_pizza_t... | Add an item to the current basket.
:param Item item: Item from menu.
:param int variant: Item SKU id. Ignored if the item is a side.
:param int quantity: The quantity of item to be added.
:return: A response having added an item to the current basket.
:rtype: requests.Response | [
"Add",
"an",
"item",
"to",
"the",
"current",
"basket",
"."
] | python | test | 38.352941 |
boriel/zxbasic | zxbpp.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpp.py#L560-L566 | def p_if_expr_header(p):
""" if_header : IF expr
"""
global ENABLED
IFDEFS.append((ENABLED, p.lineno(1)))
ENABLED = bool(int(p[2])) if p[2].isdigit() else ID_TABLE.defined(p[2]) | [
"def",
"p_if_expr_header",
"(",
"p",
")",
":",
"global",
"ENABLED",
"IFDEFS",
".",
"append",
"(",
"(",
"ENABLED",
",",
"p",
".",
"lineno",
"(",
"1",
")",
")",
")",
"ENABLED",
"=",
"bool",
"(",
"int",
"(",
"p",
"[",
"2",
"]",
")",
")",
"if",
"p"... | if_header : IF expr | [
"if_header",
":",
"IF",
"expr"
] | python | train | 27.428571 |
carpedm20/fbchat | fbchat/_client.py | https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2288-L2305 | def deleteThreads(self, thread_ids):
"""
Deletes threads
:param thread_ids: Thread IDs to delete. See :ref:`intro_threads`
:return: Whether the request was successful
:raises: FBchatException if request failed
"""
thread_ids = require_list(thread_ids)
da... | [
"def",
"deleteThreads",
"(",
"self",
",",
"thread_ids",
")",
":",
"thread_ids",
"=",
"require_list",
"(",
"thread_ids",
")",
"data_unpin",
"=",
"dict",
"(",
")",
"data_delete",
"=",
"dict",
"(",
")",
"for",
"i",
",",
"thread_id",
"in",
"enumerate",
"(",
... | Deletes threads
:param thread_ids: Thread IDs to delete. See :ref:`intro_threads`
:return: Whether the request was successful
:raises: FBchatException if request failed | [
"Deletes",
"threads"
] | python | train | 38.944444 |
adamrehn/ue4cli | ue4cli/UnrealManagerBase.py | https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L180-L187 | def getThirdpartyLibs(self, libs, configuration = 'Development', includePlatformDefaults = True):
"""
Retrieves the ThirdPartyLibraryDetails instance for Unreal-bundled versions of the specified third-party libraries
"""
if includePlatformDefaults == True:
libs = self._defaultThirdpartyLibs() + libs
interr... | [
"def",
"getThirdpartyLibs",
"(",
"self",
",",
"libs",
",",
"configuration",
"=",
"'Development'",
",",
"includePlatformDefaults",
"=",
"True",
")",
":",
"if",
"includePlatformDefaults",
"==",
"True",
":",
"libs",
"=",
"self",
".",
"_defaultThirdpartyLibs",
"(",
... | Retrieves the ThirdPartyLibraryDetails instance for Unreal-bundled versions of the specified third-party libraries | [
"Retrieves",
"the",
"ThirdPartyLibraryDetails",
"instance",
"for",
"Unreal",
"-",
"bundled",
"versions",
"of",
"the",
"specified",
"third",
"-",
"party",
"libraries"
] | python | train | 58.375 |
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#L334-L368 | def update_database(self, server_name, name, new_database_name=None,
service_objective_id=None, edition=None,
max_size_bytes=None):
'''
Updates existing database details.
server_name:
Name of the server to contain the new database.
... | [
"def",
"update_database",
"(",
"self",
",",
"server_name",
",",
"name",
",",
"new_database_name",
"=",
"None",
",",
"service_objective_id",
"=",
"None",
",",
"edition",
"=",
"None",
",",
"max_size_bytes",
"=",
"None",
")",
":",
"_validate_not_none",
"(",
"'ser... | Updates existing database details.
server_name:
Name of the server to contain the new database.
name:
Required. The name for the new database. See Naming Requirements
in Azure SQL Database General Guidelines and Limitations and
Database Identifiers for mo... | [
"Updates",
"existing",
"database",
"details",
"."
] | python | test | 45.371429 |
hactar-is/frink | frink/orm.py | https://github.com/hactar-is/frink/blob/0d2c11daca8ef6d4365e98914bdc0bc65478ae72/frink/orm.py#L320-L344 | def all(self, order_by=None, limit=0):
"""
Fetch all items.
:param limit: How many rows to fetch.
:param order_by: column on which to order the results. \
To change the sort, prepend with < or >.
"""
with rconnect() as conn:
try:
... | [
"def",
"all",
"(",
"self",
",",
"order_by",
"=",
"None",
",",
"limit",
"=",
"0",
")",
":",
"with",
"rconnect",
"(",
")",
"as",
"conn",
":",
"try",
":",
"query",
"=",
"self",
".",
"_base",
"(",
")",
"if",
"order_by",
"is",
"not",
"None",
":",
"q... | Fetch all items.
:param limit: How many rows to fetch.
:param order_by: column on which to order the results. \
To change the sort, prepend with < or >. | [
"Fetch",
"all",
"items",
"."
] | python | train | 30.68 |
AguaClara/aguaclara | aguaclara/core/physchem.py | https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L392-L401 | def head_orifice(Diam, RatioVCOrifice, FlowRate):
"""Return the head of the orifice."""
#Checking input validity
ut.check_range([Diam, ">0", "Diameter"], [FlowRate, ">0", "Flow rate"],
[RatioVCOrifice, "0-1", "VC orifice ratio"])
return ((FlowRate
/ (RatioVCOrifice * area... | [
"def",
"head_orifice",
"(",
"Diam",
",",
"RatioVCOrifice",
",",
"FlowRate",
")",
":",
"#Checking input validity",
"ut",
".",
"check_range",
"(",
"[",
"Diam",
",",
"\">0\"",
",",
"\"Diameter\"",
"]",
",",
"[",
"FlowRate",
",",
"\">0\"",
",",
"\"Flow rate\"",
... | Return the head of the orifice. | [
"Return",
"the",
"head",
"of",
"the",
"orifice",
"."
] | python | train | 40.3 |
hickeroar/LatLon23 | LatLon23/__init__.py | https://github.com/hickeroar/LatLon23/blob/1ff728216ae51055034f4c915fa715446b34549f/LatLon23/__init__.py#L447-L456 | def offset(self, heading_initial, distance, ellipse = 'WGS84'):
'''
Offset a LatLon object by a heading (in degrees) and distance (in km)
to return a new LatLon object
'''
lat1, lon1 = self.lat.decimal_degree, self.lon.decimal_degree
g = pyproj.Geod(ellps = ellipse)
... | [
"def",
"offset",
"(",
"self",
",",
"heading_initial",
",",
"distance",
",",
"ellipse",
"=",
"'WGS84'",
")",
":",
"lat1",
",",
"lon1",
"=",
"self",
".",
"lat",
".",
"decimal_degree",
",",
"self",
".",
"lon",
".",
"decimal_degree",
"g",
"=",
"pyproj",
".... | Offset a LatLon object by a heading (in degrees) and distance (in km)
to return a new LatLon object | [
"Offset",
"a",
"LatLon",
"object",
"by",
"a",
"heading",
"(",
"in",
"degrees",
")",
"and",
"distance",
"(",
"in",
"km",
")",
"to",
"return",
"a",
"new",
"LatLon",
"object"
] | python | train | 51.5 |
resonai/ybt | yabt/buildcontext.py | https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L143-L146 | def generate_all_deps(self, target: Target):
"""Generate all dependencies of `target` (the target nodes)."""
yield from (self.targets[dep_name]
for dep_name in self.generate_dep_names(target)) | [
"def",
"generate_all_deps",
"(",
"self",
",",
"target",
":",
"Target",
")",
":",
"yield",
"from",
"(",
"self",
".",
"targets",
"[",
"dep_name",
"]",
"for",
"dep_name",
"in",
"self",
".",
"generate_dep_names",
"(",
"target",
")",
")"
] | Generate all dependencies of `target` (the target nodes). | [
"Generate",
"all",
"dependencies",
"of",
"target",
"(",
"the",
"target",
"nodes",
")",
"."
] | python | train | 56.25 |
softlayer/softlayer-python | SoftLayer/managers/storage_utils.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/storage_utils.py#L150-L168 | def find_ent_endurance_tier_price(package, tier_level):
"""Find the price in the given package with the specified tier level
:param package: The Enterprise (Endurance) product package
:param tier_level: The endurance tier for which a price is desired
:return: Returns the price for the given tier, or an... | [
"def",
"find_ent_endurance_tier_price",
"(",
"package",
",",
"tier_level",
")",
":",
"for",
"item",
"in",
"package",
"[",
"'items'",
"]",
":",
"for",
"attribute",
"in",
"item",
".",
"get",
"(",
"'attributes'",
",",
"[",
"]",
")",
":",
"if",
"int",
"(",
... | Find the price in the given package with the specified tier level
:param package: The Enterprise (Endurance) product package
:param tier_level: The endurance tier for which a price is desired
:return: Returns the price for the given tier, or an error if not found | [
"Find",
"the",
"price",
"in",
"the",
"given",
"package",
"with",
"the",
"specified",
"tier",
"level"
] | python | train | 39 |
LogicalDash/LiSE | allegedb/allegedb/__init__.py | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/__init__.py#L655-L672 | def is_parent_of(self, parent, child):
"""Return whether ``child`` is a branch descended from ``parent`` at
any remove.
"""
if parent == 'trunk':
return True
if child == 'trunk':
return False
if child not in self._branches:
raise Value... | [
"def",
"is_parent_of",
"(",
"self",
",",
"parent",
",",
"child",
")",
":",
"if",
"parent",
"==",
"'trunk'",
":",
"return",
"True",
"if",
"child",
"==",
"'trunk'",
":",
"return",
"False",
"if",
"child",
"not",
"in",
"self",
".",
"_branches",
":",
"raise... | Return whether ``child`` is a branch descended from ``parent`` at
any remove. | [
"Return",
"whether",
"child",
"is",
"a",
"branch",
"descended",
"from",
"parent",
"at",
"any",
"remove",
"."
] | python | train | 32.277778 |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L4968-L4977 | def getOverlayMouseScale(self, ulOverlayHandle):
"""
Gets the mouse scaling factor that is used for mouse events. The actual texture may be a different size, but this is
typically the size of the underlying UI in pixels.
"""
fn = self.function_table.getOverlayMouseScale
... | [
"def",
"getOverlayMouseScale",
"(",
"self",
",",
"ulOverlayHandle",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getOverlayMouseScale",
"pvecMouseScale",
"=",
"HmdVector2_t",
"(",
")",
"result",
"=",
"fn",
"(",
"ulOverlayHandle",
",",
"byref",
"(",
... | Gets the mouse scaling factor that is used for mouse events. The actual texture may be a different size, but this is
typically the size of the underlying UI in pixels. | [
"Gets",
"the",
"mouse",
"scaling",
"factor",
"that",
"is",
"used",
"for",
"mouse",
"events",
".",
"The",
"actual",
"texture",
"may",
"be",
"a",
"different",
"size",
"but",
"this",
"is",
"typically",
"the",
"size",
"of",
"the",
"underlying",
"UI",
"in",
"... | python | train | 44 |
narwhaljames/restapi-logging-handler | restapi_logging_handler/restapi_logging_handler.py | https://github.com/narwhaljames/restapi-logging-handler/blob/edaedd3e702e68cfd102bc9fbfa4a33e0c002913/restapi_logging_handler/restapi_logging_handler.py#L166-L211 | def _getPayload(self, record):
"""
The data that will be sent to the RESTful API
"""
try:
# top level payload items
d = record.__dict__
pid = d.pop('process', 'nopid')
tid = d.pop('thread', 'notid')
payload = {
... | [
"def",
"_getPayload",
"(",
"self",
",",
"record",
")",
":",
"try",
":",
"# top level payload items",
"d",
"=",
"record",
".",
"__dict__",
"pid",
"=",
"d",
".",
"pop",
"(",
"'process'",
",",
"'nopid'",
")",
"tid",
"=",
"d",
".",
"pop",
"(",
"'thread'",
... | The data that will be sent to the RESTful API | [
"The",
"data",
"that",
"will",
"be",
"sent",
"to",
"the",
"RESTful",
"API"
] | python | train | 29.869565 |
senaite/senaite.core | bika/lims/monkey/zcatalog.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/monkey/zcatalog.py#L24-L64 | def searchResults(self, REQUEST=None, used=None, **kw):
"""Search the catalog
Search terms can be passed in the REQUEST or as keyword
arguments.
The used argument is now deprecated and ignored
"""
if REQUEST and REQUEST.get('getRequestUID') \
and self.id == CATALOG_ANALYSIS_LISTING... | [
"def",
"searchResults",
"(",
"self",
",",
"REQUEST",
"=",
"None",
",",
"used",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"REQUEST",
"and",
"REQUEST",
".",
"get",
"(",
"'getRequestUID'",
")",
"and",
"self",
".",
"id",
"==",
"CATALOG_ANALYSIS_LIS... | Search the catalog
Search terms can be passed in the REQUEST or as keyword
arguments.
The used argument is now deprecated and ignored | [
"Search",
"the",
"catalog"
] | python | train | 38.487805 |
juicer/juicer | juicer/utils/__init__.py | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/utils/__init__.py#L856-L858 | def chunk_list(l, n):
"""Return `n` size lists from a given list `l`"""
return [l[i:i + n] for i in range(0, len(l), n)] | [
"def",
"chunk_list",
"(",
"l",
",",
"n",
")",
":",
"return",
"[",
"l",
"[",
"i",
":",
"i",
"+",
"n",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"l",
")",
",",
"n",
")",
"]"
] | Return `n` size lists from a given list `l` | [
"Return",
"n",
"size",
"lists",
"from",
"a",
"given",
"list",
"l"
] | python | train | 42 |
gitenberg-dev/gitberg | gitenberg/book.py | https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/book.py#L213-L218 | def push(self):
""" create a github repo and push the local repo into it
"""
self.github_repo.create_and_push()
self._repo = self.github_repo.repo
return self._repo | [
"def",
"push",
"(",
"self",
")",
":",
"self",
".",
"github_repo",
".",
"create_and_push",
"(",
")",
"self",
".",
"_repo",
"=",
"self",
".",
"github_repo",
".",
"repo",
"return",
"self",
".",
"_repo"
] | create a github repo and push the local repo into it | [
"create",
"a",
"github",
"repo",
"and",
"push",
"the",
"local",
"repo",
"into",
"it"
] | python | train | 33.166667 |
MacHu-GWU/angora-project | angora/gadget/configuration.py | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/gadget/configuration.py#L253-L263 | def add_section(self, section_name):
"""Add an empty section.
"""
if section_name == "DEFAULT":
raise Exception("'DEFAULT' is reserved section name.")
if section_name in self._sections:
raise Exception(
"Error! %s is already one of the sections" %... | [
"def",
"add_section",
"(",
"self",
",",
"section_name",
")",
":",
"if",
"section_name",
"==",
"\"DEFAULT\"",
":",
"raise",
"Exception",
"(",
"\"'DEFAULT' is reserved section name.\"",
")",
"if",
"section_name",
"in",
"self",
".",
"_sections",
":",
"raise",
"Except... | Add an empty section. | [
"Add",
"an",
"empty",
"section",
"."
] | python | train | 36.636364 |
roanuz/py-cricket | src/pycricket.py | https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L290-L306 | def get_season(self, season_key, card_type="micro_card"):
"""
Calling Season API.
Arg:
season_key: key of the season
card_type: optional, default to micro_card. Accepted values are
micro_card & summary_card
Return:
json data
"""
... | [
"def",
"get_season",
"(",
"self",
",",
"season_key",
",",
"card_type",
"=",
"\"micro_card\"",
")",
":",
"season_url",
"=",
"self",
".",
"api_path",
"+",
"\"season/\"",
"+",
"season_key",
"+",
"\"/\"",
"params",
"=",
"{",
"}",
"params",
"[",
"\"card_type\"",
... | Calling Season API.
Arg:
season_key: key of the season
card_type: optional, default to micro_card. Accepted values are
micro_card & summary_card
Return:
json data | [
"Calling",
"Season",
"API",
"."
] | python | train | 29.823529 |
datastax/python-driver | cassandra/cluster.py | https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cluster.py#L2407-L2425 | def add_request_init_listener(self, fn, *args, **kwargs):
"""
Adds a callback with arguments to be called when any request is created.
It will be invoked as `fn(response_future, *args, **kwargs)` after each client request is created,
and before the request is sent\*. This can be used to... | [
"def",
"add_request_init_listener",
"(",
"self",
",",
"fn",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_request_init_callbacks",
".",
"append",
"(",
"(",
"fn",
",",
"args",
",",
"kwargs",
")",
")"
] | Adds a callback with arguments to be called when any request is created.
It will be invoked as `fn(response_future, *args, **kwargs)` after each client request is created,
and before the request is sent\*. This can be used to create extensions by adding result callbacks to the
response future.
... | [
"Adds",
"a",
"callback",
"with",
"arguments",
"to",
"be",
"called",
"when",
"any",
"request",
"is",
"created",
"."
] | python | train | 57.842105 |
twisted/txaws | txaws/s3/client.py | https://github.com/twisted/txaws/blob/5c3317376cd47e536625027e38c3b37840175ce0/txaws/s3/client.py#L645-L675 | def complete_multipart_upload(self, bucket, object_name, upload_id,
parts_list, content_type=None, metadata={}):
"""
Complete a multipart upload.
N.B. This can be possibly be a slow operation.
@param bucket: The bucket name
@param object_name: ... | [
"def",
"complete_multipart_upload",
"(",
"self",
",",
"bucket",
",",
"object_name",
",",
"upload_id",
",",
"parts_list",
",",
"content_type",
"=",
"None",
",",
"metadata",
"=",
"{",
"}",
")",
":",
"data",
"=",
"self",
".",
"_build_complete_multipart_upload_xml",... | Complete a multipart upload.
N.B. This can be possibly be a slow operation.
@param bucket: The bucket name
@param object_name: The object name
@param upload_id: The multipart upload id
@param parts_list: A List of all the parts
(2-tuples of part sequence number and ... | [
"Complete",
"a",
"multipart",
"upload",
"."
] | python | train | 41.645161 |
jeffh/describe | describe/spec/utils.py | https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/spec/utils.py#L17-L35 | def filter_traceback(error, tb, ignore_pkg=CURRENT_PACKAGE):
"""Filtered out all parent stacktraces starting with the given stacktrace that has
a given variable name in its globals.
"""
if not isinstance(tb, types.TracebackType):
return tb
def in_namespace(n):
return n and (n.starts... | [
"def",
"filter_traceback",
"(",
"error",
",",
"tb",
",",
"ignore_pkg",
"=",
"CURRENT_PACKAGE",
")",
":",
"if",
"not",
"isinstance",
"(",
"tb",
",",
"types",
".",
"TracebackType",
")",
":",
"return",
"tb",
"def",
"in_namespace",
"(",
"n",
")",
":",
"retur... | Filtered out all parent stacktraces starting with the given stacktrace that has
a given variable name in its globals. | [
"Filtered",
"out",
"all",
"parent",
"stacktraces",
"starting",
"with",
"the",
"given",
"stacktrace",
"that",
"has",
"a",
"given",
"variable",
"name",
"in",
"its",
"globals",
"."
] | python | train | 37.894737 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py#L752-L766 | def fcoe_get_login_output_fcoe_login_list_fcoe_login_connected_peer_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
fcoe_get_login = ET.Element("fcoe_get_login")
config = fcoe_get_login
output = ET.SubElement(fcoe_get_login, "output")
... | [
"def",
"fcoe_get_login_output_fcoe_login_list_fcoe_login_connected_peer_type",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"fcoe_get_login",
"=",
"ET",
".",
"Element",
"(",
"\"fcoe_get_login\"",
")",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 55.133333 |
arkottke/pysra | pysra/motion.py | https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/motion.py#L211-L229 | def load_at2_file(cls, filename):
"""Read an AT2 formatted time series.
Parameters
----------
filename: str
Filename to open.
"""
with open(filename) as fp:
next(fp)
description = next(fp).strip()
next(fp)
part... | [
"def",
"load_at2_file",
"(",
"cls",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"fp",
":",
"next",
"(",
"fp",
")",
"description",
"=",
"next",
"(",
"fp",
")",
".",
"strip",
"(",
")",
"next",
"(",
"fp",
")",
"parts",
"="... | Read an AT2 formatted time series.
Parameters
----------
filename: str
Filename to open. | [
"Read",
"an",
"AT2",
"formatted",
"time",
"series",
"."
] | python | train | 25.684211 |
alorence/pysvg-py3 | pysvg/core.py | https://github.com/alorence/pysvg-py3/blob/ce217a4da3ada44a71d3e2f391d37c67d95c724e/pysvg/core.py#L140-L149 | def save(self, filename, encoding ='ISO-8859-1', standalone='no'):
"""
Stores any element in a svg file (including header).
Calling this method only makes sense if the root element is an svg elemnt
"""
f = codecs.open(filename, 'w', encoding)
s = self.wrap_xml(self.getXM... | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"encoding",
"=",
"'ISO-8859-1'",
",",
"standalone",
"=",
"'no'",
")",
":",
"f",
"=",
"codecs",
".",
"open",
"(",
"filename",
",",
"'w'",
",",
"encoding",
")",
"s",
"=",
"self",
".",
"wrap_xml",
"(",
... | Stores any element in a svg file (including header).
Calling this method only makes sense if the root element is an svg elemnt | [
"Stores",
"any",
"element",
"in",
"a",
"svg",
"file",
"(",
"including",
"header",
")",
".",
"Calling",
"this",
"method",
"only",
"makes",
"sense",
"if",
"the",
"root",
"element",
"is",
"an",
"svg",
"elemnt"
] | python | train | 41.1 |
jaraco/jaraco.ui | jaraco/ui/editor.py | https://github.com/jaraco/jaraco.ui/blob/10e844c03f3afb3d37bd5d727ba9334af2547fcf/jaraco/ui/editor.py#L86-L92 | def _search_env(keys):
"""
Search the environment for the supplied keys, returning the first
one found or None if none was found.
"""
matches = (os.environ[key] for key in keys if key in os.environ)
return next(matches, None) | [
"def",
"_search_env",
"(",
"keys",
")",
":",
"matches",
"=",
"(",
"os",
".",
"environ",
"[",
"key",
"]",
"for",
"key",
"in",
"keys",
"if",
"key",
"in",
"os",
".",
"environ",
")",
"return",
"next",
"(",
"matches",
",",
"None",
")"
] | Search the environment for the supplied keys, returning the first
one found or None if none was found. | [
"Search",
"the",
"environment",
"for",
"the",
"supplied",
"keys",
"returning",
"the",
"first",
"one",
"found",
"or",
"None",
"if",
"none",
"was",
"found",
"."
] | python | train | 33 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.