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
calmjs/calmjs
src/calmjs/dist.py
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/dist.py#L162-L173
def find_packages_requirements_dists(pkg_names, working_set=None): """ Return the entire list of dependency requirements, reversed from the bottom. """ working_set = working_set or default_working_set requirements = [ r for r in (Requirement.parse(req) for req in pkg_names) if w...
[ "def", "find_packages_requirements_dists", "(", "pkg_names", ",", "working_set", "=", "None", ")", ":", "working_set", "=", "working_set", "or", "default_working_set", "requirements", "=", "[", "r", "for", "r", "in", "(", "Requirement", ".", "parse", "(", "req",...
Return the entire list of dependency requirements, reversed from the bottom.
[ "Return", "the", "entire", "list", "of", "dependency", "requirements", "reversed", "from", "the", "bottom", "." ]
python
train
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L777-L821
def from_path_except(dir_path, ignore=list(), ignore_ext=list(), ignore_pattern=list()): """Create a new FileCollection, and select all files except file matching ignore-rule:: dir_path = "your/path" fc = FileCollection.from_path_except( ...
[ "def", "from_path_except", "(", "dir_path", ",", "ignore", "=", "list", "(", ")", ",", "ignore_ext", "=", "list", "(", ")", ",", "ignore_pattern", "=", "list", "(", ")", ")", ":", "ignore", "=", "[", "i", ".", "lower", "(", ")", "for", "i", "in", ...
Create a new FileCollection, and select all files except file matching ignore-rule:: dir_path = "your/path" fc = FileCollection.from_path_except( dir_path, ignore=["test"], ignore_ext=[".log", ".tmp"] ignore_pattern=["some_pattern"]) ...
[ "Create", "a", "new", "FileCollection", "and", "select", "all", "files", "except", "file", "matching", "ignore", "-", "rule", "::", "dir_path", "=", "your", "/", "path", "fc", "=", "FileCollection", ".", "from_path_except", "(", "dir_path", "ignore", "=", "[...
python
train
biocommons/biocommons.seqrepo
biocommons/seqrepo/py2compat/_commonpath.py
https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/py2compat/_commonpath.py#L5-L58
def commonpath(paths): """py2 compatible version of py3's os.path.commonpath >>> commonpath([""]) '' >>> commonpath(["/"]) '/' >>> commonpath(["/a"]) '/a' >>> commonpath(["/a//"]) '/a' >>> commonpath(["/a", "/a"]) '/a' >>> commonpath(["/a/b", "/a"]) '/a' >>> comm...
[ "def", "commonpath", "(", "paths", ")", ":", "assert", "os", ".", "sep", "==", "\"/\"", ",", "\"tested only on slash-delimited paths\"", "split_re", "=", "re", ".", "compile", "(", "os", ".", "sep", "+", "\"+\"", ")", "if", "len", "(", "paths", ")", "=="...
py2 compatible version of py3's os.path.commonpath >>> commonpath([""]) '' >>> commonpath(["/"]) '/' >>> commonpath(["/a"]) '/a' >>> commonpath(["/a//"]) '/a' >>> commonpath(["/a", "/a"]) '/a' >>> commonpath(["/a/b", "/a"]) '/a' >>> commonpath(["/a/b", "/a/b"]) '...
[ "py2", "compatible", "version", "of", "py3", "s", "os", ".", "path", ".", "commonpath" ]
python
train
oasiswork/zimsoap
zimsoap/client.py
https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/client.py#L764-L774
def modify_calendar_resource(self, calres, attrs): """ :param calres: a zobjects.CalendarResource :param attrs: a dictionary of attributes to set ({key:value,...}) """ attrs = [{'n': k, '_content': v} for k, v in attrs.items()] self.request('ModifyCalendarResource', { ...
[ "def", "modify_calendar_resource", "(", "self", ",", "calres", ",", "attrs", ")", ":", "attrs", "=", "[", "{", "'n'", ":", "k", ",", "'_content'", ":", "v", "}", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", "]", "self", ".", "requ...
:param calres: a zobjects.CalendarResource :param attrs: a dictionary of attributes to set ({key:value,...})
[ ":", "param", "calres", ":", "a", "zobjects", ".", "CalendarResource", ":", "param", "attrs", ":", "a", "dictionary", "of", "attributes", "to", "set", "(", "{", "key", ":", "value", "...", "}", ")" ]
python
train
bhmm/bhmm
bhmm/hmm/generic_hmm.py
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L167-L172
def is_stationary(self): r""" Whether the MSM is stationary, i.e. whether the initial distribution is the stationary distribution of the hidden transition matrix. """ # for disconnected matrices, the stationary distribution depends on the estimator, so we can't compute # it directly. Th...
[ "def", "is_stationary", "(", "self", ")", ":", "# for disconnected matrices, the stationary distribution depends on the estimator, so we can't compute", "# it directly. Therefore we test whether the initial distribution is stationary.", "return", "np", ".", "allclose", "(", "np", ".", ...
r""" Whether the MSM is stationary, i.e. whether the initial distribution is the stationary distribution of the hidden transition matrix.
[ "r", "Whether", "the", "MSM", "is", "stationary", "i", ".", "e", ".", "whether", "the", "initial", "distribution", "is", "the", "stationary", "distribution", "of", "the", "hidden", "transition", "matrix", "." ]
python
train
michael-lazar/rtv
rtv/page.py
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/page.py#L481-L512
def prompt_and_select_link(self): """ Prompt the user to select a link from a list to open. Return the link that was selected, or ``None`` if no link was selected. """ data = self.get_selected_item() url_full = data.get('url_full') permalink = data.get('permalink...
[ "def", "prompt_and_select_link", "(", "self", ")", ":", "data", "=", "self", ".", "get_selected_item", "(", ")", "url_full", "=", "data", ".", "get", "(", "'url_full'", ")", "permalink", "=", "data", ".", "get", "(", "'permalink'", ")", "if", "url_full", ...
Prompt the user to select a link from a list to open. Return the link that was selected, or ``None`` if no link was selected.
[ "Prompt", "the", "user", "to", "select", "a", "link", "from", "a", "list", "to", "open", "." ]
python
train
cni/MRS
MRS/analysis.py
https://github.com/cni/MRS/blob/16098b3cf4830780efd787fee9efa46513850283/MRS/analysis.py#L64-L96
def separate_signals(data, w_idx=[1, 2, 3]): """ Separate the water and non-water data from each other Parameters ---------- data : nd array FID signal with shape (transients, echos, coils, time-points) w_idx : list (optional) Indices into the 'transients' (0th) dimension of the data for...
[ "def", "separate_signals", "(", "data", ",", "w_idx", "=", "[", "1", ",", "2", ",", "3", "]", ")", ":", "# The transients are the first dimension in the data", "idxes_w", "=", "np", ".", "zeros", "(", "data", ".", "shape", "[", "0", "]", ",", "dtype", "=...
Separate the water and non-water data from each other Parameters ---------- data : nd array FID signal with shape (transients, echos, coils, time-points) w_idx : list (optional) Indices into the 'transients' (0th) dimension of the data for the signal that is not water-suppressed Retu...
[ "Separate", "the", "water", "and", "non", "-", "water", "data", "from", "each", "other" ]
python
train
chrisrink10/basilisp
src/basilisp/lang/runtime.py
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1261-L1267
def init_ns_var(which_ns: str = CORE_NS, ns_var_name: str = NS_VAR_NAME) -> Var: """Initialize the dynamic `*ns*` variable in the Namespace `which_ns`.""" core_sym = sym.Symbol(which_ns) core_ns = Namespace.get_or_create(core_sym) ns_var = Var.intern(core_sym, sym.Symbol(ns_var_name), core_ns, dynamic=T...
[ "def", "init_ns_var", "(", "which_ns", ":", "str", "=", "CORE_NS", ",", "ns_var_name", ":", "str", "=", "NS_VAR_NAME", ")", "->", "Var", ":", "core_sym", "=", "sym", ".", "Symbol", "(", "which_ns", ")", "core_ns", "=", "Namespace", ".", "get_or_create", ...
Initialize the dynamic `*ns*` variable in the Namespace `which_ns`.
[ "Initialize", "the", "dynamic", "*", "ns", "*", "variable", "in", "the", "Namespace", "which_ns", "." ]
python
test
iskandr/knnimpute
knnimpute/normalized_distance.py
https://github.com/iskandr/knnimpute/blob/9a1b8abed9ce6c07a606f3f28cf45333e84d62f4/knnimpute/normalized_distance.py#L18-L84
def all_pairs_normalized_distances(X): """ We can't really compute distances over incomplete data since rows are missing different numbers of entries. The next best thing is the mean squared difference between two vectors (a normalized distance), which gets computed only over the columns that tw...
[ "def", "all_pairs_normalized_distances", "(", "X", ")", ":", "n_rows", ",", "n_cols", "=", "X", ".", "shape", "# matrix of mean squared difference between between samples", "D", "=", "np", ".", "ones", "(", "(", "n_rows", ",", "n_rows", ")", ",", "dtype", "=", ...
We can't really compute distances over incomplete data since rows are missing different numbers of entries. The next best thing is the mean squared difference between two vectors (a normalized distance), which gets computed only over the columns that two vectors have in common. If two vectors have no fe...
[ "We", "can", "t", "really", "compute", "distances", "over", "incomplete", "data", "since", "rows", "are", "missing", "different", "numbers", "of", "entries", ".", "The", "next", "best", "thing", "is", "the", "mean", "squared", "difference", "between", "two", ...
python
train
Azure/azure-cli-extensions
src/storage-preview/azext_storage_preview/_validators.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/storage-preview/azext_storage_preview/_validators.py#L355-L375
def get_datetime_type(to_string): """ Validates UTC datetime. Examples of accepted forms: 2017-12-31T01:11:59Z,2017-12-31T01:11Z or 2017-12-31T01Z or 2017-12-31 """ from datetime import datetime def datetime_type(string): """ Validates UTC datetime. Examples of accepted forms: 2017-12-3...
[ "def", "get_datetime_type", "(", "to_string", ")", ":", "from", "datetime", "import", "datetime", "def", "datetime_type", "(", "string", ")", ":", "\"\"\" Validates UTC datetime. Examples of accepted forms:\n 2017-12-31T01:11:59Z,2017-12-31T01:11Z or 2017-12-31T01Z or 2017-12-...
Validates UTC datetime. Examples of accepted forms: 2017-12-31T01:11:59Z,2017-12-31T01:11Z or 2017-12-31T01Z or 2017-12-31
[ "Validates", "UTC", "datetime", ".", "Examples", "of", "accepted", "forms", ":", "2017", "-", "12", "-", "31T01", ":", "11", ":", "59Z", "2017", "-", "12", "-", "31T01", ":", "11Z", "or", "2017", "-", "12", "-", "31T01Z", "or", "2017", "-", "12", ...
python
train
AlecAivazis/graphql-over-kafka
nautilus/management/scripts/create.py
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/management/scripts/create.py#L36-L47
def api(): """ Create the folder/directories for an ApiGateway service. """ # the template context context = { 'name': 'api', 'secret_key': random_string(32) } render_template(template='common', context=context) render_template(template='api', context=context)
[ "def", "api", "(", ")", ":", "# the template context", "context", "=", "{", "'name'", ":", "'api'", ",", "'secret_key'", ":", "random_string", "(", "32", ")", "}", "render_template", "(", "template", "=", "'common'", ",", "context", "=", "context", ")", "r...
Create the folder/directories for an ApiGateway service.
[ "Create", "the", "folder", "/", "directories", "for", "an", "ApiGateway", "service", "." ]
python
train
Rikanishu/static-bundle
static_bundle/builders.py
https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/builders.py#L157-L170
def render_asset(self, name): """ Render all includes in asset by names :type name: str|unicode :rtype: str|unicode """ result = "" if self.has_asset(name): asset = self.get_asset(name) if asset.files: for f in asset.files:...
[ "def", "render_asset", "(", "self", ",", "name", ")", ":", "result", "=", "\"\"", "if", "self", ".", "has_asset", "(", "name", ")", ":", "asset", "=", "self", ".", "get_asset", "(", "name", ")", "if", "asset", ".", "files", ":", "for", "f", "in", ...
Render all includes in asset by names :type name: str|unicode :rtype: str|unicode
[ "Render", "all", "includes", "in", "asset", "by", "names" ]
python
valid
xapple/plumbing
plumbing/trees/__init__.py
https://github.com/xapple/plumbing/blob/4a7706c7722f5996d0ca366f191aff9ac145880a/plumbing/trees/__init__.py#L96-L102
def mend(self, length): """Cut all branches from this node to its children and adopt all nodes at certain level.""" if length == 0: raise Exception("Can't mend the root !") if length == 1: return self.children = OrderedDict((node.name, node) for node in self.get_level(length)) ...
[ "def", "mend", "(", "self", ",", "length", ")", ":", "if", "length", "==", "0", ":", "raise", "Exception", "(", "\"Can't mend the root !\"", ")", "if", "length", "==", "1", ":", "return", "self", ".", "children", "=", "OrderedDict", "(", "(", "node", "...
Cut all branches from this node to its children and adopt all nodes at certain level.
[ "Cut", "all", "branches", "from", "this", "node", "to", "its", "children", "and", "adopt", "all", "nodes", "at", "certain", "level", "." ]
python
train
arcturial/clickatell-python
clickatell/http/__init__.py
https://github.com/arcturial/clickatell-python/blob/4a554c28edaf2e5d0d9e81b4c9415241bfd61d00/clickatell/http/__init__.py#L78-L88
def stopMessage(self, apiMsgId): """ See parent method for documentation """ content = self.parseLegacy(self.request('http/delmsg', {'apimsgid': apiMsgId})) return { 'id': content['ID'], 'status': content['Status'], 'description': self.getSta...
[ "def", "stopMessage", "(", "self", ",", "apiMsgId", ")", ":", "content", "=", "self", ".", "parseLegacy", "(", "self", ".", "request", "(", "'http/delmsg'", ",", "{", "'apimsgid'", ":", "apiMsgId", "}", ")", ")", "return", "{", "'id'", ":", "content", ...
See parent method for documentation
[ "See", "parent", "method", "for", "documentation" ]
python
train
apache/airflow
airflow/utils/log/wasb_task_handler.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/log/wasb_task_handler.py#L123-L133
def wasb_log_exists(self, remote_log_location): """ Check if remote_log_location exists in remote storage :param remote_log_location: log's location in remote storage :return: True if location exists else False """ try: return self.hook.check_for_blob(self.was...
[ "def", "wasb_log_exists", "(", "self", ",", "remote_log_location", ")", ":", "try", ":", "return", "self", ".", "hook", ".", "check_for_blob", "(", "self", ".", "wasb_container", ",", "remote_log_location", ")", "except", "Exception", ":", "pass", "return", "F...
Check if remote_log_location exists in remote storage :param remote_log_location: log's location in remote storage :return: True if location exists else False
[ "Check", "if", "remote_log_location", "exists", "in", "remote", "storage", ":", "param", "remote_log_location", ":", "log", "s", "location", "in", "remote", "storage", ":", "return", ":", "True", "if", "location", "exists", "else", "False" ]
python
test
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L3451-L3470
def dtpool(name): """ Return the data about a kernel pool variable. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dtpool_c.html :param name: Name of the variable whose value is to be returned. :type name: str :return: Number of values returned for name, Type o...
[ "def", "dtpool", "(", "name", ")", ":", "name", "=", "stypes", ".", "stringToCharP", "(", "name", ")", "found", "=", "ctypes", ".", "c_int", "(", ")", "n", "=", "ctypes", ".", "c_int", "(", ")", "typeout", "=", "ctypes", ".", "c_char", "(", ")", ...
Return the data about a kernel pool variable. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dtpool_c.html :param name: Name of the variable whose value is to be returned. :type name: str :return: Number of values returned for name, Type of the variable "C", "N", or "X...
[ "Return", "the", "data", "about", "a", "kernel", "pool", "variable", "." ]
python
train
vpelletier/python-libusb1
usb1/__init__.py
https://github.com/vpelletier/python-libusb1/blob/740c9778e28523e4ec3543415d95f5400ae0fa24/usb1/__init__.py#L2394-L2421
def getPollFDList(self): """ Return file descriptors to be used to poll USB events. You should not have to call this method, unless you are integrating this class with a polling mechanism. """ pollfd_p_p = libusb1.libusb_get_pollfds(self.__context_p) if not pollfd...
[ "def", "getPollFDList", "(", "self", ")", ":", "pollfd_p_p", "=", "libusb1", ".", "libusb_get_pollfds", "(", "self", ".", "__context_p", ")", "if", "not", "pollfd_p_p", ":", "errno", "=", "get_errno", "(", ")", "if", "errno", ":", "raise", "OSError", "(", ...
Return file descriptors to be used to poll USB events. You should not have to call this method, unless you are integrating this class with a polling mechanism.
[ "Return", "file", "descriptors", "to", "be", "used", "to", "poll", "USB", "events", ".", "You", "should", "not", "have", "to", "call", "this", "method", "unless", "you", "are", "integrating", "this", "class", "with", "a", "polling", "mechanism", "." ]
python
train
arogozhnikov/einops
einops/einops.py
https://github.com/arogozhnikov/einops/blob/9698f0f5efa6c5a79daa75253137ba5d79a95615/einops/einops.py#L117-L177
def reconstruct_from_shape(self, shape, optimize=False): """ Shape is a tuple that may contain integers, shape symbols (tf, keras, theano) and UnknownSize (keras, mxnet) known axes can be integers or symbols, but not Nones """ axes_lengths = list(self.elementary_axes_lengths) ...
[ "def", "reconstruct_from_shape", "(", "self", ",", "shape", ",", "optimize", "=", "False", ")", ":", "axes_lengths", "=", "list", "(", "self", ".", "elementary_axes_lengths", ")", "if", "self", ".", "ellipsis_positions", "!=", "(", "math", ".", "inf", ",", ...
Shape is a tuple that may contain integers, shape symbols (tf, keras, theano) and UnknownSize (keras, mxnet) known axes can be integers or symbols, but not Nones
[ "Shape", "is", "a", "tuple", "that", "may", "contain", "integers", "shape", "symbols", "(", "tf", "keras", "theano", ")", "and", "UnknownSize", "(", "keras", "mxnet", ")", "known", "axes", "can", "be", "integers", "or", "symbols", "but", "not", "Nones" ]
python
train
chemlab/chemlab
chemlab/io/datafile.py
https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/io/datafile.py#L85-L99
def get_handler_class(ext): """Get the IOHandler that can handle the extension *ext*.""" if ext in _extensions_map: format = _extensions_map[ext] else: raise ValueError("Unknown format for %s extension." % ext) if format in _handler_map: hc = _handler_map[format] return...
[ "def", "get_handler_class", "(", "ext", ")", ":", "if", "ext", "in", "_extensions_map", ":", "format", "=", "_extensions_map", "[", "ext", "]", "else", ":", "raise", "ValueError", "(", "\"Unknown format for %s extension.\"", "%", "ext", ")", "if", "format", "i...
Get the IOHandler that can handle the extension *ext*.
[ "Get", "the", "IOHandler", "that", "can", "handle", "the", "extension", "*", "ext", "*", "." ]
python
train
MacHu-GWU/pyknackhq-project
pyknackhq/zzz_manual_install.py
https://github.com/MacHu-GWU/pyknackhq-project/blob/dd937f24d7b0a351ba3818eb746c31b29a8cc341/pyknackhq/zzz_manual_install.py#L100-L141
def install(): """Install your package to all Python version you have installed on Windows. """ import os, shutil _ROOT = os.getcwd() _PACKAGE_NAME = os.path.basename(_ROOT) print("Installing [%s] to all python version..." % _PACKAGE_NAME) # find all Python release installed on thi...
[ "def", "install", "(", ")", ":", "import", "os", ",", "shutil", "_ROOT", "=", "os", ".", "getcwd", "(", ")", "_PACKAGE_NAME", "=", "os", ".", "path", ".", "basename", "(", "_ROOT", ")", "print", "(", "\"Installing [%s] to all python version...\"", "%", "_P...
Install your package to all Python version you have installed on Windows.
[ "Install", "your", "package", "to", "all", "Python", "version", "you", "have", "installed", "on", "Windows", "." ]
python
train
tipsi/tipsi_tools
tipsi_tools/drf/__init__.py
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/drf/__init__.py#L5-L49
def use_form(form_class, request=None, **top_kwargs): """ Validate request (query_params or request body with args from url) with serializer and pass validated data dict to the view function instead of request object. """ def validated_form(request, **kwargs): # import ipdb; ipdb.set_trace(...
[ "def", "use_form", "(", "form_class", ",", "request", "=", "None", ",", "*", "*", "top_kwargs", ")", ":", "def", "validated_form", "(", "request", ",", "*", "*", "kwargs", ")", ":", "# import ipdb; ipdb.set_trace()", "data", "=", "request", ".", "query_param...
Validate request (query_params or request body with args from url) with serializer and pass validated data dict to the view function instead of request object.
[ "Validate", "request", "(", "query_params", "or", "request", "body", "with", "args", "from", "url", ")", "with", "serializer", "and", "pass", "validated", "data", "dict", "to", "the", "view", "function", "instead", "of", "request", "object", "." ]
python
train
MartinThoma/hwrt
hwrt/utils.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L343-L376
def get_readable_time(t): """ Format the time to a readable format. Parameters ---------- t : int Time in ms Returns ------- string The time splitted to highest used time (minutes, hours, ...) """ ms = t % 1000 t -= ms t /= 1000 s = t % 60 t -= ...
[ "def", "get_readable_time", "(", "t", ")", ":", "ms", "=", "t", "%", "1000", "t", "-=", "ms", "t", "/=", "1000", "s", "=", "t", "%", "60", "t", "-=", "s", "t", "/=", "60", "minutes", "=", "t", "%", "60", "t", "-=", "minutes", "t", "/=", "60...
Format the time to a readable format. Parameters ---------- t : int Time in ms Returns ------- string The time splitted to highest used time (minutes, hours, ...)
[ "Format", "the", "time", "to", "a", "readable", "format", "." ]
python
train
openthread/openthread
tools/harness-thci/OpenThread.py
https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread.py#L2060-L2094
def joinCommissioned(self, strPSKd='threadjpaketest', waitTime=20): """start joiner Args: strPSKd: Joiner's PSKd Returns: True: successful to start joiner False: fail to start joiner """ print '%s call joinCommissioned' % self.port se...
[ "def", "joinCommissioned", "(", "self", ",", "strPSKd", "=", "'threadjpaketest'", ",", "waitTime", "=", "20", ")", ":", "print", "'%s call joinCommissioned'", "%", "self", ".", "port", "self", ".", "__sendCommand", "(", "'ifconfig up'", ")", "cmd", "=", "'join...
start joiner Args: strPSKd: Joiner's PSKd Returns: True: successful to start joiner False: fail to start joiner
[ "start", "joiner" ]
python
train
QInfer/python-qinfer
src/qinfer/distributions.py
https://github.com/QInfer/python-qinfer/blob/8170c84a0be1723f8c6b09e0d3c7a40a886f1fe3/src/qinfer/distributions.py#L320-L333
def sample(self, n=1): """ Returns random samples from the current particle distribution according to particle weights. :param int n: The number of samples to draw. :return: The sampled model parameter vectors. :rtype: `~numpy.ndarray` of shape ``(n, updater.n_rvs)``. ...
[ "def", "sample", "(", "self", ",", "n", "=", "1", ")", ":", "cumsum_weights", "=", "np", ".", "cumsum", "(", "self", ".", "particle_weights", ")", "return", "self", ".", "particle_locations", "[", "np", ".", "minimum", "(", "cumsum_weights", ".", "search...
Returns random samples from the current particle distribution according to particle weights. :param int n: The number of samples to draw. :return: The sampled model parameter vectors. :rtype: `~numpy.ndarray` of shape ``(n, updater.n_rvs)``.
[ "Returns", "random", "samples", "from", "the", "current", "particle", "distribution", "according", "to", "particle", "weights", "." ]
python
train
barryp/py-amqplib
amqplib/client_0_8/transport.py
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/transport.py#L144-L155
def read_frame(self): """ Read an AMQP frame. """ frame_type, channel, size = unpack('>BHI', self._read(7)) payload = self._read(size) ch = ord(self._read(1)) if ch == 206: # '\xce' return frame_type, channel, payload else: raise E...
[ "def", "read_frame", "(", "self", ")", ":", "frame_type", ",", "channel", ",", "size", "=", "unpack", "(", "'>BHI'", ",", "self", ".", "_read", "(", "7", ")", ")", "payload", "=", "self", ".", "_read", "(", "size", ")", "ch", "=", "ord", "(", "se...
Read an AMQP frame.
[ "Read", "an", "AMQP", "frame", "." ]
python
train
Clarify/clarify_python
clarify_python/clarify.py
https://github.com/Clarify/clarify_python/blob/1a00a5e39f77af9ad7f2e08480a3ab14e7d72aeb/clarify_python/clarify.py#L218-L265
def create_bundle(self, name=None, media_url=None, audio_channel=None, metadata=None, notify_url=None, external_id=None): """Create a new bundle. 'metadata' may be None, or an object that can be converted to a JSON string. See API documentation for r...
[ "def", "create_bundle", "(", "self", ",", "name", "=", "None", ",", "media_url", "=", "None", ",", "audio_channel", "=", "None", ",", "metadata", "=", "None", ",", "notify_url", "=", "None", ",", "external_id", "=", "None", ")", ":", "# Prepare the data we...
Create a new bundle. 'metadata' may be None, or an object that can be converted to a JSON string. See API documentation for restrictions. The conversion will take place before the API call. All other parameters are also optional. For information about these see https://api.cl...
[ "Create", "a", "new", "bundle", "." ]
python
train
assamite/creamas
creamas/examples/spiro/spiro_agent_mp.py
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L195-L221
def invent(self, n): '''Invent new spirograph by taking n random steps from current position (spirograph generation parameters) and selecting the best one based on the agent's evaluation (hedonic function). :param int n: how many spirographs are created for evaluation :returns: ...
[ "def", "invent", "(", "self", ",", "n", ")", ":", "args", "=", "self", ".", "randomize_args", "(", ")", "img", "=", "self", ".", "create", "(", "args", "[", "0", "]", ",", "args", "[", "1", "]", ")", "best_artifact", "=", "SpiroArtifact", "(", "s...
Invent new spirograph by taking n random steps from current position (spirograph generation parameters) and selecting the best one based on the agent's evaluation (hedonic function). :param int n: how many spirographs are created for evaluation :returns: Best created artifact. :...
[ "Invent", "new", "spirograph", "by", "taking", "n", "random", "steps", "from", "current", "position", "(", "spirograph", "generation", "parameters", ")", "and", "selecting", "the", "best", "one", "based", "on", "the", "agent", "s", "evaluation", "(", "hedonic"...
python
train
Robpol86/sphinxcontrib-imgur
sphinxcontrib/imgur/nodes.py
https://github.com/Robpol86/sphinxcontrib-imgur/blob/5c178481d645147d10acb096793eda41c12c57af/sphinxcontrib/imgur/nodes.py#L111-L158
def finalize(self, album_cache, image_cache, warn_node): """Update attributes after Sphinx cache is updated. :param dict album_cache: Cache of Imgur albums to read. Keys are Imgur IDs, values are Album instances. :param dict image_cache: Cache of Imgur images to read. Keys are Imgur IDs, values...
[ "def", "finalize", "(", "self", ",", "album_cache", ",", "image_cache", ",", "warn_node", ")", ":", "album", "=", "album_cache", "[", "self", ".", "imgur_id", "]", "if", "self", ".", "album", "else", "None", "image", "=", "image_cache", "[", "album", "."...
Update attributes after Sphinx cache is updated. :param dict album_cache: Cache of Imgur albums to read. Keys are Imgur IDs, values are Album instances. :param dict image_cache: Cache of Imgur images to read. Keys are Imgur IDs, values are Image instances. :param function warn_node: sphinx.envi...
[ "Update", "attributes", "after", "Sphinx", "cache", "is", "updated", "." ]
python
train
googleapis/google-cloud-python
api_core/google/api_core/bidi.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/bidi.py#L202-L222
def open(self): """Opens the stream.""" if self.is_active: raise ValueError("Can not open an already open stream.") request_generator = _RequestQueueGenerator( self._request_queue, initial_request=self._initial_request ) call = self._start_rpc(iter(reques...
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "is_active", ":", "raise", "ValueError", "(", "\"Can not open an already open stream.\"", ")", "request_generator", "=", "_RequestQueueGenerator", "(", "self", ".", "_request_queue", ",", "initial_request", "=...
Opens the stream.
[ "Opens", "the", "stream", "." ]
python
train
ThreshingFloor/libtf
libtf/logparsers/tf_auth_log.py
https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_auth_log.py#L64-L85
def _extract_features(self): """ Extracts and sets the feature data from the log file necessary for a reduction """ for parsed_line in self.parsed_lines: # If it's ssh, we can handle it if parsed_line.get('program') == 'sshd': result = self._parse...
[ "def", "_extract_features", "(", "self", ")", ":", "for", "parsed_line", "in", "self", ".", "parsed_lines", ":", "# If it's ssh, we can handle it", "if", "parsed_line", ".", "get", "(", "'program'", ")", "==", "'sshd'", ":", "result", "=", "self", ".", "_parse...
Extracts and sets the feature data from the log file necessary for a reduction
[ "Extracts", "and", "sets", "the", "feature", "data", "from", "the", "log", "file", "necessary", "for", "a", "reduction" ]
python
train
PmagPy/PmagPy
dialogs/pmag_er_magic_dialogs.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/pmag_er_magic_dialogs.py#L299-L322
def on_saveButton(self, event, grid): """saves any editing of the grid but does not continue to the next window""" wait = wx.BusyInfo("Please wait, working...") wx.SafeYield() if self.grid_frame.drop_down_menu: # unhighlight selected columns, etc. self.grid_frame.drop_down_...
[ "def", "on_saveButton", "(", "self", ",", "event", ",", "grid", ")", ":", "wait", "=", "wx", ".", "BusyInfo", "(", "\"Please wait, working...\"", ")", "wx", ".", "SafeYield", "(", ")", "if", "self", ".", "grid_frame", ".", "drop_down_menu", ":", "# unhighl...
saves any editing of the grid but does not continue to the next window
[ "saves", "any", "editing", "of", "the", "grid", "but", "does", "not", "continue", "to", "the", "next", "window" ]
python
train
hydraplatform/hydra-base
hydra_base/lib/scenario.py
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L1139-L1198
def update_value_from_mapping(source_resource_attr_id, target_resource_attr_id, source_scenario_id, target_scenario_id, **kwargs): """ Using a resource attribute mapping, take the value from the source and apply it to the target. Both source and target scenarios must be specified (and therefor ...
[ "def", "update_value_from_mapping", "(", "source_resource_attr_id", ",", "target_resource_attr_id", ",", "source_scenario_id", ",", "target_scenario_id", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "int", "(", "kwargs", ".", "get", "(", "'user_id'", ")", ")...
Using a resource attribute mapping, take the value from the source and apply it to the target. Both source and target scenarios must be specified (and therefor must exist).
[ "Using", "a", "resource", "attribute", "mapping", "take", "the", "value", "from", "the", "source", "and", "apply", "it", "to", "the", "target", ".", "Both", "source", "and", "target", "scenarios", "must", "be", "specified", "(", "and", "therefor", "must", ...
python
train
bitesofcode/projexui
projexui/dialogs/xwizardbrowserdialog/xwizardplugin.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xwizardbrowserdialog/xwizardplugin.py#L194-L204
def setGroupIcon( cls, groupName, icon ): """ Sets the group icon for the wizard plugin to the inputed icon. :param groupName | <str> icon | <str> """ if ( cls._groupIcons is None ): cls._groupIcons = {} ...
[ "def", "setGroupIcon", "(", "cls", ",", "groupName", ",", "icon", ")", ":", "if", "(", "cls", ".", "_groupIcons", "is", "None", ")", ":", "cls", ".", "_groupIcons", "=", "{", "}", "cls", ".", "_groupIcons", "[", "nativestring", "(", "groupName", ")", ...
Sets the group icon for the wizard plugin to the inputed icon. :param groupName | <str> icon | <str>
[ "Sets", "the", "group", "icon", "for", "the", "wizard", "plugin", "to", "the", "inputed", "icon", ".", ":", "param", "groupName", "|", "<str", ">", "icon", "|", "<str", ">" ]
python
train
Gandi/gandi.cli
gandi/cli/modules/paas.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L80-L126
def deploy(cls, remote_name, branch): """Deploy a PaaS instance.""" def get_remote_url(remote): return 'git config --local --get remote.%s.url' % (remote) remote_url = cls.exec_output(get_remote_url(remote_name)) \ .replace('\n', '') if not remote_url or not re....
[ "def", "deploy", "(", "cls", ",", "remote_name", ",", "branch", ")", ":", "def", "get_remote_url", "(", "remote", ")", ":", "return", "'git config --local --get remote.%s.url'", "%", "(", "remote", ")", "remote_url", "=", "cls", ".", "exec_output", "(", "get_r...
Deploy a PaaS instance.
[ "Deploy", "a", "PaaS", "instance", "." ]
python
train
ubyssey/dispatch
dispatch/api/mixins.py
https://github.com/ubyssey/dispatch/blob/8da6084fe61726f20e9cf675190480cfc45ee764/dispatch/api/mixins.py#L107-L116
def exclude_fields(self): """Excludes fields that are included in the queryparameters""" request = self.context.get('request') if request: exclude = request.query_params.get('exclude', None) if exclude is None: return excluded_fields = exclude...
[ "def", "exclude_fields", "(", "self", ")", ":", "request", "=", "self", ".", "context", ".", "get", "(", "'request'", ")", "if", "request", ":", "exclude", "=", "request", ".", "query_params", ".", "get", "(", "'exclude'", ",", "None", ")", "if", "excl...
Excludes fields that are included in the queryparameters
[ "Excludes", "fields", "that", "are", "included", "in", "the", "queryparameters" ]
python
test
juju/python-libjuju
juju/client/_client2.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client2.py#L5128-L5141
async def Delete(self, image_ids): ''' image_ids : typing.Sequence[str] Returns -> typing.Sequence[~ErrorResult] ''' # map input types to rpc msg _params = dict() msg = dict(type='ImageMetadata', request='Delete', version=2, ...
[ "async", "def", "Delete", "(", "self", ",", "image_ids", ")", ":", "# map input types to rpc msg", "_params", "=", "dict", "(", ")", "msg", "=", "dict", "(", "type", "=", "'ImageMetadata'", ",", "request", "=", "'Delete'", ",", "version", "=", "2", ",", ...
image_ids : typing.Sequence[str] Returns -> typing.Sequence[~ErrorResult]
[ "image_ids", ":", "typing", ".", "Sequence", "[", "str", "]", "Returns", "-", ">", "typing", ".", "Sequence", "[", "~ErrorResult", "]" ]
python
train
andialbrecht/sqlparse
sqlparse/lexer.py
https://github.com/andialbrecht/sqlparse/blob/913b56e34edc7e3025feea4744dbd762774805c3/sqlparse/lexer.py#L28-L73
def get_tokens(text, encoding=None): """ Return an iterable of (tokentype, value) pairs generated from `text`. If `unfiltered` is set to `True`, the filtering mechanism is bypassed even if filters are defined. Also preprocess the text, i.e. expand tabs and strip it if wa...
[ "def", "get_tokens", "(", "text", ",", "encoding", "=", "None", ")", ":", "if", "isinstance", "(", "text", ",", "file_types", ")", ":", "text", "=", "text", ".", "read", "(", ")", "if", "isinstance", "(", "text", ",", "text_type", ")", ":", "pass", ...
Return an iterable of (tokentype, value) pairs generated from `text`. If `unfiltered` is set to `True`, the filtering mechanism is bypassed even if filters are defined. Also preprocess the text, i.e. expand tabs and strip it if wanted and applies registered filters. Split ``tex...
[ "Return", "an", "iterable", "of", "(", "tokentype", "value", ")", "pairs", "generated", "from", "text", ".", "If", "unfiltered", "is", "set", "to", "True", "the", "filtering", "mechanism", "is", "bypassed", "even", "if", "filters", "are", "defined", "." ]
python
train
jciskey/pygraph
pygraph/functions/spanning_tree.py
https://github.com/jciskey/pygraph/blob/037bb2f32503fecb60d62921f9766d54109f15e2/pygraph/functions/spanning_tree.py#L57-L62
def find_minimum_spanning_forest_as_subgraphs(graph): """Calculates the minimum spanning forest and returns a list of trees as subgraphs.""" forest = find_minimum_spanning_forest(graph) list_of_subgraphs = [get_subgraph_from_edge_list(graph, edge_list) for edge_list in forest] return list_of_subgraphs
[ "def", "find_minimum_spanning_forest_as_subgraphs", "(", "graph", ")", ":", "forest", "=", "find_minimum_spanning_forest", "(", "graph", ")", "list_of_subgraphs", "=", "[", "get_subgraph_from_edge_list", "(", "graph", ",", "edge_list", ")", "for", "edge_list", "in", "...
Calculates the minimum spanning forest and returns a list of trees as subgraphs.
[ "Calculates", "the", "minimum", "spanning", "forest", "and", "returns", "a", "list", "of", "trees", "as", "subgraphs", "." ]
python
train
Prodicode/ann-visualizer
ann_visualizer/visualize.py
https://github.com/Prodicode/ann-visualizer/blob/031f4977aed3b4c1b5c009bcfd70638268b1800f/ann_visualizer/visualize.py#L18-L206
def ann_viz(model, view=True, filename="network.gv", title="My Neural Network"): """Vizualizez a Sequential model. # Arguments model: A Keras model instance. view: whether to display the model after generation. filename: where to save the vizualization. (a .gv file) title: A ...
[ "def", "ann_viz", "(", "model", ",", "view", "=", "True", ",", "filename", "=", "\"network.gv\"", ",", "title", "=", "\"My Neural Network\"", ")", ":", "from", "graphviz", "import", "Digraph", "import", "keras", "from", "keras", ".", "models", "import", "Seq...
Vizualizez a Sequential model. # Arguments model: A Keras model instance. view: whether to display the model after generation. filename: where to save the vizualization. (a .gv file) title: A title for the graph
[ "Vizualizez", "a", "Sequential", "model", "." ]
python
train
The-Politico/politico-civic-ap-loader
aploader/management/commands/reup_to_db.py
https://github.com/The-Politico/politico-civic-ap-loader/blob/4afeebb62da4b8f22da63711e7176bf4527bccfb/aploader/management/commands/reup_to_db.py#L189-L395
def process_result(self, result, tabulated, no_bots, election_slug): """ Processes top-level (state) results for candidate races, loads data into the database and sends alerts for winning results. """ # Deconstruct result in variables ( ID, RACE_I...
[ "def", "process_result", "(", "self", ",", "result", ",", "tabulated", ",", "no_bots", ",", "election_slug", ")", ":", "# Deconstruct result in variables", "(", "ID", ",", "RACE_ID", ",", "IS_BALLOT_MEASURE", ",", "ELEX_ELECTION_DATE", ",", "LEVEL", ",", "STATE_PO...
Processes top-level (state) results for candidate races, loads data into the database and sends alerts for winning results.
[ "Processes", "top", "-", "level", "(", "state", ")", "results", "for", "candidate", "races", "loads", "data", "into", "the", "database", "and", "sends", "alerts", "for", "winning", "results", "." ]
python
train
hobson/aima
aima/search.py
https://github.com/hobson/aima/blob/3572b2fb92039b4a1abe384be8545560fbd3d470/aima/search.py#L564-L569
def result(self, state, row): "Place the next queen at the given row." col = state.index(None) new = state[:] new[col] = row return new
[ "def", "result", "(", "self", ",", "state", ",", "row", ")", ":", "col", "=", "state", ".", "index", "(", "None", ")", "new", "=", "state", "[", ":", "]", "new", "[", "col", "]", "=", "row", "return", "new" ]
Place the next queen at the given row.
[ "Place", "the", "next", "queen", "at", "the", "given", "row", "." ]
python
valid
DataDog/integrations-core
openstack_controller/datadog_checks/openstack_controller/api.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack_controller/datadog_checks/openstack_controller/api.py#L598-L623
def _get_valid_endpoint(resp, name, entry_type): """ Parse the service catalog returned by the Identity API for an endpoint matching the Nova service with the requested version Sends a CRITICAL service check when no viable candidates are found in the Catalog """ catalog =...
[ "def", "_get_valid_endpoint", "(", "resp", ",", "name", ",", "entry_type", ")", ":", "catalog", "=", "resp", ".", "get", "(", "'token'", ",", "{", "}", ")", ".", "get", "(", "'catalog'", ",", "[", "]", ")", "for", "entry", "in", "catalog", ":", "if...
Parse the service catalog returned by the Identity API for an endpoint matching the Nova service with the requested version Sends a CRITICAL service check when no viable candidates are found in the Catalog
[ "Parse", "the", "service", "catalog", "returned", "by", "the", "Identity", "API", "for", "an", "endpoint", "matching", "the", "Nova", "service", "with", "the", "requested", "version", "Sends", "a", "CRITICAL", "service", "check", "when", "no", "viable", "candi...
python
train
titusjan/argos
argos/config/qtctis.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/config/qtctis.py#L340-L347
def _nodeGetNonDefaultsDict(self): """ Retrieves this nodes` values as a dictionary to be used for persistence. Non-recursive auxiliary function for getNonDefaultsDict """ dct = {} if self.data != self.defaultData: dct['data'] = self.data.toString() # calls QFont....
[ "def", "_nodeGetNonDefaultsDict", "(", "self", ")", ":", "dct", "=", "{", "}", "if", "self", ".", "data", "!=", "self", ".", "defaultData", ":", "dct", "[", "'data'", "]", "=", "self", ".", "data", ".", "toString", "(", ")", "# calls QFont.toString()", ...
Retrieves this nodes` values as a dictionary to be used for persistence. Non-recursive auxiliary function for getNonDefaultsDict
[ "Retrieves", "this", "nodes", "values", "as", "a", "dictionary", "to", "be", "used", "for", "persistence", ".", "Non", "-", "recursive", "auxiliary", "function", "for", "getNonDefaultsDict" ]
python
train
KrzyHonk/bpmn-python
bpmn_python/bpmn_diagram_import.py
https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_import.py#L452-L468
def import_activity_to_graph(diagram_graph, process_id, process_attributes, element): """ Method that adds the new element that represents BPMN activity. Should not be used directly, only as a part of method, that imports an element which extends Activity element (task, subprocess etc.) ...
[ "def", "import_activity_to_graph", "(", "diagram_graph", ",", "process_id", ",", "process_attributes", ",", "element", ")", ":", "BpmnDiagramGraphImport", ".", "import_flow_node_to_graph", "(", "diagram_graph", ",", "process_id", ",", "process_attributes", ",", "element",...
Method that adds the new element that represents BPMN activity. Should not be used directly, only as a part of method, that imports an element which extends Activity element (task, subprocess etc.) :param diagram_graph: NetworkX graph representing a BPMN process diagram, :param process_...
[ "Method", "that", "adds", "the", "new", "element", "that", "represents", "BPMN", "activity", ".", "Should", "not", "be", "used", "directly", "only", "as", "a", "part", "of", "method", "that", "imports", "an", "element", "which", "extends", "Activity", "eleme...
python
train
StyXman/ayrton
ayrton/parser/pyparser/pytokenizer.py
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/pytokenizer.py#L15-L51
def match_encoding_declaration(comment): """returns the declared encoding or None This function is a replacement for : >>> py_encoding = re.compile(r"coding[:=]\s*([-\w.]+)") >>> py_encoding.search(comment) """ # the coding line must be ascii try: comment = comment.decode('ascii') ...
[ "def", "match_encoding_declaration", "(", "comment", ")", ":", "# the coding line must be ascii", "try", ":", "comment", "=", "comment", ".", "decode", "(", "'ascii'", ")", "except", "UnicodeDecodeError", ":", "return", "None", "index", "=", "comment", ".", "find"...
returns the declared encoding or None This function is a replacement for : >>> py_encoding = re.compile(r"coding[:=]\s*([-\w.]+)") >>> py_encoding.search(comment)
[ "returns", "the", "declared", "encoding", "or", "None" ]
python
train
log2timeline/plaso
plaso/engine/profilers.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/engine/profilers.py#L286-L296
def Sample(self, task, status): """Takes a sample of the status of a task for profiling. Args: task (Task): a task. status (str): status. """ sample_time = time.time() sample = '{0:f}\t{1:s}\t{2:s}\n'.format( sample_time, task.identifier, status) self._WritesString(sample)
[ "def", "Sample", "(", "self", ",", "task", ",", "status", ")", ":", "sample_time", "=", "time", ".", "time", "(", ")", "sample", "=", "'{0:f}\\t{1:s}\\t{2:s}\\n'", ".", "format", "(", "sample_time", ",", "task", ".", "identifier", ",", "status", ")", "se...
Takes a sample of the status of a task for profiling. Args: task (Task): a task. status (str): status.
[ "Takes", "a", "sample", "of", "the", "status", "of", "a", "task", "for", "profiling", "." ]
python
train
Azure/azure-cli-extensions
src/express-route/azext_express_route/vendored_sdks/network_management_client.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/express-route/azext_express_route/vendored_sdks/network_management_client.py#L2042-L2055
def service_endpoint_policies(self): """Instance depends on the API version: * 2018-07-01: :class:`ServiceEndpointPoliciesOperations<azure.mgmt.network.v2018_07_01.operations.ServiceEndpointPoliciesOperations>` * 2018-08-01: :class:`ServiceEndpointPoliciesOperations<azure.mgmt.network.v20...
[ "def", "service_endpoint_policies", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'service_endpoint_policies'", ")", "if", "api_version", "==", "'2018-07-01'", ":", "from", ".", "v2018_07_01", ".", "operations", "import", "Service...
Instance depends on the API version: * 2018-07-01: :class:`ServiceEndpointPoliciesOperations<azure.mgmt.network.v2018_07_01.operations.ServiceEndpointPoliciesOperations>` * 2018-08-01: :class:`ServiceEndpointPoliciesOperations<azure.mgmt.network.v2018_08_01.operations.ServiceEndpointPoliciesOpera...
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
python
train
Garee/pytodoist
pytodoist/todoist.py
https://github.com/Garee/pytodoist/blob/3359cbff485ebdbbb4ffbd58d71e21a817874dd7/pytodoist/todoist.py#L1138-L1151
def get_notes(self): """Return a list of all of the project's notes. :return: A list of notes. :rtype: list of :class:`pytodoist.todoist.Note` >>> from pytodoist import todoist >>> user = todoist.login('john.doe@gmail.com', 'password') >>> project = user.get_project('Py...
[ "def", "get_notes", "(", "self", ")", ":", "self", ".", "owner", ".", "sync", "(", ")", "notes", "=", "self", ".", "owner", ".", "notes", ".", "values", "(", ")", "return", "[", "n", "for", "n", "in", "notes", "if", "n", ".", "project_id", "==", ...
Return a list of all of the project's notes. :return: A list of notes. :rtype: list of :class:`pytodoist.todoist.Note` >>> from pytodoist import todoist >>> user = todoist.login('john.doe@gmail.com', 'password') >>> project = user.get_project('PyTodoist') >>> notes = pr...
[ "Return", "a", "list", "of", "all", "of", "the", "project", "s", "notes", "." ]
python
train
wdbm/megaparsex
megaparsex.py
https://github.com/wdbm/megaparsex/blob/59da05410aa1cf8682dcee2bf0bd0572fa42bd29/megaparsex.py#L93-L230
def parse( text = None, humour = 75 ): """ Parse input text using various triggers, some returning text and some for engaging functions. If triggered, a trigger returns text or True if and if not triggered, returns False. If no triggers are triggered, return False, if one trigger is tr...
[ "def", "parse", "(", "text", "=", "None", ",", "humour", "=", "75", ")", ":", "triggers", "=", "[", "]", "# general", "if", "humour", ">=", "75", ":", "triggers", ".", "extend", "(", "[", "trigger_keyphrases", "(", "text", "=", "text", ",", "keyphras...
Parse input text using various triggers, some returning text and some for engaging functions. If triggered, a trigger returns text or True if and if not triggered, returns False. If no triggers are triggered, return False, if one trigger is triggered, return the value returned by that trigger, and if mu...
[ "Parse", "input", "text", "using", "various", "triggers", "some", "returning", "text", "and", "some", "for", "engaging", "functions", ".", "If", "triggered", "a", "trigger", "returns", "text", "or", "True", "if", "and", "if", "not", "triggered", "returns", "...
python
train
kallimachos/sphinxmark
sphinxmark/__init__.py
https://github.com/kallimachos/sphinxmark/blob/f7b17d9dabf1fff448bb38d90474498f0d203990/sphinxmark/__init__.py#L152-L159
def watermark(app, env): """Add watermark.""" if app.config.sphinxmark_enable is True: LOG.info('adding watermark...', nonl=True) buildpath, imagefile = getimage(app) cssname = buildcss(app, buildpath, imagefile) app.add_css_file(cssname) LOG.info(' done')
[ "def", "watermark", "(", "app", ",", "env", ")", ":", "if", "app", ".", "config", ".", "sphinxmark_enable", "is", "True", ":", "LOG", ".", "info", "(", "'adding watermark...'", ",", "nonl", "=", "True", ")", "buildpath", ",", "imagefile", "=", "getimage"...
Add watermark.
[ "Add", "watermark", "." ]
python
train
cloud-custodian/cloud-custodian
c7n/filters/offhours.py
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/filters/offhours.py#L398-L438
def process_resource_schedule(self, i, value, time_type): """Does the resource tag schedule and policy match the current time.""" rid = i[self.id_key] # this is to normalize trailing semicolons which when done allows # dateutil.parser.parse to process: value='off=(m-f,1);' properly. ...
[ "def", "process_resource_schedule", "(", "self", ",", "i", ",", "value", ",", "time_type", ")", ":", "rid", "=", "i", "[", "self", ".", "id_key", "]", "# this is to normalize trailing semicolons which when done allows", "# dateutil.parser.parse to process: value='off=(m-f,1...
Does the resource tag schedule and policy match the current time.
[ "Does", "the", "resource", "tag", "schedule", "and", "policy", "match", "the", "current", "time", "." ]
python
train
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/tree.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L26-L40
def get_position(self, rst_tree, node_id=None): """Get the linear position of an element of this DGParentedTree in an RSTTree. If ``node_id`` is given, this will return the position of the subtree with that node ID. Otherwise, the position of the root of this DGParentedTree in the given...
[ "def", "get_position", "(", "self", ",", "rst_tree", ",", "node_id", "=", "None", ")", ":", "if", "node_id", "is", "None", ":", "node_id", "=", "self", ".", "root_id", "if", "node_id", "in", "rst_tree", ".", "edu_set", ":", "return", "rst_tree", ".", "...
Get the linear position of an element of this DGParentedTree in an RSTTree. If ``node_id`` is given, this will return the position of the subtree with that node ID. Otherwise, the position of the root of this DGParentedTree in the given RSTTree is returned.
[ "Get", "the", "linear", "position", "of", "an", "element", "of", "this", "DGParentedTree", "in", "an", "RSTTree", "." ]
python
train
hellosign/hellosign-python-sdk
hellosign_sdk/hsclient.py
https://github.com/hellosign/hellosign-python-sdk/blob/4325a29ad5766380a214eac3914511f62f7ecba4/hellosign_sdk/hsclient.py#L173-L206
def create_account(self, email_address, password=None, client_id=None, client_secret=None): ''' Create a new account. If the account is created via an app, then Account.oauth will contain the OAuth data that can be used to execute actions on behalf of the newly created account. Args: ...
[ "def", "create_account", "(", "self", ",", "email_address", ",", "password", "=", "None", ",", "client_id", "=", "None", ",", "client_secret", "=", "None", ")", ":", "request", "=", "self", ".", "_get_request", "(", ")", "params", "=", "{", "'email_address...
Create a new account. If the account is created via an app, then Account.oauth will contain the OAuth data that can be used to execute actions on behalf of the newly created account. Args: email_address (str): Email address of the new account to create passw...
[ "Create", "a", "new", "account", "." ]
python
train
jayferg/faderport
faderport.py
https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L354-L367
def find_faderport_input_name(number=0): """ Find the MIDI input name for a connected FaderPort. NOTE! Untested for more than one FaderPort attached. :param number: 0 unless you've got more than one FaderPort attached. In which case 0 is the first, 1 is the second etc :return: Po...
[ "def", "find_faderport_input_name", "(", "number", "=", "0", ")", ":", "ins", "=", "[", "i", "for", "i", "in", "mido", ".", "get_input_names", "(", ")", "if", "i", ".", "lower", "(", ")", ".", "startswith", "(", "'faderport'", ")", "]", "if", "0", ...
Find the MIDI input name for a connected FaderPort. NOTE! Untested for more than one FaderPort attached. :param number: 0 unless you've got more than one FaderPort attached. In which case 0 is the first, 1 is the second etc :return: Port name or None
[ "Find", "the", "MIDI", "input", "name", "for", "a", "connected", "FaderPort", "." ]
python
train
spulec/moto
moto/packages/httpretty/http.py
https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/http.py#L144-L154
def last_requestline(sent_data): """ Find the last line in sent_data that can be parsed with parse_requestline """ for line in reversed(sent_data): try: parse_requestline(decode_utf8(line)) except ValueError: pass else: return line
[ "def", "last_requestline", "(", "sent_data", ")", ":", "for", "line", "in", "reversed", "(", "sent_data", ")", ":", "try", ":", "parse_requestline", "(", "decode_utf8", "(", "line", ")", ")", "except", "ValueError", ":", "pass", "else", ":", "return", "lin...
Find the last line in sent_data that can be parsed with parse_requestline
[ "Find", "the", "last", "line", "in", "sent_data", "that", "can", "be", "parsed", "with", "parse_requestline" ]
python
train
bykof/billomapy
billomapy/billomapy.py
https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L637-L651
def get_tags_of_supplier_per_page(self, supplier_id, per_page=1000, page=1): """ Get tags of suppliers per page :param supplier_id: the supplier id :param per_page: How many objects per page. Default: 1000 :param page: Which page. Default: 1 :return: list """ ...
[ "def", "get_tags_of_supplier_per_page", "(", "self", ",", "supplier_id", ",", "per_page", "=", "1000", ",", "page", "=", "1", ")", ":", "return", "self", ".", "_get_resource_per_page", "(", "resource", "=", "SUPPLIER_TAGS", ",", "per_page", "=", "per_page", ",...
Get tags of suppliers per page :param supplier_id: the supplier id :param per_page: How many objects per page. Default: 1000 :param page: Which page. Default: 1 :return: list
[ "Get", "tags", "of", "suppliers", "per", "page" ]
python
train
crankycoder/hydra
src/hydra.py
https://github.com/crankycoder/hydra/blob/3be536bd0c6716d4efcfde3e132582e6066bae43/src/hydra.py#L4-L18
def ReadingBloomFilter(filename, want_lock=False): """ Create a read-only bloom filter with an upperbound of (num_elements, max_fp_prob) as a specification and using filename as the backing datastore. """ with open('{}.desc'.format(filename), 'r') as descriptor: num_elements = int(descri...
[ "def", "ReadingBloomFilter", "(", "filename", ",", "want_lock", "=", "False", ")", ":", "with", "open", "(", "'{}.desc'", ".", "format", "(", "filename", ")", ",", "'r'", ")", "as", "descriptor", ":", "num_elements", "=", "int", "(", "descriptor", ".", "...
Create a read-only bloom filter with an upperbound of (num_elements, max_fp_prob) as a specification and using filename as the backing datastore.
[ "Create", "a", "read", "-", "only", "bloom", "filter", "with", "an", "upperbound", "of", "(", "num_elements", "max_fp_prob", ")", "as", "a", "specification", "and", "using", "filename", "as", "the", "backing", "datastore", "." ]
python
test
fracpete/python-weka-wrapper3
python/weka/core/capabilities.py
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/capabilities.py#L113-L124
def owner(self): """ Returns the owner of these capabilities, if any. :return: the owner, can be None :rtype: JavaObject """ obj = javabridge.call(self.jobject, "getOwner", "()Lweka/core/CapabilitiesHandler;") if obj is None: return None else:...
[ "def", "owner", "(", "self", ")", ":", "obj", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getOwner\"", ",", "\"()Lweka/core/CapabilitiesHandler;\"", ")", "if", "obj", "is", "None", ":", "return", "None", "else", ":", "return", "Jav...
Returns the owner of these capabilities, if any. :return: the owner, can be None :rtype: JavaObject
[ "Returns", "the", "owner", "of", "these", "capabilities", "if", "any", "." ]
python
train
digi604/django-smart-selects
smart_selects/widgets.py
https://github.com/digi604/django-smart-selects/blob/05dcc4a3de2874499ff3b9a3dfac5c623206e3e5/smart_selects/widgets.py#L157-L183
def _get_available_choices(self, queryset, value): """ get possible choices for selection """ item = queryset.filter(pk=value).first() if item: try: pk = getattr(item, self.chained_model_field + "_id") filter = {self.chained_model_field...
[ "def", "_get_available_choices", "(", "self", ",", "queryset", ",", "value", ")", ":", "item", "=", "queryset", ".", "filter", "(", "pk", "=", "value", ")", ".", "first", "(", ")", "if", "item", ":", "try", ":", "pk", "=", "getattr", "(", "item", "...
get possible choices for selection
[ "get", "possible", "choices", "for", "selection" ]
python
valid
mwgielen/jackal
jackal/core.py
https://github.com/mwgielen/jackal/blob/7fe62732eb5194b7246215d5277fb37c398097bf/jackal/core.py#L495-L519
def find_object(self, username, secret, domain=None, host_ip=None, service_id=None): """ Searches elasticsearch for objects with the same username, password, optional domain, host_ip and service_id. """ # Not sure yet if this is advisable... Older passwords can be overwritten... ...
[ "def", "find_object", "(", "self", ",", "username", ",", "secret", ",", "domain", "=", "None", ",", "host_ip", "=", "None", ",", "service_id", "=", "None", ")", ":", "# Not sure yet if this is advisable... Older passwords can be overwritten...", "search", "=", "Cred...
Searches elasticsearch for objects with the same username, password, optional domain, host_ip and service_id.
[ "Searches", "elasticsearch", "for", "objects", "with", "the", "same", "username", "password", "optional", "domain", "host_ip", "and", "service_id", "." ]
python
valid
agoragames/haigha
haigha/connection.py
https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L534-L560
def dispatch(self, frame): ''' Override the default dispatch since we don't need the rest of the stack. ''' if frame.type() == HeartbeatFrame.type(): self.send_heartbeat() elif frame.type() == MethodFrame.type(): if frame.class_id == 10: ...
[ "def", "dispatch", "(", "self", ",", "frame", ")", ":", "if", "frame", ".", "type", "(", ")", "==", "HeartbeatFrame", ".", "type", "(", ")", ":", "self", ".", "send_heartbeat", "(", ")", "elif", "frame", ".", "type", "(", ")", "==", "MethodFrame", ...
Override the default dispatch since we don't need the rest of the stack.
[ "Override", "the", "default", "dispatch", "since", "we", "don", "t", "need", "the", "rest", "of", "the", "stack", "." ]
python
train
bmcfee/pumpp
pumpp/task/regression.py
https://github.com/bmcfee/pumpp/blob/06a17b888271dd1f6cd41bddb22b0eb04d494056/pumpp/task/regression.py#L64-L92
def transform_annotation(self, ann, duration): '''Apply the vector transformation. Parameters ---------- ann : jams.Annotation The input annotation duration : number > 0 The duration of the track Returns ------- data : dict ...
[ "def", "transform_annotation", "(", "self", ",", "ann", ",", "duration", ")", ":", "_", ",", "values", "=", "ann", ".", "to_interval_values", "(", ")", "vector", "=", "np", ".", "asarray", "(", "values", "[", "0", "]", ",", "dtype", "=", "self", ".",...
Apply the vector transformation. Parameters ---------- ann : jams.Annotation The input annotation duration : number > 0 The duration of the track Returns ------- data : dict data['vector'] : np.ndarray, shape=(dimension,) ...
[ "Apply", "the", "vector", "transformation", "." ]
python
train
Esri/ArcREST
src/arcrest/manageags/_system.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_system.py#L604-L629
def recover(self,runAsync=False): """ If the shared configuration store for a site is unavailable, a site in read-only mode will operate in a degraded capacity that allows access to the ArcGIS Server Administrator Directory. You can recover a site if the shared configuration stor...
[ "def", "recover", "(", "self", ",", "runAsync", "=", "False", ")", ":", "url", "=", "self", ".", "_url", "+", "\"/recover\"", "params", "=", "{", "\"f\"", ":", "\"json\"", ",", "\"runAsync\"", ":", "runAsync", "}", "return", "self", ".", "_post", "(", ...
If the shared configuration store for a site is unavailable, a site in read-only mode will operate in a degraded capacity that allows access to the ArcGIS Server Administrator Directory. You can recover a site if the shared configuration store is permanently lost. The site must be in rea...
[ "If", "the", "shared", "configuration", "store", "for", "a", "site", "is", "unavailable", "a", "site", "in", "read", "-", "only", "mode", "will", "operate", "in", "a", "degraded", "capacity", "that", "allows", "access", "to", "the", "ArcGIS", "Server", "Ad...
python
train
brocade/pynos
pynos/versions/base/interface.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/interface.py#L3321-L3367
def ve_interfaces(self, **kwargs): """list[dict]: A list of dictionary items describing the operational state of ve interfaces along with the ip address associations. Args: rbridge_id (str): rbridge-id for device. callback (function): A function executed upon completion ...
[ "def", "ve_interfaces", "(", "self", ",", "*", "*", "kwargs", ")", ":", "urn", "=", "\"{urn:brocade.com:mgmt:brocade-interface-ext}\"", "rbridge_id", "=", "kwargs", ".", "pop", "(", "'rbridge_id'", ",", "None", ")", "ip_result", "=", "[", "]", "request_interface...
list[dict]: A list of dictionary items describing the operational state of ve interfaces along with the ip address associations. Args: rbridge_id (str): rbridge-id for device. callback (function): A function executed upon completion of the method. The only param...
[ "list", "[", "dict", "]", ":", "A", "list", "of", "dictionary", "items", "describing", "the", "operational", "state", "of", "ve", "interfaces", "along", "with", "the", "ip", "address", "associations", "." ]
python
train
pylast/pylast
src/pylast/__init__.py
https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L2423-L2428
def is_subscriber(self): """Returns whether the user is a subscriber or not. True or False.""" doc = self._request(self.ws_prefix + ".getInfo", True) return _extract(doc, "subscriber") == "1"
[ "def", "is_subscriber", "(", "self", ")", ":", "doc", "=", "self", ".", "_request", "(", "self", ".", "ws_prefix", "+", "\".getInfo\"", ",", "True", ")", "return", "_extract", "(", "doc", ",", "\"subscriber\"", ")", "==", "\"1\"" ]
Returns whether the user is a subscriber or not. True or False.
[ "Returns", "whether", "the", "user", "is", "a", "subscriber", "or", "not", ".", "True", "or", "False", "." ]
python
train
specialunderwear/django-easymode
easymode/management/commands/easy_copy_language.py
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/management/commands/easy_copy_language.py#L24-L63
def handle(self, source, target, app=None, **options): """ command execution """ translation.activate(settings.LANGUAGE_CODE) if app: unpack = app.split('.') if len(unpack) == 2: models = [get_model(unpack[0], unpack[1])] elif len(unpack) == 1...
[ "def", "handle", "(", "self", ",", "source", ",", "target", ",", "app", "=", "None", ",", "*", "*", "options", ")", ":", "translation", ".", "activate", "(", "settings", ".", "LANGUAGE_CODE", ")", "if", "app", ":", "unpack", "=", "app", ".", "split",...
command execution
[ "command", "execution" ]
python
train
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/transforms/_util.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/_util.py#L47-L82
def as_vec4(obj, default=(0, 0, 0, 1)): """ Convert `obj` to 4-element vector (numpy array with shape[-1] == 4) Parameters ---------- obj : array-like Original object. default : array-like The defaults to use if the object does not have 4 entries. Returns ------- ob...
[ "def", "as_vec4", "(", "obj", ",", "default", "=", "(", "0", ",", "0", ",", "0", ",", "1", ")", ")", ":", "obj", "=", "np", ".", "atleast_2d", "(", "obj", ")", "# For multiple vectors, reshape to (..., 4)", "if", "obj", ".", "shape", "[", "-", "1", ...
Convert `obj` to 4-element vector (numpy array with shape[-1] == 4) Parameters ---------- obj : array-like Original object. default : array-like The defaults to use if the object does not have 4 entries. Returns ------- obj : array-like The object promoted to have 4...
[ "Convert", "obj", "to", "4", "-", "element", "vector", "(", "numpy", "array", "with", "shape", "[", "-", "1", "]", "==", "4", ")" ]
python
train
bpython/curtsies
curtsies/formatstring.py
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/formatstring.py#L395-L408
def ljust(self, width, fillchar=None): """S.ljust(width[, fillchar]) -> string If a fillchar is provided, less formatting information will be preserved """ if fillchar is not None: return fmtstr(self.s.ljust(width, fillchar), **self.shared_atts) to_add = ' ' * (width...
[ "def", "ljust", "(", "self", ",", "width", ",", "fillchar", "=", "None", ")", ":", "if", "fillchar", "is", "not", "None", ":", "return", "fmtstr", "(", "self", ".", "s", ".", "ljust", "(", "width", ",", "fillchar", ")", ",", "*", "*", "self", "."...
S.ljust(width[, fillchar]) -> string If a fillchar is provided, less formatting information will be preserved
[ "S", ".", "ljust", "(", "width", "[", "fillchar", "]", ")", "-", ">", "string" ]
python
train
ClimateImpactLab/DataFS
datafs/core/data_api.py
https://github.com/ClimateImpactLab/DataFS/blob/0d32c2b4e18d300a11b748a552f6adbc3dd8f59d/datafs/core/data_api.py#L304-L361
def listdir(self, location, authority_name=None): ''' List archive path components at a given location .. Note :: When using listdir on versioned archives, listdir will provide the version numbers when a full archive path is supplied as the location argument...
[ "def", "listdir", "(", "self", ",", "location", ",", "authority_name", "=", "None", ")", ":", "authority_name", ",", "location", "=", "self", ".", "_normalize_archive_name", "(", "location", ",", "authority_name", "=", "authority_name", ")", "if", "authority_nam...
List archive path components at a given location .. Note :: When using listdir on versioned archives, listdir will provide the version numbers when a full archive path is supplied as the location argument. This is because DataFS stores the archive path as a dire...
[ "List", "archive", "path", "components", "at", "a", "given", "location" ]
python
train
networks-lab/tidyextractors
tidyextractors/base_extractor.py
https://github.com/networks-lab/tidyextractors/blob/658448ed533beecf32adcc188fc64d1068d15ca6/tidyextractors/base_extractor.py#L136-L317
def expand_on(self, col1, col2, rename1 = None, rename2 = None, drop = [], drop_collections = False): """ Returns a reshaped version of extractor's data, where unique combinations of values from col1 and col2 are given individual rows. Example function call from ``tidymbox``: ....
[ "def", "expand_on", "(", "self", ",", "col1", ",", "col2", ",", "rename1", "=", "None", ",", "rename2", "=", "None", ",", "drop", "=", "[", "]", ",", "drop_collections", "=", "False", ")", ":", "# Assumption 1: Expanded columns are either atomic are built in col...
Returns a reshaped version of extractor's data, where unique combinations of values from col1 and col2 are given individual rows. Example function call from ``tidymbox``: .. code-block:: python self.expand_on('From', 'To', ['MessageID', 'Recipient'], rename1='From', rename2='Recip...
[ "Returns", "a", "reshaped", "version", "of", "extractor", "s", "data", "where", "unique", "combinations", "of", "values", "from", "col1", "and", "col2", "are", "given", "individual", "rows", "." ]
python
train
toumorokoshi/sprinter
sprinter/core/manifest.py
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/core/manifest.py#L196-L206
def get_context_dict(self): """ return a context dict of the desired state """ context_dict = {} for s in self.sections(): for k, v in self.manifest.items(s): context_dict["%s:%s" % (s, k)] = v for k, v in self.inputs.values().items(): context_dict...
[ "def", "get_context_dict", "(", "self", ")", ":", "context_dict", "=", "{", "}", "for", "s", "in", "self", ".", "sections", "(", ")", ":", "for", "k", ",", "v", "in", "self", ".", "manifest", ".", "items", "(", "s", ")", ":", "context_dict", "[", ...
return a context dict of the desired state
[ "return", "a", "context", "dict", "of", "the", "desired", "state" ]
python
train
deschler/django-modeltranslation
modeltranslation/translator.py
https://github.com/deschler/django-modeltranslation/blob/18fec04a5105cbd83fc3759f4fda20135b3a848c/modeltranslation/translator.py#L196-L220
def add_manager(model): """ Monkey patches the original model to use MultilingualManager instead of default managers (not only ``objects``, but also every manager defined and inherited). Custom managers are merged with MultilingualManager. """ if model._meta.abstract: return # Make ...
[ "def", "add_manager", "(", "model", ")", ":", "if", "model", ".", "_meta", ".", "abstract", ":", "return", "# Make all managers local for this model to fix patching parent model managers", "model", ".", "_meta", ".", "local_managers", "=", "model", ".", "_meta", ".", ...
Monkey patches the original model to use MultilingualManager instead of default managers (not only ``objects``, but also every manager defined and inherited). Custom managers are merged with MultilingualManager.
[ "Monkey", "patches", "the", "original", "model", "to", "use", "MultilingualManager", "instead", "of", "default", "managers", "(", "not", "only", "objects", "but", "also", "every", "manager", "defined", "and", "inherited", ")", "." ]
python
train
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L946-L1067
def reshape(self, *shape, **kwargs): """Returns a **view** of this array with a new shape without altering any data. Parameters ---------- shape : tuple of int, or n ints The new shape should not change the array size, namely ``np.prod(new_shape)`` should be equa...
[ "def", "reshape", "(", "self", ",", "*", "shape", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "shape", ")", "==", "1", "and", "isinstance", "(", "shape", "[", "0", "]", ",", "(", "list", ",", "tuple", ")", ")", ":", "shape", "=", "sh...
Returns a **view** of this array with a new shape without altering any data. Parameters ---------- shape : tuple of int, or n ints The new shape should not change the array size, namely ``np.prod(new_shape)`` should be equal to ``np.prod(self.shape)``. Some d...
[ "Returns", "a", "**", "view", "**", "of", "this", "array", "with", "a", "new", "shape", "without", "altering", "any", "data", "." ]
python
train
kashifrazzaqui/vyked
vyked/bus.py
https://github.com/kashifrazzaqui/vyked/blob/94d858e939cb9a723c3bfb5176a93b46ad3422e2/vyked/bus.py#L118-L137
def _request_sender(self, packet: dict): """ Sends a request to a server from a ServiceClient auto dispatch method called from self.send() """ node_id = self._get_node_id_for_packet(packet) client_protocol = self._client_protocols.get(node_id) if node_id and clie...
[ "def", "_request_sender", "(", "self", ",", "packet", ":", "dict", ")", ":", "node_id", "=", "self", ".", "_get_node_id_for_packet", "(", "packet", ")", "client_protocol", "=", "self", ".", "_client_protocols", ".", "get", "(", "node_id", ")", "if", "node_id...
Sends a request to a server from a ServiceClient auto dispatch method called from self.send()
[ "Sends", "a", "request", "to", "a", "server", "from", "a", "ServiceClient", "auto", "dispatch", "method", "called", "from", "self", ".", "send", "()" ]
python
train
vimalloc/flask-jwt-extended
flask_jwt_extended/jwt_manager.py
https://github.com/vimalloc/flask-jwt-extended/blob/569d3b89eb5d2586d0cff4581a346229c623cefc/flask_jwt_extended/jwt_manager.py#L150-L218
def _set_default_configuration_options(app): """ Sets the default configuration options used by this extension """ # Where to look for the JWT. Available options are cookies or headers app.config.setdefault('JWT_TOKEN_LOCATION', ('headers',)) # Options for JWTs when the ...
[ "def", "_set_default_configuration_options", "(", "app", ")", ":", "# Where to look for the JWT. Available options are cookies or headers", "app", ".", "config", ".", "setdefault", "(", "'JWT_TOKEN_LOCATION'", ",", "(", "'headers'", ",", ")", ")", "# Options for JWTs when the...
Sets the default configuration options used by this extension
[ "Sets", "the", "default", "configuration", "options", "used", "by", "this", "extension" ]
python
train
jobovy/galpy
galpy/actionAngle/actionAngleStaeckel.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/actionAngle/actionAngleStaeckel.py#L94-L192
def _evaluate(self,*args,**kwargs): """ NAME: __call__ (_evaluate) PURPOSE: evaluate the actions (jr,lz,jz) INPUT: Either: a) R,vR,vT,z,vz[,phi]: 1) floats: phase-space value for single object (phi is optional) (each can be ...
[ "def", "_evaluate", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "delta", "=", "kwargs", ".", "pop", "(", "'delta'", ",", "self", ".", "_delta", ")", "order", "=", "kwargs", ".", "get", "(", "'order'", ",", "self", ".", "_ord...
NAME: __call__ (_evaluate) PURPOSE: evaluate the actions (jr,lz,jz) INPUT: Either: a) R,vR,vT,z,vz[,phi]: 1) floats: phase-space value for single object (phi is optional) (each can be a Quantity) 2) numpy.ndarray: [N] phase...
[ "NAME", ":", "__call__", "(", "_evaluate", ")", "PURPOSE", ":", "evaluate", "the", "actions", "(", "jr", "lz", "jz", ")", "INPUT", ":", "Either", ":", "a", ")", "R", "vR", "vT", "z", "vz", "[", "phi", "]", ":", "1", ")", "floats", ":", "phase", ...
python
train
globocom/GloboNetworkAPI-client-python
networkapiclient/DireitoGrupoEquipamento.py
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DireitoGrupoEquipamento.py#L170-L209
def inserir( self, id_grupo_usuario, id_grupo_equipamento, leitura, escrita, alterar_config, exclusao): """Cria um novo direito de um grupo de usuário em um grupo de equipamento e retorna o seu identificador. :param id_...
[ "def", "inserir", "(", "self", ",", "id_grupo_usuario", ",", "id_grupo_equipamento", ",", "leitura", ",", "escrita", ",", "alterar_config", ",", "exclusao", ")", ":", "direito_map", "=", "dict", "(", ")", "direito_map", "[", "'id_grupo_usuario'", "]", "=", "id...
Cria um novo direito de um grupo de usuário em um grupo de equipamento e retorna o seu identificador. :param id_grupo_usuario: Identificador do grupo de usuário. :param id_grupo_equipamento: Identificador do grupo de equipamento. :param leitura: Indicação de permissão de leitura ('0' ou '1'). ...
[ "Cria", "um", "novo", "direito", "de", "um", "grupo", "de", "usuário", "em", "um", "grupo", "de", "equipamento", "e", "retorna", "o", "seu", "identificador", "." ]
python
train
mk-fg/graphite-metrics
graphite_metrics/collectors/__init__.py
https://github.com/mk-fg/graphite-metrics/blob/f0ba28d1ed000b2316d3c403206eba78dd7b4c50/graphite_metrics/collectors/__init__.py#L24-L38
def rate_limit(max_interval=20, sampling=3, f=lambda x: x): '''x rises by 1 from 0 on each iteraton, back to 0 on triggering. f(x) should rise up to f(max_interval) in some way (with default "f(x)=x" probability rises lineary with 100% chance on "x=max_interval"). "sampling" affect probablility in an "c=1-(1-c0...
[ "def", "rate_limit", "(", "max_interval", "=", "20", ",", "sampling", "=", "3", ",", "f", "=", "lambda", "x", ":", "x", ")", ":", "from", "random", "import", "random", "val", "=", "0", "val_max", "=", "float", "(", "f", "(", "max_interval", ")", ")...
x rises by 1 from 0 on each iteraton, back to 0 on triggering. f(x) should rise up to f(max_interval) in some way (with default "f(x)=x" probability rises lineary with 100% chance on "x=max_interval"). "sampling" affect probablility in an "c=1-(1-c0)*(1-c1)*...*(1-cx)" exponential way.
[ "x", "rises", "by", "1", "from", "0", "on", "each", "iteraton", "back", "to", "0", "on", "triggering", ".", "f", "(", "x", ")", "should", "rise", "up", "to", "f", "(", "max_interval", ")", "in", "some", "way", "(", "with", "default", "f", "(", "x...
python
train
foremast/foremast
src/foremast/elb/format_listeners.py
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/elb/format_listeners.py#L131-L161
def format_cert_name(env='', account='', region='', certificate=None): """Format the SSL certificate name into ARN for ELB. Args: env (str): Account environment name account (str): Account number for ARN region (str): AWS Region. certificate (str): Name of SSL certificate R...
[ "def", "format_cert_name", "(", "env", "=", "''", ",", "account", "=", "''", ",", "region", "=", "''", ",", "certificate", "=", "None", ")", ":", "cert_name", "=", "None", "if", "certificate", ":", "if", "certificate", ".", "startswith", "(", "'arn'", ...
Format the SSL certificate name into ARN for ELB. Args: env (str): Account environment name account (str): Account number for ARN region (str): AWS Region. certificate (str): Name of SSL certificate Returns: str: Fully qualified ARN for SSL certificate None: Cer...
[ "Format", "the", "SSL", "certificate", "name", "into", "ARN", "for", "ELB", "." ]
python
train
googlefonts/glyphsLib
Lib/glyphsLib/builder/guidelines.py
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/guidelines.py#L28-L63
def to_ufo_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" guidelines = glyphs_obj.guides if not guidelines: return new_guidelines = [] for guideline in guidelines: new_guideline = {} x, y = guideline.position angle = guideline.angle % 360 if _is_...
[ "def", "to_ufo_guidelines", "(", "self", ",", "ufo_obj", ",", "glyphs_obj", ")", ":", "guidelines", "=", "glyphs_obj", ".", "guides", "if", "not", "guidelines", ":", "return", "new_guidelines", "=", "[", "]", "for", "guideline", "in", "guidelines", ":", "new...
Set guidelines.
[ "Set", "guidelines", "." ]
python
train
PyPSA/PyPSA
pypsa/pf.py
https://github.com/PyPSA/PyPSA/blob/46954b1b3c21460550f7104681517065279a53b7/pypsa/pf.py#L495-L511
def apply_transformer_t_model(network): """Convert given T-model parameters to PI-model parameters using wye-delta transformation""" z_series = network.transformers.r_pu + 1j*network.transformers.x_pu y_shunt = network.transformers.g_pu + 1j*network.transformers.b_pu ts_b = (network.transformers.model...
[ "def", "apply_transformer_t_model", "(", "network", ")", ":", "z_series", "=", "network", ".", "transformers", ".", "r_pu", "+", "1j", "*", "network", ".", "transformers", ".", "x_pu", "y_shunt", "=", "network", ".", "transformers", ".", "g_pu", "+", "1j", ...
Convert given T-model parameters to PI-model parameters using wye-delta transformation
[ "Convert", "given", "T", "-", "model", "parameters", "to", "PI", "-", "model", "parameters", "using", "wye", "-", "delta", "transformation" ]
python
train
tanghaibao/jcvi
jcvi/assembly/hic.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/hic.py#L634-L659
def mergemat(args): """ %prog mergemat *.npy Combine counts from multiple .npy data files. """ p = OptionParser(mergemat.__doc__) p.set_outfile(outfile="out") opts, args = p.parse_args(args) if len(args) < 1: sys.exit(not p.print_help()) npyfiles = args A = np.load(npy...
[ "def", "mergemat", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "mergemat", ".", "__doc__", ")", "p", ".", "set_outfile", "(", "outfile", "=", "\"out\"", ")", "opts", ",", "args", "=", "p", ".", "parse_args", "(", "args", ")", "if", "len", ...
%prog mergemat *.npy Combine counts from multiple .npy data files.
[ "%prog", "mergemat", "*", ".", "npy" ]
python
train
zyga/python-glibc
pyglibc/selectors.py
https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/pyglibc/selectors.py#L213-L227
def from_epoll_events(cls, epoll_events): """ Create a :class:`_EpollSelectorEvents` instance out of a bit mask using ``EPOLL*`` family of constants. """ self = cls() if epoll_events & select.EPOLLIN: self |= EVENT_READ if epoll_events & select.EPOLLOU...
[ "def", "from_epoll_events", "(", "cls", ",", "epoll_events", ")", ":", "self", "=", "cls", "(", ")", "if", "epoll_events", "&", "select", ".", "EPOLLIN", ":", "self", "|=", "EVENT_READ", "if", "epoll_events", "&", "select", ".", "EPOLLOUT", ":", "self", ...
Create a :class:`_EpollSelectorEvents` instance out of a bit mask using ``EPOLL*`` family of constants.
[ "Create", "a", ":", "class", ":", "_EpollSelectorEvents", "instance", "out", "of", "a", "bit", "mask", "using", "EPOLL", "*", "family", "of", "constants", "." ]
python
train
sangoma/pysensu
pysensu/api.py
https://github.com/sangoma/pysensu/blob/dc6799edbf2635247aec61fcf45b04ddec1beb49/pysensu/api.py#L133-L138
def delete_event(self, client, check): """ Resolves an event for a given check on a given client. (delayed action) """ self._request('DELETE', '/events/{}/{}'.format(client, check)) return True
[ "def", "delete_event", "(", "self", ",", "client", ",", "check", ")", ":", "self", ".", "_request", "(", "'DELETE'", ",", "'/events/{}/{}'", ".", "format", "(", "client", ",", "check", ")", ")", "return", "True" ]
Resolves an event for a given check on a given client. (delayed action)
[ "Resolves", "an", "event", "for", "a", "given", "check", "on", "a", "given", "client", ".", "(", "delayed", "action", ")" ]
python
train
asweigart/pyautogui
pyautogui/_pyautogui_osx.py
https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_osx.py#L264-L285
def _specialKeyEvent(key, upDown): """ Helper method for special keys. Source: http://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac """ assert upDown in ('up', 'down'), "upDown argument must be 'up' or 'down'" key_code = special_key_translate_table[key] ev = AppKit.NSEve...
[ "def", "_specialKeyEvent", "(", "key", ",", "upDown", ")", ":", "assert", "upDown", "in", "(", "'up'", ",", "'down'", ")", ",", "\"upDown argument must be 'up' or 'down'\"", "key_code", "=", "special_key_translate_table", "[", "key", "]", "ev", "=", "AppKit", "....
Helper method for special keys. Source: http://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac
[ "Helper", "method", "for", "special", "keys", "." ]
python
train
jkitzes/macroeco
macroeco/compare/_compare.py
https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/compare/_compare.py#L281-L303
def sum_of_squares(obs, pred): """ Sum of squares between observed and predicted data Parameters ---------- obs : iterable Observed data pred : iterable Predicted data Returns ------- float Sum of squares Notes ----- The length of observed and p...
[ "def", "sum_of_squares", "(", "obs", ",", "pred", ")", ":", "return", "np", ".", "sum", "(", "(", "np", ".", "array", "(", "obs", ")", "-", "np", ".", "array", "(", "pred", ")", ")", "**", "2", ")" ]
Sum of squares between observed and predicted data Parameters ---------- obs : iterable Observed data pred : iterable Predicted data Returns ------- float Sum of squares Notes ----- The length of observed and predicted data must match.
[ "Sum", "of", "squares", "between", "observed", "and", "predicted", "data" ]
python
train
googleads/googleads-python-lib
googleads/adwords.py
https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/googleads/adwords.py#L2416-L2451
def NextPage(self, page=None): """Sets the LIMIT clause of the AWQL to the next page. This method is meant to be used with HasNext(). When using DataService, page is needed, as its paging mechanism is different from other services. For details, see https://developers.google.com/adwords/api/docs/gui...
[ "def", "NextPage", "(", "self", ",", "page", "=", "None", ")", ":", "if", "self", ".", "_start_index", "is", "None", ":", "raise", "ValueError", "(", "'Cannot page through query with no LIMIT clause.'", ")", "# DataService has a different paging mechanism, resulting in di...
Sets the LIMIT clause of the AWQL to the next page. This method is meant to be used with HasNext(). When using DataService, page is needed, as its paging mechanism is different from other services. For details, see https://developers.google.com/adwords/api/docs/guides/bid-landscapes#paging_through_resu...
[ "Sets", "the", "LIMIT", "clause", "of", "the", "AWQL", "to", "the", "next", "page", "." ]
python
train
mangalam-research/selenic
selenic/util.py
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L401-L409
def wait_until_not(self, condition): """ Waits for a condition to be false. :param condition: Should be a callable that operates in the same way ``WebDriverWait.until_not`` expects. :returns: Whatever ``WebDriverWait.until_not`` returns. """ ret...
[ "def", "wait_until_not", "(", "self", ",", "condition", ")", ":", "return", "WebDriverWait", "(", "self", ".", "driver", ",", "self", ".", "timeout", ")", ".", "until_not", "(", "condition", ")" ]
Waits for a condition to be false. :param condition: Should be a callable that operates in the same way ``WebDriverWait.until_not`` expects. :returns: Whatever ``WebDriverWait.until_not`` returns.
[ "Waits", "for", "a", "condition", "to", "be", "false", "." ]
python
train
coded-by-hand/mass
env/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py
https://github.com/coded-by-hand/mass/blob/59005479efed3cd8598a8f0c66791a4482071899/env/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py#L647-L659
def check_if_exists(self): """Find an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.conflicts_with appropriately.""" if self.req is None: return False try: self.satisfied_by = pkg_resources.get_...
[ "def", "check_if_exists", "(", "self", ")", ":", "if", "self", ".", "req", "is", "None", ":", "return", "False", "try", ":", "self", ".", "satisfied_by", "=", "pkg_resources", ".", "get_distribution", "(", "self", ".", "req", ")", "except", "pkg_resources"...
Find an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.conflicts_with appropriately.
[ "Find", "an", "installed", "distribution", "that", "satisfies", "or", "conflicts", "with", "this", "requirement", "and", "set", "self", ".", "satisfied_by", "or", "self", ".", "conflicts_with", "appropriately", "." ]
python
train
h2oai/h2o-3
h2o-py/h2o/frame.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/frame.py#L2409-L2426
def lstrip(self, set=" "): """ Return a copy of the column with leading characters removed. The set argument is a string specifying the set of characters to be removed. If omitted, the set argument defaults to removing whitespace. :param character set: The set of characters to ...
[ "def", "lstrip", "(", "self", ",", "set", "=", "\" \"", ")", ":", "# work w/ None; parity with python lstrip", "if", "set", "is", "None", ":", "set", "=", "\" \"", "fr", "=", "H2OFrame", ".", "_expr", "(", "expr", "=", "ExprNode", "(", "\"lstrip\"", ",", ...
Return a copy of the column with leading characters removed. The set argument is a string specifying the set of characters to be removed. If omitted, the set argument defaults to removing whitespace. :param character set: The set of characters to lstrip from strings in column. :returns...
[ "Return", "a", "copy", "of", "the", "column", "with", "leading", "characters", "removed", "." ]
python
test
mathandy/svgpathtools
svgpathtools/path.py
https://github.com/mathandy/svgpathtools/blob/fd7348a1dfd88b65ea61da02325c6605aedf8c4f/svgpathtools/path.py#L2443-L2490
def area(self, chord_length=1e-4): """Find area enclosed by path. Approximates any Arc segments in the Path with lines approximately `chord_length` long, and returns the area enclosed by the approximated Path. Default chord length is 0.01. If Arc segments are included ...
[ "def", "area", "(", "self", ",", "chord_length", "=", "1e-4", ")", ":", "def", "area_without_arcs", "(", "path", ")", ":", "area_enclosed", "=", "0", "for", "seg", "in", "path", ":", "x", "=", "real", "(", "seg", ".", "poly", "(", ")", ")", "dy", ...
Find area enclosed by path. Approximates any Arc segments in the Path with lines approximately `chord_length` long, and returns the area enclosed by the approximated Path. Default chord length is 0.01. If Arc segments are included in path, to ensure accurate results, make ...
[ "Find", "area", "enclosed", "by", "path", ".", "Approximates", "any", "Arc", "segments", "in", "the", "Path", "with", "lines", "approximately", "chord_length", "long", "and", "returns", "the", "area", "enclosed", "by", "the", "approximated", "Path", ".", "Defa...
python
train
billyoverton/tweetqueue
tweetqueue/TweetList.py
https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/TweetList.py#L110-L121
def peek(self): """Peeks at the first of the list without removing it.""" c = self.connection.cursor() first_tweet_id = c.execute("SELECT tweet from tweetlist where label='first_tweet'").next()[0] if first_tweet_id is None: # No tweets are in the list, so return None ...
[ "def", "peek", "(", "self", ")", ":", "c", "=", "self", ".", "connection", ".", "cursor", "(", ")", "first_tweet_id", "=", "c", ".", "execute", "(", "\"SELECT tweet from tweetlist where label='first_tweet'\"", ")", ".", "next", "(", ")", "[", "0", "]", "if...
Peeks at the first of the list without removing it.
[ "Peeks", "at", "the", "first", "of", "the", "list", "without", "removing", "it", "." ]
python
train
AtteqCom/zsl
src/zsl/utils/xml_to_json.py
https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/xml_to_json.py#L145-L171
def _parse_list(element, definition): """Parse xml element by definition given by list. Find all elements matched by the string given as the first value in the list (as XPath or @attribute). If there is a second argument it will be handled as a definitions for the elements matched or the text when...
[ "def", "_parse_list", "(", "element", ",", "definition", ")", ":", "if", "len", "(", "definition", ")", "==", "0", ":", "raise", "XmlToJsonException", "(", "'List definition needs some definition'", ")", "tag", "=", "definition", "[", "0", "]", "tag_def", "=",...
Parse xml element by definition given by list. Find all elements matched by the string given as the first value in the list (as XPath or @attribute). If there is a second argument it will be handled as a definitions for the elements matched or the text when not. :param element: ElementTree elemen...
[ "Parse", "xml", "element", "by", "definition", "given", "by", "list", "." ]
python
train
ewels/MultiQC
multiqc/modules/bismark/bismark.py
https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/bismark/bismark.py#L186-L232
def parse_bismark_mbias(self, f): """ Parse the Bismark M-Bias plot data """ s = f['s_name'] self.bismark_mbias_data['meth']['CpG_R1'][s] = {} self.bismark_mbias_data['meth']['CHG_R1'][s] = {} self.bismark_mbias_data['meth']['CHH_R1'][s] = {} self.bismark_mbias_data['cov'...
[ "def", "parse_bismark_mbias", "(", "self", ",", "f", ")", ":", "s", "=", "f", "[", "'s_name'", "]", "self", ".", "bismark_mbias_data", "[", "'meth'", "]", "[", "'CpG_R1'", "]", "[", "s", "]", "=", "{", "}", "self", ".", "bismark_mbias_data", "[", "'m...
Parse the Bismark M-Bias plot data
[ "Parse", "the", "Bismark", "M", "-", "Bias", "plot", "data" ]
python
train
matthewdeanmartin/jiggle_version
jiggle_version/commands.py
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/commands.py#L50-L71
def find_version(project, source, force_init): # type: (str, str, bool) ->None """ Entry point to just find a version and print next :return: """ # quiet! no noise file_opener = FileOpener() finder = FindVersion(project, source, file_opener, force_init=force_init) if finder.PROJECT is N...
[ "def", "find_version", "(", "project", ",", "source", ",", "force_init", ")", ":", "# type: (str, str, bool) ->None", "# quiet! no noise", "file_opener", "=", "FileOpener", "(", ")", "finder", "=", "FindVersion", "(", "project", ",", "source", ",", "file_opener", ...
Entry point to just find a version and print next :return:
[ "Entry", "point", "to", "just", "find", "a", "version", "and", "print", "next", ":", "return", ":" ]
python
train
n1analytics/python-paillier
phe/command_line.py
https://github.com/n1analytics/python-paillier/blob/955f8c0bfa9623be15b75462b121d28acf70f04b/phe/command_line.py#L72-L87
def extract(input, output): """Extract public key from private key. Given INPUT a private paillier key file as generated by generate, extract the public key portion to OUTPUT. Use "-" to output to stdout. """ log("Loading paillier keypair") priv = json.load(input) error_msg = "Invalid ...
[ "def", "extract", "(", "input", ",", "output", ")", ":", "log", "(", "\"Loading paillier keypair\"", ")", "priv", "=", "json", ".", "load", "(", "input", ")", "error_msg", "=", "\"Invalid private key\"", "assert", "'pub'", "in", "priv", ",", "error_msg", "as...
Extract public key from private key. Given INPUT a private paillier key file as generated by generate, extract the public key portion to OUTPUT. Use "-" to output to stdout.
[ "Extract", "public", "key", "from", "private", "key", "." ]
python
train
albert12132/templar
templar/api/rules/table_of_contents.py
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/api/rules/table_of_contents.py#L57-L85
def _build_list_items(self, matches): """Returns the HTML list items for the next matches that have a larger (or equal) header compared to the first header's level. This method mutatively removes elements from the front of matches as it processes each element. This method assumes matche...
[ "def", "_build_list_items", "(", "self", ",", "matches", ")", ":", "assert", "len", "(", "matches", ")", ">", "0", ",", "\"Should be at least one match, by assumption\"", "lines", "=", "[", "]", "current_level", "=", "matches", "[", "0", "]", "[", "0", "]", ...
Returns the HTML list items for the next matches that have a larger (or equal) header compared to the first header's level. This method mutatively removes elements from the front of matches as it processes each element. This method assumes matches contains at least one match. PARAMETER...
[ "Returns", "the", "HTML", "list", "items", "for", "the", "next", "matches", "that", "have", "a", "larger", "(", "or", "equal", ")", "header", "compared", "to", "the", "first", "header", "s", "level", "." ]
python
train
coin-or/GiMPy
src/gimpy/graph.py
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2046-L2067
def floyd_warshall_get_path(self, distance, nextn, i, j): ''' API: floyd_warshall_get_path(self, distance, nextn, i, j): Description: Finds shortest path between i and j using distance and nextn dictionaries. Pre: (1) distance and nextn are...
[ "def", "floyd_warshall_get_path", "(", "self", ",", "distance", ",", "nextn", ",", "i", ",", "j", ")", ":", "if", "distance", "[", "(", "i", ",", "j", ")", "]", "==", "'infinity'", ":", "return", "None", "k", "=", "nextn", "[", "(", "i", ",", "j"...
API: floyd_warshall_get_path(self, distance, nextn, i, j): Description: Finds shortest path between i and j using distance and nextn dictionaries. Pre: (1) distance and nextn are outputs of floyd_warshall method. (2) The graph does not have a n...
[ "API", ":", "floyd_warshall_get_path", "(", "self", "distance", "nextn", "i", "j", ")", ":", "Description", ":", "Finds", "shortest", "path", "between", "i", "and", "j", "using", "distance", "and", "nextn", "dictionaries", ".", "Pre", ":", "(", "1", ")", ...
python
train
marshmallow-code/marshmallow
src/marshmallow/utils.py
https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L167-L178
def rfcformat(dt, localtime=False): """Return the RFC822-formatted representation of a datetime object. :param datetime dt: The datetime. :param bool localtime: If ``True``, return the date relative to the local timezone instead of UTC, displaying the proper offset, e.g. "Sun, 10 Nov 2013 0...
[ "def", "rfcformat", "(", "dt", ",", "localtime", "=", "False", ")", ":", "if", "not", "localtime", ":", "return", "formatdate", "(", "timegm", "(", "dt", ".", "utctimetuple", "(", ")", ")", ")", "else", ":", "return", "local_rfcformat", "(", "dt", ")" ...
Return the RFC822-formatted representation of a datetime object. :param datetime dt: The datetime. :param bool localtime: If ``True``, return the date relative to the local timezone instead of UTC, displaying the proper offset, e.g. "Sun, 10 Nov 2013 08:23:45 -0600"
[ "Return", "the", "RFC822", "-", "formatted", "representation", "of", "a", "datetime", "object", "." ]
python
train
Maplecroft/Winston
winston/utils.py
https://github.com/Maplecroft/Winston/blob/d70394c60d5b56d8b374b4db2240394dfd45cfa8/winston/utils.py#L33-L47
def raster_to_shape(raster): """Take a raster and return a polygon representing the outer edge.""" left = raster.bounds.left right = raster.bounds.right top = raster.bounds.top bottom = raster.bounds.bottom top_left = (left, top) top_right = (right, top) bottom_left = (left, bottom) ...
[ "def", "raster_to_shape", "(", "raster", ")", ":", "left", "=", "raster", ".", "bounds", ".", "left", "right", "=", "raster", ".", "bounds", ".", "right", "top", "=", "raster", ".", "bounds", ".", "top", "bottom", "=", "raster", ".", "bounds", ".", "...
Take a raster and return a polygon representing the outer edge.
[ "Take", "a", "raster", "and", "return", "a", "polygon", "representing", "the", "outer", "edge", "." ]
python
train