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
SHTOOLS/SHTOOLS
pyshtools/shclasses/shcoeffsgrid.py
https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shcoeffsgrid.py#L2500-L2523
def lons(self, degrees=True): """ Return the longitudes of each column of the gridded data. Usage ----- lons = x.get_lon([degrees]) Returns ------- lons : ndarray, shape (nlon) 1-D numpy array of size nlon containing the longitude of each row...
[ "def", "lons", "(", "self", ",", "degrees", "=", "True", ")", ":", "if", "degrees", "is", "False", ":", "return", "_np", ".", "radians", "(", "self", ".", "_lons", "(", ")", ")", "else", ":", "return", "self", ".", "_lons", "(", ")" ]
Return the longitudes of each column of the gridded data. Usage ----- lons = x.get_lon([degrees]) Returns ------- lons : ndarray, shape (nlon) 1-D numpy array of size nlon containing the longitude of each row of the gridded data. Paramet...
[ "Return", "the", "longitudes", "of", "each", "column", "of", "the", "gridded", "data", "." ]
python
train
Yubico/yubikey-manager
ykman/cli/oath.py
https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/oath.py#L120-L137
def info(ctx): """ Display status of OATH application. """ controller = ctx.obj['controller'] version = controller.version click.echo( 'OATH version: {}.{}.{}'.format(version[0], version[1], version[2])) click.echo('Password protection ' + ('enabled' if controller.lock...
[ "def", "info", "(", "ctx", ")", ":", "controller", "=", "ctx", ".", "obj", "[", "'controller'", "]", "version", "=", "controller", ".", "version", "click", ".", "echo", "(", "'OATH version: {}.{}.{}'", ".", "format", "(", "version", "[", "0", "]", ",", ...
Display status of OATH application.
[ "Display", "status", "of", "OATH", "application", "." ]
python
train
bcbio/bcbio-nextgen
bcbio/variation/prioritize.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/prioritize.py#L132-L146
def _prepare_vcf_rec(rec, pops, known, impact_info): """Parse a vcfanno output into a dictionary of useful attributes. """ out = {} for k in pops + known: out[k] = rec.INFO.get(k) if impact_info: cur_info = rec.INFO.get(impact_info.id) if cur_info: cur_impacts = [...
[ "def", "_prepare_vcf_rec", "(", "rec", ",", "pops", ",", "known", ",", "impact_info", ")", ":", "out", "=", "{", "}", "for", "k", "in", "pops", "+", "known", ":", "out", "[", "k", "]", "=", "rec", ".", "INFO", ".", "get", "(", "k", ")", "if", ...
Parse a vcfanno output into a dictionary of useful attributes.
[ "Parse", "a", "vcfanno", "output", "into", "a", "dictionary", "of", "useful", "attributes", "." ]
python
train
ageitgey/face_recognition
face_recognition/api.py
https://github.com/ageitgey/face_recognition/blob/c96b010c02f15e8eeb0f71308c641179ac1f19bb/face_recognition/api.py#L78-L89
def load_image_file(file, mode='RGB'): """ Loads an image file (.jpg, .png, etc) into a numpy array :param file: image file name or file object to load :param mode: format to convert the image to. Only 'RGB' (8-bit RGB, 3 channels) and 'L' (black and white) are supported. :return: image contents as...
[ "def", "load_image_file", "(", "file", ",", "mode", "=", "'RGB'", ")", ":", "im", "=", "PIL", ".", "Image", ".", "open", "(", "file", ")", "if", "mode", ":", "im", "=", "im", ".", "convert", "(", "mode", ")", "return", "np", ".", "array", "(", ...
Loads an image file (.jpg, .png, etc) into a numpy array :param file: image file name or file object to load :param mode: format to convert the image to. Only 'RGB' (8-bit RGB, 3 channels) and 'L' (black and white) are supported. :return: image contents as numpy array
[ "Loads", "an", "image", "file", "(", ".", "jpg", ".", "png", "etc", ")", "into", "a", "numpy", "array" ]
python
train
eqcorrscan/EQcorrscan
eqcorrscan/utils/catalog_to_dd.py
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/catalog_to_dd.py#L57-L74
def _cc_round(num, dp): """ Convenience function to take a float and round it to dp padding with zeros to return a string :type num: float :param num: Number to round :type dp: int :param dp: Number of decimal places to round to. :returns: str >>> print(_cc_round(0.25364, 2)) ...
[ "def", "_cc_round", "(", "num", ",", "dp", ")", ":", "num", "=", "round", "(", "num", ",", "dp", ")", "num", "=", "'{0:.{1}f}'", ".", "format", "(", "num", ",", "dp", ")", "return", "num" ]
Convenience function to take a float and round it to dp padding with zeros to return a string :type num: float :param num: Number to round :type dp: int :param dp: Number of decimal places to round to. :returns: str >>> print(_cc_round(0.25364, 2)) 0.25
[ "Convenience", "function", "to", "take", "a", "float", "and", "round", "it", "to", "dp", "padding", "with", "zeros", "to", "return", "a", "string" ]
python
train
inasafe/inasafe
safe/utilities/gis.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/gis.py#L271-L285
def is_line_layer(layer): """Check if a QGIS layer is vector and its geometries are lines. :param layer: A vector layer. :type layer: QgsVectorLayer, QgsMapLayer :returns: True if the layer contains lines, otherwise False. :rtype: bool """ try: return (layer.type() == QgsMapLayer....
[ "def", "is_line_layer", "(", "layer", ")", ":", "try", ":", "return", "(", "layer", ".", "type", "(", ")", "==", "QgsMapLayer", ".", "VectorLayer", ")", "and", "(", "layer", ".", "geometryType", "(", ")", "==", "QgsWkbTypes", ".", "LineGeometry", ")", ...
Check if a QGIS layer is vector and its geometries are lines. :param layer: A vector layer. :type layer: QgsVectorLayer, QgsMapLayer :returns: True if the layer contains lines, otherwise False. :rtype: bool
[ "Check", "if", "a", "QGIS", "layer", "is", "vector", "and", "its", "geometries", "are", "lines", "." ]
python
train
dropbox/pyannotate
pyannotate_runtime/collect_types.py
https://github.com/dropbox/pyannotate/blob/d128c76b8a86f208e5c78716f2a917003650cebc/pyannotate_runtime/collect_types.py#L787-L807
def default_filter_filename(filename): # type: (Optional[str]) -> Optional[str] """Default filter for filenames. Returns either a normalized filename or None. You can pass your own filter to init_types_collection(). """ if filename is None: return None elif filename.startswith(TOP_D...
[ "def", "default_filter_filename", "(", "filename", ")", ":", "# type: (Optional[str]) -> Optional[str]", "if", "filename", "is", "None", ":", "return", "None", "elif", "filename", ".", "startswith", "(", "TOP_DIR", ")", ":", "if", "filename", ".", "startswith", "(...
Default filter for filenames. Returns either a normalized filename or None. You can pass your own filter to init_types_collection().
[ "Default", "filter", "for", "filenames", "." ]
python
train
5monkeys/django-bananas
bananas/url.py
https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/url.py#L92-L134
def get_engine(scheme): """ Perform a lookup in _ENGINE_MAPPING using engine_string. :param scheme: '+'-separated string Maximum of 2 parts, i.e "postgres+psycopg" is OK, "postgres+psycopg2+postgis" is NOT OK. :return: Engine string """ path = scheme.split("+") first, rest = path[0], pa...
[ "def", "get_engine", "(", "scheme", ")", ":", "path", "=", "scheme", ".", "split", "(", "\"+\"", ")", "first", ",", "rest", "=", "path", "[", "0", "]", ",", "path", "[", "1", ":", "]", "second", "=", "rest", "[", "0", "]", "if", "rest", "else",...
Perform a lookup in _ENGINE_MAPPING using engine_string. :param scheme: '+'-separated string Maximum of 2 parts, i.e "postgres+psycopg" is OK, "postgres+psycopg2+postgis" is NOT OK. :return: Engine string
[ "Perform", "a", "lookup", "in", "_ENGINE_MAPPING", "using", "engine_string", "." ]
python
test
pantsbuild/pants
src/python/pants/goal/run_tracker.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/goal/run_tracker.py#L414-L420
def run_information(self): """Basic information about this run.""" run_information = self.run_info.get_as_dict() target_data = run_information.get('target_data', None) if target_data: run_information['target_data'] = ast.literal_eval(target_data) return run_information
[ "def", "run_information", "(", "self", ")", ":", "run_information", "=", "self", ".", "run_info", ".", "get_as_dict", "(", ")", "target_data", "=", "run_information", ".", "get", "(", "'target_data'", ",", "None", ")", "if", "target_data", ":", "run_informatio...
Basic information about this run.
[ "Basic", "information", "about", "this", "run", "." ]
python
train
rigetti/pyquil
pyquil/gates.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/gates.py#L719-L731
def LT(classical_reg1, classical_reg2, classical_reg3): """ Produce an LT instruction. :param classical_reg1: Memory address to which to store the comparison result. :param classical_reg2: Left comparison operand. :param classical_reg3: Right comparison operand. :return: A ClassicalLessThan ins...
[ "def", "LT", "(", "classical_reg1", ",", "classical_reg2", ",", "classical_reg3", ")", ":", "classical_reg1", ",", "classical_reg2", ",", "classical_reg3", "=", "prepare_ternary_operands", "(", "classical_reg1", ",", "classical_reg2", ",", "classical_reg3", ")", "retu...
Produce an LT instruction. :param classical_reg1: Memory address to which to store the comparison result. :param classical_reg2: Left comparison operand. :param classical_reg3: Right comparison operand. :return: A ClassicalLessThan instance.
[ "Produce", "an", "LT", "instruction", "." ]
python
train
relwell/corenlp-xml-lib
corenlp_xml/document.py
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L356-L368
def word(self): """ Lazy-loads word value :getter: Returns the plain string value of the word :type: str """ if self._word is None: words = self._element.xpath('word/text()') if len(words) > 0: self._word = words[0] return...
[ "def", "word", "(", "self", ")", ":", "if", "self", ".", "_word", "is", "None", ":", "words", "=", "self", ".", "_element", ".", "xpath", "(", "'word/text()'", ")", "if", "len", "(", "words", ")", ">", "0", ":", "self", ".", "_word", "=", "words"...
Lazy-loads word value :getter: Returns the plain string value of the word :type: str
[ "Lazy", "-", "loads", "word", "value" ]
python
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L83-L90
def _parse_fields(self, result, field_name): """ If Schema access, parse fields and build respective lists """ field_list = [] for key, value in result.get('schema', {}).get(field_name, {}).items(): if key not in field_list: field_list.append(key) retu...
[ "def", "_parse_fields", "(", "self", ",", "result", ",", "field_name", ")", ":", "field_list", "=", "[", "]", "for", "key", ",", "value", "in", "result", ".", "get", "(", "'schema'", ",", "{", "}", ")", ".", "get", "(", "field_name", ",", "{", "}",...
If Schema access, parse fields and build respective lists
[ "If", "Schema", "access", "parse", "fields", "and", "build", "respective", "lists" ]
python
train
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L188-L194
def get_leaf_children(gos_user, go2obj_arg): """Find all the GO descendants under all user GO IDs. Return leaf-level GO IDs.""" childgoid2obj = {} for goid_usr in gos_user: goobj_usr = go2obj_arg[goid_usr] fill_childgoid2obj(childgoid2obj, goobj_usr) return set(go for go, o in childgoid2...
[ "def", "get_leaf_children", "(", "gos_user", ",", "go2obj_arg", ")", ":", "childgoid2obj", "=", "{", "}", "for", "goid_usr", "in", "gos_user", ":", "goobj_usr", "=", "go2obj_arg", "[", "goid_usr", "]", "fill_childgoid2obj", "(", "childgoid2obj", ",", "goobj_usr"...
Find all the GO descendants under all user GO IDs. Return leaf-level GO IDs.
[ "Find", "all", "the", "GO", "descendants", "under", "all", "user", "GO", "IDs", ".", "Return", "leaf", "-", "level", "GO", "IDs", "." ]
python
train
saltstack/salt
salt/utils/win_reg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_reg.py#L162-L205
def key_exists(hive, key, use_32bit_registry=False): ''' Check that the key is found in the registry. This refers to keys and not value/data pairs. To check value/data pairs, use ``value_exists`` Args: hive (str): The hive to connect to key (str): The key to check use_32bit_r...
[ "def", "key_exists", "(", "hive", ",", "key", ",", "use_32bit_registry", "=", "False", ")", ":", "local_hive", "=", "_to_unicode", "(", "hive", ")", "local_key", "=", "_to_unicode", "(", "key", ")", "registry", "=", "Registry", "(", ")", "try", ":", "hke...
Check that the key is found in the registry. This refers to keys and not value/data pairs. To check value/data pairs, use ``value_exists`` Args: hive (str): The hive to connect to key (str): The key to check use_32bit_registry (bool): Look in the 32bit portion of the registry Re...
[ "Check", "that", "the", "key", "is", "found", "in", "the", "registry", ".", "This", "refers", "to", "keys", "and", "not", "value", "/", "data", "pairs", ".", "To", "check", "value", "/", "data", "pairs", "use", "value_exists" ]
python
train
DataDog/integrations-core
kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py#L448-L466
def kube_cronjob_next_schedule_time(self, metric, scraper_config): """ Time until the next schedule """ # Used as a service check so that one can be alerted if the cronjob's next schedule is in the past check_basename = scraper_config['namespace'] + '.cronjob.on_schedule_check' curr_time...
[ "def", "kube_cronjob_next_schedule_time", "(", "self", ",", "metric", ",", "scraper_config", ")", ":", "# Used as a service check so that one can be alerted if the cronjob's next schedule is in the past", "check_basename", "=", "scraper_config", "[", "'namespace'", "]", "+", "'.c...
Time until the next schedule
[ "Time", "until", "the", "next", "schedule" ]
python
train
inasafe/inasafe
safe/datastore/datastore.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/datastore/datastore.py#L143-L163
def layer(self, layer_name): """Get QGIS layer. :param layer_name: The name of the layer to fetch. :type layer_name: str :return: The QGIS layer. :rtype: QgsMapLayer .. versionadded:: 4.0 """ uri = self.layer_uri(layer_name) layer = QgsVectorLay...
[ "def", "layer", "(", "self", ",", "layer_name", ")", ":", "uri", "=", "self", ".", "layer_uri", "(", "layer_name", ")", "layer", "=", "QgsVectorLayer", "(", "uri", ",", "layer_name", ",", "'ogr'", ")", "if", "not", "layer", ".", "isValid", "(", ")", ...
Get QGIS layer. :param layer_name: The name of the layer to fetch. :type layer_name: str :return: The QGIS layer. :rtype: QgsMapLayer .. versionadded:: 4.0
[ "Get", "QGIS", "layer", "." ]
python
train
byroot/pysrt
pysrt/srttime.py
https://github.com/byroot/pysrt/blob/e23ca39de37d54e988f4726c311aee4d4770c2ca/pysrt/srttime.py#L165-L170
def from_time(cls, source): """ datetime.time -> SubRipTime corresponding to time object """ return cls(hours=source.hour, minutes=source.minute, seconds=source.second, milliseconds=source.microsecond // 1000)
[ "def", "from_time", "(", "cls", ",", "source", ")", ":", "return", "cls", "(", "hours", "=", "source", ".", "hour", ",", "minutes", "=", "source", ".", "minute", ",", "seconds", "=", "source", ".", "second", ",", "milliseconds", "=", "source", ".", "...
datetime.time -> SubRipTime corresponding to time object
[ "datetime", ".", "time", "-", ">", "SubRipTime", "corresponding", "to", "time", "object" ]
python
train
spotify/gordon-gcp
src/gordon_gcp/plugins/janitor/__init__.py
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/plugins/janitor/__init__.py#L56-L77
def get_reconciler(config, metrics, rrset_channel, changes_channel, **kw): """Get a GDNSReconciler client. A factory function that validates configuration, creates an auth and :class:`GDNSClient` instance, and returns a GDNSReconciler provider. Args: config (dict): Google Cloud Pub/Sub-rel...
[ "def", "get_reconciler", "(", "config", ",", "metrics", ",", "rrset_channel", ",", "changes_channel", ",", "*", "*", "kw", ")", ":", "builder", "=", "reconciler", ".", "GDNSReconcilerBuilder", "(", "config", ",", "metrics", ",", "rrset_channel", ",", "changes_...
Get a GDNSReconciler client. A factory function that validates configuration, creates an auth and :class:`GDNSClient` instance, and returns a GDNSReconciler provider. Args: config (dict): Google Cloud Pub/Sub-related configuration. metrics (obj): :interface:`IMetricRelay` implementatio...
[ "Get", "a", "GDNSReconciler", "client", "." ]
python
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L396-L406
def describe_config_variable(self, config_id): """Describe the config variable by its id.""" config = self._config_variables.get(config_id) if config is None: return [Error.INVALID_ARRAY_KEY, 0, 0, 0, 0] packed_size = config.total_size packed_size |= int(config.vari...
[ "def", "describe_config_variable", "(", "self", ",", "config_id", ")", ":", "config", "=", "self", ".", "_config_variables", ".", "get", "(", "config_id", ")", "if", "config", "is", "None", ":", "return", "[", "Error", ".", "INVALID_ARRAY_KEY", ",", "0", "...
Describe the config variable by its id.
[ "Describe", "the", "config", "variable", "by", "its", "id", "." ]
python
train
aegirhall/console-menu
consolemenu/prompt_utils.py
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/prompt_utils.py#L76-L86
def enter_to_continue(self, message=None): """ Creates a console prompt with the given message, or defaults to 'Press [Enter] to continue' if no message is provided. :param message: """ if message: message = message.rstrip() + ' ' else: mes...
[ "def", "enter_to_continue", "(", "self", ",", "message", "=", "None", ")", ":", "if", "message", ":", "message", "=", "message", ".", "rstrip", "(", ")", "+", "' '", "else", ":", "message", "=", "'Press [Enter] to continue '", "self", ".", "__screen", ".",...
Creates a console prompt with the given message, or defaults to 'Press [Enter] to continue' if no message is provided. :param message:
[ "Creates", "a", "console", "prompt", "with", "the", "given", "message", "or", "defaults", "to", "Press", "[", "Enter", "]", "to", "continue", "if", "no", "message", "is", "provided", ".", ":", "param", "message", ":" ]
python
train
rosenbrockc/fortpy
fortpy/docelements.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/docelements.py#L105-L117
def parse(self, parser, xml): """Parses the rawtext to extract contents and references.""" #We can only process references if the XML tag has inner-XML if xml.text is not None: matches = parser.RE_REFS.finditer(xml.text) if matches: for match in matches: ...
[ "def", "parse", "(", "self", ",", "parser", ",", "xml", ")", ":", "#We can only process references if the XML tag has inner-XML", "if", "xml", ".", "text", "is", "not", "None", ":", "matches", "=", "parser", ".", "RE_REFS", ".", "finditer", "(", "xml", ".", ...
Parses the rawtext to extract contents and references.
[ "Parses", "the", "rawtext", "to", "extract", "contents", "and", "references", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py#L677-L689
def qos_queue_scheduler_strict_priority_dwrr_traffic_class4(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") qos = ET.SubElement(config, "qos", xmlns="urn:brocade.com:mgmt:brocade-qos") queue = ET.SubElement(qos, "queue") scheduler = ET.SubElement...
[ "def", "qos_queue_scheduler_strict_priority_dwrr_traffic_class4", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "qos", "=", "ET", ".", "SubElement", "(", "config", ",", "\"qos\"", ",", "xmlns", "...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
apache/incubator-mxnet
example/sparse/matrix_factorization/train.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/matrix_factorization/train.py#L52-L57
def batch_row_ids(data_batch): """ Generate row ids based on the current mini-batch """ item = data_batch.data[0] user = data_batch.data[1] return {'user_weight': user.astype(np.int64), 'item_weight': item.astype(np.int64)}
[ "def", "batch_row_ids", "(", "data_batch", ")", ":", "item", "=", "data_batch", ".", "data", "[", "0", "]", "user", "=", "data_batch", ".", "data", "[", "1", "]", "return", "{", "'user_weight'", ":", "user", ".", "astype", "(", "np", ".", "int64", ")...
Generate row ids based on the current mini-batch
[ "Generate", "row", "ids", "based", "on", "the", "current", "mini", "-", "batch" ]
python
train
johncosta/django-like-button
like_button/templatetags/like_button.py
https://github.com/johncosta/django-like-button/blob/c93a1be9c041d76e8de9a26f424ad4f836ab97bd/like_button/templatetags/like_button.py#L34-L55
def like_button_js_tag(context): """ This tag will check to see if they have the FACEBOOK_LIKE_APP_ID setup correctly in the django settings, if so then it will pass the data along to the intercom_tag template to be displayed. If something isn't perfect we will return False, which will then...
[ "def", "like_button_js_tag", "(", "context", ")", ":", "if", "FACEBOOK_APP_ID", "is", "None", ":", "log", ".", "warning", "(", "\"FACEBOOK_APP_ID isn't setup correctly in your settings\"", ")", "# make sure FACEBOOK_APP_ID is setup correct and user is authenticated", "if", "FAC...
This tag will check to see if they have the FACEBOOK_LIKE_APP_ID setup correctly in the django settings, if so then it will pass the data along to the intercom_tag template to be displayed. If something isn't perfect we will return False, which will then not install the javascript since...
[ "This", "tag", "will", "check", "to", "see", "if", "they", "have", "the", "FACEBOOK_LIKE_APP_ID", "setup", "correctly", "in", "the", "django", "settings", "if", "so", "then", "it", "will", "pass", "the", "data", "along", "to", "the", "intercom_tag", "templat...
python
train
openpaperwork/paperwork-backend
paperwork_backend/index.py
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L566-L611
def find_suggestions(self, sentence): """ Search all possible suggestions. Suggestions returned always have at least one document matching. Arguments: sentence --- keywords (single strings) for which we want suggestions Return: An array of...
[ "def", "find_suggestions", "(", "self", ",", "sentence", ")", ":", "if", "not", "isinstance", "(", "sentence", ",", "str", ")", ":", "sentence", "=", "str", "(", "sentence", ")", "keywords", "=", "sentence", ".", "split", "(", "\" \"", ")", "query_parser...
Search all possible suggestions. Suggestions returned always have at least one document matching. Arguments: sentence --- keywords (single strings) for which we want suggestions Return: An array of sets of keywords. Each set of keywords (-> one string) ...
[ "Search", "all", "possible", "suggestions", ".", "Suggestions", "returned", "always", "have", "at", "least", "one", "document", "matching", "." ]
python
train
Robpol86/libnl
libnl/socket_.py
https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/socket_.py#L51-L61
def generate_local_port(): """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/socket.c#L63.""" global _PREVIOUS_LOCAL_PORT if _PREVIOUS_LOCAL_PORT is None: try: with contextlib.closing(socket.socket(getattr(socket, 'AF_NETLINK', -1), socket.SOCK_RAW)) as s: s.bind((...
[ "def", "generate_local_port", "(", ")", ":", "global", "_PREVIOUS_LOCAL_PORT", "if", "_PREVIOUS_LOCAL_PORT", "is", "None", ":", "try", ":", "with", "contextlib", ".", "closing", "(", "socket", ".", "socket", "(", "getattr", "(", "socket", ",", "'AF_NETLINK'", ...
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/socket.c#L63.
[ "https", ":", "//", "github", ".", "com", "/", "thom311", "/", "libnl", "/", "blob", "/", "libnl3_2_25", "/", "lib", "/", "socket", ".", "c#L63", "." ]
python
train
JIC-CSB/jicimagelib
jicimagelib/image.py
https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/image.py#L266-L301
def load(self, fpath): """Load a microscopy file. :param fpath: path to microscopy file """ def is_microscopy_item(fpath): """Return True if the fpath is likely to be microscopy data. :param fpath: file path to image :returns: :class:`bool` ...
[ "def", "load", "(", "self", ",", "fpath", ")", ":", "def", "is_microscopy_item", "(", "fpath", ")", ":", "\"\"\"Return True if the fpath is likely to be microscopy data.\n\n :param fpath: file path to image\n :returns: :class:`bool`\n \"\"\"", "l", "=...
Load a microscopy file. :param fpath: path to microscopy file
[ "Load", "a", "microscopy", "file", ".", ":", "param", "fpath", ":", "path", "to", "microscopy", "file" ]
python
train
IAMconsortium/pyam
pyam/utils.py
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L332-L343
def _escape_regexp(s): """escape characters with specific regexp use""" return ( str(s) .replace('|', '\\|') .replace('.', '\.') # `.` has to be replaced before `*` .replace('*', '.*') .replace('+', '\+') .replace('(', '\(') .replace(')', '\)') .r...
[ "def", "_escape_regexp", "(", "s", ")", ":", "return", "(", "str", "(", "s", ")", ".", "replace", "(", "'|'", ",", "'\\\\|'", ")", ".", "replace", "(", "'.'", ",", "'\\.'", ")", "# `.` has to be replaced before `*`", ".", "replace", "(", "'*'", ",", "'...
escape characters with specific regexp use
[ "escape", "characters", "with", "specific", "regexp", "use" ]
python
train
saltstack/salt
salt/states/augeas.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/augeas.py#L65-L110
def _check_filepath(changes): ''' Ensure all changes are fully qualified and affect only one file. This ensures that the diff output works and a state change is not incorrectly reported. ''' filename = None for change_ in changes: try: cmd, arg = change_.split(' ', 1) ...
[ "def", "_check_filepath", "(", "changes", ")", ":", "filename", "=", "None", "for", "change_", "in", "changes", ":", "try", ":", "cmd", ",", "arg", "=", "change_", ".", "split", "(", "' '", ",", "1", ")", "if", "cmd", "not", "in", "METHOD_MAP", ":", ...
Ensure all changes are fully qualified and affect only one file. This ensures that the diff output works and a state change is not incorrectly reported.
[ "Ensure", "all", "changes", "are", "fully", "qualified", "and", "affect", "only", "one", "file", ".", "This", "ensures", "that", "the", "diff", "output", "works", "and", "a", "state", "change", "is", "not", "incorrectly", "reported", "." ]
python
train
ib-lundgren/flask-oauthprovider
examples/demoprovider/login.py
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/examples/demoprovider/login.py#L90-L114
def edit_profile(): """Updates a profile""" if g.user is None: abort(401) form = dict(name=g.user.name, email=g.user.email) if request.method == 'POST': if 'delete' in request.form: db_session.delete(g.user) db_session.commit() session['openid'] = None...
[ "def", "edit_profile", "(", ")", ":", "if", "g", ".", "user", "is", "None", ":", "abort", "(", "401", ")", "form", "=", "dict", "(", "name", "=", "g", ".", "user", ".", "name", ",", "email", "=", "g", ".", "user", ".", "email", ")", "if", "re...
Updates a profile
[ "Updates", "a", "profile" ]
python
train
apache/incubator-heron
heron/tools/admin/src/python/standalone.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/admin/src/python/standalone.py#L634-L639
def make_tarfile(output_filename, source_dir): ''' Tar a directory ''' with tarfile.open(output_filename, "w:gz") as tar: tar.add(source_dir, arcname=os.path.basename(source_dir))
[ "def", "make_tarfile", "(", "output_filename", ",", "source_dir", ")", ":", "with", "tarfile", ".", "open", "(", "output_filename", ",", "\"w:gz\"", ")", "as", "tar", ":", "tar", ".", "add", "(", "source_dir", ",", "arcname", "=", "os", ".", "path", ".",...
Tar a directory
[ "Tar", "a", "directory" ]
python
valid
fastai/fastai
fastai/data_block.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L257-L265
def _label_from_list(self, labels:Iterator, label_cls:Callable=None, from_item_lists:bool=False, **kwargs)->'LabelList': "Label `self.items` with `labels`." if not from_item_lists: raise Exception("Your data isn't split, if you don't want a validation set, please use `split_none`.") ...
[ "def", "_label_from_list", "(", "self", ",", "labels", ":", "Iterator", ",", "label_cls", ":", "Callable", "=", "None", ",", "from_item_lists", ":", "bool", "=", "False", ",", "*", "*", "kwargs", ")", "->", "'LabelList'", ":", "if", "not", "from_item_lists...
Label `self.items` with `labels`.
[ "Label", "self", ".", "items", "with", "labels", "." ]
python
train
admiralobvious/flask-simpleldap
flask_simpleldap/__init__.py
https://github.com/admiralobvious/flask-simpleldap/blob/c0554780f84c42866b241c0d68fd76aaaf065e02/flask_simpleldap/__init__.py#L110-L125
def bind(self): """Attempts to bind to the LDAP server using the credentials of the service account. :return: Bound LDAP connection object if successful or ``None`` if unsuccessful. """ conn = self.initialize try: conn.simple_bind_s( ...
[ "def", "bind", "(", "self", ")", ":", "conn", "=", "self", ".", "initialize", "try", ":", "conn", ".", "simple_bind_s", "(", "current_app", ".", "config", "[", "'LDAP_USERNAME'", "]", ",", "current_app", ".", "config", "[", "'LDAP_PASSWORD'", "]", ")", "...
Attempts to bind to the LDAP server using the credentials of the service account. :return: Bound LDAP connection object if successful or ``None`` if unsuccessful.
[ "Attempts", "to", "bind", "to", "the", "LDAP", "server", "using", "the", "credentials", "of", "the", "service", "account", "." ]
python
train
saltstack/salt
salt/states/firewalld.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/firewalld.py#L338-L766
def _present(name, block_icmp=None, prune_block_icmp=False, default=None, masquerade=False, ports=None, prune_ports=False, port_fwd=None, prune_port_fwd=False, services=None, # TODO: prune_services=Fa...
[ "def", "_present", "(", "name", ",", "block_icmp", "=", "None", ",", "prune_block_icmp", "=", "False", ",", "default", "=", "None", ",", "masquerade", "=", "False", ",", "ports", "=", "None", ",", "prune_ports", "=", "False", ",", "port_fwd", "=", "None"...
Ensure a zone has specific attributes.
[ "Ensure", "a", "zone", "has", "specific", "attributes", "." ]
python
train
matthieugouel/gibica
gibica/interpreter.py
https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/interpreter.py#L58-L67
def visit_FunctionDeclaration(self, node): """Visitor for `FunctionDeclaration` AST node.""" scope = self.memory.stack.current.current.copy() args = [parameter.variable.identifier.name for parameter in node.parameters] for i in islice(scope, len(args)): self.memory.stack.cur...
[ "def", "visit_FunctionDeclaration", "(", "self", ",", "node", ")", ":", "scope", "=", "self", ".", "memory", ".", "stack", ".", "current", ".", "current", ".", "copy", "(", ")", "args", "=", "[", "parameter", ".", "variable", ".", "identifier", ".", "n...
Visitor for `FunctionDeclaration` AST node.
[ "Visitor", "for", "FunctionDeclaration", "AST", "node", "." ]
python
train
ikegami-yukino/jaconv
jaconv/jaconv.py
https://github.com/ikegami-yukino/jaconv/blob/5319e4c6b4676ab27b5e9ebec9a299d09a5a62d7/jaconv/jaconv.py#L105-L175
def h2z(text, ignore='', kana=True, ascii=False, digit=False): """Convert Half-width (Hankaku) Katakana to Full-width (Zenkaku) Katakana Parameters ---------- text : str Half-width Katakana string. ignore : str Characters to be ignored in converting. kana : bool Either c...
[ "def", "h2z", "(", "text", ",", "ignore", "=", "''", ",", "kana", "=", "True", ",", "ascii", "=", "False", ",", "digit", "=", "False", ")", ":", "def", "_conv_dakuten", "(", "text", ")", ":", "\"\"\"Convert Hankaku Dakuten Kana to Zenkaku Dakuten Kana\n ...
Convert Half-width (Hankaku) Katakana to Full-width (Zenkaku) Katakana Parameters ---------- text : str Half-width Katakana string. ignore : str Characters to be ignored in converting. kana : bool Either converting Kana or not. ascii : bool Either converting asci...
[ "Convert", "Half", "-", "width", "(", "Hankaku", ")", "Katakana", "to", "Full", "-", "width", "(", "Zenkaku", ")", "Katakana" ]
python
train
rapidpro/dash
dash/utils/templatetags/utils.py
https://github.com/rapidpro/dash/blob/e9dc05b31b86fe3fe72e956975d1ee0a275ac016/dash/utils/templatetags/utils.py#L7-L13
def if_url(context, url_name, yes, no): """ Example: %li{ class:"{% if_url 'contacts.contact_read' 'active' '' %}" } """ current = context["request"].resolver_match.url_name return yes if url_name == current else no
[ "def", "if_url", "(", "context", ",", "url_name", ",", "yes", ",", "no", ")", ":", "current", "=", "context", "[", "\"request\"", "]", ".", "resolver_match", ".", "url_name", "return", "yes", "if", "url_name", "==", "current", "else", "no" ]
Example: %li{ class:"{% if_url 'contacts.contact_read' 'active' '' %}" }
[ "Example", ":", "%li", "{", "class", ":", "{", "%", "if_url", "contacts", ".", "contact_read", "active", "%", "}", "}" ]
python
train
noxdafox/vminspect
vminspect/winreg.py
https://github.com/noxdafox/vminspect/blob/e685282564877e2d1950f1e09b292f4f4db1dbcd/vminspect/winreg.py#L89-L100
def keys(self): """Iterates over the hive's keys. Yields WinRegKey namedtuples containing: path: path of the key "RootKey\\Key\\..." timestamp: date and time of last modification values: list of values (("ValueKey", "ValueType", ValueValue), ... ) """ ...
[ "def", "keys", "(", "self", ")", ":", "for", "node", "in", "self", ".", "node_children", "(", "self", ".", "root", "(", ")", ")", ":", "yield", "from", "self", ".", "_visit_registry", "(", "node", ",", "self", ".", "_rootkey", ")" ]
Iterates over the hive's keys. Yields WinRegKey namedtuples containing: path: path of the key "RootKey\\Key\\..." timestamp: date and time of last modification values: list of values (("ValueKey", "ValueType", ValueValue), ... )
[ "Iterates", "over", "the", "hive", "s", "keys", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xorbcolumnnavigator.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbcolumnnavigator.py#L298-L309
def emitSchemaColumnChanged(self, column): """ Emits the current column changed signal. :param column | <orb.Column> || None """ edit = self.lineEdit() if edit: edit.setText(self.navigator().currentSchemaPath()) if ...
[ "def", "emitSchemaColumnChanged", "(", "self", ",", "column", ")", ":", "edit", "=", "self", ".", "lineEdit", "(", ")", "if", "edit", ":", "edit", ".", "setText", "(", "self", ".", "navigator", "(", ")", ".", "currentSchemaPath", "(", ")", ")", "if", ...
Emits the current column changed signal. :param column | <orb.Column> || None
[ "Emits", "the", "current", "column", "changed", "signal", ".", ":", "param", "column", "|", "<orb", ".", "Column", ">", "||", "None" ]
python
train
IdentityPython/fedoidcmsg
src/fedoidcmsg/operator.py
https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/operator.py#L88-L117
def eval(self, orig): """ Apply the less or equal algorithm on the ordered list of metadata statements :param orig: Start values :return: """ _le = {} _err = [] for k, v in self.sup_items(): if k in DoNotCompare: ...
[ "def", "eval", "(", "self", ",", "orig", ")", ":", "_le", "=", "{", "}", "_err", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "sup_items", "(", ")", ":", "if", "k", "in", "DoNotCompare", ":", "continue", "if", "k", "in", "orig", ":...
Apply the less or equal algorithm on the ordered list of metadata statements :param orig: Start values :return:
[ "Apply", "the", "less", "or", "equal", "algorithm", "on", "the", "ordered", "list", "of", "metadata", "statements", ":", "param", "orig", ":", "Start", "values", ":", "return", ":" ]
python
test
Becksteinlab/GromacsWrapper
gromacs/cbook.py
https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L566-L569
def delete_frames(self): """Delete all frames.""" for frame in glob.glob(self.frameglob): os.unlink(frame)
[ "def", "delete_frames", "(", "self", ")", ":", "for", "frame", "in", "glob", ".", "glob", "(", "self", ".", "frameglob", ")", ":", "os", ".", "unlink", "(", "frame", ")" ]
Delete all frames.
[ "Delete", "all", "frames", "." ]
python
valid
SuperCowPowers/workbench
workbench/server/workbench_server.py
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/workbench_server.py#L430-L443
def clear_db(self): """ Clear the Main Database of all samples and worker output. Args: None Returns: Nothing """ self.data_store.clear_db() # Have the plugin manager reload all the plugins self.plugin_manager.load_all_plug...
[ "def", "clear_db", "(", "self", ")", ":", "self", ".", "data_store", ".", "clear_db", "(", ")", "# Have the plugin manager reload all the plugins", "self", ".", "plugin_manager", ".", "load_all_plugins", "(", ")", "# Store information about commands and workbench", "self"...
Clear the Main Database of all samples and worker output. Args: None Returns: Nothing
[ "Clear", "the", "Main", "Database", "of", "all", "samples", "and", "worker", "output", ".", "Args", ":", "None", "Returns", ":", "Nothing" ]
python
train
djangomini/djangomini
djangomini/tools.py
https://github.com/djangomini/djangomini/blob/cfbe2d59acf0e89e5fd442df8952f9a117a63875/djangomini/tools.py#L14-L42
def listdir(dir_name, get_dirs=None, get_files=None, hide_ignored=False): """ Return list of all dirs and files inside given dir. Also can filter contents to return only dirs or files. Args: - dir_name: Which directory we need to scan (relative) - get_dirs: Return dirs list - get_files: Re...
[ "def", "listdir", "(", "dir_name", ",", "get_dirs", "=", "None", ",", "get_files", "=", "None", ",", "hide_ignored", "=", "False", ")", ":", "if", "get_dirs", "is", "None", "and", "get_files", "is", "None", ":", "get_dirs", "=", "True", "get_files", "=",...
Return list of all dirs and files inside given dir. Also can filter contents to return only dirs or files. Args: - dir_name: Which directory we need to scan (relative) - get_dirs: Return dirs list - get_files: Return files list - hide_ignored: Exclude files and dirs with initial underscore
[ "Return", "list", "of", "all", "dirs", "and", "files", "inside", "given", "dir", "." ]
python
train
rwl/godot
godot/base_graph.py
https://github.com/rwl/godot/blob/013687c9e8983d2aa2ceebb8a76c5c4f1e37c90f/godot/base_graph.py#L519-L548
def add_edge(self, tail_node_or_ID, head_node_or_ID, **kwds): """ Adds an edge to the graph. """ tail_node = self.add_node(tail_node_or_ID) head_node = self.add_node(head_node_or_ID) # Only top level graphs are directed and/or strict. if "directed" in self.trait_names():...
[ "def", "add_edge", "(", "self", ",", "tail_node_or_ID", ",", "head_node_or_ID", ",", "*", "*", "kwds", ")", ":", "tail_node", "=", "self", ".", "add_node", "(", "tail_node_or_ID", ")", "head_node", "=", "self", ".", "add_node", "(", "head_node_or_ID", ")", ...
Adds an edge to the graph.
[ "Adds", "an", "edge", "to", "the", "graph", "." ]
python
test
hagenw/sphinxcontrib-katex
sphinxcontrib/katex.py
https://github.com/hagenw/sphinxcontrib-katex/blob/52e235b93a2471df9a7477e04b697e4274399623/sphinxcontrib/katex.py#L159-L177
def katex_rendering_delimiters(app): """Delimiters for rendering KaTeX math. If no delimiters are specified in katex_options, add the katex_inline and katex_display delimiters. See also https://khan.github.io/KaTeX/docs/autorender.html """ # Return if we have user defined rendering delimiters ...
[ "def", "katex_rendering_delimiters", "(", "app", ")", ":", "# Return if we have user defined rendering delimiters", "if", "'delimiters'", "in", "app", ".", "config", ".", "katex_options", ":", "return", "''", "katex_inline", "=", "[", "d", ".", "replace", "(", "'\\\...
Delimiters for rendering KaTeX math. If no delimiters are specified in katex_options, add the katex_inline and katex_display delimiters. See also https://khan.github.io/KaTeX/docs/autorender.html
[ "Delimiters", "for", "rendering", "KaTeX", "math", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py#L3051-L3066
def get_stp_brief_info_output_spanning_tree_info_spanning_tree_mode_rpvstp_rpvstp_vlan_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_stp_brief_info = ET.Element("get_stp_brief_info") config = get_stp_brief_info output = ET.SubElement(get...
[ "def", "get_stp_brief_info_output_spanning_tree_info_spanning_tree_mode_rpvstp_rpvstp_vlan_id", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_stp_brief_info", "=", "ET", ".", "Element", "(", "\"get_st...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
napalm-automation/napalm
napalm/nxos/nxos.py
https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/nxos/nxos.py#L253-L378
def ping( self, destination, source=c.PING_SOURCE, ttl=c.PING_TTL, timeout=c.PING_TIMEOUT, size=c.PING_SIZE, count=c.PING_COUNT, vrf=c.PING_VRF, ): """ Execute ping on the device and returns a dictionary with the result. Output ...
[ "def", "ping", "(", "self", ",", "destination", ",", "source", "=", "c", ".", "PING_SOURCE", ",", "ttl", "=", "c", ".", "PING_TTL", ",", "timeout", "=", "c", ".", "PING_TIMEOUT", ",", "size", "=", "c", ".", "PING_SIZE", ",", "count", "=", "c", ".",...
Execute ping on the device and returns a dictionary with the result. Output dictionary has one of following keys: * success * error In case of success, inner dictionary will have the followin keys: * probes_sent (int) * packet_loss (int) * rtt_...
[ "Execute", "ping", "on", "the", "device", "and", "returns", "a", "dictionary", "with", "the", "result", ".", "Output", "dictionary", "has", "one", "of", "following", "keys", ":", "*", "success", "*", "error", "In", "case", "of", "success", "inner", "dictio...
python
train
spencerahill/aospy
aospy/utils/vertcoord.py
https://github.com/spencerahill/aospy/blob/2f6e775b9b9956c54af117fdcdce2c87196afb6c/aospy/utils/vertcoord.py#L134-L136
def dp_from_ps(bk, pk, ps, pfull_coord): """Compute pressure level thickness from surface pressure""" return d_deta_from_phalf(phalf_from_ps(bk, pk, ps), pfull_coord)
[ "def", "dp_from_ps", "(", "bk", ",", "pk", ",", "ps", ",", "pfull_coord", ")", ":", "return", "d_deta_from_phalf", "(", "phalf_from_ps", "(", "bk", ",", "pk", ",", "ps", ")", ",", "pfull_coord", ")" ]
Compute pressure level thickness from surface pressure
[ "Compute", "pressure", "level", "thickness", "from", "surface", "pressure" ]
python
train
OzymandiasTheGreat/python-libinput
libinput/event.py
https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/event.py#L1315-L1329
def button(self): """The button that triggered this event. For events that are not of type :attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property raises :exc:`AttributeError`. Returns: int: The button triggering this event. """ if self.type != EventType.TABLET_TOOL_BUTTON: raise A...
[ "def", "button", "(", "self", ")", ":", "if", "self", ".", "type", "!=", "EventType", ".", "TABLET_TOOL_BUTTON", ":", "raise", "AttributeError", "(", "_wrong_prop", ".", "format", "(", "self", ".", "type", ")", ")", "return", "self", ".", "_libinput", "....
The button that triggered this event. For events that are not of type :attr:`~libinput.constant.EventType.TABLET_TOOL_BUTTON`, this property raises :exc:`AttributeError`. Returns: int: The button triggering this event.
[ "The", "button", "that", "triggered", "this", "event", "." ]
python
train
django-ses/django-ses
django_ses/utils.py
https://github.com/django-ses/django-ses/blob/2f0fd8e3fdc76d3512982c0bb8e2f6e93e09fa3c/django_ses/utils.py#L68-L115
def certificate(self): """ Retrieves the certificate used to sign the bounce message. TODO: Cache the certificate based on the cert URL so we don't have to retrieve it for each bounce message. *We would need to do it in a secure way so that the cert couldn't be overwritten in th...
[ "def", "certificate", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_certificate'", ")", ":", "cert_url", "=", "self", ".", "_get_cert_url", "(", ")", "# Only load certificates from a certain domain?", "# Without some kind of trusted domain check, a...
Retrieves the certificate used to sign the bounce message. TODO: Cache the certificate based on the cert URL so we don't have to retrieve it for each bounce message. *We would need to do it in a secure way so that the cert couldn't be overwritten in the cache*
[ "Retrieves", "the", "certificate", "used", "to", "sign", "the", "bounce", "message", "." ]
python
train
bwohlberg/sporco
sporco/admm/cbpdn.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/cbpdn.py#L2706-L2716
def eval_objfn(self): """Compute components of regularisation function as well as total contribution to objective function. """ g0v = self.obfn_g0(self.obfn_g0var()) g1v = self.obfn_g1(self.obfn_g1var()) rgr = sl.rfl2norm2(np.sqrt(self.GHGf * np.conj(self.Xf) * self.Xf),...
[ "def", "eval_objfn", "(", "self", ")", ":", "g0v", "=", "self", ".", "obfn_g0", "(", "self", ".", "obfn_g0var", "(", ")", ")", "g1v", "=", "self", ".", "obfn_g1", "(", "self", ".", "obfn_g1var", "(", ")", ")", "rgr", "=", "sl", ".", "rfl2norm2", ...
Compute components of regularisation function as well as total contribution to objective function.
[ "Compute", "components", "of", "regularisation", "function", "as", "well", "as", "total", "contribution", "to", "objective", "function", "." ]
python
train
saltstack/salt
salt/states/incron.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/incron.py#L48-L67
def _check_cron(user, path, mask, cmd): ''' Return the changes ''' arg_mask = mask.split(',') arg_mask.sort() lst = __salt__['incron.list_tab'](user) for cron in lst['crons']: if path == cron['path'] and cron['cmd'] == cmd: ...
[ "def", "_check_cron", "(", "user", ",", "path", ",", "mask", ",", "cmd", ")", ":", "arg_mask", "=", "mask", ".", "split", "(", "','", ")", "arg_mask", ".", "sort", "(", ")", "lst", "=", "__salt__", "[", "'incron.list_tab'", "]", "(", "user", ")", "...
Return the changes
[ "Return", "the", "changes" ]
python
train
SeattleTestbed/seash
pyreadline/console/ironpython_console.py
https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/ironpython_console.py#L106-L116
def pos(self, x=None, y=None): u'''Move or query the window cursor.''' if x is not None: System.Console.CursorLeft=x else: x = System.Console.CursorLeft if y is not None: System.Console.CursorTop=y else: y = System.Console....
[ "def", "pos", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ")", ":", "if", "x", "is", "not", "None", ":", "System", ".", "Console", ".", "CursorLeft", "=", "x", "else", ":", "x", "=", "System", ".", "Console", ".", "CursorLeft", "...
u'''Move or query the window cursor.
[ "u", "Move", "or", "query", "the", "window", "cursor", "." ]
python
train
glomex/gcdt
gcdt/cloudwatch_logs.py
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/cloudwatch_logs.py#L221-L233
def check_log_stream_exists(awsclient, log_group_name, log_stream_name): """Check :param log_group_name: log group name :param log_stream_name: log stream name :return: True / False """ lg = describe_log_group(awsclient, log_group_name) if lg and lg['logGroupName'] == log_group_name: ...
[ "def", "check_log_stream_exists", "(", "awsclient", ",", "log_group_name", ",", "log_stream_name", ")", ":", "lg", "=", "describe_log_group", "(", "awsclient", ",", "log_group_name", ")", "if", "lg", "and", "lg", "[", "'logGroupName'", "]", "==", "log_group_name",...
Check :param log_group_name: log group name :param log_stream_name: log stream name :return: True / False
[ "Check" ]
python
train
tanghaibao/jcvi
jcvi/assembly/hic.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/hic.py#L1078-L1096
def optimize_orientations(fwtour, clm, phase, cpus): """ Optimize the orientations of contigs by using heuristic flipping. """ # Prepare input files tour_contigs = clm.active_contigs tour = clm.tour oo = clm.oo print_tour(fwtour, tour, "FLIPALL{}".format(phase), tour_cont...
[ "def", "optimize_orientations", "(", "fwtour", ",", "clm", ",", "phase", ",", "cpus", ")", ":", "# Prepare input files", "tour_contigs", "=", "clm", ".", "active_contigs", "tour", "=", "clm", ".", "tour", "oo", "=", "clm", ".", "oo", "print_tour", "(", "fw...
Optimize the orientations of contigs by using heuristic flipping.
[ "Optimize", "the", "orientations", "of", "contigs", "by", "using", "heuristic", "flipping", "." ]
python
train
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/reftrackitemdata.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/reftrackitemdata.py#L261-L275
def reftrack_object_data(rt, role): """Return the reftrack for REFTRACK_OBJECT_ROLE :param rt: the :class:`jukeboxcore.reftrack.Reftrack` holds the data :type rt: :class:`jukeboxcore.reftrack.Reftrack` :param role: item data role :type role: QtCore.Qt.ItemDataRole :returns: data for the id ...
[ "def", "reftrack_object_data", "(", "rt", ",", "role", ")", ":", "if", "role", "==", "QtCore", ".", "Qt", ".", "DisplayRole", ":", "return", "str", "(", "rt", ")", "if", "role", "==", "REFTRACK_OBJECT_ROLE", ":", "return", "rt" ]
Return the reftrack for REFTRACK_OBJECT_ROLE :param rt: the :class:`jukeboxcore.reftrack.Reftrack` holds the data :type rt: :class:`jukeboxcore.reftrack.Reftrack` :param role: item data role :type role: QtCore.Qt.ItemDataRole :returns: data for the id :rtype: depending on the role :raises: ...
[ "Return", "the", "reftrack", "for", "REFTRACK_OBJECT_ROLE" ]
python
train
pyca/pyopenssl
src/OpenSSL/SSL.py
https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/src/OpenSSL/SSL.py#L2488-L2498
def request_ocsp(self): """ Called to request that the server sends stapled OCSP data, if available. If this is not called on the client side then the server will not send OCSP data. Should be used in conjunction with :meth:`Context.set_ocsp_client_callback`. """ ...
[ "def", "request_ocsp", "(", "self", ")", ":", "rc", "=", "_lib", ".", "SSL_set_tlsext_status_type", "(", "self", ".", "_ssl", ",", "_lib", ".", "TLSEXT_STATUSTYPE_ocsp", ")", "_openssl_assert", "(", "rc", "==", "1", ")" ]
Called to request that the server sends stapled OCSP data, if available. If this is not called on the client side then the server will not send OCSP data. Should be used in conjunction with :meth:`Context.set_ocsp_client_callback`.
[ "Called", "to", "request", "that", "the", "server", "sends", "stapled", "OCSP", "data", "if", "available", ".", "If", "this", "is", "not", "called", "on", "the", "client", "side", "then", "the", "server", "will", "not", "send", "OCSP", "data", ".", "Shou...
python
test
rackerlabs/fleece
fleece/xray.py
https://github.com/rackerlabs/fleece/blob/42d79dfa0777e99dbb09bc46105449a9be5dbaa9/fleece/xray.py#L436-L466
def extract_http_metadata(wrapped, instance, args, kwargs, return_value): """Provide HTTP request metadata for improved visualization. See documentation for this data structure: http://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-http """ response = r...
[ "def", "extract_http_metadata", "(", "wrapped", ",", "instance", ",", "args", ",", "kwargs", ",", "return_value", ")", ":", "response", "=", "return_value", "LOGGER", ".", "debug", "(", "'Extracting HTTP metadata'", ",", "args", "=", "args", ",", "kwargs", "="...
Provide HTTP request metadata for improved visualization. See documentation for this data structure: http://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-http
[ "Provide", "HTTP", "request", "metadata", "for", "improved", "visualization", "." ]
python
train
FutunnOpen/futuquant
futuquant/quote/quote_response_handler.py
https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/quote/quote_response_handler.py#L353-L360
def on_recv_rsp(self, rsp_pb): """receive response callback function""" ret_code, msg, data = OrderDetail.unpack_rsp(rsp_pb) if ret_code != RET_OK: return ret_code, msg else: return RET_OK, data
[ "def", "on_recv_rsp", "(", "self", ",", "rsp_pb", ")", ":", "ret_code", ",", "msg", ",", "data", "=", "OrderDetail", ".", "unpack_rsp", "(", "rsp_pb", ")", "if", "ret_code", "!=", "RET_OK", ":", "return", "ret_code", ",", "msg", "else", ":", "return", ...
receive response callback function
[ "receive", "response", "callback", "function" ]
python
train
NASA-AMMOS/AIT-Core
ait/core/db.py
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L467-L479
def _create_table(self, packet_defn): ''' Creates a database table for the given PacketDefinition Arguments packet_defn The :class:`ait.core.tlm.PacketDefinition` instance for which a table entry should be made. ''' cols = ('%s %s' % (defn.nam...
[ "def", "_create_table", "(", "self", ",", "packet_defn", ")", ":", "cols", "=", "(", "'%s %s'", "%", "(", "defn", ".", "name", ",", "self", ".", "_getTypename", "(", "defn", ")", ")", "for", "defn", "in", "packet_defn", ".", "fields", ")", "sql", "="...
Creates a database table for the given PacketDefinition Arguments packet_defn The :class:`ait.core.tlm.PacketDefinition` instance for which a table entry should be made.
[ "Creates", "a", "database", "table", "for", "the", "given", "PacketDefinition" ]
python
train
materialsproject/pymatgen
pymatgen/io/abinit/utils.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/utils.py#L296-L334
def symlink_abiext(self, inext, outext): """ Create a simbolic link (outext --> inext). The file names are implicitly given by the ABINIT file extension. Example: outdir.symlink_abiext('1WF', 'DDK') creates the link out_DDK that points to out_1WF Return: 0...
[ "def", "symlink_abiext", "(", "self", ",", "inext", ",", "outext", ")", ":", "infile", "=", "self", ".", "has_abiext", "(", "inext", ")", "if", "not", "infile", ":", "raise", "RuntimeError", "(", "'no file with extension %s in %s'", "%", "(", "inext", ",", ...
Create a simbolic link (outext --> inext). The file names are implicitly given by the ABINIT file extension. Example: outdir.symlink_abiext('1WF', 'DDK') creates the link out_DDK that points to out_1WF Return: 0 if success. Raise: RuntimeError
[ "Create", "a", "simbolic", "link", "(", "outext", "--", ">", "inext", ")", ".", "The", "file", "names", "are", "implicitly", "given", "by", "the", "ABINIT", "file", "extension", "." ]
python
train
Apitax/Apitax
apitax/api/controllers/scriptax_controller.py
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/scriptax_controller.py#L20-L44
def create_driver_script(driver, script_create=None): # noqa: E501 """Create a new script Create a new script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_create: The data needed to create this script :type script_create: dict | byt...
[ "def", "create_driver_script", "(", "driver", ",", "script_create", "=", "None", ")", ":", "# noqa: E501", "if", "connexion", ".", "request", ".", "is_json", ":", "script_create", "=", "ScriptCreate", ".", "from_dict", "(", "connexion", ".", "request", ".", "g...
Create a new script Create a new script # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :param script_create: The data needed to create this script :type script_create: dict | bytes :rtype: Response
[ "Create", "a", "new", "script" ]
python
train
edx/XBlock
xblock/runtime.py
https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/runtime.py#L1095-L1156
def querypath(self, block, path): """An XPath-like interface to `query`.""" class BadPath(Exception): """Bad path exception thrown when path cannot be found.""" pass results = self.query(block) ROOT, SEP, WORD, FINAL = six.moves.range(4) # pylint: di...
[ "def", "querypath", "(", "self", ",", "block", ",", "path", ")", ":", "class", "BadPath", "(", "Exception", ")", ":", "\"\"\"Bad path exception thrown when path cannot be found.\"\"\"", "pass", "results", "=", "self", ".", "query", "(", "block", ")", "ROOT", ","...
An XPath-like interface to `query`.
[ "An", "XPath", "-", "like", "interface", "to", "query", "." ]
python
train
scdoshi/django-bits
bits/gis.py
https://github.com/scdoshi/django-bits/blob/0a2f4fd9374d2a8acb8df9a7b83eebcf2782256f/bits/gis.py#L63-L76
def calculate_boundingbox(lng, lat, miles): """ Given a latitude, longitude and a distance in miles, calculate the co-ordinates of the bounding box 2*miles on long each side with the given co-ordinates at the center. """ latChange = change_in_latitude(miles) latSouth = lat - latChange l...
[ "def", "calculate_boundingbox", "(", "lng", ",", "lat", ",", "miles", ")", ":", "latChange", "=", "change_in_latitude", "(", "miles", ")", "latSouth", "=", "lat", "-", "latChange", "latNorth", "=", "lat", "+", "latChange", "lngChange", "=", "change_in_longitud...
Given a latitude, longitude and a distance in miles, calculate the co-ordinates of the bounding box 2*miles on long each side with the given co-ordinates at the center.
[ "Given", "a", "latitude", "longitude", "and", "a", "distance", "in", "miles", "calculate", "the", "co", "-", "ordinates", "of", "the", "bounding", "box", "2", "*", "miles", "on", "long", "each", "side", "with", "the", "given", "co", "-", "ordinates", "at...
python
train
ska-sa/purr
Purr/Editors.py
https://github.com/ska-sa/purr/blob/4c848768d0485d0f88b30850d0d5372221b21b66/Purr/Editors.py#L1208-L1216
def _startDPDrag(self): """Callback for item menu.""" dp = self._dp_menu_on if dp and dp.archived: drag = QDrag(self) mimedata = QMimeData() mimedata.setUrls([QUrl.fromLocalFile(dp.fullpath)]) drag.setMimeData(mimedata) drag.exec_(Qt.Co...
[ "def", "_startDPDrag", "(", "self", ")", ":", "dp", "=", "self", ".", "_dp_menu_on", "if", "dp", "and", "dp", ".", "archived", ":", "drag", "=", "QDrag", "(", "self", ")", "mimedata", "=", "QMimeData", "(", ")", "mimedata", ".", "setUrls", "(", "[", ...
Callback for item menu.
[ "Callback", "for", "item", "menu", "." ]
python
train
jtwhite79/pyemu
pyemu/mat/mat_handler.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/mat/mat_handler.py#L875-L890
def shape(self): """get the implied, 2D shape of self Returns ------- tuple : tuple length 2 tuple of ints """ if self.__x is not None: if self.isdiagonal: return (max(self.__x.shape), max(self.__x.shape)) if len(self....
[ "def", "shape", "(", "self", ")", ":", "if", "self", ".", "__x", "is", "not", "None", ":", "if", "self", ".", "isdiagonal", ":", "return", "(", "max", "(", "self", ".", "__x", ".", "shape", ")", ",", "max", "(", "self", ".", "__x", ".", "shape"...
get the implied, 2D shape of self Returns ------- tuple : tuple length 2 tuple of ints
[ "get", "the", "implied", "2D", "shape", "of", "self" ]
python
train
google/mobly
mobly/controllers/android_device_lib/event_dispatcher.py
https://github.com/google/mobly/blob/38ba2cf7d29a20e6a2fca1718eecb337df38db26/mobly/controllers/android_device_lib/event_dispatcher.py#L414-L427
def clear_events(self, event_name): """Clear all events of a particular name. Args: event_name: Name of the events to be popped. """ self.lock.acquire() try: q = self.get_event_q(event_name) q.queue.clear() except queue.Empty: ...
[ "def", "clear_events", "(", "self", ",", "event_name", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "try", ":", "q", "=", "self", ".", "get_event_q", "(", "event_name", ")", "q", ".", "queue", ".", "clear", "(", ")", "except", "queue", ...
Clear all events of a particular name. Args: event_name: Name of the events to be popped.
[ "Clear", "all", "events", "of", "a", "particular", "name", "." ]
python
train
wright-group/WrightTools
WrightTools/units.py
https://github.com/wright-group/WrightTools/blob/80d3ddd5074d8d5c1bc03fd5a0e0f10d4b424aeb/WrightTools/units.py#L194-L209
def kind(units): """Find the kind of given units. Parameters ---------- units : string The units of interest Returns ------- string The kind of the given units. If no match is found, returns None. """ for k, v in dicts.items(): if units in v.keys(): ...
[ "def", "kind", "(", "units", ")", ":", "for", "k", ",", "v", "in", "dicts", ".", "items", "(", ")", ":", "if", "units", "in", "v", ".", "keys", "(", ")", ":", "return", "k" ]
Find the kind of given units. Parameters ---------- units : string The units of interest Returns ------- string The kind of the given units. If no match is found, returns None.
[ "Find", "the", "kind", "of", "given", "units", "." ]
python
train
spdx/tools-python
spdx/parsers/lexers/tagvalue.py
https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/lexers/tagvalue.py#L167-L174
def t_LINE_OR_KEYWORD_VALUE(self, t): r':.+' t.value = t.value[1:].strip() if t.value in self.reserved.keys(): t.type = self.reserved[t.value] else: t.type = 'LINE' return t
[ "def", "t_LINE_OR_KEYWORD_VALUE", "(", "self", ",", "t", ")", ":", "t", ".", "value", "=", "t", ".", "value", "[", "1", ":", "]", ".", "strip", "(", ")", "if", "t", ".", "value", "in", "self", ".", "reserved", ".", "keys", "(", ")", ":", "t", ...
r':.+
[ "r", ":", ".", "+" ]
python
valid
SoCo/SoCo
dev_tools/analyse_ws.py
https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/dev_tools/analyse_ws.py#L382-L387
def finalize_content(self): """ Finalize the additons """ self.write_closed = True body = self.raw_body.decode(self.encoding) self._init_xml(body) self._form_output()
[ "def", "finalize_content", "(", "self", ")", ":", "self", ".", "write_closed", "=", "True", "body", "=", "self", ".", "raw_body", ".", "decode", "(", "self", ".", "encoding", ")", "self", ".", "_init_xml", "(", "body", ")", "self", ".", "_form_output", ...
Finalize the additons
[ "Finalize", "the", "additons" ]
python
train
StackStorm/pybind
pybind/nos/v6_0_2f/rbridge_id/interface/ve/ipv6/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/interface/ve/ipv6/__init__.py#L314-L335
def _set_ipv6_nd_ra(self, v, load=False): """ Setter method for ipv6_nd_ra, mapped from YANG variable /rbridge_id/interface/ve/ipv6/ipv6_nd_ra (container) If this variable is read-only (config: false) in the source YANG file, then _set_ipv6_nd_ra is considered as a private method. Backends looking t...
[ "def", "_set_ipv6_nd_ra", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "bas...
Setter method for ipv6_nd_ra, mapped from YANG variable /rbridge_id/interface/ve/ipv6/ipv6_nd_ra (container) If this variable is read-only (config: false) in the source YANG file, then _set_ipv6_nd_ra is considered as a private method. Backends looking to populate this variable should do so via calling ...
[ "Setter", "method", "for", "ipv6_nd_ra", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "interface", "/", "ve", "/", "ipv6", "/", "ipv6_nd_ra", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", ...
python
train
rbuffat/pyepw
pyepw/epw.py
https://github.com/rbuffat/pyepw/blob/373d4d3c8386c8d35789f086ac5f6018c2711745/pyepw/epw.py#L100-L122
def city(self, value=None): """Corresponds to IDD Field `city` Args: value (str): value for IDD Field `city` if `value` is None it will not be checked against the specification and is assumed to be a missing value Raises: ValueError: if `...
[ "def", "city", "(", "self", ",", "value", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "try", ":", "value", "=", "str", "(", "value", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'value {} need to be of type str '", "...
Corresponds to IDD Field `city` Args: value (str): value for IDD Field `city` if `value` is None it will not be checked against the specification and is assumed to be a missing value Raises: ValueError: if `value` is not a valid value
[ "Corresponds", "to", "IDD", "Field", "city" ]
python
train
ewiger/mlab
src/mlab/awmstools.py
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L674-L690
def weave(*iterables): r"""weave(seq1 [, seq2] [...]) -> iter([seq1[0], seq2[0] ...]). >>> list(weave([1,2,3], [4,5,6,'A'], [6,7,8, 'B', 'C'])) [1, 4, 6, 2, 5, 7, 3, 6, 8] Any iterable will work. The first exhausted iterable determines when to stop. FIXME rethink stopping semantics. >>> list...
[ "def", "weave", "(", "*", "iterables", ")", ":", "iterables", "=", "map", "(", "iter", ",", "iterables", ")", "while", "True", ":", "for", "it", "in", "iterables", ":", "yield", "it", ".", "next", "(", ")" ]
r"""weave(seq1 [, seq2] [...]) -> iter([seq1[0], seq2[0] ...]). >>> list(weave([1,2,3], [4,5,6,'A'], [6,7,8, 'B', 'C'])) [1, 4, 6, 2, 5, 7, 3, 6, 8] Any iterable will work. The first exhausted iterable determines when to stop. FIXME rethink stopping semantics. >>> list(weave(iter(('is','psu')), ...
[ "r", "weave", "(", "seq1", "[", "seq2", "]", "[", "...", "]", ")", "-", ">", "iter", "(", "[", "seq1", "[", "0", "]", "seq2", "[", "0", "]", "...", "]", ")", "." ]
python
train
aconrad/pycobertura
pycobertura/cobertura.py
https://github.com/aconrad/pycobertura/blob/26e472f1424f5cd499c42232dc5ee12e4042806f/pycobertura/cobertura.py#L282-L292
def has_better_coverage(self): """ Return `True` if coverage of has improved, `False` otherwise. This does not ensure that all changes have been covered. If this is what you want, use `CoberturaDiff.has_all_changes_covered()` instead. """ for filename in self.files(): ...
[ "def", "has_better_coverage", "(", "self", ")", ":", "for", "filename", "in", "self", ".", "files", "(", ")", ":", "if", "self", ".", "diff_total_misses", "(", "filename", ")", ">", "0", ":", "return", "False", "return", "True" ]
Return `True` if coverage of has improved, `False` otherwise. This does not ensure that all changes have been covered. If this is what you want, use `CoberturaDiff.has_all_changes_covered()` instead.
[ "Return", "True", "if", "coverage", "of", "has", "improved", "False", "otherwise", "." ]
python
train
jmurty/xml4h
xml4h/nodes.py
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L361-L376
def clone_node(self, node): """ Clone a node from another document to become a child of this node, by copying the node's data into this document but leaving the node untouched in the source document. The node to be cloned can be a :class:`Node` based on the same underlying XML li...
[ "def", "clone_node", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "xml4h", ".", "nodes", ".", "Node", ")", ":", "child_impl_node", "=", "node", ".", "impl_node", "else", ":", "child_impl_node", "=", "node", "# Assume it's a val...
Clone a node from another document to become a child of this node, by copying the node's data into this document but leaving the node untouched in the source document. The node to be cloned can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "...
[ "Clone", "a", "node", "from", "another", "document", "to", "become", "a", "child", "of", "this", "node", "by", "copying", "the", "node", "s", "data", "into", "this", "document", "but", "leaving", "the", "node", "untouched", "in", "the", "source", "document...
python
train
gabstopper/smc-python
smc/core/node.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/node.py#L362-L374
def lock_online(self, comment=None): """ Executes a Lock-Online operation on the specified node :param str comment: comment for audit :raises NodeCommandFailed: cannot lock online :return: None """ self.make_request( NodeCommandFailed, met...
[ "def", "lock_online", "(", "self", ",", "comment", "=", "None", ")", ":", "self", ".", "make_request", "(", "NodeCommandFailed", ",", "method", "=", "'update'", ",", "resource", "=", "'lock_online'", ",", "params", "=", "{", "'comment'", ":", "comment", "}...
Executes a Lock-Online operation on the specified node :param str comment: comment for audit :raises NodeCommandFailed: cannot lock online :return: None
[ "Executes", "a", "Lock", "-", "Online", "operation", "on", "the", "specified", "node" ]
python
train
zblz/naima
naima/radiative.py
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1783-L1799
def _calc_specpp_loE(self, Egamma): """ Delta-functional approximation for low energies Egamma < 0.1 TeV """ from scipy.integrate import quad Egamma = Egamma.to("TeV").value Epimin = Egamma + self._m_pi ** 2 / (4 * Egamma) result = ( 2 * ...
[ "def", "_calc_specpp_loE", "(", "self", ",", "Egamma", ")", ":", "from", "scipy", ".", "integrate", "import", "quad", "Egamma", "=", "Egamma", ".", "to", "(", "\"TeV\"", ")", ".", "value", "Epimin", "=", "Egamma", "+", "self", ".", "_m_pi", "**", "2", ...
Delta-functional approximation for low energies Egamma < 0.1 TeV
[ "Delta", "-", "functional", "approximation", "for", "low", "energies", "Egamma", "<", "0", ".", "1", "TeV" ]
python
train
googlefonts/ufo2ft
Lib/ufo2ft/__init__.py
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/__init__.py#L219-L316
def compileInterpolatableTTFs( ufos, preProcessorClass=TTFInterpolatablePreProcessor, outlineCompilerClass=OutlineTTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, cubicConversionError=None, reverseDirection=True, inplace=False...
[ "def", "compileInterpolatableTTFs", "(", "ufos", ",", "preProcessorClass", "=", "TTFInterpolatablePreProcessor", ",", "outlineCompilerClass", "=", "OutlineTTFCompiler", ",", "featureCompilerClass", "=", "None", ",", "featureWriters", "=", "None", ",", "glyphOrder", "=", ...
Create FontTools TrueType fonts from a list of UFOs with interpolatable outlines. Cubic curves are converted compatibly to quadratic curves using the Cu2Qu conversion algorithm. Return an iterator object that yields a TTFont instance for each UFO. *layerNames* refers to the layer names to use glyphs f...
[ "Create", "FontTools", "TrueType", "fonts", "from", "a", "list", "of", "UFOs", "with", "interpolatable", "outlines", ".", "Cubic", "curves", "are", "converted", "compatibly", "to", "quadratic", "curves", "using", "the", "Cu2Qu", "conversion", "algorithm", "." ]
python
train
thefab/tornadis
tornadis/pool.py
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L97-L110
def get_client_nowait(self): """Gets a Client object (not necessary connected). If max_size is reached, this method will return None (and won't block). Returns: A Client instance (not necessary connected) as result (or None). """ if self.__sem is not None: ...
[ "def", "get_client_nowait", "(", "self", ")", ":", "if", "self", ".", "__sem", "is", "not", "None", ":", "if", "self", ".", "__sem", ".", "_value", "==", "0", ":", "return", "None", "self", ".", "__sem", ".", "acquire", "(", ")", "_", ",", "client"...
Gets a Client object (not necessary connected). If max_size is reached, this method will return None (and won't block). Returns: A Client instance (not necessary connected) as result (or None).
[ "Gets", "a", "Client", "object", "(", "not", "necessary", "connected", ")", "." ]
python
train
spyder-ide/spyder
spyder/plugins/ipythonconsole/widgets/client.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L512-L555
def restart_kernel(self): """ Restart the associated kernel. Took this code from the qtconsole project Licensed under the BSD license """ sw = self.shellwidget if not running_under_pytest() and self.ask_before_restart: message = _('Are you ...
[ "def", "restart_kernel", "(", "self", ")", ":", "sw", "=", "self", ".", "shellwidget", "if", "not", "running_under_pytest", "(", ")", "and", "self", ".", "ask_before_restart", ":", "message", "=", "_", "(", "'Are you sure you want to restart the kernel?'", ")", ...
Restart the associated kernel. Took this code from the qtconsole project Licensed under the BSD license
[ "Restart", "the", "associated", "kernel", ".", "Took", "this", "code", "from", "the", "qtconsole", "project", "Licensed", "under", "the", "BSD", "license" ]
python
train
fitnr/convertdate
convertdate/julianday.py
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julianday.py#L16-L37
def to_datetime(jdc): '''Return a datetime for the input floating point Julian Day Count''' year, month, day = gregorian.from_jd(jdc) # in jdc: 0.0 = noon, 0.5 = midnight # the 0.5 changes it to 0.0 = midnight, 0.5 = noon frac = (jdc + 0.5) % 1 hours = int(24 * frac) mfrac = frac * 24 - h...
[ "def", "to_datetime", "(", "jdc", ")", ":", "year", ",", "month", ",", "day", "=", "gregorian", ".", "from_jd", "(", "jdc", ")", "# in jdc: 0.0 = noon, 0.5 = midnight", "# the 0.5 changes it to 0.0 = midnight, 0.5 = noon", "frac", "=", "(", "jdc", "+", "0.5", ")",...
Return a datetime for the input floating point Julian Day Count
[ "Return", "a", "datetime", "for", "the", "input", "floating", "point", "Julian", "Day", "Count" ]
python
train
MartinThoma/hwrt
hwrt/segmentation/segmentation.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/segmentation/segmentation.py#L285-L316
def filter_recordings(recordings): """Remove all recordings which have points without time. Parameters ---------- recordings : list of dicts Each dictionary has the keys 'data' and 'segmentation' Returns ------- list of dicts : Only recordings where all points have time valu...
[ "def", "filter_recordings", "(", "recordings", ")", ":", "new_recordings", "=", "[", "]", "for", "recording", "in", "recordings", ":", "recording", "[", "'data'", "]", "=", "json", ".", "loads", "(", "recording", "[", "'data'", "]", ")", "tmp", "=", "jso...
Remove all recordings which have points without time. Parameters ---------- recordings : list of dicts Each dictionary has the keys 'data' and 'segmentation' Returns ------- list of dicts : Only recordings where all points have time values.
[ "Remove", "all", "recordings", "which", "have", "points", "without", "time", ".", "Parameters", "----------", "recordings", ":", "list", "of", "dicts", "Each", "dictionary", "has", "the", "keys", "data", "and", "segmentation" ]
python
train
gitpython-developers/GitPython
git/refs/symbolic.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/refs/symbolic.py#L29-L34
def _git_dir(repo, path): """ Find the git dir that's appropriate for the path""" name = "%s" % (path,) if name in ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'index', 'logs']: return repo.git_dir return repo.common_dir
[ "def", "_git_dir", "(", "repo", ",", "path", ")", ":", "name", "=", "\"%s\"", "%", "(", "path", ",", ")", "if", "name", "in", "[", "'HEAD'", ",", "'ORIG_HEAD'", ",", "'FETCH_HEAD'", ",", "'index'", ",", "'logs'", "]", ":", "return", "repo", ".", "g...
Find the git dir that's appropriate for the path
[ "Find", "the", "git", "dir", "that", "s", "appropriate", "for", "the", "path" ]
python
train
uw-it-aca/uw-restclients-mailman
uw_mailman/course_list.py
https://github.com/uw-it-aca/uw-restclients-mailman/blob/ef077f2cc945871422fcd66391e82264e2384b2c/uw_mailman/course_list.py#L32-L38
def exists_course_list(curriculum_abbr, course_number, section_id, quarter, year, joint=False): """ Return True if the corresponding mailman list exists for the course """ return exists(get_course_list_name(curriculum_abbr, course_number, sec...
[ "def", "exists_course_list", "(", "curriculum_abbr", ",", "course_number", ",", "section_id", ",", "quarter", ",", "year", ",", "joint", "=", "False", ")", ":", "return", "exists", "(", "get_course_list_name", "(", "curriculum_abbr", ",", "course_number", ",", "...
Return True if the corresponding mailman list exists for the course
[ "Return", "True", "if", "the", "corresponding", "mailman", "list", "exists", "for", "the", "course" ]
python
train
edwardgeorge/virtualenv-clone
clonevirtualenv.py
https://github.com/edwardgeorge/virtualenv-clone/blob/434b12eb725ac1850b60f2bad8e848540e5596de/clonevirtualenv.py#L50-L64
def _virtualenv_sys(venv_path): "obtain version and path info from a virtualenv." executable = os.path.join(venv_path, env_bin_dir, 'python') # Must use "executable" as the first argument rather than as the # keyword argument "executable" to get correct value from sys.path p = subprocess.Popen([exec...
[ "def", "_virtualenv_sys", "(", "venv_path", ")", ":", "executable", "=", "os", ".", "path", ".", "join", "(", "venv_path", ",", "env_bin_dir", ",", "'python'", ")", "# Must use \"executable\" as the first argument rather than as the", "# keyword argument \"executable\" to g...
obtain version and path info from a virtualenv.
[ "obtain", "version", "and", "path", "info", "from", "a", "virtualenv", "." ]
python
train
klen/zeta-library
zetalibrary/utils.py
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/utils.py#L19-L29
def gen_files(path, prefix="_"): " Return file generator " if op.isdir(path): for name in listdir(path): fpath = op.join(path, name) if is_parsed_file(fpath): yield op.abspath(fpath) elif is_parsed_file(path): yield op.abspath(path)
[ "def", "gen_files", "(", "path", ",", "prefix", "=", "\"_\"", ")", ":", "if", "op", ".", "isdir", "(", "path", ")", ":", "for", "name", "in", "listdir", "(", "path", ")", ":", "fpath", "=", "op", ".", "join", "(", "path", ",", "name", ")", "if"...
Return file generator
[ "Return", "file", "generator" ]
python
train
niklasf/python-chess
chess/__init__.py
https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2865-L2870
def is_en_passant(self, move: Move) -> bool: """Checks if the given pseudo-legal move is an en passant capture.""" return (self.ep_square == move.to_square and bool(self.pawns & BB_SQUARES[move.from_square]) and abs(move.to_square - move.from_square) in [7, 9] and ...
[ "def", "is_en_passant", "(", "self", ",", "move", ":", "Move", ")", "->", "bool", ":", "return", "(", "self", ".", "ep_square", "==", "move", ".", "to_square", "and", "bool", "(", "self", ".", "pawns", "&", "BB_SQUARES", "[", "move", ".", "from_square"...
Checks if the given pseudo-legal move is an en passant capture.
[ "Checks", "if", "the", "given", "pseudo", "-", "legal", "move", "is", "an", "en", "passant", "capture", "." ]
python
train
10gen/mongo-orchestration
mongo_orchestration/process.py
https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L94-L98
def release_port(self, port): """release port""" if port in self.__closed: self.__closed.remove(port) self.__ports.add(port)
[ "def", "release_port", "(", "self", ",", "port", ")", ":", "if", "port", "in", "self", ".", "__closed", ":", "self", ".", "__closed", ".", "remove", "(", "port", ")", "self", ".", "__ports", ".", "add", "(", "port", ")" ]
release port
[ "release", "port" ]
python
train
globocom/GloboNetworkAPI-client-python
networkapiclient/Equipamento.py
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Equipamento.py#L671-L700
def remover_grupo(self, id_equipamento, id_grupo): """Remove a associação de um equipamento com um grupo de equipamento. :param id_equipamento: Identificador do equipamento. :param id_grupo: Identificador do grupo de equipamento. :return: None :raise EquipamentoGrupoNaoExisteE...
[ "def", "remover_grupo", "(", "self", ",", "id_equipamento", ",", "id_grupo", ")", ":", "if", "not", "is_valid_int_param", "(", "id_equipamento", ")", ":", "raise", "InvalidParameterError", "(", "u'O identificador do equipamento é inválido ou não foi informado.')", "", "if...
Remove a associação de um equipamento com um grupo de equipamento. :param id_equipamento: Identificador do equipamento. :param id_grupo: Identificador do grupo de equipamento. :return: None :raise EquipamentoGrupoNaoExisteError: Associação entre grupo e equipamento não cadastrada. ...
[ "Remove", "a", "associação", "de", "um", "equipamento", "com", "um", "grupo", "de", "equipamento", "." ]
python
train
soravux/scoop
scoop/_types.py
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_types.py#L411-L416
def sendResult(self, future): """Send back results to broker for distribution to parent task.""" # Greenlets cannot be pickled future.greenlet = None assert future._ended(), "The results are not valid" self.socket.sendResult(future)
[ "def", "sendResult", "(", "self", ",", "future", ")", ":", "# Greenlets cannot be pickled", "future", ".", "greenlet", "=", "None", "assert", "future", ".", "_ended", "(", ")", ",", "\"The results are not valid\"", "self", ".", "socket", ".", "sendResult", "(", ...
Send back results to broker for distribution to parent task.
[ "Send", "back", "results", "to", "broker", "for", "distribution", "to", "parent", "task", "." ]
python
train
Spinmob/spinmob
_functions.py
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L326-L343
def decompose_covariance(c): """ This decomposes a covariance matrix into an error vector and a correlation matrix """ # make it a kickass copy of the original c = _n.array(c) # first get the error vector e = [] for n in range(0, len(c[0])): e.append(_n.sqrt(c[n][n])) # now cycle ...
[ "def", "decompose_covariance", "(", "c", ")", ":", "# make it a kickass copy of the original", "c", "=", "_n", ".", "array", "(", "c", ")", "# first get the error vector", "e", "=", "[", "]", "for", "n", "in", "range", "(", "0", ",", "len", "(", "c", "[", ...
This decomposes a covariance matrix into an error vector and a correlation matrix
[ "This", "decomposes", "a", "covariance", "matrix", "into", "an", "error", "vector", "and", "a", "correlation", "matrix" ]
python
train
qiniu/python-sdk
qiniu/services/compute/app.py
https://github.com/qiniu/python-sdk/blob/a69fbef4e3e6ea1ebe09f4610a5b18bb2c17de59/qiniu/services/compute/app.py#L43-L53
def get_qcos_client(self, app_uri): """获得资源管理客户端 缓存,但不是线程安全的 """ client = self.qcos_clients.get(app_uri) if (client is None): client = self.create_qcos_client(app_uri) self.qcos_clients[app_uri] = client return client
[ "def", "get_qcos_client", "(", "self", ",", "app_uri", ")", ":", "client", "=", "self", ".", "qcos_clients", ".", "get", "(", "app_uri", ")", "if", "(", "client", "is", "None", ")", ":", "client", "=", "self", ".", "create_qcos_client", "(", "app_uri", ...
获得资源管理客户端 缓存,但不是线程安全的
[ "获得资源管理客户端", "缓存,但不是线程安全的" ]
python
train
pulseenergy/vacation
vacation/transactions.py
https://github.com/pulseenergy/vacation/blob/23c6122590852a5e55d84d366143469af6602839/vacation/transactions.py#L123-L146
def _parse_transaction_entry(entry): """ Validate & parse a transaction into (date, action, value) tuple. """ parts = entry.split() date_string = parts[0] try: date = datetime.datetime.strptime(date_string[:-1], '%Y-%m-%d').date() except ValueError: raise ValueError('Invalid date in...
[ "def", "_parse_transaction_entry", "(", "entry", ")", ":", "parts", "=", "entry", ".", "split", "(", ")", "date_string", "=", "parts", "[", "0", "]", "try", ":", "date", "=", "datetime", ".", "datetime", ".", "strptime", "(", "date_string", "[", ":", "...
Validate & parse a transaction into (date, action, value) tuple.
[ "Validate", "&", "parse", "a", "transaction", "into", "(", "date", "action", "value", ")", "tuple", "." ]
python
train
senaite/senaite.core
bika/lims/controlpanel/bika_worksheettemplates.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/controlpanel/bika_worksheettemplates.py#L115-L144
def folderitem(self, obj, item, index): """Service triggered each time an item is iterated in folderitems. The use of this service prevents the extra-loops in child objects. :obj: the instance of the class to be foldered :item: dict containing the properties of the object to be used by ...
[ "def", "folderitem", "(", "self", ",", "obj", ",", "item", ",", "index", ")", ":", "item", "[", "\"Description\"", "]", "=", "obj", ".", "Description", "(", ")", "item", "[", "\"replace\"", "]", "[", "\"Title\"", "]", "=", "get_link", "(", "item", "[...
Service triggered each time an item is iterated in folderitems. The use of this service prevents the extra-loops in child objects. :obj: the instance of the class to be foldered :item: dict containing the properties of the object to be used by the template :index: current ind...
[ "Service", "triggered", "each", "time", "an", "item", "is", "iterated", "in", "folderitems", ".", "The", "use", "of", "this", "service", "prevents", "the", "extra", "-", "loops", "in", "child", "objects", ".", ":", "obj", ":", "the", "instance", "of", "t...
python
train
mozilla/libnfldap
libnfldap.py
https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L155-L162
def template(self): """ Create a rules file in iptables-restore format """ s = Template(self._IPTABLES_TEMPLATE) return s.substitute(filtertable='\n'.join(self.filters), rawtable='\n'.join(self.raw), mangletable='\n'.join(self.mangle), nattable='\n'.join(self.nat), date=datetime.today(...
[ "def", "template", "(", "self", ")", ":", "s", "=", "Template", "(", "self", ".", "_IPTABLES_TEMPLATE", ")", "return", "s", ".", "substitute", "(", "filtertable", "=", "'\\n'", ".", "join", "(", "self", ".", "filters", ")", ",", "rawtable", "=", "'\\n'...
Create a rules file in iptables-restore format
[ "Create", "a", "rules", "file", "in", "iptables", "-", "restore", "format" ]
python
train
uogbuji/versa
tools/py/driver/mongo.py
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/driver/mongo.py#L74-L78
def copy(self, contents=True): '''Create a copy of this model, optionally without contents (i.e. just configuration)''' cp = connection(collection=self._db_coll, baseiri=self._baseiri) if contents: cp.add_many(self._relationships) return cp
[ "def", "copy", "(", "self", ",", "contents", "=", "True", ")", ":", "cp", "=", "connection", "(", "collection", "=", "self", ".", "_db_coll", ",", "baseiri", "=", "self", ".", "_baseiri", ")", "if", "contents", ":", "cp", ".", "add_many", "(", "self"...
Create a copy of this model, optionally without contents (i.e. just configuration)
[ "Create", "a", "copy", "of", "this", "model", "optionally", "without", "contents", "(", "i", ".", "e", ".", "just", "configuration", ")" ]
python
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/sessions_client.py
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/sessions_client.py#L201-L299
def detect_intent(self, session, query_input, query_params=None, output_audio_config=None, input_audio=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=go...
[ "def", "detect_intent", "(", "self", ",", "session", ",", "query_input", ",", "query_params", "=", "None", ",", "output_audio_config", "=", "None", ",", "input_audio", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method",...
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries. Example: >>> import dialogflow_v...
[ "Processes", "a", "natural", "language", "query", "and", "returns", "structured", "actionable", "data", "as", "a", "result", ".", "This", "method", "is", "not", "idempotent", "because", "it", "may", "cause", "contexts", "and", "session", "entity", "types", "to...
python
train
tornadoweb/tornado
tornado/queues.py
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/queues.py#L225-L252
def get(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[_T]: """Remove and return an item from the queue. Returns an awaitable which resolves once an item is available, or raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denoting a ti...
[ "def", "get", "(", "self", ",", "timeout", ":", "Union", "[", "float", ",", "datetime", ".", "timedelta", "]", "=", "None", ")", "->", "Awaitable", "[", "_T", "]", ":", "future", "=", "Future", "(", ")", "# type: Future[_T]", "try", ":", "future", "....
Remove and return an item from the queue. Returns an awaitable which resolves once an item is available, or raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denoting a time (on the same scale as `tornado.ioloop.IOLoop.time`, normally `time.time`), or a ...
[ "Remove", "and", "return", "an", "item", "from", "the", "queue", "." ]
python
train
google/grr
grr/server/grr_response_server/stats_server.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/stats_server.py#L38-L52
def Start(self): """Start HTTPServer.""" try: self._http_server = http_server.HTTPServer(("", self.port), StatsServerHandler) except socket.error as e: if e.errno == errno.EADDRINUSE: raise base_stats_server.PortInUseError(self.port) ...
[ "def", "Start", "(", "self", ")", ":", "try", ":", "self", ".", "_http_server", "=", "http_server", ".", "HTTPServer", "(", "(", "\"\"", ",", "self", ".", "port", ")", ",", "StatsServerHandler", ")", "except", "socket", ".", "error", "as", "e", ":", ...
Start HTTPServer.
[ "Start", "HTTPServer", "." ]
python
train
apple/turicreate
src/unity/python/turicreate/data_structures/sarray.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sarray.py#L2338-L2375
def datetime_to_str(self,format="%Y-%m-%dT%H:%M:%S%ZP"): """ Create a new SArray with all the values cast to str. The string format is specified by the 'format' parameter. Parameters ---------- format : str The format to output the string. Default format is "...
[ "def", "datetime_to_str", "(", "self", ",", "format", "=", "\"%Y-%m-%dT%H:%M:%S%ZP\"", ")", ":", "if", "(", "self", ".", "dtype", "!=", "datetime", ".", "datetime", ")", ":", "raise", "TypeError", "(", "\"datetime_to_str expects SArray of datetime as input SArray\"", ...
Create a new SArray with all the values cast to str. The string format is specified by the 'format' parameter. Parameters ---------- format : str The format to output the string. Default format is "%Y-%m-%dT%H:%M:%S%ZP". Returns ------- out : SArray[...
[ "Create", "a", "new", "SArray", "with", "all", "the", "values", "cast", "to", "str", ".", "The", "string", "format", "is", "specified", "by", "the", "format", "parameter", "." ]
python
train