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
geophysics-ubonn/reda
lib/reda/containers/ERT.py
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L371-L388
def delete_measurements(self, row_or_rows): """Delete one or more measurements by index of the DataFrame. Resets the DataFrame index. Parameters ---------- row_or_rows : int or list of ints Row numbers (starting with zero) of the data DataFrame (ert.data) ...
[ "def", "delete_measurements", "(", "self", ",", "row_or_rows", ")", ":", "self", ".", "data", ".", "drop", "(", "self", ".", "data", ".", "index", "[", "row_or_rows", "]", ",", "inplace", "=", "True", ")", "self", ".", "data", "=", "self", ".", "data...
Delete one or more measurements by index of the DataFrame. Resets the DataFrame index. Parameters ---------- row_or_rows : int or list of ints Row numbers (starting with zero) of the data DataFrame (ert.data) to delete Returns ------- N...
[ "Delete", "one", "or", "more", "measurements", "by", "index", "of", "the", "DataFrame", "." ]
python
train
wearpants/fakesleep
fakesleep.py
https://github.com/wearpants/fakesleep/blob/b2b8f422a0838fff50143ec00c1bbb7974e92a83/fakesleep.py#L53-L59
def monkey_restore(): """restore real versions. Inverse of `monkey_patch`""" for k, v in originals.items(): setattr(time_mod, k, v) global epoch epoch = None
[ "def", "monkey_restore", "(", ")", ":", "for", "k", ",", "v", "in", "originals", ".", "items", "(", ")", ":", "setattr", "(", "time_mod", ",", "k", ",", "v", ")", "global", "epoch", "epoch", "=", "None" ]
restore real versions. Inverse of `monkey_patch`
[ "restore", "real", "versions", ".", "Inverse", "of", "monkey_patch" ]
python
train
iotile/coretools
scripts/release.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/scripts/release.py#L76-L87
def check_version(component, expected_version): """Make sure the package version in setuptools matches what we expect it to be""" comp = comp_names[component] compath = os.path.realpath(os.path.abspath(comp.path)) sys.path.insert(0, compath) import version if version.version != expected_vers...
[ "def", "check_version", "(", "component", ",", "expected_version", ")", ":", "comp", "=", "comp_names", "[", "component", "]", "compath", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "abspath", "(", "comp", ".", "path", ")", ")...
Make sure the package version in setuptools matches what we expect it to be
[ "Make", "sure", "the", "package", "version", "in", "setuptools", "matches", "what", "we", "expect", "it", "to", "be" ]
python
train
guaix-ucm/pyemir
emirdrp/processing/wavecal/median_slitlets_rectified.py
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/median_slitlets_rectified.py#L42-L167
def median_slitlets_rectified( input_image, mode=0, minimum_slitlet_width_mm=EMIR_MINIMUM_SLITLET_WIDTH_MM, maximum_slitlet_width_mm=EMIR_MAXIMUM_SLITLET_WIDTH_MM, debugplot=0 ): """Compute median spectrum for each slitlet. Parameters ---------- input_image :...
[ "def", "median_slitlets_rectified", "(", "input_image", ",", "mode", "=", "0", ",", "minimum_slitlet_width_mm", "=", "EMIR_MINIMUM_SLITLET_WIDTH_MM", ",", "maximum_slitlet_width_mm", "=", "EMIR_MAXIMUM_SLITLET_WIDTH_MM", ",", "debugplot", "=", "0", ")", ":", "image_header...
Compute median spectrum for each slitlet. Parameters ---------- input_image : HDUList object Input 2D image. mode : int Indicate desired result: 0 : image with the same size as the input image, with the median spectrum of each slitlet spanning all the spectra ...
[ "Compute", "median", "spectrum", "for", "each", "slitlet", "." ]
python
train
ethereum/py-evm
eth/db/header.py
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/db/header.py#L120-L127
def get_canonical_block_header_by_number(self, block_number: BlockNumber) -> BlockHeader: """ Returns the block header with the given number in the canonical chain. Raises BlockNotFound if there's no block header with the given number in the canonical chain. """ return s...
[ "def", "get_canonical_block_header_by_number", "(", "self", ",", "block_number", ":", "BlockNumber", ")", "->", "BlockHeader", ":", "return", "self", ".", "_get_canonical_block_header_by_number", "(", "self", ".", "db", ",", "block_number", ")" ]
Returns the block header with the given number in the canonical chain. Raises BlockNotFound if there's no block header with the given number in the canonical chain.
[ "Returns", "the", "block", "header", "with", "the", "given", "number", "in", "the", "canonical", "chain", "." ]
python
train
biolink/ontobio
ontobio/sparql/skos.py
https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/ontobio/sparql/skos.py#L51-L105
def process_rdfgraph(self, rg, ont=None): """ Transform a skos terminology expressed in an rdf graph into an Ontology object Arguments --------- rg: rdflib.Graph graph object Returns ------- Ontology """ # TODO: ontology metad...
[ "def", "process_rdfgraph", "(", "self", ",", "rg", ",", "ont", "=", "None", ")", ":", "# TODO: ontology metadata", "if", "ont", "is", "None", ":", "ont", "=", "Ontology", "(", ")", "subjs", "=", "list", "(", "rg", ".", "subjects", "(", "RDF", ".", "t...
Transform a skos terminology expressed in an rdf graph into an Ontology object Arguments --------- rg: rdflib.Graph graph object Returns ------- Ontology
[ "Transform", "a", "skos", "terminology", "expressed", "in", "an", "rdf", "graph", "into", "an", "Ontology", "object" ]
python
train
agile-geoscience/striplog
striplog/striplog.py
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1902-L1939
def merge_neighbours(self, strict=True): """ Makes a new striplog in which matching neighbours (for which the components are the same) are unioned. That is, they are replaced by a new Interval with the same top as the uppermost and the same bottom as the lowermost. Args ...
[ "def", "merge_neighbours", "(", "self", ",", "strict", "=", "True", ")", ":", "new_strip", "=", "[", "self", "[", "0", "]", ".", "copy", "(", ")", "]", "for", "lower", "in", "self", "[", "1", ":", "]", ":", "# Determine if touching.", "touching", "="...
Makes a new striplog in which matching neighbours (for which the components are the same) are unioned. That is, they are replaced by a new Interval with the same top as the uppermost and the same bottom as the lowermost. Args strict (bool): If True, then all of the component...
[ "Makes", "a", "new", "striplog", "in", "which", "matching", "neighbours", "(", "for", "which", "the", "components", "are", "the", "same", ")", "are", "unioned", ".", "That", "is", "they", "are", "replaced", "by", "a", "new", "Interval", "with", "the", "s...
python
test
tensorflow/tensorboard
tensorboard/plugins/hparams/hparams_plugin_loader.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/hparams/hparams_plugin_loader.py#L30-L46
def load(self, context): """Returns the plugin, if possible. Args: context: The TBContext flags. Returns: A HParamsPlugin instance or None if it couldn't be loaded. """ try: # pylint: disable=g-import-not-at-top,unused-import import tensorflow except ImportError: ...
[ "def", "load", "(", "self", ",", "context", ")", ":", "try", ":", "# pylint: disable=g-import-not-at-top,unused-import", "import", "tensorflow", "except", "ImportError", ":", "return", "# pylint: disable=g-import-not-at-top", "from", "tensorboard", ".", "plugins", ".", ...
Returns the plugin, if possible. Args: context: The TBContext flags. Returns: A HParamsPlugin instance or None if it couldn't be loaded.
[ "Returns", "the", "plugin", "if", "possible", "." ]
python
train
JasonKessler/scattertext
scattertext/TermDocMatrixWithoutCategories.py
https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/TermDocMatrixWithoutCategories.py#L423-L431
def term_doc_lists(self): ''' Returns ------- dict ''' doc_ids = self._X.transpose().tolil().rows terms = self._term_idx_store.values() return dict(zip(terms, doc_ids))
[ "def", "term_doc_lists", "(", "self", ")", ":", "doc_ids", "=", "self", ".", "_X", ".", "transpose", "(", ")", ".", "tolil", "(", ")", ".", "rows", "terms", "=", "self", ".", "_term_idx_store", ".", "values", "(", ")", "return", "dict", "(", "zip", ...
Returns ------- dict
[ "Returns", "-------", "dict" ]
python
train
klen/zeta-library
zetalibrary/scss/__init__.py
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1352-L1371
def _do_each(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name): """ Implements @each """ var, _, name = name.partition('in') name = self.calculate(name, rule[CONTEXT], rule[OPTIONS], rule) if name: name ...
[ "def", "_do_each", "(", "self", ",", "rule", ",", "p_selectors", ",", "p_parents", ",", "p_children", ",", "scope", ",", "media", ",", "c_lineno", ",", "c_property", ",", "c_codestr", ",", "code", ",", "name", ")", ":", "var", ",", "_", ",", "name", ...
Implements @each
[ "Implements" ]
python
train
spyder-ide/spyder
spyder/app/mainwindow.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2600-L2654
def render_issue(self, description='', traceback=''): """Render issue before sending it to Github""" # Get component versions versions = get_versions() # Get git revision for development version revision = '' if versions['revision']: revision = versio...
[ "def", "render_issue", "(", "self", ",", "description", "=", "''", ",", "traceback", "=", "''", ")", ":", "# Get component versions\r", "versions", "=", "get_versions", "(", ")", "# Get git revision for development version\r", "revision", "=", "''", "if", "versions"...
Render issue before sending it to Github
[ "Render", "issue", "before", "sending", "it", "to", "Github" ]
python
train
mrcagney/gtfstk
gtfstk/stops.py
https://github.com/mrcagney/gtfstk/blob/c91494e6fefc02523889655a0dc92d1c0eee8d03/gtfstk/stops.py#L905-L961
def map_stops( feed: "Feed", stop_ids: List[str], stop_style: Dict = STOP_STYLE ): """ Return a Folium map showing the given stops. Parameters ---------- feed : Feed stop_ids : list IDs of trips in ``feed.stops`` stop_style: dictionary Folium CircleMarker parameters to u...
[ "def", "map_stops", "(", "feed", ":", "\"Feed\"", ",", "stop_ids", ":", "List", "[", "str", "]", ",", "stop_style", ":", "Dict", "=", "STOP_STYLE", ")", ":", "import", "folium", "as", "fl", "# Initialize map", "my_map", "=", "fl", ".", "Map", "(", "til...
Return a Folium map showing the given stops. Parameters ---------- feed : Feed stop_ids : list IDs of trips in ``feed.stops`` stop_style: dictionary Folium CircleMarker parameters to use for styling stops. Returns ------- dictionary A Folium Map depicting the st...
[ "Return", "a", "Folium", "map", "showing", "the", "given", "stops", "." ]
python
train
krukas/Trionyx
trionyx/trionyx/apps.py
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/apps.py#L47-L54
def auto_load_app_modules(self, modules): """Auto load app modules""" for app in apps.get_app_configs(): for module in modules: try: import_module('{}.{}'.format(app.module.__package__, module)) except ImportError: pass
[ "def", "auto_load_app_modules", "(", "self", ",", "modules", ")", ":", "for", "app", "in", "apps", ".", "get_app_configs", "(", ")", ":", "for", "module", "in", "modules", ":", "try", ":", "import_module", "(", "'{}.{}'", ".", "format", "(", "app", ".", ...
Auto load app modules
[ "Auto", "load", "app", "modules" ]
python
train
AlecAivazis/graphql-over-kafka
nautilus/conventions/api.py
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/api.py#L15-L25
def crud_mutation_name(action, model): """ This function returns the name of a mutation that performs the specified crud action on the given model service """ model_string = get_model_string(model) # make sure the mutation name is correctly camelcases model_string = model_string[0].u...
[ "def", "crud_mutation_name", "(", "action", ",", "model", ")", ":", "model_string", "=", "get_model_string", "(", "model", ")", "# make sure the mutation name is correctly camelcases", "model_string", "=", "model_string", "[", "0", "]", ".", "upper", "(", ")", "+", ...
This function returns the name of a mutation that performs the specified crud action on the given model service
[ "This", "function", "returns", "the", "name", "of", "a", "mutation", "that", "performs", "the", "specified", "crud", "action", "on", "the", "given", "model", "service" ]
python
train
CartoDB/carto-python
carto/auth.py
https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/auth.py#L128-L154
def send(self, relative_path, http_method, **requests_args): """ Makes an API-key-authorized request :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kwargs to be sent to requests :type relative_path: str ...
[ "def", "send", "(", "self", ",", "relative_path", ",", "http_method", ",", "*", "*", "requests_args", ")", ":", "try", ":", "http_method", ",", "requests_args", "=", "self", ".", "prepare_send", "(", "http_method", ",", "*", "*", "requests_args", ")", "res...
Makes an API-key-authorized request :param relative_path: URL path relative to self.base_url :param http_method: HTTP method :param requests_args: kwargs to be sent to requests :type relative_path: str :type http_method: str :type requests_args: kwargs :return: ...
[ "Makes", "an", "API", "-", "key", "-", "authorized", "request" ]
python
train
wadda/gps3
examples/human.py
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/examples/human.py#L39-L57
def add_args(): """Adds commandline arguments and formatted Help""" parser = argparse.ArgumentParser() parser.add_argument('-host', action='store', dest='host', default='127.0.0.1', help='DEFAULT "127.0.0.1"') parser.add_argument('-port', action='store', dest='port', default='2947', help='DEFAULT 2947'...
[ "def", "add_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-host'", ",", "action", "=", "'store'", ",", "dest", "=", "'host'", ",", "default", "=", "'127.0.0.1'", ",", "help", "=", ...
Adds commandline arguments and formatted Help
[ "Adds", "commandline", "arguments", "and", "formatted", "Help" ]
python
train
greenbender/pynntp
nntp/nntp.py
https://github.com/greenbender/pynntp/blob/991a76331cdf5d8f9dbf5b18f6e29adc80749a2f/nntp/nntp.py#L692-L708
def newnews(self, pattern, timestamp): """NEWNEWS command. Retrieves a list of message-ids for articles created since the specified timestamp for newsgroups with names that match the given pattern. See newnews_gen() for more details. See <http://tools.ietf.org/html/rfc3977#sect...
[ "def", "newnews", "(", "self", ",", "pattern", ",", "timestamp", ")", ":", "return", "[", "x", "for", "x", "in", "self", ".", "newnews_gen", "(", "pattern", ",", "timestamp", ")", "]" ]
NEWNEWS command. Retrieves a list of message-ids for articles created since the specified timestamp for newsgroups with names that match the given pattern. See newnews_gen() for more details. See <http://tools.ietf.org/html/rfc3977#section-7.4> Args: pattern: Glob ...
[ "NEWNEWS", "command", "." ]
python
test
HazyResearch/fonduer
src/fonduer/utils/utils_udf.py
https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/utils/utils_udf.py#L224-L280
def drop_all_keys(session, key_table, candidate_classes): """Bulk drop annotation keys for all the candidate_classes in the table. Rather than directly dropping the keys, this removes the candidate_classes specified for the given keys only. If all candidate_classes are removed for a key, the key is dro...
[ "def", "drop_all_keys", "(", "session", ",", "key_table", ",", "candidate_classes", ")", ":", "if", "not", "candidate_classes", ":", "return", "candidate_classes", "=", "set", "(", "[", "c", ".", "__tablename__", "for", "c", "in", "candidate_classes", "]", ")"...
Bulk drop annotation keys for all the candidate_classes in the table. Rather than directly dropping the keys, this removes the candidate_classes specified for the given keys only. If all candidate_classes are removed for a key, the key is dropped. :param key_table: The sqlalchemy class to insert into....
[ "Bulk", "drop", "annotation", "keys", "for", "all", "the", "candidate_classes", "in", "the", "table", "." ]
python
train
pyroscope/pyrocore
src/pyrocore/scripts/base.py
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/scripts/base.py#L353-L371
def get_options(self): """ Get program options. """ super(ScriptBaseWithConfig, self).get_options() self.config_dir = os.path.abspath(os.path.expanduser(self.options.config_dir or os.environ.get('PYRO_CONFIG_DIR', None) or self.CONFIG_DIR_DEFAULT)) load_c...
[ "def", "get_options", "(", "self", ")", ":", "super", "(", "ScriptBaseWithConfig", ",", "self", ")", ".", "get_options", "(", ")", "self", ".", "config_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "self"...
Get program options.
[ "Get", "program", "options", "." ]
python
train
OSSOS/MOP
src/jjk/preproc/MOPplot.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L43-L133
def load_abgfiles(dir=None): """Load the targets from a file""" import ephem,string if dir is None: import tkFileDialog try: dir=tkFileDialog.askdirectory() except: return if dir is None: return None from glob import glob files=glob(dir+"/*.abg")...
[ "def", "load_abgfiles", "(", "dir", "=", "None", ")", ":", "import", "ephem", ",", "string", "if", "dir", "is", "None", ":", "import", "tkFileDialog", "try", ":", "dir", "=", "tkFileDialog", ".", "askdirectory", "(", ")", "except", ":", "return", "if", ...
Load the targets from a file
[ "Load", "the", "targets", "from", "a", "file" ]
python
train
devassistant/devassistant
devassistant/gui/run_window.py
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L192-L212
def delete_event(self, widget, event, data=None): """ Event cancels the project creation """ if not self.close_win: if self.thread.isAlive(): dlg = self.gui_helper.create_message_dialog("Do you want to cancel project creation?", ...
[ "def", "delete_event", "(", "self", ",", "widget", ",", "event", ",", "data", "=", "None", ")", ":", "if", "not", "self", ".", "close_win", ":", "if", "self", ".", "thread", ".", "isAlive", "(", ")", ":", "dlg", "=", "self", ".", "gui_helper", ".",...
Event cancels the project creation
[ "Event", "cancels", "the", "project", "creation" ]
python
train
mapnik/Cascadenik
cascadenik/compile.py
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L146-L169
def output_path(self, path_name): """ Modify a path so it fits expectations. Avoid returning relative paths that start with '../' and possibly return relative paths when output and cache directories match. """ # make sure it is a valid posix format ...
[ "def", "output_path", "(", "self", ",", "path_name", ")", ":", "# make sure it is a valid posix format", "path", "=", "to_posix", "(", "path_name", ")", "assert", "(", "path", "==", "path_name", ")", ",", "\"path_name passed to output_path must be in posix format\"", "i...
Modify a path so it fits expectations. Avoid returning relative paths that start with '../' and possibly return relative paths when output and cache directories match.
[ "Modify", "a", "path", "so", "it", "fits", "expectations", ".", "Avoid", "returning", "relative", "paths", "that", "start", "with", "..", "/", "and", "possibly", "return", "relative", "paths", "when", "output", "and", "cache", "directories", "match", "." ]
python
train
dhermes/bezier
src/bezier/_helpers.py
https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_helpers.py#L294-L384
def _simple_convex_hull(points): r"""Compute the convex hull for a set of points. .. _wikibooks: https://en.wikibooks.org/wiki/Algorithm_Implementation/\ Geometry/Convex_hull/Monotone_chain This uses Andrew's monotone chain convex hull algorithm and this code used a `wikibooks`_ imp...
[ "def", "_simple_convex_hull", "(", "points", ")", ":", "# NOTE: There is no corresponding \"enable\", but the disable only applies", "# in this lexical scope.", "# pylint: disable=too-many-branches", "if", "points", ".", "size", "==", "0", ":", "return", "points", "# First,...
r"""Compute the convex hull for a set of points. .. _wikibooks: https://en.wikibooks.org/wiki/Algorithm_Implementation/\ Geometry/Convex_hull/Monotone_chain This uses Andrew's monotone chain convex hull algorithm and this code used a `wikibooks`_ implementation as motivation. tion. The ...
[ "r", "Compute", "the", "convex", "hull", "for", "a", "set", "of", "points", "." ]
python
train
dcramer/django-ratings
djangoratings/fields.py
https://github.com/dcramer/django-ratings/blob/4d00dedc920a4e32d650dc12d5f480c51fc6216c/djangoratings/fields.py#L82-L88
def get_real_rating(self): """get_rating() Returns the unmodified average rating.""" if not (self.votes and self.score): return 0 return float(self.score)/self.votes
[ "def", "get_real_rating", "(", "self", ")", ":", "if", "not", "(", "self", ".", "votes", "and", "self", ".", "score", ")", ":", "return", "0", "return", "float", "(", "self", ".", "score", ")", "/", "self", ".", "votes" ]
get_rating() Returns the unmodified average rating.
[ "get_rating", "()", "Returns", "the", "unmodified", "average", "rating", "." ]
python
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L467-L493
def get_global_register_attributes(self, register_attribute, do_sort=True, **kwargs): """Calculating register numbers from register names. Usage: get_global_register_attributes("attribute_name", name = [regname_1, regname_2, ...], addresses = 2) Receives: attribute name to be returned, dict...
[ "def", "get_global_register_attributes", "(", "self", ",", "register_attribute", ",", "do_sort", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# speed up of the most often used keyword name\r", "try", ":", "names", "=", "iterable", "(", "kwargs", ".", "pop", "(...
Calculating register numbers from register names. Usage: get_global_register_attributes("attribute_name", name = [regname_1, regname_2, ...], addresses = 2) Receives: attribute name to be returned, dictionaries (kwargs) of register attributes and values for making cuts Returns: list of attr...
[ "Calculating", "register", "numbers", "from", "register", "names", ".", "Usage", ":", "get_global_register_attributes", "(", "attribute_name", "name", "=", "[", "regname_1", "regname_2", "...", "]", "addresses", "=", "2", ")", "Receives", ":", "attribute", "name",...
python
train
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/futures.py
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/futures.py#L634-L640
def _run_queued_callbacks(self): ''' run the init/quued calback when the trasnfer is initiated on apsera ''' for callback in self._queued_callbacks: try: callback() except Exception as ex: logger.error("Exception: %s" % str(ex))
[ "def", "_run_queued_callbacks", "(", "self", ")", ":", "for", "callback", "in", "self", ".", "_queued_callbacks", ":", "try", ":", "callback", "(", ")", "except", "Exception", "as", "ex", ":", "logger", ".", "error", "(", "\"Exception: %s\"", "%", "str", "...
run the init/quued calback when the trasnfer is initiated on apsera
[ "run", "the", "init", "/", "quued", "calback", "when", "the", "trasnfer", "is", "initiated", "on", "apsera" ]
python
train
CivicSpleen/ambry
ambry/etl/pipeline.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/etl/pipeline.py#L486-L496
def report_progress(self): """ This function can be called from a higher level to report progress. It is usually called from an alarm signal handler which is installed just before starting an operation: :return: Tuple: (process description, #records, #total records, #rate) """ ...
[ "def", "report_progress", "(", "self", ")", ":", "from", "time", "import", "time", "# rows, rate = pl.sink.report_progress()", "return", "(", "self", ".", "i", ",", "round", "(", "float", "(", "self", ".", "i", ")", "/", "float", "(", "time", "(", ")", "...
This function can be called from a higher level to report progress. It is usually called from an alarm signal handler which is installed just before starting an operation: :return: Tuple: (process description, #records, #total records, #rate)
[ "This", "function", "can", "be", "called", "from", "a", "higher", "level", "to", "report", "progress", ".", "It", "is", "usually", "called", "from", "an", "alarm", "signal", "handler", "which", "is", "installed", "just", "before", "starting", "an", "operatio...
python
train
Esri/ArcREST
src/arcrest/ags/_gpobjects.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_gpobjects.py#L513-L525
def fromJSON(value): """loads the GP object from a JSON string """ j = json.loads(value) v = GPBoolean() if "defaultValue" in j: v.value = j['defaultValue'] else: v.value = j['value'] if 'paramName' in j: v.paramName = j['paramName'] ...
[ "def", "fromJSON", "(", "value", ")", ":", "j", "=", "json", ".", "loads", "(", "value", ")", "v", "=", "GPBoolean", "(", ")", "if", "\"defaultValue\"", "in", "j", ":", "v", ".", "value", "=", "j", "[", "'defaultValue'", "]", "else", ":", "v", "....
loads the GP object from a JSON string
[ "loads", "the", "GP", "object", "from", "a", "JSON", "string" ]
python
train
hobson/pug-dj
pug/dj/crawler/views.py
https://github.com/hobson/pug-dj/blob/55678b08755a55366ce18e7d3b8ea8fa4491ab04/pug/dj/crawler/views.py#L16-L24
def stop(self, spider_name=None): """Stop the named running spider, or the first spider found, if spider_name is None""" if spider_name is None: spider_name = self.spider_name else: self.spider_name = spider_name if self.spider_name is None: self.spide...
[ "def", "stop", "(", "self", ",", "spider_name", "=", "None", ")", ":", "if", "spider_name", "is", "None", ":", "spider_name", "=", "self", ".", "spider_name", "else", ":", "self", ".", "spider_name", "=", "spider_name", "if", "self", ".", "spider_name", ...
Stop the named running spider, or the first spider found, if spider_name is None
[ "Stop", "the", "named", "running", "spider", "or", "the", "first", "spider", "found", "if", "spider_name", "is", "None" ]
python
train
ahtn/python-easyhid
easyhid/easyhid.py
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L329-L350
def description(self): """ Get a string describing the HID descriptor. """ return \ """HIDDevice: {} | {:x}:{:x} | {} | {} | {} release_number: {} usage_page: {} usage: {} interface_number: {}\ """.format(self.path, self.vendor_id, self.product_i...
[ "def", "description", "(", "self", ")", ":", "return", "\"\"\"HIDDevice:\n {} | {:x}:{:x} | {} | {} | {}\n release_number: {}\n usage_page: {}\n usage: {}\n interface_number: {}\\\n\"\"\"", ".", "format", "(", "self", ".", "path", ",", "self", ".", "vendor_id", ","...
Get a string describing the HID descriptor.
[ "Get", "a", "string", "describing", "the", "HID", "descriptor", "." ]
python
train
dixudx/rtcclient
rtcclient/template.py
https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/template.py#L196-L344
def getTemplate(self, copied_from, template_name=None, template_folder=None, keep=False, encoding="UTF-8"): """Get template from some to-be-copied :class:`rtcclient.workitem.Workitem` The resulting XML document is returned as a :class:`string`, but if `template_name`...
[ "def", "getTemplate", "(", "self", ",", "copied_from", ",", "template_name", "=", "None", ",", "template_folder", "=", "None", ",", "keep", "=", "False", ",", "encoding", "=", "\"UTF-8\"", ")", ":", "try", ":", "if", "isinstance", "(", "copied_from", ",", ...
Get template from some to-be-copied :class:`rtcclient.workitem.Workitem` The resulting XML document is returned as a :class:`string`, but if `template_name` (a string value) is specified, it is written there instead. :param copied_from: the to-be-copied :class:`rtcc...
[ "Get", "template", "from", "some", "to", "-", "be", "-", "copied", ":", "class", ":", "rtcclient", ".", "workitem", ".", "Workitem" ]
python
train
uw-it-aca/uw-restclients-grad
uw_grad/petition.py
https://github.com/uw-it-aca/uw-restclients-grad/blob/ca06ed2f24f3683314a5690f6078e97d37fc8e52/uw_grad/petition.py#L20-L39
def _process_json(data): """ return a list of GradPetition objects. """ requests = [] for item in data: petition = GradPetition() petition.description = item.get('description') petition.submit_date = parse_datetime(item.get('submitDate')) petition.decision_date = pars...
[ "def", "_process_json", "(", "data", ")", ":", "requests", "=", "[", "]", "for", "item", "in", "data", ":", "petition", "=", "GradPetition", "(", ")", "petition", ".", "description", "=", "item", ".", "get", "(", "'description'", ")", "petition", ".", ...
return a list of GradPetition objects.
[ "return", "a", "list", "of", "GradPetition", "objects", "." ]
python
train
sk-/git-lint
gitlint/git.py
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/git.py#L109-L140
def modified_lines(filename, extra_data, commit=None): """Returns the lines that have been modifed for this file. Args: filename: the file to check. extra_data: is the extra_data returned by modified_files. Additionally, a value of None means that the file was not modified. commit: th...
[ "def", "modified_lines", "(", "filename", ",", "extra_data", ",", "commit", "=", "None", ")", ":", "if", "extra_data", "is", "None", ":", "return", "[", "]", "if", "extra_data", "not", "in", "(", "'M '", ",", "' M'", ",", "'MM'", ")", ":", "return", ...
Returns the lines that have been modifed for this file. Args: filename: the file to check. extra_data: is the extra_data returned by modified_files. Additionally, a value of None means that the file was not modified. commit: the complete sha1 (40 chars) of the commit. Note that specifying...
[ "Returns", "the", "lines", "that", "have", "been", "modifed", "for", "this", "file", "." ]
python
train
thombashi/pathvalidate
pathvalidate/_file.py
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_file.py#L477-L515
def validate_filepath(file_path, platform=None, min_len=1, max_len=None): """Verifying whether the ``file_path`` is a valid file path or not. Args: file_path (str): File path to validate. platform (str, optional): .. include:: platform.txt min_len (int, optional)...
[ "def", "validate_filepath", "(", "file_path", ",", "platform", "=", "None", ",", "min_len", "=", "1", ",", "max_len", "=", "None", ")", ":", "FilePathSanitizer", "(", "platform", "=", "platform", ",", "min_len", "=", "min_len", ",", "max_len", "=", "max_le...
Verifying whether the ``file_path`` is a valid file path or not. Args: file_path (str): File path to validate. platform (str, optional): .. include:: platform.txt min_len (int, optional): Minimum length of the ``file_path``. The value must be greater or e...
[ "Verifying", "whether", "the", "file_path", "is", "a", "valid", "file", "path", "or", "not", "." ]
python
train
mobolic/facebook-sdk
facebook/__init__.py
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L218-L222
def delete_request(self, user_id, request_id): """Deletes the Request with the given ID for the given user.""" return self.request( "{0}_{1}".format(request_id, user_id), method="DELETE" )
[ "def", "delete_request", "(", "self", ",", "user_id", ",", "request_id", ")", ":", "return", "self", ".", "request", "(", "\"{0}_{1}\"", ".", "format", "(", "request_id", ",", "user_id", ")", ",", "method", "=", "\"DELETE\"", ")" ]
Deletes the Request with the given ID for the given user.
[ "Deletes", "the", "Request", "with", "the", "given", "ID", "for", "the", "given", "user", "." ]
python
train
m0n5t3r/gstats
examples/generate_traffic.py
https://github.com/m0n5t3r/gstats/blob/ae600d309ae8a159079fe1d6e6fa1c9097125f5b/examples/generate_traffic.py#L16-L24
def run(self): """ generate <nreq> requests taking a random amount of time between 0 and 0.5 seconds """ for i in xrange(self.nreq): req = '%s_%s' % (self.ident, i) pre_request(None, req) sleep(random() / 2) post_request(None, req)
[ "def", "run", "(", "self", ")", ":", "for", "i", "in", "xrange", "(", "self", ".", "nreq", ")", ":", "req", "=", "'%s_%s'", "%", "(", "self", ".", "ident", ",", "i", ")", "pre_request", "(", "None", ",", "req", ")", "sleep", "(", "random", "(",...
generate <nreq> requests taking a random amount of time between 0 and 0.5 seconds
[ "generate", "<nreq", ">", "requests", "taking", "a", "random", "amount", "of", "time", "between", "0", "and", "0", ".", "5", "seconds" ]
python
train
DLR-RM/RAFCON
source/rafcon/gui/controllers/state_editor/semantic_data_editor.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/state_editor/semantic_data_editor.py#L170-L174
def add_action_callback(self, key_value, modifier_mask, a_dict=False): """Callback method for add action""" if react_to_event(self.view, self.tree_view, event=(key_value, modifier_mask)) and self.active_entry_widget is None: self.on_add(None, a_dict) return True
[ "def", "add_action_callback", "(", "self", ",", "key_value", ",", "modifier_mask", ",", "a_dict", "=", "False", ")", ":", "if", "react_to_event", "(", "self", ".", "view", ",", "self", ".", "tree_view", ",", "event", "=", "(", "key_value", ",", "modifier_m...
Callback method for add action
[ "Callback", "method", "for", "add", "action" ]
python
train
Devoxin/Lavalink.py
lavalink/WebSocket.py
https://github.com/Devoxin/Lavalink.py/blob/63f55c3d726d24c4cfd3674d3cd6aab6f5be110d/lavalink/WebSocket.py#L36-L73
async def connect(self): """ Establishes a connection to the Lavalink server. """ await self._lavalink.bot.wait_until_ready() if self._ws and self._ws.open: log.debug('WebSocket still open, closing...') await self._ws.close() user_id = self._lavalink.bot...
[ "async", "def", "connect", "(", "self", ")", ":", "await", "self", ".", "_lavalink", ".", "bot", ".", "wait_until_ready", "(", ")", "if", "self", ".", "_ws", "and", "self", ".", "_ws", ".", "open", ":", "log", ".", "debug", "(", "'WebSocket still open,...
Establishes a connection to the Lavalink server.
[ "Establishes", "a", "connection", "to", "the", "Lavalink", "server", "." ]
python
valid
tensorflow/mesh
mesh_tensorflow/ops.py
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L225-L245
def tensor_dimension_to_mesh_axis(self, tensor_dimension, mesh_shape): """Mesh axis associated with tensor dimension (or None). Args: tensor_dimension: Dimension. mesh_shape: Shape. Returns: Integer or None. Raises: ValueError: If one Tensor dimension maps to two mesh dimensio...
[ "def", "tensor_dimension_to_mesh_axis", "(", "self", ",", "tensor_dimension", ",", "mesh_shape", ")", ":", "val", "=", "[", "i", "for", "i", ",", "mesh_dimension", "in", "enumerate", "(", "mesh_shape", ")", "if", "(", "tensor_dimension", ".", "name", ",", "m...
Mesh axis associated with tensor dimension (or None). Args: tensor_dimension: Dimension. mesh_shape: Shape. Returns: Integer or None. Raises: ValueError: If one Tensor dimension maps to two mesh dimensions.
[ "Mesh", "axis", "associated", "with", "tensor", "dimension", "(", "or", "None", ")", "." ]
python
train
datastax/python-driver
cassandra/cqlengine/models.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cqlengine/models.py#L448-L488
def _construct_instance(cls, values): """ method used to construct instances from query results this is where polymorphic deserialization occurs """ # we're going to take the values, which is from the DB as a dict # and translate that into our local fields # the d...
[ "def", "_construct_instance", "(", "cls", ",", "values", ")", ":", "# we're going to take the values, which is from the DB as a dict", "# and translate that into our local fields", "# the db_map is a db_field -> model field map", "if", "cls", ".", "_db_map", ":", "values", "=", "...
method used to construct instances from query results this is where polymorphic deserialization occurs
[ "method", "used", "to", "construct", "instances", "from", "query", "results", "this", "is", "where", "polymorphic", "deserialization", "occurs" ]
python
train
inspirehep/refextract
refextract/references/text.py
https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/text.py#L91-L142
def get_reference_lines(docbody, ref_sect_start_line, ref_sect_end_line, ref_sect_title, ref_line_marker_ptn, title_marker_same_line): """After the reference section of a document has been identif...
[ "def", "get_reference_lines", "(", "docbody", ",", "ref_sect_start_line", ",", "ref_sect_end_line", ",", "ref_sect_title", ",", "ref_line_marker_ptn", ",", "title_marker_same_line", ")", ":", "start_idx", "=", "ref_sect_start_line", "if", "title_marker_same_line", ":", "#...
After the reference section of a document has been identified, and the first and last lines of the reference section have been recorded, this function is called to take the reference lines out of the document body. The document's reference lines are returned in a list of strings whereby each...
[ "After", "the", "reference", "section", "of", "a", "document", "has", "been", "identified", "and", "the", "first", "and", "last", "lines", "of", "the", "reference", "section", "have", "been", "recorded", "this", "function", "is", "called", "to", "take", "the...
python
train
wummel/patool
patoolib/programs/star.py
https://github.com/wummel/patool/blob/d7e64d9fd60faaa4b3f824bd97c43ce59b185c40/patoolib/programs/star.py#L26-L31
def list_tar (archive, compression, cmd, verbosity, interactive): """List a TAR archive.""" cmdlist = [cmd, '-n'] add_star_opts(cmdlist, compression, verbosity) cmdlist.append("file=%s" % archive) return cmdlist
[ "def", "list_tar", "(", "archive", ",", "compression", ",", "cmd", ",", "verbosity", ",", "interactive", ")", ":", "cmdlist", "=", "[", "cmd", ",", "'-n'", "]", "add_star_opts", "(", "cmdlist", ",", "compression", ",", "verbosity", ")", "cmdlist", ".", "...
List a TAR archive.
[ "List", "a", "TAR", "archive", "." ]
python
train
craffel/mir_eval
mir_eval/chord.py
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L759-L804
def thirds_inv(reference_labels, estimated_labels): """Score chords along root, third, & bass relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est....
[ "def", "thirds_inv", "(", "reference_labels", ",", "estimated_labels", ")", ":", "validate", "(", "reference_labels", ",", "estimated_labels", ")", "ref_roots", ",", "ref_semitones", ",", "ref_bass", "=", "encode_many", "(", "reference_labels", ",", "False", ")", ...
Score chords along root, third, & bass relationships. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab') >>> est_intervals, est_labels = mir_eval.util.adj...
[ "Score", "chords", "along", "root", "third", "&", "bass", "relationships", "." ]
python
train
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L455-L493
def plot_pseudosections(self, column, filename=None, return_fig=False): """Create a multi-plot with one pseudosection for each frequency. Parameters ---------- column : string which column to plot filename : None|string output filename. If set to None, do...
[ "def", "plot_pseudosections", "(", "self", ",", "column", ",", "filename", "=", "None", ",", "return_fig", "=", "False", ")", ":", "assert", "column", "in", "self", ".", "data", ".", "columns", "g", "=", "self", ".", "data", ".", "groupby", "(", "'freq...
Create a multi-plot with one pseudosection for each frequency. Parameters ---------- column : string which column to plot filename : None|string output filename. If set to None, do not write to file. Default: None return_fig : bool ...
[ "Create", "a", "multi", "-", "plot", "with", "one", "pseudosection", "for", "each", "frequency", "." ]
python
train
stefankoegl/kdtree
kdtree.py
https://github.com/stefankoegl/kdtree/blob/587edc7056d7735177ad56a84ad5abccdea91693/kdtree.py#L644-L677
def visualize(tree, max_level=100, node_width=10, left_padding=5): """ Prints the tree to stdout """ height = min(max_level, tree.height()-1) max_width = pow(2, height) per_level = 1 in_level = 0 level = 0 for node in level_order(tree, include_all=True): if in_level == 0: ...
[ "def", "visualize", "(", "tree", ",", "max_level", "=", "100", ",", "node_width", "=", "10", ",", "left_padding", "=", "5", ")", ":", "height", "=", "min", "(", "max_level", ",", "tree", ".", "height", "(", ")", "-", "1", ")", "max_width", "=", "po...
Prints the tree to stdout
[ "Prints", "the", "tree", "to", "stdout" ]
python
train
nicolargo/glances
glances/plugins/glances_ports.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L75-L98
def update(self): """Update the ports list.""" if self.input_method == 'local': # Only refresh: # * if there is not other scanning thread # * every refresh seconds (define in the configuration file) if self._thread is None: thread_is_runnin...
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "input_method", "==", "'local'", ":", "# Only refresh:", "# * if there is not other scanning thread", "# * every refresh seconds (define in the configuration file)", "if", "self", ".", "_thread", "is", "None", ":"...
Update the ports list.
[ "Update", "the", "ports", "list", "." ]
python
train
data-8/datascience
datascience/util.py
https://github.com/data-8/datascience/blob/4cee38266903ca169cea4a53b8cc39502d85c464/datascience/util.py#L203-L244
def minimize(f, start=None, smooth=False, log=None, array=False, **vargs): """Minimize a function f of one or more arguments. Args: f: A function that takes numbers and returns a number start: A starting value or list of starting values smooth: Whether to assume that f is smooth and u...
[ "def", "minimize", "(", "f", ",", "start", "=", "None", ",", "smooth", "=", "False", ",", "log", "=", "None", ",", "array", "=", "False", ",", "*", "*", "vargs", ")", ":", "if", "start", "is", "None", ":", "assert", "not", "array", ",", "\"Please...
Minimize a function f of one or more arguments. Args: f: A function that takes numbers and returns a number start: A starting value or list of starting values smooth: Whether to assume that f is smooth and use first-order info log: Logging function called on the result of optimiz...
[ "Minimize", "a", "function", "f", "of", "one", "or", "more", "arguments", "." ]
python
train
laysakura/relshell
relshell/daemon_shelloperator.py
https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/daemon_shelloperator.py#L82-L118
def run(self, in_batches): """Run shell operator synchronously to eat `in_batches` :param in_batches: `tuple` of batches to process """ if len(in_batches) != len(self._batcmd.batch_to_file_s): BaseShellOperator._rm_process_input_tmpfiles(self._batcmd.batch_to_file_s) # [tod...
[ "def", "run", "(", "self", ",", "in_batches", ")", ":", "if", "len", "(", "in_batches", ")", "!=", "len", "(", "self", ".", "_batcmd", ".", "batch_to_file_s", ")", ":", "BaseShellOperator", ".", "_rm_process_input_tmpfiles", "(", "self", ".", "_batcmd", "....
Run shell operator synchronously to eat `in_batches` :param in_batches: `tuple` of batches to process
[ "Run", "shell", "operator", "synchronously", "to", "eat", "in_batches" ]
python
train
DLR-RM/RAFCON
source/rafcon/gui/controllers/state_machine_tree.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/state_machine_tree.py#L509-L528
def _handle_double_click(self, event): """ Double click with left mouse button focuses the state and toggles the collapse status""" if event.get_button()[1] == 1: # Left mouse button path_info = self.tree_view.get_path_at_pos(int(event.x), int(event.y)) if path_info: # Valid en...
[ "def", "_handle_double_click", "(", "self", ",", "event", ")", ":", "if", "event", ".", "get_button", "(", ")", "[", "1", "]", "==", "1", ":", "# Left mouse button", "path_info", "=", "self", ".", "tree_view", ".", "get_path_at_pos", "(", "int", "(", "ev...
Double click with left mouse button focuses the state and toggles the collapse status
[ "Double", "click", "with", "left", "mouse", "button", "focuses", "the", "state", "and", "toggles", "the", "collapse", "status" ]
python
train
scour-project/scour
scour/scour.py
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L831-L854
def unprotected_ids(doc, options): u"""Returns a list of unprotected IDs within the document doc.""" identifiedElements = findElementsWithId(doc.documentElement) if not (options.protect_ids_noninkscape or options.protect_ids_list or options.protect_ids_prefix): return identif...
[ "def", "unprotected_ids", "(", "doc", ",", "options", ")", ":", "identifiedElements", "=", "findElementsWithId", "(", "doc", ".", "documentElement", ")", "if", "not", "(", "options", ".", "protect_ids_noninkscape", "or", "options", ".", "protect_ids_list", "or", ...
u"""Returns a list of unprotected IDs within the document doc.
[ "u", "Returns", "a", "list", "of", "unprotected", "IDs", "within", "the", "document", "doc", "." ]
python
train
dls-controls/annotypes
annotypes/_serializable.py
https://github.com/dls-controls/annotypes/blob/31ab68a0367bb70ebd9898e8b9fa9405423465bd/annotypes/_serializable.py#L125-L138
def to_dict(self, dict_cls=FrozenOrderedDict): # type: (Type[dict]) -> Dict[str, Any] """Create a dictionary representation of object attributes Returns: OrderedDict serialised version of self """ pairs = tuple((k, serialize_object(getattr(self, k), dict_cls)) ...
[ "def", "to_dict", "(", "self", ",", "dict_cls", "=", "FrozenOrderedDict", ")", ":", "# type: (Type[dict]) -> Dict[str, Any]", "pairs", "=", "tuple", "(", "(", "k", ",", "serialize_object", "(", "getattr", "(", "self", ",", "k", ")", ",", "dict_cls", ")", ")"...
Create a dictionary representation of object attributes Returns: OrderedDict serialised version of self
[ "Create", "a", "dictionary", "representation", "of", "object", "attributes" ]
python
train
matthiask/django-cte-forest
cte_forest/models.py
https://github.com/matthiask/django-cte-forest/blob/7bff29d69eddfcf214e9cf61647c91d28655619c/cte_forest/models.py#L880-L910
def prepare_delete_monarchy(self, node, position=None, save=True): """ Prepares a given :class:`CTENode` `node` for deletion, by executing the :const:`DELETE_METHOD_MONARCHY` semantics. Descendant nodes, if present, will be moved; in this case the optional `position` can be a...
[ "def", "prepare_delete_monarchy", "(", "self", ",", "node", ",", "position", "=", "None", ",", "save", "=", "True", ")", ":", "# We are going to iterate all children, even though the first child is", "# treated in a special way, because the query iterator may be custom, so", "# w...
Prepares a given :class:`CTENode` `node` for deletion, by executing the :const:`DELETE_METHOD_MONARCHY` semantics. Descendant nodes, if present, will be moved; in this case the optional `position` can be a ``callable`` which is invoked prior to each move operation (see :m...
[ "Prepares", "a", "given", ":", "class", ":", "CTENode", "node", "for", "deletion", "by", "executing", "the", ":", "const", ":", "DELETE_METHOD_MONARCHY", "semantics", ".", "Descendant", "nodes", "if", "present", "will", "be", "moved", ";", "in", "this", "cas...
python
train
adafruit/Adafruit_CircuitPython_framebuf
adafruit_framebuf.py
https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/b9f62c4b71efa963150f9c5a0284b61c7add9d02/adafruit_framebuf.py#L249-L275
def line(self, x_0, y_0, x_1, y_1, color): # pylint: disable=too-many-arguments """Bresenham's line algorithm""" d_x = abs(x_1 - x_0) d_y = abs(y_1 - y_0) x, y = x_0, y_0 s_x = -1 if x_0 > x_1 else 1 s_y = -1 if y_0 > y_1 else 1 if d_x > d_y: e...
[ "def", "line", "(", "self", ",", "x_0", ",", "y_0", ",", "x_1", ",", "y_1", ",", "color", ")", ":", "# pylint: disable=too-many-arguments", "d_x", "=", "abs", "(", "x_1", "-", "x_0", ")", "d_y", "=", "abs", "(", "y_1", "-", "y_0", ")", "x", ",", ...
Bresenham's line algorithm
[ "Bresenham", "s", "line", "algorithm" ]
python
train
openstack/proliantutils
proliantutils/redfish/resources/system/storage/array_controller.py
https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L151-L158
def array_controller_by_model(self, model): """Returns array controller instance by model :returns Instance of array controller """ for member in self.get_members(): if member.model == model: return member
[ "def", "array_controller_by_model", "(", "self", ",", "model", ")", ":", "for", "member", "in", "self", ".", "get_members", "(", ")", ":", "if", "member", ".", "model", "==", "model", ":", "return", "member" ]
Returns array controller instance by model :returns Instance of array controller
[ "Returns", "array", "controller", "instance", "by", "model" ]
python
train
vmware/pyvmomi
pyVmomi/VmomiSupport.py
https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVmomi/VmomiSupport.py#L379-L395
def explode(self, obj): """ Determine if the object should be exploded. """ if obj in self._done: return False result = False for item in self._explode: if hasattr(item, '_moId'): # If it has a _moId it is an instance if obj._moId =...
[ "def", "explode", "(", "self", ",", "obj", ")", ":", "if", "obj", "in", "self", ".", "_done", ":", "return", "False", "result", "=", "False", "for", "item", "in", "self", ".", "_explode", ":", "if", "hasattr", "(", "item", ",", "'_moId'", ")", ":",...
Determine if the object should be exploded.
[ "Determine", "if", "the", "object", "should", "be", "exploded", "." ]
python
train
quantumlib/Cirq
dev_tools/incremental_coverage.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/incremental_coverage.py#L115-L162
def get_incremental_uncovered_lines(abs_path: str, base_commit: str, actual_commit: Optional[str] ) -> List[Tuple[int, str, str]]: """ Uses git diff and the annotation files created by `pytest --cov-r...
[ "def", "get_incremental_uncovered_lines", "(", "abs_path", ":", "str", ",", "base_commit", ":", "str", ",", "actual_commit", ":", "Optional", "[", "str", "]", ")", "->", "List", "[", "Tuple", "[", "int", ",", "str", ",", "str", "]", "]", ":", "# Deleted ...
Uses git diff and the annotation files created by `pytest --cov-report annotate` to find touched but uncovered lines in the given file. Args: abs_path: The path of a file to look for uncovered lines in. base_commit: Old state to diff against. actual_commit: Current state. Use None t...
[ "Uses", "git", "diff", "and", "the", "annotation", "files", "created", "by", "pytest", "--", "cov", "-", "report", "annotate", "to", "find", "touched", "but", "uncovered", "lines", "in", "the", "given", "file", "." ]
python
train
nerandell/cauldron
cauldron/redis_cache.py
https://github.com/nerandell/cauldron/blob/d363bac763781bb2da18debfa0fdd4be28288b92/cauldron/redis_cache.py#L9-L16
def connect(self, host, port, minsize=5, maxsize=10, loop=asyncio.get_event_loop()): """ Setup a connection pool :param host: Redis host :param port: Redis port :param loop: Event loop """ self._pool = yield from aioredis.create_pool((host, port), minsize=minsize,...
[ "def", "connect", "(", "self", ",", "host", ",", "port", ",", "minsize", "=", "5", ",", "maxsize", "=", "10", ",", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", ")", ":", "self", ".", "_pool", "=", "yield", "from", "aioredis", ".", "crea...
Setup a connection pool :param host: Redis host :param port: Redis port :param loop: Event loop
[ "Setup", "a", "connection", "pool", ":", "param", "host", ":", "Redis", "host", ":", "param", "port", ":", "Redis", "port", ":", "param", "loop", ":", "Event", "loop" ]
python
valid
pyamg/pyamg
pyamg/vis/vis_coarse.py
https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/vis/vis_coarse.py#L20-L147
def vis_aggregate_groups(Verts, E2V, Agg, mesh_type, output='vtk', fname='output.vtu'): """Coarse grid visualization of aggregate groups. Create .vtu files for use in Paraview or display with Matplotlib. Parameters ---------- Verts : {array} coordinate array (N x D...
[ "def", "vis_aggregate_groups", "(", "Verts", ",", "E2V", ",", "Agg", ",", "mesh_type", ",", "output", "=", "'vtk'", ",", "fname", "=", "'output.vtu'", ")", ":", "check_input", "(", "Verts", "=", "Verts", ",", "E2V", "=", "E2V", ",", "Agg", "=", "Agg", ...
Coarse grid visualization of aggregate groups. Create .vtu files for use in Paraview or display with Matplotlib. Parameters ---------- Verts : {array} coordinate array (N x D) E2V : {array} element index array (Nel x Nelnodes) Agg : {csr_matrix} sparse matrix for the ag...
[ "Coarse", "grid", "visualization", "of", "aggregate", "groups", "." ]
python
train
timknip/pycsg
csg/geom.py
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/geom.py#L50-L52
def plus(self, a): """ Add. """ return Vector(self.x+a.x, self.y+a.y, self.z+a.z)
[ "def", "plus", "(", "self", ",", "a", ")", ":", "return", "Vector", "(", "self", ".", "x", "+", "a", ".", "x", ",", "self", ".", "y", "+", "a", ".", "y", ",", "self", ".", "z", "+", "a", ".", "z", ")" ]
Add.
[ "Add", "." ]
python
train
google/grr
grr/server/grr_response_server/flow.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L560-L566
def Close(self): """Flushes the flow and all its requests to the data_store.""" self._CheckLeaseAndFlush() super(FlowBase, self).Close() # Writing the messages queued in the queue_manager of the runner always has # to be the last thing that happens or we will have a race condition. self.FlushMes...
[ "def", "Close", "(", "self", ")", ":", "self", ".", "_CheckLeaseAndFlush", "(", ")", "super", "(", "FlowBase", ",", "self", ")", ".", "Close", "(", ")", "# Writing the messages queued in the queue_manager of the runner always has", "# to be the last thing that happens or ...
Flushes the flow and all its requests to the data_store.
[ "Flushes", "the", "flow", "and", "all", "its", "requests", "to", "the", "data_store", "." ]
python
train
ihmeuw/vivarium
src/vivarium/interface/interactive.py
https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/interface/interactive.py#L261-L286
def initialize_simulation_from_model_specification(model_specification_file: str) -> InteractiveContext: """Construct a simulation from a model specification file. The simulation context returned by this method still needs to be setup by calling its setup method. It is mostly useful for testing and debuggi...
[ "def", "initialize_simulation_from_model_specification", "(", "model_specification_file", ":", "str", ")", "->", "InteractiveContext", ":", "model_specification", "=", "build_model_specification", "(", "model_specification_file", ")", "plugin_config", "=", "model_specification", ...
Construct a simulation from a model specification file. The simulation context returned by this method still needs to be setup by calling its setup method. It is mostly useful for testing and debugging. Parameters ---------- model_specification_file The path to a model specification file. ...
[ "Construct", "a", "simulation", "from", "a", "model", "specification", "file", "." ]
python
train
PredixDev/predixpy
predix/admin/cf/api.py
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/api.py#L50-L66
def get(self, path): """ Generic GET with headers """ uri = self.config.get_target() + path headers = self._get_headers() logging.debug("URI=GET " + str(uri)) logging.debug("HEADERS=" + str(headers)) response = self.session.get(uri, headers=headers) ...
[ "def", "get", "(", "self", ",", "path", ")", ":", "uri", "=", "self", ".", "config", ".", "get_target", "(", ")", "+", "path", "headers", "=", "self", ".", "_get_headers", "(", ")", "logging", ".", "debug", "(", "\"URI=GET \"", "+", "str", "(", "ur...
Generic GET with headers
[ "Generic", "GET", "with", "headers" ]
python
train
jssimporter/python-jss
jss/jss_prefs.py
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jss_prefs.py#L134-L167
def parse_plist(self, preferences_file): """Try to reset preferences from preference_file.""" preferences_file = os.path.expanduser(preferences_file) # Try to open using FoundationPlist. If it's not available, # fall back to plistlib and hope it's not binary encoded. try: ...
[ "def", "parse_plist", "(", "self", ",", "preferences_file", ")", ":", "preferences_file", "=", "os", ".", "path", ".", "expanduser", "(", "preferences_file", ")", "# Try to open using FoundationPlist. If it's not available,", "# fall back to plistlib and hope it's not binary en...
Try to reset preferences from preference_file.
[ "Try", "to", "reset", "preferences", "from", "preference_file", "." ]
python
train
pybel/pybel
src/pybel/manager/database_io.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/database_io.py#L20-L38
def to_database(graph, manager: Optional[Manager] = None, store_parts: bool = True, use_tqdm: bool = False): """Store a graph in a database. :param BELGraph graph: A BEL graph :param store_parts: Should the graph be stored in the edge store? :return: If successful, returns the network object from the d...
[ "def", "to_database", "(", "graph", ",", "manager", ":", "Optional", "[", "Manager", "]", "=", "None", ",", "store_parts", ":", "bool", "=", "True", ",", "use_tqdm", ":", "bool", "=", "False", ")", ":", "if", "manager", "is", "None", ":", "manager", ...
Store a graph in a database. :param BELGraph graph: A BEL graph :param store_parts: Should the graph be stored in the edge store? :return: If successful, returns the network object from the database. :rtype: Optional[Network]
[ "Store", "a", "graph", "in", "a", "database", "." ]
python
train
xeroc/python-graphenelib
grapheneapi/http.py
https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/grapheneapi/http.py#L22-L38
def rpcexec(self, payload): """ Execute a call by sending the payload :param json payload: Payload data :raises ValueError: if the server does not respond in proper JSON format :raises HttpInvalidStatusCode: if the server returns a status code...
[ "def", "rpcexec", "(", "self", ",", "payload", ")", ":", "log", ".", "debug", "(", "json", ".", "dumps", "(", "payload", ")", ")", "query", "=", "requests", ".", "post", "(", "self", ".", "url", ",", "json", "=", "payload", ",", "proxies", "=", "...
Execute a call by sending the payload :param json payload: Payload data :raises ValueError: if the server does not respond in proper JSON format :raises HttpInvalidStatusCode: if the server returns a status code that is not 200
[ "Execute", "a", "call", "by", "sending", "the", "payload" ]
python
valid
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L215-L294
def modify(self, dn: str, mod_list: dict) -> None: """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify", self, dn, mod_list) # need to work out how to reverse changes in mod_list; result in revlist ...
[ "def", "modify", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", "->", "None", ":", "_debug", "(", "\"modify\"", ",", "self", ",", "dn", ",", "mod_list", ")", "# need to work out how to reverse changes in mod_list; result in revlist", "rev...
Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Modify", "a", "DN", "in", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
python
train
BernardFW/bernard
src/bernard/platforms/facebook/platform.py
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L484-L505
async def _get_messenger_profile(self, page, fields: List[Text]): """ Fetch the value of specified fields in order to avoid setting the same field twice at the same value (since Facebook engineers are not able to make menus that keep on working if set again). """ params ...
[ "async", "def", "_get_messenger_profile", "(", "self", ",", "page", ",", "fields", ":", "List", "[", "Text", "]", ")", ":", "params", "=", "{", "'access_token'", ":", "page", "[", "'page_token'", "]", ",", "'fields'", ":", "','", ".", "join", "(", "fie...
Fetch the value of specified fields in order to avoid setting the same field twice at the same value (since Facebook engineers are not able to make menus that keep on working if set again).
[ "Fetch", "the", "value", "of", "specified", "fields", "in", "order", "to", "avoid", "setting", "the", "same", "field", "twice", "at", "the", "same", "value", "(", "since", "Facebook", "engineers", "are", "not", "able", "to", "make", "menus", "that", "keep"...
python
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/accounts/accounts_daemon.py#L221-L230
def _RemoveUsers(self, remove_users): """Deprovision Linux user accounts that do not appear in account metadata. Args: remove_users: list, the username strings of the Linux accounts to remove. """ for username in remove_users: self.utils.RemoveUser(username) self.user_ssh_keys.pop(use...
[ "def", "_RemoveUsers", "(", "self", ",", "remove_users", ")", ":", "for", "username", "in", "remove_users", ":", "self", ".", "utils", ".", "RemoveUser", "(", "username", ")", "self", ".", "user_ssh_keys", ".", "pop", "(", "username", ",", "None", ")", "...
Deprovision Linux user accounts that do not appear in account metadata. Args: remove_users: list, the username strings of the Linux accounts to remove.
[ "Deprovision", "Linux", "user", "accounts", "that", "do", "not", "appear", "in", "account", "metadata", "." ]
python
train
jvamvas/rhymediscovery
rhymediscovery/celex.py
https://github.com/jvamvas/rhymediscovery/blob/b76509c98554b12efa06fe9ab557cca5fa5e4a79/rhymediscovery/celex.py#L44-L74
def init_perfect_ttable(words): """initialize (normalized) theta according to whether words rhyme""" d = read_celex() not_in_dict = 0 n = len(words) t_table = numpy.zeros((n, n + 1)) # initialize P(c|r) accordingly for r, w in enumerate(words): if w not in d: not_in_di...
[ "def", "init_perfect_ttable", "(", "words", ")", ":", "d", "=", "read_celex", "(", ")", "not_in_dict", "=", "0", "n", "=", "len", "(", "words", ")", "t_table", "=", "numpy", ".", "zeros", "(", "(", "n", ",", "n", "+", "1", ")", ")", "# initialize P...
initialize (normalized) theta according to whether words rhyme
[ "initialize", "(", "normalized", ")", "theta", "according", "to", "whether", "words", "rhyme" ]
python
train
lsst-sqre/sqre-codekit
codekit/codetools.py
https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/codetools.py#L24-L91
def setup_logging(verbosity=0): """Configure python `logging`. This is required before the `debug()`, `info()`, etc. functions may be used. If any other `codekit.*` modules, which are not a "package", have been imported, and they have a `setup_logging()` function, that is called before `logging` i...
[ "def", "setup_logging", "(", "verbosity", "=", "0", ")", ":", "import", "pkgutil", "import", "logging", "import", "codekit", "# https://packaging.python.org/guides/creating-and-discovering-plugins/#using-namespace-packages", "def", "iter_namespace", "(", "ns_pkg", ")", ":", ...
Configure python `logging`. This is required before the `debug()`, `info()`, etc. functions may be used. If any other `codekit.*` modules, which are not a "package", have been imported, and they have a `setup_logging()` function, that is called before `logging` is configured. This gives other modules...
[ "Configure", "python", "logging", ".", "This", "is", "required", "before", "the", "debug", "()", "info", "()", "etc", ".", "functions", "may", "be", "used", "." ]
python
train
vxgmichel/aiostream
aiostream/stream/advanced.py
https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/advanced.py#L116-L126
def flatten(source, task_limit=None): """Given an asynchronous sequence of sequences, generate the elements of the sequences as soon as they're received. The sequences are awaited concurrently, although it's possible to limit the amount of running sequences using the `task_limit` argument. Errors ...
[ "def", "flatten", "(", "source", ",", "task_limit", "=", "None", ")", ":", "return", "base_combine", ".", "raw", "(", "source", ",", "task_limit", "=", "task_limit", ",", "switch", "=", "False", ",", "ordered", "=", "False", ")" ]
Given an asynchronous sequence of sequences, generate the elements of the sequences as soon as they're received. The sequences are awaited concurrently, although it's possible to limit the amount of running sequences using the `task_limit` argument. Errors raised in the source or an element sequence a...
[ "Given", "an", "asynchronous", "sequence", "of", "sequences", "generate", "the", "elements", "of", "the", "sequences", "as", "soon", "as", "they", "re", "received", "." ]
python
train
ASKIDA/Selenium2LibraryExtension
src/Selenium2LibraryExtension/keywords/__init__.py
https://github.com/ASKIDA/Selenium2LibraryExtension/blob/5ca3fa776063c6046dff317cb2575e4772d7541f/src/Selenium2LibraryExtension/keywords/__init__.py#L332-L339
def element_focus_should_be_set(self, locator): """Verifies the element identified by `locator` has focus. | *Argument* | *Description* | *Example* | | locator | Selenium 2 element locator | id=my_id |""" self._info("Verifying element '%s' focus is set" % locator) self._check_element_focus(True, locator)
[ "def", "element_focus_should_be_set", "(", "self", ",", "locator", ")", ":", "self", ".", "_info", "(", "\"Verifying element '%s' focus is set\"", "%", "locator", ")", "self", ".", "_check_element_focus", "(", "True", ",", "locator", ")" ]
Verifies the element identified by `locator` has focus. | *Argument* | *Description* | *Example* | | locator | Selenium 2 element locator | id=my_id |
[ "Verifies", "the", "element", "identified", "by", "locator", "has", "focus", "." ]
python
train
google/grr
api_client/python/grr_api_client/root.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/api_client/python/grr_api_client/root.py#L144-L159
def CreateGrrUser(self, username=None, user_type=None, password=None): """Creates a new GRR user of a given type with a given username/password.""" if not username: raise ValueError("Username can't be empty.") args = user_management_pb2.ApiCreateGrrUserArgs(username=username) if user_type is no...
[ "def", "CreateGrrUser", "(", "self", ",", "username", "=", "None", ",", "user_type", "=", "None", ",", "password", "=", "None", ")", ":", "if", "not", "username", ":", "raise", "ValueError", "(", "\"Username can't be empty.\"", ")", "args", "=", "user_manage...
Creates a new GRR user of a given type with a given username/password.
[ "Creates", "a", "new", "GRR", "user", "of", "a", "given", "type", "with", "a", "given", "username", "/", "password", "." ]
python
train
Stewori/pytypes
pytypes/type_util.py
https://github.com/Stewori/pytypes/blob/b814d38709e84c0e0825caf8b721c20eb5a8ab3b/pytypes/type_util.py#L1104-L1145
def _issubclass_Mapping_covariant(subclass, superclass, bound_Generic, bound_typevars, bound_typevars_readonly, follow_fwd_refs, _recursion_check): """Helper for _issubclass, a.k.a pytypes.issubtype. This subclass-check treats Mapping-values as covariant. """ if is_Generic(subclass): ...
[ "def", "_issubclass_Mapping_covariant", "(", "subclass", ",", "superclass", ",", "bound_Generic", ",", "bound_typevars", ",", "bound_typevars_readonly", ",", "follow_fwd_refs", ",", "_recursion_check", ")", ":", "if", "is_Generic", "(", "subclass", ")", ":", "if", "...
Helper for _issubclass, a.k.a pytypes.issubtype. This subclass-check treats Mapping-values as covariant.
[ "Helper", "for", "_issubclass", "a", ".", "k", ".", "a", "pytypes", ".", "issubtype", ".", "This", "subclass", "-", "check", "treats", "Mapping", "-", "values", "as", "covariant", "." ]
python
train
sassoo/goldman
goldman/queryparams/page.py
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/page.py#L100-L110
def prev(self): """ Generate query parameters for the prev page """ if self.total: if self.offset - self.limit - self.limit < 0: return self.first else: offset = self.offset - self.limit return {'page[offset]': offset, 'page[limit]...
[ "def", "prev", "(", "self", ")", ":", "if", "self", ".", "total", ":", "if", "self", ".", "offset", "-", "self", ".", "limit", "-", "self", ".", "limit", "<", "0", ":", "return", "self", ".", "first", "else", ":", "offset", "=", "self", ".", "o...
Generate query parameters for the prev page
[ "Generate", "query", "parameters", "for", "the", "prev", "page" ]
python
train
basho/riak-python-client
riak/riak_object.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/riak_object.py#L319-L348
def delete(self, r=None, w=None, dw=None, pr=None, pw=None, timeout=None): """ Delete this object from Riak. :param r: R-value, wait for this many partitions to read object before performing the put :type r: integer :param w: W-value, wait for this many p...
[ "def", "delete", "(", "self", ",", "r", "=", "None", ",", "w", "=", "None", ",", "dw", "=", "None", ",", "pr", "=", "None", ",", "pw", "=", "None", ",", "timeout", "=", "None", ")", ":", "self", ".", "client", ".", "delete", "(", "self", ",",...
Delete this object from Riak. :param r: R-value, wait for this many partitions to read object before performing the put :type r: integer :param w: W-value, wait for this many partitions to respond before returning to client. :type w: integer :param dw: DW-value...
[ "Delete", "this", "object", "from", "Riak", "." ]
python
train
mongodb/mongo-python-driver
pymongo/message.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/message.py#L544-L553
def _insert_uncompressed(collection_name, docs, check_keys, safe, last_error_args, continue_on_error, opts): """Internal insert message helper.""" op_insert, max_bson_size = _insert( collection_name, docs, check_keys, continue_on_error, opts) rid, msg = __pack_message(2002, op_insert) ...
[ "def", "_insert_uncompressed", "(", "collection_name", ",", "docs", ",", "check_keys", ",", "safe", ",", "last_error_args", ",", "continue_on_error", ",", "opts", ")", ":", "op_insert", ",", "max_bson_size", "=", "_insert", "(", "collection_name", ",", "docs", "...
Internal insert message helper.
[ "Internal", "insert", "message", "helper", "." ]
python
train
DataBiosphere/toil
src/toil/jobStores/googleJobStore.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/jobStores/googleJobStore.py#L450-L476
def _uploadStream(self, fileName, update=False, encrypt=True): """ Yields a context manager that can be used to write to the bucket with a stream. See :class:`~toil.jobStores.utils.WritablePipe` for an example. Will throw assertion error if the file shouldn't be updated and yet ...
[ "def", "_uploadStream", "(", "self", ",", "fileName", ",", "update", "=", "False", ",", "encrypt", "=", "True", ")", ":", "blob", "=", "self", ".", "bucket", ".", "blob", "(", "bytes", "(", "fileName", ")", ",", "encryption_key", "=", "self", ".", "s...
Yields a context manager that can be used to write to the bucket with a stream. See :class:`~toil.jobStores.utils.WritablePipe` for an example. Will throw assertion error if the file shouldn't be updated and yet exists. :param fileName: name of file to be inserted into bucket :...
[ "Yields", "a", "context", "manager", "that", "can", "be", "used", "to", "write", "to", "the", "bucket", "with", "a", "stream", ".", "See", ":", "class", ":", "~toil", ".", "jobStores", ".", "utils", ".", "WritablePipe", "for", "an", "example", "." ]
python
train
rstoneback/pysat
pysat/instruments/netcdf_pandas.py
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/netcdf_pandas.py#L49-L104
def load(fnames, tag=None, sat_id=None, **kwargs): """Loads data using pysat.utils.load_netcdf4 . This routine is called as needed by pysat. It is not intended for direct user interaction. Parameters ---------- fnames : array-like iterable of filename strings, full path, to data fi...
[ "def", "load", "(", "fnames", ",", "tag", "=", "None", ",", "sat_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "pysat", ".", "utils", ".", "load_netcdf4", "(", "fnames", ",", "*", "*", "kwargs", ")" ]
Loads data using pysat.utils.load_netcdf4 . This routine is called as needed by pysat. It is not intended for direct user interaction. Parameters ---------- fnames : array-like iterable of filename strings, full path, to data files to be loaded. This input is nominally provided...
[ "Loads", "data", "using", "pysat", ".", "utils", ".", "load_netcdf4", "." ]
python
train
saltstack/salt
salt/modules/poudriere.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/poudriere.py#L175-L204
def create_jail(name, arch, version="9.0-RELEASE"): ''' Creates a new poudriere jail if one does not exist *NOTE* creating a new jail will take some time the master is not hanging CLI Example: .. code-block:: bash salt '*' poudriere.create_jail 90amd64 amd64 ''' # Config file mus...
[ "def", "create_jail", "(", "name", ",", "arch", ",", "version", "=", "\"9.0-RELEASE\"", ")", ":", "# Config file must be on system to create a poudriere jail", "_check_config_exists", "(", ")", "# Check if the jail is there", "if", "is_jail", "(", "name", ")", ":", "ret...
Creates a new poudriere jail if one does not exist *NOTE* creating a new jail will take some time the master is not hanging CLI Example: .. code-block:: bash salt '*' poudriere.create_jail 90amd64 amd64
[ "Creates", "a", "new", "poudriere", "jail", "if", "one", "does", "not", "exist" ]
python
train
nikhilkumarsingh/gnewsclient
gnewsclient/gnewsclient.py
https://github.com/nikhilkumarsingh/gnewsclient/blob/65422f1dee9408f1b51ae6a2ee08ae478432e1d5/gnewsclient/gnewsclient.py#L24-L33
def get_config(self): """ function to get current configuration """ config = { 'location': self.location, 'language': self.language, 'topic': self.topic, } return config
[ "def", "get_config", "(", "self", ")", ":", "config", "=", "{", "'location'", ":", "self", ".", "location", ",", "'language'", ":", "self", ".", "language", ",", "'topic'", ":", "self", ".", "topic", ",", "}", "return", "config" ]
function to get current configuration
[ "function", "to", "get", "current", "configuration" ]
python
train
nteract/papermill
papermill/parameterize.py
https://github.com/nteract/papermill/blob/7423a303f3fa22ec6d03edf5fd9700d659b5a6fa/papermill/parameterize.py#L55-L106
def parameterize_notebook(nb, parameters, report_mode=False): """Assigned parameters into the appropriate place in the input notebook Parameters ---------- nb : NotebookNode Executable notebook object parameters : dict Arbitrary keyword arguments to pass as notebook parameters rep...
[ "def", "parameterize_notebook", "(", "nb", ",", "parameters", ",", "report_mode", "=", "False", ")", ":", "# Load from a file if 'parameters' is a string.", "if", "isinstance", "(", "parameters", ",", "six", ".", "string_types", ")", ":", "parameters", "=", "read_ya...
Assigned parameters into the appropriate place in the input notebook Parameters ---------- nb : NotebookNode Executable notebook object parameters : dict Arbitrary keyword arguments to pass as notebook parameters report_mode : bool, optional Flag to set report mode
[ "Assigned", "parameters", "into", "the", "appropriate", "place", "in", "the", "input", "notebook" ]
python
train
dpkp/kafka-python
kafka/coordinator/base.py
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L297-L321
def poll_heartbeat(self): """ Check the status of the heartbeat thread (if it is active) and indicate the liveness of the client. This must be called periodically after joining with :meth:`.ensure_active_group` to ensure that the member stays in the group. If an interval of time ...
[ "def", "poll_heartbeat", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_heartbeat_thread", "is", "not", "None", ":", "if", "self", ".", "_heartbeat_thread", ".", "failed", ":", "# set the heartbeat thread to None and raise an except...
Check the status of the heartbeat thread (if it is active) and indicate the liveness of the client. This must be called periodically after joining with :meth:`.ensure_active_group` to ensure that the member stays in the group. If an interval of time longer than the provided rebalance tim...
[ "Check", "the", "status", "of", "the", "heartbeat", "thread", "(", "if", "it", "is", "active", ")", "and", "indicate", "the", "liveness", "of", "the", "client", ".", "This", "must", "be", "called", "periodically", "after", "joining", "with", ":", "meth", ...
python
train
ojarva/python-sshpubkeys
sshpubkeys/keys.py
https://github.com/ojarva/python-sshpubkeys/blob/86dc1ab27ce82dcc091ce127416cc3ee219e9bec/sshpubkeys/keys.py#L163-L166
def hash_sha512(self): """Calculates sha512 fingerprint.""" fp_plain = hashlib.sha512(self._decoded_key).digest() return (b"SHA512:" + base64.b64encode(fp_plain).replace(b"=", b"")).decode("utf-8")
[ "def", "hash_sha512", "(", "self", ")", ":", "fp_plain", "=", "hashlib", ".", "sha512", "(", "self", ".", "_decoded_key", ")", ".", "digest", "(", ")", "return", "(", "b\"SHA512:\"", "+", "base64", ".", "b64encode", "(", "fp_plain", ")", ".", "replace", ...
Calculates sha512 fingerprint.
[ "Calculates", "sha512", "fingerprint", "." ]
python
test
brainiak/brainiak
brainiak/fcma/voxelselector.py
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/fcma/voxelselector.py#L284-L329
def _correlation_computation(self, task): """Use BLAS API to do correlation computation (matrix multiplication). Parameters ---------- task: tuple (start_voxel_id, num_processed_voxels) depicting the voxels assigned to compute Returns ------- corr: 3...
[ "def", "_correlation_computation", "(", "self", ",", "task", ")", ":", "time1", "=", "time", ".", "time", "(", ")", "s", "=", "task", "[", "0", "]", "nEpochs", "=", "len", "(", "self", ".", "raw_data", ")", "logger", ".", "debug", "(", "'start to com...
Use BLAS API to do correlation computation (matrix multiplication). Parameters ---------- task: tuple (start_voxel_id, num_processed_voxels) depicting the voxels assigned to compute Returns ------- corr: 3D array in shape [num_processed_voxels, num_epochs, n...
[ "Use", "BLAS", "API", "to", "do", "correlation", "computation", "(", "matrix", "multiplication", ")", "." ]
python
train
janpipek/physt
physt/binnings.py
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L972-L1007
def ideal_bin_count(data, method: str = "default") -> int: """A theoretically ideal bin count. Parameters ---------- data: array_likes Data to work on. Most methods don't use this. method: str Name of the method to apply, available values: - default (~sturges) - ...
[ "def", "ideal_bin_count", "(", "data", ",", "method", ":", "str", "=", "\"default\"", ")", "->", "int", ":", "n", "=", "data", ".", "size", "if", "n", "<", "1", ":", "return", "1", "if", "method", "==", "\"default\"", ":", "if", "n", "<=", "32", ...
A theoretically ideal bin count. Parameters ---------- data: array_likes Data to work on. Most methods don't use this. method: str Name of the method to apply, available values: - default (~sturges) - sqrt - sturges - doane - rice ...
[ "A", "theoretically", "ideal", "bin", "count", "." ]
python
train
bukun/TorCMS
torcms/handlers/filter_handler.py
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/filter_handler.py#L110-L159
def echo_html(self, url_str): ''' Show the HTML ''' logger.info('info echo html: {0}'.format(url_str)) condition = self.gen_redis_kw() url_arr = self.parse_url(url_str) sig = url_arr[0] num = (len(url_arr) - 2) // 2 catinfo = MCategory.get_by_...
[ "def", "echo_html", "(", "self", ",", "url_str", ")", ":", "logger", ".", "info", "(", "'info echo html: {0}'", ".", "format", "(", "url_str", ")", ")", "condition", "=", "self", ".", "gen_redis_kw", "(", ")", "url_arr", "=", "self", ".", "parse_url", "(...
Show the HTML
[ "Show", "the", "HTML" ]
python
train
saltstack/salt
salt/client/ssh/ssh_py_shim.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/ssh_py_shim.py#L159-L172
def unpack_thin(thin_path): ''' Unpack the Salt thin archive. ''' tfile = tarfile.TarFile.gzopen(thin_path) old_umask = os.umask(0o077) # pylint: disable=blacklisted-function tfile.extractall(path=OPTIONS.saltdir) tfile.close() os.umask(old_umask) # pylint: disable=blacklisted-function...
[ "def", "unpack_thin", "(", "thin_path", ")", ":", "tfile", "=", "tarfile", ".", "TarFile", ".", "gzopen", "(", "thin_path", ")", "old_umask", "=", "os", ".", "umask", "(", "0o077", ")", "# pylint: disable=blacklisted-function", "tfile", ".", "extractall", "(",...
Unpack the Salt thin archive.
[ "Unpack", "the", "Salt", "thin", "archive", "." ]
python
train
soravux/scoop
examples/shared_example.py
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/examples/shared_example.py#L26-L35
def myFunc(parameter): """This function will be executed on the remote host even if it was not available at launch.""" print('Hello World from {0}!'.format(scoop.worker)) # It is possible to get a constant anywhere print(shared.getConst('myVar')[2]) # Parameters are handled as usual ret...
[ "def", "myFunc", "(", "parameter", ")", ":", "print", "(", "'Hello World from {0}!'", ".", "format", "(", "scoop", ".", "worker", ")", ")", "# It is possible to get a constant anywhere", "print", "(", "shared", ".", "getConst", "(", "'myVar'", ")", "[", "2", "...
This function will be executed on the remote host even if it was not available at launch.
[ "This", "function", "will", "be", "executed", "on", "the", "remote", "host", "even", "if", "it", "was", "not", "available", "at", "launch", "." ]
python
train
jantman/awslimitchecker
awslimitchecker/limit.py
https://github.com/jantman/awslimitchecker/blob/e50197f70f3d0abcc5cfc7fde6336f548b790e34/awslimitchecker/limit.py#L323-L353
def set_threshold_override(self, warn_percent=None, warn_count=None, crit_percent=None, crit_count=None): """ Override the default warning and critical thresholds used to evaluate this limit's usage. Theresholds can be specified as a percentage of the limit...
[ "def", "set_threshold_override", "(", "self", ",", "warn_percent", "=", "None", ",", "warn_count", "=", "None", ",", "crit_percent", "=", "None", ",", "crit_count", "=", "None", ")", ":", "self", ".", "warn_percent", "=", "warn_percent", "self", ".", "warn_c...
Override the default warning and critical thresholds used to evaluate this limit's usage. Theresholds can be specified as a percentage of the limit, or as a usage count, or both. **Note:** The percent thresholds (``warn_percent`` and ``crit_percent``) have default values that are set gl...
[ "Override", "the", "default", "warning", "and", "critical", "thresholds", "used", "to", "evaluate", "this", "limit", "s", "usage", ".", "Theresholds", "can", "be", "specified", "as", "a", "percentage", "of", "the", "limit", "or", "as", "a", "usage", "count",...
python
train
VingtCinq/python-mailchimp
mailchimp3/entities/campaignfeedback.py
https://github.com/VingtCinq/python-mailchimp/blob/1b472f1b64fdde974732ac4b7ed48908bb707260/mailchimp3/entities/campaignfeedback.py#L28-L51
def create(self, campaign_id, data, **queryparams): """ Add feedback on a specific campaign. :param campaign_id: The unique id for the campaign. :type campaign_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { ...
[ "def", "create", "(", "self", ",", "campaign_id", ",", "data", ",", "*", "*", "queryparams", ")", ":", "self", ".", "campaign_id", "=", "campaign_id", "if", "'message'", "not", "in", "data", ":", "raise", "KeyError", "(", "'The campaign feedback must have a me...
Add feedback on a specific campaign. :param campaign_id: The unique id for the campaign. :type campaign_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "message": string* } :param queryparams: The que...
[ "Add", "feedback", "on", "a", "specific", "campaign", "." ]
python
valid
pyca/pyopenssl
src/OpenSSL/SSL.py
https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/src/OpenSSL/SSL.py#L861-L870
def _check_env_vars_set(self, dir_env_var, file_env_var): """ Check to see if the default cert dir/file environment vars are present. :return: bool """ return ( os.environ.get(file_env_var) is not None or os.environ.get(dir_env_var) is not None )
[ "def", "_check_env_vars_set", "(", "self", ",", "dir_env_var", ",", "file_env_var", ")", ":", "return", "(", "os", ".", "environ", ".", "get", "(", "file_env_var", ")", "is", "not", "None", "or", "os", ".", "environ", ".", "get", "(", "dir_env_var", ")",...
Check to see if the default cert dir/file environment vars are present. :return: bool
[ "Check", "to", "see", "if", "the", "default", "cert", "dir", "/", "file", "environment", "vars", "are", "present", "." ]
python
test
LuminosoInsight/python-ftfy
ftfy/fixes.py
https://github.com/LuminosoInsight/python-ftfy/blob/476acc6ad270bffe07f97d4f7cf2139acdc69633/ftfy/fixes.py#L582-L600
def restore_byte_a0(byts): """ Some mojibake has been additionally altered by a process that said "hmm, byte A0, that's basically a space!" and replaced it with an ASCII space. When the A0 is part of a sequence that we intend to decode as UTF-8, changing byte A0 to 20 would make it fail to decode. ...
[ "def", "restore_byte_a0", "(", "byts", ")", ":", "def", "replacement", "(", "match", ")", ":", "\"The function to apply when this regex matches.\"", "return", "match", ".", "group", "(", "0", ")", ".", "replace", "(", "b'\\x20'", ",", "b'\\xa0'", ")", "return", ...
Some mojibake has been additionally altered by a process that said "hmm, byte A0, that's basically a space!" and replaced it with an ASCII space. When the A0 is part of a sequence that we intend to decode as UTF-8, changing byte A0 to 20 would make it fail to decode. This process finds sequences that w...
[ "Some", "mojibake", "has", "been", "additionally", "altered", "by", "a", "process", "that", "said", "hmm", "byte", "A0", "that", "s", "basically", "a", "space!", "and", "replaced", "it", "with", "an", "ASCII", "space", ".", "When", "the", "A0", "is", "pa...
python
train
pixelogik/NearPy
nearpy/hashes/permutation/permutation.py
https://github.com/pixelogik/NearPy/blob/1b534b864d320d875508e95cd2b76b6d8c07a90b/nearpy/hashes/permutation/permutation.py#L40-L65
def build_permuted_index( self, lshash, buckets, num_permutation, beam_size, num_neighbour): """ Build a permutedIndex and store it into the dict self.permutedIndexs. lshash: the binary lshash object (nearpy.hashes.lshash). ...
[ "def", "build_permuted_index", "(", "self", ",", "lshash", ",", "buckets", ",", "num_permutation", ",", "beam_size", ",", "num_neighbour", ")", ":", "# Init a PermutedIndex", "pi", "=", "PermutedIndex", "(", "lshash", ",", "buckets", ",", "num_permutation", ",", ...
Build a permutedIndex and store it into the dict self.permutedIndexs. lshash: the binary lshash object (nearpy.hashes.lshash). buckets: the buckets object corresponding to lshash. It's a dict object which can get from nearpy.storage.buckets[lshash.hash_name] num_permutation: th...
[ "Build", "a", "permutedIndex", "and", "store", "it", "into", "the", "dict", "self", ".", "permutedIndexs", ".", "lshash", ":", "the", "binary", "lshash", "object", "(", "nearpy", ".", "hashes", ".", "lshash", ")", ".", "buckets", ":", "the", "buckets", "...
python
train
housecanary/hc-api-python
housecanary/utilities.py
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/utilities.py#L6-L26
def get_readable_time_string(seconds): """Returns human readable string from number of seconds""" seconds = int(seconds) minutes = seconds // 60 seconds = seconds % 60 hours = minutes // 60 minutes = minutes % 60 days = hours // 24 hours = hours % 24 result = "" if days > 0: ...
[ "def", "get_readable_time_string", "(", "seconds", ")", ":", "seconds", "=", "int", "(", "seconds", ")", "minutes", "=", "seconds", "//", "60", "seconds", "=", "seconds", "%", "60", "hours", "=", "minutes", "//", "60", "minutes", "=", "minutes", "%", "60...
Returns human readable string from number of seconds
[ "Returns", "human", "readable", "string", "from", "number", "of", "seconds" ]
python
train
LLNL/certipy
certipy/certipy.py
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L414-L428
def remove_files(self, common_name, delete_dir=False): """Delete files and record associated with this common name""" record = self.remove_record(common_name) if delete_dir: delete_dirs = [] if 'files' in record: key_containing_dir = os.path.dirname(recor...
[ "def", "remove_files", "(", "self", ",", "common_name", ",", "delete_dir", "=", "False", ")", ":", "record", "=", "self", ".", "remove_record", "(", "common_name", ")", "if", "delete_dir", ":", "delete_dirs", "=", "[", "]", "if", "'files'", "in", "record",...
Delete files and record associated with this common name
[ "Delete", "files", "and", "record", "associated", "with", "this", "common", "name" ]
python
train
fermiPy/fermipy
fermipy/jobs/file_archive.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/file_archive.py#L386-L397
def copy_to_scratch(file_mapping, dry_run=True): """Copy input files to scratch area """ for key, value in file_mapping.items(): if not os.path.exists(key): continue if dry_run: print ("copy %s %s" % (key, value)) else: ...
[ "def", "copy_to_scratch", "(", "file_mapping", ",", "dry_run", "=", "True", ")", ":", "for", "key", ",", "value", "in", "file_mapping", ".", "items", "(", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "key", ")", ":", "continue", "if"...
Copy input files to scratch area
[ "Copy", "input", "files", "to", "scratch", "area" ]
python
train
valohai/valohai-yaml
valohai_yaml/commands.py
https://github.com/valohai/valohai-yaml/blob/3d2e92381633d84cdba039f6905df34c9633a2e1/valohai_yaml/commands.py#L44-L83
def build_command(command, parameter_map): """ Build command line(s) using the given parameter map. Even if the passed a single `command`, this function will return a list of shell commands. It is the caller's responsibility to concatenate them, likely using the semicolon or double ampersands. ...
[ "def", "build_command", "(", "command", ",", "parameter_map", ")", ":", "if", "isinstance", "(", "parameter_map", ",", "list", ")", ":", "# Partially emulate old (pre-0.7) API for this function.", "parameter_map", "=", "LegacyParameterMap", "(", "parameter_map", ")", "o...
Build command line(s) using the given parameter map. Even if the passed a single `command`, this function will return a list of shell commands. It is the caller's responsibility to concatenate them, likely using the semicolon or double ampersands. :param command: The command to interpolate params int...
[ "Build", "command", "line", "(", "s", ")", "using", "the", "given", "parameter", "map", "." ]
python
train
seung-lab/cloud-volume
cloudvolume/lib.py
https://github.com/seung-lab/cloud-volume/blob/d2fd4500333f1bc3cd3e3919a8b649cec5d8e214/cloudvolume/lib.py#L206-L212
def divisors(n): """Generate the divisors of n""" for i in range(1, int(math.sqrt(n) + 1)): if n % i == 0: yield i if i*i != n: yield n / i
[ "def", "divisors", "(", "n", ")", ":", "for", "i", "in", "range", "(", "1", ",", "int", "(", "math", ".", "sqrt", "(", "n", ")", "+", "1", ")", ")", ":", "if", "n", "%", "i", "==", "0", ":", "yield", "i", "if", "i", "*", "i", "!=", "n",...
Generate the divisors of n
[ "Generate", "the", "divisors", "of", "n" ]
python
train
kytos/python-openflow
pyof/foundation/network_types.py
https://github.com/kytos/python-openflow/blob/4f2d0d08ab28e102ed88fe57a4ee17729f1e1bb7/pyof/foundation/network_types.py#L640-L649
def value(self): """Return sub type and sub value as binary data. Returns: :class:`~pyof.foundation.basic_types.BinaryData`: BinaryData calculated. """ binary = UBInt8(self.sub_type).pack() + self.sub_value.pack() return BinaryData(binary)
[ "def", "value", "(", "self", ")", ":", "binary", "=", "UBInt8", "(", "self", ".", "sub_type", ")", ".", "pack", "(", ")", "+", "self", ".", "sub_value", ".", "pack", "(", ")", "return", "BinaryData", "(", "binary", ")" ]
Return sub type and sub value as binary data. Returns: :class:`~pyof.foundation.basic_types.BinaryData`: BinaryData calculated.
[ "Return", "sub", "type", "and", "sub", "value", "as", "binary", "data", "." ]
python
train