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
Unbabel/unbabel-py
unbabel/api.py
https://github.com/Unbabel/unbabel-py/blob/3bd6397174e184d89d2a11149d87be5d12570c64/unbabel/api.py#L451-L476
def get_language_pairs(self, train_langs=None): ''' Returns the language pairs available on unbabel ''' if train_langs is None: result = self.api_call('language_pair/') else: result = self.api_call( 'language_pair/?train_langs={}'.forma...
[ "def", "get_language_pairs", "(", "self", ",", "train_langs", "=", "None", ")", ":", "if", "train_langs", "is", "None", ":", "result", "=", "self", ".", "api_call", "(", "'language_pair/'", ")", "else", ":", "result", "=", "self", ".", "api_call", "(", "...
Returns the language pairs available on unbabel
[ "Returns", "the", "language", "pairs", "available", "on", "unbabel" ]
python
train
adamziel/python_translate
python_translate/translations.py
https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/translations.py#L114-L130
def get(self, id, domain='messages'): """ Gets a message translation. @rtype: str @return: The message translation """ assert isinstance(id, (str, unicode)) assert isinstance(domain, (str, unicode)) if self.defines(id, domain): return self.me...
[ "def", "get", "(", "self", ",", "id", ",", "domain", "=", "'messages'", ")", ":", "assert", "isinstance", "(", "id", ",", "(", "str", ",", "unicode", ")", ")", "assert", "isinstance", "(", "domain", ",", "(", "str", ",", "unicode", ")", ")", "if", ...
Gets a message translation. @rtype: str @return: The message translation
[ "Gets", "a", "message", "translation", "." ]
python
train
gabstopper/smc-python
smc/core/interfaces.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/interfaces.py#L143-L156
def set_primary_heartbeat(self, interface_id): """ Set this interface as the primary heartbeat for this engine. This will 'unset' the current primary heartbeat and move to specified interface_id. Clusters and Master NGFW Engines only. :param str,int interface_id...
[ "def", "set_primary_heartbeat", "(", "self", ",", "interface_id", ")", ":", "self", ".", "interface", ".", "set_unset", "(", "interface_id", ",", "'primary_heartbeat'", ")", "self", ".", "_engine", ".", "update", "(", ")" ]
Set this interface as the primary heartbeat for this engine. This will 'unset' the current primary heartbeat and move to specified interface_id. Clusters and Master NGFW Engines only. :param str,int interface_id: interface specified for primary mgmt :raises InterfaceNot...
[ "Set", "this", "interface", "as", "the", "primary", "heartbeat", "for", "this", "engine", ".", "This", "will", "unset", "the", "current", "primary", "heartbeat", "and", "move", "to", "specified", "interface_id", ".", "Clusters", "and", "Master", "NGFW", "Engin...
python
train
quantumlib/Cirq
cirq/devices/noise_model.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/devices/noise_model.py#L75-L92
def noisy_moment(self, moment: 'cirq.Moment', system_qubits: Sequence['cirq.Qid']) -> 'cirq.OP_TREE': """Adds noise to the operations from a moment. Args: moment: The moment to add noise to. system_qubits: A list of all qubits in the system. Returns...
[ "def", "noisy_moment", "(", "self", ",", "moment", ":", "'cirq.Moment'", ",", "system_qubits", ":", "Sequence", "[", "'cirq.Qid'", "]", ")", "->", "'cirq.OP_TREE'", ":", "if", "not", "hasattr", "(", "self", ".", "noisy_moments", ",", "'_not_overridden'", ")", ...
Adds noise to the operations from a moment. Args: moment: The moment to add noise to. system_qubits: A list of all qubits in the system. Returns: An OP_TREE corresponding to the noisy operations for the moment.
[ "Adds", "noise", "to", "the", "operations", "from", "a", "moment", "." ]
python
train
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L60-L74
def by_id(cls, semantictag_id, autoflush=True): '''Return the semantic tag with the given id, or None. :param semantictag_id: the id of the semantic tag to return :type semantictag_id: string :returns: the semantic tag with the given id, or None if there is no tag with that id :rtype: ckan.model.semantic...
[ "def", "by_id", "(", "cls", ",", "semantictag_id", ",", "autoflush", "=", "True", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "SemanticTag", ")", ".", "filter", "(", "SemanticTag", ".", "id", "==", "semantictag_id", ")", "query", ...
Return the semantic tag with the given id, or None. :param semantictag_id: the id of the semantic tag to return :type semantictag_id: string :returns: the semantic tag with the given id, or None if there is no tag with that id :rtype: ckan.model.semantictag.SemanticTag # TODO check this
[ "Return", "the", "semantic", "tag", "with", "the", "given", "id", "or", "None", "." ]
python
train
bicv/LogGabor
LogGabor/LogGabor.py
https://github.com/bicv/LogGabor/blob/dea9560d8752cc9aa040ac3fd895cf9bb72b61f4/LogGabor/LogGabor.py#L61-L120
def golden_pyramid(self, z, mask=False, spiral=True, fig_width=13): """ The Golden Laplacian Pyramid. To represent the edges of the image at different levels, we may use a simple recursive approach constructing progressively a set of images of decreasing sizes, from a base to the summit of a pyr...
[ "def", "golden_pyramid", "(", "self", ",", "z", ",", "mask", "=", "False", ",", "spiral", "=", "True", ",", "fig_width", "=", "13", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "opts", "=", "{", "'vmin'", ":", "0.", ",", "'vmax'", ...
The Golden Laplacian Pyramid. To represent the edges of the image at different levels, we may use a simple recursive approach constructing progressively a set of images of decreasing sizes, from a base to the summit of a pyramid. Using simple down-scaling and up-scaling operators we may approximate well a Lapla...
[ "The", "Golden", "Laplacian", "Pyramid", ".", "To", "represent", "the", "edges", "of", "the", "image", "at", "different", "levels", "we", "may", "use", "a", "simple", "recursive", "approach", "constructing", "progressively", "a", "set", "of", "images", "of", ...
python
test
tensorflow/tensor2tensor
tensor2tensor/insights/graph.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/insights/graph.py#L112-L126
def get_vertex(self, key): """Returns or Creates a Vertex mapped by key. Args: key: A string reference for a vertex. May refer to a new Vertex in which case it will be created. Returns: A the Vertex mapped to by key. """ if key in self.vertex_map: return self.vertex_map[ke...
[ "def", "get_vertex", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "vertex_map", ":", "return", "self", ".", "vertex_map", "[", "key", "]", "vertex", "=", "self", ".", "new_vertex", "(", ")", "self", ".", "vertex_map", "[", "key"...
Returns or Creates a Vertex mapped by key. Args: key: A string reference for a vertex. May refer to a new Vertex in which case it will be created. Returns: A the Vertex mapped to by key.
[ "Returns", "or", "Creates", "a", "Vertex", "mapped", "by", "key", "." ]
python
train
frictionlessdata/datapackage-py
datapackage/pushpull.py
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/pushpull.py#L202-L229
def _convert_schemas(mapping, schemas): """Convert schemas to be compatible with storage schemas. Foreign keys related operations. Args: mapping (dict): mapping between resource name and table name schemas (list): schemas Raises: ValueError: if there is no resource ...
[ "def", "_convert_schemas", "(", "mapping", ",", "schemas", ")", ":", "schemas", "=", "deepcopy", "(", "schemas", ")", "for", "schema", "in", "schemas", ":", "for", "fk", "in", "schema", ".", "get", "(", "'foreignKeys'", ",", "[", "]", ")", ":", "resour...
Convert schemas to be compatible with storage schemas. Foreign keys related operations. Args: mapping (dict): mapping between resource name and table name schemas (list): schemas Raises: ValueError: if there is no resource for some foreign key in given mapping Ret...
[ "Convert", "schemas", "to", "be", "compatible", "with", "storage", "schemas", "." ]
python
valid
connectordb/connectordb-python
connectordb/logger.py
https://github.com/connectordb/connectordb-python/blob/2092b0cb30898139a247176bcf433d5a4abde7cb/connectordb/logger.py#L272-L284
def start(self): """Start the logger background synchronization service. This allows you to not need to worry about syncing with ConnectorDB - you just insert into the Logger, and the Logger will by synced every syncperiod.""" with self.synclock: if self.syncthread is not No...
[ "def", "start", "(", "self", ")", ":", "with", "self", ".", "synclock", ":", "if", "self", ".", "syncthread", "is", "not", "None", ":", "logging", ".", "warn", "(", "\"Logger: Start called on a syncer that is already running\"", ")", "return", "self", ".", "sy...
Start the logger background synchronization service. This allows you to not need to worry about syncing with ConnectorDB - you just insert into the Logger, and the Logger will by synced every syncperiod.
[ "Start", "the", "logger", "background", "synchronization", "service", ".", "This", "allows", "you", "to", "not", "need", "to", "worry", "about", "syncing", "with", "ConnectorDB", "-", "you", "just", "insert", "into", "the", "Logger", "and", "the", "Logger", ...
python
test
pytroll/trollimage
trollimage/image.py
https://github.com/pytroll/trollimage/blob/d35a7665ad475ff230e457085523e21f2cd3f454/trollimage/image.py#L984-L1014
def stretch_linear(self, ch_nb, cutoffs=(0.005, 0.005)): """Stretch linearly the contrast of the current image on channel *ch_nb*, using *cutoffs* for left and right trimming. """ logger.debug("Perform a linear contrast stretch.") if((self.channels[ch_nb].size == np....
[ "def", "stretch_linear", "(", "self", ",", "ch_nb", ",", "cutoffs", "=", "(", "0.005", ",", "0.005", ")", ")", ":", "logger", ".", "debug", "(", "\"Perform a linear contrast stretch.\"", ")", "if", "(", "(", "self", ".", "channels", "[", "ch_nb", "]", "....
Stretch linearly the contrast of the current image on channel *ch_nb*, using *cutoffs* for left and right trimming.
[ "Stretch", "linearly", "the", "contrast", "of", "the", "current", "image", "on", "channel", "*", "ch_nb", "*", "using", "*", "cutoffs", "*", "for", "left", "and", "right", "trimming", "." ]
python
train
wadda/gps3
gps3/gps3.py
https://github.com/wadda/gps3/blob/91adcd7073b891b135b2a46d039ce2125cf09a09/gps3/gps3.py#L128-L133
def close(self): """turn off stream and close socket""" if self.streamSock: self.watch(enable=False) self.streamSock.close() self.streamSock = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "streamSock", ":", "self", ".", "watch", "(", "enable", "=", "False", ")", "self", ".", "streamSock", ".", "close", "(", ")", "self", ".", "streamSock", "=", "None" ]
turn off stream and close socket
[ "turn", "off", "stream", "and", "close", "socket" ]
python
train
alorence/pysvg-py3
pysvg/builders.py
https://github.com/alorence/pysvg-py3/blob/ce217a4da3ada44a71d3e2f391d37c67d95c724e/pysvg/builders.py#L23-L44
def createCircle(self, cx, cy, r, strokewidth=1, stroke='black', fill='none'): """ Creates a circle @type cx: string or int @param cx: starting x-coordinate @type cy: string or int @param cy: starting y-coordinate @type r: string or int @param r: ...
[ "def", "createCircle", "(", "self", ",", "cx", ",", "cy", ",", "r", ",", "strokewidth", "=", "1", ",", "stroke", "=", "'black'", ",", "fill", "=", "'none'", ")", ":", "style_dict", "=", "{", "'fill'", ":", "fill", ",", "'stroke-width'", ":", "strokew...
Creates a circle @type cx: string or int @param cx: starting x-coordinate @type cy: string or int @param cy: starting y-coordinate @type r: string or int @param r: radius @type strokewidth: string or int @param strokewidth: width of the pen use...
[ "Creates", "a", "circle" ]
python
train
gawel/irc3
irc3/__init__.py
https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L297-L301
def kick(self, channel, target, reason=None): """kick target from channel""" if reason: target += ' :' + reason self.send_line('KICK %s %s' % (channel, target), nowait=True)
[ "def", "kick", "(", "self", ",", "channel", ",", "target", ",", "reason", "=", "None", ")", ":", "if", "reason", ":", "target", "+=", "' :'", "+", "reason", "self", ".", "send_line", "(", "'KICK %s %s'", "%", "(", "channel", ",", "target", ")", ",", ...
kick target from channel
[ "kick", "target", "from", "channel" ]
python
train
openstax/cnx-easybake
cnxeasybake/oven.py
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L635-L675
def lookup(self, vtype, vname, target_id=None): """Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is retu...
[ "def", "lookup", "(", "self", ",", "vtype", ",", "vname", ",", "target_id", "=", "None", ")", ":", "nullvals", "=", "{", "'strings'", ":", "''", ",", "'counters'", ":", "0", ",", "'pending'", ":", "(", "None", ",", "None", ")", "}", "nullval", "=",...
Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is returned.
[ "Return", "value", "of", "vname", "from", "the", "variable", "store", "vtype", "." ]
python
train
ga4gh/ga4gh-client
ga4gh/client/client.py
https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/client.py#L568-L582
def search_continuous_sets(self, dataset_id): """ Returns an iterator over the ContinuousSets fulfilling the specified conditions from the specified Dataset. :param str dataset_id: The ID of the :class:`ga4gh.protocol.Dataset` of interest. :return: An iterator over t...
[ "def", "search_continuous_sets", "(", "self", ",", "dataset_id", ")", ":", "request", "=", "protocol", ".", "SearchContinuousSetsRequest", "(", ")", "request", ".", "dataset_id", "=", "dataset_id", "request", ".", "page_size", "=", "pb", ".", "int", "(", "self...
Returns an iterator over the ContinuousSets fulfilling the specified conditions from the specified Dataset. :param str dataset_id: The ID of the :class:`ga4gh.protocol.Dataset` of interest. :return: An iterator over the :class:`ga4gh.protocol.ContinuousSet` objects defin...
[ "Returns", "an", "iterator", "over", "the", "ContinuousSets", "fulfilling", "the", "specified", "conditions", "from", "the", "specified", "Dataset", "." ]
python
train
apache/incubator-heron
heron/tools/cli/src/python/result.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/cli/src/python/result.py#L94-L101
def add_context(self, err_context, succ_context=None): """ Prepend msg to add some context information :param pmsg: context info :return: None """ self.err_context = err_context self.succ_context = succ_context
[ "def", "add_context", "(", "self", ",", "err_context", ",", "succ_context", "=", "None", ")", ":", "self", ".", "err_context", "=", "err_context", "self", ".", "succ_context", "=", "succ_context" ]
Prepend msg to add some context information :param pmsg: context info :return: None
[ "Prepend", "msg", "to", "add", "some", "context", "information" ]
python
valid
chhantyal/sorl-thumbnail-async
thumbnail/__init__.py
https://github.com/chhantyal/sorl-thumbnail-async/blob/023d20aac79090a691d563dc26f558bb87239811/thumbnail/__init__.py#L9-L17
def get_thumbnail(file_, name): """ get_thumbnail version that uses aliasses defined in THUMBNAIL_OPTIONS_DICT """ options = settings.OPTIONS_DICT[name] opt = copy(options) geometry = opt.pop('geometry') return original_get_thumbnail(file_, geometry, **opt)
[ "def", "get_thumbnail", "(", "file_", ",", "name", ")", ":", "options", "=", "settings", ".", "OPTIONS_DICT", "[", "name", "]", "opt", "=", "copy", "(", "options", ")", "geometry", "=", "opt", ".", "pop", "(", "'geometry'", ")", "return", "original_get_t...
get_thumbnail version that uses aliasses defined in THUMBNAIL_OPTIONS_DICT
[ "get_thumbnail", "version", "that", "uses", "aliasses", "defined", "in", "THUMBNAIL_OPTIONS_DICT" ]
python
train
hollenstein/maspy
maspy/auxiliary.py
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/auxiliary.py#L115-L133
def openSafeReplace(filepath, mode='w+b'): """Context manager to open a temporary file and replace the original file on closing. """ tempfileName = None #Check if the filepath can be accessed and is writable before creating the #tempfile if not _isFileAccessible(filepath): raise IOEr...
[ "def", "openSafeReplace", "(", "filepath", ",", "mode", "=", "'w+b'", ")", ":", "tempfileName", "=", "None", "#Check if the filepath can be accessed and is writable before creating the", "#tempfile", "if", "not", "_isFileAccessible", "(", "filepath", ")", ":", "raise", ...
Context manager to open a temporary file and replace the original file on closing.
[ "Context", "manager", "to", "open", "a", "temporary", "file", "and", "replace", "the", "original", "file", "on", "closing", "." ]
python
train
F5Networks/f5-common-python
f5/bigip/tm/ltm/node.py
https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/tm/ltm/node.py#L118-L134
def _modify(self, **patch): """Override modify to check kwargs before request sent to device.""" if 'state' in patch: if patch['state'] not in ['user-up', 'user-down', 'unchecked', 'fqdn-up']: msg = "The node resource does not support a modify with the " \ ...
[ "def", "_modify", "(", "self", ",", "*", "*", "patch", ")", ":", "if", "'state'", "in", "patch", ":", "if", "patch", "[", "'state'", "]", "not", "in", "[", "'user-up'", ",", "'user-down'", ",", "'unchecked'", ",", "'fqdn-up'", "]", ":", "msg", "=", ...
Override modify to check kwargs before request sent to device.
[ "Override", "modify", "to", "check", "kwargs", "before", "request", "sent", "to", "device", "." ]
python
train
jhshi/wltrace
wltrace/wltrace.py
https://github.com/jhshi/wltrace/blob/4c8441162f7cddd47375da2effc52c95b97dc81d/wltrace/wltrace.py#L59-L77
def load_trace(path, *args, **kwargs): """Read a packet trace file, return a :class:`wltrace.common.WlTrace` object. This function first reads the file's magic (first ``FILE_TYPE_HANDLER`` bytes), and automatically determine the file type, and call appropriate handler to process the file. Args: ...
[ "def", "load_trace", "(", "path", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "magic", "=", "f", ".", "read", "(", "MAGIC_LEN", ")", "if", "magic", "not", "in", "FILE_TYPE_HA...
Read a packet trace file, return a :class:`wltrace.common.WlTrace` object. This function first reads the file's magic (first ``FILE_TYPE_HANDLER`` bytes), and automatically determine the file type, and call appropriate handler to process the file. Args: path (str): the file's path to be loaded...
[ "Read", "a", "packet", "trace", "file", "return", "a", ":", "class", ":", "wltrace", ".", "common", ".", "WlTrace", "object", "." ]
python
train
72squared/redpipe
redpipe/keyspaces.py
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1263-L1280
def lrange(self, name, start, stop): """ Returns a range of items. :param name: str the name of the redis key :param start: integer representing the start index of the range :param stop: integer representing the size of the list. :return: Future() """ ...
[ "def", "lrange", "(", "self", ",", "name", ",", "start", ",", "stop", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "f", "=", "Future", "(", ")", "res", "=", "pipe", ".", "lrange", "(", "self", ".", "redis_key", "(", "name", ")", ",...
Returns a range of items. :param name: str the name of the redis key :param start: integer representing the start index of the range :param stop: integer representing the size of the list. :return: Future()
[ "Returns", "a", "range", "of", "items", "." ]
python
train
btel/svg_utils
src/svgutils/transform.py
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L38-L50
def rotate(self, angle, x=0, y=0): """Rotate element by given angle around given pivot. Parameters ---------- angle : float rotation angle in degrees x, y : float pivot coordinates in user coordinate system (defaults to top-left corner of the ...
[ "def", "rotate", "(", "self", ",", "angle", ",", "x", "=", "0", ",", "y", "=", "0", ")", ":", "self", ".", "root", ".", "set", "(", "\"transform\"", ",", "\"%s rotate(%f %f %f)\"", "%", "(", "self", ".", "root", ".", "get", "(", "\"transform\"", ")...
Rotate element by given angle around given pivot. Parameters ---------- angle : float rotation angle in degrees x, y : float pivot coordinates in user coordinate system (defaults to top-left corner of the figure)
[ "Rotate", "element", "by", "given", "angle", "around", "given", "pivot", "." ]
python
train
wummel/linkchecker
linkcheck/fileutil.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/fileutil.py#L218-L227
def is_writable(filename): """Check if - the file is a regular file and is writable, or - the file does not exist and its parent directory exists and is writable """ if not os.path.exists(filename): parentdir = os.path.dirname(filename) return os.path.isdir(parentdir) and os.ac...
[ "def", "is_writable", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "parentdir", "=", "os", ".", "path", ".", "dirname", "(", "filename", ")", "return", "os", ".", "path", ".", "isdir", "(", "p...
Check if - the file is a regular file and is writable, or - the file does not exist and its parent directory exists and is writable
[ "Check", "if", "-", "the", "file", "is", "a", "regular", "file", "and", "is", "writable", "or", "-", "the", "file", "does", "not", "exist", "and", "its", "parent", "directory", "exists", "and", "is", "writable" ]
python
train
psphere-project/psphere
psphere/__init__.py
https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/__init__.py#L153-L168
def update(self, properties=None): """Updates the properties being held for this instance. :param properties: The list of properties to update. :type properties: list or None (default). If None, update all currently cached properties. """ if properties is None: ...
[ "def", "update", "(", "self", ",", "properties", "=", "None", ")", ":", "if", "properties", "is", "None", ":", "try", ":", "self", ".", "update_view_data", "(", "properties", "=", "list", "(", "self", ".", "_cache", ".", "keys", "(", ")", ")", ")", ...
Updates the properties being held for this instance. :param properties: The list of properties to update. :type properties: list or None (default). If None, update all currently cached properties.
[ "Updates", "the", "properties", "being", "held", "for", "this", "instance", "." ]
python
train
kamikaze/webdav
src/webdav/client.py
https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L335-L355
def download_directory(self, remote_path, local_path, progress=None): """Downloads directory and downloads all nested files and directories from remote WebDAV to local. If there is something on local path it deletes directories and files then creates new. :param remote_path: the path to directo...
[ "def", "download_directory", "(", "self", ",", "remote_path", ",", "local_path", ",", "progress", "=", "None", ")", ":", "urn", "=", "Urn", "(", "remote_path", ",", "directory", "=", "True", ")", "if", "not", "self", ".", "is_dir", "(", "urn", ".", "pa...
Downloads directory and downloads all nested files and directories from remote WebDAV to local. If there is something on local path it deletes directories and files then creates new. :param remote_path: the path to directory for downloading form WebDAV server. :param local_path: the path to loc...
[ "Downloads", "directory", "and", "downloads", "all", "nested", "files", "and", "directories", "from", "remote", "WebDAV", "to", "local", ".", "If", "there", "is", "something", "on", "local", "path", "it", "deletes", "directories", "and", "files", "then", "crea...
python
train
aegirhall/console-menu
consolemenu/selection_menu.py
https://github.com/aegirhall/console-menu/blob/1a28959d6f1dd6ac79c87b11efd8529d05532422/consolemenu/selection_menu.py#L29-L50
def get_selection(cls, strings, title="Select an option", subtitle=None, exit_option=True, _menu=None): """ Single-method way of getting a selection out of a list of strings. Args: strings (:obj:`list` of :obj:`str`): The list of strings this menu should be built from. ...
[ "def", "get_selection", "(", "cls", ",", "strings", ",", "title", "=", "\"Select an option\"", ",", "subtitle", "=", "None", ",", "exit_option", "=", "True", ",", "_menu", "=", "None", ")", ":", "menu", "=", "cls", "(", "strings", ",", "title", ",", "s...
Single-method way of getting a selection out of a list of strings. Args: strings (:obj:`list` of :obj:`str`): The list of strings this menu should be built from. title (str): The title of the menu. subtitle (str): The subtitle of the menu. exit_option (bool): Sp...
[ "Single", "-", "method", "way", "of", "getting", "a", "selection", "out", "of", "a", "list", "of", "strings", "." ]
python
train
tensorflow/mesh
mesh_tensorflow/transformer/dataset.py
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/dataset.py#L330-L376
def pretokenized_tfrecord_dataset(filenames, text2self, eos_included, repeat, batch_size, sequence_length): """Reads tensor2tensor-style data files....
[ "def", "pretokenized_tfrecord_dataset", "(", "filenames", ",", "text2self", ",", "eos_included", ",", "repeat", ",", "batch_size", ",", "sequence_length", ")", ":", "dataset", "=", "tf", ".", "data", ".", "TFRecordDataset", "(", "filenames", ",", "buffer_size", ...
Reads tensor2tensor-style data files. The dataset is defined by sets of TFRecord files of TFExample protos. There should be a "targets" feature (a 1d tensor of integers) If not text2self, there should also be an "inputs" feature. Other features get ignored. eos_included specifies whether the inputs and targ...
[ "Reads", "tensor2tensor", "-", "style", "data", "files", "." ]
python
train
wmayner/pyphi
pyphi/db.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/db.py#L34-L45
def find(key): """Return the value associated with a key. If there is no value with the given key, returns ``None``. """ docs = list(collection.find({KEY_FIELD: key})) # Return None if we didn't find anything. if not docs: return None pickled_value = docs[0][VALUE_FIELD] # Unpic...
[ "def", "find", "(", "key", ")", ":", "docs", "=", "list", "(", "collection", ".", "find", "(", "{", "KEY_FIELD", ":", "key", "}", ")", ")", "# Return None if we didn't find anything.", "if", "not", "docs", ":", "return", "None", "pickled_value", "=", "docs...
Return the value associated with a key. If there is no value with the given key, returns ``None``.
[ "Return", "the", "value", "associated", "with", "a", "key", "." ]
python
train
trailofbits/manticore
manticore/utils/fallback_emulator.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/utils/fallback_emulator.py#L64-L86
def _create_emulated_mapping(self, uc, address): """ Create a mapping in Unicorn and note that we'll need it if we retry. :param uc: The Unicorn instance. :param address: The address which is contained by the mapping. :rtype Map """ m = self._cpu.memory.map_conta...
[ "def", "_create_emulated_mapping", "(", "self", ",", "uc", ",", "address", ")", ":", "m", "=", "self", ".", "_cpu", ".", "memory", ".", "map_containing", "(", "address", ")", "permissions", "=", "UC_PROT_NONE", "if", "'r'", "in", "m", ".", "perms", ":", ...
Create a mapping in Unicorn and note that we'll need it if we retry. :param uc: The Unicorn instance. :param address: The address which is contained by the mapping. :rtype Map
[ "Create", "a", "mapping", "in", "Unicorn", "and", "note", "that", "we", "ll", "need", "it", "if", "we", "retry", ".", ":", "param", "uc", ":", "The", "Unicorn", "instance", ".", ":", "param", "address", ":", "The", "address", "which", "is", "contained"...
python
valid
flatangle/flatlib
flatlib/dignities/accidental.py
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/accidental.py#L237-L252
def eqMutualReceptions(self): """ Returns a list with mutual receptions with the object and other planets, when the reception is the same for both (both ruler or both exaltation). It basically return a list with every ruler-ruler and exalt-exalt mutual receptions ...
[ "def", "eqMutualReceptions", "(", "self", ")", ":", "mrs", "=", "self", ".", "reMutualReceptions", "(", ")", "res", "=", "[", "]", "for", "ID", ",", "receptions", "in", "mrs", ".", "items", "(", ")", ":", "for", "pair", "in", "receptions", ":", "if",...
Returns a list with mutual receptions with the object and other planets, when the reception is the same for both (both ruler or both exaltation). It basically return a list with every ruler-ruler and exalt-exalt mutual receptions
[ "Returns", "a", "list", "with", "mutual", "receptions", "with", "the", "object", "and", "other", "planets", "when", "the", "reception", "is", "the", "same", "for", "both", "(", "both", "ruler", "or", "both", "exaltation", ")", ".", "It", "basically", "retu...
python
train
goldsmith/Wikipedia
wikipedia/wikipedia.py
https://github.com/goldsmith/Wikipedia/blob/2065c568502b19b8634241b47fd96930d1bf948d/wikipedia/wikipedia.py#L653-L676
def section(self, section_title): ''' Get the plain text content of a section from `self.sections`. Returns None if `section_title` isn't found, otherwise returns a whitespace stripped string. This is a convenience method that wraps self.content. .. warning:: Calling `section` on a section that ha...
[ "def", "section", "(", "self", ",", "section_title", ")", ":", "section", "=", "u\"== {} ==\"", ".", "format", "(", "section_title", ")", "try", ":", "index", "=", "self", ".", "content", ".", "index", "(", "section", ")", "+", "len", "(", "section", "...
Get the plain text content of a section from `self.sections`. Returns None if `section_title` isn't found, otherwise returns a whitespace stripped string. This is a convenience method that wraps self.content. .. warning:: Calling `section` on a section that has subheadings will NOT return the f...
[ "Get", "the", "plain", "text", "content", "of", "a", "section", "from", "self", ".", "sections", ".", "Returns", "None", "if", "section_title", "isn", "t", "found", "otherwise", "returns", "a", "whitespace", "stripped", "string", "." ]
python
train
fastai/fastai
docs_src/nbval/plugin.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/docs_src/nbval/plugin.py#L796-L831
def coalesce_streams(outputs): """ Merge all stream outputs with shared names into single streams to ensure deterministic outputs. Parameters ---------- outputs : iterable of NotebookNodes Outputs being processed """ if not outputs: return outputs new_outputs = [] ...
[ "def", "coalesce_streams", "(", "outputs", ")", ":", "if", "not", "outputs", ":", "return", "outputs", "new_outputs", "=", "[", "]", "streams", "=", "{", "}", "for", "output", "in", "outputs", ":", "if", "(", "output", ".", "output_type", "==", "'stream'...
Merge all stream outputs with shared names into single streams to ensure deterministic outputs. Parameters ---------- outputs : iterable of NotebookNodes Outputs being processed
[ "Merge", "all", "stream", "outputs", "with", "shared", "names", "into", "single", "streams", "to", "ensure", "deterministic", "outputs", "." ]
python
train
ArchiveTeam/wpull
wpull/url.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/url.py#L402-L415
def parse_url_or_log(url, encoding='utf-8'): '''Parse and return a URLInfo. This function logs a warning if the URL cannot be parsed and returns None. ''' try: url_info = URLInfo.parse(url, encoding=encoding) except ValueError as error: _logger.warning(__( _('Unable ...
[ "def", "parse_url_or_log", "(", "url", ",", "encoding", "=", "'utf-8'", ")", ":", "try", ":", "url_info", "=", "URLInfo", ".", "parse", "(", "url", ",", "encoding", "=", "encoding", ")", "except", "ValueError", "as", "error", ":", "_logger", ".", "warnin...
Parse and return a URLInfo. This function logs a warning if the URL cannot be parsed and returns None.
[ "Parse", "and", "return", "a", "URLInfo", "." ]
python
train
rackerlabs/fastfood
fastfood/shell.py
https://github.com/rackerlabs/fastfood/blob/543970c4cedbb3956e84a7986469fdd7e4ee8fc8/fastfood/shell.py#L117-L252
def main(argv=None): """fastfood command line interface.""" # pylint: disable=missing-docstring import argparse import traceback class HelpfulParser(argparse.ArgumentParser): def error(self, message, print_help=False): if 'too few arguments' in message: sys.argv....
[ "def", "main", "(", "argv", "=", "None", ")", ":", "# pylint: disable=missing-docstring", "import", "argparse", "import", "traceback", "class", "HelpfulParser", "(", "argparse", ".", "ArgumentParser", ")", ":", "def", "error", "(", "self", ",", "message", ",", ...
fastfood command line interface.
[ "fastfood", "command", "line", "interface", "." ]
python
train
annoviko/pyclustering
pyclustering/nnet/sync.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/sync.py#L120-L128
def output(self): """! @brief (list) Returns output dynamic of the Sync network (phase coordinates of each oscillator in the network) during simulation. """ if ( (self._ccore_sync_dynamic_pointer is not None) and ( (self._dynamic is None) or (len(self._dynamic) == 0) ) ): ...
[ "def", "output", "(", "self", ")", ":", "if", "(", "(", "self", ".", "_ccore_sync_dynamic_pointer", "is", "not", "None", ")", "and", "(", "(", "self", ".", "_dynamic", "is", "None", ")", "or", "(", "len", "(", "self", ".", "_dynamic", ")", "==", "0...
! @brief (list) Returns output dynamic of the Sync network (phase coordinates of each oscillator in the network) during simulation.
[ "!" ]
python
valid
obulpathi/cdn-fastly-python
fastly/__init__.py
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L608-L611
def get_request_setting(self, service_id, version_number, name): """Gets the specified Request Settings object.""" content = self._fetch("/service/%s/version/%d/request_settings/%s" % (service_id, version_number, name)) return FastlyRequestSetting(self, content)
[ "def", "get_request_setting", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/request_settings/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")...
Gets the specified Request Settings object.
[ "Gets", "the", "specified", "Request", "Settings", "object", "." ]
python
train
fastai/fastai
fastai/callbacks/mlflow.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/callbacks/mlflow.py#L16-L24
def on_train_begin(self, **kwargs: Any) -> None: "Prepare MLflow experiment and log params" self.client = mlflow.tracking.MlflowClient(self.uri) exp = self.client.get_experiment_by_name(self.exp_name) self.exp_id = self.client.create_experiment(self.exp_name) if exp is None else exp.expe...
[ "def", "on_train_begin", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "self", ".", "client", "=", "mlflow", ".", "tracking", ".", "MlflowClient", "(", "self", ".", "uri", ")", "exp", "=", "self", ".", "client", ".", "ge...
Prepare MLflow experiment and log params
[ "Prepare", "MLflow", "experiment", "and", "log", "params" ]
python
train
20c/facsimile
facsimile/base.py
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/base.py#L294-L376
def check_config(self): """ called after config was modified to sanity check raises on error """ # sanity checks - no config access past here if not getattr(self, 'stages', None): raise NotImplementedError("member variable 'stages' must be defined") #...
[ "def", "check_config", "(", "self", ")", ":", "# sanity checks - no config access past here", "if", "not", "getattr", "(", "self", ",", "'stages'", ",", "None", ")", ":", "raise", "NotImplementedError", "(", "\"member variable 'stages' must be defined\"", ")", "# start ...
called after config was modified to sanity check raises on error
[ "called", "after", "config", "was", "modified", "to", "sanity", "check", "raises", "on", "error" ]
python
train
HazyResearch/metal
metal/label_model/label_model.py
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/label_model/label_model.py#L41-L62
def _create_L_ind(self, L): """Convert a label matrix with labels in 0...k to a one-hot format Args: L: An [n,m] scipy.sparse label matrix with values in {0,1,...,k} Returns: L_ind: An [n,m*k] dense np.ndarray with values in {0,1} Note that no column is require...
[ "def", "_create_L_ind", "(", "self", ",", "L", ")", ":", "# TODO: Update LabelModel to keep L variants as sparse matrices", "# throughout and remove this line.", "if", "issparse", "(", "L", ")", ":", "L", "=", "L", ".", "todense", "(", ")", "L_ind", "=", "np", "."...
Convert a label matrix with labels in 0...k to a one-hot format Args: L: An [n,m] scipy.sparse label matrix with values in {0,1,...,k} Returns: L_ind: An [n,m*k] dense np.ndarray with values in {0,1} Note that no column is required for 0 (abstain) labels.
[ "Convert", "a", "label", "matrix", "with", "labels", "in", "0", "...", "k", "to", "a", "one", "-", "hot", "format" ]
python
train
rpcope1/PythonConfluenceAPI
PythonConfluenceAPI/cfapi.py
https://github.com/rpcope1/PythonConfluenceAPI/blob/b7f0ca2a390f964715fdf3a60b5b0c5ef7116d40/PythonConfluenceAPI/cfapi.py#L69-L106
def _service_request(self, request_type, sub_uri, params=None, callback=None, raise_for_status=True, raw=False, **kwargs): """ Base method for handling HTTP requests via the current requests session. :param request_type: The request type as a string (e.g. "POST", "GET", ...
[ "def", "_service_request", "(", "self", ",", "request_type", ",", "sub_uri", ",", "params", "=", "None", ",", "callback", "=", "None", ",", "raise_for_status", "=", "True", ",", "raw", "=", "False", ",", "*", "*", "kwargs", ")", ":", "api_logger", ".", ...
Base method for handling HTTP requests via the current requests session. :param request_type: The request type as a string (e.g. "POST", "GET", "PUT", etc.) :param sub_uri: The REST end point (sub-uri) to communicate with. :param params: (Optional) HTTP Request parameters. Default: none ...
[ "Base", "method", "for", "handling", "HTTP", "requests", "via", "the", "current", "requests", "session", ".", ":", "param", "request_type", ":", "The", "request", "type", "as", "a", "string", "(", "e", ".", "g", ".", "POST", "GET", "PUT", "etc", ".", "...
python
train
peterbrittain/asciimatics
asciimatics/screen.py
https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/screen.py#L1465-L1474
def _unhandled_event_default(event): """ Default unhandled event handler for handling simple scene navigation. """ if isinstance(event, KeyboardEvent): c = event.key_code if c in (ord("X"), ord("x"), ord("Q"), ord("q")): raise StopApplication("User...
[ "def", "_unhandled_event_default", "(", "event", ")", ":", "if", "isinstance", "(", "event", ",", "KeyboardEvent", ")", ":", "c", "=", "event", ".", "key_code", "if", "c", "in", "(", "ord", "(", "\"X\"", ")", ",", "ord", "(", "\"x\"", ")", ",", "ord"...
Default unhandled event handler for handling simple scene navigation.
[ "Default", "unhandled", "event", "handler", "for", "handling", "simple", "scene", "navigation", "." ]
python
train
codeinn/vcs
vcs/utils/diffs.py
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/diffs.py#L363-L370
def raw_diff(self): """ Returns raw string as udiff """ udiff_copy = self.copy_iterator() if self.__format == 'gitdiff': udiff_copy = self._parse_gitdiff(udiff_copy) return u''.join(udiff_copy)
[ "def", "raw_diff", "(", "self", ")", ":", "udiff_copy", "=", "self", ".", "copy_iterator", "(", ")", "if", "self", ".", "__format", "==", "'gitdiff'", ":", "udiff_copy", "=", "self", ".", "_parse_gitdiff", "(", "udiff_copy", ")", "return", "u''", ".", "j...
Returns raw string as udiff
[ "Returns", "raw", "string", "as", "udiff" ]
python
train
RudolfCardinal/pythonlib
cardinal_pythonlib/sqlalchemy/list_types.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sqlalchemy/list_types.py#L271-L275
def process_literal_param(self, value: Optional[List[int]], dialect: Dialect) -> str: """Convert things on the way from Python to the database.""" retval = self._intlist_to_dbstr(value) return retval
[ "def", "process_literal_param", "(", "self", ",", "value", ":", "Optional", "[", "List", "[", "int", "]", "]", ",", "dialect", ":", "Dialect", ")", "->", "str", ":", "retval", "=", "self", ".", "_intlist_to_dbstr", "(", "value", ")", "return", "retval" ]
Convert things on the way from Python to the database.
[ "Convert", "things", "on", "the", "way", "from", "Python", "to", "the", "database", "." ]
python
train
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L9961-L9986
def pxfrm2(frame_from, frame_to, etfrom, etto): """ Return the 3x3 matrix that transforms position vectors from one specified frame at a specified epoch to another specified frame at another specified epoch. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pxfrm2_c.html :param frame_fro...
[ "def", "pxfrm2", "(", "frame_from", ",", "frame_to", ",", "etfrom", ",", "etto", ")", ":", "frame_from", "=", "stypes", ".", "stringToCharP", "(", "frame_from", ")", "frame_to", "=", "stypes", ".", "stringToCharP", "(", "frame_to", ")", "etfrom", "=", "cty...
Return the 3x3 matrix that transforms position vectors from one specified frame at a specified epoch to another specified frame at another specified epoch. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pxfrm2_c.html :param frame_from: Name of the frame to transform from. :type frame_from...
[ "Return", "the", "3x3", "matrix", "that", "transforms", "position", "vectors", "from", "one", "specified", "frame", "at", "a", "specified", "epoch", "to", "another", "specified", "frame", "at", "another", "specified", "epoch", "." ]
python
train
quintusdias/glymur
glymur/jp2box.py
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2box.py#L929-L957
def parse(cls, fptr, offset, length): """Parse component mapping box. Parameters ---------- fptr : file Open file object. offset : int Start position of box in bytes. length : int Length of the box in bytes. Returns --...
[ "def", "parse", "(", "cls", ",", "fptr", ",", "offset", ",", "length", ")", ":", "num_bytes", "=", "offset", "+", "length", "-", "fptr", ".", "tell", "(", ")", "num_components", "=", "int", "(", "num_bytes", "/", "4", ")", "read_buffer", "=", "fptr",...
Parse component mapping box. Parameters ---------- fptr : file Open file object. offset : int Start position of box in bytes. length : int Length of the box in bytes. Returns ------- ComponentMappingBox Ins...
[ "Parse", "component", "mapping", "box", "." ]
python
train
awslabs/serverless-application-model
examples/apps/lex-book-trip-python/lambda_function.py
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-book-trip-python/lambda_function.py#L97-L113
def generate_car_price(location, days, age, car_type): """ Generates a number within a reasonable range that might be expected for a flight. The price is fixed for a given pair of locations. """ car_types = ['economy', 'standard', 'midsize', 'full size', 'minivan', 'luxury'] base_location_cost ...
[ "def", "generate_car_price", "(", "location", ",", "days", ",", "age", ",", "car_type", ")", ":", "car_types", "=", "[", "'economy'", ",", "'standard'", ",", "'midsize'", ",", "'full size'", ",", "'minivan'", ",", "'luxury'", "]", "base_location_cost", "=", ...
Generates a number within a reasonable range that might be expected for a flight. The price is fixed for a given pair of locations.
[ "Generates", "a", "number", "within", "a", "reasonable", "range", "that", "might", "be", "expected", "for", "a", "flight", ".", "The", "price", "is", "fixed", "for", "a", "given", "pair", "of", "locations", "." ]
python
train
exa-analytics/exa
exa/core/editor.py
https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L88-L96
def head(self, n=10): """ Display the top of the file. Args: n (int): Number of lines to display """ r = self.__repr__().split('\n') print('\n'.join(r[:n]), end=' ')
[ "def", "head", "(", "self", ",", "n", "=", "10", ")", ":", "r", "=", "self", ".", "__repr__", "(", ")", ".", "split", "(", "'\\n'", ")", "print", "(", "'\\n'", ".", "join", "(", "r", "[", ":", "n", "]", ")", ",", "end", "=", "' '", ")" ]
Display the top of the file. Args: n (int): Number of lines to display
[ "Display", "the", "top", "of", "the", "file", "." ]
python
train
tango-controls/pytango
tango/pytango_pprint.py
https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/pytango_pprint.py#L59-L62
def __struct_params_s(obj, separator=', ', f=repr, fmt='%s = %s'): """method wrapper for printing all elements of a struct""" s = separator.join([__single_param(obj, n, f, fmt) for n in dir(obj) if __inc_param(obj, n)]) return s
[ "def", "__struct_params_s", "(", "obj", ",", "separator", "=", "', '", ",", "f", "=", "repr", ",", "fmt", "=", "'%s = %s'", ")", ":", "s", "=", "separator", ".", "join", "(", "[", "__single_param", "(", "obj", ",", "n", ",", "f", ",", "fmt", ")", ...
method wrapper for printing all elements of a struct
[ "method", "wrapper", "for", "printing", "all", "elements", "of", "a", "struct" ]
python
train
lpantano/seqcluster
seqcluster/libs/annotation.py
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/annotation.py#L9-L36
def read_gtf_line(cols, field="name"): """parse gtf line to get class/name information""" field = field.lower() try: group = cols[2] attrs = cols[8].split(";") name = [attr.strip().split(" ")[1] for attr in attrs if attr.strip().split(" ")[0].lower().endswith(field)] if not n...
[ "def", "read_gtf_line", "(", "cols", ",", "field", "=", "\"name\"", ")", ":", "field", "=", "field", ".", "lower", "(", ")", "try", ":", "group", "=", "cols", "[", "2", "]", "attrs", "=", "cols", "[", "8", "]", ".", "split", "(", "\";\"", ")", ...
parse gtf line to get class/name information
[ "parse", "gtf", "line", "to", "get", "class", "/", "name", "information" ]
python
train
douban/brownant
brownant/utils.py
https://github.com/douban/brownant/blob/3c7e6d30f67b8f0f8ca1f823ea3daed74e8725cd/brownant/utils.py#L4-L22
def to_bytes_safe(text, encoding="utf-8"): """Convert the input value into bytes type. If the input value is string type and could be encode as UTF-8 bytes, the encoded value will be returned. Otherwise, the encoding has failed, the origin value will be returned as well. :param text: the input val...
[ "def", "to_bytes_safe", "(", "text", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "not", "isinstance", "(", "text", ",", "(", "bytes", ",", "text_type", ")", ")", ":", "raise", "TypeError", "(", "\"must be string type\"", ")", "if", "isinstance", "("...
Convert the input value into bytes type. If the input value is string type and could be encode as UTF-8 bytes, the encoded value will be returned. Otherwise, the encoding has failed, the origin value will be returned as well. :param text: the input value which could be string or bytes. :param enco...
[ "Convert", "the", "input", "value", "into", "bytes", "type", "." ]
python
train
BD2KGenomics/protect
attic/ProTECT.py
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/attic/ProTECT.py#L301-L361
def run_star(job, fastqs, univ_options, star_options): """ This module uses STAR to align the RNA fastqs to the reference ARGUMENTS 1. fastqs: REFER RETURN VALUE of run_cutadapt() 2. univ_options: Dict of universal arguments used by almost all tools univ_options +- 'dockerhub...
[ "def", "run_star", "(", "job", ",", "fastqs", ",", "univ_options", ",", "star_options", ")", ":", "assert", "star_options", "[", "'type'", "]", "in", "(", "'star'", ",", "'starlong'", ")", "job", ".", "fileStore", ".", "logToMaster", "(", "'Running STAR on %...
This module uses STAR to align the RNA fastqs to the reference ARGUMENTS 1. fastqs: REFER RETURN VALUE of run_cutadapt() 2. univ_options: Dict of universal arguments used by almost all tools univ_options +- 'dockerhub': <dockerhub to use> 3. star_options: Dict of parameters speci...
[ "This", "module", "uses", "STAR", "to", "align", "the", "RNA", "fastqs", "to", "the", "reference" ]
python
train
wglass/lighthouse
lighthouse/zookeeper.py
https://github.com/wglass/lighthouse/blob/f4ce6550895acc31e433ede0c05d366718a3ffe5/lighthouse/zookeeper.py#L109-L126
def handle_connection_change(self, state): """ Callback for handling changes in the kazoo client's connection state. If the connection becomes lost or suspended, the `connected` Event is cleared. Other given states imply that the connection is established so `connected` is set....
[ "def", "handle_connection_change", "(", "self", ",", "state", ")", ":", "if", "state", "==", "client", ".", "KazooState", ".", "LOST", ":", "if", "not", "self", ".", "shutdown", ".", "is_set", "(", ")", ":", "logger", ".", "info", "(", "\"Zookeeper sessi...
Callback for handling changes in the kazoo client's connection state. If the connection becomes lost or suspended, the `connected` Event is cleared. Other given states imply that the connection is established so `connected` is set.
[ "Callback", "for", "handling", "changes", "in", "the", "kazoo", "client", "s", "connection", "state", "." ]
python
train
geopy/geopy
geopy/geocoders/what3words.py
https://github.com/geopy/geopy/blob/02c838d965e76497f3c3d61f53808c86b5c58224/geopy/geocoders/what3words.py#L102-L152
def geocode(self, query, lang='en', exactly_one=True, timeout=DEFAULT_SENTINEL): """ Return a location point for a `3 words` query. If the `3 words` address doesn't exist, a :class:`geopy.exc.GeocoderQueryError` exception will be ...
[ "def", "geocode", "(", "self", ",", "query", ",", "lang", "=", "'en'", ",", "exactly_one", "=", "True", ",", "timeout", "=", "DEFAULT_SENTINEL", ")", ":", "if", "not", "self", ".", "_check_query", "(", "query", ")", ":", "raise", "exc", ".", "GeocoderQ...
Return a location point for a `3 words` query. If the `3 words` address doesn't exist, a :class:`geopy.exc.GeocoderQueryError` exception will be thrown. :param str query: The 3-word address you wish to geocode. :param str lang: two character language codes as supported by t...
[ "Return", "a", "location", "point", "for", "a", "3", "words", "query", ".", "If", "the", "3", "words", "address", "doesn", "t", "exist", "a", ":", "class", ":", "geopy", ".", "exc", ".", "GeocoderQueryError", "exception", "will", "be", "thrown", "." ]
python
train
mitsei/dlkit
dlkit/handcar/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L3098-L3122
def get_activity_form_for_update(self, activity_id=None): """Gets the activity form for updating an existing activity. A new activity form should be requested for each update transaction. arg: activityId (osid.id.Id): the Id of the Activity return: (osid.learning.ActivityForm)...
[ "def", "get_activity_form_for_update", "(", "self", ",", "activity_id", "=", "None", ")", ":", "if", "activity_id", "is", "None", ":", "raise", "NullArgument", "(", ")", "try", ":", "url_path", "=", "construct_url", "(", "'activities'", ",", "bank_id", "=", ...
Gets the activity form for updating an existing activity. A new activity form should be requested for each update transaction. arg: activityId (osid.id.Id): the Id of the Activity return: (osid.learning.ActivityForm) - the activity form raise: NotFound - activityId is not fou...
[ "Gets", "the", "activity", "form", "for", "updating", "an", "existing", "activity", ".", "A", "new", "activity", "form", "should", "be", "requested", "for", "each", "update", "transaction", ".", "arg", ":", "activityId", "(", "osid", ".", "id", ".", "Id", ...
python
train
tanghaibao/goatools
goatools/cli/docopt_parse.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/docopt_parse.py#L82-L96
def _chk_docunknown(args, exp): """Return any unknown args.""" unknown = [] for arg in args: if arg[:2] == '--': val = arg[2:] if val not in exp: unknown.append(arg) elif arg[:1] == '-': val = arg[1:] ...
[ "def", "_chk_docunknown", "(", "args", ",", "exp", ")", ":", "unknown", "=", "[", "]", "for", "arg", "in", "args", ":", "if", "arg", "[", ":", "2", "]", "==", "'--'", ":", "val", "=", "arg", "[", "2", ":", "]", "if", "val", "not", "in", "exp"...
Return any unknown args.
[ "Return", "any", "unknown", "args", "." ]
python
train
trendels/braceexpand
braceexpand.py
https://github.com/trendels/braceexpand/blob/c17aa2f2b0d9f016a8115163d94acc9a147d54c2/braceexpand.py#L23-L93
def braceexpand(pattern, escape=True): """braceexpand(pattern) -> iterator over generated strings Returns an iterator over the strings resulting from brace expansion of pattern. This function implements Brace Expansion as described in bash(1), with the following limitations: * A pattern containing...
[ "def", "braceexpand", "(", "pattern", ",", "escape", "=", "True", ")", ":", "return", "(", "_flatten", "(", "t", ",", "escape", ")", "for", "t", "in", "parse_pattern", "(", "pattern", ",", "escape", ")", ")" ]
braceexpand(pattern) -> iterator over generated strings Returns an iterator over the strings resulting from brace expansion of pattern. This function implements Brace Expansion as described in bash(1), with the following limitations: * A pattern containing unbalanced braces will raise an Unbalan...
[ "braceexpand", "(", "pattern", ")", "-", ">", "iterator", "over", "generated", "strings" ]
python
train
annoviko/pyclustering
pyclustering/cluster/agglomerative.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/agglomerative.py#L194-L213
def __merge_similar_clusters(self): """! @brief Merges the most similar clusters in line with link type. """ if (self.__similarity == type_link.AVERAGE_LINK): self.__merge_by_average_link(); elif (self.__similarity == type_link.CENTROID_LINK...
[ "def", "__merge_similar_clusters", "(", "self", ")", ":", "if", "(", "self", ".", "__similarity", "==", "type_link", ".", "AVERAGE_LINK", ")", ":", "self", ".", "__merge_by_average_link", "(", ")", "elif", "(", "self", ".", "__similarity", "==", "type_link", ...
! @brief Merges the most similar clusters in line with link type.
[ "!" ]
python
valid
tensorflow/tensor2tensor
tensor2tensor/rl/trainer_model_based.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/rl/trainer_model_based.py#L253-L378
def training_loop(hparams, output_dir, report_fn=None, report_metric=None): """Run the main training loop.""" if report_fn: assert report_metric is not None # Directories subdirectories = [ "data", "tmp", "world_model", ("world_model", "debug_videos"), "policy", "eval_metrics" ] directories...
[ "def", "training_loop", "(", "hparams", ",", "output_dir", ",", "report_fn", "=", "None", ",", "report_metric", "=", "None", ")", ":", "if", "report_fn", ":", "assert", "report_metric", "is", "not", "None", "# Directories", "subdirectories", "=", "[", "\"data\...
Run the main training loop.
[ "Run", "the", "main", "training", "loop", "." ]
python
train
RJT1990/pyflux
pyflux/families/poisson.py
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L216-L240
def markov_blanket(y, mean, scale, shape, skewness): """ Markov blanket for the Poisson distribution Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Poisson distribution scale : ...
[ "def", "markov_blanket", "(", "y", ",", "mean", ",", "scale", ",", "shape", ",", "skewness", ")", ":", "return", "ss", ".", "poisson", ".", "logpmf", "(", "y", ",", "mean", ")" ]
Markov blanket for the Poisson distribution Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Poisson distribution scale : float scale parameter for the Poisson distribution ...
[ "Markov", "blanket", "for", "the", "Poisson", "distribution" ]
python
train
googledatalab/pydatalab
google/datalab/storage/_api.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/storage/_api.py#L250-L264
def objects_patch(self, bucket, key, info): """Updates the metadata associated with an object. Args: bucket: the name of the bucket containing the object. key: the key of the object being updated. info: the metadata to update. Returns: A parsed object information dictionary. Rai...
[ "def", "objects_patch", "(", "self", ",", "bucket", ",", "key", ",", "info", ")", ":", "url", "=", "Api", ".", "_ENDPOINT", "+", "(", "Api", ".", "_OBJECT_PATH", "%", "(", "bucket", ",", "Api", ".", "_escape_key", "(", "key", ")", ")", ")", "return...
Updates the metadata associated with an object. Args: bucket: the name of the bucket containing the object. key: the key of the object being updated. info: the metadata to update. Returns: A parsed object information dictionary. Raises: Exception if there is an error performin...
[ "Updates", "the", "metadata", "associated", "with", "an", "object", "." ]
python
train
iwanbk/nyamuk
nyamuk/base_nyamuk.py
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L139-L230
def packet_read(self): """Read packet from network.""" bytes_received = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN if self.in_packet.command == 0: ba_data, errnum, errmsg = nyamuk_net.read(self.sock, 1) if errnum == 0 ...
[ "def", "packet_read", "(", "self", ")", ":", "bytes_received", "=", "0", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "if", "self", ".", "in_packet", ".", "command", "==", "0", ":", "ba_data", "...
Read packet from network.
[ "Read", "packet", "from", "network", "." ]
python
train
incf-nidash/nidmresults
nidmresults/objects/modelfitting.py
https://github.com/incf-nidash/nidmresults/blob/438f7cce6abc4a4379b629bd76f4d427891e033f/nidmresults/objects/modelfitting.py#L160-L168
def export(self, nidm_version, export_dir): """ Create prov entities and activities. """ self.add_attributes(( (PROV['type'], self.type), (NIDM_GROUP_NAME, self.group_name), (NIDM_NUMBER_OF_SUBJECTS, self.num_subjects), (PROV['label'], self...
[ "def", "export", "(", "self", ",", "nidm_version", ",", "export_dir", ")", ":", "self", ".", "add_attributes", "(", "(", "(", "PROV", "[", "'type'", "]", ",", "self", ".", "type", ")", ",", "(", "NIDM_GROUP_NAME", ",", "self", ".", "group_name", ")", ...
Create prov entities and activities.
[ "Create", "prov", "entities", "and", "activities", "." ]
python
train
mastro35/flows
flows/FlowsManager.py
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L271-L282
def _start_message_fetcher(self): """ Start the message fetcher (called from coroutine) """ Global.LOGGER.debug('starting the message fetcher') event_loop = asyncio.get_event_loop() try: Global.LOGGER.debug('entering event loop for message fetcher coro...
[ "def", "_start_message_fetcher", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "debug", "(", "'starting the message fetcher'", ")", "event_loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "try", ":", "Global", ".", "LOGGER", ".", "debug", "(", ...
Start the message fetcher (called from coroutine)
[ "Start", "the", "message", "fetcher", "(", "called", "from", "coroutine", ")" ]
python
train
pypa/pipenv
pipenv/vendor/distlib/_backport/tarfile.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/_backport/tarfile.py#L2372-L2392
def chown(self, tarinfo, targetpath): """Set owner of targetpath according to tarinfo. """ if pwd and hasattr(os, "geteuid") and os.geteuid() == 0: # We have to be root to do so. try: g = grp.getgrnam(tarinfo.gname)[2] except KeyError: ...
[ "def", "chown", "(", "self", ",", "tarinfo", ",", "targetpath", ")", ":", "if", "pwd", "and", "hasattr", "(", "os", ",", "\"geteuid\"", ")", "and", "os", ".", "geteuid", "(", ")", "==", "0", ":", "# We have to be root to do so.", "try", ":", "g", "=", ...
Set owner of targetpath according to tarinfo.
[ "Set", "owner", "of", "targetpath", "according", "to", "tarinfo", "." ]
python
train
rigetti/pyquil
pyquil/device.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/device.py#L467-L478
def get_isa(self, oneq_type='Xhalves', twoq_type='CZ') -> ISA: """ Construct an ISA suitable for targeting by compilation. This will raise an exception if the requested ISA is not supported by the device. :param oneq_type: The family of one-qubit gates to target :param twoq_typ...
[ "def", "get_isa", "(", "self", ",", "oneq_type", "=", "'Xhalves'", ",", "twoq_type", "=", "'CZ'", ")", "->", "ISA", ":", "qubits", "=", "[", "Qubit", "(", "id", "=", "q", ".", "id", ",", "type", "=", "oneq_type", ",", "dead", "=", "q", ".", "dead...
Construct an ISA suitable for targeting by compilation. This will raise an exception if the requested ISA is not supported by the device. :param oneq_type: The family of one-qubit gates to target :param twoq_type: The family of two-qubit gates to target
[ "Construct", "an", "ISA", "suitable", "for", "targeting", "by", "compilation", "." ]
python
train
OCHA-DAP/hdx-data-freshness
src/hdx/freshness/retry.py
https://github.com/OCHA-DAP/hdx-data-freshness/blob/991152a5ec4c4a980a5378411db060b13730cad3/src/hdx/freshness/retry.py#L31-L106
async def send_http(session, method, url, *, retries=1, interval=1, backoff=2, http_status_codes_to_retry=HTTP_STATUS_CODES_TO_RETRY, fn=lambda x:x, **kwargs): """ Sends a HTTP request and imp...
[ "async", "def", "send_http", "(", "session", ",", "method", ",", "url", ",", "*", ",", "retries", "=", "1", ",", "interval", "=", "1", ",", "backoff", "=", "2", ",", "http_status_codes_to_retry", "=", "HTTP_STATUS_CODES_TO_RETRY", ",", "fn", "=", "lambda",...
Sends a HTTP request and implements a retry logic. Arguments: session (obj): A client aiohttp session object method (str): Method to use url (str): URL for the request retries (int): Number of times to retry in case of failure interval (float): Time to wait before retries ...
[ "Sends", "a", "HTTP", "request", "and", "implements", "a", "retry", "logic", "." ]
python
train
Qiskit/qiskit-terra
qiskit/quantum_info/operators/channel/superop.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L268-L283
def multiply(self, other): """Return the QuantumChannel self + other. Args: other (complex): a complex number. Returns: SuperOp: the scalar multiplication other * self as a SuperOp object. Raises: QiskitError: if other is not a valid scalar. ...
[ "def", "multiply", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "Number", ")", ":", "raise", "QiskitError", "(", "\"other is not a number\"", ")", "return", "SuperOp", "(", "other", "*", "self", ".", "_data", ",", "s...
Return the QuantumChannel self + other. Args: other (complex): a complex number. Returns: SuperOp: the scalar multiplication other * self as a SuperOp object. Raises: QiskitError: if other is not a valid scalar.
[ "Return", "the", "QuantumChannel", "self", "+", "other", "." ]
python
test
Microsoft/nni
src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py#L174-L191
def mmf(x, alpha, beta, kappa, delta): """Morgan-Mercer-Flodin http://www.pisces-conservation.com/growthhelp/index.html?morgan_mercer_floden.htm Parameters ---------- x: int alpha: float beta: float kappa: float delta: float Returns ------- float alpha - (alpha ...
[ "def", "mmf", "(", "x", ",", "alpha", ",", "beta", ",", "kappa", ",", "delta", ")", ":", "return", "alpha", "-", "(", "alpha", "-", "beta", ")", "/", "(", "1.", "+", "(", "kappa", "*", "x", ")", "**", "delta", ")" ]
Morgan-Mercer-Flodin http://www.pisces-conservation.com/growthhelp/index.html?morgan_mercer_floden.htm Parameters ---------- x: int alpha: float beta: float kappa: float delta: float Returns ------- float alpha - (alpha - beta) / (1. + (kappa * x)**delta)
[ "Morgan", "-", "Mercer", "-", "Flodin", "http", ":", "//", "www", ".", "pisces", "-", "conservation", ".", "com", "/", "growthhelp", "/", "index", ".", "html?morgan_mercer_floden", ".", "htm" ]
python
train
apache/incubator-mxnet
example/gluon/dc_gan/dcgan.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L52-L69
def visual(title, X, name): """Image visualization and preservation :param title: title :param X: images to visualized :param name: saved picture`s name :return: """ assert len(X.shape) == 4 X = X.transpose((0, 2, 3, 1)) X = np.clip((X - np.min(X))*(255.0/(np.max(X) - np.min(X))), 0,...
[ "def", "visual", "(", "title", ",", "X", ",", "name", ")", ":", "assert", "len", "(", "X", ".", "shape", ")", "==", "4", "X", "=", "X", ".", "transpose", "(", "(", "0", ",", "2", ",", "3", ",", "1", ")", ")", "X", "=", "np", ".", "clip", ...
Image visualization and preservation :param title: title :param X: images to visualized :param name: saved picture`s name :return:
[ "Image", "visualization", "and", "preservation", ":", "param", "title", ":", "title", ":", "param", "X", ":", "images", "to", "visualized", ":", "param", "name", ":", "saved", "picture", "s", "name", ":", "return", ":" ]
python
train
markovmodel/PyEMMA
pyemma/coordinates/pipelines.py
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/pipelines.py#L223-L254
def save_dtrajs(self, prefix='', output_dir='.', output_format='ascii', extension='.dtraj'): r"""Saves calculated discrete trajectories. Filenames are taken from given reader. If data comes from memory dtrajs are written to a default filename. Parameters ---...
[ "def", "save_dtrajs", "(", "self", ",", "prefix", "=", "''", ",", "output_dir", "=", "'.'", ",", "output_format", "=", "'ascii'", ",", "extension", "=", "'.dtraj'", ")", ":", "clustering", "=", "self", ".", "_chain", "[", "-", "1", "]", "reader", "=", ...
r"""Saves calculated discrete trajectories. Filenames are taken from given reader. If data comes from memory dtrajs are written to a default filename. Parameters ---------- prefix : str prepend prefix to filenames. output_dir : str (optional) sav...
[ "r", "Saves", "calculated", "discrete", "trajectories", ".", "Filenames", "are", "taken", "from", "given", "reader", ".", "If", "data", "comes", "from", "memory", "dtrajs", "are", "written", "to", "a", "default", "filename", "." ]
python
train
Qiskit/qiskit-terra
qiskit/tools/monitor/backend_overview.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/monitor/backend_overview.py#L42-L121
def backend_monitor(backend): """Monitor a single IBMQ backend. Args: backend (IBMQBackend): Backend to monitor. Raises: QiskitError: Input is not a IBMQ backend. """ if not isinstance(backend, IBMQBackend): raise QiskitError('Input variable is not of type IBMQBackend.') ...
[ "def", "backend_monitor", "(", "backend", ")", ":", "if", "not", "isinstance", "(", "backend", ",", "IBMQBackend", ")", ":", "raise", "QiskitError", "(", "'Input variable is not of type IBMQBackend.'", ")", "config", "=", "backend", ".", "configuration", "(", ")",...
Monitor a single IBMQ backend. Args: backend (IBMQBackend): Backend to monitor. Raises: QiskitError: Input is not a IBMQ backend.
[ "Monitor", "a", "single", "IBMQ", "backend", "." ]
python
test
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L665-L699
def fnd_unq_rws(A, return_index=False, return_inverse=False): """Find unique rows in 2D array. Parameters ---------- A : 2d numpy array Array for which unique rows should be identified. return_index : bool Bool to decide whether I is returned. return_inverse : bool Bool ...
[ "def", "fnd_unq_rws", "(", "A", ",", "return_index", "=", "False", ",", "return_inverse", "=", "False", ")", ":", "A", "=", "np", ".", "require", "(", "A", ",", "requirements", "=", "'C'", ")", "assert", "A", ".", "ndim", "==", "2", ",", "\"array mus...
Find unique rows in 2D array. Parameters ---------- A : 2d numpy array Array for which unique rows should be identified. return_index : bool Bool to decide whether I is returned. return_inverse : bool Bool to decide whether J is returned. Returns ------- B : 1d ...
[ "Find", "unique", "rows", "in", "2D", "array", "." ]
python
train
hubo1016/vlcp
vlcp/service/connection/tcpserver.py
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/service/connection/tcpserver.py#L162-L172
async def startlisten(self, vhost = None): ''' Start listen on current servers :param vhost: return only servers of vhost if specified. '' to return only default servers. None for all servers. ''' servers = self.getservers(vhost) for s in se...
[ "async", "def", "startlisten", "(", "self", ",", "vhost", "=", "None", ")", ":", "servers", "=", "self", ".", "getservers", "(", "vhost", ")", "for", "s", "in", "servers", ":", "await", "s", ".", "startlisten", "(", ")", "return", "len", "(", "server...
Start listen on current servers :param vhost: return only servers of vhost if specified. '' to return only default servers. None for all servers.
[ "Start", "listen", "on", "current", "servers", ":", "param", "vhost", ":", "return", "only", "servers", "of", "vhost", "if", "specified", ".", "to", "return", "only", "default", "servers", ".", "None", "for", "all", "servers", "." ]
python
train
nugget/python-insteonplm
insteonplm/messages/standardReceive.py
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/standardReceive.py#L43-L49
def from_raw_message(cls, rawmessage): """Create message from a raw byte stream.""" return StandardReceive(rawmessage[2:5], rawmessage[5:8], {'cmd1': rawmessage[9], 'cmd2': rawmessage[10]}, ...
[ "def", "from_raw_message", "(", "cls", ",", "rawmessage", ")", ":", "return", "StandardReceive", "(", "rawmessage", "[", "2", ":", "5", "]", ",", "rawmessage", "[", "5", ":", "8", "]", ",", "{", "'cmd1'", ":", "rawmessage", "[", "9", "]", ",", "'cmd2...
Create message from a raw byte stream.
[ "Create", "message", "from", "a", "raw", "byte", "stream", "." ]
python
train
bertrandvidal/parse_this
parse_this/core.py
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L264-L299
def _get_parser_call_method(func): """Returns the method that is linked to the 'call' method of the parser Args: func: the decorated function Raises: ParseThisError if the decorated method is __init__, __init__ can only be decorated in a class decorated by parse_class """ f...
[ "def", "_get_parser_call_method", "(", "func", ")", ":", "func_name", "=", "func", ".", "__name__", "parser", "=", "func", ".", "parser", "def", "inner_call", "(", "instance", "=", "None", ",", "args", "=", "None", ")", ":", "\"\"\"This is method attached to <...
Returns the method that is linked to the 'call' method of the parser Args: func: the decorated function Raises: ParseThisError if the decorated method is __init__, __init__ can only be decorated in a class decorated by parse_class
[ "Returns", "the", "method", "that", "is", "linked", "to", "the", "call", "method", "of", "the", "parser" ]
python
train
xtrementl/focus
focus/daemon.py
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/daemon.py#L219-L226
def _reg_sighandlers(self): """ Registers signal handlers to this class. """ # SIGCHLD, so we shutdown when any of the child processes exit _handler = lambda signo, frame: self.shutdown() signal.signal(signal.SIGCHLD, _handler) signal.signal(signal.SIGTERM, _handler)
[ "def", "_reg_sighandlers", "(", "self", ")", ":", "# SIGCHLD, so we shutdown when any of the child processes exit", "_handler", "=", "lambda", "signo", ",", "frame", ":", "self", ".", "shutdown", "(", ")", "signal", ".", "signal", "(", "signal", ".", "SIGCHLD", ",...
Registers signal handlers to this class.
[ "Registers", "signal", "handlers", "to", "this", "class", "." ]
python
train
hyperledger/indy-plenum
stp_core/crypto/nacl_wrappers.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/crypto/nacl_wrappers.py#L86-L108
def verify(self, smessage, signature=None, encoder=encoding.RawEncoder): """ Verifies the signature of a signed message, returning the message if it has not been tampered with else raising :class:`~ValueError`. :param smessage: [:class:`bytes`] Either the original messaged or a ...
[ "def", "verify", "(", "self", ",", "smessage", ",", "signature", "=", "None", ",", "encoder", "=", "encoding", ".", "RawEncoder", ")", ":", "if", "signature", "is", "not", "None", ":", "# If we were given the message and signature separately, combine", "# them.", ...
Verifies the signature of a signed message, returning the message if it has not been tampered with else raising :class:`~ValueError`. :param smessage: [:class:`bytes`] Either the original messaged or a signature and message concated together. :param signature: [:class:`bytes...
[ "Verifies", "the", "signature", "of", "a", "signed", "message", "returning", "the", "message", "if", "it", "has", "not", "been", "tampered", "with", "else", "raising", ":", "class", ":", "~ValueError", "." ]
python
train
KelSolaar/Umbra
umbra/ui/widgets/basic_QPlainTextEdit.py
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/basic_QPlainTextEdit.py#L898-L911
def go_to_line(self, line): """ Moves the text cursor to given line. :param line: Line to go to. :type line: int :return: Method success. :rtype: bool """ cursor = self.textCursor() cursor.setPosition(self.document().findBlockByNumber(line - 1).p...
[ "def", "go_to_line", "(", "self", ",", "line", ")", ":", "cursor", "=", "self", ".", "textCursor", "(", ")", "cursor", ".", "setPosition", "(", "self", ".", "document", "(", ")", ".", "findBlockByNumber", "(", "line", "-", "1", ")", ".", "position", ...
Moves the text cursor to given line. :param line: Line to go to. :type line: int :return: Method success. :rtype: bool
[ "Moves", "the", "text", "cursor", "to", "given", "line", "." ]
python
train
secure-systems-lab/securesystemslib
securesystemslib/pyca_crypto_keys.py
https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/pyca_crypto_keys.py#L649-L739
def encrypt_key(key_object, password): """ <Purpose> Return a string containing 'key_object' in encrypted form. Encrypted strings may be safely saved to a file. The corresponding decrypt_key() function can be applied to the encrypted string to restore the original key object. 'key_object' is a TUF...
[ "def", "encrypt_key", "(", "key_object", ",", "password", ")", ":", "# Do the arguments have the correct format?", "# Ensure the arguments have the appropriate number of objects and object", "# types, and that all dict keys are properly named.", "# Raise 'securesystemslib.exceptions.FormatErro...
<Purpose> Return a string containing 'key_object' in encrypted form. Encrypted strings may be safely saved to a file. The corresponding decrypt_key() function can be applied to the encrypted string to restore the original key object. 'key_object' is a TUF key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEM...
[ "<Purpose", ">", "Return", "a", "string", "containing", "key_object", "in", "encrypted", "form", ".", "Encrypted", "strings", "may", "be", "safely", "saved", "to", "a", "file", ".", "The", "corresponding", "decrypt_key", "()", "function", "can", "be", "applied...
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/pylabtools.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/pylabtools.py#L53-L77
def getfigs(*fig_nums): """Get a list of matplotlib figures by figure numbers. If no arguments are given, all available figures are returned. If the argument list contains references to invalid figures, a warning is printed but the function continues pasting further figures. Parameters ------...
[ "def", "getfigs", "(", "*", "fig_nums", ")", ":", "from", "matplotlib", ".", "_pylab_helpers", "import", "Gcf", "if", "not", "fig_nums", ":", "fig_managers", "=", "Gcf", ".", "get_all_fig_managers", "(", ")", "return", "[", "fm", ".", "canvas", ".", "figur...
Get a list of matplotlib figures by figure numbers. If no arguments are given, all available figures are returned. If the argument list contains references to invalid figures, a warning is printed but the function continues pasting further figures. Parameters ---------- figs : tuple A...
[ "Get", "a", "list", "of", "matplotlib", "figures", "by", "figure", "numbers", "." ]
python
test
krukas/Trionyx
trionyx/renderer.py
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/renderer.py#L62-L65
def render_value(self, value, **options): """Render value""" renderer = self.renderers.get(type(value), lambda value, **options: value) return renderer(value, **options)
[ "def", "render_value", "(", "self", ",", "value", ",", "*", "*", "options", ")", ":", "renderer", "=", "self", ".", "renderers", ".", "get", "(", "type", "(", "value", ")", ",", "lambda", "value", ",", "*", "*", "options", ":", "value", ")", "retur...
Render value
[ "Render", "value" ]
python
train
spyder-ide/spyder
spyder/utils/qthelpers.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L190-L213
def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None, toggled=None, triggered=None, autoraise=True, text_beside_icon=False): """Create a QToolButton""" button = QToolButton(parent) if text is not None: button.setText(text) ...
[ "def", "create_toolbutton", "(", "parent", ",", "text", "=", "None", ",", "shortcut", "=", "None", ",", "icon", "=", "None", ",", "tip", "=", "None", ",", "toggled", "=", "None", ",", "triggered", "=", "None", ",", "autoraise", "=", "True", ",", "tex...
Create a QToolButton
[ "Create", "a", "QToolButton" ]
python
train
nerdvegas/rez
src/rez/package_filter.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/package_filter.py#L49-L64
def iter_packages(self, name, range_=None, paths=None): """Same as iter_packages in packages.py, but also applies this filter. Args: name (str): Name of the package, eg 'maya'. range_ (VersionRange or str): If provided, limits the versions returned to those in `r...
[ "def", "iter_packages", "(", "self", ",", "name", ",", "range_", "=", "None", ",", "paths", "=", "None", ")", ":", "for", "package", "in", "iter_packages", "(", "name", ",", "range_", ",", "paths", ")", ":", "if", "not", "self", ".", "excludes", "(",...
Same as iter_packages in packages.py, but also applies this filter. Args: name (str): Name of the package, eg 'maya'. range_ (VersionRange or str): If provided, limits the versions returned to those in `range_`. paths (list of str, optional): paths to search ...
[ "Same", "as", "iter_packages", "in", "packages", ".", "py", "but", "also", "applies", "this", "filter", "." ]
python
train
qubell/contrib-python-qubell-client
qubell/api/private/organization.py
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/organization.py#L184-L188
def get_application(self, id=None, name=None): """ Get application object by name or id. """ log.info("Picking application: %s (%s)" % (name, id)) return self.applications[id or name]
[ "def", "get_application", "(", "self", ",", "id", "=", "None", ",", "name", "=", "None", ")", ":", "log", ".", "info", "(", "\"Picking application: %s (%s)\"", "%", "(", "name", ",", "id", ")", ")", "return", "self", ".", "applications", "[", "id", "or...
Get application object by name or id.
[ "Get", "application", "object", "by", "name", "or", "id", "." ]
python
train
spotify/luigi
luigi/contrib/batch.py
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/batch.py#L115-L130
def get_job_status(self, job_id): """Retrieve task statuses from ECS API :param job_id (str): AWS Batch job uuid Returns one of {SUBMITTED|PENDING|RUNNABLE|STARTING|RUNNING|SUCCEEDED|FAILED} """ response = self._client.describe_jobs(jobs=[job_id]) # Error checking ...
[ "def", "get_job_status", "(", "self", ",", "job_id", ")", ":", "response", "=", "self", ".", "_client", ".", "describe_jobs", "(", "jobs", "=", "[", "job_id", "]", ")", "# Error checking", "status_code", "=", "response", "[", "'ResponseMetadata'", "]", "[", ...
Retrieve task statuses from ECS API :param job_id (str): AWS Batch job uuid Returns one of {SUBMITTED|PENDING|RUNNABLE|STARTING|RUNNING|SUCCEEDED|FAILED}
[ "Retrieve", "task", "statuses", "from", "ECS", "API" ]
python
train
saltstack/salt
salt/thorium/file.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/file.py#L51-L86
def save(name, filter=False): ''' Save the register to <salt cachedir>/thorium/saves/<name>, or to an absolute path. If an absolute path is specified, then the directory will be created non-recursively if it doesn't exist. USAGE: .. code-block:: yaml foo: file.save ...
[ "def", "save", "(", "name", ",", "filter", "=", "False", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "''", ",", "'result'", ":", "True", "}", "if", "name", ".", "startswith", "(", "'/'...
Save the register to <salt cachedir>/thorium/saves/<name>, or to an absolute path. If an absolute path is specified, then the directory will be created non-recursively if it doesn't exist. USAGE: .. code-block:: yaml foo: file.save /tmp/foo: file.save
[ "Save", "the", "register", "to", "<salt", "cachedir", ">", "/", "thorium", "/", "saves", "/", "<name", ">", "or", "to", "an", "absolute", "path", "." ]
python
train
bslatkin/dpxdt
dpxdt/server/work_queue_handlers.py
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L59-L78
def handle_lease(queue_name): """Leases a task from a queue.""" owner = request.form.get('owner', request.remote_addr, type=str) try: task_list = work_queue.lease( queue_name, owner, request.form.get('count', 1, type=int), request.form.get('timeout', 6...
[ "def", "handle_lease", "(", "queue_name", ")", ":", "owner", "=", "request", ".", "form", ".", "get", "(", "'owner'", ",", "request", ".", "remote_addr", ",", "type", "=", "str", ")", "try", ":", "task_list", "=", "work_queue", ".", "lease", "(", "queu...
Leases a task from a queue.
[ "Leases", "a", "task", "from", "a", "queue", "." ]
python
train
saulpw/visidata
visidata/clipboard.py
https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/clipboard.py#L79-L90
def copy(self, value): 'Copy a cell to the system clipboard.' with tempfile.NamedTemporaryFile() as temp: with open(temp.name, 'w', encoding=options.encoding) as fp: fp.write(str(value)) p = subprocess.Popen( self.command, stdin=o...
[ "def", "copy", "(", "self", ",", "value", ")", ":", "with", "tempfile", ".", "NamedTemporaryFile", "(", ")", "as", "temp", ":", "with", "open", "(", "temp", ".", "name", ",", "'w'", ",", "encoding", "=", "options", ".", "encoding", ")", "as", "fp", ...
Copy a cell to the system clipboard.
[ "Copy", "a", "cell", "to", "the", "system", "clipboard", "." ]
python
train
inveniosoftware/invenio-files-rest
invenio_files_rest/models.py
https://github.com/inveniosoftware/invenio-files-rest/blob/59a950da61cc8d5882a03c6fde6db2e2ed10befd/invenio_files_rest/models.py#L1006-L1024
def set_location(self, uri, size, checksum, storage_class=None): """Set only URI location of for object. Useful to link files on externally controlled storage. If a file instance has already been set, this methods raises an ``FileInstanceAlreadySetError`` exception. :param uri:...
[ "def", "set_location", "(", "self", ",", "uri", ",", "size", ",", "checksum", ",", "storage_class", "=", "None", ")", ":", "self", ".", "file", "=", "FileInstance", "(", ")", "self", ".", "file", ".", "set_uri", "(", "uri", ",", "size", ",", "checksu...
Set only URI location of for object. Useful to link files on externally controlled storage. If a file instance has already been set, this methods raises an ``FileInstanceAlreadySetError`` exception. :param uri: Full URI to object (which can be interpreted by the storage int...
[ "Set", "only", "URI", "location", "of", "for", "object", "." ]
python
train
BerkeleyAutomation/perception
perception/image.py
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L517-L540
def min_images(images): """Create a min Image from a list of Images. Parameters ---------- :obj:`list` of :obj:`Image` A list of Image objects. Returns ------- :obj:`Image` A new Image of the same type whose data is the min of all of ...
[ "def", "min_images", "(", "images", ")", ":", "images_data", "=", "np", ".", "array", "(", "[", "image", ".", "data", "for", "image", "in", "images", "]", ")", "images_data", "[", "images_data", "==", "0", "]", "=", "np", ".", "inf", "min_image_data", ...
Create a min Image from a list of Images. Parameters ---------- :obj:`list` of :obj:`Image` A list of Image objects. Returns ------- :obj:`Image` A new Image of the same type whose data is the min of all of the images' data.
[ "Create", "a", "min", "Image", "from", "a", "list", "of", "Images", "." ]
python
train
CalebBell/thermo
thermo/chemical.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/chemical.py#L1182-L1197
def charge(self): r'''Charge of a chemical, computed with RDKit from a chemical's SMILES. If RDKit is not available, holds None. Examples -------- >>> Chemical('sodium ion').charge 1 ''' try: if not self.rdkitmol: return charge...
[ "def", "charge", "(", "self", ")", ":", "try", ":", "if", "not", "self", ".", "rdkitmol", ":", "return", "charge_from_formula", "(", "self", ".", "formula", ")", "else", ":", "return", "Chem", ".", "GetFormalCharge", "(", "self", ".", "rdkitmol", ")", ...
r'''Charge of a chemical, computed with RDKit from a chemical's SMILES. If RDKit is not available, holds None. Examples -------- >>> Chemical('sodium ion').charge 1
[ "r", "Charge", "of", "a", "chemical", "computed", "with", "RDKit", "from", "a", "chemical", "s", "SMILES", ".", "If", "RDKit", "is", "not", "available", "holds", "None", "." ]
python
valid
alejandroautalan/pygubu
pygubudesigner/uitreeeditor.py
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L169-L185
def tree_to_xml(self): """Traverses treeview and generates a ElementTree object""" # Need to remove filter or hidden items will not be saved. self.filter_remove(remember=True) tree = self.treeview root = ET.Element('interface') items = tree.get_children() for it...
[ "def", "tree_to_xml", "(", "self", ")", ":", "# Need to remove filter or hidden items will not be saved.", "self", ".", "filter_remove", "(", "remember", "=", "True", ")", "tree", "=", "self", ".", "treeview", "root", "=", "ET", ".", "Element", "(", "'interface'",...
Traverses treeview and generates a ElementTree object
[ "Traverses", "treeview", "and", "generates", "a", "ElementTree", "object" ]
python
train
rocky/python-xdis
xdis/main.py
https://github.com/rocky/python-xdis/blob/46a2902ae8f5d8eee495eed67ac0690fd545453d/xdis/main.py#L157-L222
def disco_loop_asm_format(opc, version, co, real_out, fn_name_map, all_fns): """Produces disassembly in a format more conducive to automatic assembly by producing inner modules before they are used by outer ones. Since this is recusive, we'll use more stack space at runtime. ...
[ "def", "disco_loop_asm_format", "(", "opc", ",", "version", ",", "co", ",", "real_out", ",", "fn_name_map", ",", "all_fns", ")", ":", "if", "version", "<", "3.0", ":", "co", "=", "code2compat", "(", "co", ")", "else", ":", "co", "=", "code3compat", "("...
Produces disassembly in a format more conducive to automatic assembly by producing inner modules before they are used by outer ones. Since this is recusive, we'll use more stack space at runtime.
[ "Produces", "disassembly", "in", "a", "format", "more", "conducive", "to", "automatic", "assembly", "by", "producing", "inner", "modules", "before", "they", "are", "used", "by", "outer", "ones", ".", "Since", "this", "is", "recusive", "we", "ll", "use", "mor...
python
train
sassoftware/saspy
saspy/sasiostdio.py
https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasiostdio.py#L537-L737
def submit(self, code: str, results: str ="html", prompt: dict = None) -> dict: ''' This method is used to submit any SAS code. It returns the Log and Listing as a python dictionary. code - the SAS statements you want to execute results - format of results, HTML is default, TEXT is the altern...
[ "def", "submit", "(", "self", ",", "code", ":", "str", ",", "results", ":", "str", "=", "\"html\"", ",", "prompt", ":", "dict", "=", "None", ")", "->", "dict", ":", "prompt", "=", "prompt", "if", "prompt", "is", "not", "None", "else", "{", "}", "...
This method is used to submit any SAS code. It returns the Log and Listing as a python dictionary. code - the SAS statements you want to execute results - format of results, HTML is default, TEXT is the alternative prompt - dict of names:flags to prompt for; create macro variables (used in submitt...
[ "This", "method", "is", "used", "to", "submit", "any", "SAS", "code", ".", "It", "returns", "the", "Log", "and", "Listing", "as", "a", "python", "dictionary", ".", "code", "-", "the", "SAS", "statements", "you", "want", "to", "execute", "results", "-", ...
python
train
angr/claripy
claripy/vsa/strided_interval.py
https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/vsa/strided_interval.py#L594-L618
def _unsigned_bounds(self): """ Get lower bound and upper bound for `self` in unsigned arithmetic. :return: a list of (lower_bound, upper_bound) tuples. """ ssplit = self._ssplit() if len(ssplit) == 1: lb = ssplit[0].lower_bound ub = ssplit[0].up...
[ "def", "_unsigned_bounds", "(", "self", ")", ":", "ssplit", "=", "self", ".", "_ssplit", "(", ")", "if", "len", "(", "ssplit", ")", "==", "1", ":", "lb", "=", "ssplit", "[", "0", "]", ".", "lower_bound", "ub", "=", "ssplit", "[", "0", "]", ".", ...
Get lower bound and upper bound for `self` in unsigned arithmetic. :return: a list of (lower_bound, upper_bound) tuples.
[ "Get", "lower", "bound", "and", "upper", "bound", "for", "self", "in", "unsigned", "arithmetic", "." ]
python
train
dpkp/kafka-python
kafka/cluster.py
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/cluster.py#L213-L222
def failed_update(self, exception): """Update cluster state given a failed MetadataRequest.""" f = None with self._lock: if self._future: f = self._future self._future = None if f: f.failure(exception) self._last_refresh_ms ...
[ "def", "failed_update", "(", "self", ",", "exception", ")", ":", "f", "=", "None", "with", "self", ".", "_lock", ":", "if", "self", ".", "_future", ":", "f", "=", "self", ".", "_future", "self", ".", "_future", "=", "None", "if", "f", ":", "f", "...
Update cluster state given a failed MetadataRequest.
[ "Update", "cluster", "state", "given", "a", "failed", "MetadataRequest", "." ]
python
train
AN3223/fpbox
fpbox/funcs.py
https://github.com/AN3223/fpbox/blob/d3b88fa6d68b7673c58edf46c89a552a9aedd162/fpbox/funcs.py#L81-L85
def lazy_reverse_binmap(f, xs): """ Same as lazy_binmap, except the parameters are flipped for the binary function """ return (f(y, x) for x, y in zip(xs, xs[1:]))
[ "def", "lazy_reverse_binmap", "(", "f", ",", "xs", ")", ":", "return", "(", "f", "(", "y", ",", "x", ")", "for", "x", ",", "y", "in", "zip", "(", "xs", ",", "xs", "[", "1", ":", "]", ")", ")" ]
Same as lazy_binmap, except the parameters are flipped for the binary function
[ "Same", "as", "lazy_binmap", "except", "the", "parameters", "are", "flipped", "for", "the", "binary", "function" ]
python
train
google/grr
grr/server/grr_response_server/flow.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flow.py#L189-L210
def GetOutputPluginStates(output_plugins, source=None, token=None): """Initializes state for a list of output plugins.""" output_plugins_states = [] for plugin_descriptor in output_plugins: plugin_class = plugin_descriptor.GetPluginClass() try: _, plugin_state = plugin_class.CreatePluginAndDefaultSt...
[ "def", "GetOutputPluginStates", "(", "output_plugins", ",", "source", "=", "None", ",", "token", "=", "None", ")", ":", "output_plugins_states", "=", "[", "]", "for", "plugin_descriptor", "in", "output_plugins", ":", "plugin_class", "=", "plugin_descriptor", ".", ...
Initializes state for a list of output plugins.
[ "Initializes", "state", "for", "a", "list", "of", "output", "plugins", "." ]
python
train
Mic92/python-mpd2
mpd/base.py
https://github.com/Mic92/python-mpd2/blob/fc2782009915d9b642ceef6e4d3b52fa6168998b/mpd/base.py#L133-L159
def mpd_command_provider(cls): """Decorator hooking up registered MPD commands to concrete client implementation. A class using this decorator must inherit from ``MPDClientBase`` and implement it's ``add_command`` function. """ def collect(cls, callbacks=dict()): """Collect MPD command ...
[ "def", "mpd_command_provider", "(", "cls", ")", ":", "def", "collect", "(", "cls", ",", "callbacks", "=", "dict", "(", ")", ")", ":", "\"\"\"Collect MPD command callbacks from given class.\n\n Searches class __dict__ on given class and all it's bases for functions\n ...
Decorator hooking up registered MPD commands to concrete client implementation. A class using this decorator must inherit from ``MPDClientBase`` and implement it's ``add_command`` function.
[ "Decorator", "hooking", "up", "registered", "MPD", "commands", "to", "concrete", "client", "implementation", "." ]
python
train
globus/globus-cli
globus_cli/commands/endpoint/update.py
https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/commands/endpoint/update.py#L17-L41
def endpoint_update(**kwargs): """ Executor for `globus endpoint update` """ # validate params. Requires a get call to check the endpoint type client = get_client() endpoint_id = kwargs.pop("endpoint_id") get_res = client.get_endpoint(endpoint_id) if get_res["host_endpoint_id"]: ...
[ "def", "endpoint_update", "(", "*", "*", "kwargs", ")", ":", "# validate params. Requires a get call to check the endpoint type", "client", "=", "get_client", "(", ")", "endpoint_id", "=", "kwargs", ".", "pop", "(", "\"endpoint_id\"", ")", "get_res", "=", "client", ...
Executor for `globus endpoint update`
[ "Executor", "for", "globus", "endpoint", "update" ]
python
train