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
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#L1779-L1825
def route_filter_rules(self): """Instance depends on the API version: * 2016-12-01: :class:`RouteFilterRulesOperations<azure.mgmt.network.v2016_12_01.operations.RouteFilterRulesOperations>` * 2017-03-01: :class:`RouteFilterRulesOperations<azure.mgmt.network.v2017_03_01.operations.RouteFil...
[ "def", "route_filter_rules", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'route_filter_rules'", ")", "if", "api_version", "==", "'2016-12-01'", ":", "from", ".", "v2016_12_01", ".", "operations", "import", "RouteFilterRulesOpera...
Instance depends on the API version: * 2016-12-01: :class:`RouteFilterRulesOperations<azure.mgmt.network.v2016_12_01.operations.RouteFilterRulesOperations>` * 2017-03-01: :class:`RouteFilterRulesOperations<azure.mgmt.network.v2017_03_01.operations.RouteFilterRulesOperations>` * 2017-06...
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
python
train
tylerbutler/engineer
engineer/util.py
https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/util.py#L214-L225
def ensure_exists(p, assume_dirs=False): """ Ensures a given path *p* exists. If a path to a file is passed in, then the path to the file will be checked. This can be overridden by passing a value of ``True`` to ``assume_dirs``, in which case the paths will be assumed to be to directories, not files. ...
[ "def", "ensure_exists", "(", "p", ",", "assume_dirs", "=", "False", ")", ":", "if", "path", "(", "p", ")", ".", "ext", "and", "not", "assume_dirs", ":", "path", "(", "p", ")", ".", "dirname", "(", ")", ".", "makedirs_p", "(", ")", "else", ":", "p...
Ensures a given path *p* exists. If a path to a file is passed in, then the path to the file will be checked. This can be overridden by passing a value of ``True`` to ``assume_dirs``, in which case the paths will be assumed to be to directories, not files.
[ "Ensures", "a", "given", "path", "*", "p", "*", "exists", "." ]
python
train
JNRowe/upoints
upoints/baken.py
https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/baken.py#L123-L205
def import_locations(self, baken_file): """Import baken data files. ``import_locations()`` returns a dictionary with keys containing the section title, and values consisting of a collection :class:`Baken` objects. It expects data files in the format used by the baken_ amateur r...
[ "def", "import_locations", "(", "self", ",", "baken_file", ")", ":", "self", ".", "_baken_file", "=", "baken_file", "data", "=", "ConfigParser", "(", ")", "if", "hasattr", "(", "baken_file", ",", "'readlines'", ")", ":", "data", ".", "readfp", "(", "baken_...
Import baken data files. ``import_locations()`` returns a dictionary with keys containing the section title, and values consisting of a collection :class:`Baken` objects. It expects data files in the format used by the baken_ amateur radio package, which is Windows INI style fi...
[ "Import", "baken", "data", "files", "." ]
python
train
Parsl/libsubmit
libsubmit/utils.py
https://github.com/Parsl/libsubmit/blob/27a41c16dd6f1c16d830a9ce1c97804920a59f64/libsubmit/utils.py#L4-L17
def wtime_to_minutes(time_string): ''' wtime_to_minutes Convert standard wallclock time string to minutes. Args: - Time_string in HH:MM:SS format Returns: (int) minutes ''' hours, mins, seconds = time_string.split(':') return int(hours) * 60 + int(mins) + 1
[ "def", "wtime_to_minutes", "(", "time_string", ")", ":", "hours", ",", "mins", ",", "seconds", "=", "time_string", ".", "split", "(", "':'", ")", "return", "int", "(", "hours", ")", "*", "60", "+", "int", "(", "mins", ")", "+", "1" ]
wtime_to_minutes Convert standard wallclock time string to minutes. Args: - Time_string in HH:MM:SS format Returns: (int) minutes
[ "wtime_to_minutes" ]
python
train
cloudendpoints/endpoints-python
endpoints/util.py
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L262-L287
def check_list_type(objects, allowed_type, name, allow_none=True): """Verify that objects in list are of the allowed type or raise TypeError. Args: objects: The list of objects to check. allowed_type: The allowed type of items in 'settings'. name: Name of the list of objects, added to the exception. ...
[ "def", "check_list_type", "(", "objects", ",", "allowed_type", ",", "name", ",", "allow_none", "=", "True", ")", ":", "if", "objects", "is", "None", ":", "if", "not", "allow_none", ":", "raise", "TypeError", "(", "'%s is None, which is not allowed.'", "%", "na...
Verify that objects in list are of the allowed type or raise TypeError. Args: objects: The list of objects to check. allowed_type: The allowed type of items in 'settings'. name: Name of the list of objects, added to the exception. allow_none: If set, None is also allowed. Raises: TypeError: if...
[ "Verify", "that", "objects", "in", "list", "are", "of", "the", "allowed", "type", "or", "raise", "TypeError", "." ]
python
train
google/apitools
apitools/base/protorpclite/protojson.py
https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/protorpclite/protojson.py#L256-L303
def __decode_dictionary(self, message_type, dictionary): """Merge dictionary in to message. Args: message: Message to merge dictionary in to. dictionary: Dictionary to extract information from. Dictionary is as parsed from JSON. Nested objects will also be dictionaries...
[ "def", "__decode_dictionary", "(", "self", ",", "message_type", ",", "dictionary", ")", ":", "message", "=", "message_type", "(", ")", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "dictionary", ")", ":", "if", "value", "is", "None", ":...
Merge dictionary in to message. Args: message: Message to merge dictionary in to. dictionary: Dictionary to extract information from. Dictionary is as parsed from JSON. Nested objects will also be dictionaries.
[ "Merge", "dictionary", "in", "to", "message", "." ]
python
train
Duke-GCB/DukeDSClient
ddsc/core/d4s2.py
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/d4s2.py#L151-L160
def check_response(self, response): """ Raises error if the response isn't successful. :param response: requests.Response response to be checked """ if response.status_code == 401: raise D4S2Error(UNAUTHORIZED_MESSAGE) if not 200 <= response.status_code < 300:...
[ "def", "check_response", "(", "self", ",", "response", ")", ":", "if", "response", ".", "status_code", "==", "401", ":", "raise", "D4S2Error", "(", "UNAUTHORIZED_MESSAGE", ")", "if", "not", "200", "<=", "response", ".", "status_code", "<", "300", ":", "rai...
Raises error if the response isn't successful. :param response: requests.Response response to be checked
[ "Raises", "error", "if", "the", "response", "isn", "t", "successful", ".", ":", "param", "response", ":", "requests", ".", "Response", "response", "to", "be", "checked" ]
python
train
CloverHealth/temple
temple/ls.py
https://github.com/CloverHealth/temple/blob/d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd/temple/ls.py#L32-L74
def _code_search(query, github_user=None): """Performs a Github API code search Args: query (str): The query sent to Github's code search github_user (str, optional): The Github user being searched in the query string Returns: dict: A dictionary of repository information keyed on t...
[ "def", "_code_search", "(", "query", ",", "github_user", "=", "None", ")", ":", "github_client", "=", "temple", ".", "utils", ".", "GithubClient", "(", ")", "headers", "=", "{", "'Accept'", ":", "'application/vnd.github.v3.text-match+json'", "}", "resp", "=", ...
Performs a Github API code search Args: query (str): The query sent to Github's code search github_user (str, optional): The Github user being searched in the query string Returns: dict: A dictionary of repository information keyed on the git SSH url Raises: `InvalidGithub...
[ "Performs", "a", "Github", "API", "code", "search" ]
python
valid
tomnor/channelpack
channelpack/pullxl.py
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pullxl.py#L435-L446
def fromxldate(xldate, datemode=1): """Return a python datetime object xldate: float The xl number. datemode: int 0: 1900-based, 1: 1904-based. See xlrd documentation. """ t = xlrd.xldate_as_tuple(xldate, datemode) return datetime.datetime(*t)
[ "def", "fromxldate", "(", "xldate", ",", "datemode", "=", "1", ")", ":", "t", "=", "xlrd", ".", "xldate_as_tuple", "(", "xldate", ",", "datemode", ")", "return", "datetime", ".", "datetime", "(", "*", "t", ")" ]
Return a python datetime object xldate: float The xl number. datemode: int 0: 1900-based, 1: 1904-based. See xlrd documentation.
[ "Return", "a", "python", "datetime", "object" ]
python
train
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L145-L167
def flush(self): """Force a flush.""" if not self.items: return retry = 0 options = {"deadline": DATASTORE_DEADLINE} while retry <= self.__timeout_retries: try: self.__flush_function(self.items, options) self.clear() break except db.Timeout, e: logg...
[ "def", "flush", "(", "self", ")", ":", "if", "not", "self", ".", "items", ":", "return", "retry", "=", "0", "options", "=", "{", "\"deadline\"", ":", "DATASTORE_DEADLINE", "}", "while", "retry", "<=", "self", ".", "__timeout_retries", ":", "try", ":", ...
Force a flush.
[ "Force", "a", "flush", "." ]
python
train
pyroscope/pyrobase
src/pyrobase/bencode.py
https://github.com/pyroscope/pyrobase/blob/7a2591baa492c3d8997ab4801b97c7b1f2ebc6b1/src/pyrobase/bencode.py#L124-L155
def encode(self, obj): """ Add the given object to the result. """ if isinstance(obj, int_like_types): self.result.append("i%de" % obj) elif isinstance(obj, string_types): self.result.extend([str(len(obj)), ':', str(obj)]) elif hasattr(obj, "__bencode__"):...
[ "def", "encode", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "int_like_types", ")", ":", "self", ".", "result", ".", "append", "(", "\"i%de\"", "%", "obj", ")", "elif", "isinstance", "(", "obj", ",", "string_types", ")", "...
Add the given object to the result.
[ "Add", "the", "given", "object", "to", "the", "result", "." ]
python
train
boriel/zxbasic
symbols/vararray.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/vararray.py#L38-L41
def count(self): """ Total number of array cells """ return functools.reduce(lambda x, y: x * y, (x.count for x in self.bounds))
[ "def", "count", "(", "self", ")", ":", "return", "functools", ".", "reduce", "(", "lambda", "x", ",", "y", ":", "x", "*", "y", ",", "(", "x", ".", "count", "for", "x", "in", "self", ".", "bounds", ")", ")" ]
Total number of array cells
[ "Total", "number", "of", "array", "cells" ]
python
train
gitpython-developers/GitPython
git/index/typ.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/index/typ.py#L172-L176
def from_blob(cls, blob, stage=0): """:return: Minimal entry resembling the given blob object""" time = pack(">LL", 0, 0) return IndexEntry((blob.mode, blob.binsha, stage << CE_STAGESHIFT, blob.path, time, time, 0, 0, 0, 0, blob.size))
[ "def", "from_blob", "(", "cls", ",", "blob", ",", "stage", "=", "0", ")", ":", "time", "=", "pack", "(", "\">LL\"", ",", "0", ",", "0", ")", "return", "IndexEntry", "(", "(", "blob", ".", "mode", ",", "blob", ".", "binsha", ",", "stage", "<<", ...
:return: Minimal entry resembling the given blob object
[ ":", "return", ":", "Minimal", "entry", "resembling", "the", "given", "blob", "object" ]
python
train
wavefrontHQ/python-client
wavefront_api_client/models/message.py
https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/models/message.py#L157-L174
def display(self, display): """Sets the display of this Message. The form of display for this message # noqa: E501 :param display: The display of this Message. # noqa: E501 :type: str """ if display is None: raise ValueError("Invalid value for `display`, m...
[ "def", "display", "(", "self", ",", "display", ")", ":", "if", "display", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `display`, must not be `None`\"", ")", "# noqa: E501", "allowed_values", "=", "[", "\"BANNER\"", ",", "\"TOASTER\"", "]", ...
Sets the display of this Message. The form of display for this message # noqa: E501 :param display: The display of this Message. # noqa: E501 :type: str
[ "Sets", "the", "display", "of", "this", "Message", "." ]
python
train
portfors-lab/sparkle
sparkle/gui/stim/qstimulus.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/qstimulus.py#L196-L206
def showEditor(self): """Creates and shows an editor for this Stimulus""" if self.editor is not None: editor = self.editor() editor.setModel(self) factory = get_stimulus_factory(self._stim.stimType()) editor.editingFinished.connect(factory.update) ...
[ "def", "showEditor", "(", "self", ")", ":", "if", "self", ".", "editor", "is", "not", "None", ":", "editor", "=", "self", ".", "editor", "(", ")", "editor", ".", "setModel", "(", "self", ")", "factory", "=", "get_stimulus_factory", "(", "self", ".", ...
Creates and shows an editor for this Stimulus
[ "Creates", "and", "shows", "an", "editor", "for", "this", "Stimulus" ]
python
train
mitsei/dlkit
dlkit/json_/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/sessions.py#L6241-L6262
def is_child_of_objective_bank(self, id_, objective_bank_id): """Tests if an objective bank is a direct child of another. arg: id (osid.id.Id): an ``Id`` arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (boolean) - ``true`` if the ``id``...
[ "def", "is_child_of_objective_bank", "(", "self", ",", "id_", ",", "objective_bank_id", ")", ":", "# Implemented from template for", "# osid.resource.BinHierarchySession.is_child_of_bin", "if", "self", ".", "_catalog_session", "is", "not", "None", ":", "return", "self", "...
Tests if an objective bank is a direct child of another. arg: id (osid.id.Id): an ``Id`` arg: objective_bank_id (osid.id.Id): the ``Id`` of an objective bank return: (boolean) - ``true`` if the ``id`` is a child of ``objective_bank_id,`` ``false`` otherwis...
[ "Tests", "if", "an", "objective", "bank", "is", "a", "direct", "child", "of", "another", "." ]
python
train
RudolfCardinal/pythonlib
cardinal_pythonlib/pdf.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/pdf.py#L232-L402
def make_pdf_from_html( # Mandatory parameters: on_disk: bool, html: str, # Disk options: output_path: str = None, # Shared options: header_html: str = None, footer_html: str = None, wkhtmltopdf_filename: str = _WKHTMLTOPDF_FILENAME, wkhtml...
[ "def", "make_pdf_from_html", "(", "# Mandatory parameters:", "on_disk", ":", "bool", ",", "html", ":", "str", ",", "# Disk options:", "output_path", ":", "str", "=", "None", ",", "# Shared options:", "header_html", ":", "str", "=", "None", ",", "footer_html", ":...
Takes HTML and either returns a PDF in memory or makes one on disk. For preference, uses ``wkhtmltopdf`` (with ``pdfkit``): - faster than ``xhtml2pdf`` - tables not buggy like ``Weasyprint`` - however, doesn't support CSS Paged Media, so we have the ``header_html`` and ``footer_html`` options to...
[ "Takes", "HTML", "and", "either", "returns", "a", "PDF", "in", "memory", "or", "makes", "one", "on", "disk", "." ]
python
train
wilson-eft/wilson
wilson/translate/wet.py
https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1462-L1478
def Fierz_to_EOS_chrom(C, dd, parameters): """From Fierz to chromomagnetic EOS basis for Class V. dd should be of the form 'sb', 'ds' etc.""" p = parameters V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"]) Vtb = V[2,2] Vts = V[2,1] e = sqrt(4 * pi * parameters['alpha_e']) ...
[ "def", "Fierz_to_EOS_chrom", "(", "C", ",", "dd", ",", "parameters", ")", ":", "p", "=", "parameters", "V", "=", "ckmutil", ".", "ckm", ".", "ckm_tree", "(", "p", "[", "\"Vus\"", "]", ",", "p", "[", "\"Vub\"", "]", ",", "p", "[", "\"Vcb\"", "]", ...
From Fierz to chromomagnetic EOS basis for Class V. dd should be of the form 'sb', 'ds' etc.
[ "From", "Fierz", "to", "chromomagnetic", "EOS", "basis", "for", "Class", "V", ".", "dd", "should", "be", "of", "the", "form", "sb", "ds", "etc", "." ]
python
train
micha030201/aionationstates
aionationstates/world_.py
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L124-L150
def regionsbytag(self, *tags): """All regions with any of the named tags. Parameters ---------- *tags : str Regional tags. Can be preceded by a ``-`` to select regions without that tag. Returns ------- an :class:`ApiQuery` of a list of :...
[ "def", "regionsbytag", "(", "self", ",", "*", "tags", ")", ":", "if", "len", "(", "tags", ")", ">", "10", ":", "raise", "ValueError", "(", "'You can specify up to 10 tags'", ")", "if", "not", "tags", ":", "raise", "ValueError", "(", "'No tags specified'", ...
All regions with any of the named tags. Parameters ---------- *tags : str Regional tags. Can be preceded by a ``-`` to select regions without that tag. Returns ------- an :class:`ApiQuery` of a list of :class:`Region`
[ "All", "regions", "with", "any", "of", "the", "named", "tags", "." ]
python
train
awacha/sastool
sastool/io/credo_saxsctrl/header.py
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_saxsctrl/header.py#L114-L126
def distance(self) -> ErrorValue: """Sample-to-detector distance""" if 'DistCalibrated' in self._data: dist = self._data['DistCalibrated'] else: dist = self._data["Dist"] if 'DistCalibratedError' in self._data: disterr = self._data['DistCalibratedError...
[ "def", "distance", "(", "self", ")", "->", "ErrorValue", ":", "if", "'DistCalibrated'", "in", "self", ".", "_data", ":", "dist", "=", "self", ".", "_data", "[", "'DistCalibrated'", "]", "else", ":", "dist", "=", "self", ".", "_data", "[", "\"Dist\"", "...
Sample-to-detector distance
[ "Sample", "-", "to", "-", "detector", "distance" ]
python
train
apache/spark
python/pyspark/ml/clustering.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/clustering.py#L522-L531
def summary(self): """ Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the training set. An exception is thrown if no summary exists. """ if self.hasSummary: return BisectingKMeansSummary(super(BisectingKMeansModel, self).summary) ...
[ "def", "summary", "(", "self", ")", ":", "if", "self", ".", "hasSummary", ":", "return", "BisectingKMeansSummary", "(", "super", "(", "BisectingKMeansModel", ",", "self", ")", ".", "summary", ")", "else", ":", "raise", "RuntimeError", "(", "\"No training summa...
Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the training set. An exception is thrown if no summary exists.
[ "Gets", "summary", "(", "e", ".", "g", ".", "cluster", "assignments", "cluster", "sizes", ")", "of", "the", "model", "trained", "on", "the", "training", "set", ".", "An", "exception", "is", "thrown", "if", "no", "summary", "exists", "." ]
python
train
HewlettPackard/python-hpOneView
hpOneView/resources/servers/enclosures.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/enclosures.py#L197-L209
def get_sso(self, role): """ Builds the SSO (Single Sign-On) URL parameters for the specified enclosure. This allows the user to log in to the enclosure without providing credentials. This API is currently only supported by C7000 enclosures. Args: role: Role Returns...
[ "def", "get_sso", "(", "self", ",", "role", ")", ":", "uri", "=", "\"{}/sso?role={}\"", ".", "format", "(", "self", ".", "data", "[", "'uri'", "]", ",", "role", ")", "return", "self", ".", "_helper", ".", "do_get", "(", "uri", ")" ]
Builds the SSO (Single Sign-On) URL parameters for the specified enclosure. This allows the user to log in to the enclosure without providing credentials. This API is currently only supported by C7000 enclosures. Args: role: Role Returns: SSO (Single Sign-On) URL parame...
[ "Builds", "the", "SSO", "(", "Single", "Sign", "-", "On", ")", "URL", "parameters", "for", "the", "specified", "enclosure", ".", "This", "allows", "the", "user", "to", "log", "in", "to", "the", "enclosure", "without", "providing", "credentials", ".", "This...
python
train
WebarchivCZ/WA-KAT
src/wa_kat/db/request_info.py
https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/db/request_info.py#L177-L194
def to_dict(self): """ This method is used in with connection to REST API. It basically converts all important properties to dictionary, which may be used by frontend. Returns: dict: ``{"all_set": bool, "progress": [int(done), int(how_many)], \ "val...
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "\"all_set\"", ":", "self", ".", "_is_all_set", "(", ")", ",", "\"progress\"", ":", "self", ".", "progress", "(", ")", ",", "\"values\"", ":", "{", "property_name", ":", "getattr", "(", "self", ",...
This method is used in with connection to REST API. It basically converts all important properties to dictionary, which may be used by frontend. Returns: dict: ``{"all_set": bool, "progress": [int(done), int(how_many)], \ "values": {"property": [values], ..}}``
[ "This", "method", "is", "used", "in", "with", "connection", "to", "REST", "API", ".", "It", "basically", "converts", "all", "important", "properties", "to", "dictionary", "which", "may", "be", "used", "by", "frontend", "." ]
python
train
fastai/fastai
docs_src/nbval/plugin.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/docs_src/nbval/plugin.py#L248-L259
def get_sanitize_files(self): """ Return list of all sanitize files provided by the user on the command line. N.B.: We only support one sanitize file at the moment, but this is likely to change in the future """ if self.parent.config.option.sanitize_with is not No...
[ "def", "get_sanitize_files", "(", "self", ")", ":", "if", "self", ".", "parent", ".", "config", ".", "option", ".", "sanitize_with", "is", "not", "None", ":", "return", "[", "self", ".", "parent", ".", "config", ".", "option", ".", "sanitize_with", "]", ...
Return list of all sanitize files provided by the user on the command line. N.B.: We only support one sanitize file at the moment, but this is likely to change in the future
[ "Return", "list", "of", "all", "sanitize", "files", "provided", "by", "the", "user", "on", "the", "command", "line", "." ]
python
train
apache/incubator-mxnet
python/mxnet/model.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L121-L128
def _initialize_kvstore(kvstore, param_arrays, arg_params, param_names, update_on_kvstore): """Initialize kvstore""" for idx, param_on_devs in enumerate(param_arrays): name = param_names[idx] kvstore.init(name, arg_params[name]) if update_on_kvstore: kvstore.pull(name, param...
[ "def", "_initialize_kvstore", "(", "kvstore", ",", "param_arrays", ",", "arg_params", ",", "param_names", ",", "update_on_kvstore", ")", ":", "for", "idx", ",", "param_on_devs", "in", "enumerate", "(", "param_arrays", ")", ":", "name", "=", "param_names", "[", ...
Initialize kvstore
[ "Initialize", "kvstore" ]
python
train
geopy/geopy
geopy/geocoders/ignfrance.py
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/ignfrance.py#L548-L577
def _parse_place(place, is_freeform=None): """ Get the location, lat, lng and place from a single json place. """ # When freeform already so full address if is_freeform == 'true': location = place.get('freeformaddress') else: # For parcelle ...
[ "def", "_parse_place", "(", "place", ",", "is_freeform", "=", "None", ")", ":", "# When freeform already so full address", "if", "is_freeform", "==", "'true'", ":", "location", "=", "place", ".", "get", "(", "'freeformaddress'", ")", "else", ":", "# For parcelle",...
Get the location, lat, lng and place from a single json place.
[ "Get", "the", "location", "lat", "lng", "and", "place", "from", "a", "single", "json", "place", "." ]
python
train
bitshares/uptick
uptick/callorders.py
https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/callorders.py#L20-L57
def calls(ctx, obj, limit): """ List call/short positions of an account or an asset """ if obj.upper() == obj: # Asset from bitshares.asset import Asset asset = Asset(obj, full=True) calls = asset.get_call_orders(limit) t = [["acount", "debt", "collateral", "call pri...
[ "def", "calls", "(", "ctx", ",", "obj", ",", "limit", ")", ":", "if", "obj", ".", "upper", "(", ")", "==", "obj", ":", "# Asset", "from", "bitshares", ".", "asset", "import", "Asset", "asset", "=", "Asset", "(", "obj", ",", "full", "=", "True", "...
List call/short positions of an account or an asset
[ "List", "call", "/", "short", "positions", "of", "an", "account", "or", "an", "asset" ]
python
train
mamrhein/specification
specification/_extd_ast_expr.py
https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L214-L218
def visit_Dict(self, node: AST, dfltChaining: bool = True) -> str: """Return dict representation of `node`s elements.""" items = (': '.join((self.visit(key), self.visit(value))) for key, value in zip(node.keys, node.values)) return f"{{{', '.join(items)}}}"
[ "def", "visit_Dict", "(", "self", ",", "node", ":", "AST", ",", "dfltChaining", ":", "bool", "=", "True", ")", "->", "str", ":", "items", "=", "(", "': '", ".", "join", "(", "(", "self", ".", "visit", "(", "key", ")", ",", "self", ".", "visit", ...
Return dict representation of `node`s elements.
[ "Return", "dict", "representation", "of", "node", "s", "elements", "." ]
python
train
Crypto-toolbox/btfxwss
btfxwss/client.py
https://github.com/Crypto-toolbox/btfxwss/blob/16827fa6aacb2c0e289aa852bf61a18df6905835/btfxwss/client.py#L210-L218
def subscribe_to_order_book(self, pair, **kwargs): """Subscribe to the passed pair's order book channel. :param pair: str, Symbol pair to request data for :param kwargs: :return: """ identifier = ('book', pair) self._subscribe('book', identifier, symbol=pair, **k...
[ "def", "subscribe_to_order_book", "(", "self", ",", "pair", ",", "*", "*", "kwargs", ")", ":", "identifier", "=", "(", "'book'", ",", "pair", ")", "self", ".", "_subscribe", "(", "'book'", ",", "identifier", ",", "symbol", "=", "pair", ",", "*", "*", ...
Subscribe to the passed pair's order book channel. :param pair: str, Symbol pair to request data for :param kwargs: :return:
[ "Subscribe", "to", "the", "passed", "pair", "s", "order", "book", "channel", "." ]
python
test
xeroc/python-graphenelib
grapheneapi/api.py
https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/grapheneapi/api.py#L116-L121
def reset_counter(self): """ reset the failed connection counters """ self._cnt_retries = 0 for i in self._url_counter: self._url_counter[i] = 0
[ "def", "reset_counter", "(", "self", ")", ":", "self", ".", "_cnt_retries", "=", "0", "for", "i", "in", "self", ".", "_url_counter", ":", "self", ".", "_url_counter", "[", "i", "]", "=", "0" ]
reset the failed connection counters
[ "reset", "the", "failed", "connection", "counters" ]
python
valid
DeV1doR/aioethereum
aioethereum/management/eth.py
https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/eth.py#L81-L95
def eth_getBalance(self, address, block=BLOCK_TAG_LATEST): """https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getbalance :param address: Account address :type address: str :param block: Block tag or number (optional) :type block: int or BLOCK_TAGS :return: wei ...
[ "def", "eth_getBalance", "(", "self", ",", "address", ",", "block", "=", "BLOCK_TAG_LATEST", ")", ":", "block", "=", "validate_block", "(", "block", ")", "return", "hex_to_dec", "(", "(", "yield", "from", "self", ".", "rpc_call", "(", "'eth_getBalance'", ","...
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getbalance :param address: Account address :type address: str :param block: Block tag or number (optional) :type block: int or BLOCK_TAGS :return: wei :rtype: int
[ "https", ":", "//", "github", ".", "com", "/", "ethereum", "/", "wiki", "/", "wiki", "/", "JSON", "-", "RPC#eth_getbalance" ]
python
train
pylp/pylp
pylp/cli/colors.py
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/colors.py#L69-L78
def foreground(color): """Set the foreground color.""" if color not in foreground_colors: return if is_win32: last_fg = foreground_colors[color][1] set_color_win32(last_fg | last_bg) else: set_color_ansi(foreground_colors[color][0])
[ "def", "foreground", "(", "color", ")", ":", "if", "color", "not", "in", "foreground_colors", ":", "return", "if", "is_win32", ":", "last_fg", "=", "foreground_colors", "[", "color", "]", "[", "1", "]", "set_color_win32", "(", "last_fg", "|", "last_bg", ")...
Set the foreground color.
[ "Set", "the", "foreground", "color", "." ]
python
train
timkpaine/pyEX
pyEX/stocks.py
https://github.com/timkpaine/pyEX/blob/91cf751dafdb208a0c8b5377945e5808b99f94ba/pyEX/stocks.py#L794-L809
def financials(symbol, token='', version=''): '''Pulls income statement, balance sheet, and cash flow data from the four most recent reported quarters. https://iexcloud.io/docs/api/#financials Updates at 8am, 9am UTC daily Args: symbol (string); Ticker to request token (string); Access...
[ "def", "financials", "(", "symbol", ",", "token", "=", "''", ",", "version", "=", "''", ")", ":", "_raiseIfNotStr", "(", "symbol", ")", "return", "_getJson", "(", "'stock/'", "+", "symbol", "+", "'/financials'", ",", "token", ",", "version", ")" ]
Pulls income statement, balance sheet, and cash flow data from the four most recent reported quarters. https://iexcloud.io/docs/api/#financials Updates at 8am, 9am UTC daily Args: symbol (string); Ticker to request token (string); Access token version (string); API version Ret...
[ "Pulls", "income", "statement", "balance", "sheet", "and", "cash", "flow", "data", "from", "the", "four", "most", "recent", "reported", "quarters", "." ]
python
valid
mariano/pyfire
pyfire/message.py
https://github.com/mariano/pyfire/blob/42e3490c138abc8e10f2e9f8f8f3b40240a80412/pyfire/message.py#L121-L131
def is_text(self): """ Tells if this message is a text message. Returns: bool. Success """ return self.type in [ self._TYPE_PASTE, self._TYPE_TEXT, self._TYPE_TWEET ]
[ "def", "is_text", "(", "self", ")", ":", "return", "self", ".", "type", "in", "[", "self", ".", "_TYPE_PASTE", ",", "self", ".", "_TYPE_TEXT", ",", "self", ".", "_TYPE_TWEET", "]" ]
Tells if this message is a text message. Returns: bool. Success
[ "Tells", "if", "this", "message", "is", "a", "text", "message", "." ]
python
valid
Tygs/ww
src/ww/wrappers/tuples.py
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/tuples.py#L33-L48
def index(self, value): """ Args: value: index Returns: index of the values Raises: ValueError: value is not in list """ for i, x in enumerate(self): if x == value: return i raise ValueError("{} is not in lis...
[ "def", "index", "(", "self", ",", "value", ")", ":", "for", "i", ",", "x", "in", "enumerate", "(", "self", ")", ":", "if", "x", "==", "value", ":", "return", "i", "raise", "ValueError", "(", "\"{} is not in list\"", ".", "format", "(", "value", ")", ...
Args: value: index Returns: index of the values Raises: ValueError: value is not in list
[ "Args", ":", "value", ":", "index" ]
python
train
kubernetes-client/python
kubernetes/client/apis/extensions_v1beta1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/extensions_v1beta1_api.py#L7730-L7754
def replace_namespaced_network_policy(self, name, namespace, body, **kwargs): """ replace the specified NetworkPolicy This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.replace_namespaced_netw...
[ "def", "replace_namespaced_network_policy", "(", "self", ",", "name", ",", "namespace", ",", "body", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "...
replace the specified NetworkPolicy This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.replace_namespaced_network_policy(name, namespace, body, async_req=True) >>> result = thread.get() :para...
[ "replace", "the", "specified", "NetworkPolicy", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">>>", "thread", "=", "ap...
python
train
wbond/oscrypto
oscrypto/_win/asymmetric.py
https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_win/asymmetric.py#L2997-L3051
def _advapi32_encrypt(certificate_or_public_key, data, rsa_oaep_padding=False): """ Encrypts a value using an RSA public key via CryptoAPI :param certificate_or_public_key: A Certificate or PublicKey instance to encrypt with :param data: A byte string of the data to encrypt :param...
[ "def", "_advapi32_encrypt", "(", "certificate_or_public_key", ",", "data", ",", "rsa_oaep_padding", "=", "False", ")", ":", "flags", "=", "0", "if", "rsa_oaep_padding", ":", "flags", "=", "Advapi32Const", ".", "CRYPT_OAEP", "out_len", "=", "new", "(", "advapi32"...
Encrypts a value using an RSA public key via CryptoAPI :param certificate_or_public_key: A Certificate or PublicKey instance to encrypt with :param data: A byte string of the data to encrypt :param rsa_oaep_padding: If OAEP padding should be used instead of PKCS#1 v1.5 :raise...
[ "Encrypts", "a", "value", "using", "an", "RSA", "public", "key", "via", "CryptoAPI" ]
python
valid
the01/paps-settings
paps_settings/settable_plugin.py
https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/paps_settings/settable_plugin.py#L136-L187
def resource_update_list(self, reset=False): """ Update internal struct of resource, hash list and get diff (Warning: Resource names have to be unique!!) :param reset: Should resources be rebuild from scratch (default: False) :type reset: bool :return: List of resources...
[ "def", "resource_update_list", "(", "self", ",", "reset", "=", "False", ")", ":", "if", "not", "self", ".", "_resource_path", ":", "raise", "PluginException", "(", "\"No resource path set\"", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ...
Update internal struct of resource, hash list and get diff (Warning: Resource names have to be unique!!) :param reset: Should resources be rebuild from scratch (default: False) :type reset: bool :return: List of resources and hashes that changed :rtype: list[(unicode, unicode)]
[ "Update", "internal", "struct", "of", "resource", "hash", "list", "and", "get", "diff" ]
python
train
oz123/blogit
blogit/blogit.py
https://github.com/oz123/blogit/blob/15b94969fa43aaf8dc677a8184b144ae8c0f7700/blogit/blogit.py#L399-L413
def update_index(entries): """find the last 10 entries in the database and create the main page. Each entry in has an doc_id, so we only get the last 10 doc_ids. This method also updates the ATOM feed. """ context = GLOBAL_TEMPLATE_CONTEXT.copy() context['entries'] = entries context['la...
[ "def", "update_index", "(", "entries", ")", ":", "context", "=", "GLOBAL_TEMPLATE_CONTEXT", ".", "copy", "(", ")", "context", "[", "'entries'", "]", "=", "entries", "context", "[", "'last_build'", "]", "=", "datetime", ".", "datetime", ".", "now", "(", ")"...
find the last 10 entries in the database and create the main page. Each entry in has an doc_id, so we only get the last 10 doc_ids. This method also updates the ATOM feed.
[ "find", "the", "last", "10", "entries", "in", "the", "database", "and", "create", "the", "main", "page", ".", "Each", "entry", "in", "has", "an", "doc_id", "so", "we", "only", "get", "the", "last", "10", "doc_ids", "." ]
python
train
materialsproject/pymatgen
pymatgen/analysis/chemenv/coordination_environments/chemenv_strategies.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/chemenv/coordination_environments/chemenv_strategies.py#L779-L790
def as_dict(self): """ Bson-serializable dict representation of the TargettedPenaltiedAbundanceChemenvStrategy object. :return: Bson-serializable dict representation of the TargettedPenaltiedAbundanceChemenvStrategy object. """ return {"@module": self.__class__.__module__, ...
[ "def", "as_dict", "(", "self", ")", ":", "return", "{", "\"@module\"", ":", "self", ".", "__class__", ".", "__module__", ",", "\"@class\"", ":", "self", ".", "__class__", ".", "__name__", ",", "\"additional_condition\"", ":", "self", ".", "_additional_conditio...
Bson-serializable dict representation of the TargettedPenaltiedAbundanceChemenvStrategy object. :return: Bson-serializable dict representation of the TargettedPenaltiedAbundanceChemenvStrategy object.
[ "Bson", "-", "serializable", "dict", "representation", "of", "the", "TargettedPenaltiedAbundanceChemenvStrategy", "object", ".", ":", "return", ":", "Bson", "-", "serializable", "dict", "representation", "of", "the", "TargettedPenaltiedAbundanceChemenvStrategy", "object", ...
python
train
erdc/RAPIDpy
RAPIDpy/dataset.py
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L296-L412
def get_time_array(self, datetime_simulation_start=None, simulation_time_step_seconds=None, return_datetime=False, time_index_array=None): """ This method extracts or generates an array of time. The new v...
[ "def", "get_time_array", "(", "self", ",", "datetime_simulation_start", "=", "None", ",", "simulation_time_step_seconds", "=", "None", ",", "return_datetime", "=", "False", ",", "time_index_array", "=", "None", ")", ":", "# Original Qout file", "if", "datetime_simulat...
This method extracts or generates an array of time. The new version of RAPID output has the time array stored. However, the old version requires the user to know when the simulation began and the time step of the output. Parameters ---------- datetime_simulation_start: :...
[ "This", "method", "extracts", "or", "generates", "an", "array", "of", "time", ".", "The", "new", "version", "of", "RAPID", "output", "has", "the", "time", "array", "stored", ".", "However", "the", "old", "version", "requires", "the", "user", "to", "know", ...
python
train
klmitch/turnstile
turnstile/tools.py
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L141-L177
def get_kwargs(self, args): """ Given a Namespace object drawn from argparse, determines the keyword arguments to pass to the underlying function. Note that, if the underlying function accepts all keyword arguments, the dictionary returned will contain the entire content...
[ "def", "get_kwargs", "(", "self", ",", "args", ")", ":", "# Now we need to figure out which arguments the final function", "# actually needs", "kwargs", "=", "{", "}", "argspec", "=", "inspect", ".", "getargspec", "(", "self", ".", "_func", ")", "required", "=", "...
Given a Namespace object drawn from argparse, determines the keyword arguments to pass to the underlying function. Note that, if the underlying function accepts all keyword arguments, the dictionary returned will contain the entire contents of the Namespace object. Also note that an ...
[ "Given", "a", "Namespace", "object", "drawn", "from", "argparse", "determines", "the", "keyword", "arguments", "to", "pass", "to", "the", "underlying", "function", ".", "Note", "that", "if", "the", "underlying", "function", "accepts", "all", "keyword", "argument...
python
train
trailofbits/manticore
manticore/ethereum/abi.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L24-L40
def _type_size(ty): """ Calculate `static` type size """ if ty[0] in ('int', 'uint', 'bytesM', 'function'): return 32 elif ty[0] in ('tuple'): result = 0 for ty_i in ty[1]: result += ABI._type_size(ty_i) return result elif t...
[ "def", "_type_size", "(", "ty", ")", ":", "if", "ty", "[", "0", "]", "in", "(", "'int'", ",", "'uint'", ",", "'bytesM'", ",", "'function'", ")", ":", "return", "32", "elif", "ty", "[", "0", "]", "in", "(", "'tuple'", ")", ":", "result", "=", "0...
Calculate `static` type size
[ "Calculate", "static", "type", "size" ]
python
valid
PyCQA/astroid
astroid/node_classes.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/node_classes.py#L56-L79
def unpack_infer(stmt, context=None): """recursively generate nodes inferred by the given statement. If the inferred value is a list or a tuple, recurse on the elements """ if isinstance(stmt, (List, Tuple)): for elt in stmt.elts: if elt is util.Uninferable: yield elt...
[ "def", "unpack_infer", "(", "stmt", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "stmt", ",", "(", "List", ",", "Tuple", ")", ")", ":", "for", "elt", "in", "stmt", ".", "elts", ":", "if", "elt", "is", "util", ".", "Uninferable", ...
recursively generate nodes inferred by the given statement. If the inferred value is a list or a tuple, recurse on the elements
[ "recursively", "generate", "nodes", "inferred", "by", "the", "given", "statement", ".", "If", "the", "inferred", "value", "is", "a", "list", "or", "a", "tuple", "recurse", "on", "the", "elements" ]
python
train
juju/charm-helpers
charmhelpers/core/hookenv.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/hookenv.py#L496-L504
def relation_ids(reltype=None): """A list of relation_ids""" reltype = reltype or relation_type() relid_cmd_line = ['relation-ids', '--format=json'] if reltype is not None: relid_cmd_line.append(reltype) return json.loads( subprocess.check_output(relid_cmd_line).decode('UTF-8...
[ "def", "relation_ids", "(", "reltype", "=", "None", ")", ":", "reltype", "=", "reltype", "or", "relation_type", "(", ")", "relid_cmd_line", "=", "[", "'relation-ids'", ",", "'--format=json'", "]", "if", "reltype", "is", "not", "None", ":", "relid_cmd_line", ...
A list of relation_ids
[ "A", "list", "of", "relation_ids" ]
python
train
cjdrake/pyeda
pyeda/boolalg/bdd.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/bdd.py#L371-L397
def to_dot(self, name='BDD'): # pragma: no cover """Convert to DOT language representation. See the `DOT language reference <http://www.graphviz.org/content/dot-language>`_ for details. """ parts = ['graph', name, '{'] for node in self.dfs_postorder(): ...
[ "def", "to_dot", "(", "self", ",", "name", "=", "'BDD'", ")", ":", "# pragma: no cover", "parts", "=", "[", "'graph'", ",", "name", ",", "'{'", "]", "for", "node", "in", "self", ".", "dfs_postorder", "(", ")", ":", "if", "node", "is", "BDDNODEZERO", ...
Convert to DOT language representation. See the `DOT language reference <http://www.graphviz.org/content/dot-language>`_ for details.
[ "Convert", "to", "DOT", "language", "representation", "." ]
python
train
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/lib_acquisition_function.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/lib_acquisition_function.py#L154-L187
def next_hyperparameter_lowest_mu(fun_prediction, fun_prediction_args, x_bounds, x_types, minimize_starting_points, minimize_constraints_fun=None): ''' "Lowest Mu" acquisition ...
[ "def", "next_hyperparameter_lowest_mu", "(", "fun_prediction", ",", "fun_prediction_args", ",", "x_bounds", ",", "x_types", ",", "minimize_starting_points", ",", "minimize_constraints_fun", "=", "None", ")", ":", "best_x", "=", "None", "best_acquisition_value", "=", "No...
"Lowest Mu" acquisition function
[ "Lowest", "Mu", "acquisition", "function" ]
python
train
callowayproject/Transmogrify
transmogrify/contrib/django/templatetags/transmogrifiers.py
https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/contrib/django/templatetags/transmogrifiers.py#L22-L29
def resolve(var, context): """ Resolve the variable, or return the value passed to it in the first place """ try: return var.resolve(context) except template.VariableDoesNotExist: return var.var
[ "def", "resolve", "(", "var", ",", "context", ")", ":", "try", ":", "return", "var", ".", "resolve", "(", "context", ")", "except", "template", ".", "VariableDoesNotExist", ":", "return", "var", ".", "var" ]
Resolve the variable, or return the value passed to it in the first place
[ "Resolve", "the", "variable", "or", "return", "the", "value", "passed", "to", "it", "in", "the", "first", "place" ]
python
train
singularityhub/sregistry-cli
sregistry/logger/message.py
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/logger/message.py#L274-L290
def table(self, rows, col_width=2): '''table will print a table of entries. If the rows is a dictionary, the keys are interpreted as column names. if not, a numbered list is used. ''' labels = [str(x) for x in range(1,len(rows)+1)] if isinstance(rows, dict): ...
[ "def", "table", "(", "self", ",", "rows", ",", "col_width", "=", "2", ")", ":", "labels", "=", "[", "str", "(", "x", ")", "for", "x", "in", "range", "(", "1", ",", "len", "(", "rows", ")", "+", "1", ")", "]", "if", "isinstance", "(", "rows", ...
table will print a table of entries. If the rows is a dictionary, the keys are interpreted as column names. if not, a numbered list is used.
[ "table", "will", "print", "a", "table", "of", "entries", ".", "If", "the", "rows", "is", "a", "dictionary", "the", "keys", "are", "interpreted", "as", "column", "names", ".", "if", "not", "a", "numbered", "list", "is", "used", "." ]
python
test
ourway/auth
auth/CAS/authorization.py
https://github.com/ourway/auth/blob/f0d9676854dcec494add4fa086a9b2a3e4d8cea5/auth/CAS/authorization.py#L30-L36
def get_permissions(self, role): """gets permissions of role""" target_role = AuthGroup.objects(role=role, creator=self.client).first() if not target_role: return '[]' targets = AuthPermission.objects(groups=target_role, creator=self.client).only('name') return json.l...
[ "def", "get_permissions", "(", "self", ",", "role", ")", ":", "target_role", "=", "AuthGroup", ".", "objects", "(", "role", "=", "role", ",", "creator", "=", "self", ".", "client", ")", ".", "first", "(", ")", "if", "not", "target_role", ":", "return",...
gets permissions of role
[ "gets", "permissions", "of", "role" ]
python
train
KennethWilke/PingdomLib
pingdomlib/check.py
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/check.py#L87-L143
def getAnalyses(self, **kwargs): """Returns a list of the latest root cause analysis results for a specified check. Optional Parameters: * limit -- Limits the number of returned results to the specified quantity. Type: Integer ...
[ "def", "getAnalyses", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# 'from' is a reserved word, use time_from instead", "if", "kwargs", ".", "get", "(", "'time_from'", ")", ":", "kwargs", "[", "'from'", "]", "=", "kwargs", ".", "get", "(", "'time_from'", ...
Returns a list of the latest root cause analysis results for a specified check. Optional Parameters: * limit -- Limits the number of returned results to the specified quantity. Type: Integer Default: 100 * offset -- O...
[ "Returns", "a", "list", "of", "the", "latest", "root", "cause", "analysis", "results", "for", "a", "specified", "check", "." ]
python
train
django-crispy-forms/django-crispy-forms
crispy_forms/templatetags/crispy_forms_tags.py
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/templatetags/crispy_forms_tags.py#L135-L184
def get_response_dict(self, helper, context, is_formset): """ Returns a dictionary with all the parameters necessary to render the form/formset in a template. :param context: `django.template.Context` for the node :param is_formset: Boolean value. If set to True, indicates we are workin...
[ "def", "get_response_dict", "(", "self", ",", "helper", ",", "context", ",", "is_formset", ")", ":", "if", "not", "isinstance", "(", "helper", ",", "FormHelper", ")", ":", "raise", "TypeError", "(", "'helper object provided to {% crispy %} tag must be a crispy.helper....
Returns a dictionary with all the parameters necessary to render the form/formset in a template. :param context: `django.template.Context` for the node :param is_formset: Boolean value. If set to True, indicates we are working with a formset.
[ "Returns", "a", "dictionary", "with", "all", "the", "parameters", "necessary", "to", "render", "the", "form", "/", "formset", "in", "a", "template", "." ]
python
train
glormph/msstitch
src/app/actions/headers/peptable.py
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/headers/peptable.py#L81-L94
def get_proteininfo_fields(poolnames=False, genecentric=False): """Returns header fields for protein (group) information.""" allfields = OrderedDict() basefields = [peptabledata.HEADER_PROTEINS, peptabledata.HEADER_GENES, peptabledata.HEADER_ASSOCIATED, ...
[ "def", "get_proteininfo_fields", "(", "poolnames", "=", "False", ",", "genecentric", "=", "False", ")", ":", "allfields", "=", "OrderedDict", "(", ")", "basefields", "=", "[", "peptabledata", ".", "HEADER_PROTEINS", ",", "peptabledata", ".", "HEADER_GENES", ",",...
Returns header fields for protein (group) information.
[ "Returns", "header", "fields", "for", "protein", "(", "group", ")", "information", "." ]
python
train
webrecorder/warcio
warcio/statusandheaders.py
https://github.com/webrecorder/warcio/blob/c64c4394805e13256695f51af072c95389397ee9/warcio/statusandheaders.py#L176-L195
def percent_encode_non_ascii_headers(self, encoding='UTF-8'): """ Encode any headers that are not plain ascii as UTF-8 as per: https://tools.ietf.org/html/rfc8187#section-3.2.3 https://tools.ietf.org/html/rfc5987#section-3.2.2 """ def do_encode(m): ...
[ "def", "percent_encode_non_ascii_headers", "(", "self", ",", "encoding", "=", "'UTF-8'", ")", ":", "def", "do_encode", "(", "m", ")", ":", "return", "\"*={0}''\"", ".", "format", "(", "encoding", ")", "+", "quote", "(", "to_native_str", "(", "m", ".", "gro...
Encode any headers that are not plain ascii as UTF-8 as per: https://tools.ietf.org/html/rfc8187#section-3.2.3 https://tools.ietf.org/html/rfc5987#section-3.2.2
[ "Encode", "any", "headers", "that", "are", "not", "plain", "ascii", "as", "UTF", "-", "8", "as", "per", ":", "https", ":", "//", "tools", ".", "ietf", ".", "org", "/", "html", "/", "rfc8187#section", "-", "3", ".", "2", ".", "3", "https", ":", "/...
python
train
lincolnloop/goodconf
goodconf/values.py
https://github.com/lincolnloop/goodconf/blob/19515da5783f86b9516dbf81531107c2d9eae567/goodconf/values.py#L96-L102
def cast(self, val: str): """converts string to type requested by `cast_as`""" try: return getattr(self, 'cast_as_{}'.format( self.cast_as.__name__.lower()))(val) except AttributeError: return self.cast_as(val)
[ "def", "cast", "(", "self", ",", "val", ":", "str", ")", ":", "try", ":", "return", "getattr", "(", "self", ",", "'cast_as_{}'", ".", "format", "(", "self", ".", "cast_as", ".", "__name__", ".", "lower", "(", ")", ")", ")", "(", "val", ")", "exce...
converts string to type requested by `cast_as`
[ "converts", "string", "to", "type", "requested", "by", "cast_as" ]
python
test
Chilipp/psyplot
psyplot/plotter.py
https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/plotter.py#L2145-L2168
def _set_sharing_keys(self, keys): """ Set the keys to share or unshare Parameters ---------- keys: string or iterable of strings The iterable may contain formatoptions that shall be shared (or unshared), or group names of formatoptions to share all ...
[ "def", "_set_sharing_keys", "(", "self", ",", "keys", ")", ":", "if", "isinstance", "(", "keys", ",", "str", ")", ":", "keys", "=", "{", "keys", "}", "keys", "=", "set", "(", "self", ")", "if", "keys", "is", "None", "else", "set", "(", "keys", ")...
Set the keys to share or unshare Parameters ---------- keys: string or iterable of strings The iterable may contain formatoptions that shall be shared (or unshared), or group names of formatoptions to share all formatoptions of that group (see the :attr:`fmt_...
[ "Set", "the", "keys", "to", "share", "or", "unshare" ]
python
train
Azure/azure-event-hubs-python
azure/eventhub/client.py
https://github.com/Azure/azure-event-hubs-python/blob/737c5f966557ada2cf10fa0d8f3c19671ae96348/azure/eventhub/client.py#L147-L170
def from_sas_token(cls, address, sas_token, eventhub=None, **kwargs): """Create an EventHubClient from an existing auth token or token generator. :param address: The Event Hub address URL :type address: str :param sas_token: A SAS token or function that returns a SAS token. If a functio...
[ "def", "from_sas_token", "(", "cls", ",", "address", ",", "sas_token", ",", "eventhub", "=", "None", ",", "*", "*", "kwargs", ")", ":", "address", "=", "_build_uri", "(", "address", ",", "eventhub", ")", "return", "cls", "(", "address", ",", "sas_token",...
Create an EventHubClient from an existing auth token or token generator. :param address: The Event Hub address URL :type address: str :param sas_token: A SAS token or function that returns a SAS token. If a function is supplied, it will be used to retrieve subsequent tokens in the case...
[ "Create", "an", "EventHubClient", "from", "an", "existing", "auth", "token", "or", "token", "generator", "." ]
python
train
ctuning/ck
ck/repo/module/repo/module.py
https://github.com/ctuning/ck/blob/7e009814e975f8742790d3106340088a46223714/ck/repo/module/repo/module.py#L1591-L1627
def unzip(i): """ Input: { (data_uoa) - repo UOA where to unzip (default, if not specified) zip - path to zipfile (local or remote http/ftp) (overwrite) - if 'yes', overwrite files when unarchiving } Output: { return ...
[ "def", "unzip", "(", "i", ")", ":", "o", "=", "i", ".", "get", "(", "'out'", ",", "''", ")", "duoa", "=", "i", ".", "get", "(", "'data_uoa'", ",", "''", ")", "if", "duoa", "==", "''", ":", "duoa", "=", "'local'", "overwrite", "=", "i", ".", ...
Input: { (data_uoa) - repo UOA where to unzip (default, if not specified) zip - path to zipfile (local or remote http/ftp) (overwrite) - if 'yes', overwrite files when unarchiving } Output: { return - return code = 0, if suc...
[ "Input", ":", "{", "(", "data_uoa", ")", "-", "repo", "UOA", "where", "to", "unzip", "(", "default", "if", "not", "specified", ")", "zip", "-", "path", "to", "zipfile", "(", "local", "or", "remote", "http", "/", "ftp", ")", "(", "overwrite", ")", "...
python
train
agoragames/chai
chai/stub.py
https://github.com/agoragames/chai/blob/8148d7b7754226b0d1cabfc2af10cd912612abdc/chai/stub.py#L576-L587
def _teardown(self): ''' Overload so that we can clear out the cache after a test run. ''' # __new__ is a super-special case in that even when stubbing a class # which implements its own __new__ and subclasses object, the # "Class.__new__" reference is a staticmethod and ...
[ "def", "_teardown", "(", "self", ")", ":", "# __new__ is a super-special case in that even when stubbing a class", "# which implements its own __new__ and subclasses object, the", "# \"Class.__new__\" reference is a staticmethod and not a method (or", "# function). That confuses the \"was_object_m...
Overload so that we can clear out the cache after a test run.
[ "Overload", "so", "that", "we", "can", "clear", "out", "the", "cache", "after", "a", "test", "run", "." ]
python
train
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/treemodel.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/treemodel.py#L241-L254
def set_model(self, model): """Set the model the item belongs to A TreeItem can only belong to one model. :param model: the model the item belongs to :type model: :class:`Treemodel` :returns: None :rtype: None :raises: None """ self._model = mode...
[ "def", "set_model", "(", "self", ",", "model", ")", ":", "self", ".", "_model", "=", "model", "for", "c", "in", "self", ".", "childItems", ":", "c", ".", "set_model", "(", "model", ")" ]
Set the model the item belongs to A TreeItem can only belong to one model. :param model: the model the item belongs to :type model: :class:`Treemodel` :returns: None :rtype: None :raises: None
[ "Set", "the", "model", "the", "item", "belongs", "to" ]
python
train
PythonCharmers/python-future
src/future/backports/http/server.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/http/server.py#L441-L452
def send_response(self, code, message=None): """Add the response header to the headers buffer and log the response code. Also send two standard headers with the server software version and the current date. """ self.log_request(code) self.send_response_only(code...
[ "def", "send_response", "(", "self", ",", "code", ",", "message", "=", "None", ")", ":", "self", ".", "log_request", "(", "code", ")", "self", ".", "send_response_only", "(", "code", ",", "message", ")", "self", ".", "send_header", "(", "'Server'", ",", ...
Add the response header to the headers buffer and log the response code. Also send two standard headers with the server software version and the current date.
[ "Add", "the", "response", "header", "to", "the", "headers", "buffer", "and", "log", "the", "response", "code", "." ]
python
train
keon/algorithms
algorithms/set/set_covering.py
https://github.com/keon/algorithms/blob/4d6569464a62a75c1357acc97e2dd32ee2f9f4a3/algorithms/set/set_covering.py#L37-L58
def optimal_set_cover(universe, subsets, costs): """ Optimal algorithm - DONT USE ON BIG INPUTS - O(2^n) complexity! Finds the minimum cost subcollection os S that covers all elements of U Args: universe (list): Universe of elements subsets (dict): Subsets of U {S1:elements,S2:elements} ...
[ "def", "optimal_set_cover", "(", "universe", ",", "subsets", ",", "costs", ")", ":", "pset", "=", "powerset", "(", "subsets", ".", "keys", "(", ")", ")", "best_set", "=", "None", "best_cost", "=", "float", "(", "\"inf\"", ")", "for", "subset", "in", "p...
Optimal algorithm - DONT USE ON BIG INPUTS - O(2^n) complexity! Finds the minimum cost subcollection os S that covers all elements of U Args: universe (list): Universe of elements subsets (dict): Subsets of U {S1:elements,S2:elements} costs (dict): Costs of each subset in S - {S1:cost, ...
[ "Optimal", "algorithm", "-", "DONT", "USE", "ON", "BIG", "INPUTS", "-", "O", "(", "2^n", ")", "complexity!", "Finds", "the", "minimum", "cost", "subcollection", "os", "S", "that", "covers", "all", "elements", "of", "U" ]
python
train
synw/dataswim
dataswim/data/__init__.py
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L55-L65
def clone_(self, quiet=False): """ Clone the DataSwim instance """ ds2 = self._duplicate_(quiet=True) if ds2 is None: self.err("Can not clone instance") else: if quiet is False: self.ok("Instance cloned") return ds2
[ "def", "clone_", "(", "self", ",", "quiet", "=", "False", ")", ":", "ds2", "=", "self", ".", "_duplicate_", "(", "quiet", "=", "True", ")", "if", "ds2", "is", "None", ":", "self", ".", "err", "(", "\"Can not clone instance\"", ")", "else", ":", "if",...
Clone the DataSwim instance
[ "Clone", "the", "DataSwim", "instance" ]
python
train
tensorflow/probability
tensorflow_probability/examples/disentangled_vae.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/examples/disentangled_vae.py#L421-L441
def call(self, inputs): """Runs the model to generate an intermediate representation of x_t. Args: inputs: A batch of image sequences `x_{1:T}` of shape `[sample_shape, batch_size, timesteps, height, width, channels]`. Returns: A batch of intermediate representations of shape [...
[ "def", "call", "(", "self", ",", "inputs", ")", ":", "image_shape", "=", "tf", ".", "shape", "(", "input", "=", "inputs", ")", "[", "-", "3", ":", "]", "collapsed_shape", "=", "tf", ".", "concat", "(", "(", "[", "-", "1", "]", ",", "image_shape",...
Runs the model to generate an intermediate representation of x_t. Args: inputs: A batch of image sequences `x_{1:T}` of shape `[sample_shape, batch_size, timesteps, height, width, channels]`. Returns: A batch of intermediate representations of shape [sample_shape, batch_size,...
[ "Runs", "the", "model", "to", "generate", "an", "intermediate", "representation", "of", "x_t", "." ]
python
test
ruipgil/TrackToTrip
tracktotrip/transportation_mode.py
https://github.com/ruipgil/TrackToTrip/blob/5537c14ee9748091b5255b658ab528e1d6227f99/tracktotrip/transportation_mode.py#L142-L167
def detect_changepoints(points, min_time, data_processor=acc_difference): """ Detects changepoints on points that have at least a specific duration Args: points (:obj:`Point`) min_time (float): Min time that a sub-segmented, bounded by two changepoints, must have data_processor (functio...
[ "def", "detect_changepoints", "(", "points", ",", "min_time", ",", "data_processor", "=", "acc_difference", ")", ":", "data", "=", "data_processor", "(", "points", ")", "changepoints", "=", "pelt", "(", "normal_mean", "(", "data", ",", "np", ".", "std", "(",...
Detects changepoints on points that have at least a specific duration Args: points (:obj:`Point`) min_time (float): Min time that a sub-segmented, bounded by two changepoints, must have data_processor (function): Function to extract data to feed to the changepoint algorithm. Def...
[ "Detects", "changepoints", "on", "points", "that", "have", "at", "least", "a", "specific", "duration" ]
python
train
pantsbuild/pants
src/python/pants/base/deprecated.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/base/deprecated.py#L132-L202
def warn_or_error(removal_version, deprecated_entity_description, hint=None, deprecation_start_version=None, stacklevel=3, frame_info=None, context=1, ensure_stderr=False): """Check the removal_version against the current pants version. Issues a warning if the removal version is...
[ "def", "warn_or_error", "(", "removal_version", ",", "deprecated_entity_description", ",", "hint", "=", "None", ",", "deprecation_start_version", "=", "None", ",", "stacklevel", "=", "3", ",", "frame_info", "=", "None", ",", "context", "=", "1", ",", "ensure_std...
Check the removal_version against the current pants version. Issues a warning if the removal version is > current pants version, or an error otherwise. :param string removal_version: The pantsbuild.pants version at which the deprecated entity will be/was removed. :param string d...
[ "Check", "the", "removal_version", "against", "the", "current", "pants", "version", "." ]
python
train
fermiPy/fermipy
fermipy/gtutils.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtutils.py#L490-L497
def nFreeParams(self): """Count the number of free parameters in the active model.""" nF = 0 pars = self.params() for par in pars: if par.isFree(): nF += 1 return nF
[ "def", "nFreeParams", "(", "self", ")", ":", "nF", "=", "0", "pars", "=", "self", ".", "params", "(", ")", "for", "par", "in", "pars", ":", "if", "par", ".", "isFree", "(", ")", ":", "nF", "+=", "1", "return", "nF" ]
Count the number of free parameters in the active model.
[ "Count", "the", "number", "of", "free", "parameters", "in", "the", "active", "model", "." ]
python
train
sprockets/sprockets
sprockets/cli.py
https://github.com/sprockets/sprockets/blob/089dbaf04da54afd95645fce31f4ff9c8bdd8fae/sprockets/cli.py#L189-L202
def _get_application_module(self, controller, application): """Return the module for an application. If it's a entry-point registered application name, return the module name from the entry points data. If not, the passed in application name is returned. :param str controller: The contr...
[ "def", "_get_application_module", "(", "self", ",", "controller", ",", "application", ")", ":", "for", "pkg", "in", "self", ".", "_get_applications", "(", "controller", ")", ":", "if", "pkg", ".", "name", "==", "application", ":", "return", "pkg", ".", "mo...
Return the module for an application. If it's a entry-point registered application name, return the module name from the entry points data. If not, the passed in application name is returned. :param str controller: The controller type :param str application: The application name or modu...
[ "Return", "the", "module", "for", "an", "application", ".", "If", "it", "s", "a", "entry", "-", "point", "registered", "application", "name", "return", "the", "module", "name", "from", "the", "entry", "points", "data", ".", "If", "not", "the", "passed", ...
python
train
pjmark/NIMPA
resources/resources.py
https://github.com/pjmark/NIMPA/blob/3f4231fed2934a1d92e4cd8e9e153b0118e29d86/resources/resources.py#L281-L376
def get_mmr_constants(): ''' Put all the constants together in a dictionary ''' Cnt = { 'ISOTOPE':'F18', 'DCYCRR':DCYCRR, 'ALPHA':ALPHA, 'NRNG':NRNG, 'NSRNG':NSRNG, 'NCRS':NCRS, 'NCRSR':NCRSR, 'NBCKT':224, 'NSANGLES':A, 'NS...
[ "def", "get_mmr_constants", "(", ")", ":", "Cnt", "=", "{", "'ISOTOPE'", ":", "'F18'", ",", "'DCYCRR'", ":", "DCYCRR", ",", "'ALPHA'", ":", "ALPHA", ",", "'NRNG'", ":", "NRNG", ",", "'NSRNG'", ":", "NSRNG", ",", "'NCRS'", ":", "NCRS", ",", "'NCRSR'", ...
Put all the constants together in a dictionary
[ "Put", "all", "the", "constants", "together", "in", "a", "dictionary" ]
python
train
mitsei/dlkit
dlkit/runtime/impls/configuration/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/runtime/impls/configuration/objects.py#L247-L274
def get_next_parameters(self, n=None): """Gets the next set of ``Parameters`` in this list which must be less than or equal to the return from ``available()``. arg: n (cardinal): the number of ``Parameter`` elements requested which must be less than or equal to ``avai...
[ "def", "get_next_parameters", "(", "self", ",", "n", "=", "None", ")", ":", "# Implemented from template for osid.resource.ResourceList.get_next_resources", "if", "n", ">", "self", ".", "available", "(", ")", ":", "# !!! This is not quite as specified (see method docs) !!!", ...
Gets the next set of ``Parameters`` in this list which must be less than or equal to the return from ``available()``. arg: n (cardinal): the number of ``Parameter`` elements requested which must be less than or equal to ``available()`` return: (osid.configuration.Para...
[ "Gets", "the", "next", "set", "of", "Parameters", "in", "this", "list", "which", "must", "be", "less", "than", "or", "equal", "to", "the", "return", "from", "available", "()", "." ]
python
train
broadinstitute/fiss
firecloud/api.py
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1023-L1056
def create_submission(wnamespace, workspace, cnamespace, config, entity, etype, expression=None, use_callcache=True): """Submit job in FireCloud workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): M...
[ "def", "create_submission", "(", "wnamespace", ",", "workspace", ",", "cnamespace", ",", "config", ",", "entity", ",", "etype", ",", "expression", "=", "None", ",", "use_callcache", "=", "True", ")", ":", "uri", "=", "\"workspaces/{0}/{1}/submissions\"", ".", ...
Submit job in FireCloud workspace. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name cnamespace (str): Method configuration namespace config (str): Method configuration name entity (str): Entity to submit job on. Should be the same typ...
[ "Submit", "job", "in", "FireCloud", "workspace", "." ]
python
train
raiden-network/raiden
raiden/transfer/channel.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/channel.py#L973-L1007
def get_batch_unlock( end_state: NettingChannelEndState, ) -> Optional[MerkleTreeLeaves]: """ Unlock proof for an entire merkle tree of pending locks The unlock proof contains all the merkle tree data, tightly packed, needed by the token network contract to verify the secret expiry and calculate th...
[ "def", "get_batch_unlock", "(", "end_state", ":", "NettingChannelEndState", ",", ")", "->", "Optional", "[", "MerkleTreeLeaves", "]", ":", "if", "len", "(", "end_state", ".", "merkletree", ".", "layers", "[", "LEAVES", "]", ")", "==", "0", ":", "# pylint: di...
Unlock proof for an entire merkle tree of pending locks The unlock proof contains all the merkle tree data, tightly packed, needed by the token network contract to verify the secret expiry and calculate the token amounts to transfer.
[ "Unlock", "proof", "for", "an", "entire", "merkle", "tree", "of", "pending", "locks" ]
python
train
cjdrake/pyeda
pyeda/boolalg/table.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/table.py#L176-L191
def iter_zeros(self): """Iterate through the indices of all zero items.""" num = quotient = 0 while num < self._len: chunk = self.data[quotient] if chunk & self.zero_mask: remainder = 0 while remainder < self.width and num < self._len: ...
[ "def", "iter_zeros", "(", "self", ")", ":", "num", "=", "quotient", "=", "0", "while", "num", "<", "self", ".", "_len", ":", "chunk", "=", "self", ".", "data", "[", "quotient", "]", "if", "chunk", "&", "self", ".", "zero_mask", ":", "remainder", "=...
Iterate through the indices of all zero items.
[ "Iterate", "through", "the", "indices", "of", "all", "zero", "items", "." ]
python
train
lincolnloop/goodconf
goodconf/__init__.py
https://github.com/lincolnloop/goodconf/blob/19515da5783f86b9516dbf81531107c2d9eae567/goodconf/__init__.py#L18-L32
def _load_config(path: str) -> dict: """ Given a file path, parse it based on its extension (YAML or JSON) and return the values as a Python dictionary. JSON is the default if an extension can't be determined. """ __, ext = os.path.splitext(path) if ext in ['.yaml', '.yml']: import r...
[ "def", "_load_config", "(", "path", ":", "str", ")", "->", "dict", ":", "__", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "path", ")", "if", "ext", "in", "[", "'.yaml'", ",", "'.yml'", "]", ":", "import", "ruamel", ".", "yaml", "loa...
Given a file path, parse it based on its extension (YAML or JSON) and return the values as a Python dictionary. JSON is the default if an extension can't be determined.
[ "Given", "a", "file", "path", "parse", "it", "based", "on", "its", "extension", "(", "YAML", "or", "JSON", ")", "and", "return", "the", "values", "as", "a", "Python", "dictionary", ".", "JSON", "is", "the", "default", "if", "an", "extension", "can", "t...
python
test
ethpm/py-ethpm
ethpm/deployments.py
https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/deployments.py#L45-L61
def get_instance(self, contract_name: str) -> None: """ Fetches a contract instance belonging to deployment after validating contract name. """ self._validate_name_and_references(contract_name) # Use a deployment's "contract_type" to lookup contract factory # in c...
[ "def", "get_instance", "(", "self", ",", "contract_name", ":", "str", ")", "->", "None", ":", "self", ".", "_validate_name_and_references", "(", "contract_name", ")", "# Use a deployment's \"contract_type\" to lookup contract factory", "# in case the deployment uses a contract ...
Fetches a contract instance belonging to deployment after validating contract name.
[ "Fetches", "a", "contract", "instance", "belonging", "to", "deployment", "after", "validating", "contract", "name", "." ]
python
train
gwpy/gwpy
gwpy/signal/spectral/_ui.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/signal/spectral/_ui.py#L246-L263
def psd(timeseries, method_func, *args, **kwargs): """Generate a PSD using a method function All arguments are presumed to be given in physical units Parameters ---------- timeseries : `~gwpy.timeseries.TimeSeries`, `tuple` the data to process, or a 2-tuple of series to correlate meth...
[ "def", "psd", "(", "timeseries", ",", "method_func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# decorator has translated the arguments for us, so just call psdn()", "return", "_psdn", "(", "timeseries", ",", "method_func", ",", "*", "args", ",", "*", ...
Generate a PSD using a method function All arguments are presumed to be given in physical units Parameters ---------- timeseries : `~gwpy.timeseries.TimeSeries`, `tuple` the data to process, or a 2-tuple of series to correlate method_func : `callable` the function that will be cal...
[ "Generate", "a", "PSD", "using", "a", "method", "function" ]
python
train
serge-sans-paille/pythran
pythran/types/types.py
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L349-L359
def visit_BoolOp(self, node): """ Merge BoolOp operand type. BoolOp are "and" and "or" and may return any of these results so all operands should have the combinable type. """ # Visit subnodes self.generic_visit(node) # Merge all operands types. [...
[ "def", "visit_BoolOp", "(", "self", ",", "node", ")", ":", "# Visit subnodes", "self", ".", "generic_visit", "(", "node", ")", "# Merge all operands types.", "[", "self", ".", "combine", "(", "node", ",", "value", ")", "for", "value", "in", "node", ".", "v...
Merge BoolOp operand type. BoolOp are "and" and "or" and may return any of these results so all operands should have the combinable type.
[ "Merge", "BoolOp", "operand", "type", "." ]
python
train
paramiko/paramiko
paramiko/win_pageant.py
https://github.com/paramiko/paramiko/blob/cf7d49d66f3b1fbc8b0853518a54050182b3b5eb/paramiko/win_pageant.py#L79-L114
def _query_pageant(msg): """ Communication with the Pageant process is done through a shared memory-mapped file. """ hwnd = _get_pageant_window_object() if not hwnd: # Raise a failure to connect exception, pageant isn't running anymore! return None # create a name for the mm...
[ "def", "_query_pageant", "(", "msg", ")", ":", "hwnd", "=", "_get_pageant_window_object", "(", ")", "if", "not", "hwnd", ":", "# Raise a failure to connect exception, pageant isn't running anymore!", "return", "None", "# create a name for the mmap", "map_name", "=", "\"Page...
Communication with the Pageant process is done through a shared memory-mapped file.
[ "Communication", "with", "the", "Pageant", "process", "is", "done", "through", "a", "shared", "memory", "-", "mapped", "file", "." ]
python
train
google/grr
grr/server/grr_response_server/data_store.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L1238-L1273
def IndexReadPostingLists(self, index_urn, keywords, start_time, end_time, last_seen_map=None): """Finds all objects associated with any of the keywords. Args: index...
[ "def", "IndexReadPostingLists", "(", "self", ",", "index_urn", ",", "keywords", ",", "start_time", ",", "end_time", ",", "last_seen_map", "=", "None", ")", ":", "keyword_urns", "=", "{", "self", ".", "_KeywordToURN", "(", "index_urn", ",", "k", ")", ":", "...
Finds all objects associated with any of the keywords. Args: index_urn: The base urn of the index. keywords: A collection of keywords that we are interested in. start_time: Only considers keywords added at or after this point in time. end_time: Only considers keywords at or before this poin...
[ "Finds", "all", "objects", "associated", "with", "any", "of", "the", "keywords", "." ]
python
train
spacetelescope/acstools
acstools/acszpt.py
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acszpt.py#L250-L283
def _check_date(self, fmt='%Y-%m-%d'): """Convenience method for determining if the input date is valid. Parameters ---------- fmt : str The format of the date string. The default is ``%Y-%m-%d``, which corresponds to ``YYYY-MM-DD``. Returns ----...
[ "def", "_check_date", "(", "self", ",", "fmt", "=", "'%Y-%m-%d'", ")", ":", "result", "=", "None", "try", ":", "dt_obj", "=", "dt", ".", "datetime", ".", "strptime", "(", "self", ".", "date", ",", "fmt", ")", "except", "ValueError", ":", "result", "=...
Convenience method for determining if the input date is valid. Parameters ---------- fmt : str The format of the date string. The default is ``%Y-%m-%d``, which corresponds to ``YYYY-MM-DD``. Returns ------- status : str or `None` If ...
[ "Convenience", "method", "for", "determining", "if", "the", "input", "date", "is", "valid", "." ]
python
train
autokey/autokey
lib/autokey/qtapp.py
https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtapp.py#L281-L292
def shutdown(self): """ Shut down the entire application. """ logging.info("Shutting down") self.closeAllWindows() self.notifier.hide() self.service.shutdown() self.monitor.stop() self.quit() os.remove(common.LOCK_FILE) # TODO: maybe use a...
[ "def", "shutdown", "(", "self", ")", ":", "logging", ".", "info", "(", "\"Shutting down\"", ")", "self", ".", "closeAllWindows", "(", ")", "self", ".", "notifier", ".", "hide", "(", ")", "self", ".", "service", ".", "shutdown", "(", ")", "self", ".", ...
Shut down the entire application.
[ "Shut", "down", "the", "entire", "application", "." ]
python
train
fastai/fastai
fastai/vision/data.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/data.py#L264-L266
def open(self, fn): "Open image in `fn`, subclass and overwrite for custom behavior." return open_image(fn, convert_mode=self.convert_mode, after_open=self.after_open)
[ "def", "open", "(", "self", ",", "fn", ")", ":", "return", "open_image", "(", "fn", ",", "convert_mode", "=", "self", ".", "convert_mode", ",", "after_open", "=", "self", ".", "after_open", ")" ]
Open image in `fn`, subclass and overwrite for custom behavior.
[ "Open", "image", "in", "fn", "subclass", "and", "overwrite", "for", "custom", "behavior", "." ]
python
train
ladybug-tools/ladybug
ladybug/wea.py
https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/wea.py#L219-L247
def from_stat_file(cls, statfile, timestep=1, is_leap_year=False): """Create an ASHRAE Revised Clear Sky wea object from the monthly sky optical depths in a .stat file. Args: statfile: Full path to the .stat file. timestep: An optional integer to set the number of time s...
[ "def", "from_stat_file", "(", "cls", ",", "statfile", ",", "timestep", "=", "1", ",", "is_leap_year", "=", "False", ")", ":", "stat", "=", "STAT", "(", "statfile", ")", "# check to be sure the stat file does not have missing tau values", "def", "check_missing", "(",...
Create an ASHRAE Revised Clear Sky wea object from the monthly sky optical depths in a .stat file. Args: statfile: Full path to the .stat file. timestep: An optional integer to set the number of time steps per hour. Default is 1 for one value per hour. ...
[ "Create", "an", "ASHRAE", "Revised", "Clear", "Sky", "wea", "object", "from", "the", "monthly", "sky", "optical", "depths", "in", "a", ".", "stat", "file", "." ]
python
train
pgjones/quart
quart/app.py
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L778-L795
def template_global(self, name: Optional[str]=None) -> Callable: """Add a template global. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.template_global('name') def five(): return 5 Arguments: ...
[ "def", "template_global", "(", "self", ",", "name", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Callable", ":", "def", "decorator", "(", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "add_template_global", "(", "func", ...
Add a template global. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.template_global('name') def five(): return 5 Arguments: name: The global name (defaults to function name).
[ "Add", "a", "template", "global", "." ]
python
train
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py#L1043-L1063
def best_match(self, req, working_set, installer=None): """Find distribution best matching `req` and usable on `working_set` This calls the ``find(req)`` method of the `working_set` to see if a suitable distribution is already active. (This may raise ``VersionConflict`` if an unsuitabl...
[ "def", "best_match", "(", "self", ",", "req", ",", "working_set", ",", "installer", "=", "None", ")", ":", "dist", "=", "working_set", ".", "find", "(", "req", ")", "if", "dist", "is", "not", "None", ":", "return", "dist", "for", "dist", "in", "self"...
Find distribution best matching `req` and usable on `working_set` This calls the ``find(req)`` method of the `working_set` to see if a suitable distribution is already active. (This may raise ``VersionConflict`` if an unsuitable version of the project is already active in the specified...
[ "Find", "distribution", "best", "matching", "req", "and", "usable", "on", "working_set" ]
python
test
josiahcarlson/rom
rom/model.py
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/model.py#L523-L530
def copy(self): ''' Creates a shallow copy of the given entity (any entities that can be retrieved from a OneToMany relationship will not be copied). ''' x = self.to_dict() x.pop(self._pkey) return self.__class__(**x)
[ "def", "copy", "(", "self", ")", ":", "x", "=", "self", ".", "to_dict", "(", ")", "x", ".", "pop", "(", "self", ".", "_pkey", ")", "return", "self", ".", "__class__", "(", "*", "*", "x", ")" ]
Creates a shallow copy of the given entity (any entities that can be retrieved from a OneToMany relationship will not be copied).
[ "Creates", "a", "shallow", "copy", "of", "the", "given", "entity", "(", "any", "entities", "that", "can", "be", "retrieved", "from", "a", "OneToMany", "relationship", "will", "not", "be", "copied", ")", "." ]
python
test
awslabs/sockeye
sockeye/output_handler.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/output_handler.py#L253-L276
def handle(self, t_input: inference.TranslatorInput, t_output: inference.TranslatorOutput, t_walltime: float = 0.): """ :param t_input: Translator input. :param t_output: Translator output. :param t_walltime: Total wall-clock time for translat...
[ "def", "handle", "(", "self", ",", "t_input", ":", "inference", ".", "TranslatorInput", ",", "t_output", ":", "inference", ".", "TranslatorOutput", ",", "t_walltime", ":", "float", "=", "0.", ")", ":", "line", "=", "\"{sent_id} ||| {target} ||| {score:f} ||| {sour...
:param t_input: Translator input. :param t_output: Translator output. :param t_walltime: Total wall-clock time for translation.
[ ":", "param", "t_input", ":", "Translator", "input", ".", ":", "param", "t_output", ":", "Translator", "output", ".", ":", "param", "t_walltime", ":", "Total", "wall", "-", "clock", "time", "for", "translation", "." ]
python
train
vpelletier/python-libusb1
usb1/__init__.py
https://github.com/vpelletier/python-libusb1/blob/740c9778e28523e4ec3543415d95f5400ae0fa24/usb1/__init__.py#L2590-L2650
def hotplugRegisterCallback( self, callback, # pylint: disable=undefined-variable events=HOTPLUG_EVENT_DEVICE_ARRIVED | HOTPLUG_EVENT_DEVICE_LEFT, flags=HOTPLUG_ENUMERATE, vendor_id=HOTPLUG_MATCH_ANY, product_id=HOTPLUG_MATCH_ANY, dev_c...
[ "def", "hotplugRegisterCallback", "(", "self", ",", "callback", ",", "# pylint: disable=undefined-variable", "events", "=", "HOTPLUG_EVENT_DEVICE_ARRIVED", "|", "HOTPLUG_EVENT_DEVICE_LEFT", ",", "flags", "=", "HOTPLUG_ENUMERATE", ",", "vendor_id", "=", "HOTPLUG_MATCH_ANY", ...
Registers an hotplug callback. On success, returns an opaque value which can be passed to hotplugDeregisterCallback. Callback must accept the following positional arguments: - this USBContext instance - an USBDevice instance If device has left, configuration descriptors...
[ "Registers", "an", "hotplug", "callback", ".", "On", "success", "returns", "an", "opaque", "value", "which", "can", "be", "passed", "to", "hotplugDeregisterCallback", ".", "Callback", "must", "accept", "the", "following", "positional", "arguments", ":", "-", "th...
python
train
Erotemic/timerit
timerit/core.py
https://github.com/Erotemic/timerit/blob/625449f5359f757fb0ab8093b228dc8f37b8ffaf/timerit/core.py#L99-L101
def chunks(seq, size): """ simple two-line alternative to `ubelt.chunks` """ return (seq[pos:pos + size] for pos in range(0, len(seq), size))
[ "def", "chunks", "(", "seq", ",", "size", ")", ":", "return", "(", "seq", "[", "pos", ":", "pos", "+", "size", "]", "for", "pos", "in", "range", "(", "0", ",", "len", "(", "seq", ")", ",", "size", ")", ")" ]
simple two-line alternative to `ubelt.chunks`
[ "simple", "two", "-", "line", "alternative", "to", "ubelt", ".", "chunks" ]
python
train
Parsely/probably
probably/hll.py
https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/hll.py#L38-L45
def _get_rho(self, w, arr): """ Return the least signifiant bit O(N) in the worst case """ lsb = 0 while not (w & arr[lsb]): lsb += 1 return lsb + 1
[ "def", "_get_rho", "(", "self", ",", "w", ",", "arr", ")", ":", "lsb", "=", "0", "while", "not", "(", "w", "&", "arr", "[", "lsb", "]", ")", ":", "lsb", "+=", "1", "return", "lsb", "+", "1" ]
Return the least signifiant bit O(N) in the worst case
[ "Return", "the", "least", "signifiant", "bit", "O", "(", "N", ")", "in", "the", "worst", "case" ]
python
train
globus/globus-cli
globus_cli/commands/update.py
https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/commands/update.py#L18-L25
def _call_pip(*args): """ Invoke pip *safely* and in the *supported* way: https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program """ all_args = [sys.executable, "-m", "pip"] + list(args) print("> {}".format(" ".join(all_args))) subprocess.check_call(all_args)
[ "def", "_call_pip", "(", "*", "args", ")", ":", "all_args", "=", "[", "sys", ".", "executable", ",", "\"-m\"", ",", "\"pip\"", "]", "+", "list", "(", "args", ")", "print", "(", "\"> {}\"", ".", "format", "(", "\" \"", ".", "join", "(", "all_args", ...
Invoke pip *safely* and in the *supported* way: https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program
[ "Invoke", "pip", "*", "safely", "*", "and", "in", "the", "*", "supported", "*", "way", ":", "https", ":", "//", "pip", ".", "pypa", ".", "io", "/", "en", "/", "latest", "/", "user_guide", "/", "#using", "-", "pip", "-", "from", "-", "your", "-", ...
python
train
hydraplatform/hydra-base
hydra_base/lib/scenario.py
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L910-L936
def get_attribute_data(attr_ids, node_ids, **kwargs): """ For a given attribute or set of attributes, return all the resources and resource scenarios in the network """ node_attrs = db.DBSession.query(ResourceAttr).\ options(joinedload_all('attr')...
[ "def", "get_attribute_data", "(", "attr_ids", ",", "node_ids", ",", "*", "*", "kwargs", ")", ":", "node_attrs", "=", "db", ".", "DBSession", ".", "query", "(", "ResourceAttr", ")", ".", "options", "(", "joinedload_all", "(", "'attr'", ")", ")", ".", "fil...
For a given attribute or set of attributes, return all the resources and resource scenarios in the network
[ "For", "a", "given", "attribute", "or", "set", "of", "attributes", "return", "all", "the", "resources", "and", "resource", "scenarios", "in", "the", "network" ]
python
train
pandas-dev/pandas
pandas/io/parsers.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parsers.py#L2837-L2856
def _alert_malformed(self, msg, row_num): """ Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message t...
[ "def", "_alert_malformed", "(", "self", ",", "msg", ",", "row_num", ")", ":", "if", "self", ".", "error_bad_lines", ":", "raise", "ParserError", "(", "msg", ")", "elif", "self", ".", "warn_bad_lines", ":", "base", "=", "'Skipping line {row_num}: '", ".", "fo...
Alert a user about a malformed row. If `self.error_bad_lines` is True, the alert will be `ParserError`. If `self.warn_bad_lines` is True, the alert will be printed out. Parameters ---------- msg : The error message to display. row_num : The row number where the parsing ...
[ "Alert", "a", "user", "about", "a", "malformed", "row", "." ]
python
train
CivicSpleen/ckcache
ckcache/filesystem.py
https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/filesystem.py#L924-L929
def find(self, query): '''Passes the query to the upstream, if it exists''' if not self.upstream: raise Exception("CompressionCache must have an upstream") return self.upstream.find(query)
[ "def", "find", "(", "self", ",", "query", ")", ":", "if", "not", "self", ".", "upstream", ":", "raise", "Exception", "(", "\"CompressionCache must have an upstream\"", ")", "return", "self", ".", "upstream", ".", "find", "(", "query", ")" ]
Passes the query to the upstream, if it exists
[ "Passes", "the", "query", "to", "the", "upstream", "if", "it", "exists" ]
python
train
cackharot/suds-py3
suds/properties.py
https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/properties.py#L407-L416
def prime(self): """ Prime the stored values based on default values found in property definitions. @return: self @rtype: L{Properties} """ for d in self.definitions.values(): self.defined[d.name] = d.default return self
[ "def", "prime", "(", "self", ")", ":", "for", "d", "in", "self", ".", "definitions", ".", "values", "(", ")", ":", "self", ".", "defined", "[", "d", ".", "name", "]", "=", "d", ".", "default", "return", "self" ]
Prime the stored values based on default values found in property definitions. @return: self @rtype: L{Properties}
[ "Prime", "the", "stored", "values", "based", "on", "default", "values", "found", "in", "property", "definitions", "." ]
python
train
ebroecker/canmatrix
src/canmatrix/log.py
https://github.com/ebroecker/canmatrix/blob/d6150b7a648350f051a11c431e9628308c8d5593/src/canmatrix/log.py#L48-L61
def set_log_level(logger, level): # type: (logging.Logger, int) -> None """Dynamic reconfiguration of the log level""" if level > 2: level = 2 if level < -1: level = -1 levels = { -1: logging.ERROR, 0: logging.WARN, 1: logging.INFO, 2: logging.DEBUG ...
[ "def", "set_log_level", "(", "logger", ",", "level", ")", ":", "# type: (logging.Logger, int) -> None", "if", "level", ">", "2", ":", "level", "=", "2", "if", "level", "<", "-", "1", ":", "level", "=", "-", "1", "levels", "=", "{", "-", "1", ":", "lo...
Dynamic reconfiguration of the log level
[ "Dynamic", "reconfiguration", "of", "the", "log", "level" ]
python
train
minorg/pastpy
py/src/pastpy/gen/database/impl/online/online_database_object_detail_image.py
https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/online/online_database_object_detail_image.py#L445-L487
def write(self, oprot): ''' Write this object to the given output protocol and return self. :type oprot: thryft.protocol._output_protocol._OutputProtocol :rtype: pastpy.gen.database.impl.online.online_database_object_detail_image.OnlineDatabaseObjectDetailImage ''' opro...
[ "def", "write", "(", "self", ",", "oprot", ")", ":", "oprot", ".", "write_struct_begin", "(", "'OnlineDatabaseObjectDetailImage'", ")", "oprot", ".", "write_field_begin", "(", "name", "=", "'full_size_url'", ",", "type", "=", "11", ",", "id", "=", "None", ")...
Write this object to the given output protocol and return self. :type oprot: thryft.protocol._output_protocol._OutputProtocol :rtype: pastpy.gen.database.impl.online.online_database_object_detail_image.OnlineDatabaseObjectDetailImage
[ "Write", "this", "object", "to", "the", "given", "output", "protocol", "and", "return", "self", "." ]
python
train
earwig/mwparserfromhell
mwparserfromhell/wikicode.py
https://github.com/earwig/mwparserfromhell/blob/98dc30902d35c714a70aca8e6616f49d71cb24cc/mwparserfromhell/wikicode.py#L163-L205
def _do_weak_search(self, obj, recursive): """Search for an element that looks like *obj* within the node list. This follows the same rules as :meth:`_do_strong_search` with some differences. *obj* is treated as a string that might represent any :class:`.Node`, :class:`.Wikicode`, or co...
[ "def", "_do_weak_search", "(", "self", ",", "obj", ",", "recursive", ")", ":", "obj", "=", "parse_anything", "(", "obj", ")", "if", "not", "obj", "or", "obj", "not", "in", "self", ":", "raise", "ValueError", "(", "obj", ")", "results", "=", "[", "]",...
Search for an element that looks like *obj* within the node list. This follows the same rules as :meth:`_do_strong_search` with some differences. *obj* is treated as a string that might represent any :class:`.Node`, :class:`.Wikicode`, or combination of the two present in the node list....
[ "Search", "for", "an", "element", "that", "looks", "like", "*", "obj", "*", "within", "the", "node", "list", "." ]
python
train
phoebe-project/phoebe2
phoebe/frontend/bundle.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/frontend/bundle.py#L936-L953
def undo(self, i=-1): """ Undo an item in the history logs :parameter int i: integer for indexing (can be positive or negative). Defaults to -1 if not provided (the latest recorded history item) :raises ValueError: if no history items have been recorded ...
[ "def", "undo", "(", "self", ",", "i", "=", "-", "1", ")", ":", "_history_enabled", "=", "self", ".", "history_enabled", "param", "=", "self", ".", "get_history", "(", "i", ")", "self", ".", "disable_history", "(", ")", "param", ".", "undo", "(", ")",...
Undo an item in the history logs :parameter int i: integer for indexing (can be positive or negative). Defaults to -1 if not provided (the latest recorded history item) :raises ValueError: if no history items have been recorded
[ "Undo", "an", "item", "in", "the", "history", "logs" ]
python
train
TheRealLink/pylgtv
pylgtv/webos_client.py
https://github.com/TheRealLink/pylgtv/blob/a7d9ad87ce47e77180fe9262da785465219f4ed6/pylgtv/webos_client.py#L314-L317
def get_volume(self): """Get the current volume.""" self.request(EP_GET_VOLUME) return 0 if self.last_response is None else self.last_response.get('payload').get('volume')
[ "def", "get_volume", "(", "self", ")", ":", "self", ".", "request", "(", "EP_GET_VOLUME", ")", "return", "0", "if", "self", ".", "last_response", "is", "None", "else", "self", ".", "last_response", ".", "get", "(", "'payload'", ")", ".", "get", "(", "'...
Get the current volume.
[ "Get", "the", "current", "volume", "." ]
python
train