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
manns/pyspread
pyspread/src/lib/vlc.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L5130-L5138
def libvlc_media_player_get_nsobject(p_mi): '''Get the NSView handler previously set with L{libvlc_media_player_set_nsobject}(). @param p_mi: the Media Player. @return: the NSView handler or 0 if none where set. ''' f = _Cfunctions.get('libvlc_media_player_get_nsobject', None) or \ _Cfunctio...
[ "def", "libvlc_media_player_get_nsobject", "(", "p_mi", ")", ":", "f", "=", "_Cfunctions", ".", "get", "(", "'libvlc_media_player_get_nsobject'", ",", "None", ")", "or", "_Cfunction", "(", "'libvlc_media_player_get_nsobject'", ",", "(", "(", "1", ",", ")", ",", ...
Get the NSView handler previously set with L{libvlc_media_player_set_nsobject}(). @param p_mi: the Media Player. @return: the NSView handler or 0 if none where set.
[ "Get", "the", "NSView", "handler", "previously", "set", "with", "L", "{", "libvlc_media_player_set_nsobject", "}", "()", "." ]
python
train
facelessuser/wcmatch
wcmatch/wcmatch.py
https://github.com/facelessuser/wcmatch/blob/d153e7007cc73b994ae1ba553dc4584039f5c212/wcmatch/wcmatch.py#L214-L258
def _walk(self): """Start search for valid files.""" self._base_len = len(self.base) for base, dirs, files in os.walk(self.base, followlinks=self.follow_links): # Remove child folders based on exclude rules for name in dirs[:]: try: i...
[ "def", "_walk", "(", "self", ")", ":", "self", ".", "_base_len", "=", "len", "(", "self", ".", "base", ")", "for", "base", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "base", ",", "followlinks", "=", "self", ".", "follow...
Start search for valid files.
[ "Start", "search", "for", "valid", "files", "." ]
python
train
numenta/htmresearch
htmresearch/frameworks/layers/physical_objects.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/layers/physical_objects.py#L757-L835
def visualize(self, numPoints=100): """ Visualization utility for models. Helps to debug the math and logic. Helps to monitor complex objects with difficult to define boundaries. Only supports 3-dimensional objects. TODO: center the objects using scale, rotate and translate operations on mesh ...
[ "def", "visualize", "(", "self", ",", "numPoints", "=", "100", ")", ":", "try", ":", "import", "pyqtgraph", "as", "pg", "import", "pyqtgraph", ".", "multiprocess", "as", "mp", "import", "pyqtgraph", ".", "opengl", "as", "gl", "except", "ImportError", "as",...
Visualization utility for models. Helps to debug the math and logic. Helps to monitor complex objects with difficult to define boundaries. Only supports 3-dimensional objects. TODO: center the objects using scale, rotate and translate operations on mesh objects.
[ "Visualization", "utility", "for", "models", ".", "Helps", "to", "debug", "the", "math", "and", "logic", ".", "Helps", "to", "monitor", "complex", "objects", "with", "difficult", "to", "define", "boundaries", "." ]
python
train
blockstack/blockstack-core
blockstack/lib/subdomains.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L850-L929
def index_discovered_zonefiles(self, lastblock): """ Go through the list of zone files we discovered via Atlas, grouped by name and ordered by block height. Find all subsequent zone files for this name, and process all subdomain operations contained within them. """ all_queued_zf...
[ "def", "index_discovered_zonefiles", "(", "self", ",", "lastblock", ")", ":", "all_queued_zfinfos", "=", "[", "]", "# contents of the queue", "subdomain_zonefile_infos", "=", "{", "}", "# map subdomain fqn to list of zonefile info bundles, for process_subdomains", "name_blocks", ...
Go through the list of zone files we discovered via Atlas, grouped by name and ordered by block height. Find all subsequent zone files for this name, and process all subdomain operations contained within them.
[ "Go", "through", "the", "list", "of", "zone", "files", "we", "discovered", "via", "Atlas", "grouped", "by", "name", "and", "ordered", "by", "block", "height", ".", "Find", "all", "subsequent", "zone", "files", "for", "this", "name", "and", "process", "all"...
python
train
pantsbuild/pants
src/python/pants/pantsd/process_manager.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/pantsd/process_manager.py#L565-L580
def parse_fingerprint(self, cmdline, key=None, sep=None): """Given a psutil.Process.cmdline, parse and return a fingerprint. :param list cmdline: The psutil.Process.cmdline of the current process. :param string key: The key for fingerprint discovery. :param string sep: The key/value separator for finge...
[ "def", "parse_fingerprint", "(", "self", ",", "cmdline", ",", "key", "=", "None", ",", "sep", "=", "None", ")", ":", "key", "=", "key", "or", "self", ".", "FINGERPRINT_CMD_KEY", "if", "key", ":", "sep", "=", "sep", "or", "self", ".", "FINGERPRINT_CMD_S...
Given a psutil.Process.cmdline, parse and return a fingerprint. :param list cmdline: The psutil.Process.cmdline of the current process. :param string key: The key for fingerprint discovery. :param string sep: The key/value separator for fingerprint discovery. :returns: The parsed fingerprint or `None`....
[ "Given", "a", "psutil", ".", "Process", ".", "cmdline", "parse", "and", "return", "a", "fingerprint", "." ]
python
train
elastic/apm-agent-python
elasticapm/processors.py
https://github.com/elastic/apm-agent-python/blob/2975663d7bd22282dc39336b2c37b37c12c7a774/elasticapm/processors.py#L212-L229
def sanitize_http_request_body(client, event): """ Sanitizes http request body. This only works if the request body is a query-encoded string. Other types (e.g. JSON) are not handled by this sanitizer. :param client: an ElasticAPM client :param event: a transaction or error event :return: T...
[ "def", "sanitize_http_request_body", "(", "client", ",", "event", ")", ":", "try", ":", "body", "=", "force_text", "(", "event", "[", "\"context\"", "]", "[", "\"request\"", "]", "[", "\"body\"", "]", ",", "errors", "=", "\"replace\"", ")", "except", "(", ...
Sanitizes http request body. This only works if the request body is a query-encoded string. Other types (e.g. JSON) are not handled by this sanitizer. :param client: an ElasticAPM client :param event: a transaction or error event :return: The modified event
[ "Sanitizes", "http", "request", "body", ".", "This", "only", "works", "if", "the", "request", "body", "is", "a", "query", "-", "encoded", "string", ".", "Other", "types", "(", "e", ".", "g", ".", "JSON", ")", "are", "not", "handled", "by", "this", "s...
python
train
nats-io/python-nats
nats/io/client.py
https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L495-L514
def _flush_timeout(self, timeout): """ Takes a timeout and sets up a future which will return True once the server responds back otherwise raise a TimeoutError. """ future = tornado.concurrent.Future() yield self._send_ping(future) try: result = yield ...
[ "def", "_flush_timeout", "(", "self", ",", "timeout", ")", ":", "future", "=", "tornado", ".", "concurrent", ".", "Future", "(", ")", "yield", "self", ".", "_send_ping", "(", "future", ")", "try", ":", "result", "=", "yield", "tornado", ".", "gen", "."...
Takes a timeout and sets up a future which will return True once the server responds back otherwise raise a TimeoutError.
[ "Takes", "a", "timeout", "and", "sets", "up", "a", "future", "which", "will", "return", "True", "once", "the", "server", "responds", "back", "otherwise", "raise", "a", "TimeoutError", "." ]
python
train
Robpol86/terminaltables
example1.py
https://github.com/Robpol86/terminaltables/blob/ad8f46e50afdbaea377fc1f713bc0e7a31c4fccc/example1.py#L18-L38
def main(): """Main function.""" title = 'Jetta SportWagen' # AsciiTable. table_instance = AsciiTable(TABLE_DATA, title) table_instance.justify_columns[2] = 'right' print(table_instance.table) print() # SingleTable. table_instance = SingleTable(TABLE_DATA, title) table_instance...
[ "def", "main", "(", ")", ":", "title", "=", "'Jetta SportWagen'", "# AsciiTable.", "table_instance", "=", "AsciiTable", "(", "TABLE_DATA", ",", "title", ")", "table_instance", ".", "justify_columns", "[", "2", "]", "=", "'right'", "print", "(", "table_instance",...
Main function.
[ "Main", "function", "." ]
python
train
belbio/bel
bel/db/arangodb.py
https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/db/arangodb.py#L247-L279
def get_belapi_handle(client, username=None, password=None): """Get BEL API arango db handle""" (username, password) = get_user_creds(username, password) sys_db = client.db("_system", username=username, password=password) # Create a new database named "belapi" try: if username and passwor...
[ "def", "get_belapi_handle", "(", "client", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "(", "username", ",", "password", ")", "=", "get_user_creds", "(", "username", ",", "password", ")", "sys_db", "=", "client", ".", "db", "(",...
Get BEL API arango db handle
[ "Get", "BEL", "API", "arango", "db", "handle" ]
python
train
Nachtfeuer/pipeline
spline/tools/decorators.py
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/decorators.py#L25-L53
def singleton(the_class): """ Decorator for a class to make a singleton out of it. @type the_class: class @param the_class: the class that should work as a singleton @rtype: decorator @return: decorator """ class_instances = {} def get_instance(*args, **kwargs): """ ...
[ "def", "singleton", "(", "the_class", ")", ":", "class_instances", "=", "{", "}", "def", "get_instance", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Creating or just return the one and only class instance.\n\n The singleton depends on the pa...
Decorator for a class to make a singleton out of it. @type the_class: class @param the_class: the class that should work as a singleton @rtype: decorator @return: decorator
[ "Decorator", "for", "a", "class", "to", "make", "a", "singleton", "out", "of", "it", "." ]
python
train
TankerHQ/python-cli-ui
cli_ui/__init__.py
https://github.com/TankerHQ/python-cli-ui/blob/4c9928827cea06cf80e6a1f5bd86478d8566863f/cli_ui/__init__.py#L328-L337
def dot(*, last: bool = False, fileobj: Any = None) -> None: """ Print a dot without a newline unless it is the last one. Useful when you want to display a progress with very little knowledge. :param last: whether this is the last dot (will insert a newline) """ end = "\n" if last else "" ...
[ "def", "dot", "(", "*", ",", "last", ":", "bool", "=", "False", ",", "fileobj", ":", "Any", "=", "None", ")", "->", "None", ":", "end", "=", "\"\\n\"", "if", "last", "else", "\"\"", "info", "(", "\".\"", ",", "end", "=", "end", ",", "fileobj", ...
Print a dot without a newline unless it is the last one. Useful when you want to display a progress with very little knowledge. :param last: whether this is the last dot (will insert a newline)
[ "Print", "a", "dot", "without", "a", "newline", "unless", "it", "is", "the", "last", "one", "." ]
python
train
codelv/enaml-native
src/enamlnative/android/android_drawer_layout.py
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_drawer_layout.py#L75-L90
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidDrawerLayout, self).init_widget() d = self.declaration if d.title: self.set_title(d.title) if d.drawer_elevation: self.set_drawer_elevation(d.drawer_elevation) i...
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidDrawerLayout", ",", "self", ")", ".", "init_widget", "(", ")", "d", "=", "self", ".", "declaration", "if", "d", ".", "title", ":", "self", ".", "set_title", "(", "d", ".", "title", ")...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
python
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/grapher.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/grapher.py#L192-L332
def plotit(self, x, y, fields, colors=[], title=None): '''plot a set of graphs using date for x axis''' pylab.ion() self.fig = pylab.figure(num=1, figsize=(12,6)) self.ax1 = self.fig.gca() ax2 = None for i in range(0, len(fields)): if len(x[i]) == 0: continue ...
[ "def", "plotit", "(", "self", ",", "x", ",", "y", ",", "fields", ",", "colors", "=", "[", "]", ",", "title", "=", "None", ")", ":", "pylab", ".", "ion", "(", ")", "self", ".", "fig", "=", "pylab", ".", "figure", "(", "num", "=", "1", ",", "...
plot a set of graphs using date for x axis
[ "plot", "a", "set", "of", "graphs", "using", "date", "for", "x", "axis" ]
python
train
kgori/treeCl
treeCl/plotter.py
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/plotter.py#L31-L82
def heatmap(dm, partition=None, cmap=CM.Blues, fontsize=10): """ heatmap(dm, partition=None, cmap=CM.Blues, fontsize=10) Produce a 2D plot of the distance matrix, with values encoded by coloured cells. Args: partition: treeCl.Partition object - if supplied, will reorder ...
[ "def", "heatmap", "(", "dm", ",", "partition", "=", "None", ",", "cmap", "=", "CM", ".", "Blues", ",", "fontsize", "=", "10", ")", ":", "assert", "isinstance", "(", "dm", ",", "DistanceMatrix", ")", "datamax", "=", "float", "(", "np", ".", "abs", "...
heatmap(dm, partition=None, cmap=CM.Blues, fontsize=10) Produce a 2D plot of the distance matrix, with values encoded by coloured cells. Args: partition: treeCl.Partition object - if supplied, will reorder rows and columns of the distance matrix to reflect ...
[ "heatmap", "(", "dm", "partition", "=", "None", "cmap", "=", "CM", ".", "Blues", "fontsize", "=", "10", ")", "Produce", "a", "2D", "plot", "of", "the", "distance", "matrix", "with", "values", "encoded", "by", "coloured", "cells", "." ]
python
train
pybel/pybel-tools
src/pybel_tools/selection/metapaths.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/metapaths.py#L37-L55
def get_walks_exhaustive(graph, node, length): """Gets all walks under a given length starting at a given node :param networkx.Graph graph: A graph :param node: Starting node :param int length: The length of walks to get :return: A list of paths :rtype: list[tuple] """ if 0 == length: ...
[ "def", "get_walks_exhaustive", "(", "graph", ",", "node", ",", "length", ")", ":", "if", "0", "==", "length", ":", "return", "(", "node", ",", ")", ",", "return", "tuple", "(", "(", "node", ",", "key", ")", "+", "path", "for", "neighbor", "in", "gr...
Gets all walks under a given length starting at a given node :param networkx.Graph graph: A graph :param node: Starting node :param int length: The length of walks to get :return: A list of paths :rtype: list[tuple]
[ "Gets", "all", "walks", "under", "a", "given", "length", "starting", "at", "a", "given", "node" ]
python
valid
mozilla/python-zeppelin
zeppelin/converters/markdown.py
https://github.com/mozilla/python-zeppelin/blob/76ce6b7608ef6cf7b807bd5d850a58ea6a59ef07/zeppelin/converters/markdown.py#L60-L64
def build_code(self, lang, body): """Wrap text with markdown specific flavour.""" self.out.append("```" + lang) self.build_markdown(lang, body) self.out.append("```")
[ "def", "build_code", "(", "self", ",", "lang", ",", "body", ")", ":", "self", ".", "out", ".", "append", "(", "\"```\"", "+", "lang", ")", "self", ".", "build_markdown", "(", "lang", ",", "body", ")", "self", ".", "out", ".", "append", "(", "\"```\...
Wrap text with markdown specific flavour.
[ "Wrap", "text", "with", "markdown", "specific", "flavour", "." ]
python
train
ladybug-tools/ladybug
ladybug/analysisperiod.py
https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/analysisperiod.py#L287-L294
def doys_int(self): """A sorted list of days of the year in this analysis period as integers.""" if not self._is_reversed: return self._calc_daystamps(self.st_time, self.end_time) else: doys_st = self._calc_daystamps(self.st_time, DateTime.from_hoy(8759)) doys...
[ "def", "doys_int", "(", "self", ")", ":", "if", "not", "self", ".", "_is_reversed", ":", "return", "self", ".", "_calc_daystamps", "(", "self", ".", "st_time", ",", "self", ".", "end_time", ")", "else", ":", "doys_st", "=", "self", ".", "_calc_daystamps"...
A sorted list of days of the year in this analysis period as integers.
[ "A", "sorted", "list", "of", "days", "of", "the", "year", "in", "this", "analysis", "period", "as", "integers", "." ]
python
train
cltk/cltk
cltk/corpus/readers.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/corpus/readers.py#L295-L305
def words(self, fileids=None) -> Generator[str, str, None]: """ Provide the words of the corpus; skipping any paragraphs flagged by keywords to the main class constructor :param fileids: :return: words, including punctuation, one by one """ for sentence in self.se...
[ "def", "words", "(", "self", ",", "fileids", "=", "None", ")", "->", "Generator", "[", "str", ",", "str", ",", "None", "]", ":", "for", "sentence", "in", "self", ".", "sents", "(", "fileids", ")", ":", "words", "=", "self", ".", "_word_tokenizer", ...
Provide the words of the corpus; skipping any paragraphs flagged by keywords to the main class constructor :param fileids: :return: words, including punctuation, one by one
[ "Provide", "the", "words", "of", "the", "corpus", ";", "skipping", "any", "paragraphs", "flagged", "by", "keywords", "to", "the", "main", "class", "constructor", ":", "param", "fileids", ":", ":", "return", ":", "words", "including", "punctuation", "one", "b...
python
train
Ceasar/staticjinja
staticjinja/staticjinja.py
https://github.com/Ceasar/staticjinja/blob/57b8cac81da7fee3387510af4843e1bd1fd3ba28/staticjinja/staticjinja.py#L386-L399
def render_templates(self, templates, filepath=None): """Render a collection of :class:`jinja2.Template` objects. :param templates: A collection of Templates to render. :param filepath: Optional. A file or file-like object to dump the complete template strea...
[ "def", "render_templates", "(", "self", ",", "templates", ",", "filepath", "=", "None", ")", ":", "for", "template", "in", "templates", ":", "self", ".", "render_template", "(", "template", ",", "filepath", ")" ]
Render a collection of :class:`jinja2.Template` objects. :param templates: A collection of Templates to render. :param filepath: Optional. A file or file-like object to dump the complete template stream into. Defaults to to ``os.path.join(self.outpath, t...
[ "Render", "a", "collection", "of", ":", "class", ":", "jinja2", ".", "Template", "objects", "." ]
python
train
TissueMAPS/TmClient
src/python/tmclient/api.py
https://github.com/TissueMAPS/TmClient/blob/6fb40622af19142cb5169a64b8c2965993a25ab1/src/python/tmclient/api.py#L1927-L1955
def rename_mapobject_type(self, name, new_name): '''Renames a mapobject type. Parameters ---------- name: str name of the mapobject type that should be renamed new_name: str name that should be given to the mapobject type See also -------...
[ "def", "rename_mapobject_type", "(", "self", ",", "name", ",", "new_name", ")", ":", "logger", ".", "info", "(", "'rename mapobject type \"%s\" of experiment \"%s\"'", ",", "name", ",", "self", ".", "experiment_name", ")", "content", "=", "{", "'name'", ":", "ne...
Renames a mapobject type. Parameters ---------- name: str name of the mapobject type that should be renamed new_name: str name that should be given to the mapobject type See also -------- :func:`tmserver.api.mapobject.update_mapobject_typ...
[ "Renames", "a", "mapobject", "type", "." ]
python
train
bretth/woven
woven/linux.py
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/linux.py#L244-L272
def lsb_release(): """ Get the linux distribution information and return in an attribute dict The following attributes should be available: base, distributor_id, description, release, codename For example Ubuntu Lucid would return base = debian distributor_id = Ubuntu descripti...
[ "def", "lsb_release", "(", ")", ":", "output", "=", "run", "(", "'lsb_release -a'", ")", ".", "split", "(", "'\\n'", ")", "release", "=", "_AttributeDict", "(", "{", "}", ")", "for", "line", "in", "output", ":", "try", ":", "key", ",", "value", "=", ...
Get the linux distribution information and return in an attribute dict The following attributes should be available: base, distributor_id, description, release, codename For example Ubuntu Lucid would return base = debian distributor_id = Ubuntu description = Ubuntu 10.04.x LTS rel...
[ "Get", "the", "linux", "distribution", "information", "and", "return", "in", "an", "attribute", "dict", "The", "following", "attributes", "should", "be", "available", ":", "base", "distributor_id", "description", "release", "codename", "For", "example", "Ubuntu", ...
python
train
Mindwerks/worldengine
worldengine/draw.py
https://github.com/Mindwerks/worldengine/blob/64dff8eb7824ce46b5b6cb8006bcef21822ef144/worldengine/draw.py#L234-L256
def get_normalized_elevation_array(world): ''' Convert raw elevation into normalized values between 0 and 255, and return a numpy array of these values ''' e = world.layers['elevation'].data ocean = world.layers['ocean'].data mask = numpy.ma.array(e, mask=ocean) # only land min_elev_land ...
[ "def", "get_normalized_elevation_array", "(", "world", ")", ":", "e", "=", "world", ".", "layers", "[", "'elevation'", "]", ".", "data", "ocean", "=", "world", ".", "layers", "[", "'ocean'", "]", ".", "data", "mask", "=", "numpy", ".", "ma", ".", "arra...
Convert raw elevation into normalized values between 0 and 255, and return a numpy array of these values
[ "Convert", "raw", "elevation", "into", "normalized", "values", "between", "0", "and", "255", "and", "return", "a", "numpy", "array", "of", "these", "values" ]
python
train
CiscoUcs/UcsPythonSDK
src/UcsSdk/UcsBase.py
https://github.com/CiscoUcs/UcsPythonSDK/blob/bf6b07d6abeacb922c92b198352eda4eb9e4629b/src/UcsSdk/UcsBase.py#L460-L502
def LoadFromXml(self, node, handle): """ Method updates/fills the object from the xml representation of the managed object. """ from Ucs import ClassFactory self.SetHandle(handle) if node.hasAttributes(): # attributes = node._get_attributes() # attCount = attributes._get_length() attributes = node.att...
[ "def", "LoadFromXml", "(", "self", ",", "node", ",", "handle", ")", ":", "from", "Ucs", "import", "ClassFactory", "self", ".", "SetHandle", "(", "handle", ")", "if", "node", ".", "hasAttributes", "(", ")", ":", "# attributes = node._get_attributes()", "# attCo...
Method updates/fills the object from the xml representation of the managed object.
[ "Method", "updates", "/", "fills", "the", "object", "from", "the", "xml", "representation", "of", "the", "managed", "object", "." ]
python
train
koenedaele/skosprovider
skosprovider/registry.py
https://github.com/koenedaele/skosprovider/blob/7304a37953978ca8227febc2d3cc2b2be178f215/skosprovider/registry.py#L177-L201
def get_all(self, **kwargs): '''Get all concepts from all providers. .. code-block:: python # get all concepts in all providers. registry.get_all() # get all concepts in all providers. # If possible, display the results with a Dutch label. r...
[ "def", "get_all", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwarguments", "=", "{", "}", "if", "'language'", "in", "kwargs", ":", "kwarguments", "[", "'language'", "]", "=", "kwargs", "[", "'language'", "]", "return", "[", "{", "'id'", ":", "p...
Get all concepts from all providers. .. code-block:: python # get all concepts in all providers. registry.get_all() # get all concepts in all providers. # If possible, display the results with a Dutch label. registry.get_all(language='nl') ...
[ "Get", "all", "concepts", "from", "all", "providers", "." ]
python
valid
HPCC-Cloud-Computing/CAL
calplus/client.py
https://github.com/HPCC-Cloud-Computing/CAL/blob/7134b3dfe9ee3a383506a592765c7a12fa4ca1e9/calplus/client.py#L25-L82
def Client(version=__version__, resource=None, provider=None, **kwargs): """Initialize client object based on given version. :params version: version of CAL, define at setup.cfg :params resource: resource type (network, compute, object_storage, block_storage) :params provider: prov...
[ "def", "Client", "(", "version", "=", "__version__", ",", "resource", "=", "None", ",", "provider", "=", "None", ",", "*", "*", "kwargs", ")", ":", "versions", "=", "_CLIENTS", ".", "keys", "(", ")", "if", "version", "not", "in", "versions", ":", "ra...
Initialize client object based on given version. :params version: version of CAL, define at setup.cfg :params resource: resource type (network, compute, object_storage, block_storage) :params provider: provider object :params cloud_config: cloud auth config :params **kwargs: sp...
[ "Initialize", "client", "object", "based", "on", "given", "version", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_acm.py#L210-L227
def nacm_rule_list_rule_rule_type_data_node_path(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") nacm = ET.SubElement(config, "nacm", xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm") rule_list = ET.SubElement(nacm, "rule-list") name_key = ET...
[ "def", "nacm_rule_list_rule_rule_type_data_node_path", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "nacm", "=", "ET", ".", "SubElement", "(", "config", ",", "\"nacm\"", ",", "xmlns", "=", "\"...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
twisted/vertex
vertex/q2q.py
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L907-L927
def _listen(self, protocols, From, description): """ Implementation of L{Listen}. """ # The peer is coming from a client-side representation of the user # described by 'From', and talking *to* a server-side representation of # the user described by 'From'. self.ve...
[ "def", "_listen", "(", "self", ",", "protocols", ",", "From", ",", "description", ")", ":", "# The peer is coming from a client-side representation of the user", "# described by 'From', and talking *to* a server-side representation of", "# the user described by 'From'.", "self", ".",...
Implementation of L{Listen}.
[ "Implementation", "of", "L", "{", "Listen", "}", "." ]
python
train
gmr/tinman
tinman/auth/mixins.py
https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/auth/mixins.py#L162-L184
def github_request(self, path, callback, access_token=None, post_args=None, **kwargs): """Make a request to the GitHub API, passing in the path, a callback, the access token, optional post arguments and keyword arguments to be added as values in the request body or URI ...
[ "def", "github_request", "(", "self", ",", "path", ",", "callback", ",", "access_token", "=", "None", ",", "post_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_API_URL", "+", "path", "all_args", "=", "{", "}", "if",...
Make a request to the GitHub API, passing in the path, a callback, the access token, optional post arguments and keyword arguments to be added as values in the request body or URI
[ "Make", "a", "request", "to", "the", "GitHub", "API", "passing", "in", "the", "path", "a", "callback", "the", "access", "token", "optional", "post", "arguments", "and", "keyword", "arguments", "to", "be", "added", "as", "values", "in", "the", "request", "b...
python
train
PmagPy/PmagPy
pmagpy/contribution_builder.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/contribution_builder.py#L1154-L1182
def remove_names(self, dtype): """ Remove unneeded name columns ('specimen'/'sample'/etc) from the specified table. Parameters ---------- dtype : str Returns --------- pandas DataFrame without the unneeded columns Example -------...
[ "def", "remove_names", "(", "self", ",", "dtype", ")", ":", "if", "dtype", "not", "in", "self", ".", "ancestry", ":", "return", "if", "dtype", "in", "self", ".", "tables", ":", "# remove extra columns here", "self_ind", "=", "self", ".", "ancestry", ".", ...
Remove unneeded name columns ('specimen'/'sample'/etc) from the specified table. Parameters ---------- dtype : str Returns --------- pandas DataFrame without the unneeded columns Example --------- Contribution.tables['specimens'].df = Co...
[ "Remove", "unneeded", "name", "columns", "(", "specimen", "/", "sample", "/", "etc", ")", "from", "the", "specified", "table", "." ]
python
train
blubberdiblub/eztemplate
eztemplate/__main__.py
https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/__main__.py#L403-L421
def perform_templating(args): """Perform templating according to the given arguments.""" engine = engines.engines[args.engine] if args.vary: it = variable_outfile_iterator(args.outfiles, args.infiles, args.args, ...
[ "def", "perform_templating", "(", "args", ")", ":", "engine", "=", "engines", ".", "engines", "[", "args", ".", "engine", "]", "if", "args", ".", "vary", ":", "it", "=", "variable_outfile_iterator", "(", "args", ".", "outfiles", ",", "args", ".", "infile...
Perform templating according to the given arguments.
[ "Perform", "templating", "according", "to", "the", "given", "arguments", "." ]
python
train
nok/sklearn-porter
sklearn_porter/estimator/classifier/KNeighborsClassifier/__init__.py
https://github.com/nok/sklearn-porter/blob/04673f768310bde31f9747a68a5e070592441ef2/sklearn_porter/estimator/classifier/KNeighborsClassifier/__init__.py#L155-L178
def predict(self, temp_type): """ Transpile the predict method. Parameters ---------- :param temp_type : string The kind of export type (embedded, separated, exported). Returns ------- :return : string The transpiled predict metho...
[ "def", "predict", "(", "self", ",", "temp_type", ")", ":", "# Exported:", "if", "temp_type", "==", "'exported'", ":", "temp", "=", "self", ".", "temp", "(", "'exported.class'", ")", "return", "temp", ".", "format", "(", "class_name", "=", "self", ".", "c...
Transpile the predict method. Parameters ---------- :param temp_type : string The kind of export type (embedded, separated, exported). Returns ------- :return : string The transpiled predict method as string.
[ "Transpile", "the", "predict", "method", "." ]
python
train
apache/airflow
airflow/models/taskinstance.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/models/taskinstance.py#L1363-L1368
def init_run_context(self, raw=False): """ Sets the log context. """ self.raw = raw self._set_context(self)
[ "def", "init_run_context", "(", "self", ",", "raw", "=", "False", ")", ":", "self", ".", "raw", "=", "raw", "self", ".", "_set_context", "(", "self", ")" ]
Sets the log context.
[ "Sets", "the", "log", "context", "." ]
python
test
saltstack/salt
salt/modules/lxc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L4439-L4476
def reboot(name, path=None): ''' Reboot a container. path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash salt 'minion' lxc.reboot myvm ''' ret = {'result': True, ...
[ "def", "reboot", "(", "name", ",", "path", "=", "None", ")", ":", "ret", "=", "{", "'result'", ":", "True", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "'{0} rebooted'", ".", "format", "(", "name", ")", "}", "does_exist", "=", "exists", ...
Reboot a container. path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 CLI Examples: .. code-block:: bash salt 'minion' lxc.reboot myvm
[ "Reboot", "a", "container", "." ]
python
train
tanghaibao/jcvi
jcvi/compara/quota.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/compara/quota.py#L64-L99
def get_2D_overlap(chain, eclusters): """ Implements a sweep line algorithm, that has better running time than naive O(n^2): assume block has x_ends, and y_ends for the bounds 1. sort x_ends, and take a sweep line to scan the x_ends 2. if left end, test y-axis intersection of current block with `ac...
[ "def", "get_2D_overlap", "(", "chain", ",", "eclusters", ")", ":", "mergeables", "=", "Grouper", "(", ")", "active", "=", "set", "(", ")", "x_ends", "=", "[", "]", "for", "i", ",", "(", "range_x", ",", "range_y", ",", "score", ")", "in", "enumerate",...
Implements a sweep line algorithm, that has better running time than naive O(n^2): assume block has x_ends, and y_ends for the bounds 1. sort x_ends, and take a sweep line to scan the x_ends 2. if left end, test y-axis intersection of current block with `active` set; also put this block in the `acti...
[ "Implements", "a", "sweep", "line", "algorithm", "that", "has", "better", "running", "time", "than", "naive", "O", "(", "n^2", ")", ":", "assume", "block", "has", "x_ends", "and", "y_ends", "for", "the", "bounds" ]
python
train
jobovy/galpy
galpy/orbit/Orbit.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/orbit/Orbit.py#L2321-L2352
def dec(self,*args,**kwargs): """ NAME: dec PURPOSE: return the declination INPUT: t - (optional) time at which to get dec (can be Quantity) obs=[X,Y,Z] - (optional) position of observer (in kpc; entries can be Quantity) (defa...
[ "def", "dec", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "out", "=", "self", ".", "_orb", ".", "dec", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "len", "(", "out", ")", "==", "1", ":", "return", "out", "[",...
NAME: dec PURPOSE: return the declination INPUT: t - (optional) time at which to get dec (can be Quantity) obs=[X,Y,Z] - (optional) position of observer (in kpc; entries can be Quantity) (default=[8.0,0.,0.]) OR Orbit object that corresponds ...
[ "NAME", ":" ]
python
train
Pegase745/sqlalchemy-datatables
examples/pyramid_tut/pyramid_tut/views.py
https://github.com/Pegase745/sqlalchemy-datatables/blob/049ab5f98f20ad37926fe86d5528da0c91cd462d/examples/pyramid_tut/pyramid_tut/views.py#L12-L23
def home(request): """Try to connect to database, and list available examples.""" try: DBSession.query(User).first() except DBAPIError: return Response( conn_err_msg, content_type="text/plain", status_int=500, ) return {"project": "pyramid_tut...
[ "def", "home", "(", "request", ")", ":", "try", ":", "DBSession", ".", "query", "(", "User", ")", ".", "first", "(", ")", "except", "DBAPIError", ":", "return", "Response", "(", "conn_err_msg", ",", "content_type", "=", "\"text/plain\"", ",", "status_int",...
Try to connect to database, and list available examples.
[ "Try", "to", "connect", "to", "database", "and", "list", "available", "examples", "." ]
python
train
pandas-dev/pandas
pandas/core/internals/blocks.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2477-L2506
def _try_coerce_args(self, values, other): """ Coerce values and other to int64, with null values converted to iNaT. values is always ndarray-like, other may not be Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ...
[ "def", "_try_coerce_args", "(", "self", ",", "values", ",", "other", ")", ":", "values", "=", "values", ".", "view", "(", "'i8'", ")", "if", "isinstance", "(", "other", ",", "bool", ")", ":", "raise", "TypeError", "elif", "is_null_datetimelike", "(", "ot...
Coerce values and other to int64, with null values converted to iNaT. values is always ndarray-like, other may not be Parameters ---------- values : ndarray-like other : ndarray-like or scalar Returns ------- base-type values, base-type other
[ "Coerce", "values", "and", "other", "to", "int64", "with", "null", "values", "converted", "to", "iNaT", ".", "values", "is", "always", "ndarray", "-", "like", "other", "may", "not", "be" ]
python
train
pmacosta/peng
peng/wave_functions.py
https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/wave_functions.py#L1115-L1157
def iffti(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the imaginary part of the inverse Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** ...
[ "def", "iffti", "(", "wave", ",", "npoints", "=", "None", ",", "indep_min", "=", "None", ",", "indep_max", "=", "None", ")", ":", "return", "imag", "(", "ifft", "(", "wave", ",", "npoints", ",", "indep_min", ",", "indep_max", ")", ")" ]
r""" Return the imaginary part of the inverse Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** is less than the size of the independent variable vector ...
[ "r", "Return", "the", "imaginary", "part", "of", "the", "inverse", "Fast", "Fourier", "Transform", "of", "a", "waveform", "." ]
python
test
manahl/arctic
arctic/tickstore/toplevel.py
https://github.com/manahl/arctic/blob/57e110b6e182dbab00e7e214dc26f7d9ec47c120/arctic/tickstore/toplevel.py#L119-L138
def write(self, symbol, data): """ Split the tick data to the underlying collections and write the data to each low level library. Args: symbol (str): the symbol for the timeseries data data (list of dicts or pandas dataframe): Tick data to write ...
[ "def", "write", "(", "self", ",", "symbol", ",", "data", ")", ":", "# get the full set of date ranges that we have", "cursor", "=", "self", ".", "_collection", ".", "find", "(", ")", "for", "res", "in", "cursor", ":", "library", "=", "self", ".", "_arctic_li...
Split the tick data to the underlying collections and write the data to each low level library. Args: symbol (str): the symbol for the timeseries data data (list of dicts or pandas dataframe): Tick data to write if a list of dicts is given the list must be in tim...
[ "Split", "the", "tick", "data", "to", "the", "underlying", "collections", "and", "write", "the", "data", "to", "each", "low", "level", "library", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7662-L7673
def parse_buffer(self, s): '''input some data bytes, possibly returning a list of new messages''' m = self.parse_char(s) if m is None: return None ret = [m] while True: m = self.parse_char("") if m is None: ...
[ "def", "parse_buffer", "(", "self", ",", "s", ")", ":", "m", "=", "self", ".", "parse_char", "(", "s", ")", "if", "m", "is", "None", ":", "return", "None", "ret", "=", "[", "m", "]", "while", "True", ":", "m", "=", "self", ".", "parse_char", "(...
input some data bytes, possibly returning a list of new messages
[ "input", "some", "data", "bytes", "possibly", "returning", "a", "list", "of", "new", "messages" ]
python
train
iotile/coretools
iotilesensorgraph/iotile/sg/parser/statements/streamer_statement.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/parser/statements/streamer_statement.py#L62-L75
def execute(self, sensor_graph, scope_stack): """Execute this statement on the sensor_graph given the current scope tree. This adds a single DataStreamer to the current sensor graph Args: sensor_graph (SensorGraph): The sensor graph that we are building or modifying...
[ "def", "execute", "(", "self", ",", "sensor_graph", ",", "scope_stack", ")", ":", "streamer", "=", "DataStreamer", "(", "self", ".", "selector", ",", "self", ".", "dest", ",", "self", ".", "report_format", ",", "self", ".", "auto", ",", "report_type", "=...
Execute this statement on the sensor_graph given the current scope tree. This adds a single DataStreamer to the current sensor graph Args: sensor_graph (SensorGraph): The sensor graph that we are building or modifying scope_stack (list(Scope)): A stack of nested...
[ "Execute", "this", "statement", "on", "the", "sensor_graph", "given", "the", "current", "scope", "tree", "." ]
python
train
mathandy/svgpathtools
svgpathtools/path.py
https://github.com/mathandy/svgpathtools/blob/fd7348a1dfd88b65ea61da02325c6605aedf8c4f/svgpathtools/path.py#L2188-L2203
def continuous_subpaths(self): """Breaks self into its continuous components, returning a list of continuous subpaths. I.e. (all(subpath.iscontinuous() for subpath in self.continuous_subpaths()) and self == concatpaths(self.continuous_subpaths())) ) """ s...
[ "def", "continuous_subpaths", "(", "self", ")", ":", "subpaths", "=", "[", "]", "subpath_start", "=", "0", "for", "i", "in", "range", "(", "len", "(", "self", ")", "-", "1", ")", ":", "if", "self", "[", "i", "]", ".", "end", "!=", "self", "[", ...
Breaks self into its continuous components, returning a list of continuous subpaths. I.e. (all(subpath.iscontinuous() for subpath in self.continuous_subpaths()) and self == concatpaths(self.continuous_subpaths())) )
[ "Breaks", "self", "into", "its", "continuous", "components", "returning", "a", "list", "of", "continuous", "subpaths", ".", "I", ".", "e", ".", "(", "all", "(", "subpath", ".", "iscontinuous", "()", "for", "subpath", "in", "self", ".", "continuous_subpaths",...
python
train
explosion/spaCy
examples/training/pretrain_textcat.py
https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/examples/training/pretrain_textcat.py#L41-L51
def load_textcat_data(limit=0): """Load data from the IMDB dataset.""" # Partition off part of the train data for evaluation train_data, eval_data = thinc.extra.datasets.imdb() random.shuffle(train_data) train_data = train_data[-limit:] texts, labels = zip(*train_data) eval_texts, eval_label...
[ "def", "load_textcat_data", "(", "limit", "=", "0", ")", ":", "# Partition off part of the train data for evaluation", "train_data", ",", "eval_data", "=", "thinc", ".", "extra", ".", "datasets", ".", "imdb", "(", ")", "random", ".", "shuffle", "(", "train_data", ...
Load data from the IMDB dataset.
[ "Load", "data", "from", "the", "IMDB", "dataset", "." ]
python
train
python-security/pyt
pyt/vulnerabilities/vulnerabilities.py
https://github.com/python-security/pyt/blob/efc0cfb716e40e0c8df4098f1cc8cf43723cd31f/pyt/vulnerabilities/vulnerabilities.py#L512-L549
def find_vulnerabilities( cfg_list, blackbox_mapping_file, sources_and_sinks_file, interactive=False, nosec_lines=defaultdict(set) ): """Find vulnerabilities in a list of CFGs from a trigger_word_file. Args: cfg_list(list[CFG]): the list of CFGs to scan. blackbox_mapping_fil...
[ "def", "find_vulnerabilities", "(", "cfg_list", ",", "blackbox_mapping_file", ",", "sources_and_sinks_file", ",", "interactive", "=", "False", ",", "nosec_lines", "=", "defaultdict", "(", "set", ")", ")", ":", "vulnerabilities", "=", "list", "(", ")", "definitions...
Find vulnerabilities in a list of CFGs from a trigger_word_file. Args: cfg_list(list[CFG]): the list of CFGs to scan. blackbox_mapping_file(str) sources_and_sinks_file(str) interactive(bool): determines if we ask the user about blackbox functions not in the mapping file. Returns...
[ "Find", "vulnerabilities", "in", "a", "list", "of", "CFGs", "from", "a", "trigger_word_file", "." ]
python
train
ponty/EasyProcess
easyprocess/__init__.py
https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L248-L272
def wait(self, timeout=None): """Wait for command to complete. Timeout: - discussion: http://stackoverflow.com/questions/1191374/subprocess-with-timeout - implementation: threading :rtype: self """ if timeout is not None: if not self._thread: ...
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "timeout", "is", "not", "None", ":", "if", "not", "self", ".", "_thread", ":", "self", ".", "_thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_wait...
Wait for command to complete. Timeout: - discussion: http://stackoverflow.com/questions/1191374/subprocess-with-timeout - implementation: threading :rtype: self
[ "Wait", "for", "command", "to", "complete", "." ]
python
train
prompt-toolkit/pymux
pymux/server.py
https://github.com/prompt-toolkit/pymux/blob/3f66e62b9de4b2251c7f9afad6c516dc5a30ec67/pymux/server.py#L115-L135
def _run_command(self, packet): """ Execute a run command from the client. """ create_temp_cli = self.client_states is None if create_temp_cli: # If this client doesn't have a CLI. Create a Fake CLI where the # window containing this pane, is the active o...
[ "def", "_run_command", "(", "self", ",", "packet", ")", ":", "create_temp_cli", "=", "self", ".", "client_states", "is", "None", "if", "create_temp_cli", ":", "# If this client doesn't have a CLI. Create a Fake CLI where the", "# window containing this pane, is the active one. ...
Execute a run command from the client.
[ "Execute", "a", "run", "command", "from", "the", "client", "." ]
python
train
klmitch/framer
framer/transport.py
https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/transport.py#L307-L342
def get_extra_info(self, name, default=None): """ Called by the client protocol to return optional transport information. Information requests not recognized by the ``FramerProtocol`` are passed on to the underlying transport. The values of ``name`` recognized directly by ...
[ "def", "get_extra_info", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "# Handle data we know about", "if", "name", "in", "self", ".", "_handlers", ":", "return", "self", ".", "_handlers", "[", "name", "]", "(", "self", ")", "# Call get_...
Called by the client protocol to return optional transport information. Information requests not recognized by the ``FramerProtocol`` are passed on to the underlying transport. The values of ``name`` recognized directly by ``FramerProtocol`` are: =============== =============...
[ "Called", "by", "the", "client", "protocol", "to", "return", "optional", "transport", "information", ".", "Information", "requests", "not", "recognized", "by", "the", "FramerProtocol", "are", "passed", "on", "to", "the", "underlying", "transport", "." ]
python
train
tjcsl/cslbot
cslbot/helpers/core.py
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/helpers/core.py#L183-L207
def reload_handler(self, c, e): """This handles reloads.""" cmd = self.is_reload(e) cmdchar = self.config['core']['cmdchar'] if cmd is not None: # If we're in a minimal reload state, only the owner can do stuff, as we can't rely on the db working. if self.reload_e...
[ "def", "reload_handler", "(", "self", ",", "c", ",", "e", ")", ":", "cmd", "=", "self", ".", "is_reload", "(", "e", ")", "cmdchar", "=", "self", ".", "config", "[", "'core'", "]", "[", "'cmdchar'", "]", "if", "cmd", "is", "not", "None", ":", "# I...
This handles reloads.
[ "This", "handles", "reloads", "." ]
python
train
numenta/nupic
src/nupic/swarming/permutations_runner.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/permutations_runner.py#L308-L341
def runWithPermutationsScript(permutationsFilePath, options, outputLabel, permWorkDir): """ Starts a swarm, given a path to a permutations.py script. This function is meant to be used with a CLI wrapper that passes command line arguments in through the options parameter. @pa...
[ "def", "runWithPermutationsScript", "(", "permutationsFilePath", ",", "options", ",", "outputLabel", ",", "permWorkDir", ")", ":", "global", "g_currentVerbosityLevel", "if", "\"verbosityCount\"", "in", "options", ":", "g_currentVerbosityLevel", "=", "options", "[", "\"v...
Starts a swarm, given a path to a permutations.py script. This function is meant to be used with a CLI wrapper that passes command line arguments in through the options parameter. @param permutationsFilePath {string} Path to permutations.py. @param options {dict} CLI options. @param outputLabel {string} Lab...
[ "Starts", "a", "swarm", "given", "a", "path", "to", "a", "permutations", ".", "py", "script", "." ]
python
valid
briancappello/py-yaml-fixtures
py_yaml_fixtures/fixtures_loader.py
https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L152-L164
def _load_from_yaml(self, filename: str, model_identifiers: Dict[str, List[str]]): """ Load fixtures from the given filename """ class_name = filename[:filename.rfind('.')] rendered_yaml = self.env.get_template(filename).render( model_identifiers=model_identifiers) ...
[ "def", "_load_from_yaml", "(", "self", ",", "filename", ":", "str", ",", "model_identifiers", ":", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ")", ":", "class_name", "=", "filename", "[", ":", "filename", ".", "rfind", "(", "'.'", ")", "]...
Load fixtures from the given filename
[ "Load", "fixtures", "from", "the", "given", "filename" ]
python
train
saltstack/salt
salt/modules/mac_timezone.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_timezone.py#L31-L58
def _get_date_time_format(dt_string): ''' Function that detects the date/time format for the string passed. :param str dt_string: A date/time string :return: The format of the passed dt_string :rtype: str :raises: SaltInvocationError on Invalid Date/Time string ''' valid_forma...
[ "def", "_get_date_time_format", "(", "dt_string", ")", ":", "valid_formats", "=", "[", "'%H:%M'", ",", "'%H:%M:%S'", ",", "'%m:%d:%y'", ",", "'%m:%d:%Y'", ",", "'%m/%d/%y'", ",", "'%m/%d/%Y'", "]", "for", "dt_format", "in", "valid_formats", ":", "try", ":", "d...
Function that detects the date/time format for the string passed. :param str dt_string: A date/time string :return: The format of the passed dt_string :rtype: str :raises: SaltInvocationError on Invalid Date/Time string
[ "Function", "that", "detects", "the", "date", "/", "time", "format", "for", "the", "string", "passed", "." ]
python
train
bcbio/bcbio-nextgen
bcbio/pipeline/sample.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L86-L100
def _add_supplemental_bams(data): """Add supplemental files produced by alignment, useful for structural variant calling. """ file_key = "work_bam" if data.get(file_key): for supext in ["disc", "sr"]: base, ext = os.path.splitext(data[file_key]) test_file = "%s-%s%s" ...
[ "def", "_add_supplemental_bams", "(", "data", ")", ":", "file_key", "=", "\"work_bam\"", "if", "data", ".", "get", "(", "file_key", ")", ":", "for", "supext", "in", "[", "\"disc\"", ",", "\"sr\"", "]", ":", "base", ",", "ext", "=", "os", ".", "path", ...
Add supplemental files produced by alignment, useful for structural variant calling.
[ "Add", "supplemental", "files", "produced", "by", "alignment", "useful", "for", "structural", "variant", "calling", "." ]
python
train
kylejusticemagnuson/pyti
pyti/volume_index.py
https://github.com/kylejusticemagnuson/pyti/blob/2f78430dfd60a0d20f4e7fc0cb4588c03107c4b2/pyti/volume_index.py#L35-L54
def negative_volume_index(close_data, volume): """ Negative Volume Index (NVI). Formula: NVI0 = 1 IF Vt < Vt-1 NVIt = NVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * NVIt-1) ELSE: NVIt = NVIt-1 """ catch_errors.check_for_input_len_diff(close_data, volume) nvi = np.zeros(len...
[ "def", "negative_volume_index", "(", "close_data", ",", "volume", ")", ":", "catch_errors", ".", "check_for_input_len_diff", "(", "close_data", ",", "volume", ")", "nvi", "=", "np", ".", "zeros", "(", "len", "(", "volume", ")", ")", "nvi", "[", "0", "]", ...
Negative Volume Index (NVI). Formula: NVI0 = 1 IF Vt < Vt-1 NVIt = NVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * NVIt-1) ELSE: NVIt = NVIt-1
[ "Negative", "Volume", "Index", "(", "NVI", ")", "." ]
python
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_silva_2008.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_silva_2008.py#L327-L334
def _compute_sigma_b(self, C, mag, vs30measured): """ Equation 23, page 81. """ sigma_0 = self._compute_sigma_0(C, mag, vs30measured) sigma_amp = self.CONSTS['sigma_amp'] return np.sqrt(sigma_0 ** 2 - sigma_amp ** 2)
[ "def", "_compute_sigma_b", "(", "self", ",", "C", ",", "mag", ",", "vs30measured", ")", ":", "sigma_0", "=", "self", ".", "_compute_sigma_0", "(", "C", ",", "mag", ",", "vs30measured", ")", "sigma_amp", "=", "self", ".", "CONSTS", "[", "'sigma_amp'", "]"...
Equation 23, page 81.
[ "Equation", "23", "page", "81", "." ]
python
train
tensorflow/probability
tensorflow_probability/python/mcmc/diagnostic.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/diagnostic.py#L388-L393
def _axis_size(x, axis=None): """Get number of elements of `x` in `axis`, as type `x.dtype`.""" if axis is None: return tf.cast(tf.size(input=x), x.dtype) return tf.cast( tf.reduce_prod(input_tensor=tf.gather(tf.shape(input=x), axis)), x.dtype)
[ "def", "_axis_size", "(", "x", ",", "axis", "=", "None", ")", ":", "if", "axis", "is", "None", ":", "return", "tf", ".", "cast", "(", "tf", ".", "size", "(", "input", "=", "x", ")", ",", "x", ".", "dtype", ")", "return", "tf", ".", "cast", "(...
Get number of elements of `x` in `axis`, as type `x.dtype`.
[ "Get", "number", "of", "elements", "of", "x", "in", "axis", "as", "type", "x", ".", "dtype", "." ]
python
test
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/bson/json_util.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/json_util.py#L723-L729
def _parse_canonical_minkey(doc): """Decode a JSON MinKey to bson.min_key.MinKey.""" if doc['$minKey'] is not 1: raise TypeError('$minKey value must be 1: %s' % (doc,)) if len(doc) != 1: raise TypeError('Bad $minKey, extra field(s): %s' % (doc,)) return MinKey()
[ "def", "_parse_canonical_minkey", "(", "doc", ")", ":", "if", "doc", "[", "'$minKey'", "]", "is", "not", "1", ":", "raise", "TypeError", "(", "'$minKey value must be 1: %s'", "%", "(", "doc", ",", ")", ")", "if", "len", "(", "doc", ")", "!=", "1", ":",...
Decode a JSON MinKey to bson.min_key.MinKey.
[ "Decode", "a", "JSON", "MinKey", "to", "bson", ".", "min_key", ".", "MinKey", "." ]
python
train
InQuest/python-sandboxapi
sandboxapi/fireeye.py
https://github.com/InQuest/python-sandboxapi/blob/9bad73f453e25d7d23e7b4b1ae927f44a35a5bc3/sandboxapi/fireeye.py#L31-L77
def _request(self, uri, method='GET', params=None, files=None, headers=None, auth=None): """Override the parent _request method. We have to do this here because FireEye requires some extra authentication steps. On each request we pass the auth headers, and if the session has expired, we...
[ "def", "_request", "(", "self", ",", "uri", ",", "method", "=", "'GET'", ",", "params", "=", "None", ",", "files", "=", "None", ",", "headers", "=", "None", ",", "auth", "=", "None", ")", ":", "if", "headers", ":", "headers", "[", "'Accept'", "]", ...
Override the parent _request method. We have to do this here because FireEye requires some extra authentication steps. On each request we pass the auth headers, and if the session has expired, we automatically reauthenticate.
[ "Override", "the", "parent", "_request", "method", "." ]
python
train
keon/algorithms
algorithms/sort/counting_sort.py
https://github.com/keon/algorithms/blob/4d6569464a62a75c1357acc97e2dd32ee2f9f4a3/algorithms/sort/counting_sort.py#L1-L36
def counting_sort(arr): """ Counting_sort Sorting a array which has no element greater than k Creating a new temp_arr,where temp_arr[i] contain the number of element less than or equal to i in the arr Then placing the number i into a correct position in the result_arr return the result_arr ...
[ "def", "counting_sort", "(", "arr", ")", ":", "m", "=", "min", "(", "arr", ")", "# in case there are negative elements, change the array to all positive element", "different", "=", "0", "if", "m", "<", "0", ":", "# save the change, so that we can convert the array back to a...
Counting_sort Sorting a array which has no element greater than k Creating a new temp_arr,where temp_arr[i] contain the number of element less than or equal to i in the arr Then placing the number i into a correct position in the result_arr return the result_arr Complexity: 0(n)
[ "Counting_sort", "Sorting", "a", "array", "which", "has", "no", "element", "greater", "than", "k", "Creating", "a", "new", "temp_arr", "where", "temp_arr", "[", "i", "]", "contain", "the", "number", "of", "element", "less", "than", "or", "equal", "to", "i"...
python
train
tensorflow/datasets
tensorflow_datasets/text/xnli.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/text/xnli.py#L107-L123
def _generate_examples(self, filepath): """This function returns the examples in the raw (text) form.""" rows_per_pair_id = collections.defaultdict(list) with tf.io.gfile.GFile(filepath) as f: reader = csv.DictReader(f, delimiter='\t', quoting=csv.QUOTE_NONE) for row in reader: rows_per...
[ "def", "_generate_examples", "(", "self", ",", "filepath", ")", ":", "rows_per_pair_id", "=", "collections", ".", "defaultdict", "(", "list", ")", "with", "tf", ".", "io", ".", "gfile", ".", "GFile", "(", "filepath", ")", "as", "f", ":", "reader", "=", ...
This function returns the examples in the raw (text) form.
[ "This", "function", "returns", "the", "examples", "in", "the", "raw", "(", "text", ")", "form", "." ]
python
train
litl/rauth
rauth/oauth.py
https://github.com/litl/rauth/blob/a6d887d7737cf21ec896a8104f25c2754c694011/rauth/oauth.py#L228-L248
def sign(self, consumer_secret, access_token_secret, method, url, oauth_params, req_kwargs): '''Sign request using PLAINTEXT method. :param consumer_secret: Consumer secret. :type consumer_secret: str :param access_token_secret: Access token secret (optional). :type...
[ "def", "sign", "(", "self", ",", "consumer_secret", ",", "access_token_secret", ",", "method", ",", "url", ",", "oauth_params", ",", "req_kwargs", ")", ":", "key", "=", "self", ".", "_escape", "(", "consumer_secret", ")", "+", "b'&'", "if", "access_token_sec...
Sign request using PLAINTEXT method. :param consumer_secret: Consumer secret. :type consumer_secret: str :param access_token_secret: Access token secret (optional). :type access_token_secret: str :param method: Unused :type method: str :param url: Unused ...
[ "Sign", "request", "using", "PLAINTEXT", "method", "." ]
python
train
heitzmann/gdspy
gdspy/__init__.py
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L197-L219
def rotate(self, angle, center=(0, 0)): """ Rotate this object. Parameters ---------- angle : number The angle of rotation (in *radians*). center : array-like[2] Center point for the rotation. Returns ------- out : ``Polyg...
[ "def", "rotate", "(", "self", ",", "angle", ",", "center", "=", "(", "0", ",", "0", ")", ")", ":", "ca", "=", "numpy", ".", "cos", "(", "angle", ")", "sa", "=", "numpy", ".", "sin", "(", "angle", ")", "sa", "=", "numpy", ".", "array", "(", ...
Rotate this object. Parameters ---------- angle : number The angle of rotation (in *radians*). center : array-like[2] Center point for the rotation. Returns ------- out : ``PolygonSet`` This object.
[ "Rotate", "this", "object", "." ]
python
train
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_db.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_db.py#L937-L955
def get_sql_insert_or_update(table: str, fieldlist: Sequence[str], delims: Tuple[str, str] = ("", "")) -> str: """Returns ?-marked SQL for an INSERT-or-if-duplicate-key-UPDATE statement. """ # http://stackoverflow.com/questions/4205181 return """...
[ "def", "get_sql_insert_or_update", "(", "table", ":", "str", ",", "fieldlist", ":", "Sequence", "[", "str", "]", ",", "delims", ":", "Tuple", "[", "str", ",", "str", "]", "=", "(", "\"\"", ",", "\"\"", ")", ")", "->", "str", ":", "# http://stackoverflo...
Returns ?-marked SQL for an INSERT-or-if-duplicate-key-UPDATE statement.
[ "Returns", "?", "-", "marked", "SQL", "for", "an", "INSERT", "-", "or", "-", "if", "-", "duplicate", "-", "key", "-", "UPDATE", "statement", "." ]
python
train
sunshowers/ntfs
ntfsutils/hardlink.py
https://github.com/sunshowers/ntfs/blob/33388a514f0a5a032f68dfeb9a40ce7c772e7cf5/ntfsutils/hardlink.py#L25-L34
def samefile(path1, path2): """ Returns True if path1 and path2 refer to the same file. """ # Check if both are on the same volume and have the same file ID info1 = fs.getfileinfo(path1) info2 = fs.getfileinfo(path2) return (info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber and ...
[ "def", "samefile", "(", "path1", ",", "path2", ")", ":", "# Check if both are on the same volume and have the same file ID", "info1", "=", "fs", ".", "getfileinfo", "(", "path1", ")", "info2", "=", "fs", ".", "getfileinfo", "(", "path2", ")", "return", "(", "inf...
Returns True if path1 and path2 refer to the same file.
[ "Returns", "True", "if", "path1", "and", "path2", "refer", "to", "the", "same", "file", "." ]
python
test
codelv/enaml-native
src/enamlnative/android/android_fragment.py
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L73-L81
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidFragment, self).init_widget() f = self.fragment f.setFragmentListener(f.getId()) f.onCreateView.connect(self.on_create_view) f.onDestroyView.connect(self.on_destroy_view)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidFragment", ",", "self", ")", ".", "init_widget", "(", ")", "f", "=", "self", ".", "fragment", "f", ".", "setFragmentListener", "(", "f", ".", "getId", "(", ")", ")", "f", ".", "onCrea...
Initialize the underlying widget.
[ "Initialize", "the", "underlying", "widget", "." ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/coremltools/converters/libsvm/__init__.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/libsvm/__init__.py#L17-L93
def convert(model, input_names='input', target_name='target', probability='classProbability', input_length='auto'): """ Convert a LIBSVM model to Core ML format. Parameters ---------- model: a libsvm model (C-SVC, nu-SVC, epsilon-SVR, or nu-SVR) or string path to a saved model....
[ "def", "convert", "(", "model", ",", "input_names", "=", "'input'", ",", "target_name", "=", "'target'", ",", "probability", "=", "'classProbability'", ",", "input_length", "=", "'auto'", ")", ":", "if", "not", "(", "_HAS_LIBSVM", ")", ":", "raise", "Runtime...
Convert a LIBSVM model to Core ML format. Parameters ---------- model: a libsvm model (C-SVC, nu-SVC, epsilon-SVR, or nu-SVR) or string path to a saved model. input_names: str | [str] Name of the input column(s). If a single string is used (the default) the input will be an ar...
[ "Convert", "a", "LIBSVM", "model", "to", "Core", "ML", "format", "." ]
python
train
woolfson-group/isambard
isambard/ampal/non_canonical.py
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/non_canonical.py#L16-L66
def convert_pro_to_hyp(pro): """Converts a pro residue to a hydroxypro residue. All metadata associated with the original pro will be lost i.e. tags. As a consequence, it is advisable to relabel all atoms in the structure in order to make them contiguous. Parameters ---------- pro: ampal.R...
[ "def", "convert_pro_to_hyp", "(", "pro", ")", ":", "with", "open", "(", "str", "(", "REF_PATH", "/", "'hydroxyproline_ref_1bkv_0_6.pickle'", ")", ",", "'rb'", ")", "as", "inf", ":", "hyp_ref", "=", "pickle", ".", "load", "(", "inf", ")", "align_nab", "(", ...
Converts a pro residue to a hydroxypro residue. All metadata associated with the original pro will be lost i.e. tags. As a consequence, it is advisable to relabel all atoms in the structure in order to make them contiguous. Parameters ---------- pro: ampal.Residue The proline residue t...
[ "Converts", "a", "pro", "residue", "to", "a", "hydroxypro", "residue", "." ]
python
train
thefab/tornadis
tornadis/utils.py
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/utils.py#L108-L120
def _done_callback(self, wrapped): """Internal "done callback" to set the result of the object. The result of the object if forced by the wrapped future. So this internal callback must be called when the wrapped future is ready. Args: wrapped (Future): the wrapped Future ob...
[ "def", "_done_callback", "(", "self", ",", "wrapped", ")", ":", "if", "wrapped", ".", "exception", "(", ")", ":", "self", ".", "set_exception", "(", "wrapped", ".", "exception", "(", ")", ")", "else", ":", "self", ".", "set_result", "(", "wrapped", "."...
Internal "done callback" to set the result of the object. The result of the object if forced by the wrapped future. So this internal callback must be called when the wrapped future is ready. Args: wrapped (Future): the wrapped Future object
[ "Internal", "done", "callback", "to", "set", "the", "result", "of", "the", "object", "." ]
python
train
FujiMakoto/IPS-Vagrant
ips_vagrant/downloaders/downloader.py
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/downloaders/downloader.py#L97-L116
def get(self, version, use_cache=True): """ Get the filepath to the specified version (downloading it in the process if necessary) @type version: IpsMeta @param use_cache: Use cached version downloads if available @type use_cache: bool @rtype: str """ ...
[ "def", "get", "(", "self", ",", "version", ",", "use_cache", "=", "True", ")", ":", "self", ".", "log", ".", "info", "(", "'Retrieving %s version %s'", ",", "self", ".", "meta_name", ",", "version", ".", "version", ")", "if", "version", ".", "filepath", ...
Get the filepath to the specified version (downloading it in the process if necessary) @type version: IpsMeta @param use_cache: Use cached version downloads if available @type use_cache: bool @rtype: str
[ "Get", "the", "filepath", "to", "the", "specified", "version", "(", "downloading", "it", "in", "the", "process", "if", "necessary", ")" ]
python
train
hobson/aima
aima/search.py
https://github.com/hobson/aima/blob/3572b2fb92039b4a1abe384be8545560fbd3d470/aima/search.py#L613-L620
def print_boggle(board): "Print the board in a 2-d array." n2 = len(board); n = exact_sqrt(n2) for i in range(n2): if i % n == 0 and i > 0: print if board[i] == 'Q': print 'Qu', else: print str(board[i]) + ' ', print
[ "def", "print_boggle", "(", "board", ")", ":", "n2", "=", "len", "(", "board", ")", "n", "=", "exact_sqrt", "(", "n2", ")", "for", "i", "in", "range", "(", "n2", ")", ":", "if", "i", "%", "n", "==", "0", "and", "i", ">", "0", ":", "print", ...
Print the board in a 2-d array.
[ "Print", "the", "board", "in", "a", "2", "-", "d", "array", "." ]
python
valid
sammchardy/python-binance
binance/client.py
https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1565-L1594
def get_asset_balance(self, asset, **params): """Get current asset balance. https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-information-user_data :param asset: required :type asset: str :param recvWindow: the number of milliseconds ...
[ "def", "get_asset_balance", "(", "self", ",", "asset", ",", "*", "*", "params", ")", ":", "res", "=", "self", ".", "get_account", "(", "*", "*", "params", ")", "# find asset balance in list of balances", "if", "\"balances\"", "in", "res", ":", "for", "bal", ...
Get current asset balance. https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-information-user_data :param asset: required :type asset: str :param recvWindow: the number of milliseconds the request is valid for :type recvWindow: int ...
[ "Get", "current", "asset", "balance", "." ]
python
train
cltk/cltk
cltk/prosody/latin/syllabifier.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/prosody/latin/syllabifier.py#L306-L315
def _find_consonant_cluster(self, letters: List[str]) -> List[int]: """ Find clusters of consonants that do not contain a vowel. :param letters: :return: """ for idx, letter_group in enumerate(letters): if self._contains_consonants(letter_group) and not self._...
[ "def", "_find_consonant_cluster", "(", "self", ",", "letters", ":", "List", "[", "str", "]", ")", "->", "List", "[", "int", "]", ":", "for", "idx", ",", "letter_group", "in", "enumerate", "(", "letters", ")", ":", "if", "self", ".", "_contains_consonants...
Find clusters of consonants that do not contain a vowel. :param letters: :return:
[ "Find", "clusters", "of", "consonants", "that", "do", "not", "contain", "a", "vowel", ".", ":", "param", "letters", ":", ":", "return", ":" ]
python
train
spyder-ide/spyder
spyder/plugins/editor/panels/indentationguides.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/indentationguides.py#L32-L80
def paintEvent(self, event): """Override Qt method.""" painter = QPainter(self) color = QColor(self.color) color.setAlphaF(.5) painter.setPen(color) offset = self.editor.document().documentMargin() + \ self.editor.contentOffset().x() for _, line_numb...
[ "def", "paintEvent", "(", "self", ",", "event", ")", ":", "painter", "=", "QPainter", "(", "self", ")", "color", "=", "QColor", "(", "self", ".", "color", ")", "color", ".", "setAlphaF", "(", ".5", ")", "painter", ".", "setPen", "(", "color", ")", ...
Override Qt method.
[ "Override", "Qt", "method", "." ]
python
train
radjkarl/fancyWidgets
DUMP/pyqtgraphBased/parametertree/parameterTypes.py
https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/DUMP/pyqtgraphBased/parametertree/parameterTypes.py#L287-L303
def optsChanged(self, param, opts): """Called when any options are changed that are not name, value, default, or limits""" # print "opts changed:", opts ParameterItem.optsChanged(self, param, opts) w = self.widget if 'readonly' in opts: self.updateDefaultBtn()...
[ "def", "optsChanged", "(", "self", ",", "param", ",", "opts", ")", ":", "# print \"opts changed:\", opts", "ParameterItem", ".", "optsChanged", "(", "self", ",", "param", ",", "opts", ")", "w", "=", "self", ".", "widget", "if", "'readonly'", "in", "opts", ...
Called when any options are changed that are not name, value, default, or limits
[ "Called", "when", "any", "options", "are", "changed", "that", "are", "not", "name", "value", "default", "or", "limits" ]
python
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1986-L2000
def GetName(self, number): """Retrieves the name of an enumeration value by number. Args: number (int): number. Returns: str: name of the enumeration value or None if no corresponding enumeration value was found. """ value = self._data_type_definition.values_per_number.get(nu...
[ "def", "GetName", "(", "self", ",", "number", ")", ":", "value", "=", "self", ".", "_data_type_definition", ".", "values_per_number", ".", "get", "(", "number", ",", "None", ")", "if", "not", "value", ":", "return", "None", "return", "value", ".", "name"...
Retrieves the name of an enumeration value by number. Args: number (int): number. Returns: str: name of the enumeration value or None if no corresponding enumeration value was found.
[ "Retrieves", "the", "name", "of", "an", "enumeration", "value", "by", "number", "." ]
python
train
quantmind/pulsar
docs/_ext/sphinxtogithub.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/docs/_ext/sphinxtogithub.py#L288-L292
def setup(app): "Setup function for Sphinx Extension" app.add_config_value("sphinx_to_github", True, '') app.add_config_value("sphinx_to_github_verbose", True, '') app.connect("build-finished", sphinx_extension)
[ "def", "setup", "(", "app", ")", ":", "app", ".", "add_config_value", "(", "\"sphinx_to_github\"", ",", "True", ",", "''", ")", "app", ".", "add_config_value", "(", "\"sphinx_to_github_verbose\"", ",", "True", ",", "''", ")", "app", ".", "connect", "(", "\...
Setup function for Sphinx Extension
[ "Setup", "function", "for", "Sphinx", "Extension" ]
python
train
hvac/hvac
hvac/v1/__init__.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/v1/__init__.py#L647-L673
def auth_ec2(self, pkcs7, nonce=None, role=None, use_token=True, mount_point='aws-ec2'): """POST /auth/<mount point>/login :param pkcs7: PKCS#7 version of an AWS Instance Identity Document from the EC2 Metadata Service. :type pkcs7: str. :param nonce: Optional nonce returned as part of ...
[ "def", "auth_ec2", "(", "self", ",", "pkcs7", ",", "nonce", "=", "None", ",", "role", "=", "None", ",", "use_token", "=", "True", ",", "mount_point", "=", "'aws-ec2'", ")", ":", "params", "=", "{", "'pkcs7'", ":", "pkcs7", "}", "if", "nonce", ":", ...
POST /auth/<mount point>/login :param pkcs7: PKCS#7 version of an AWS Instance Identity Document from the EC2 Metadata Service. :type pkcs7: str. :param nonce: Optional nonce returned as part of the original authentication request. Not required if the backend has "allow_instance_mig...
[ "POST", "/", "auth", "/", "<mount", "point", ">", "/", "login" ]
python
train
balloob/pychromecast
pychromecast/controllers/multizone.py
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L68-L76
def multizone_member_added(self, member_uuid): """Handle added audio group member.""" casts = self._casts if member_uuid not in casts: casts[member_uuid] = {'listeners': [], 'groups': set()} casts[member_uuid]['groups'].add(self._group_uuid) ...
[ "def", "multizone_member_added", "(", "self", ",", "member_uuid", ")", ":", "casts", "=", "self", ".", "_casts", "if", "member_uuid", "not", "in", "casts", ":", "casts", "[", "member_uuid", "]", "=", "{", "'listeners'", ":", "[", "]", ",", "'groups'", ":...
Handle added audio group member.
[ "Handle", "added", "audio", "group", "member", "." ]
python
train
PyCQA/astroid
astroid/as_string.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/as_string.py#L615-L623
def _import_string(names): """return a list of (name, asname) formatted as a string""" _names = [] for name, asname in names: if asname is not None: _names.append("%s as %s" % (name, asname)) else: _names.append(name) return ", ".join(_names)
[ "def", "_import_string", "(", "names", ")", ":", "_names", "=", "[", "]", "for", "name", ",", "asname", "in", "names", ":", "if", "asname", "is", "not", "None", ":", "_names", ".", "append", "(", "\"%s as %s\"", "%", "(", "name", ",", "asname", ")", ...
return a list of (name, asname) formatted as a string
[ "return", "a", "list", "of", "(", "name", "asname", ")", "formatted", "as", "a", "string" ]
python
train
sorgerlab/indra
indra/assemblers/pysb/bmi_wrapper.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L203-L215
def get_input_var_names(self): """Return a list of variables names that can be set as input. Returns ------- var_names : list[str] A list of variable names that can be set from the outside """ in_vars = copy.copy(self.input_vars) for idx, var in enume...
[ "def", "get_input_var_names", "(", "self", ")", ":", "in_vars", "=", "copy", ".", "copy", "(", "self", ".", "input_vars", ")", "for", "idx", ",", "var", "in", "enumerate", "(", "in_vars", ")", ":", "if", "self", ".", "_map_in_out", "(", "var", ")", "...
Return a list of variables names that can be set as input. Returns ------- var_names : list[str] A list of variable names that can be set from the outside
[ "Return", "a", "list", "of", "variables", "names", "that", "can", "be", "set", "as", "input", "." ]
python
train
Komnomnomnom/swigibpy
swigibpy.py
https://github.com/Komnomnomnom/swigibpy/blob/cfd307fdbfaffabc69a2dc037538d7e34a8b8daf/swigibpy.py#L1557-L1559
def exerciseOptions(self, tickerId, contract, exerciseAction, exerciseQuantity, account, override): """exerciseOptions(EClientSocketBase self, TickerId tickerId, Contract contract, int exerciseAction, int exerciseQuantity, IBString const & account, int override)""" return _swigibpy.EClientSocketBase_exe...
[ "def", "exerciseOptions", "(", "self", ",", "tickerId", ",", "contract", ",", "exerciseAction", ",", "exerciseQuantity", ",", "account", ",", "override", ")", ":", "return", "_swigibpy", ".", "EClientSocketBase_exerciseOptions", "(", "self", ",", "tickerId", ",", ...
exerciseOptions(EClientSocketBase self, TickerId tickerId, Contract contract, int exerciseAction, int exerciseQuantity, IBString const & account, int override)
[ "exerciseOptions", "(", "EClientSocketBase", "self", "TickerId", "tickerId", "Contract", "contract", "int", "exerciseAction", "int", "exerciseQuantity", "IBString", "const", "&", "account", "int", "override", ")" ]
python
train
priestc/giotto
giotto/views/__init__.py
https://github.com/priestc/giotto/blob/d4c26380caefa7745bb27135e315de830f7254d3/giotto/views/__init__.py#L219-L228
def jinja_template(template_name, name='data', mimetype="text/html"): """ Meta-renderer for rendering jinja templates """ def jinja_renderer(result, errors): template = get_jinja_template(template_name) context = {name: result or Mock(), 'errors': errors, 'enumerate': enumerate} ...
[ "def", "jinja_template", "(", "template_name", ",", "name", "=", "'data'", ",", "mimetype", "=", "\"text/html\"", ")", ":", "def", "jinja_renderer", "(", "result", ",", "errors", ")", ":", "template", "=", "get_jinja_template", "(", "template_name", ")", "cont...
Meta-renderer for rendering jinja templates
[ "Meta", "-", "renderer", "for", "rendering", "jinja", "templates" ]
python
train
warner/magic-wormhole
src/wormhole/xfer_util.py
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/xfer_util.py#L10-L75
def receive(reactor, appid, relay_url, code, use_tor=False, launch_tor=False, tor_control_port=None, on_code=None): """ This is a convenience API which returns a Deferred that callbacks with a single chunk of data from anoth...
[ "def", "receive", "(", "reactor", ",", "appid", ",", "relay_url", ",", "code", ",", "use_tor", "=", "False", ",", "launch_tor", "=", "False", ",", "tor_control_port", "=", "None", ",", "on_code", "=", "None", ")", ":", "tor", "=", "None", "if", "use_to...
This is a convenience API which returns a Deferred that callbacks with a single chunk of data from another wormhole (and then closes the wormhole). Under the hood, it's just using an instance returned from :func:`wormhole.wormhole`. This is similar to the `wormhole receive` command. :param unicode ...
[ "This", "is", "a", "convenience", "API", "which", "returns", "a", "Deferred", "that", "callbacks", "with", "a", "single", "chunk", "of", "data", "from", "another", "wormhole", "(", "and", "then", "closes", "the", "wormhole", ")", ".", "Under", "the", "hood...
python
train
klavinslab/coral
coral/database/_yeast.py
https://github.com/klavinslab/coral/blob/17f59591211562a59a051f474cd6cecba4829df9/coral/database/_yeast.py#L6-L83
def fetch_yeast_locus_sequence(locus_name, flanking_size=0): '''Acquire a sequence from SGD http://www.yeastgenome.org. :param locus_name: Common name or systematic name for the locus (e.g. ACT1 or YFL039C). :type locus_name: str :param flanking_size: The length of flanking DNA (...
[ "def", "fetch_yeast_locus_sequence", "(", "locus_name", ",", "flanking_size", "=", "0", ")", ":", "from", "intermine", ".", "webservice", "import", "Service", "service", "=", "Service", "(", "'http://yeastmine.yeastgenome.org/yeastmine/service'", ")", "# Get a new query o...
Acquire a sequence from SGD http://www.yeastgenome.org. :param locus_name: Common name or systematic name for the locus (e.g. ACT1 or YFL039C). :type locus_name: str :param flanking_size: The length of flanking DNA (on each side) to return :type flanking_size: int
[ "Acquire", "a", "sequence", "from", "SGD", "http", ":", "//", "www", ".", "yeastgenome", ".", "org", "." ]
python
train
fopina/tgbotplug
tgbot/botapi.py
https://github.com/fopina/tgbotplug/blob/c115733b03f2e23ddcdecfce588d1a6a1e5bde91/tgbot/botapi.py#L1537-L1588
def send_video(chat_id, video, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, **kwargs): """ Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). :param chat_id: Unique identifier for the m...
[ "def", "send_video", "(", "chat_id", ",", "video", ",", "duration", "=", "None", ",", "caption", "=", "None", ",", "reply_to_message_id", "=", "None", ",", "reply_markup", "=", "None", ",", "*", "*", "kwargs", ")", ":", "files", "=", "None", "if", "isi...
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). :param chat_id: Unique identifier for the message recipient — User or GroupChat id :param video: Video to send. You can either pass a file_id as String to resend a video that is a...
[ "Use", "this", "method", "to", "send", "video", "files", "Telegram", "clients", "support", "mp4", "videos", "(", "other", "formats", "may", "be", "sent", "as", "Document", ")", "." ]
python
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L1598-L1612
def _inverse_i(self, y, i): """return inverse of y in component i""" lb = self._lb[self._index(i)] ub = self._ub[self._index(i)] al = self._al[self._index(i)] au = self._au[self._index(i)] if 1 < 3: if not lb <= y <= ub: raise ValueError('argum...
[ "def", "_inverse_i", "(", "self", ",", "y", ",", "i", ")", ":", "lb", "=", "self", ".", "_lb", "[", "self", ".", "_index", "(", "i", ")", "]", "ub", "=", "self", ".", "_ub", "[", "self", ".", "_index", "(", "i", ")", "]", "al", "=", "self",...
return inverse of y in component i
[ "return", "inverse", "of", "y", "in", "component", "i" ]
python
train
BDNYC/astrodbkit
astrodbkit/astrodb.py
https://github.com/BDNYC/astrodbkit/blob/02c03c5e91aa7c7b0f3b5fa95bcf71e33ffcee09/astrodbkit/astrodb.py#L1416-L1495
def plot_spectrum(self, spectrum_id, table='spectra', column='spectrum', overplot=False, color='b', norm=False): """ Plots a spectrum from the given column and table Parameters ---------- spectrum_id: int The id from the table of the spectrum to plot. overplo...
[ "def", "plot_spectrum", "(", "self", ",", "spectrum_id", ",", "table", "=", "'spectra'", ",", "column", "=", "'spectrum'", ",", "overplot", "=", "False", ",", "color", "=", "'b'", ",", "norm", "=", "False", ")", ":", "# TODO: Look into axes number formats. As ...
Plots a spectrum from the given column and table Parameters ---------- spectrum_id: int The id from the table of the spectrum to plot. overplot: bool Overplot the spectrum table: str The table from which the plot is being made column: ...
[ "Plots", "a", "spectrum", "from", "the", "given", "column", "and", "table" ]
python
train
apple/turicreate
src/unity/python/turicreate/toolkits/classifier/boosted_trees_classifier.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/classifier/boosted_trees_classifier.py#L450-L638
def create(dataset, target, features=None, max_iterations=10, validation_set='auto', class_weights = None, max_depth=6, step_size=0.3, min_loss_reduction=0.0, min_child_weight=0.1, row_subsample=1.0, column_subsample=1.0, verbose=True, ...
[ "def", "create", "(", "dataset", ",", "target", ",", "features", "=", "None", ",", "max_iterations", "=", "10", ",", "validation_set", "=", "'auto'", ",", "class_weights", "=", "None", ",", "max_depth", "=", "6", ",", "step_size", "=", "0.3", ",", "min_l...
Create a (binary or multi-class) classifier model of type :class:`~turicreate.boosted_trees_classifier.BoostedTreesClassifier` using gradient boosted trees (sometimes known as GBMs). Parameters ---------- dataset : SFrame A training dataset containing feature columns and a target column. ...
[ "Create", "a", "(", "binary", "or", "multi", "-", "class", ")", "classifier", "model", "of", "type", ":", "class", ":", "~turicreate", ".", "boosted_trees_classifier", ".", "BoostedTreesClassifier", "using", "gradient", "boosted", "trees", "(", "sometimes", "kno...
python
train
pywbem/pywbem
attic/cim_provider.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/attic/cim_provider.py#L661-L676
def MI_deleteInstance(self, env, instanceName): # pylint: disable=invalid-name """Delete a CIM instance Implements the WBEM operation DeleteInstance in terms of the delete_instance method. A derived class will not normally ove...
[ "def", "MI_deleteInstance", "(", "self", ",", "env", ",", "instanceName", ")", ":", "# pylint: disable=invalid-name", "logger", "=", "env", ".", "get_logger", "(", ")", "logger", ".", "log_debug", "(", "'CIMProvider MI_deleteInstance called...'", ")", "self", ".", ...
Delete a CIM instance Implements the WBEM operation DeleteInstance in terms of the delete_instance method. A derived class will not normally override this method.
[ "Delete", "a", "CIM", "instance" ]
python
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/session_entity_types_client.py
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/session_entity_types_client.py#L484-L537
def delete_session_entity_type( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Deletes the specified session entity type. Example: >>> import ...
[ "def", "delete_session_entity_type", "(", "self", ",", "name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ","...
Deletes the specified session entity type. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.SessionEntityTypesClient() >>> >>> name = client.session_entity_type_path('[PROJECT]', '[SESSION]', '[ENTITY_TYPE]') >>> ...
[ "Deletes", "the", "specified", "session", "entity", "type", "." ]
python
train
openstack/networking-cisco
networking_cisco/plugins/cisco/cfg_agent/service_helpers/routing_svc_helper.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/cfg_agent/service_helpers/routing_svc_helper.py#L317-L351
def collect_state(self, configurations): """Collect state from this helper. A set of attributes which summarizes the state of the routers and configurations managed by this config agent. :param configurations: dict of configuration values :return dict of updated configuration va...
[ "def", "collect_state", "(", "self", ",", "configurations", ")", ":", "num_ex_gw_ports", "=", "0", "num_interfaces", "=", "0", "num_floating_ips", "=", "0", "router_infos", "=", "self", ".", "router_info", ".", "values", "(", ")", "num_routers", "=", "len", ...
Collect state from this helper. A set of attributes which summarizes the state of the routers and configurations managed by this config agent. :param configurations: dict of configuration values :return dict of updated configuration values
[ "Collect", "state", "from", "this", "helper", "." ]
python
train
leancloud/python-sdk
leancloud/query.py
https://github.com/leancloud/python-sdk/blob/fea3240257ce65e6a32c7312a5cee1f94a51a587/leancloud/query.py#L636-L648
def within_kilometers(self, key, point, max_distance, min_distance=None): """ 增加查询条件,限制返回结果指定字段值的位置在某点的一段距离之内。 :param key: 查询条件字段名 :param point: 查询地理位置 :param max_distance: 最大距离限定(千米) :param min_distance: 最小距离限定(千米) :rtype: Query """ if min_distan...
[ "def", "within_kilometers", "(", "self", ",", "key", ",", "point", ",", "max_distance", ",", "min_distance", "=", "None", ")", ":", "if", "min_distance", "is", "not", "None", ":", "min_distance", "=", "min_distance", "/", "6371.0", "return", "self", ".", "...
增加查询条件,限制返回结果指定字段值的位置在某点的一段距离之内。 :param key: 查询条件字段名 :param point: 查询地理位置 :param max_distance: 最大距离限定(千米) :param min_distance: 最小距离限定(千米) :rtype: Query
[ "增加查询条件,限制返回结果指定字段值的位置在某点的一段距离之内。" ]
python
train
b3j0f/aop
b3j0f/aop/advice/core.py
https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L452-L471
def _unweave(target, advices, pointcut, ctx, depth, depth_predicate): """Unweave deeply advices in target.""" # if weaving has to be done if pointcut is None or pointcut(target): # do something only if target is intercepted if is_intercepted(target): _remove_advices(target=targe...
[ "def", "_unweave", "(", "target", ",", "advices", ",", "pointcut", ",", "ctx", ",", "depth", ",", "depth_predicate", ")", ":", "# if weaving has to be done", "if", "pointcut", "is", "None", "or", "pointcut", "(", "target", ")", ":", "# do something only if targe...
Unweave deeply advices in target.
[ "Unweave", "deeply", "advices", "in", "target", "." ]
python
train
yyuu/botornado
boto/cloudfront/distribution.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/cloudfront/distribution.py#L403-L414
def get_objects(self): """ Return a list of all content objects in this distribution. :rtype: list of :class:`boto.cloudfront.object.Object` :return: The content objects """ bucket = self._get_bucket() objs = [] for key in bucket: objs...
[ "def", "get_objects", "(", "self", ")", ":", "bucket", "=", "self", ".", "_get_bucket", "(", ")", "objs", "=", "[", "]", "for", "key", "in", "bucket", ":", "objs", ".", "append", "(", "key", ")", "return", "objs" ]
Return a list of all content objects in this distribution. :rtype: list of :class:`boto.cloudfront.object.Object` :return: The content objects
[ "Return", "a", "list", "of", "all", "content", "objects", "in", "this", "distribution", ".", ":", "rtype", ":", "list", "of", ":", "class", ":", "boto", ".", "cloudfront", ".", "object", ".", "Object", ":", "return", ":", "The", "content", "objects" ]
python
train
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9851-L9879
def clean_offsetscounts(offsets, counts): """Return cleaned offsets and byte counts. Remove zero offsets and counts. Use to sanitize StripOffsets and StripByteCounts tag values. """ # TODO: cythonize this offsets = list(offsets) counts = list(counts) size = len(offsets) if size != ...
[ "def", "clean_offsetscounts", "(", "offsets", ",", "counts", ")", ":", "# TODO: cythonize this", "offsets", "=", "list", "(", "offsets", ")", "counts", "=", "list", "(", "counts", ")", "size", "=", "len", "(", "offsets", ")", "if", "size", "!=", "len", "...
Return cleaned offsets and byte counts. Remove zero offsets and counts. Use to sanitize StripOffsets and StripByteCounts tag values.
[ "Return", "cleaned", "offsets", "and", "byte", "counts", "." ]
python
train
475Cumulus/TBone
tbone/resources/mongo.py
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/mongo.py#L229-L240
def build_sort(self, **kwargs): ''' Break url parameters and turn into sort arguments ''' sort = [] order = kwargs.get('order_by', None) if order: if type(order) is list: order = order[0] if order[:1] == '-': sort.append((order[1:],...
[ "def", "build_sort", "(", "self", ",", "*", "*", "kwargs", ")", ":", "sort", "=", "[", "]", "order", "=", "kwargs", ".", "get", "(", "'order_by'", ",", "None", ")", "if", "order", ":", "if", "type", "(", "order", ")", "is", "list", ":", "order", ...
Break url parameters and turn into sort arguments
[ "Break", "url", "parameters", "and", "turn", "into", "sort", "arguments" ]
python
train
fedora-python/pyp2rpm
pyp2rpm/utils.py
https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L44-L56
def memoize_by_args(func): """Memoizes return value of a func based on args.""" memory = {} @functools.wraps(func) def memoized(*args): if args not in memory.keys(): value = func(*args) memory[args] = value return memory[args] return memoized
[ "def", "memoize_by_args", "(", "func", ")", ":", "memory", "=", "{", "}", "@", "functools", ".", "wraps", "(", "func", ")", "def", "memoized", "(", "*", "args", ")", ":", "if", "args", "not", "in", "memory", ".", "keys", "(", ")", ":", "value", "...
Memoizes return value of a func based on args.
[ "Memoizes", "return", "value", "of", "a", "func", "based", "on", "args", "." ]
python
train
yodle/docker-registry-client
docker_registry_client/_BaseClient.py
https://github.com/yodle/docker-registry-client/blob/8abf6b0200a68bed986f698dcbf02d444257b75c/docker_registry_client/_BaseClient.py#L229-L269
def _http_response(self, url, method, data=None, content_type=None, schema=None, **kwargs): """url -> full target url method -> method from requests data -> request body kwargs -> url formatting args """ if schema is None: sche...
[ "def", "_http_response", "(", "self", ",", "url", ",", "method", ",", "data", "=", "None", ",", "content_type", "=", "None", ",", "schema", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "schema", "is", "None", ":", "schema", "=", "self", "....
url -> full target url method -> method from requests data -> request body kwargs -> url formatting args
[ "url", "-", ">", "full", "target", "url", "method", "-", ">", "method", "from", "requests", "data", "-", ">", "request", "body", "kwargs", "-", ">", "url", "formatting", "args" ]
python
train
DerwenAI/pytextrank
pytextrank/pytextrank.py
https://github.com/DerwenAI/pytextrank/blob/181ea41375d29922eb96768cf6550e57a77a0c95/pytextrank/pytextrank.py#L414-L429
def enumerate_chunks (phrase, spacy_nlp): """ iterate through the noun phrases """ if (len(phrase) > 1): found = False text = " ".join([rl.text for rl in phrase]) doc = spacy_nlp(text.strip(), parse=True) for np in doc.noun_chunks: if np.text != text: ...
[ "def", "enumerate_chunks", "(", "phrase", ",", "spacy_nlp", ")", ":", "if", "(", "len", "(", "phrase", ")", ">", "1", ")", ":", "found", "=", "False", "text", "=", "\" \"", ".", "join", "(", "[", "rl", ".", "text", "for", "rl", "in", "phrase", "]...
iterate through the noun phrases
[ "iterate", "through", "the", "noun", "phrases" ]
python
valid
zyga/morris
morris/__init__.py
https://github.com/zyga/morris/blob/7cd6da662c8c95b93b5fb8bb25eae8686becf31a/morris/__init__.py#L828-L854
def assertSignalOrdering(self, *expected_events): """ Assert that a signals were fired in a specific sequence. :param expected_events: A (varadic) list of events describing the signals that were fired Each element is a 3-tuple (signal, args, kwargs) that describes ...
[ "def", "assertSignalOrdering", "(", "self", ",", "*", "expected_events", ")", ":", "expected_order", "=", "[", "self", ".", "_events_seen", ".", "index", "(", "event", ")", "for", "event", "in", "expected_events", "]", "actual_order", "=", "sorted", "(", "ex...
Assert that a signals were fired in a specific sequence. :param expected_events: A (varadic) list of events describing the signals that were fired Each element is a 3-tuple (signal, args, kwargs) that describes the event. .. note:: If you are using :meth...
[ "Assert", "that", "a", "signals", "were", "fired", "in", "a", "specific", "sequence", "." ]
python
train
mongodb/mongo-python-driver
pymongo/collection.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/collection.py#L1877-L1974
def create_index(self, keys, session=None, **kwargs): """Creates an index on this collection. Takes either a single key or a list of (key, direction) pairs. The key(s) must be an instance of :class:`basestring` (:class:`str` in python 3), and the direction(s) must be one of (:da...
[ "def", "create_index", "(", "self", ",", "keys", ",", "session", "=", "None", ",", "*", "*", "kwargs", ")", ":", "keys", "=", "helpers", ".", "_index_list", "(", "keys", ")", "name", "=", "kwargs", ".", "setdefault", "(", "\"name\"", ",", "helpers", ...
Creates an index on this collection. Takes either a single key or a list of (key, direction) pairs. The key(s) must be an instance of :class:`basestring` (:class:`str` in python 3), and the direction(s) must be one of (:data:`~pymongo.ASCENDING`, :data:`~pymongo.DESCENDING`, :da...
[ "Creates", "an", "index", "on", "this", "collection", "." ]
python
train