repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
yougov/pmxbot | pmxbot/commands.py | https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L784-L793 | def nastygram(nick, rest):
"""
A random passive-agressive comment, optionally directed toward
some(one|thing).
"""
recipient = ""
if rest:
recipient = rest.strip()
karma.Karma.store.change(recipient, -1)
return util.passagg(recipient, nick.lower()) | [
"def",
"nastygram",
"(",
"nick",
",",
"rest",
")",
":",
"recipient",
"=",
"\"\"",
"if",
"rest",
":",
"recipient",
"=",
"rest",
".",
"strip",
"(",
")",
"karma",
".",
"Karma",
".",
"store",
".",
"change",
"(",
"recipient",
",",
"-",
"1",
")",
"return... | A random passive-agressive comment, optionally directed toward
some(one|thing). | [
"A",
"random",
"passive",
"-",
"agressive",
"comment",
"optionally",
"directed",
"toward",
"some",
"(",
"one|thing",
")",
"."
] | python | train |
openai/universe | universe/remotes/docker_remote.py | https://github.com/openai/universe/blob/cc9ce6ec241821bfb0f3b85dd455bd36e4ee7a8c/universe/remotes/docker_remote.py#L60-L77 | def pop(self, n=None):
"""Call from main thread. Returns the list of newly-available (handle, env) pairs."""
if self._popped:
assert n is None
return []
self._popped = True
envs = []
for i, instance in enumerate(self.instances):
env = remote.R... | [
"def",
"pop",
"(",
"self",
",",
"n",
"=",
"None",
")",
":",
"if",
"self",
".",
"_popped",
":",
"assert",
"n",
"is",
"None",
"return",
"[",
"]",
"self",
".",
"_popped",
"=",
"True",
"envs",
"=",
"[",
"]",
"for",
"i",
",",
"instance",
"in",
"enum... | Call from main thread. Returns the list of newly-available (handle, env) pairs. | [
"Call",
"from",
"main",
"thread",
".",
"Returns",
"the",
"list",
"of",
"newly",
"-",
"available",
"(",
"handle",
"env",
")",
"pairs",
"."
] | python | train |
horejsek/python-webdriverwrapper | webdriverwrapper/wrapper.py | https://github.com/horejsek/python-webdriverwrapper/blob/a492f79ab60ed83d860dd817b6a0961500d7e3f5/webdriverwrapper/wrapper.py#L603-L610 | def fill_out(self, data, prefix='', turbo=False):
"""
Shortcut for filling out first ``<form>`` on page. See
:py:class:`~webdriverwrapper.forms.Form` for more information.
.. versionadded:: 2.0
"""
return self.get_elm(tag_name='form').fill_out(data, prefix, turbo) | [
"def",
"fill_out",
"(",
"self",
",",
"data",
",",
"prefix",
"=",
"''",
",",
"turbo",
"=",
"False",
")",
":",
"return",
"self",
".",
"get_elm",
"(",
"tag_name",
"=",
"'form'",
")",
".",
"fill_out",
"(",
"data",
",",
"prefix",
",",
"turbo",
")"
] | Shortcut for filling out first ``<form>`` on page. See
:py:class:`~webdriverwrapper.forms.Form` for more information.
.. versionadded:: 2.0 | [
"Shortcut",
"for",
"filling",
"out",
"first",
"<form",
">",
"on",
"page",
".",
"See",
":",
"py",
":",
"class",
":",
"~webdriverwrapper",
".",
"forms",
".",
"Form",
"for",
"more",
"information",
"."
] | python | train |
gc3-uzh-ch/elasticluster | elasticluster/cluster.py | https://github.com/gc3-uzh-ch/elasticluster/blob/e6345633308c76de13b889417df572815aabe744/elasticluster/cluster.py#L905-L981 | def get_ssh_to_node(self, ssh_to=None):
"""
Return target node for SSH/SFTP connections.
The target node is the first node of the class specified in
the configuration file as ``ssh_to`` (but argument ``ssh_to``
can override this choice).
If not ``ssh_to`` has been speci... | [
"def",
"get_ssh_to_node",
"(",
"self",
",",
"ssh_to",
"=",
"None",
")",
":",
"if",
"ssh_to",
"is",
"None",
":",
"ssh_to",
"=",
"self",
".",
"ssh_to",
"# first try to interpret `ssh_to` as a node name",
"if",
"ssh_to",
":",
"try",
":",
"return",
"self",
".",
... | Return target node for SSH/SFTP connections.
The target node is the first node of the class specified in
the configuration file as ``ssh_to`` (but argument ``ssh_to``
can override this choice).
If not ``ssh_to`` has been specified in this cluster's config,
then try node class n... | [
"Return",
"target",
"node",
"for",
"SSH",
"/",
"SFTP",
"connections",
"."
] | python | train |
aleju/imgaug | imgaug/external/poly_point_isect_py2py3.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/external/poly_point_isect_py2py3.py#L1218-L1283 | def remove(self, key):
"""T.remove(key) <==> del T[key], remove item <key> from tree."""
if self._root is None:
raise KeyError(str(key))
head = Node() # False tree root
node = head
node.right = self._root
parent = None
grand_parent = None
foun... | [
"def",
"remove",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"_root",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"str",
"(",
"key",
")",
")",
"head",
"=",
"Node",
"(",
")",
"# False tree root",
"node",
"=",
"head",
"node",
".",
"right",... | T.remove(key) <==> del T[key], remove item <key> from tree. | [
"T",
".",
"remove",
"(",
"key",
")",
"<",
"==",
">",
"del",
"T",
"[",
"key",
"]",
"remove",
"item",
"<key",
">",
"from",
"tree",
"."
] | python | valid |
zsethna/OLGA | olga/load_model.py | https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/load_model.py#L790-L892 | def read_igor_marginals_txt(marginals_file_name , dim_names=False):
"""Load raw IGoR model marginals.
Parameters
----------
marginals_file_name : str
File name for a IGOR model marginals file.
Returns
-------
model_dict : dict
Dictionary with model marginals.
dimens... | [
"def",
"read_igor_marginals_txt",
"(",
"marginals_file_name",
",",
"dim_names",
"=",
"False",
")",
":",
"with",
"open",
"(",
"marginals_file_name",
",",
"'r'",
")",
"as",
"file",
":",
"#Model parameters are stored inside a dictionary of ndarrays",
"model_dict",
"=",
"{"... | Load raw IGoR model marginals.
Parameters
----------
marginals_file_name : str
File name for a IGOR model marginals file.
Returns
-------
model_dict : dict
Dictionary with model marginals.
dimension_names_dict : dict
Dictionary that defines IGoR model dependecie... | [
"Load",
"raw",
"IGoR",
"model",
"marginals",
".",
"Parameters",
"----------",
"marginals_file_name",
":",
"str",
"File",
"name",
"for",
"a",
"IGOR",
"model",
"marginals",
"file",
"."
] | python | train |
nitmir/django-cas-server | cas_server/views.py | https://github.com/nitmir/django-cas-server/blob/d106181b94c444f1946269da5c20f6c904840ad3/cas_server/views.py#L958-L1008 | def post(request):
"""
method called on POST request on this view
:param django.http.HttpRequest request: The current request object
:return: ``HttpResponse(u"yes\\n")`` if the POSTed tuple (username, password, service)
if valid (i.e. (username, password) is ... | [
"def",
"post",
"(",
"request",
")",
":",
"username",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'username'",
")",
"password",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'password'",
")",
"service",
"=",
"request",
".",
"POST",
".",
"get",
"("... | method called on POST request on this view
:param django.http.HttpRequest request: The current request object
:return: ``HttpResponse(u"yes\\n")`` if the POSTed tuple (username, password, service)
if valid (i.e. (username, password) is valid dans username is allowed on service).... | [
"method",
"called",
"on",
"POST",
"request",
"on",
"this",
"view"
] | python | train |
chrissimpkins/crypto | lib/crypto/library/cryptor.py | https://github.com/chrissimpkins/crypto/blob/6b95fa81b26312e46f02557dca0b5f5c898a76fd/lib/crypto/library/cryptor.py#L149-L167 | def _is_common_text(self, inpath):
"""private method to compare file path mime type to common text file types"""
# make local variables for the available char numbers in the suffix types to be tested
one_suffix = inpath[-2:]
two_suffix = inpath[-3:]
three_suffix = inpath[-4:]
... | [
"def",
"_is_common_text",
"(",
"self",
",",
"inpath",
")",
":",
"# make local variables for the available char numbers in the suffix types to be tested",
"one_suffix",
"=",
"inpath",
"[",
"-",
"2",
":",
"]",
"two_suffix",
"=",
"inpath",
"[",
"-",
"3",
":",
"]",
"thr... | private method to compare file path mime type to common text file types | [
"private",
"method",
"to",
"compare",
"file",
"path",
"mime",
"type",
"to",
"common",
"text",
"file",
"types"
] | python | train |
ethereum/pyethereum | ethereum/abi.py | https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/abi.py#L188-L403 | def encode_single(typ, arg): # pylint: disable=too-many-return-statements,too-many-branches,too-many-statements,too-many-locals
""" Encode `arg` as `typ`.
`arg` will be encoded in a best effort manner, were necessary the function
will try to correctly define the underlying binary representation (ie.
d... | [
"def",
"encode_single",
"(",
"typ",
",",
"arg",
")",
":",
"# pylint: disable=too-many-return-statements,too-many-branches,too-many-statements,too-many-locals",
"base",
",",
"sub",
",",
"_",
"=",
"typ",
"if",
"base",
"==",
"'uint'",
":",
"sub",
"=",
"int",
"(",
"sub"... | Encode `arg` as `typ`.
`arg` will be encoded in a best effort manner, were necessary the function
will try to correctly define the underlying binary representation (ie.
decoding a hex-encoded address/hash).
Args:
typ (Tuple[(str, int, list)]): A 3-tuple defining the `arg` type.
Th... | [
"Encode",
"arg",
"as",
"typ",
"."
] | python | train |
fermiPy/fermipy | fermipy/wcs_utils.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L94-L120 | def distance_to_edge(geom, skydir):
"""Return the angular distance from the given direction and
the edge of the projection."""
# FIXME: We should add a pixel_size property in gammapy.maps
# FIXME: We should make this into a MapGeom method
xpix, ypix = skydir.to_pixel(geom.wcs, origin=0)
d... | [
"def",
"distance_to_edge",
"(",
"geom",
",",
"skydir",
")",
":",
"# FIXME: We should add a pixel_size property in gammapy.maps",
"# FIXME: We should make this into a MapGeom method ",
"xpix",
",",
"ypix",
"=",
"skydir",
".",
"to_pixel",
"(",
"geom",
".",
"wcs",
",",
"orig... | Return the angular distance from the given direction and
the edge of the projection. | [
"Return",
"the",
"angular",
"distance",
"from",
"the",
"given",
"direction",
"and",
"the",
"edge",
"of",
"the",
"projection",
"."
] | python | train |
glitchassassin/lackey | lackey/RegionMatching.py | https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/RegionMatching.py#L1923-L1926 | def newRegion(self, loc, width, height):
""" Creates a new region on the current screen at the specified offset with the specified
width and height. """
return Region.create(self.getTopLeft().offset(loc), width, height) | [
"def",
"newRegion",
"(",
"self",
",",
"loc",
",",
"width",
",",
"height",
")",
":",
"return",
"Region",
".",
"create",
"(",
"self",
".",
"getTopLeft",
"(",
")",
".",
"offset",
"(",
"loc",
")",
",",
"width",
",",
"height",
")"
] | Creates a new region on the current screen at the specified offset with the specified
width and height. | [
"Creates",
"a",
"new",
"region",
"on",
"the",
"current",
"screen",
"at",
"the",
"specified",
"offset",
"with",
"the",
"specified",
"width",
"and",
"height",
"."
] | python | train |
pymupdf/PyMuPDF | fitz/fitz.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L2409-L2421 | def copyPage(self, pno, to=-1):
"""Copy a page to before some other page of the document. Specify 'to = -1' to copy after last page.
"""
pl = list(range(len(self)))
if pno < 0 or pno > pl[-1]:
raise ValueError("'from' page number out of range")
if to < -1 or to > pl[-... | [
"def",
"copyPage",
"(",
"self",
",",
"pno",
",",
"to",
"=",
"-",
"1",
")",
":",
"pl",
"=",
"list",
"(",
"range",
"(",
"len",
"(",
"self",
")",
")",
")",
"if",
"pno",
"<",
"0",
"or",
"pno",
">",
"pl",
"[",
"-",
"1",
"]",
":",
"raise",
"Val... | Copy a page to before some other page of the document. Specify 'to = -1' to copy after last page. | [
"Copy",
"a",
"page",
"to",
"before",
"some",
"other",
"page",
"of",
"the",
"document",
".",
"Specify",
"to",
"=",
"-",
"1",
"to",
"copy",
"after",
"last",
"page",
"."
] | python | train |
stlehmann/pyads | pyads/pyads_ex.py | https://github.com/stlehmann/pyads/blob/44bd84394db2785332ac44b2948373916bea0f02/pyads/pyads_ex.py#L228-L260 | def adsSyncReadStateReqEx(port, address):
# type: (int, AmsAddr) -> Tuple[int, int]
"""Read the current ADS-state and the machine-state.
Read the current ADS-state and the machine-state from the
ADS-server.
:param pyads.structs.AmsAddr address: local or remote AmsAddr
:rtype: (int, int)
:r... | [
"def",
"adsSyncReadStateReqEx",
"(",
"port",
",",
"address",
")",
":",
"# type: (int, AmsAddr) -> Tuple[int, int]",
"sync_read_state_request",
"=",
"_adsDLL",
".",
"AdsSyncReadStateReqEx",
"# C pointer to ams address struct",
"ams_address_pointer",
"=",
"ctypes",
".",
"pointer"... | Read the current ADS-state and the machine-state.
Read the current ADS-state and the machine-state from the
ADS-server.
:param pyads.structs.AmsAddr address: local or remote AmsAddr
:rtype: (int, int)
:return: ads_state, device_state | [
"Read",
"the",
"current",
"ADS",
"-",
"state",
"and",
"the",
"machine",
"-",
"state",
"."
] | python | valid |
horazont/aioxmpp | aioxmpp/muc/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L2382-L2435 | def set_affiliation(self, mucjid, jid, affiliation, *, reason=None):
"""
Change the affiliation of an entity with a MUC.
:param mucjid: The bare JID identifying the MUC.
:type mucjid: :class:`~aioxmpp.JID`
:param jid: The bare JID of the entity whose affiliation shall be
... | [
"def",
"set_affiliation",
"(",
"self",
",",
"mucjid",
",",
"jid",
",",
"affiliation",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"if",
"mucjid",
"is",
"None",
"or",
"not",
"mucjid",
".",
"is_bare",
":",
"raise",
"ValueError",
"(",
"\"mucjid must be ... | Change the affiliation of an entity with a MUC.
:param mucjid: The bare JID identifying the MUC.
:type mucjid: :class:`~aioxmpp.JID`
:param jid: The bare JID of the entity whose affiliation shall be
changed.
:type jid: :class:`~aioxmpp.JID`
:param affiliation: The ne... | [
"Change",
"the",
"affiliation",
"of",
"an",
"entity",
"with",
"a",
"MUC",
"."
] | python | train |
dropbox/stone | stone/frontend/parser.py | https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/frontend/parser.py#L72-L82 | def get_parser(self):
"""
Returns a ParserFactory with the state reset so it can be used to
parse again.
:return: ParserFactory
"""
self.path = None
self.anony_defs = []
self.exhausted = False
return self | [
"def",
"get_parser",
"(",
"self",
")",
":",
"self",
".",
"path",
"=",
"None",
"self",
".",
"anony_defs",
"=",
"[",
"]",
"self",
".",
"exhausted",
"=",
"False",
"return",
"self"
] | Returns a ParserFactory with the state reset so it can be used to
parse again.
:return: ParserFactory | [
"Returns",
"a",
"ParserFactory",
"with",
"the",
"state",
"reset",
"so",
"it",
"can",
"be",
"used",
"to",
"parse",
"again",
"."
] | python | train |
aisayko/Django-tinymce-filebrowser | mce_filebrowser/utils.py | https://github.com/aisayko/Django-tinymce-filebrowser/blob/f34c9e8f8c5e32c1d1221270314f31ee07f24409/mce_filebrowser/utils.py#L9-L41 | def render_paginate(request, template, objects, per_page, extra_context={}):
"""
Paginated list of objects.
"""
paginator = Paginator(objects, per_page)
page = request.GET.get('page', 1)
get_params = '&'.join(['%s=%s' % (k, request.GET[k])
for k in request.GET if k != ... | [
"def",
"render_paginate",
"(",
"request",
",",
"template",
",",
"objects",
",",
"per_page",
",",
"extra_context",
"=",
"{",
"}",
")",
":",
"paginator",
"=",
"Paginator",
"(",
"objects",
",",
"per_page",
")",
"page",
"=",
"request",
".",
"GET",
".",
"get"... | Paginated list of objects. | [
"Paginated",
"list",
"of",
"objects",
"."
] | python | train |
pyQode/pyqode.core | pyqode/core/managers/file.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/file.py#L201-L281 | def open(self, path, encoding=None, use_cached_encoding=True):
"""
Open a file and set its content on the editor widget.
pyqode does not try to guess encoding. It's up to the client code to
handle encodings. You can either use a charset detector to detect
encoding or rely on a s... | [
"def",
"open",
"(",
"self",
",",
"path",
",",
"encoding",
"=",
"None",
",",
"use_cached_encoding",
"=",
"True",
")",
":",
"ret_val",
"=",
"False",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"locale",
".",
"getpreferredencoding",
"(",
")",
"sel... | Open a file and set its content on the editor widget.
pyqode does not try to guess encoding. It's up to the client code to
handle encodings. You can either use a charset detector to detect
encoding or rely on a settings in your application. It is also up to
you to handle UnicodeDecodeEr... | [
"Open",
"a",
"file",
"and",
"set",
"its",
"content",
"on",
"the",
"editor",
"widget",
"."
] | python | train |
ejeschke/ginga | ginga/ImageView.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/ImageView.py#L1985-L2004 | def _sanity_check_scale(self, scale_x, scale_y):
"""Do a sanity check on the proposed scale vs. window size.
Raises an exception if there will be a problem.
"""
win_wd, win_ht = self.get_window_size()
if (win_wd <= 0) or (win_ht <= 0):
raise ImageViewError("window siz... | [
"def",
"_sanity_check_scale",
"(",
"self",
",",
"scale_x",
",",
"scale_y",
")",
":",
"win_wd",
",",
"win_ht",
"=",
"self",
".",
"get_window_size",
"(",
")",
"if",
"(",
"win_wd",
"<=",
"0",
")",
"or",
"(",
"win_ht",
"<=",
"0",
")",
":",
"raise",
"Imag... | Do a sanity check on the proposed scale vs. window size.
Raises an exception if there will be a problem. | [
"Do",
"a",
"sanity",
"check",
"on",
"the",
"proposed",
"scale",
"vs",
".",
"window",
"size",
".",
"Raises",
"an",
"exception",
"if",
"there",
"will",
"be",
"a",
"problem",
"."
] | python | train |
log2timeline/plaso | plaso/output/shared_elastic.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/shared_elastic.py#L250-L257 | def SetIndexName(self, index_name):
"""Set the index name.
Args:
index_name (str): name of the index.
"""
self._index_name = index_name
logger.debug('Elasticsearch index name: {0:s}'.format(index_name)) | [
"def",
"SetIndexName",
"(",
"self",
",",
"index_name",
")",
":",
"self",
".",
"_index_name",
"=",
"index_name",
"logger",
".",
"debug",
"(",
"'Elasticsearch index name: {0:s}'",
".",
"format",
"(",
"index_name",
")",
")"
] | Set the index name.
Args:
index_name (str): name of the index. | [
"Set",
"the",
"index",
"name",
"."
] | python | train |
Clinical-Genomics/scout | scout/server/blueprints/variants/views.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/variants/views.py#L407-L410 | def cancer_variants(institute_id, case_name):
"""Show cancer variants overview."""
data = controllers.cancer_variants(store, request.args, institute_id, case_name)
return data | [
"def",
"cancer_variants",
"(",
"institute_id",
",",
"case_name",
")",
":",
"data",
"=",
"controllers",
".",
"cancer_variants",
"(",
"store",
",",
"request",
".",
"args",
",",
"institute_id",
",",
"case_name",
")",
"return",
"data"
] | Show cancer variants overview. | [
"Show",
"cancer",
"variants",
"overview",
"."
] | python | test |
librosa/librosa | librosa/decompose.py | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/decompose.py#L379-L513 | def nn_filter(S, rec=None, aggregate=None, axis=-1, **kwargs):
'''Filtering by nearest-neighbors.
Each data point (e.g, spectrogram column) is replaced
by aggregating its nearest neighbors in feature space.
This can be useful for de-noising a spectrogram or feature matrix.
The non-local means met... | [
"def",
"nn_filter",
"(",
"S",
",",
"rec",
"=",
"None",
",",
"aggregate",
"=",
"None",
",",
"axis",
"=",
"-",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"aggregate",
"is",
"None",
":",
"aggregate",
"=",
"np",
".",
"mean",
"if",
"rec",
"is",
"... | Filtering by nearest-neighbors.
Each data point (e.g, spectrogram column) is replaced
by aggregating its nearest neighbors in feature space.
This can be useful for de-noising a spectrogram or feature matrix.
The non-local means method [1]_ can be recovered by providing a
weighted recurrence matri... | [
"Filtering",
"by",
"nearest",
"-",
"neighbors",
"."
] | python | test |
thombashi/pytablewriter | pytablewriter/writer/_table_writer.py | https://github.com/thombashi/pytablewriter/blob/52ea85ed8e89097afa64f137c6a1b3acdfefdbda/pytablewriter/writer/_table_writer.py#L654-L686 | def from_series(self, series, add_index_column=True):
"""
Set tabular attributes to the writer from :py:class:`pandas.Series`.
Following attributes are set by the method:
- :py:attr:`~.headers`
- :py:attr:`~.value_matrix`
- :py:attr:`~.type_hints`
Ar... | [
"def",
"from_series",
"(",
"self",
",",
"series",
",",
"add_index_column",
"=",
"True",
")",
":",
"if",
"series",
".",
"name",
":",
"self",
".",
"headers",
"=",
"[",
"series",
".",
"name",
"]",
"else",
":",
"self",
".",
"headers",
"=",
"[",
"\"value\... | Set tabular attributes to the writer from :py:class:`pandas.Series`.
Following attributes are set by the method:
- :py:attr:`~.headers`
- :py:attr:`~.value_matrix`
- :py:attr:`~.type_hints`
Args:
series(pandas.Series):
Input pandas.Series... | [
"Set",
"tabular",
"attributes",
"to",
"the",
"writer",
"from",
":",
"py",
":",
"class",
":",
"pandas",
".",
"Series",
".",
"Following",
"attributes",
"are",
"set",
"by",
"the",
"method",
":"
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_http_redirect.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_http_redirect.py#L53-L64 | def set_http_application_url_output_status_string(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
set_http_application_url = ET.Element("set_http_application_url")
config = set_http_application_url
output = ET.SubElement(set_http_application_url,... | [
"def",
"set_http_application_url_output_status_string",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"set_http_application_url",
"=",
"ET",
".",
"Element",
"(",
"\"set_http_application_url\"",
")",
"c... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
limpyd/redis-limpyd | limpyd/contrib/collection.py | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/contrib/collection.py#L765-L778 | def values(self, *fields):
"""
Ask the collection to return a list of dict of given fields for each
instance found in the collection.
If no fields are given, all "simple value" fields are used.
"""
if not fields:
fields = self._get_simple_fields()
fie... | [
"def",
"values",
"(",
"self",
",",
"*",
"fields",
")",
":",
"if",
"not",
"fields",
":",
"fields",
"=",
"self",
".",
"_get_simple_fields",
"(",
")",
"fields",
"=",
"self",
".",
"_coerce_fields_parameters",
"(",
"fields",
")",
"self",
".",
"_instances",
"=... | Ask the collection to return a list of dict of given fields for each
instance found in the collection.
If no fields are given, all "simple value" fields are used. | [
"Ask",
"the",
"collection",
"to",
"return",
"a",
"list",
"of",
"dict",
"of",
"given",
"fields",
"for",
"each",
"instance",
"found",
"in",
"the",
"collection",
".",
"If",
"no",
"fields",
"are",
"given",
"all",
"simple",
"value",
"fields",
"are",
"used",
"... | python | train |
mrstephenneal/mysql-toolkit | mysql/toolkit/components/operations/__init__.py | https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/components/operations/__init__.py#L16-L18 | def script(self, sql_script, split_algo='sql_split', prep_statements=True, dump_fails=True):
"""Wrapper method providing access to the SQLScript class's methods and properties."""
return Execute(sql_script, split_algo, prep_statements, dump_fails, self) | [
"def",
"script",
"(",
"self",
",",
"sql_script",
",",
"split_algo",
"=",
"'sql_split'",
",",
"prep_statements",
"=",
"True",
",",
"dump_fails",
"=",
"True",
")",
":",
"return",
"Execute",
"(",
"sql_script",
",",
"split_algo",
",",
"prep_statements",
",",
"du... | Wrapper method providing access to the SQLScript class's methods and properties. | [
"Wrapper",
"method",
"providing",
"access",
"to",
"the",
"SQLScript",
"class",
"s",
"methods",
"and",
"properties",
"."
] | python | train |
scikit-learn-contrib/categorical-encoding | examples/source_data/loaders.py | https://github.com/scikit-learn-contrib/categorical-encoding/blob/5e9e803c9131b377af305d5302723ba2415001da/examples/source_data/loaders.py#L49-L69 | def get_splice_data():
"""
Load the mushroom dataset, split it into X and y, and then call the label encoder to get an integer y column.
:return:
"""
df = pd.read_csv('source_data/splice/splice.csv')
X = df.reindex(columns=[x for x in df.columns.values if x != 'class'])
X['dna'] = X['dna']... | [
"def",
"get_splice_data",
"(",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"'source_data/splice/splice.csv'",
")",
"X",
"=",
"df",
".",
"reindex",
"(",
"columns",
"=",
"[",
"x",
"for",
"x",
"in",
"df",
".",
"columns",
".",
"values",
"if",
"x",
"... | Load the mushroom dataset, split it into X and y, and then call the label encoder to get an integer y column.
:return: | [
"Load",
"the",
"mushroom",
"dataset",
"split",
"it",
"into",
"X",
"and",
"y",
"and",
"then",
"call",
"the",
"label",
"encoder",
"to",
"get",
"an",
"integer",
"y",
"column",
"."
] | python | valid |
GNS3/gns3-server | gns3server/compute/vmware/__init__.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/__init__.py#L87-L123 | def find_vmrun(self):
"""
Searches for vmrun.
:returns: path to vmrun
"""
# look for vmrun
vmrun_path = self.config.get_section_config("VMware").get("vmrun_path")
if not vmrun_path:
if sys.platform.startswith("win"):
vmrun_path = shut... | [
"def",
"find_vmrun",
"(",
"self",
")",
":",
"# look for vmrun",
"vmrun_path",
"=",
"self",
".",
"config",
".",
"get_section_config",
"(",
"\"VMware\"",
")",
".",
"get",
"(",
"\"vmrun_path\"",
")",
"if",
"not",
"vmrun_path",
":",
"if",
"sys",
".",
"platform",... | Searches for vmrun.
:returns: path to vmrun | [
"Searches",
"for",
"vmrun",
"."
] | python | train |
bitshares/uptick | uptick/message.py | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/message.py#L24-L31 | def sign(ctx, file, account):
""" Sign a message with an account
"""
if not file:
print_message("Prompting for message. Terminate with CTRL-D", "info")
file = click.get_text_stream("stdin")
m = Message(file.read(), bitshares_instance=ctx.bitshares)
print_message(m.sign(account), "inf... | [
"def",
"sign",
"(",
"ctx",
",",
"file",
",",
"account",
")",
":",
"if",
"not",
"file",
":",
"print_message",
"(",
"\"Prompting for message. Terminate with CTRL-D\"",
",",
"\"info\"",
")",
"file",
"=",
"click",
".",
"get_text_stream",
"(",
"\"stdin\"",
")",
"m"... | Sign a message with an account | [
"Sign",
"a",
"message",
"with",
"an",
"account"
] | python | train |
numenta/nupic | src/nupic/math/stats.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L327-L341 | def clean_outcpd(self):
"""Hack to act like clean_outcpd on zeta1.TopLevelNode.
Take the max element in each to column, set it to 1, and set all the
other elements to 0.
Only called by inferRowMaxProd() and only needed if an updateRow()
has been called since the last clean_outcpd().
"""
m = ... | [
"def",
"clean_outcpd",
"(",
"self",
")",
":",
"m",
"=",
"self",
".",
"hist_",
".",
"toDense",
"(",
")",
"for",
"j",
"in",
"xrange",
"(",
"m",
".",
"shape",
"[",
"1",
"]",
")",
":",
"# For each column.",
"cmax",
"=",
"m",
"[",
":",
",",
"j",
"]"... | Hack to act like clean_outcpd on zeta1.TopLevelNode.
Take the max element in each to column, set it to 1, and set all the
other elements to 0.
Only called by inferRowMaxProd() and only needed if an updateRow()
has been called since the last clean_outcpd(). | [
"Hack",
"to",
"act",
"like",
"clean_outcpd",
"on",
"zeta1",
".",
"TopLevelNode",
".",
"Take",
"the",
"max",
"element",
"in",
"each",
"to",
"column",
"set",
"it",
"to",
"1",
"and",
"set",
"all",
"the",
"other",
"elements",
"to",
"0",
".",
"Only",
"calle... | python | valid |
glitchassassin/lackey | lackey/RegionMatching.py | https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/RegionMatching.py#L878-L921 | def type(self, *args):
""" Usage: type([PSMRL], text, [modifiers])
If a pattern is specified, the pattern is clicked first. Doesn't support text paths.
Special keys can be entered with the key name between brackets, as `"{SPACE}"`, or as
`Key.SPACE`.
"""
pattern = None
... | [
"def",
"type",
"(",
"self",
",",
"*",
"args",
")",
":",
"pattern",
"=",
"None",
"text",
"=",
"None",
"modifiers",
"=",
"None",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"basestring",
")",
":",... | Usage: type([PSMRL], text, [modifiers])
If a pattern is specified, the pattern is clicked first. Doesn't support text paths.
Special keys can be entered with the key name between brackets, as `"{SPACE}"`, or as
`Key.SPACE`. | [
"Usage",
":",
"type",
"(",
"[",
"PSMRL",
"]",
"text",
"[",
"modifiers",
"]",
")"
] | python | train |
msmbuilder/osprey | osprey/config.py | https://github.com/msmbuilder/osprey/blob/ea09da24e45820e1300e24a52fefa6c849f7a986/osprey/config.py#L138-L227 | def estimator(self):
"""Get the estimator, an instance of a (subclass of)
sklearn.base.BaseEstimator
It can be loaded either from a pickle, from a string using eval(),
or from an entry point.
e.g.
estimator:
# only one of the following can actually be activ... | [
"def",
"estimator",
"(",
"self",
")",
":",
"module_path",
"=",
"self",
".",
"get_value",
"(",
"'estimator/module'",
")",
"if",
"module_path",
"is",
"not",
"None",
":",
"with",
"prepend_syspath",
"(",
"dirname",
"(",
"abspath",
"(",
"self",
".",
"path",
")"... | Get the estimator, an instance of a (subclass of)
sklearn.base.BaseEstimator
It can be loaded either from a pickle, from a string using eval(),
or from an entry point.
e.g.
estimator:
# only one of the following can actually be active in a given
# confi... | [
"Get",
"the",
"estimator",
"an",
"instance",
"of",
"a",
"(",
"subclass",
"of",
")",
"sklearn",
".",
"base",
".",
"BaseEstimator"
] | python | valid |
RudolfCardinal/pythonlib | cardinal_pythonlib/pdf.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/pdf.py#L541-L560 | def append_memory_pdf_to_writer(input_pdf: bytes,
writer: PdfFileWriter,
start_recto: bool = True) -> None:
"""
Appends a PDF (as bytes in memory) to a PyPDF2 writer.
Args:
input_pdf: the PDF, as ``bytes``
writer: the writer
... | [
"def",
"append_memory_pdf_to_writer",
"(",
"input_pdf",
":",
"bytes",
",",
"writer",
":",
"PdfFileWriter",
",",
"start_recto",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"if",
"not",
"input_pdf",
":",
"return",
"if",
"start_recto",
"and",
"writer",
".... | Appends a PDF (as bytes in memory) to a PyPDF2 writer.
Args:
input_pdf: the PDF, as ``bytes``
writer: the writer
start_recto: start a new right-hand page? | [
"Appends",
"a",
"PDF",
"(",
"as",
"bytes",
"in",
"memory",
")",
"to",
"a",
"PyPDF2",
"writer",
"."
] | python | train |
VasilyStepanov/pywidl | pywidl/grammar.py | https://github.com/VasilyStepanov/pywidl/blob/8d84b2e53157bfe276bf16301c19e8b6b32e861e/pywidl/grammar.py#L979-L983 | def p_ExtendedAttributeArgList(p):
"""ExtendedAttributeArgList : IDENTIFIER "(" ArgumentList ")"
"""
p[0] = model.ExtendedAttribute(
value=model.ExtendedAttributeValue(name=p[1], arguments=p[3])) | [
"def",
"p_ExtendedAttributeArgList",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"model",
".",
"ExtendedAttribute",
"(",
"value",
"=",
"model",
".",
"ExtendedAttributeValue",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"arguments",
"=",
"p",
"[",
"3",
... | ExtendedAttributeArgList : IDENTIFIER "(" ArgumentList ")" | [
"ExtendedAttributeArgList",
":",
"IDENTIFIER",
"(",
"ArgumentList",
")"
] | python | train |
bitesofcode/projexui | projexui/widgets/xlineedit.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xlineedit.py#L617-L624 | def setObjectName( self, objectName ):
"""
Updates the style sheet for this line edit when the name changes.
:param objectName | <str>
"""
super(XLineEdit, self).setObjectName(objectName)
self.adjustStyleSheet() | [
"def",
"setObjectName",
"(",
"self",
",",
"objectName",
")",
":",
"super",
"(",
"XLineEdit",
",",
"self",
")",
".",
"setObjectName",
"(",
"objectName",
")",
"self",
".",
"adjustStyleSheet",
"(",
")"
] | Updates the style sheet for this line edit when the name changes.
:param objectName | <str> | [
"Updates",
"the",
"style",
"sheet",
"for",
"this",
"line",
"edit",
"when",
"the",
"name",
"changes",
".",
":",
"param",
"objectName",
"|",
"<str",
">"
] | python | train |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L6737-L6755 | def Runtime_releaseObjectGroup(self, objectGroup):
"""
Function path: Runtime.releaseObjectGroup
Domain: Runtime
Method name: releaseObjectGroup
Parameters:
Required arguments:
'objectGroup' (type: string) -> Symbolic object group name.
No return value.
Description: Releases all remote... | [
"def",
"Runtime_releaseObjectGroup",
"(",
"self",
",",
"objectGroup",
")",
":",
"assert",
"isinstance",
"(",
"objectGroup",
",",
"(",
"str",
",",
")",
")",
",",
"\"Argument 'objectGroup' must be of type '['str']'. Received type: '%s'\"",
"%",
"type",
"(",
"objectGroup",... | Function path: Runtime.releaseObjectGroup
Domain: Runtime
Method name: releaseObjectGroup
Parameters:
Required arguments:
'objectGroup' (type: string) -> Symbolic object group name.
No return value.
Description: Releases all remote objects that belong to a given group. | [
"Function",
"path",
":",
"Runtime",
".",
"releaseObjectGroup",
"Domain",
":",
"Runtime",
"Method",
"name",
":",
"releaseObjectGroup",
"Parameters",
":",
"Required",
"arguments",
":",
"objectGroup",
"(",
"type",
":",
"string",
")",
"-",
">",
"Symbolic",
"object",... | python | train |
androguard/androguard | androguard/core/bytecode.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecode.py#L894-L919 | def get_package_class_name(name):
"""
Return package and class name in a java variant from a typed variant name.
If no package could be found, the package is an empty string.
example::
>>> get_package_class_name('Ljava/lang/Object;')
('java.lang', 'Object')
:param name: the name
... | [
"def",
"get_package_class_name",
"(",
"name",
")",
":",
"if",
"name",
"[",
"0",
"]",
"!=",
"'L'",
"and",
"name",
"[",
"-",
"1",
"]",
"!=",
"';'",
":",
"raise",
"ValueError",
"(",
"\"The name '{}' does not look like a typed name!\"",
".",
"format",
"(",
"name... | Return package and class name in a java variant from a typed variant name.
If no package could be found, the package is an empty string.
example::
>>> get_package_class_name('Ljava/lang/Object;')
('java.lang', 'Object')
:param name: the name
:rtype: tuple
:return: | [
"Return",
"package",
"and",
"class",
"name",
"in",
"a",
"java",
"variant",
"from",
"a",
"typed",
"variant",
"name",
"."
] | python | train |
pydata/xarray | xarray/core/utils.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L95-L119 | def multiindex_from_product_levels(levels: Sequence[pd.Index],
names: Optional[Sequence[str]] = None
) -> pd.MultiIndex:
"""Creating a MultiIndex from a product without refactorizing levels.
Keeping levels the same gives back the original la... | [
"def",
"multiindex_from_product_levels",
"(",
"levels",
":",
"Sequence",
"[",
"pd",
".",
"Index",
"]",
",",
"names",
":",
"Optional",
"[",
"Sequence",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"pd",
".",
"MultiIndex",
":",
"if",
"any",
"(",
"not",
... | Creating a MultiIndex from a product without refactorizing levels.
Keeping levels the same gives back the original labels when we unstack.
Parameters
----------
levels : sequence of pd.Index
Values for each MultiIndex level.
names : optional sequence of objects
Names for each level... | [
"Creating",
"a",
"MultiIndex",
"from",
"a",
"product",
"without",
"refactorizing",
"levels",
"."
] | python | train |
LonamiWebs/Telethon | telethon/utils.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/utils.py#L196-L210 | def get_input_channel(entity):
"""Similar to :meth:`get_input_peer`, but for :tl:`InputChannel`'s alone."""
try:
if entity.SUBCLASS_OF_ID == 0x40f202fd: # crc32(b'InputChannel')
return entity
except AttributeError:
_raise_cast_fail(entity, 'InputChannel')
if isinstance(enti... | [
"def",
"get_input_channel",
"(",
"entity",
")",
":",
"try",
":",
"if",
"entity",
".",
"SUBCLASS_OF_ID",
"==",
"0x40f202fd",
":",
"# crc32(b'InputChannel')",
"return",
"entity",
"except",
"AttributeError",
":",
"_raise_cast_fail",
"(",
"entity",
",",
"'InputChannel'"... | Similar to :meth:`get_input_peer`, but for :tl:`InputChannel`'s alone. | [
"Similar",
"to",
":",
"meth",
":",
"get_input_peer",
"but",
"for",
":",
"tl",
":",
"InputChannel",
"s",
"alone",
"."
] | python | train |
pypa/pipenv | pipenv/patched/notpip/_internal/index.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/index.py#L992-L1007 | def iter_links(self):
# type: () -> Iterable[Link]
"""Yields all links in the page"""
document = html5lib.parse(
self.content,
transport_encoding=_get_encoding_from_headers(self.headers),
namespaceHTMLElements=False,
)
base_url = _determine_bas... | [
"def",
"iter_links",
"(",
"self",
")",
":",
"# type: () -> Iterable[Link]",
"document",
"=",
"html5lib",
".",
"parse",
"(",
"self",
".",
"content",
",",
"transport_encoding",
"=",
"_get_encoding_from_headers",
"(",
"self",
".",
"headers",
")",
",",
"namespaceHTMLE... | Yields all links in the page | [
"Yields",
"all",
"links",
"in",
"the",
"page"
] | python | train |
jbittel/django-mama-cas | mama_cas/utils.py | https://github.com/jbittel/django-mama-cas/blob/03935d97442b46d8127ab9e1cd8deb96953fe156/mama_cas/utils.py#L23-L38 | def add_query_params(url, params):
"""
Inject additional query parameters into an existing URL. If
parameters already exist with the same name, they will be
overwritten. Parameters with empty values are ignored. Return
the modified URL as a string.
"""
def encode(s):
return force_byt... | [
"def",
"add_query_params",
"(",
"url",
",",
"params",
")",
":",
"def",
"encode",
"(",
"s",
")",
":",
"return",
"force_bytes",
"(",
"s",
",",
"settings",
".",
"DEFAULT_CHARSET",
")",
"params",
"=",
"dict",
"(",
"[",
"(",
"encode",
"(",
"k",
")",
",",
... | Inject additional query parameters into an existing URL. If
parameters already exist with the same name, they will be
overwritten. Parameters with empty values are ignored. Return
the modified URL as a string. | [
"Inject",
"additional",
"query",
"parameters",
"into",
"an",
"existing",
"URL",
".",
"If",
"parameters",
"already",
"exist",
"with",
"the",
"same",
"name",
"they",
"will",
"be",
"overwritten",
".",
"Parameters",
"with",
"empty",
"values",
"are",
"ignored",
"."... | python | train |
jason-weirather/py-seq-tools | seqtools/errors.py | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/errors.py#L346-L359 | def set_observable(self,tseq,qseq):
"""Set the observable sequence data
:param tseq: target sequence (from the homopolymer)
:param qseq: query sequence ( from the homopolymer)
:type tseq: string
:type qseq: string
"""
tnt = None
qnt = None
if len(tseq) > 0: tnt = tseq[0]
if len... | [
"def",
"set_observable",
"(",
"self",
",",
"tseq",
",",
"qseq",
")",
":",
"tnt",
"=",
"None",
"qnt",
"=",
"None",
"if",
"len",
"(",
"tseq",
")",
">",
"0",
":",
"tnt",
"=",
"tseq",
"[",
"0",
"]",
"if",
"len",
"(",
"qseq",
")",
">",
"0",
":",
... | Set the observable sequence data
:param tseq: target sequence (from the homopolymer)
:param qseq: query sequence ( from the homopolymer)
:type tseq: string
:type qseq: string | [
"Set",
"the",
"observable",
"sequence",
"data"
] | python | train |
riga/law | law/util.py | https://github.com/riga/law/blob/479f84ce06ecf3bafe9d33cb7b8fc52e39fb80a1/law/util.py#L241-L253 | def make_list(obj, cast=True):
"""
Converts an object *obj* to a list and returns it. Objects of types *tuple* and *set* are
converted if *cast* is *True*. Otherwise, and for all other types, *obj* is put in a new list.
"""
if isinstance(obj, list):
return list(obj)
elif is_lazy_iterable... | [
"def",
"make_list",
"(",
"obj",
",",
"cast",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"return",
"list",
"(",
"obj",
")",
"elif",
"is_lazy_iterable",
"(",
"obj",
")",
":",
"return",
"list",
"(",
"obj",
")",
"elif... | Converts an object *obj* to a list and returns it. Objects of types *tuple* and *set* are
converted if *cast* is *True*. Otherwise, and for all other types, *obj* is put in a new list. | [
"Converts",
"an",
"object",
"*",
"obj",
"*",
"to",
"a",
"list",
"and",
"returns",
"it",
".",
"Objects",
"of",
"types",
"*",
"tuple",
"*",
"and",
"*",
"set",
"*",
"are",
"converted",
"if",
"*",
"cast",
"*",
"is",
"*",
"True",
"*",
".",
"Otherwise",
... | python | train |
django-blog-zinnia/zinnia-wysiwyg-markitup | zinnia_markitup/admin.py | https://github.com/django-blog-zinnia/zinnia-wysiwyg-markitup/blob/8c8d45b762c0d6b00f6f13499201fe92fe7c3201/zinnia_markitup/admin.py#L55-L75 | def _media(self):
"""
The medias needed to enhance the admin page.
"""
def static_url(url):
return staticfiles_storage.url('zinnia_markitup/%s' % url)
media = super(EntryAdminMarkItUpMixin, self).media
media += Media(
js=(static_url('js/jquery.mi... | [
"def",
"_media",
"(",
"self",
")",
":",
"def",
"static_url",
"(",
"url",
")",
":",
"return",
"staticfiles_storage",
".",
"url",
"(",
"'zinnia_markitup/%s'",
"%",
"url",
")",
"media",
"=",
"super",
"(",
"EntryAdminMarkItUpMixin",
",",
"self",
")",
".",
"med... | The medias needed to enhance the admin page. | [
"The",
"medias",
"needed",
"to",
"enhance",
"the",
"admin",
"page",
"."
] | python | train |
TorkamaniLab/metapipe | metapipe/runtime.py | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/runtime.py#L34-L46 | def run(self):
""" Begins the runtime execution. """
iterations = 0
queue = self.queue.tick()
while True:
try:
next(queue)
except StopIteration:
break
iterations += 1
sleep(self.sleep_time)
return it... | [
"def",
"run",
"(",
"self",
")",
":",
"iterations",
"=",
"0",
"queue",
"=",
"self",
".",
"queue",
".",
"tick",
"(",
")",
"while",
"True",
":",
"try",
":",
"next",
"(",
"queue",
")",
"except",
"StopIteration",
":",
"break",
"iterations",
"+=",
"1",
"... | Begins the runtime execution. | [
"Begins",
"the",
"runtime",
"execution",
"."
] | python | train |
novopl/peltak | src/peltak/logic/lint.py | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/logic/lint.py#L61-L77 | def tool(name):
# type: (str) -> FunctionType
""" Decorator for defining lint tools.
Args:
name (str):
The name of the tool. This name will be used to identify the tool
in `pelconf.yaml`.
"""
global g_tools
def decorator(fn): # pylint: disable=missing-docstring... | [
"def",
"tool",
"(",
"name",
")",
":",
"# type: (str) -> FunctionType",
"global",
"g_tools",
"def",
"decorator",
"(",
"fn",
")",
":",
"# pylint: disable=missing-docstring",
"# type: (FunctionType) -> FunctionType",
"g_tools",
"[",
"name",
"]",
"=",
"fn",
"return",
"fn"... | Decorator for defining lint tools.
Args:
name (str):
The name of the tool. This name will be used to identify the tool
in `pelconf.yaml`. | [
"Decorator",
"for",
"defining",
"lint",
"tools",
"."
] | python | train |
aetros/aetros-cli | aetros/backend.py | https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1705-L1779 | def add_embedding_path(self, x, dimensions, vectors_path, metadata=None, image_shape=None, image=None):
"""
Adds a new embedding with optional metadata.
Example how to generate vectors based on 2D numpy array:
# 4 vectors, each size of 3
vectors = [
[2.3, 4.... | [
"def",
"add_embedding_path",
"(",
"self",
",",
"x",
",",
"dimensions",
",",
"vectors_path",
",",
"metadata",
"=",
"None",
",",
"image_shape",
"=",
"None",
",",
"image",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"vectors... | Adds a new embedding with optional metadata.
Example how to generate vectors based on 2D numpy array:
# 4 vectors, each size of 3
vectors = [
[2.3, 4.0, 33],
[2.4, 4.2, 44],
[2.5, 3.9, 34],
[5.5, 200.2, 66]
]
metadata = [... | [
"Adds",
"a",
"new",
"embedding",
"with",
"optional",
"metadata",
".",
"Example",
"how",
"to",
"generate",
"vectors",
"based",
"on",
"2D",
"numpy",
"array",
":"
] | python | train |
saltstack/salt | salt/modules/neutron.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/neutron.py#L1179-L1232 | def create_ipsec_site_connection(name,
ipsecpolicy,
ikepolicy,
vpnservice,
peer_cidrs,
peer_address,
peer_id,
... | [
"def",
"create_ipsec_site_connection",
"(",
"name",
",",
"ipsecpolicy",
",",
"ikepolicy",
",",
"vpnservice",
",",
"peer_cidrs",
",",
"peer_address",
",",
"peer_id",
",",
"psk",
",",
"admin_state_up",
"=",
"True",
",",
"profile",
"=",
"None",
",",
"*",
"*",
"... | Creates a new IPsecSiteConnection
CLI Example:
.. code-block:: bash
salt '*' neutron.show_ipsec_site_connection connection-name
ipsec-policy-name ikepolicy-name vpnservice-name
192.168.XXX.XXX/24 192.168.XXX.XXX 192.168.XXX.XXX secret
:param name: Set friendly nam... | [
"Creates",
"a",
"new",
"IPsecSiteConnection"
] | python | train |
penguinmenac3/starttf | starttf/utils/misc.py | https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/utils/misc.py#L63-L72 | def tf_if(condition, a, b):
"""
Implements an if condition in tensorflow.
:param condition: A boolean condition.
:param a: Case a.
:param b: Case b.
:return: A if condition was true, b otherwise.
"""
int_condition = tf.to_float(tf.to_int64(condition))
return a * int_condition + (1 - ... | [
"def",
"tf_if",
"(",
"condition",
",",
"a",
",",
"b",
")",
":",
"int_condition",
"=",
"tf",
".",
"to_float",
"(",
"tf",
".",
"to_int64",
"(",
"condition",
")",
")",
"return",
"a",
"*",
"int_condition",
"+",
"(",
"1",
"-",
"int_condition",
")",
"*",
... | Implements an if condition in tensorflow.
:param condition: A boolean condition.
:param a: Case a.
:param b: Case b.
:return: A if condition was true, b otherwise. | [
"Implements",
"an",
"if",
"condition",
"in",
"tensorflow",
".",
":",
"param",
"condition",
":",
"A",
"boolean",
"condition",
".",
":",
"param",
"a",
":",
"Case",
"a",
".",
":",
"param",
"b",
":",
"Case",
"b",
".",
":",
"return",
":",
"A",
"if",
"co... | python | train |
wonambi-python/wonambi | wonambi/widgets/traces.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/traces.py#L654-L660 | def step_next(self):
"""Go to the next step."""
window_start = around(self.parent.value('window_start') +
self.parent.value('window_length') /
self.parent.value('window_step'), 2)
self.parent.overview.update_position(window_start) | [
"def",
"step_next",
"(",
"self",
")",
":",
"window_start",
"=",
"around",
"(",
"self",
".",
"parent",
".",
"value",
"(",
"'window_start'",
")",
"+",
"self",
".",
"parent",
".",
"value",
"(",
"'window_length'",
")",
"/",
"self",
".",
"parent",
".",
"val... | Go to the next step. | [
"Go",
"to",
"the",
"next",
"step",
"."
] | python | train |
qubole/qds-sdk-py | qds_sdk/cluster.py | https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/cluster.py#L670-L679 | def snapshot(cls, cluster_id_label, s3_location, backup_type):
"""
Create hbase snapshot full/incremental
"""
conn = Qubole.agent(version=Cluster.api_version)
parameters = {}
parameters['s3_location'] = s3_location
if backup_type:
parameters['backup_ty... | [
"def",
"snapshot",
"(",
"cls",
",",
"cluster_id_label",
",",
"s3_location",
",",
"backup_type",
")",
":",
"conn",
"=",
"Qubole",
".",
"agent",
"(",
"version",
"=",
"Cluster",
".",
"api_version",
")",
"parameters",
"=",
"{",
"}",
"parameters",
"[",
"'s3_loc... | Create hbase snapshot full/incremental | [
"Create",
"hbase",
"snapshot",
"full",
"/",
"incremental"
] | python | train |
rueckstiess/mtools | mtools/util/logevent.py | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L455-L467 | def actual_query(self):
"""Extract the actual query (not pattern) from operations."""
if not self._actual_query:
# trigger evaluation of operation
if (self.operation in ['query', 'getmore', 'update', 'remove'] or
self.command in ['count', 'findandmodify']):
... | [
"def",
"actual_query",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_actual_query",
":",
"# trigger evaluation of operation",
"if",
"(",
"self",
".",
"operation",
"in",
"[",
"'query'",
",",
"'getmore'",
",",
"'update'",
",",
"'remove'",
"]",
"or",
"self... | Extract the actual query (not pattern) from operations. | [
"Extract",
"the",
"actual",
"query",
"(",
"not",
"pattern",
")",
"from",
"operations",
"."
] | python | train |
F5Networks/f5-common-python | f5/bigip/resource.py | https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L519-L594 | def _update(self, **kwargs):
"""wrapped with update, override that in a subclass to customize"""
requests_params, update_uri, session, read_only = \
self._prepare_put_or_patch(kwargs)
read_only_mutations = []
for attr in read_only:
if attr in kwargs:
... | [
"def",
"_update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"requests_params",
",",
"update_uri",
",",
"session",
",",
"read_only",
"=",
"self",
".",
"_prepare_put_or_patch",
"(",
"kwargs",
")",
"read_only_mutations",
"=",
"[",
"]",
"for",
"attr",
"i... | wrapped with update, override that in a subclass to customize | [
"wrapped",
"with",
"update",
"override",
"that",
"in",
"a",
"subclass",
"to",
"customize"
] | python | train |
libyal/dtfabric | dtfabric/runtime/data_maps.py | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1944-L1959 | def FoldByteStream(self, mapped_value, **unused_kwargs): # pylint: disable=redundant-returns-doc
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the data type definition cannot be folded int... | [
"def",
"FoldByteStream",
"(",
"self",
",",
"mapped_value",
",",
"*",
"*",
"unused_kwargs",
")",
":",
"# pylint: disable=redundant-returns-doc",
"raise",
"errors",
".",
"FoldingError",
"(",
"'Unable to fold {0:s} data type into byte stream'",
".",
"format",
"(",
"self",
... | Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the data type definition cannot be folded into
the byte stream. | [
"Folds",
"the",
"data",
"type",
"into",
"a",
"byte",
"stream",
"."
] | python | train |
hzdg/django-ecstatic | ecstatic/utils.py | https://github.com/hzdg/django-ecstatic/blob/e2b9bd57ae19938449315457b31130c8df831911/ecstatic/utils.py#L33-L46 | def get_hashed_filename(name, file, suffix=None):
"""
Gets a new filename for the provided file of the form
"oldfilename.hash.ext". If the old filename looks like it already contains a
hash, it will be replaced (so you don't end up with names like
"pic.hash.hash.ext")
"""
basename, hash, ex... | [
"def",
"get_hashed_filename",
"(",
"name",
",",
"file",
",",
"suffix",
"=",
"None",
")",
":",
"basename",
",",
"hash",
",",
"ext",
"=",
"split_filename",
"(",
"name",
")",
"file",
".",
"seek",
"(",
"0",
")",
"new_hash",
"=",
"'.%s'",
"%",
"md5",
"(",... | Gets a new filename for the provided file of the form
"oldfilename.hash.ext". If the old filename looks like it already contains a
hash, it will be replaced (so you don't end up with names like
"pic.hash.hash.ext") | [
"Gets",
"a",
"new",
"filename",
"for",
"the",
"provided",
"file",
"of",
"the",
"form",
"oldfilename",
".",
"hash",
".",
"ext",
".",
"If",
"the",
"old",
"filename",
"looks",
"like",
"it",
"already",
"contains",
"a",
"hash",
"it",
"will",
"be",
"replaced",... | python | train |
neo4j-drivers/neobolt | neobolt/impl/python/routing.py | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L153-L162 | def update(self, new_routing_table):
""" Update the current routing table with new routing information
from a replacement table.
"""
self.routers.replace(new_routing_table.routers)
self.readers.replace(new_routing_table.readers)
self.writers.replace(new_routing_table.writ... | [
"def",
"update",
"(",
"self",
",",
"new_routing_table",
")",
":",
"self",
".",
"routers",
".",
"replace",
"(",
"new_routing_table",
".",
"routers",
")",
"self",
".",
"readers",
".",
"replace",
"(",
"new_routing_table",
".",
"readers",
")",
"self",
".",
"wr... | Update the current routing table with new routing information
from a replacement table. | [
"Update",
"the",
"current",
"routing",
"table",
"with",
"new",
"routing",
"information",
"from",
"a",
"replacement",
"table",
"."
] | python | train |
hyperledger/sawtooth-core | validator/sawtooth_validator/journal/consensus/dev_mode/dev_mode_consensus.py | https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/dev_mode/dev_mode_consensus.py#L201-L254 | def compare_forks(self, cur_fork_head, new_fork_head):
"""The longest chain is selected. If they are equal, then the hash
value of the previous block id and publisher signature is computed.
The lowest result value is the winning block.
Args:
cur_fork_head: The current head of... | [
"def",
"compare_forks",
"(",
"self",
",",
"cur_fork_head",
",",
"new_fork_head",
")",
":",
"# If the new fork head is not DevMode consensus, bail out. This should",
"# never happen, but we need to protect against it.",
"if",
"new_fork_head",
".",
"consensus",
"!=",
"b\"Devmode\"",... | The longest chain is selected. If they are equal, then the hash
value of the previous block id and publisher signature is computed.
The lowest result value is the winning block.
Args:
cur_fork_head: The current head of the block chain.
new_fork_head: The head of the fork ... | [
"The",
"longest",
"chain",
"is",
"selected",
".",
"If",
"they",
"are",
"equal",
"then",
"the",
"hash",
"value",
"of",
"the",
"previous",
"block",
"id",
"and",
"publisher",
"signature",
"is",
"computed",
".",
"The",
"lowest",
"result",
"value",
"is",
"the",... | python | train |
vilmibm/done | sql_interp/sql_interp.py | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/sql_interp/sql_interp.py#L52-L77 | def esc(self, val):
"""
Returns the given object in the appropriate wrapper class from esc_types.py.
In most cases, you will not need to call this directly. However, if you are
passing a string to the interp method that should be used as an SQL bind value
and not raw SQL, you m... | [
"def",
"esc",
"(",
"self",
",",
"val",
")",
":",
"if",
"type",
"(",
"val",
")",
"in",
"self",
".",
"type_map",
":",
"return",
"self",
".",
"type_map",
"[",
"type",
"(",
"val",
")",
"]",
"(",
"val",
")",
"else",
":",
"return",
"Esc",
"(",
"val",... | Returns the given object in the appropriate wrapper class from esc_types.py.
In most cases, you will not need to call this directly. However, if you are
passing a string to the interp method that should be used as an SQL bind value
and not raw SQL, you must pass it to this method to avoid a SQ... | [
"Returns",
"the",
"given",
"object",
"in",
"the",
"appropriate",
"wrapper",
"class",
"from",
"esc_types",
".",
"py",
"."
] | python | train |
rytilahti/python-songpal | songpal/main.py | https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L453-L458 | async def settings(dev: Device):
"""Print out all possible settings."""
settings_tree = await dev.get_settings()
for module in settings_tree:
await traverse_settings(dev, module.usage, module.settings) | [
"async",
"def",
"settings",
"(",
"dev",
":",
"Device",
")",
":",
"settings_tree",
"=",
"await",
"dev",
".",
"get_settings",
"(",
")",
"for",
"module",
"in",
"settings_tree",
":",
"await",
"traverse_settings",
"(",
"dev",
",",
"module",
".",
"usage",
",",
... | Print out all possible settings. | [
"Print",
"out",
"all",
"possible",
"settings",
"."
] | python | train |
GoogleCloudPlatform/datastore-ndb-python | ndb/memcache_client.py | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/memcache_client.py#L103-L128 | def memcache_get(self, key, for_cas=False, namespace=None, use_cache=False,
deadline=None):
"""An auto-batching wrapper for memcache.get() or .get_multi().
Args:
key: Key to set. This must be a string; no prefix is applied.
for_cas: If True, request and store CAS ids on the Cont... | [
"def",
"memcache_get",
"(",
"self",
",",
"key",
",",
"for_cas",
"=",
"False",
",",
"namespace",
"=",
"None",
",",
"use_cache",
"=",
"False",
",",
"deadline",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"basestring",
")",
":",
"... | An auto-batching wrapper for memcache.get() or .get_multi().
Args:
key: Key to set. This must be a string; no prefix is applied.
for_cas: If True, request and store CAS ids on the Context.
namespace: Optional namespace.
deadline: Optional deadline for the RPC.
Returns:
A Future ... | [
"An",
"auto",
"-",
"batching",
"wrapper",
"for",
"memcache",
".",
"get",
"()",
"or",
".",
"get_multi",
"()",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/tophat.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/tophat.py#L344-L369 | def fix_insert_size(in_bam, config):
"""
Tophat sets PI in the RG to be the inner distance size, but the SAM spec
states should be the insert size. This fixes the RG in the alignment
file generated by Tophat header to match the spec
"""
fixed_file = os.path.splitext(in_bam)[0] + ".pi_fixed.bam"
... | [
"def",
"fix_insert_size",
"(",
"in_bam",
",",
"config",
")",
":",
"fixed_file",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"in_bam",
")",
"[",
"0",
"]",
"+",
"\".pi_fixed.bam\"",
"if",
"file_exists",
"(",
"fixed_file",
")",
":",
"return",
"fixed_file",
... | Tophat sets PI in the RG to be the inner distance size, but the SAM spec
states should be the insert size. This fixes the RG in the alignment
file generated by Tophat header to match the spec | [
"Tophat",
"sets",
"PI",
"in",
"the",
"RG",
"to",
"be",
"the",
"inner",
"distance",
"size",
"but",
"the",
"SAM",
"spec",
"states",
"should",
"be",
"the",
"insert",
"size",
".",
"This",
"fixes",
"the",
"RG",
"in",
"the",
"alignment",
"file",
"generated",
... | python | train |
apache/incubator-mxnet | python/mxnet/gluon/block.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/block.py#L845-L858 | def _infer_attrs(self, infer_fn, attr, *args):
"""Generic infer attributes."""
inputs, out = self._get_graph(*args)
args, _ = _flatten(args, "input")
with warnings.catch_warnings(record=True) as w:
arg_attrs, _, aux_attrs = getattr(out, infer_fn)(
**{i.name: g... | [
"def",
"_infer_attrs",
"(",
"self",
",",
"infer_fn",
",",
"attr",
",",
"*",
"args",
")",
":",
"inputs",
",",
"out",
"=",
"self",
".",
"_get_graph",
"(",
"*",
"args",
")",
"args",
",",
"_",
"=",
"_flatten",
"(",
"args",
",",
"\"input\"",
")",
"with"... | Generic infer attributes. | [
"Generic",
"infer",
"attributes",
"."
] | python | train |
rm-hull/luma.core | luma/core/legacy/__init__.py | https://github.com/rm-hull/luma.core/blob/034b628fb304a01e77732a299c0b42e94d6443db/luma/core/legacy/__init__.py#L61-L93 | def show_message(device, msg, y_offset=0, fill=None, font=None,
scroll_delay=0.03):
"""
Scrolls a message right-to-left across the devices display.
:param device: The device to scroll across.
:param msg: The text message to display (must be ASCII only).
:type msg: str
:param y_... | [
"def",
"show_message",
"(",
"device",
",",
"msg",
",",
"y_offset",
"=",
"0",
",",
"fill",
"=",
"None",
",",
"font",
"=",
"None",
",",
"scroll_delay",
"=",
"0.03",
")",
":",
"fps",
"=",
"0",
"if",
"scroll_delay",
"==",
"0",
"else",
"1.0",
"/",
"scro... | Scrolls a message right-to-left across the devices display.
:param device: The device to scroll across.
:param msg: The text message to display (must be ASCII only).
:type msg: str
:param y_offset: The row to use to display the text.
:type y_offset: int
:param fill: The fill color to use (stand... | [
"Scrolls",
"a",
"message",
"right",
"-",
"to",
"-",
"left",
"across",
"the",
"devices",
"display",
"."
] | python | train |
jedie/DragonPy | dragonpy/utils/srecord_utils.py | https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/srecord_utils.py#L161-L172 | def parse_srec(srec):
"""
Extract the data portion of a given S-Record (without checksum)
Returns: the record type, the lenght of the data section, the write address, the data itself and the checksum
"""
record_type = srec[0:2]
data_len = srec[2:4]
addr_len = __ADDR_LEN.get(record_ty... | [
"def",
"parse_srec",
"(",
"srec",
")",
":",
"record_type",
"=",
"srec",
"[",
"0",
":",
"2",
"]",
"data_len",
"=",
"srec",
"[",
"2",
":",
"4",
"]",
"addr_len",
"=",
"__ADDR_LEN",
".",
"get",
"(",
"record_type",
")",
"*",
"2",
"addr",
"=",
"srec",
... | Extract the data portion of a given S-Record (without checksum)
Returns: the record type, the lenght of the data section, the write address, the data itself and the checksum | [
"Extract",
"the",
"data",
"portion",
"of",
"a",
"given",
"S",
"-",
"Record",
"(",
"without",
"checksum",
")",
"Returns",
":",
"the",
"record",
"type",
"the",
"lenght",
"of",
"the",
"data",
"section",
"the",
"write",
"address",
"the",
"data",
"itself",
"a... | python | train |
AnalogJ/lexicon | lexicon/providers/subreg.py | https://github.com/AnalogJ/lexicon/blob/9330b871988753cad44fe2876a217b4c67b1fa0e/lexicon/providers/subreg.py#L278-L282 | def _request_delete_dns_record_by_id(self, identifier):
"""Sends Delete_DNS_Record request"""
return self._request_internal("Delete_DNS_Record",
domain=self.domain,
record={'id': identifier}) | [
"def",
"_request_delete_dns_record_by_id",
"(",
"self",
",",
"identifier",
")",
":",
"return",
"self",
".",
"_request_internal",
"(",
"\"Delete_DNS_Record\"",
",",
"domain",
"=",
"self",
".",
"domain",
",",
"record",
"=",
"{",
"'id'",
":",
"identifier",
"}",
"... | Sends Delete_DNS_Record request | [
"Sends",
"Delete_DNS_Record",
"request"
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/django/fields/jsonclassfield.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/jsonclassfield.py#L161-L178 | def to_python(self, value):
"""
"Called during deserialization and during the clean() method used
from forms.... [s]hould deal gracefully with... (*) an instance of
the correct type; (*) a string; (*) None (if the field allows
null=True)."
"For ``to_python()``, if anythi... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"value",
"if",
"not",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"value",
"try",
":",
"return",
"json_decode",
"(",
"value",
")",
"e... | "Called during deserialization and during the clean() method used
from forms.... [s]hould deal gracefully with... (*) an instance of
the correct type; (*) a string; (*) None (if the field allows
null=True)."
"For ``to_python()``, if anything goes wrong during value conversion,
y... | [
"Called",
"during",
"deserialization",
"and",
"during",
"the",
"clean",
"()",
"method",
"used",
"from",
"forms",
"....",
"[",
"s",
"]",
"hould",
"deal",
"gracefully",
"with",
"...",
"(",
"*",
")",
"an",
"instance",
"of",
"the",
"correct",
"type",
";",
"(... | python | train |
tehmaze/natural | natural/phone.py | https://github.com/tehmaze/natural/blob/d7a1fc9de712f9bcf68884a80826a7977df356fb/natural/phone.py#L234-L246 | def pesn(number, separator=u''):
'''
Printable Pseudo Electronic Serial Number.
:param number: hexadecimal string
>>> print(pesn('1B69B4BA630F34E'))
805F9EF7
'''
number = re.sub(r'[\s-]', '', meid(number))
serial = hashlib.sha1(unhexlify(number[:14]))
return separator.join(['80', ... | [
"def",
"pesn",
"(",
"number",
",",
"separator",
"=",
"u''",
")",
":",
"number",
"=",
"re",
".",
"sub",
"(",
"r'[\\s-]'",
",",
"''",
",",
"meid",
"(",
"number",
")",
")",
"serial",
"=",
"hashlib",
".",
"sha1",
"(",
"unhexlify",
"(",
"number",
"[",
... | Printable Pseudo Electronic Serial Number.
:param number: hexadecimal string
>>> print(pesn('1B69B4BA630F34E'))
805F9EF7 | [
"Printable",
"Pseudo",
"Electronic",
"Serial",
"Number",
"."
] | python | train |
six8/polydatum | src/polydatum/resources.py | https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/resources.py#L54-L62 | def register_resources(self, **resources):
"""
Register resources with the ResourceManager.
"""
for key, resource in resources.items():
if key in self._resources:
raise AlreadyExistsException('A Service for {} is already registered.'.format(key))
... | [
"def",
"register_resources",
"(",
"self",
",",
"*",
"*",
"resources",
")",
":",
"for",
"key",
",",
"resource",
"in",
"resources",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"self",
".",
"_resources",
":",
"raise",
"AlreadyExistsException",
"(",
"'A ... | Register resources with the ResourceManager. | [
"Register",
"resources",
"with",
"the",
"ResourceManager",
"."
] | python | test |
fastai/fastai | docs_src/nbval/kernel.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/docs_src/nbval/kernel.py#L200-L208 | def stop(self):
"""
Instructs the kernel process to stop channels
and the kernel manager to then shutdown the process.
"""
logger.debug('Stopping kernel')
self.kc.stop_channels()
self.km.shutdown_kernel(now=True)
del self.km | [
"def",
"stop",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Stopping kernel'",
")",
"self",
".",
"kc",
".",
"stop_channels",
"(",
")",
"self",
".",
"km",
".",
"shutdown_kernel",
"(",
"now",
"=",
"True",
")",
"del",
"self",
".",
"km"
] | Instructs the kernel process to stop channels
and the kernel manager to then shutdown the process. | [
"Instructs",
"the",
"kernel",
"process",
"to",
"stop",
"channels",
"and",
"the",
"kernel",
"manager",
"to",
"then",
"shutdown",
"the",
"process",
"."
] | python | train |
pyokagan/pyglreg | glreg.py | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L659-L667 | def _load_enums(root):
"""Returns {name: Enum}"""
out = collections.OrderedDict()
for elem in root.findall('enums/enum'):
name = elem.attrib['name']
value = elem.attrib['value']
comment = elem.get('comment')
out[name] = Enum(name, value, comment)
return out | [
"def",
"_load_enums",
"(",
"root",
")",
":",
"out",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"elem",
"in",
"root",
".",
"findall",
"(",
"'enums/enum'",
")",
":",
"name",
"=",
"elem",
".",
"attrib",
"[",
"'name'",
"]",
"value",
"=",
"e... | Returns {name: Enum} | [
"Returns",
"{",
"name",
":",
"Enum",
"}"
] | python | train |
vmware/nsxramlclient | nsxramlclient/http_session.py | https://github.com/vmware/nsxramlclient/blob/2ff892f9fb6c6bad411df2258e3a98475d0d5091/nsxramlclient/http_session.py#L78-L127 | def do_request(self, method, url, data=None, headers=None, params=None):
"""
Handle API requests / responses transport
:param method: HTTP method to use as string
:param data: Any data as PyDict (will be converted to XML string)
:param headers: Any data as PyDict
:return... | [
"def",
"do_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"response_content",
"=",
"None",
"if",
"data",
":",
"if",
"headers",
":",
"headers",
".",
"updat... | Handle API requests / responses transport
:param method: HTTP method to use as string
:param data: Any data as PyDict (will be converted to XML string)
:param headers: Any data as PyDict
:return: If response is XML then an xml.etree.ElementTree else the raw content
:raise: Any u... | [
"Handle",
"API",
"requests",
"/",
"responses",
"transport"
] | python | train |
annoviko/pyclustering | pyclustering/container/cftree.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/container/cftree.py#L1042-L1092 | def __insert_for_noneleaf_node(self, entry, search_node):
"""!
@brief Recursive insert entry from none-leaf node to the tree.
@param[in] entry (cfentry): Clustering feature.
@param[in] search_node (cfnode): None-leaf node from that insertion should be started.
... | [
"def",
"__insert_for_noneleaf_node",
"(",
"self",
",",
"entry",
",",
"search_node",
")",
":",
"node_amount_updation",
"=",
"False",
"min_key",
"=",
"lambda",
"child_node",
":",
"child_node",
".",
"get_distance",
"(",
"search_node",
",",
"self",
".",
"__type_measur... | !
@brief Recursive insert entry from none-leaf node to the tree.
@param[in] entry (cfentry): Clustering feature.
@param[in] search_node (cfnode): None-leaf node from that insertion should be started.
@return (bool) True if number of nodes at the below level is cha... | [
"!"
] | python | valid |
saltstack/salt | salt/modules/boto_elasticache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L540-L581 | def create(name, num_cache_nodes=None, engine=None, cache_node_type=None,
replication_group_id=None, engine_version=None,
cache_parameter_group_name=None, cache_subnet_group_name=None,
cache_security_group_names=None, security_group_ids=None,
snapshot_arns=None, preferred_ava... | [
"def",
"create",
"(",
"name",
",",
"num_cache_nodes",
"=",
"None",
",",
"engine",
"=",
"None",
",",
"cache_node_type",
"=",
"None",
",",
"replication_group_id",
"=",
"None",
",",
"engine_version",
"=",
"None",
",",
"cache_parameter_group_name",
"=",
"None",
",... | Create a cache cluster.
CLI example::
salt myminion boto_elasticache.create myelasticache 1 redis cache.t1.micro
cache_security_group_names='["myelasticachesg"]' | [
"Create",
"a",
"cache",
"cluster",
"."
] | python | train |
mozilla/FoxPuppet | foxpuppet/windows/browser/notifications/addons.py | https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/notifications/addons.py#L35-L38 | def cancel(self):
"""Cancel add-on install."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.find_secondary_button().click() | [
"def",
"cancel",
"(",
"self",
")",
":",
"with",
"self",
".",
"selenium",
".",
"context",
"(",
"self",
".",
"selenium",
".",
"CONTEXT_CHROME",
")",
":",
"self",
".",
"find_secondary_button",
"(",
")",
".",
"click",
"(",
")"
] | Cancel add-on install. | [
"Cancel",
"add",
"-",
"on",
"install",
"."
] | python | train |
xtrementl/focus | focus/plugin/modules/stats.py | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/stats.py#L114-L152 | def _fuzzy_time_parse(self, value):
""" Parses a fuzzy time value into a meaningful interpretation.
`value`
String value to parse.
"""
value = value.lower().strip()
today = datetime.date.today()
if value in ('today', 't'):
return tod... | [
"def",
"_fuzzy_time_parse",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
"today",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"if",
"value",
"in",
"(",
"'today'",
",",
"'t'",
... | Parses a fuzzy time value into a meaningful interpretation.
`value`
String value to parse. | [
"Parses",
"a",
"fuzzy",
"time",
"value",
"into",
"a",
"meaningful",
"interpretation",
"."
] | python | train |
clalancette/pycdlib | pycdlib/udf.py | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L2169-L2184 | def new(self):
# type: () -> None
'''
A method to create a new UDF Logical Volume Header Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Logical Volume Header... | [
"def",
"new",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF Logical Volume Header Descriptor already initialized'",
")",
"self",
".",
"unique_id",
"=",
"261",
"... | A method to create a new UDF Logical Volume Header Descriptor.
Parameters:
None.
Returns:
Nothing. | [
"A",
"method",
"to",
"create",
"a",
"new",
"UDF",
"Logical",
"Volume",
"Header",
"Descriptor",
"."
] | python | train |
rsheftel/raccoon | raccoon/series.py | https://github.com/rsheftel/raccoon/blob/e5c4b5fb933b51f33aff11e8168c39790e9a7c75/raccoon/series.py#L455-L467 | def _insert_row(self, i, index):
"""
Insert a new row in the Series.
:param i: index location to insert
:param index: index value to insert into the index list
:return: nothing
"""
if i == len(self._index):
self._add_row(index)
else:
... | [
"def",
"_insert_row",
"(",
"self",
",",
"i",
",",
"index",
")",
":",
"if",
"i",
"==",
"len",
"(",
"self",
".",
"_index",
")",
":",
"self",
".",
"_add_row",
"(",
"index",
")",
"else",
":",
"self",
".",
"_index",
".",
"insert",
"(",
"i",
",",
"in... | Insert a new row in the Series.
:param i: index location to insert
:param index: index value to insert into the index list
:return: nothing | [
"Insert",
"a",
"new",
"row",
"in",
"the",
"Series",
"."
] | python | train |
wooyek/django-powerbank | src/django_powerbank/views/mixins.py | https://github.com/wooyek/django-powerbank/blob/df91189f2ac18bacc545ccf3c81c4465fb993949/src/django_powerbank/views/mixins.py#L25-L50 | def dispatch(self, request, *args, **kwargs):
"""
Does request processing for return_url query parameter and redirects with it's missing
We can't do that in the get method, as it does not exist in the View base class
and child mixins implementing get do not call super().get
"""
... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"return_url",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'return_url'",
",",
"None",
")",
"referrer",
"=",
"request",
".",
"META",
... | Does request processing for return_url query parameter and redirects with it's missing
We can't do that in the get method, as it does not exist in the View base class
and child mixins implementing get do not call super().get | [
"Does",
"request",
"processing",
"for",
"return_url",
"query",
"parameter",
"and",
"redirects",
"with",
"it",
"s",
"missing"
] | python | train |
senaite/senaite.core.supermodel | src/senaite/core/supermodel/model.py | https://github.com/senaite/senaite.core.supermodel/blob/1819154332b8776f187aa98a2e299701983a0119/src/senaite/core/supermodel/model.py#L260-L266 | def get_catalog_for(self, brain_or_object):
"""Return the primary catalog for the given brain or object
"""
if not api.is_object(brain_or_object):
raise TypeError("Invalid object type %r" % brain_or_object)
catalogs = api.get_catalogs_for(brain_or_object, default="uid_catalog... | [
"def",
"get_catalog_for",
"(",
"self",
",",
"brain_or_object",
")",
":",
"if",
"not",
"api",
".",
"is_object",
"(",
"brain_or_object",
")",
":",
"raise",
"TypeError",
"(",
"\"Invalid object type %r\"",
"%",
"brain_or_object",
")",
"catalogs",
"=",
"api",
".",
... | Return the primary catalog for the given brain or object | [
"Return",
"the",
"primary",
"catalog",
"for",
"the",
"given",
"brain",
"or",
"object"
] | python | train |
AirtestProject/Airtest | benchmark/plot.py | https://github.com/AirtestProject/Airtest/blob/21583da2698a601cd632228228fc16d41f60a517/benchmark/plot.py#L97-L104 | def _get_graph_title(self):
"""获取图像的title."""
start_time = datetime.fromtimestamp(int(self.timestamp_list[0]))
end_time = datetime.fromtimestamp(int(self.timestamp_list[-1]))
end_time = end_time.strftime('%H:%M:%S')
title = "Timespan: %s —— %s" % (start_time, end_time)
r... | [
"def",
"_get_graph_title",
"(",
"self",
")",
":",
"start_time",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"int",
"(",
"self",
".",
"timestamp_list",
"[",
"0",
"]",
")",
")",
"end_time",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"int",
"(",
"self",
".... | 获取图像的title. | [
"获取图像的title",
"."
] | python | train |
eventbrite/eventbrite-sdk-python | eventbrite/access_methods.py | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/access_methods.py#L700-L706 | def get_tracking_beacon(self, tracking_beacons_id, **data):
"""
GET /tracking_beacons/:tracking_beacons_id/
Returns the :format:`tracking_beacon` with the specified :tracking_beacons_id.
"""
return self.get("/tracking_beacons/{0}/".format(tracking_beacons_id), data=data) | [
"def",
"get_tracking_beacon",
"(",
"self",
",",
"tracking_beacons_id",
",",
"*",
"*",
"data",
")",
":",
"return",
"self",
".",
"get",
"(",
"\"/tracking_beacons/{0}/\"",
".",
"format",
"(",
"tracking_beacons_id",
")",
",",
"data",
"=",
"data",
")"
] | GET /tracking_beacons/:tracking_beacons_id/
Returns the :format:`tracking_beacon` with the specified :tracking_beacons_id. | [
"GET",
"/",
"tracking_beacons",
"/",
":",
"tracking_beacons_id",
"/",
"Returns",
"the",
":",
"format",
":",
"tracking_beacon",
"with",
"the",
"specified",
":",
"tracking_beacons_id",
"."
] | python | train |
ludeeus/pyruter | pyruter/common.py | https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/common.py#L20-L33 | async def api_call(self, endpoint):
"""Call the API."""
data = None
if self.session is None:
self.session = aiohttp.ClientSession()
try:
async with async_timeout.timeout(5, loop=self.loop):
response = await self.session.get(endpoint, headers=HEADER... | [
"async",
"def",
"api_call",
"(",
"self",
",",
"endpoint",
")",
":",
"data",
"=",
"None",
"if",
"self",
".",
"session",
"is",
"None",
":",
"self",
".",
"session",
"=",
"aiohttp",
".",
"ClientSession",
"(",
")",
"try",
":",
"async",
"with",
"async_timeou... | Call the API. | [
"Call",
"the",
"API",
"."
] | python | train |
gmr/tredis | tredis/keys.py | https://github.com/gmr/tredis/blob/2e91c6a58a35460be0525c51ac6a98fde3b506ad/tredis/keys.py#L86-L126 | def expire(self, key, timeout):
"""Set a timeout on key. After the timeout has expired, the key will
automatically be deleted. A key with an associated timeout is often
said to be volatile in Redis terminology.
The timeout is cleared only when the key is removed using the
:meth:... | [
"def",
"expire",
"(",
"self",
",",
"key",
",",
"timeout",
")",
":",
"return",
"self",
".",
"_execute",
"(",
"[",
"b'EXPIRE'",
",",
"key",
",",
"ascii",
"(",
"timeout",
")",
".",
"encode",
"(",
"'ascii'",
")",
"]",
",",
"1",
")"
] | Set a timeout on key. After the timeout has expired, the key will
automatically be deleted. A key with an associated timeout is often
said to be volatile in Redis terminology.
The timeout is cleared only when the key is removed using the
:meth:`~tredis.RedisClient.delete` method or over... | [
"Set",
"a",
"timeout",
"on",
"key",
".",
"After",
"the",
"timeout",
"has",
"expired",
"the",
"key",
"will",
"automatically",
"be",
"deleted",
".",
"A",
"key",
"with",
"an",
"associated",
"timeout",
"is",
"often",
"said",
"to",
"be",
"volatile",
"in",
"Re... | python | train |
JnyJny/Geometry | Geometry/triangle2.py | https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle2.py#L238-L244 | def circumradius(self):
'''
Distance from the circumcenter to all the verticies in
the Triangle, float.
'''
return (self.a * self.b * self.c) / (self.area * 4) | [
"def",
"circumradius",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"a",
"*",
"self",
".",
"b",
"*",
"self",
".",
"c",
")",
"/",
"(",
"self",
".",
"area",
"*",
"4",
")"
] | Distance from the circumcenter to all the verticies in
the Triangle, float. | [
"Distance",
"from",
"the",
"circumcenter",
"to",
"all",
"the",
"verticies",
"in",
"the",
"Triangle",
"float",
"."
] | python | train |
OpenKMIP/PyKMIP | kmip/services/server/monitor.py | https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/services/server/monitor.py#L135-L148 | def run(self):
"""
Start monitoring operation policy files.
"""
self.initialize_tracking_structures()
if self.live_monitoring:
self.logger.info("Starting up the operation policy file monitor.")
while not self.halt_trigger.is_set():
time.sl... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"initialize_tracking_structures",
"(",
")",
"if",
"self",
".",
"live_monitoring",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Starting up the operation policy file monitor.\"",
")",
"while",
"not",
"self",
"... | Start monitoring operation policy files. | [
"Start",
"monitoring",
"operation",
"policy",
"files",
"."
] | python | test |
andymccurdy/redis-py | redis/connection.py | https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/connection.py#L1109-L1156 | def get_connection(self, command_name, *keys, **options):
"""
Get a connection, blocking for ``self.timeout`` until a connection
is available from the pool.
If the connection returned is ``None`` then creates a new connection.
Because we use a last-in first-out queue, the existi... | [
"def",
"get_connection",
"(",
"self",
",",
"command_name",
",",
"*",
"keys",
",",
"*",
"*",
"options",
")",
":",
"# Make sure we haven't changed process.",
"self",
".",
"_checkpid",
"(",
")",
"# Try and get a connection from the pool. If one isn't available within",
"# se... | Get a connection, blocking for ``self.timeout`` until a connection
is available from the pool.
If the connection returned is ``None`` then creates a new connection.
Because we use a last-in first-out queue, the existing connections
(having been returned to the pool after the initial ``N... | [
"Get",
"a",
"connection",
"blocking",
"for",
"self",
".",
"timeout",
"until",
"a",
"connection",
"is",
"available",
"from",
"the",
"pool",
"."
] | python | train |
pypa/setuptools | setuptools/command/bdist_egg.py | https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/bdist_egg.py#L43-L50 | def sorted_walk(dir):
"""Do os.walk in a reproducible way,
independent of indeterministic filesystem readdir order
"""
for base, dirs, files in os.walk(dir):
dirs.sort()
files.sort()
yield base, dirs, files | [
"def",
"sorted_walk",
"(",
"dir",
")",
":",
"for",
"base",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"dir",
")",
":",
"dirs",
".",
"sort",
"(",
")",
"files",
".",
"sort",
"(",
")",
"yield",
"base",
",",
"dirs",
",",
"files"
] | Do os.walk in a reproducible way,
independent of indeterministic filesystem readdir order | [
"Do",
"os",
".",
"walk",
"in",
"a",
"reproducible",
"way",
"independent",
"of",
"indeterministic",
"filesystem",
"readdir",
"order"
] | python | train |
SamLau95/nbinteract | nbinteract/cli.py | https://github.com/SamLau95/nbinteract/blob/9f346452283831aad3f4416c04879f1d187ec3b7/nbinteract/cli.py#L174-L218 | def run_converter(arguments):
"""
Converts notebooks to HTML files. Returns list of output file paths
"""
# Get spec from config file
if os.path.isfile(CONFIG_FILE):
with open(CONFIG_FILE, encoding='utf-8') as f:
config = json.load(f)
arguments['--spec'] = arguments['... | [
"def",
"run_converter",
"(",
"arguments",
")",
":",
"# Get spec from config file",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"CONFIG_FILE",
")",
":",
"with",
"open",
"(",
"CONFIG_FILE",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"config",
"="... | Converts notebooks to HTML files. Returns list of output file paths | [
"Converts",
"notebooks",
"to",
"HTML",
"files",
".",
"Returns",
"list",
"of",
"output",
"file",
"paths"
] | python | train |
PolyJIT/benchbuild | benchbuild/likwid.py | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/likwid.py#L54-L90 | def read_table(fstream):
"""
Read a likwid table info from the text stream.
Args:
fstream: Likwid's filestream.
Returns (dict(str: str)):
A dict containing likwid's table info as key/value pairs.
"""
pos = fstream.tell()
line = fstream.readline().strip()
fragments = lin... | [
"def",
"read_table",
"(",
"fstream",
")",
":",
"pos",
"=",
"fstream",
".",
"tell",
"(",
")",
"line",
"=",
"fstream",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"fragments",
"=",
"line",
".",
"split",
"(",
"\",\"",
")",
"fragments",
"=",
"["... | Read a likwid table info from the text stream.
Args:
fstream: Likwid's filestream.
Returns (dict(str: str)):
A dict containing likwid's table info as key/value pairs. | [
"Read",
"a",
"likwid",
"table",
"info",
"from",
"the",
"text",
"stream",
"."
] | python | train |
amelchio/pysonos | pysonos/discovery.py | https://github.com/amelchio/pysonos/blob/23527c445a00e198fbb94d44b92f7f99d139e325/pysonos/discovery.py#L162-L171 | def discover_thread(callback,
timeout=5,
include_invisible=False,
interface_addr=None):
""" Return a started thread with a discovery callback. """
thread = StoppableThread(
target=_discover_thread,
args=(callback, timeout, include_invis... | [
"def",
"discover_thread",
"(",
"callback",
",",
"timeout",
"=",
"5",
",",
"include_invisible",
"=",
"False",
",",
"interface_addr",
"=",
"None",
")",
":",
"thread",
"=",
"StoppableThread",
"(",
"target",
"=",
"_discover_thread",
",",
"args",
"=",
"(",
"callb... | Return a started thread with a discovery callback. | [
"Return",
"a",
"started",
"thread",
"with",
"a",
"discovery",
"callback",
"."
] | python | train |
Bystroushaak/BalancedDiscStorage | src/BalancedDiscStorage/balanced_disc_storage_z.py | https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage_z.py#L57-L90 | def add_archive_as_dir(self, zip_file_obj):
"""
Add archive to the storage and unpack it.
Args:
zip_file_obj (file): Opened file-like object.
Returns:
obj: Path where the `zip_file_obj` was unpacked wrapped in \
:class:`.PathAndHash` structure.
... | [
"def",
"add_archive_as_dir",
"(",
"self",
",",
"zip_file_obj",
")",
":",
"BalancedDiscStorage",
".",
"_check_interface",
"(",
"zip_file_obj",
")",
"file_hash",
"=",
"self",
".",
"_get_hash",
"(",
"zip_file_obj",
")",
"dir_path",
"=",
"self",
".",
"_create_dir_path... | Add archive to the storage and unpack it.
Args:
zip_file_obj (file): Opened file-like object.
Returns:
obj: Path where the `zip_file_obj` was unpacked wrapped in \
:class:`.PathAndHash` structure.
Raises:
ValueError: If there is too many fi... | [
"Add",
"archive",
"to",
"the",
"storage",
"and",
"unpack",
"it",
"."
] | python | train |
markovmodel/msmtools | msmtools/flux/dense/tpt.py | https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/flux/dense/tpt.py#L104-L120 | def flux_production(F):
r"""Returns the net flux production for all states
Parameters
----------
F : (n, n) ndarray
Matrix of flux values between pairs of states.
Returns
-------
prod : (n) ndarray
array with flux production (positive) or consumption (negative) at each stat... | [
"def",
"flux_production",
"(",
"F",
")",
":",
"influxes",
"=",
"np",
".",
"array",
"(",
"np",
".",
"sum",
"(",
"F",
",",
"axis",
"=",
"0",
")",
")",
".",
"flatten",
"(",
")",
"# all that flows in",
"outfluxes",
"=",
"np",
".",
"array",
"(",
"np",
... | r"""Returns the net flux production for all states
Parameters
----------
F : (n, n) ndarray
Matrix of flux values between pairs of states.
Returns
-------
prod : (n) ndarray
array with flux production (positive) or consumption (negative) at each state | [
"r",
"Returns",
"the",
"net",
"flux",
"production",
"for",
"all",
"states"
] | python | train |
brechtm/rinohtype | src/rinoh/attribute.py | https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/attribute.py#L298-L309 | def _get_default(cls, attribute):
"""Return the default value for `attribute`.
If no default is specified in this style, get the default from the
nearest superclass.
If `attribute` is not supported, raise a :class:`KeyError`."""
try:
for klass in cls.__mro__:
... | [
"def",
"_get_default",
"(",
"cls",
",",
"attribute",
")",
":",
"try",
":",
"for",
"klass",
"in",
"cls",
".",
"__mro__",
":",
"if",
"attribute",
"in",
"klass",
".",
"_attributes",
":",
"return",
"klass",
".",
"_attributes",
"[",
"attribute",
"]",
".",
"... | Return the default value for `attribute`.
If no default is specified in this style, get the default from the
nearest superclass.
If `attribute` is not supported, raise a :class:`KeyError`. | [
"Return",
"the",
"default",
"value",
"for",
"attribute",
"."
] | python | train |
tmr232/Sark | sark/code/function.py | https://github.com/tmr232/Sark/blob/bee62879c2aea553a3924d887e2b30f2a6008581/sark/code/function.py#L336-L342 | def color(self):
"""Function color in IDA View"""
color = idc.GetColor(self.ea, idc.CIC_FUNC)
if color == 0xFFFFFFFF:
return None
return color | [
"def",
"color",
"(",
"self",
")",
":",
"color",
"=",
"idc",
".",
"GetColor",
"(",
"self",
".",
"ea",
",",
"idc",
".",
"CIC_FUNC",
")",
"if",
"color",
"==",
"0xFFFFFFFF",
":",
"return",
"None",
"return",
"color"
] | Function color in IDA View | [
"Function",
"color",
"in",
"IDA",
"View"
] | python | train |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L26-L33 | def find_analysis(self, family, started_at, status):
"""Find a single analysis."""
query = self.Analysis.query.filter_by(
family=family,
started_at=started_at,
status=status,
)
return query.first() | [
"def",
"find_analysis",
"(",
"self",
",",
"family",
",",
"started_at",
",",
"status",
")",
":",
"query",
"=",
"self",
".",
"Analysis",
".",
"query",
".",
"filter_by",
"(",
"family",
"=",
"family",
",",
"started_at",
"=",
"started_at",
",",
"status",
"=",... | Find a single analysis. | [
"Find",
"a",
"single",
"analysis",
"."
] | python | train |
HPAC/matchpy | matchpy/matching/syntactic.py | https://github.com/HPAC/matchpy/blob/06b2ec50ee0efdf3dd183768c0ffdb51b7efc393/matchpy/matching/syntactic.py#L750-L790 | def add(self, pattern: Pattern) -> int:
"""Add a pattern that will be recognized by the matcher.
Args:
pattern:
The pattern to add.
Returns:
An internal index for the pattern.
Raises:
ValueError:
If the pattern does n... | [
"def",
"add",
"(",
"self",
",",
"pattern",
":",
"Pattern",
")",
"->",
"int",
":",
"inner",
"=",
"pattern",
".",
"expression",
"if",
"self",
".",
"operation",
"is",
"None",
":",
"if",
"not",
"isinstance",
"(",
"inner",
",",
"Operation",
")",
"or",
"is... | Add a pattern that will be recognized by the matcher.
Args:
pattern:
The pattern to add.
Returns:
An internal index for the pattern.
Raises:
ValueError:
If the pattern does not have the correct form.
TypeError:
... | [
"Add",
"a",
"pattern",
"that",
"will",
"be",
"recognized",
"by",
"the",
"matcher",
"."
] | python | train |
tehmaze/diagram | diagram.py | https://github.com/tehmaze/diagram/blob/1701526a91c14dc8ebc6452c45c8ec9a563a56db/diagram.py#L466-L480 | def human(self, size, base=1000, units=' kMGTZ'):
"""Convert the input ``size`` to human readable, short form."""
sign = '+' if size >= 0 else '-'
size = abs(size)
if size < 1000:
return '%s%d' % (sign, size)
for i, suffix in enumerate(units):
unit = 1000 ... | [
"def",
"human",
"(",
"self",
",",
"size",
",",
"base",
"=",
"1000",
",",
"units",
"=",
"' kMGTZ'",
")",
":",
"sign",
"=",
"'+'",
"if",
"size",
">=",
"0",
"else",
"'-'",
"size",
"=",
"abs",
"(",
"size",
")",
"if",
"size",
"<",
"1000",
":",
"retu... | Convert the input ``size`` to human readable, short form. | [
"Convert",
"the",
"input",
"size",
"to",
"human",
"readable",
"short",
"form",
"."
] | python | valid |
ethereum/web3.py | web3/contract.py | https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/contract.py#L1065-L1161 | def getLogs(self,
argument_filters=None,
fromBlock=None,
toBlock=None,
blockHash=None):
"""Get events for this contract instance using eth_getLogs API.
This is a stateless method, as opposed to createFilter.
It can be safely called... | [
"def",
"getLogs",
"(",
"self",
",",
"argument_filters",
"=",
"None",
",",
"fromBlock",
"=",
"None",
",",
"toBlock",
"=",
"None",
",",
"blockHash",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"address",
":",
"raise",
"TypeError",
"(",
"\"This method ... | Get events for this contract instance using eth_getLogs API.
This is a stateless method, as opposed to createFilter.
It can be safely called against nodes which do not provide
eth_newFilter API, like Infura nodes.
If there are many events,
like ``Transfer`` events for a popular... | [
"Get",
"events",
"for",
"this",
"contract",
"instance",
"using",
"eth_getLogs",
"API",
"."
] | python | train |
danilobellini/audiolazy | audiolazy/lazy_auditory.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_auditory.py#L158-L182 | def gammatone(freq, bandwidth, phase=0, eta=4):
"""
``Bellini, D. J. S. "AudioLazy: Processamento digital de sinais
expressivo e em tempo real", IME-USP, Mastership Thesis, 2013.``
This implementation have the impulse response (for each sample ``n``,
keeping the input parameter names):
.. math::
... | [
"def",
"gammatone",
"(",
"freq",
",",
"bandwidth",
",",
"phase",
"=",
"0",
",",
"eta",
"=",
"4",
")",
":",
"assert",
"eta",
">=",
"1",
"A",
"=",
"exp",
"(",
"-",
"bandwidth",
")",
"numerator",
"=",
"cos",
"(",
"phase",
")",
"-",
"A",
"*",
"cos"... | ``Bellini, D. J. S. "AudioLazy: Processamento digital de sinais
expressivo e em tempo real", IME-USP, Mastership Thesis, 2013.``
This implementation have the impulse response (for each sample ``n``,
keeping the input parameter names):
.. math::
n^{{eta - 1}} e^{{- bandwidth \cdot n}} \cos(freq \cdot n ... | [
"Bellini",
"D",
".",
"J",
".",
"S",
".",
"AudioLazy",
":",
"Processamento",
"digital",
"de",
"sinais",
"expressivo",
"e",
"em",
"tempo",
"real",
"IME",
"-",
"USP",
"Mastership",
"Thesis",
"2013",
"."
] | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/mongo_client.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/mongo_client.py#L802-L814 | def _is_writable(self):
"""Attempt to connect to a writable server, or return False.
"""
topology = self._get_topology() # Starts monitors if necessary.
try:
svr = topology.select_server(writable_server_selector)
# When directly connected to a secondary, arbiter... | [
"def",
"_is_writable",
"(",
"self",
")",
":",
"topology",
"=",
"self",
".",
"_get_topology",
"(",
")",
"# Starts monitors if necessary.",
"try",
":",
"svr",
"=",
"topology",
".",
"select_server",
"(",
"writable_server_selector",
")",
"# When directly connected to a se... | Attempt to connect to a writable server, or return False. | [
"Attempt",
"to",
"connect",
"to",
"a",
"writable",
"server",
"or",
"return",
"False",
"."
] | python | train |
spyder-ide/spyder | spyder/plugins/help/plugin.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L332-L334 | def set_plain_text_font(self, font, color_scheme=None):
"""Set plain text mode font"""
self.plain_text.set_font(font, color_scheme=color_scheme) | [
"def",
"set_plain_text_font",
"(",
"self",
",",
"font",
",",
"color_scheme",
"=",
"None",
")",
":",
"self",
".",
"plain_text",
".",
"set_font",
"(",
"font",
",",
"color_scheme",
"=",
"color_scheme",
")"
] | Set plain text mode font | [
"Set",
"plain",
"text",
"mode",
"font"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.