repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
coderholic/pyradio
pyradio/radio.py
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L995-L1007
def _print_foreign_playlist_copy_error(self): """ reset previous message """ self.operation_mode = self.window_mode = NORMAL_MODE self.refreshBody() txt ='''Foreign playlist copying |failed|! Make sure the file is not open with another application and try to load...
[ "def", "_print_foreign_playlist_copy_error", "(", "self", ")", ":", "self", ".", "operation_mode", "=", "self", ".", "window_mode", "=", "NORMAL_MODE", "self", ".", "refreshBody", "(", ")", "txt", "=", "'''Foreign playlist copying |failed|!\n\n Make sure the fi...
reset previous message
[ "reset", "previous", "message" ]
python
train
39.230769
pypa/pipenv
pipenv/vendor/urllib3/contrib/securetransport.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/contrib/securetransport.py#L165-L173
def extract_from_urllib3(): """ Undo monkey-patching by :func:`inject_into_urllib3`. """ util.ssl_.SSLContext = orig_util_SSLContext util.HAS_SNI = orig_util_HAS_SNI util.ssl_.HAS_SNI = orig_util_HAS_SNI util.IS_SECURETRANSPORT = False util.ssl_.IS_SECURETRANSPORT = False
[ "def", "extract_from_urllib3", "(", ")", ":", "util", ".", "ssl_", ".", "SSLContext", "=", "orig_util_SSLContext", "util", ".", "HAS_SNI", "=", "orig_util_HAS_SNI", "util", ".", "ssl_", ".", "HAS_SNI", "=", "orig_util_HAS_SNI", "util", ".", "IS_SECURETRANSPORT", ...
Undo monkey-patching by :func:`inject_into_urllib3`.
[ "Undo", "monkey", "-", "patching", "by", ":", "func", ":", "inject_into_urllib3", "." ]
python
train
32.888889
SketchingDev/Doodle-Dashboard
doodledashboard/dashboard.py
https://github.com/SketchingDev/Doodle-Dashboard/blob/4d7f4c248875f82a962c275009aac4aa76bd0320/doodledashboard/dashboard.py#L39-L46
def cycle(self): """ Cycles through notifications with latest results from data feeds. """ messages = self.poll_datafeeds() notifications = self.process_notifications(messages) self.draw_notifications(notifications)
[ "def", "cycle", "(", "self", ")", ":", "messages", "=", "self", ".", "poll_datafeeds", "(", ")", "notifications", "=", "self", ".", "process_notifications", "(", "messages", ")", "self", ".", "draw_notifications", "(", "notifications", ")" ]
Cycles through notifications with latest results from data feeds.
[ "Cycles", "through", "notifications", "with", "latest", "results", "from", "data", "feeds", "." ]
python
test
32.125
psd-tools/psd-tools
src/psd_tools/api/mask.py
https://github.com/psd-tools/psd-tools/blob/4952b57bcf1cf2c1f16fd9d6d51d4fa0b53bce4e/src/psd_tools/api/mask.py#L44-L48
def right(self): """Right coordinate.""" if self._has_real(): return self._data.real_right return self._data.right
[ "def", "right", "(", "self", ")", ":", "if", "self", ".", "_has_real", "(", ")", ":", "return", "self", ".", "_data", ".", "real_right", "return", "self", ".", "_data", ".", "right" ]
Right coordinate.
[ "Right", "coordinate", "." ]
python
train
29.2
zeroSteiner/AdvancedHTTPServer
advancedhttpserver.py
https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L236-L321
def build_server_from_argparser(description=None, server_klass=None, handler_klass=None): """ Build a server from command line arguments. If a ServerClass or HandlerClass is specified, then the object must inherit from the corresponding AdvancedHTTPServer base class. :param str description: Description string to ...
[ "def", "build_server_from_argparser", "(", "description", "=", "None", ",", "server_klass", "=", "None", ",", "handler_klass", "=", "None", ")", ":", "import", "argparse", "def", "_argp_dir_type", "(", "arg", ")", ":", "if", "not", "os", ".", "path", ".", ...
Build a server from command line arguments. If a ServerClass or HandlerClass is specified, then the object must inherit from the corresponding AdvancedHTTPServer base class. :param str description: Description string to be passed to the argument parser. :param server_klass: Alternative server class to use. :type ...
[ "Build", "a", "server", "from", "command", "line", "arguments", ".", "If", "a", "ServerClass", "or", "HandlerClass", "is", "specified", "then", "the", "object", "must", "inherit", "from", "the", "corresponding", "AdvancedHTTPServer", "base", "class", "." ]
python
train
48.139535
vertexproject/synapse
synapse/lib/chop.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/chop.py#L24-L57
def hexstr(text): ''' Ensure a string is valid hex. Args: text (str): String to normalize. Examples: Norm a few strings: hexstr('0xff00') hexstr('ff00') Notes: Will accept strings prefixed by '0x' or '0X' and remove them. Returns: str:...
[ "def", "hexstr", "(", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", ".", "lower", "(", ")", "if", "text", ".", "startswith", "(", "(", "'0x'", ",", "'0X'", ")", ")", ":", "text", "=", "text", "[", "2", ":", "]", "if", "not", ...
Ensure a string is valid hex. Args: text (str): String to normalize. Examples: Norm a few strings: hexstr('0xff00') hexstr('ff00') Notes: Will accept strings prefixed by '0x' or '0X' and remove them. Returns: str: Normalized hex string.
[ "Ensure", "a", "string", "is", "valid", "hex", "." ]
python
train
24.411765
mfcloud/python-zvm-sdk
zvmsdk/networkops.py
https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/networkops.py#L242-L258
def _create_network_doscript(self, network_file_path): """doscript: contains a invokeScript.sh which will do the special work The network.doscript contains network configuration files and it will be used by zvmguestconfigure to configure zLinux os network when it starts up """ ...
[ "def", "_create_network_doscript", "(", "self", ",", "network_file_path", ")", ":", "# Generate the tar package for punch", "LOG", ".", "debug", "(", "'Creating network doscript in the folder %s'", "%", "network_file_path", ")", "network_doscript", "=", "os", ".", "path", ...
doscript: contains a invokeScript.sh which will do the special work The network.doscript contains network configuration files and it will be used by zvmguestconfigure to configure zLinux os network when it starts up
[ "doscript", ":", "contains", "a", "invokeScript", ".", "sh", "which", "will", "do", "the", "special", "work" ]
python
train
46.352941
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L458-L497
def gif_summary(name, tensor, max_outputs=3, fps=10, collections=None, family=None): """Outputs a `Summary` protocol buffer with gif animations. Args: name: Name of the summary. tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width, channels]` where `channels` is 1...
[ "def", "gif_summary", "(", "name", ",", "tensor", ",", "max_outputs", "=", "3", ",", "fps", "=", "10", ",", "collections", "=", "None", ",", "family", "=", "None", ")", ":", "tensor", "=", "tf", ".", "convert_to_tensor", "(", "tensor", ")", "if", "le...
Outputs a `Summary` protocol buffer with gif animations. Args: name: Name of the summary. tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_outputs: Max number of batch elements to generate gifs for. fps: frames per second of t...
[ "Outputs", "a", "Summary", "protocol", "buffer", "with", "gif", "animations", "." ]
python
train
39.3
materialsproject/pymatgen
pymatgen/analysis/elasticity/elastic.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/elasticity/elastic.py#L387-L392
def universal_anisotropy(self): """ returns the universal anisotropy value """ return 5. * self.g_voigt / self.g_reuss + \ self.k_voigt / self.k_reuss - 6.
[ "def", "universal_anisotropy", "(", "self", ")", ":", "return", "5.", "*", "self", ".", "g_voigt", "/", "self", ".", "g_reuss", "+", "self", ".", "k_voigt", "/", "self", ".", "k_reuss", "-", "6." ]
returns the universal anisotropy value
[ "returns", "the", "universal", "anisotropy", "value" ]
python
train
32.333333
TaylorSMarks/playsound
playsound.py
https://github.com/TaylorSMarks/playsound/blob/907f1fe73375a2156f7e0900c4b42c0a60fa1d00/playsound.py#L4-L41
def _playsoundWin(sound, block = True): ''' Utilizes windll.winmm. Tested and known to work with MP3 and WAVE on Windows 7 with Python 2.7. Probably works with more file formats. Probably works on Windows XP thru Windows 10. Probably works with all versions of Python. Inspired by (but not copie...
[ "def", "_playsoundWin", "(", "sound", ",", "block", "=", "True", ")", ":", "from", "ctypes", "import", "c_buffer", ",", "windll", "from", "random", "import", "random", "from", "time", "import", "sleep", "from", "sys", "import", "getfilesystemencoding", "def", ...
Utilizes windll.winmm. Tested and known to work with MP3 and WAVE on Windows 7 with Python 2.7. Probably works with more file formats. Probably works on Windows XP thru Windows 10. Probably works with all versions of Python. Inspired by (but not copied from) Michael Gundlach <gundlach@gmail.com>'s mp3p...
[ "Utilizes", "windll", ".", "winmm", ".", "Tested", "and", "known", "to", "work", "with", "MP3", "and", "WAVE", "on", "Windows", "7", "with", "Python", "2", ".", "7", ".", "Probably", "works", "with", "more", "file", "formats", ".", "Probably", "works", ...
python
train
41.605263
lesscpy/lesscpy
lesscpy/lessc/parser.py
https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/lessc/parser.py#L185-L197
def p_unit_list(self, p): """ unit_list : unit_list unit | unit """ if isinstance(p[1], list): if len(p) >= 3: if isinstance(p[2], list): p[1].extend(p[2]) else: ...
[ "def", "p_unit_list", "(", "self", ",", "p", ")", ":", "if", "isinstance", "(", "p", "[", "1", "]", ",", "list", ")", ":", "if", "len", "(", "p", ")", ">=", "3", ":", "if", "isinstance", "(", "p", "[", "2", "]", ",", "list", ")", ":", "p", ...
unit_list : unit_list unit | unit
[ "unit_list", ":", "unit_list", "unit", "|", "unit" ]
python
valid
29.769231
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/handlers.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/handlers.py#L607-L648
def _process_datum(self, data, input_reader, ctx, transient_shard_state): """Process a single data piece. Call mapper handler on the data. Args: data: a datum to process. input_reader: input reader. ctx: mapreduce context transient_shard_state: transient shard state. Returns: ...
[ "def", "_process_datum", "(", "self", ",", "data", ",", "input_reader", ",", "ctx", ",", "transient_shard_state", ")", ":", "if", "data", "is", "not", "input_readers", ".", "ALLOW_CHECKPOINT", ":", "self", ".", "slice_context", ".", "incr", "(", "context", "...
Process a single data piece. Call mapper handler on the data. Args: data: a datum to process. input_reader: input reader. ctx: mapreduce context transient_shard_state: transient shard state. Returns: True if scan should be continued, False if scan should be stopped.
[ "Process", "a", "single", "data", "piece", "." ]
python
train
31.166667
hazelcast/hazelcast-python-client
hazelcast/transaction.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/transaction.py#L63-L74
def new_transaction(self, timeout, durability, transaction_type): """ Creates a Transaction object with given timeout, durability and transaction type. :param timeout: (long), the timeout in seconds determines the maximum lifespan of a transaction. :param durability: (int), the durabili...
[ "def", "new_transaction", "(", "self", ",", "timeout", ",", "durability", ",", "transaction_type", ")", ":", "connection", "=", "self", ".", "_connect", "(", ")", "return", "Transaction", "(", "self", ".", "_client", ",", "connection", ",", "timeout", ",", ...
Creates a Transaction object with given timeout, durability and transaction type. :param timeout: (long), the timeout in seconds determines the maximum lifespan of a transaction. :param durability: (int), the durability is the number of machines that can take over if a member fails during a ...
[ "Creates", "a", "Transaction", "object", "with", "given", "timeout", "durability", "and", "transaction", "type", "." ]
python
train
69.166667
romanorac/discomll
discomll/ensemble/core/k_medoids.py
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/ensemble/core/k_medoids.py#L8-L41
def fit(sim_mat, D_len, cidx): """ Algorithm maximizes energy between clusters, which is distinction in this algorithm. Distance matrix contains mostly 0, which are overlooked due to search of maximal distances. Algorithm does not try to retain k clusters. D: numpy array - Symmetric distance matrix k: ...
[ "def", "fit", "(", "sim_mat", ",", "D_len", ",", "cidx", ")", ":", "min_energy", "=", "np", ".", "inf", "for", "j", "in", "range", "(", "3", ")", ":", "# select indices in each sample that maximizes its dimension", "inds", "=", "[", "np", ".", "argmin", "(...
Algorithm maximizes energy between clusters, which is distinction in this algorithm. Distance matrix contains mostly 0, which are overlooked due to search of maximal distances. Algorithm does not try to retain k clusters. D: numpy array - Symmetric distance matrix k: int - number of clusters
[ "Algorithm", "maximizes", "energy", "between", "clusters", "which", "is", "distinction", "in", "this", "algorithm", ".", "Distance", "matrix", "contains", "mostly", "0", "which", "are", "overlooked", "due", "to", "search", "of", "maximal", "distances", ".", "Alg...
python
train
39.823529
sphinx-gallery/sphinx-gallery
sphinx_gallery/notebook.py
https://github.com/sphinx-gallery/sphinx-gallery/blob/b0c1f6701bf3f4cef238757e1105cf3686b5e674/sphinx_gallery/notebook.py#L24-L51
def jupyter_notebook_skeleton(): """Returns a dictionary with the elements of a Jupyter notebook""" py_version = sys.version_info notebook_skeleton = { "cells": [], "metadata": { "kernelspec": { "display_name": "Python " + str(py_version[0]), "lang...
[ "def", "jupyter_notebook_skeleton", "(", ")", ":", "py_version", "=", "sys", ".", "version_info", "notebook_skeleton", "=", "{", "\"cells\"", ":", "[", "]", ",", "\"metadata\"", ":", "{", "\"kernelspec\"", ":", "{", "\"display_name\"", ":", "\"Python \"", "+", ...
Returns a dictionary with the elements of a Jupyter notebook
[ "Returns", "a", "dictionary", "with", "the", "elements", "of", "a", "Jupyter", "notebook" ]
python
train
34.464286
spyder-ide/spyder
spyder/plugins/profiler/plugin.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/profiler/plugin.py#L80-L95
def register_plugin(self): """Register plugin in Spyder's main window""" self.profiler.datatree.sig_edit_goto.connect(self.main.editor.load) self.profiler.redirect_stdio.connect( self.main.redirect_internalshell_stdio) self.main.add_dockwidget(self) profiler_act = cr...
[ "def", "register_plugin", "(", "self", ")", ":", "self", ".", "profiler", ".", "datatree", ".", "sig_edit_goto", ".", "connect", "(", "self", ".", "main", ".", "editor", ".", "load", ")", "self", ".", "profiler", ".", "redirect_stdio", ".", "connect", "(...
Register plugin in Spyder's main window
[ "Register", "plugin", "in", "Spyder", "s", "main", "window" ]
python
train
48.5
rackerlabs/yoke
examples/api_gateway_with_authorizer/authorizer/src/policy.py
https://github.com/rackerlabs/yoke/blob/00c01d6217b77f9ce14233a0f3686ac6f7b1c247/examples/api_gateway_with_authorizer/authorizer/src/policy.py#L153-L178
def build(self): """ Generates the policy document based on the internal lists of allowed and denied conditions. This will generate a policy with two main statements for the effect: one statement for Allow and one statement for Deny. Methods that includes conditions will ...
[ "def", "build", "(", "self", ")", ":", "if", "(", "(", "self", ".", "allowMethods", "is", "None", "or", "len", "(", "self", ".", "allowMethods", ")", "==", "0", ")", "and", "(", "self", ".", "denyMethods", "is", "None", "or", "len", "(", "self", ...
Generates the policy document based on the internal lists of allowed and denied conditions. This will generate a policy with two main statements for the effect: one statement for Allow and one statement for Deny. Methods that includes conditions will have their own statement in the polic...
[ "Generates", "the", "policy", "document", "based", "on", "the", "internal", "lists", "of", "allowed", "and", "denied", "conditions", ".", "This", "will", "generate", "a", "policy", "with", "two", "main", "statements", "for", "the", "effect", ":", "one", "sta...
python
valid
39.423077
CivicSpleen/ambry
ambry/orm/partition.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/partition.py#L810-L820
def update_id(self, sequence_id=None): """Alter the sequence id, and all of the names and ids derived from it. This often needs to be done after an IntegrityError in a multiprocessing run""" if sequence_id: self.sequence_id = sequence_id self._set_ids(force=True) i...
[ "def", "update_id", "(", "self", ",", "sequence_id", "=", "None", ")", ":", "if", "sequence_id", ":", "self", ".", "sequence_id", "=", "sequence_id", "self", ".", "_set_ids", "(", "force", "=", "True", ")", "if", "self", ".", "dataset", ":", "self", "....
Alter the sequence id, and all of the names and ids derived from it. This often needs to be done after an IntegrityError in a multiprocessing run
[ "Alter", "the", "sequence", "id", "and", "all", "of", "the", "names", "and", "ids", "derived", "from", "it", ".", "This", "often", "needs", "to", "be", "done", "after", "an", "IntegrityError", "in", "a", "multiprocessing", "run" ]
python
train
32.545455
cgarciae/phi
phi/dsl.py
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L682-L793
def List(self, *branches, **kwargs): """ While `Seq` is sequential, `phi.dsl.Expression.List` allows you to split the computation and get back a list with the result of each path. While the list literal should be the most incarnation of this expresion, it can actually be any iterable (implements `__iter__`) tha...
[ "def", "List", "(", "self", ",", "*", "branches", ",", "*", "*", "kwargs", ")", ":", "gs", "=", "[", "_parse", "(", "code", ")", ".", "_f", "for", "code", "in", "branches", "]", "def", "h", "(", "x", ",", "state", ")", ":", "ys", "=", "[", ...
While `Seq` is sequential, `phi.dsl.Expression.List` allows you to split the computation and get back a list with the result of each path. While the list literal should be the most incarnation of this expresion, it can actually be any iterable (implements `__iter__`) that is not a tuple and yields a valid expresion. T...
[ "While", "Seq", "is", "sequential", "phi", ".", "dsl", ".", "Expression", ".", "List", "allows", "you", "to", "split", "the", "computation", "and", "get", "back", "a", "list", "with", "the", "result", "of", "each", "path", ".", "While", "the", "list", ...
python
train
24.026786
iotile/coretools
iotileemulate/iotile/emulate/internal/emulation_loop.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/internal/emulation_loop.py#L451-L483
async def _clean_shutdown(self): """Cleanly shutdown the emulation loop.""" # Cleanly stop any other outstanding tasks not associated with tiles remaining_tasks = [] for task in self._tasks.get(None, []): self._logger.debug("Cancelling task at shutdown %s", task) ...
[ "async", "def", "_clean_shutdown", "(", "self", ")", ":", "# Cleanly stop any other outstanding tasks not associated with tiles", "remaining_tasks", "=", "[", "]", "for", "task", "in", "self", ".", "_tasks", ".", "get", "(", "None", ",", "[", "]", ")", ":", "sel...
Cleanly shutdown the emulation loop.
[ "Cleanly", "shutdown", "the", "emulation", "loop", "." ]
python
train
30.848485
mivade/tornadose
tornadose/handlers.py
https://github.com/mivade/tornadose/blob/d220e0e3040d24c98997eee7a8a236602b4c5159/tornadose/handlers.py#L102-L107
async def open(self): """Register with the publisher.""" self.store.register(self) while not self.finished: message = await self.messages.get() await self.publish(message)
[ "async", "def", "open", "(", "self", ")", ":", "self", ".", "store", ".", "register", "(", "self", ")", "while", "not", "self", ".", "finished", ":", "message", "=", "await", "self", ".", "messages", ".", "get", "(", ")", "await", "self", ".", "pub...
Register with the publisher.
[ "Register", "with", "the", "publisher", "." ]
python
train
36.5
ThreatConnect-Inc/tcex
tcex/tcex_bin_run.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_run.py#L522-L527
def included_profiles(self): """Load all profiles.""" profiles = [] for directory in self.tcex_json.get('profile_include_dirs') or []: profiles.extend(self._load_config_include(directory)) return profiles
[ "def", "included_profiles", "(", "self", ")", ":", "profiles", "=", "[", "]", "for", "directory", "in", "self", ".", "tcex_json", ".", "get", "(", "'profile_include_dirs'", ")", "or", "[", "]", ":", "profiles", ".", "extend", "(", "self", ".", "_load_con...
Load all profiles.
[ "Load", "all", "profiles", "." ]
python
train
40.5
gem/oq-engine
openquake/commonlib/oqvalidation.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L595-L622
def is_valid_geometry(self): """ It is possible to infer the geometry only if exactly one of sites, sites_csv, hazard_curves_csv, gmfs_csv, region is set. You did set more than one, or nothing. """ has_sites = (self.sites is not None or 'sites' in self.inputs ...
[ "def", "is_valid_geometry", "(", "self", ")", ":", "has_sites", "=", "(", "self", ".", "sites", "is", "not", "None", "or", "'sites'", "in", "self", ".", "inputs", "or", "'site_model'", "in", "self", ".", "inputs", ")", "if", "not", "has_sites", "and", ...
It is possible to infer the geometry only if exactly one of sites, sites_csv, hazard_curves_csv, gmfs_csv, region is set. You did set more than one, or nothing.
[ "It", "is", "possible", "to", "infer", "the", "geometry", "only", "if", "exactly", "one", "of", "sites", "sites_csv", "hazard_curves_csv", "gmfs_csv", "region", "is", "set", ".", "You", "did", "set", "more", "than", "one", "or", "nothing", "." ]
python
train
49.928571
openstax/cnx-easybake
cnxeasybake/oven.py
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L59-L71
def log_decl_method(func): """Decorate do_declartion methods for debug logging.""" from functools import wraps @wraps(func) def with_logging(*args, **kwargs): self = args[0] decl = args[2] log(DEBUG, u" {}: {} {}".format( self.state['current_step'], decl.name, ...
[ "def", "log_decl_method", "(", "func", ")", ":", "from", "functools", "import", "wraps", "@", "wraps", "(", "func", ")", "def", "with_logging", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "decl", "=", "a...
Decorate do_declartion methods for debug logging.
[ "Decorate", "do_declartion", "methods", "for", "debug", "logging", "." ]
python
train
32.692308
google/grr
grr/core/grr_response_core/lib/rdfvalues/client_fs.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/rdfvalues/client_fs.py#L213-L223
def Validate(self): """Ensure the pathspec is valid.""" self.pathspec.Validate() if (self.HasField("start_time") and self.HasField("end_time") and self.start_time > self.end_time): raise ValueError("Start time must be before end time.") if not self.path_regex and not self.data_regex and ...
[ "def", "Validate", "(", "self", ")", ":", "self", ".", "pathspec", ".", "Validate", "(", ")", "if", "(", "self", ".", "HasField", "(", "\"start_time\"", ")", "and", "self", ".", "HasField", "(", "\"end_time\"", ")", "and", "self", ".", "start_time", ">...
Ensure the pathspec is valid.
[ "Ensure", "the", "pathspec", "is", "valid", "." ]
python
train
42.454545
xflr6/gsheets
gsheets/models.py
https://github.com/xflr6/gsheets/blob/ca4f1273044704e529c1138e3f942836fc496e1b/gsheets/models.py#L226-L236
def titles(self, unique=False): """Return a list of contained worksheet titles. Args: unique (bool): drop duplicates Returns: list: list of titles/name strings """ if unique: return tools.uniqued(s.title for s in self._items) return [s...
[ "def", "titles", "(", "self", ",", "unique", "=", "False", ")", ":", "if", "unique", ":", "return", "tools", ".", "uniqued", "(", "s", ".", "title", "for", "s", "in", "self", ".", "_items", ")", "return", "[", "s", ".", "title", "for", "s", "in",...
Return a list of contained worksheet titles. Args: unique (bool): drop duplicates Returns: list: list of titles/name strings
[ "Return", "a", "list", "of", "contained", "worksheet", "titles", "." ]
python
train
30.727273
proycon/pynlpl
pynlpl/formats/folia.py
https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4521-L4539
def append(self, child, *args, **kwargs): """See :meth:`AbstractElement.append`""" #if no set is associated with the layer yet, we learn it from span annotation elements that are added if self.set is False or self.set is None: if inspect.isclass(child): if issubclass(...
[ "def", "append", "(", "self", ",", "child", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#if no set is associated with the layer yet, we learn it from span annotation elements that are added", "if", "self", ".", "set", "is", "False", "or", "self", ".", "set...
See :meth:`AbstractElement.append`
[ "See", ":", "meth", ":", "AbstractElement", ".", "append" ]
python
train
54.894737
SHTOOLS/SHTOOLS
pyshtools/shclasses/shcoeffsgrid.py
https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shcoeffsgrid.py#L1999-L2019
def _expandDH(self, sampling, lmax, lmax_calc): """Evaluate the coefficients on a Driscoll and Healy (1994) grid.""" if self.normalization == '4pi': norm = 1 elif self.normalization == 'schmidt': norm = 2 elif self.normalization == 'unnorm': norm = 3 ...
[ "def", "_expandDH", "(", "self", ",", "sampling", ",", "lmax", ",", "lmax_calc", ")", ":", "if", "self", ".", "normalization", "==", "'4pi'", ":", "norm", "=", "1", "elif", "self", ".", "normalization", "==", "'schmidt'", ":", "norm", "=", "2", "elif",...
Evaluate the coefficients on a Driscoll and Healy (1994) grid.
[ "Evaluate", "the", "coefficients", "on", "a", "Driscoll", "and", "Healy", "(", "1994", ")", "grid", "." ]
python
train
41.619048
upsight/doctor
doctor/docs/base.py
https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/docs/base.py#L787-L804
def define_example_values(self, http_method, route, values, update=False): """Define example values for a given request. By default, example values are determined from the example properties in the schema. But if you want to change the example used in the documentation for a specific ro...
[ "def", "define_example_values", "(", "self", ",", "http_method", ",", "route", ",", "values", ",", "update", "=", "False", ")", ":", "self", ".", "defined_example_values", "[", "(", "http_method", ".", "lower", "(", ")", ",", "route", ")", "]", "=", "{",...
Define example values for a given request. By default, example values are determined from the example properties in the schema. But if you want to change the example used in the documentation for a specific route, and this method lets you do that. :param str http_method: An HTTP method...
[ "Define", "example", "values", "for", "a", "given", "request", "." ]
python
train
48.722222
apache/spark
python/pyspark/rdd.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L247-L258
def unpersist(self, blocking=False): """ Mark the RDD as non-persistent, and remove all blocks for it from memory and disk. .. versionchanged:: 3.0.0 Added optional argument `blocking` to specify whether to block until all blocks are deleted. """ se...
[ "def", "unpersist", "(", "self", ",", "blocking", "=", "False", ")", ":", "self", ".", "is_cached", "=", "False", "self", ".", "_jrdd", ".", "unpersist", "(", "blocking", ")", "return", "self" ]
Mark the RDD as non-persistent, and remove all blocks for it from memory and disk. .. versionchanged:: 3.0.0 Added optional argument `blocking` to specify whether to block until all blocks are deleted.
[ "Mark", "the", "RDD", "as", "non", "-", "persistent", "and", "remove", "all", "blocks", "for", "it", "from", "memory", "and", "disk", "." ]
python
train
32.333333
cloud9ers/gurumate
environment/lib/python2.7/site-packages/psutil/_psosx.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/psutil/_psosx.py#L154-L158
def get_process_cmdline(self): """Return process cmdline as a list of arguments.""" if not pid_exists(self.pid): raise NoSuchProcess(self.pid, self._process_name) return _psutil_osx.get_process_cmdline(self.pid)
[ "def", "get_process_cmdline", "(", "self", ")", ":", "if", "not", "pid_exists", "(", "self", ".", "pid", ")", ":", "raise", "NoSuchProcess", "(", "self", ".", "pid", ",", "self", ".", "_process_name", ")", "return", "_psutil_osx", ".", "get_process_cmdline",...
Return process cmdline as a list of arguments.
[ "Return", "process", "cmdline", "as", "a", "list", "of", "arguments", "." ]
python
test
48.6
HttpRunner/HttpRunner
httprunner/utils.py
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L293-L327
def extend_variables(raw_variables, override_variables): """ extend raw_variables with override_variables. override_variables will merge and override raw_variables. Args: raw_variables (list): override_variables (list): Returns: dict: extended variables mapping Example...
[ "def", "extend_variables", "(", "raw_variables", ",", "override_variables", ")", ":", "if", "not", "raw_variables", ":", "override_variables_mapping", "=", "ensure_mapping_format", "(", "override_variables", ")", "return", "override_variables_mapping", "elif", "not", "ove...
extend raw_variables with override_variables. override_variables will merge and override raw_variables. Args: raw_variables (list): override_variables (list): Returns: dict: extended variables mapping Examples: >>> raw_variables = [{"var1": "val1"}, {"var2": "val2"...
[ "extend", "raw_variables", "with", "override_variables", ".", "override_variables", "will", "merge", "and", "override", "raw_variables", "." ]
python
train
33.457143
adrianliaw/PyCuber
pycuber/solver/cfop/oll.py
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/oll.py#L30-L43
def recognise(self): """ Recognise which is Cube's OLL case. """ if not isinstance(self.cube, Cube): raise ValueError("Use Solver.feed(cube) to feed the cube to solver.") result = "" for face in "LFRB": for square in self.cube.get_face(face)[0]: ...
[ "def", "recognise", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "cube", ",", "Cube", ")", ":", "raise", "ValueError", "(", "\"Use Solver.feed(cube) to feed the cube to solver.\"", ")", "result", "=", "\"\"", "for", "face", "in", "\"LFRB...
Recognise which is Cube's OLL case.
[ "Recognise", "which", "is", "Cube", "s", "OLL", "case", "." ]
python
train
42.285714
Qiskit/qiskit-terra
qiskit/quantum_info/synthesis/two_qubit_kak.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/synthesis/two_qubit_kak.py#L100-L128
def simplify_U(theta, phi, lam): """Return the gate u1, u2, or u3 implementing U with the fewest pulses. The returned gate implements U exactly, not up to a global phase. Args: theta, phi, lam: input Euler rotation angles for a general U gate Returns: Gate: one of IdGate, U1Gate, U2Ga...
[ "def", "simplify_U", "(", "theta", ",", "phi", ",", "lam", ")", ":", "gate", "=", "U3Gate", "(", "theta", ",", "phi", ",", "lam", ")", "# Y rotation is 0 mod 2*pi, so the gate is a u1", "if", "abs", "(", "gate", ".", "params", "[", "0", "]", "%", "(", ...
Return the gate u1, u2, or u3 implementing U with the fewest pulses. The returned gate implements U exactly, not up to a global phase. Args: theta, phi, lam: input Euler rotation angles for a general U gate Returns: Gate: one of IdGate, U1Gate, U2Gate, U3Gate.
[ "Return", "the", "gate", "u1", "u2", "or", "u3", "implementing", "U", "with", "the", "fewest", "pulses", "." ]
python
test
45.103448
addok/addok
addok/autocomplete.py
https://github.com/addok/addok/blob/46a270d76ec778d2b445c2be753e5c6ba070a9b2/addok/autocomplete.py#L128-L133
def do_AUTOCOMPLETE(cmd, s): """Shows autocomplete results for a given token.""" s = list(preprocess_query(s))[0] keys = [k.decode() for k in DB.smembers(edge_ngram_key(s))] print(white(keys)) print(magenta('({} elements)'.format(len(keys))))
[ "def", "do_AUTOCOMPLETE", "(", "cmd", ",", "s", ")", ":", "s", "=", "list", "(", "preprocess_query", "(", "s", ")", ")", "[", "0", "]", "keys", "=", "[", "k", ".", "decode", "(", ")", "for", "k", "in", "DB", ".", "smembers", "(", "edge_ngram_key"...
Shows autocomplete results for a given token.
[ "Shows", "autocomplete", "results", "for", "a", "given", "token", "." ]
python
test
42.833333
gem/oq-engine
openquake/hazardlib/calc/filters.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/calc/filters.py#L289-L296
def get_rectangle(self, src): """ :param src: a source object :returns: ((min_lon, min_lat), width, height), useful for plotting """ min_lon, min_lat, max_lon, max_lat = ( self.integration_distance.get_affected_box(src)) return (min_lon, min_lat), (max_lon - m...
[ "def", "get_rectangle", "(", "self", ",", "src", ")", ":", "min_lon", ",", "min_lat", ",", "max_lon", ",", "max_lat", "=", "(", "self", ".", "integration_distance", ".", "get_affected_box", "(", "src", ")", ")", "return", "(", "min_lon", ",", "min_lat", ...
:param src: a source object :returns: ((min_lon, min_lat), width, height), useful for plotting
[ ":", "param", "src", ":", "a", "source", "object", ":", "returns", ":", "((", "min_lon", "min_lat", ")", "width", "height", ")", "useful", "for", "plotting" ]
python
train
43.125
ARMmbed/icetea
icetea_lib/LogManager.py
https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/LogManager.py#L677-L689
def _get_filehandler_with_formatter(logname, formatter=None): """ Return a logging FileHandler for given logname using a given logging formatter :param logname: Name of the file where logs will be stored, ".log" extension will be added :param formatter: An instance of logging.Formatter or None if th...
[ "def", "_get_filehandler_with_formatter", "(", "logname", ",", "formatter", "=", "None", ")", ":", "handler", "=", "logging", ".", "FileHandler", "(", "logname", ")", "if", "formatter", "is", "not", "None", ":", "handler", ".", "setFormatter", "(", "formatter"...
Return a logging FileHandler for given logname using a given logging formatter :param logname: Name of the file where logs will be stored, ".log" extension will be added :param formatter: An instance of logging.Formatter or None if the default should be used :return:
[ "Return", "a", "logging", "FileHandler", "for", "given", "logname", "using", "a", "given", "logging", "formatter", ":", "param", "logname", ":", "Name", "of", "the", "file", "where", "logs", "will", "be", "stored", ".", "log", "extension", "will", "be", "a...
python
train
37.615385
urinieto/msaf
msaf/algorithms/cnmf/segmenter.py
https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/algorithms/cnmf/segmenter.py#L184-L231
def processFlat(self): """Main process. Returns ------- est_idxs : np.array(N) Estimated indeces for the segment boundaries in frames. est_labels : np.array(N-1) Estimated labels for the segments. """ # C-NMF params niter = self.con...
[ "def", "processFlat", "(", "self", ")", ":", "# C-NMF params", "niter", "=", "self", ".", "config", "[", "\"niters\"", "]", "# Iterations for the MF and clustering", "# Preprocess to obtain features, times, and input boundary indeces", "F", "=", "self", ".", "_preprocess", ...
Main process. Returns ------- est_idxs : np.array(N) Estimated indeces for the segment boundaries in frames. est_labels : np.array(N-1) Estimated labels for the segments.
[ "Main", "process", ".", "Returns", "-------", "est_idxs", ":", "np", ".", "array", "(", "N", ")", "Estimated", "indeces", "for", "the", "segment", "boundaries", "in", "frames", ".", "est_labels", ":", "np", ".", "array", "(", "N", "-", "1", ")", "Estim...
python
test
38.291667
mon/ifstools
ifstools/handlers/TexFolder.py
https://github.com/mon/ifstools/blob/ccd9c1c3632aa22cdcc4e064f17e07803b1d27ba/ifstools/handlers/TexFolder.py#L35-L56
def load(self, draw_bbox = False, **kwargs): ''' Makes the canvas. This could be far speedier if it copied raw pixels, but that would take far too much time to write vs using Image inbuilts ''' im = Image.new('RGBA', self.img_size) draw = None if draw_bbox: ...
[ "def", "load", "(", "self", ",", "draw_bbox", "=", "False", ",", "*", "*", "kwargs", ")", ":", "im", "=", "Image", ".", "new", "(", "'RGBA'", ",", "self", ".", "img_size", ")", "draw", "=", "None", "if", "draw_bbox", ":", "draw", "=", "ImageDraw", ...
Makes the canvas. This could be far speedier if it copied raw pixels, but that would take far too much time to write vs using Image inbuilts
[ "Makes", "the", "canvas", ".", "This", "could", "be", "far", "speedier", "if", "it", "copied", "raw", "pixels", "but", "that", "would", "take", "far", "too", "much", "time", "to", "write", "vs", "using", "Image", "inbuilts" ]
python
train
34.045455
Azure/blobxfer
blobxfer/operations/download.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/download.py#L377-L406
def _check_for_crypto_done(self): # type: (Downloader) -> None """Check queue for crypto done :param Downloader self: this """ cv = self._crypto_offload.done_cv while not self.termination_check: result = None cv.acquire() while True: ...
[ "def", "_check_for_crypto_done", "(", "self", ")", ":", "# type: (Downloader) -> None", "cv", "=", "self", ".", "_crypto_offload", ".", "done_cv", "while", "not", "self", ".", "termination_check", ":", "result", "=", "None", "cv", ".", "acquire", "(", ")", "wh...
Check queue for crypto done :param Downloader self: this
[ "Check", "queue", "for", "crypto", "done", ":", "param", "Downloader", "self", ":", "this" ]
python
train
37.833333
opereto/pyopereto
pyopereto/client.py
https://github.com/opereto/pyopereto/blob/16ca987738a7e1b82b52b0b099794a74ed557223/pyopereto/client.py#L495-L514
def delete_service_version(self, service_id , service_version='default', mode='production'): ''' delete_service(self, service_id, service_version='default', mode='production') Deletes a Service version from Opereto :Parameters: * *service_id* (`string`) -- Service identifier ...
[ "def", "delete_service_version", "(", "self", ",", "service_id", ",", "service_version", "=", "'default'", ",", "mode", "=", "'production'", ")", ":", "return", "self", ".", "_call_rest_api", "(", "'delete'", ",", "'/services/'", "+", "service_id", "+", "'/'", ...
delete_service(self, service_id, service_version='default', mode='production') Deletes a Service version from Opereto :Parameters: * *service_id* (`string`) -- Service identifier * *service_version* (`string`) -- Service version. Default is 'default' * *mode* (`string`) -- deve...
[ "delete_service", "(", "self", "service_id", "service_version", "=", "default", "mode", "=", "production", ")" ]
python
train
37.2
rootpy/rootpy
rootpy/plotting/utils.py
https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/utils.py#L417-L433
def find_all_primitives(pad): """ Recursively find all primities on a pad, even those hiding behind a GetListOfFunctions() of a primitive """ result = [] for primitive in pad.GetListOfPrimitives(): result.append(primitive) if hasattr(primitive, "GetListOfFunctions"): ...
[ "def", "find_all_primitives", "(", "pad", ")", ":", "result", "=", "[", "]", "for", "primitive", "in", "pad", ".", "GetListOfPrimitives", "(", ")", ":", "result", ".", "append", "(", "primitive", ")", "if", "hasattr", "(", "primitive", ",", "\"GetListOfFun...
Recursively find all primities on a pad, even those hiding behind a GetListOfFunctions() of a primitive
[ "Recursively", "find", "all", "primities", "on", "a", "pad", "even", "those", "hiding", "behind", "a", "GetListOfFunctions", "()", "of", "a", "primitive" ]
python
train
35.823529
jldantas/libmft
libmft/api.py
https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/api.py#L946-L972
def get_full_path(self, fn_attr): '''Returns the full path of a FILENAME. The NTFS filesystem allows for things called hardlinks. Hard links are saved, internally, as different filename attributes. Because of this, an entry can, when dealing with full paths, have multiple full paths. ...
[ "def", "get_full_path", "(", "self", ",", "fn_attr", ")", ":", "if", "fn_attr", ".", "header", ".", "attr_type_id", "is", "not", "AttrTypes", ".", "FILE_NAME", ":", "raise", "MFTError", "(", "\"Need a filename attribute to compute full path.\"", ")", "orphan", ","...
Returns the full path of a FILENAME. The NTFS filesystem allows for things called hardlinks. Hard links are saved, internally, as different filename attributes. Because of this, an entry can, when dealing with full paths, have multiple full paths. As such, this function receives a fn_a...
[ "Returns", "the", "full", "path", "of", "a", "FILENAME", "." ]
python
train
47.888889
jamesstidard/sanic-envconfig
sanic_envconfig/__init__.py
https://github.com/jamesstidard/sanic-envconfig/blob/d88f2a23aedbc43604105b5c7d2277ae51157983/sanic_envconfig/__init__.py#L89-L105
def parse(type: Type): """ Register a parser for a attribute type. Parsers will be used to parse `str` type objects from either the commandline arguments or environment variables. Args: type: the type the decorated function will be responsible for pa...
[ "def", "parse", "(", "type", ":", "Type", ")", ":", "def", "decorator", "(", "parser", ")", ":", "EnvVar", ".", "parsers", "[", "type", "]", "=", "parser", "return", "parser", "return", "decorator" ]
Register a parser for a attribute type. Parsers will be used to parse `str` type objects from either the commandline arguments or environment variables. Args: type: the type the decorated function will be responsible for parsing a environment variable to.
[ "Register", "a", "parser", "for", "a", "attribute", "type", "." ]
python
valid
27.882353
zimeon/iiif
iiif/manipulator_netpbm.py
https://github.com/zimeon/iiif/blob/9d10018d01202fa2a76dfa61598dc6eca07b471f/iiif/manipulator_netpbm.py#L72-L90
def do_first(self): """Create PNM file from input image file.""" pid = os.getpid() self.basename = os.path.join(self.tmpdir, 'iiif_netpbm_' + str(pid)) outfile = self.basename + '.pnm' # Convert source file to pnm filetype = self.file_type(self.srcfile) if (filety...
[ "def", "do_first", "(", "self", ")", ":", "pid", "=", "os", ".", "getpid", "(", ")", "self", ".", "basename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "tmpdir", ",", "'iiif_netpbm_'", "+", "str", "(", "pid", ")", ")", "outfile", "="...
Create PNM file from input image file.
[ "Create", "PNM", "file", "from", "input", "image", "file", "." ]
python
train
49.157895
saltstack/salt
salt/modules/upstart_service.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/upstart_service.py#L538-L552
def enable(name, **kwargs): ''' Enable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.enable <service name> ''' if _service_is_upstart(name): return _upstart_enable(name) executable = _get_service_exec() cmd = '{0} -f {1} defaults...
[ "def", "enable", "(", "name", ",", "*", "*", "kwargs", ")", ":", "if", "_service_is_upstart", "(", "name", ")", ":", "return", "_upstart_enable", "(", "name", ")", "executable", "=", "_get_service_exec", "(", ")", "cmd", "=", "'{0} -f {1} defaults'", ".", ...
Enable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.enable <service name>
[ "Enable", "the", "named", "service", "to", "start", "at", "boot" ]
python
train
26.4
vsjha18/nsetools
nse.py
https://github.com/vsjha18/nsetools/blob/c306b568471701c19195d2f17e112cc92022d3e0/nse.py#L323-L347
def get_index_quote(self, code, as_json=False): """ params: code : string index code as_json: True|False returns: a dict | json quote for the given index """ url = self.index_url if self.is_valid_index(code): req = Request(u...
[ "def", "get_index_quote", "(", "self", ",", "code", ",", "as_json", "=", "False", ")", ":", "url", "=", "self", ".", "index_url", "if", "self", ".", "is_valid_index", "(", "code", ")", ":", "req", "=", "Request", "(", "url", ",", "None", ",", "self",...
params: code : string index code as_json: True|False returns: a dict | json quote for the given index
[ "params", ":", "code", ":", "string", "index", "code", "as_json", ":", "True|False", "returns", ":", "a", "dict", "|", "json", "quote", "for", "the", "given", "index" ]
python
train
38.16
sanand0/xmljson
xmljson/__init__.py
https://github.com/sanand0/xmljson/blob/2ecc2065fe7c87b3d282d362289927f13ce7f8b0/xmljson/__init__.py#L149-L173
def data(self, root): '''Convert etree.Element into a dictionary''' value = self.dict() children = [node for node in root if isinstance(node.tag, basestring)] for attr, attrval in root.attrib.items(): attr = attr if self.attr_prefix is None else self.attr_prefix + attr ...
[ "def", "data", "(", "self", ",", "root", ")", ":", "value", "=", "self", ".", "dict", "(", ")", "children", "=", "[", "node", "for", "node", "in", "root", "if", "isinstance", "(", "node", ".", "tag", ",", "basestring", ")", "]", "for", "attr", ",...
Convert etree.Element into a dictionary
[ "Convert", "etree", ".", "Element", "into", "a", "dictionary" ]
python
train
48.28
tensorflow/tensor2tensor
tensor2tensor/envs/trajectory.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/envs/trajectory.py#L201-L266
def step(self, observations, raw_rewards, processed_rewards, dones, actions): """Record the information obtained from taking a step in all envs. Records (observation, rewards, done) in a new time-step and actions in the current time-step. If any trajectory gets done, we move that trajectory to com...
[ "def", "step", "(", "self", ",", "observations", ",", "raw_rewards", ",", "processed_rewards", ",", "dones", ",", "actions", ")", ":", "# Pre-conditions", "assert", "isinstance", "(", "observations", ",", "np", ".", "ndarray", ")", "assert", "isinstance", "(",...
Record the information obtained from taking a step in all envs. Records (observation, rewards, done) in a new time-step and actions in the current time-step. If any trajectory gets done, we move that trajectory to completed_trajectories. Args: observations: ndarray of first dimension self.b...
[ "Record", "the", "information", "obtained", "from", "taking", "a", "step", "in", "all", "envs", "." ]
python
train
42.787879
rosshamish/catanlog
catanlog.py
https://github.com/rosshamish/catanlog/blob/6f204920d9b67fd53fc6ff6a1c7b6a756b009bf0/catanlog.py#L151-L156
def log_player_roll(self, player, roll): """ :param player: catan.game.Player :param roll: integer or string, the sum of the dice """ self._logln('{0} rolls {1}{2}'.format(player.color, roll, ' ...DEUCES!' if int(roll) == 2 else ''))
[ "def", "log_player_roll", "(", "self", ",", "player", ",", "roll", ")", ":", "self", ".", "_logln", "(", "'{0} rolls {1}{2}'", ".", "format", "(", "player", ".", "color", ",", "roll", ",", "' ...DEUCES!'", "if", "int", "(", "roll", ")", "==", "2", "els...
:param player: catan.game.Player :param roll: integer or string, the sum of the dice
[ ":", "param", "player", ":", "catan", ".", "game", ".", "Player", ":", "param", "roll", ":", "integer", "or", "string", "the", "sum", "of", "the", "dice" ]
python
train
44.666667
GaretJax/django-click
djclick/adapter.py
https://github.com/GaretJax/django-click/blob/3584bff81cb7891a1aa2d7fe49c1db501f5b0e84/djclick/adapter.py#L57-L67
def run_from_argv(self, argv): """ Called when run from the command line. """ try: return self.main(args=argv[2:], standalone_mode=False) except click.ClickException as e: if getattr(e.ctx, 'traceback', False): raise e.show() ...
[ "def", "run_from_argv", "(", "self", ",", "argv", ")", ":", "try", ":", "return", "self", ".", "main", "(", "args", "=", "argv", "[", "2", ":", "]", ",", "standalone_mode", "=", "False", ")", "except", "click", ".", "ClickException", "as", "e", ":", ...
Called when run from the command line.
[ "Called", "when", "run", "from", "the", "command", "line", "." ]
python
train
31
danilobellini/audiolazy
audiolazy/lazy_analysis.py
https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_analysis.py#L1147-L1161
def stft(func=None, **kwparams): """ Short Time Fourier Transform for complex data. Same to the default STFT strategy, but with new defaults. This is the same to: .. code-block:: python stft.base(transform=numpy.fft.fft, inverse_transform=numpy.fft.ifft) See ``stft.base`` docs for more. """ from...
[ "def", "stft", "(", "func", "=", "None", ",", "*", "*", "kwparams", ")", ":", "from", "numpy", ".", "fft", "import", "fft", ",", "ifft", "return", "stft", ".", "base", "(", "transform", "=", "fft", ",", "inverse_transform", "=", "ifft", ")", "(", "...
Short Time Fourier Transform for complex data. Same to the default STFT strategy, but with new defaults. This is the same to: .. code-block:: python stft.base(transform=numpy.fft.fft, inverse_transform=numpy.fft.ifft) See ``stft.base`` docs for more.
[ "Short", "Time", "Fourier", "Transform", "for", "complex", "data", "." ]
python
train
27.266667
rootpy/rootpy
rootpy/tree/treemodel.py
https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L122-L139
def to_struct(cls, name=None): """ Convert the TreeModel into a compiled C struct """ if name is None: name = cls.__name__ basic_attrs = dict([(attr_name, value) for attr_name, value in cls.get_attrs() if isinsta...
[ "def", "to_struct", "(", "cls", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "cls", ".", "__name__", "basic_attrs", "=", "dict", "(", "[", "(", "attr_name", ",", "value", ")", "for", "attr_name", ",", "value", "...
Convert the TreeModel into a compiled C struct
[ "Convert", "the", "TreeModel", "into", "a", "compiled", "C", "struct" ]
python
train
37.222222
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L7760-L7780
def latsph(radius, lon, lat): """ Convert from latitudinal coordinates to spherical coordinates. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/latsph_c.html :param radius: Distance of a point from the origin. :param lon: Angle of the point from the XZ plane in radians. :param lat: An...
[ "def", "latsph", "(", "radius", ",", "lon", ",", "lat", ")", ":", "radius", "=", "ctypes", ".", "c_double", "(", "radius", ")", "lon", "=", "ctypes", ".", "c_double", "(", "lon", ")", "lat", "=", "ctypes", ".", "c_double", "(", "lat", ")", "rho", ...
Convert from latitudinal coordinates to spherical coordinates. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/latsph_c.html :param radius: Distance of a point from the origin. :param lon: Angle of the point from the XZ plane in radians. :param lat: Angle of the point from the XY plane in radi...
[ "Convert", "from", "latitudinal", "coordinates", "to", "spherical", "coordinates", "." ]
python
train
36.047619
rochacbruno/flask_simplelogin
flask_simplelogin/__init__.py
https://github.com/rochacbruno/flask_simplelogin/blob/5b319977053649352daa87a6b0632949eee0643c/flask_simplelogin/__init__.py#L49-L57
def is_logged_in(username=None): """Checks if user is logged in if `username` is passed check if specified user is logged in username can be a list""" if username: if not isinstance(username, (list, tuple)): username = [username] return 'simple_logged_in' in session and get_u...
[ "def", "is_logged_in", "(", "username", "=", "None", ")", ":", "if", "username", ":", "if", "not", "isinstance", "(", "username", ",", "(", "list", ",", "tuple", ")", ")", ":", "username", "=", "[", "username", "]", "return", "'simple_logged_in'", "in", ...
Checks if user is logged in if `username` is passed check if specified user is logged in username can be a list
[ "Checks", "if", "user", "is", "logged", "in", "if", "username", "is", "passed", "check", "if", "specified", "user", "is", "logged", "in", "username", "can", "be", "a", "list" ]
python
train
41.555556
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/prefilter.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/prefilter.py#L553-L563
def check(self, line_info): "Allow ! and !! in multi-line statements if multi_line_specials is on" # Note that this one of the only places we check the first character of # ifun and *not* the pre_char. Also note that the below test matches # both ! and !!. if line_info.continue_...
[ "def", "check", "(", "self", ",", "line_info", ")", ":", "# Note that this one of the only places we check the first character of", "# ifun and *not* the pre_char. Also note that the below test matches", "# both ! and !!.", "if", "line_info", ".", "continue_prompt", "and", "self", ...
Allow ! and !! in multi-line statements if multi_line_specials is on
[ "Allow", "!", "and", "!!", "in", "multi", "-", "line", "statements", "if", "multi_line_specials", "is", "on" ]
python
test
49.272727
pvlib/pvlib-python
versioneer.py
https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/versioneer.py#L1044-L1124
def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): """Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* expanded, and _version.py hasn't already been rewritten with a short version string, meani...
[ "def", "git_pieces_from_vcs", "(", "tag_prefix", ",", "root", ",", "verbose", ",", "run_command", "=", "run_command", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "root", ",", "\".git\"", ")", ")", ...
Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* expanded, and _version.py hasn't already been rewritten with a short version string, meaning we're inside a checked out source tree.
[ "Get", "version", "from", "git", "describe", "in", "the", "root", "of", "the", "source", "tree", "." ]
python
train
37.061728
Toilal/rebulk
rebulk/utils.py
https://github.com/Toilal/rebulk/blob/7511a4671f2fd9493e3df1e5177b7656789069e8/rebulk/utils.py#L14-L56
def find_all(string, sub, start=None, end=None, ignore_case=False, **kwargs): """ Return all indices in string s where substring sub is found, such that sub is contained in the slice s[start:end]. >>> list(find_all('The quick brown fox jumps over the lazy dog', 'fox')) [16] >>> list(find_all('...
[ "def", "find_all", "(", "string", ",", "sub", ",", "start", "=", "None", ",", "end", "=", "None", ",", "ignore_case", "=", "False", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=unused-argument", "if", "ignore_case", ":", "sub", "=", "sub", ".", ...
Return all indices in string s where substring sub is found, such that sub is contained in the slice s[start:end]. >>> list(find_all('The quick brown fox jumps over the lazy dog', 'fox')) [16] >>> list(find_all('The quick brown fox jumps over the lazy dog', 'mountain')) [] >>> list(find_all('...
[ "Return", "all", "indices", "in", "string", "s", "where", "substring", "sub", "is", "found", "such", "that", "sub", "is", "contained", "in", "the", "slice", "s", "[", "start", ":", "end", "]", "." ]
python
train
28.232558
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L4062-L4066
def user_sessions(self, user_id, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/sessions#list-sessions" api_path = "/api/v2/users/{user_id}/sessions.json" api_path = api_path.format(user_id=user_id) return self.call(api_path, **kwargs)
[ "def", "user_sessions", "(", "self", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/users/{user_id}/sessions.json\"", "api_path", "=", "api_path", ".", "format", "(", "user_id", "=", "user_id", ")", "return", "self", ".", "call"...
https://developer.zendesk.com/rest_api/docs/core/sessions#list-sessions
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "sessions#list", "-", "sessions" ]
python
train
55.4
gbowerman/azurerm
azurerm/keyvault.py
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/keyvault.py#L79-L96
def get_keyvault(access_token, subscription_id, rgname, vault_name): '''Gets details about the named key vault. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. vault_name (str): ...
[ "def", "get_keyvault", "(", "access_token", ",", "subscription_id", ",", "rgname", ",", "vault_name", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourcegroups/'"...
Gets details about the named key vault. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. vault_name (str): Name of the key vault. Returns: HTTP response. JSON body of key...
[ "Gets", "details", "about", "the", "named", "key", "vault", "." ]
python
train
40.833333
shawalli/psycopg2-pgevents
psycopg2_pgevents/trigger.py
https://github.com/shawalli/psycopg2-pgevents/blob/bf04c05839a27c56834b26748d227c71cd87257c/psycopg2_pgevents/trigger.py#L122-L155
def trigger_installed(connection: connection, table: str, schema: str='public'): """Test whether or not a psycopg2-pgevents trigger is installed for a table. Parameters ---------- connection: psycopg2.extensions.connection Active connection to a PostGreSQL database. table: str Table...
[ "def", "trigger_installed", "(", "connection", ":", "connection", ",", "table", ":", "str", ",", "schema", ":", "str", "=", "'public'", ")", ":", "installed", "=", "False", "log", "(", "'Checking if {}.{} trigger installed...'", ".", "format", "(", "schema", "...
Test whether or not a psycopg2-pgevents trigger is installed for a table. Parameters ---------- connection: psycopg2.extensions.connection Active connection to a PostGreSQL database. table: str Table whose trigger-existence will be checked. schema: str Schema to which the ta...
[ "Test", "whether", "or", "not", "a", "psycopg2", "-", "pgevents", "trigger", "is", "installed", "for", "a", "table", "." ]
python
train
26.617647
ArchiveTeam/wpull
wpull/processor/coprocessor/phantomjs.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/processor/coprocessor/phantomjs.py#L297-L309
def _scrape_document(self): '''Extract links from the DOM.''' mock_response = self._new_mock_response( self._response, self._get_temp_path('phantom', '.html') ) self._item_session.request = self._request self._item_session.response = mock_response self._proc...
[ "def", "_scrape_document", "(", "self", ")", ":", "mock_response", "=", "self", ".", "_new_mock_response", "(", "self", ".", "_response", ",", "self", ".", "_get_temp_path", "(", "'phantom'", ",", "'.html'", ")", ")", "self", ".", "_item_session", ".", "requ...
Extract links from the DOM.
[ "Extract", "links", "from", "the", "DOM", "." ]
python
train
32.307692
dslackw/slpkg
slpkg/slack/slack_version.py
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/slack/slack_version.py#L31-L44
def slack_ver(): """ Open file and read Slackware version """ if _meta_.slackware_version in ["off", "OFF"]: sv = Utils().read_file("/etc/slackware-version") version = re.findall(r"\d+", sv) if len(sv) > 2: return (".".join(version[:2])) else: ret...
[ "def", "slack_ver", "(", ")", ":", "if", "_meta_", ".", "slackware_version", "in", "[", "\"off\"", ",", "\"OFF\"", "]", ":", "sv", "=", "Utils", "(", ")", ".", "read_file", "(", "\"/etc/slackware-version\"", ")", "version", "=", "re", ".", "findall", "("...
Open file and read Slackware version
[ "Open", "file", "and", "read", "Slackware", "version" ]
python
train
27.142857
twitterdev/tweet_parser
tweet_parser/getter_methods/gnip_fields.py
https://github.com/twitterdev/tweet_parser/blob/3435de8367d36b483a6cfd8d46cc28694ee8a42e/tweet_parser/getter_methods/gnip_fields.py#L7-L27
def get_matching_rules(tweet): """ Retrieves the matching rules for a tweet with a gnip field enrichment. Args: tweet (Tweet): the tweet Returns: list: potential ``[{"tag": "user_tag", "value": "rule_value"}]`` pairs from standard rulesets or None if no rules or no mat...
[ "def", "get_matching_rules", "(", "tweet", ")", ":", "if", "is_original_format", "(", "tweet", ")", ":", "rules", "=", "tweet", ".", "get", "(", "\"matching_rules\"", ")", "else", ":", "gnip", "=", "tweet", ".", "get", "(", "\"gnip\"", ")", "rules", "=",...
Retrieves the matching rules for a tweet with a gnip field enrichment. Args: tweet (Tweet): the tweet Returns: list: potential ``[{"tag": "user_tag", "value": "rule_value"}]`` pairs from standard rulesets or None if no rules or no matching_rules field is found. \n More...
[ "Retrieves", "the", "matching", "rules", "for", "a", "tweet", "with", "a", "gnip", "field", "enrichment", "." ]
python
train
30.714286
bcbio/bcbio-nextgen
bcbio/variation/deepvariant.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/deepvariant.py#L70-L78
def _postprocess_variants(record_file, data, ref_file, out_file): """Post-process variants, converting into standard VCF file. """ if not utils.file_uptodate(out_file, record_file): with file_transaction(data, out_file) as tx_out_file: cmd = ["dv_postprocess_variants.py", "--ref", ref_fi...
[ "def", "_postprocess_variants", "(", "record_file", ",", "data", ",", "ref_file", ",", "out_file", ")", ":", "if", "not", "utils", ".", "file_uptodate", "(", "out_file", ",", "record_file", ")", ":", "with", "file_transaction", "(", "data", ",", "out_file", ...
Post-process variants, converting into standard VCF file.
[ "Post", "-", "process", "variants", "converting", "into", "standard", "VCF", "file", "." ]
python
train
55
jmurty/xml4h
xml4h/builder.py
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L261-L271
def ns_prefix(self, prefix, ns_uri): """ Set the namespace prefix of the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.set_ns_prefix`. """ self._element.set_ns_prefix(prefix, ...
[ "def", "ns_prefix", "(", "self", ",", "prefix", ",", "ns_uri", ")", ":", "self", ".", "_element", ".", "set_ns_prefix", "(", "prefix", ",", "ns_uri", ")", "return", "self" ]
Set the namespace prefix of the :class:`xml4h.nodes.Element` node represented by this Builder. :return: the current Builder. Delegates to :meth:`xml4h.nodes.Element.set_ns_prefix`.
[ "Set", "the", "namespace", "prefix", "of", "the", ":", "class", ":", "xml4h", ".", "nodes", ".", "Element", "node", "represented", "by", "this", "Builder", "." ]
python
train
30.636364
gccxml/pygccxml
pygccxml/declarations/container_traits.py
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L488-L494
def element_type(self, type_): """returns reference to the class value\\mapped type declaration""" return self.__find_xxx_type( type_, self.element_type_index, self.element_type_typedef, 'container_element_type')
[ "def", "element_type", "(", "self", ",", "type_", ")", ":", "return", "self", ".", "__find_xxx_type", "(", "type_", ",", "self", ".", "element_type_index", ",", "self", ".", "element_type_typedef", ",", "'container_element_type'", ")" ]
returns reference to the class value\\mapped type declaration
[ "returns", "reference", "to", "the", "class", "value", "\\\\", "mapped", "type", "declaration" ]
python
train
38.571429
project-rig/rig
rig/machine_control/machine_controller.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L151-L159
def scp_data_length(self): """The maximum SCP data field length supported by the machine (bytes). """ # If not known, query the machine if self._scp_data_length is None: data = self.get_software_version(255, 255, 0) self._scp_data_length = data.buffer_size...
[ "def", "scp_data_length", "(", "self", ")", ":", "# If not known, query the machine", "if", "self", ".", "_scp_data_length", "is", "None", ":", "data", "=", "self", ".", "get_software_version", "(", "255", ",", "255", ",", "0", ")", "self", ".", "_scp_data_len...
The maximum SCP data field length supported by the machine (bytes).
[ "The", "maximum", "SCP", "data", "field", "length", "supported", "by", "the", "machine", "(", "bytes", ")", "." ]
python
train
38.777778
pandas-dev/pandas
pandas/io/pytables.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L1095-L1139
def walk(self, where="/"): """ Walk the pytables group hierarchy for pandas objects This generator will yield the group path, subgroups and pandas object names for each group. Any non-pandas PyTables objects that are not a group will be ignored. The `where` group itself is list...
[ "def", "walk", "(", "self", ",", "where", "=", "\"/\"", ")", ":", "_tables", "(", ")", "self", ".", "_check_if_open", "(", ")", "for", "g", "in", "self", ".", "_handle", ".", "walk_groups", "(", "where", ")", ":", "if", "getattr", "(", "g", ".", ...
Walk the pytables group hierarchy for pandas objects This generator will yield the group path, subgroups and pandas object names for each group. Any non-pandas PyTables objects that are not a group will be ignored. The `where` group itself is listed first (preorder), then each of its ...
[ "Walk", "the", "pytables", "group", "hierarchy", "for", "pandas", "objects" ]
python
train
34.911111
saltstack/salt
salt/cloud/libcloudfuncs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L273-L299
def get_image(conn, vm_): ''' Return the image object to use ''' images = conn.list_images() vm_image = config.get_cloud_config_value('image', vm_, __opts__) if not six.PY3: vm_image = vm_image.encode('ascii', 'salt-cloud-force-ascii') for img in images: if isinstance(img.i...
[ "def", "get_image", "(", "conn", ",", "vm_", ")", ":", "images", "=", "conn", ".", "list_images", "(", ")", "vm_image", "=", "config", ".", "get_cloud_config_value", "(", "'image'", ",", "vm_", ",", "__opts__", ")", "if", "not", "six", ".", "PY3", ":",...
Return the image object to use
[ "Return", "the", "image", "object", "to", "use" ]
python
train
34.222222
horazont/aioxmpp
aioxmpp/stringprep.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stringprep.py#L149-L185
def nodeprep(string, allow_unassigned=False): """ Process the given `string` using the Nodeprep (`RFC 6122`_) profile. In the error cases defined in `RFC 3454`_ (stringprep), a :class:`ValueError` is raised. """ chars = list(string) _nodeprep_do_mapping(chars) do_normalization(chars) ...
[ "def", "nodeprep", "(", "string", ",", "allow_unassigned", "=", "False", ")", ":", "chars", "=", "list", "(", "string", ")", "_nodeprep_do_mapping", "(", "chars", ")", "do_normalization", "(", "chars", ")", "check_prohibited_output", "(", "chars", ",", "(", ...
Process the given `string` using the Nodeprep (`RFC 6122`_) profile. In the error cases defined in `RFC 3454`_ (stringprep), a :class:`ValueError` is raised.
[ "Process", "the", "given", "string", "using", "the", "Nodeprep", "(", "RFC", "6122", "_", ")", "profile", ".", "In", "the", "error", "cases", "defined", "in", "RFC", "3454", "_", "(", "stringprep", ")", "a", ":", "class", ":", "ValueError", "is", "rais...
python
train
26.918919
angr/angr
angr/analyses/backward_slice.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/backward_slice.py#L561-L592
def _map_to_cfg(self): """ Map our current slice to CFG. Based on self._statements_per_run and self._exit_statements_per_run, this method will traverse the CFG and check if there is any missing block on the path. If there is, the default exit of that missing block will be includ...
[ "def", "_map_to_cfg", "(", "self", ")", ":", "exit_statements_per_run", "=", "self", ".", "chosen_exits", "new_exit_statements_per_run", "=", "defaultdict", "(", "list", ")", "while", "len", "(", "exit_statements_per_run", ")", ":", "for", "block_address", ",", "e...
Map our current slice to CFG. Based on self._statements_per_run and self._exit_statements_per_run, this method will traverse the CFG and check if there is any missing block on the path. If there is, the default exit of that missing block will be included in the slice. This is because Slicecutor...
[ "Map", "our", "current", "slice", "to", "CFG", "." ]
python
train
50.25
materialsproject/pymatgen
pymatgen/core/surface.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/surface.py#L176-L268
def get_tasker2_slabs(self, tol=0.01, same_species_only=True): """ Get a list of slabs that have been Tasker 2 corrected. Args: tol (float): Tolerance to determine if atoms are within same plane. This is a fractional tolerance, not an absolute one. same_s...
[ "def", "get_tasker2_slabs", "(", "self", ",", "tol", "=", "0.01", ",", "same_species_only", "=", "True", ")", ":", "sites", "=", "list", "(", "self", ".", "sites", ")", "slabs", "=", "[", "]", "sortedcsites", "=", "sorted", "(", "sites", ",", "key", ...
Get a list of slabs that have been Tasker 2 corrected. Args: tol (float): Tolerance to determine if atoms are within same plane. This is a fractional tolerance, not an absolute one. same_species_only (bool): If True, only that are of the exact same specie...
[ "Get", "a", "list", "of", "slabs", "that", "have", "been", "Tasker", "2", "corrected", "." ]
python
train
44.580645
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/scheduler.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/scheduler.py#L99-L110
def schedule(self, callback, *args, **kwargs): """Schedule the callback to be called asynchronously in a thread pool. Args: callback (Callable): The function to call. args: Positional arguments passed to the function. kwargs: Key-word arguments passed to the function...
[ "def", "schedule", "(", "self", ",", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_executor", ".", "submit", "(", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Schedule the callback to be called asynchronously in a thread pool. Args: callback (Callable): The function to call. args: Positional arguments passed to the function. kwargs: Key-word arguments passed to the function. Returns: None
[ "Schedule", "the", "callback", "to", "be", "called", "asynchronously", "in", "a", "thread", "pool", "." ]
python
train
34.5
tensorflow/cleverhans
cleverhans/attacks_tfe.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/attacks_tfe.py#L128-L159
def fgm(self, x, labels, targeted=False): """ TensorFlow Eager implementation of the Fast Gradient Method. :param x: the input variable :param targeted: Is the attack targeted or untargeted? Untargeted, the default, will try to make the label incorrect. Targeted...
[ "def", "fgm", "(", "self", ",", "x", ",", "labels", ",", "targeted", "=", "False", ")", ":", "# Compute loss", "with", "tf", ".", "GradientTape", "(", ")", "as", "tape", ":", "# input should be watched because it may be", "# combination of trainable and non-trainabl...
TensorFlow Eager implementation of the Fast Gradient Method. :param x: the input variable :param targeted: Is the attack targeted or untargeted? Untargeted, the default, will try to make the label incorrect. Targeted will instead try to move in the direction ...
[ "TensorFlow", "Eager", "implementation", "of", "the", "Fast", "Gradient", "Method", ".", ":", "param", "x", ":", "the", "input", "variable", ":", "param", "targeted", ":", "Is", "the", "attack", "targeted", "or", "untargeted?", "Untargeted", "the", "default", ...
python
train
39.40625
wummel/linkchecker
third_party/miniboa-r42/miniboa/telnet.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/miniboa-r42/miniboa/telnet.py#L344-L412
def _iac_sniffer(self, byte): """ Watches incomming data for Telnet IAC sequences. Passes the data, if any, with the IAC commands stripped to _recv_byte(). """ ## Are we not currently in an IAC sequence coming from the DE? if self.telnet_got_iac is False: ...
[ "def", "_iac_sniffer", "(", "self", ",", "byte", ")", ":", "## Are we not currently in an IAC sequence coming from the DE?", "if", "self", ".", "telnet_got_iac", "is", "False", ":", "if", "byte", "==", "IAC", ":", "## Well, we are now", "self", ".", "telnet_got_iac", ...
Watches incomming data for Telnet IAC sequences. Passes the data, if any, with the IAC commands stripped to _recv_byte().
[ "Watches", "incomming", "data", "for", "Telnet", "IAC", "sequences", ".", "Passes", "the", "data", "if", "any", "with", "the", "IAC", "commands", "stripped", "to", "_recv_byte", "()", "." ]
python
train
30.768116
eerimoq/textparser
textparser.py
https://github.com/eerimoq/textparser/blob/5f158210cfd3a20b19775191e92f22a13054a852/textparser.py#L730-L741
def tokenize_init(spec): """Initialize a tokenizer. Should only be called by the :func:`~textparser.Parser.tokenize` method in the parser. """ tokens = [Token('__SOF__', '__SOF__', 0)] re_token = '|'.join([ '(?P<{}>{})'.format(name, regex) for name, regex in spec ]) return tokens,...
[ "def", "tokenize_init", "(", "spec", ")", ":", "tokens", "=", "[", "Token", "(", "'__SOF__'", ",", "'__SOF__'", ",", "0", ")", "]", "re_token", "=", "'|'", ".", "join", "(", "[", "'(?P<{}>{})'", ".", "format", "(", "name", ",", "regex", ")", "for", ...
Initialize a tokenizer. Should only be called by the :func:`~textparser.Parser.tokenize` method in the parser.
[ "Initialize", "a", "tokenizer", ".", "Should", "only", "be", "called", "by", "the", ":", "func", ":", "~textparser", ".", "Parser", ".", "tokenize", "method", "in", "the", "parser", "." ]
python
train
26.5
RLBot/RLBot
src/main/python/rlbot/gui/qt_root.py
https://github.com/RLBot/RLBot/blob/3f9b6bec8b9baf4dcfff0f6cf3103c8744ac6234/src/main/python/rlbot/gui/qt_root.py#L603-L641
def load_agent(self, overall_index: int=None): """ Loads all data for overall_index from the overall config and also loads both presets :param overall_index: the index of the targeted agent :return agent: an Agent (gui_agent) class with all loaded values """ if not self.i...
[ "def", "load_agent", "(", "self", ",", "overall_index", ":", "int", "=", "None", ")", ":", "if", "not", "self", ".", "index_manager", ".", "has_free_slots", "(", ")", ":", "return", "None", "if", "overall_index", "is", "None", ":", "overall_index", "=", ...
Loads all data for overall_index from the overall config and also loads both presets :param overall_index: the index of the targeted agent :return agent: an Agent (gui_agent) class with all loaded values
[ "Loads", "all", "data", "for", "overall_index", "from", "the", "overall", "config", "and", "also", "loads", "both", "presets", ":", "param", "overall_index", ":", "the", "index", "of", "the", "targeted", "agent", ":", "return", "agent", ":", "an", "Agent", ...
python
train
52.871795
aliyun/aliyun-odps-python-sdk
odps/ml/algolib/objects.py
https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/ml/algolib/objects.py#L356-L368
def add_port(self, port): """ Add a port object to the definition :param port: port definition :type port: PortDef """ self.ports.append(port) if port.io_type not in self.port_seqs: self.port_seqs[port.io_type] = 0 self.port_seqs[port.io_type]...
[ "def", "add_port", "(", "self", ",", "port", ")", ":", "self", ".", "ports", ".", "append", "(", "port", ")", "if", "port", ".", "io_type", "not", "in", "self", ".", "port_seqs", ":", "self", ".", "port_seqs", "[", "port", ".", "io_type", "]", "=",...
Add a port object to the definition :param port: port definition :type port: PortDef
[ "Add", "a", "port", "object", "to", "the", "definition" ]
python
train
29.692308
MisterY/gnucash-portfolio
gnucash_portfolio/lib/generic.py
https://github.com/MisterY/gnucash-portfolio/blob/bfaad8345a5479d1cd111acee1939e25c2a638c2/gnucash_portfolio/lib/generic.py#L82-L94
def run_report_from_console(output_file_name, callback): """ Runs the report from the command line. Receives the book url from the console. """ print("The report uses a read-only access to the book.") print("Now enter the data or ^Z to continue:") #report_method = kwargs["report_method"] re...
[ "def", "run_report_from_console", "(", "output_file_name", ",", "callback", ")", ":", "print", "(", "\"The report uses a read-only access to the book.\"", ")", "print", "(", "\"Now enter the data or ^Z to continue:\"", ")", "#report_method = kwargs[\"report_method\"]", "result", ...
Runs the report from the command line. Receives the book url from the console.
[ "Runs", "the", "report", "from", "the", "command", "line", ".", "Receives", "the", "book", "url", "from", "the", "console", "." ]
python
train
35.153846
juju/charm-helpers
charmhelpers/core/hookenv.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/hookenv.py#L429-L445
def relation_get(attribute=None, unit=None, rid=None): """Get relation information""" _args = ['relation-get', '--format=json'] if rid: _args.append('-r') _args.append(rid) _args.append(attribute or '-') if unit: _args.append(unit) try: return json.loads(subproces...
[ "def", "relation_get", "(", "attribute", "=", "None", ",", "unit", "=", "None", ",", "rid", "=", "None", ")", ":", "_args", "=", "[", "'relation-get'", ",", "'--format=json'", "]", "if", "rid", ":", "_args", ".", "append", "(", "'-r'", ")", "_args", ...
Get relation information
[ "Get", "relation", "information" ]
python
train
28.764706
gwastro/pycbc
pycbc/psd/__init__.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/psd/__init__.py#L537-L556
def associate_psds_to_multi_ifo_segments(opt, fd_segments, gwstrain, flen, delta_f, flow, ifos, dyn_range_factor=1., precision=None): """ Associate PSDs to segments for all ifos when using the multi-detector CLI """ for if...
[ "def", "associate_psds_to_multi_ifo_segments", "(", "opt", ",", "fd_segments", ",", "gwstrain", ",", "flen", ",", "delta_f", ",", "flow", ",", "ifos", ",", "dyn_range_factor", "=", "1.", ",", "precision", "=", "None", ")", ":", "for", "ifo", "in", "ifos", ...
Associate PSDs to segments for all ifos when using the multi-detector CLI
[ "Associate", "PSDs", "to", "segments", "for", "all", "ifos", "when", "using", "the", "multi", "-", "detector", "CLI" ]
python
train
36.1
mdickinson/bigfloat
fabfile.py
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/fabfile.py#L12-L21
def build(python=PYTHON): """Build the bigfloat library for in-place testing.""" clean() local( "LIBRARY_PATH={library_path} CPATH={include_path} {python} " "setup.py build_ext --inplace".format( library_path=LIBRARY_PATH, include_path=INCLUDE_PATH, python...
[ "def", "build", "(", "python", "=", "PYTHON", ")", ":", "clean", "(", ")", "local", "(", "\"LIBRARY_PATH={library_path} CPATH={include_path} {python} \"", "\"setup.py build_ext --inplace\"", ".", "format", "(", "library_path", "=", "LIBRARY_PATH", ",", "include_path", "...
Build the bigfloat library for in-place testing.
[ "Build", "the", "bigfloat", "library", "for", "in", "-", "place", "testing", "." ]
python
train
33
icometrix/dicom2nifti
dicom2nifti/convert_siemens.py
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_siemens.py#L69-L88
def _is_mosaic(dicom_input): """ Use this function to detect if a dicom series is a siemens 4d dataset NOTE: Only the first slice will be checked so you can only provide an already sorted dicom directory (containing one series) """ # for grouped dicoms if type(dicom_input) is list and type(d...
[ "def", "_is_mosaic", "(", "dicom_input", ")", ":", "# for grouped dicoms", "if", "type", "(", "dicom_input", ")", "is", "list", "and", "type", "(", "dicom_input", "[", "0", "]", ")", "is", "list", ":", "header", "=", "dicom_input", "[", "0", "]", "[", ...
Use this function to detect if a dicom series is a siemens 4d dataset NOTE: Only the first slice will be checked so you can only provide an already sorted dicom directory (containing one series)
[ "Use", "this", "function", "to", "detect", "if", "a", "dicom", "series", "is", "a", "siemens", "4d", "dataset", "NOTE", ":", "Only", "the", "first", "slice", "will", "be", "checked", "so", "you", "can", "only", "provide", "an", "already", "sorted", "dico...
python
train
33.8
CivicSpleen/ckcache
ckcache/s3.py
https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/s3.py#L423-L428
def remove(self, rel_path, propagate=False): '''Delete the file from the cache, and from the upstream''' key = self._get_boto_key(rel_path) if key: key.delete()
[ "def", "remove", "(", "self", ",", "rel_path", ",", "propagate", "=", "False", ")", ":", "key", "=", "self", ".", "_get_boto_key", "(", "rel_path", ")", "if", "key", ":", "key", ".", "delete", "(", ")" ]
Delete the file from the cache, and from the upstream
[ "Delete", "the", "file", "from", "the", "cache", "and", "from", "the", "upstream" ]
python
train
32
ministryofjustice/money-to-prisoners-common
mtp_common/build_tasks/executor.py
https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/build_tasks/executor.py#L314-L330
def consume_arguments(self, argument_list): """ Takes arguments from a list while this parameter can accept them """ if len(argument_list) == 0: return [] if argument_list[0] == self.arg_name: argument_list = argument_list[1:] if self.constrain...
[ "def", "consume_arguments", "(", "self", ",", "argument_list", ")", ":", "if", "len", "(", "argument_list", ")", "==", "0", ":", "return", "[", "]", "if", "argument_list", "[", "0", "]", "==", "self", ".", "arg_name", ":", "argument_list", "=", "argument...
Takes arguments from a list while this parameter can accept them
[ "Takes", "arguments", "from", "a", "list", "while", "this", "parameter", "can", "accept", "them" ]
python
train
37.235294
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L837-L863
def asset_create(self, name, items, tag='', description='', atype='static'): '''asset_create_static name, ips, tags, description Create a new asset list with the defined information. UN-DOCUMENTED CALL: This function is not considered stable. :param name: asset list name (must be uniqu...
[ "def", "asset_create", "(", "self", ",", "name", ",", "items", ",", "tag", "=", "''", ",", "description", "=", "''", ",", "atype", "=", "'static'", ")", ":", "data", "=", "{", "'name'", ":", "name", ",", "'description'", ":", "description", ",", "'ty...
asset_create_static name, ips, tags, description Create a new asset list with the defined information. UN-DOCUMENTED CALL: This function is not considered stable. :param name: asset list name (must be unique) :type name: string :param items: list of IP Addresses, CIDR, and Netw...
[ "asset_create_static", "name", "ips", "tags", "description", "Create", "a", "new", "asset", "list", "with", "the", "defined", "information", "." ]
python
train
37
olitheolix/qtmacs
qtmacs/qtmacsmain.py
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L1672-L1809
def qteNextApplet(self, numSkip: int=1, ofsApp: (QtmacsApplet, str)=None, skipInvisible: bool=True, skipVisible: bool=False, skipMiniApplet: bool=True, windowObj: QtmacsWindow=None): """ Return the next applet in cyclic order. If...
[ "def", "qteNextApplet", "(", "self", ",", "numSkip", ":", "int", "=", "1", ",", "ofsApp", ":", "(", "QtmacsApplet", ",", "str", ")", "=", "None", ",", "skipInvisible", ":", "bool", "=", "True", ",", "skipVisible", ":", "bool", "=", "False", ",", "ski...
Return the next applet in cyclic order. If ``ofsApp=None`` then start cycling at the currently active applet. If ``ofsApp`` does not fit the selection criteria, then the cycling starts at the next applet in cyclic order that does. The returned applet is ``numSkip`` items in cyc...
[ "Return", "the", "next", "applet", "in", "cyclic", "order", "." ]
python
train
40.463768
log2timeline/plaso
plaso/storage/sqlite/sqlite_file.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/storage/sqlite/sqlite_file.py#L652-L667
def AddEventTags(self, event_tags): """Adds event tags. Args: event_tags (list[EventTag]): event tags. Raises: IOError: when the storage file is closed or read-only or if the event tags cannot be serialized. OSError: when the storage file is closed or read-only or if ...
[ "def", "AddEventTags", "(", "self", ",", "event_tags", ")", ":", "self", ".", "_RaiseIfNotWritable", "(", ")", "for", "event_tag", "in", "event_tags", ":", "self", ".", "AddEventTag", "(", "event_tag", ")" ]
Adds event tags. Args: event_tags (list[EventTag]): event tags. Raises: IOError: when the storage file is closed or read-only or if the event tags cannot be serialized. OSError: when the storage file is closed or read-only or if the event tags cannot be serialized.
[ "Adds", "event", "tags", "." ]
python
train
28
google/mobly
mobly/controllers/monsoon.py
https://github.com/google/mobly/blob/38ba2cf7d29a20e6a2fca1718eecb337df38db26/mobly/controllers/monsoon.py#L387-L394
def _SendStruct(self, fmt, *args): """Pack a struct (without length or checksum) and send it. """ data = struct.pack(fmt, *args) data_len = len(data) + 1 checksum = (data_len + sum(bytearray(data))) % 256 out = struct.pack("B", data_len) + data + struct.pack("B", checksum...
[ "def", "_SendStruct", "(", "self", ",", "fmt", ",", "*", "args", ")", ":", "data", "=", "struct", ".", "pack", "(", "fmt", ",", "*", "args", ")", "data_len", "=", "len", "(", "data", ")", "+", "1", "checksum", "=", "(", "data_len", "+", "sum", ...
Pack a struct (without length or checksum) and send it.
[ "Pack", "a", "struct", "(", "without", "length", "or", "checksum", ")", "and", "send", "it", "." ]
python
train
42.75
reillysiemens/layabout
layabout.py
https://github.com/reillysiemens/layabout/blob/a146c47f2558e66bb51cf708d39909b93eaea7f4/layabout.py#L177-L186
def _ensure_slack(self, connector: Any, retries: int, backoff: Callable[[int], float]) -> None: """ Ensure we have a SlackClient. """ connector = self._env_var if connector is None else connector slack: SlackClient = _create_slack(connector) self._slack = _SlackClie...
[ "def", "_ensure_slack", "(", "self", ",", "connector", ":", "Any", ",", "retries", ":", "int", ",", "backoff", ":", "Callable", "[", "[", "int", "]", ",", "float", "]", ")", "->", "None", ":", "connector", "=", "self", ".", "_env_var", "if", "connect...
Ensure we have a SlackClient.
[ "Ensure", "we", "have", "a", "SlackClient", "." ]
python
train
41.3
hatemile/hatemile-for-python
hatemile/implementation/event.py
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/event.py#L61-L81
def _keyboard_access(self, element): """ Provide keyboard access for element, if it not has. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement """ # pylint: disable=no-self-use if not element.has_attribute('tabindex'): ...
[ "def", "_keyboard_access", "(", "self", ",", "element", ")", ":", "# pylint: disable=no-self-use", "if", "not", "element", ".", "has_attribute", "(", "'tabindex'", ")", ":", "tag", "=", "element", ".", "get_tag_name", "(", ")", "if", "(", "tag", "==", "'A'",...
Provide keyboard access for element, if it not has. :param element: The element. :type element: hatemile.util.html.htmldomelement.HTMLDOMElement
[ "Provide", "keyboard", "access", "for", "element", "if", "it", "not", "has", "." ]
python
train
35
dgraph-io/pydgraph
pydgraph/client_stub.py
https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/client_stub.py#L53-L56
def mutate(self, mutation, timeout=None, metadata=None, credentials=None): """Runs mutate operation.""" return self.stub.Mutate(mutation, timeout=timeout, metadata=metadata, credentials=credentials)
[ "def", "mutate", "(", "self", ",", "mutation", ",", "timeout", "=", "None", ",", "metadata", "=", "None", ",", "credentials", "=", "None", ")", ":", "return", "self", ".", "stub", ".", "Mutate", "(", "mutation", ",", "timeout", "=", "timeout", ",", "...
Runs mutate operation.
[ "Runs", "mutate", "operation", "." ]
python
train
60.75
mandiant/ioc_writer
ioc_writer/utils/xmlutils.py
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/utils/xmlutils.py#L60-L96
def remove_namespace(doc, namespace): """ Takes in a ElementTree object and namespace value. The length of that namespace value is removed from all Element nodes within the document. This effectively removes the namespace from that document. :param doc: lxml.etree :param namespace: Namespace t...
[ "def", "remove_namespace", "(", "doc", ",", "namespace", ")", ":", "# http://homework.nwsnet.de/products/45be_remove-namespace-in-an-xml-document-using-elementtree", "#", "# Permission is hereby granted, free of charge, to any person obtaining", "# a copy of this software and associated docume...
Takes in a ElementTree object and namespace value. The length of that namespace value is removed from all Element nodes within the document. This effectively removes the namespace from that document. :param doc: lxml.etree :param namespace: Namespace that needs to be removed. :return: Returns the ...
[ "Takes", "in", "a", "ElementTree", "object", "and", "namespace", "value", ".", "The", "length", "of", "that", "namespace", "value", "is", "removed", "from", "all", "Element", "nodes", "within", "the", "document", ".", "This", "effectively", "removes", "the", ...
python
train
49.405405
Robpol86/libnl
libnl/nl.py
https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl.py#L213-L242
def nl_complete_msg(sk, msg): """Finalize Netlink message. https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L450 This function finalizes a Netlink message by completing the message with desirable flags and values depending on the socket configuration. - If not yet filled out, the source...
[ "def", "nl_complete_msg", "(", "sk", ",", "msg", ")", ":", "nlh", "=", "msg", ".", "nm_nlh", "if", "nlh", ".", "nlmsg_pid", "==", "NL_AUTO_PORT", ":", "nlh", ".", "nlmsg_pid", "=", "nl_socket_get_local_port", "(", "sk", ")", "if", "nlh", ".", "nlmsg_seq"...
Finalize Netlink message. https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L450 This function finalizes a Netlink message by completing the message with desirable flags and values depending on the socket configuration. - If not yet filled out, the source address of the message (`nlmsg_pid`)...
[ "Finalize", "Netlink", "message", "." ]
python
train
42.566667
titusjan/argos
argos/collect/collector.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/collect/collector.py#L180-L190
def clearAndSetComboBoxes(self, axesNames): """ Removes all comboboxes. """ logger.debug("Collector clearAndSetComboBoxes: {}".format(axesNames)) check_is_a_sequence(axesNames) row = 0 self._deleteComboBoxes(row) self.clear() self._setAxesNames(axesNames) ...
[ "def", "clearAndSetComboBoxes", "(", "self", ",", "axesNames", ")", ":", "logger", ".", "debug", "(", "\"Collector clearAndSetComboBoxes: {}\"", ".", "format", "(", "axesNames", ")", ")", "check_is_a_sequence", "(", "axesNames", ")", "row", "=", "0", "self", "."...
Removes all comboboxes.
[ "Removes", "all", "comboboxes", "." ]
python
train
34.090909
f3at/feat
src/feat/database/tools.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/database/tools.py#L279-L313
def define_standalone_options(parser, extra_options=None): ''' Adds the options specific to the database connection. Parses the agency configuration files and uses its configuration as the default values. ''' c = config.parse_service_config() parser.add_option('--dbhost', '-H', action='stor...
[ "def", "define_standalone_options", "(", "parser", ",", "extra_options", "=", "None", ")", ":", "c", "=", "config", ".", "parse_service_config", "(", ")", "parser", ".", "add_option", "(", "'--dbhost'", ",", "'-H'", ",", "action", "=", "'store'", ",", "dest"...
Adds the options specific to the database connection. Parses the agency configuration files and uses its configuration as the default values.
[ "Adds", "the", "options", "specific", "to", "the", "database", "connection", ".", "Parses", "the", "agency", "configuration", "files", "and", "uses", "its", "configuration", "as", "the", "default", "values", "." ]
python
train
46.314286
mosdef-hub/mbuild
mbuild/compound.py
https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/compound.py#L1205-L1229
def update_coordinates(self, filename, update_port_locations=True): """Update the coordinates of this Compound from a file. Parameters ---------- filename : str Name of file from which to load coordinates. Supported file types are the same as those supported by l...
[ "def", "update_coordinates", "(", "self", ",", "filename", ",", "update_port_locations", "=", "True", ")", ":", "if", "update_port_locations", ":", "xyz_init", "=", "self", ".", "xyz", "self", "=", "load", "(", "filename", ",", "compound", "=", "self", ",", ...
Update the coordinates of this Compound from a file. Parameters ---------- filename : str Name of file from which to load coordinates. Supported file types are the same as those supported by load() update_port_locations : bool, optional, default=True ...
[ "Update", "the", "coordinates", "of", "this", "Compound", "from", "a", "file", "." ]
python
train
41
Microsoft/nni
examples/trials/weight_sharing/ga_squad/graph_to_tf.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/graph_to_tf.py#L208-L240
def feedforward(inputs, num_units, scope="multihead_attention"): '''Point-wise feed forward net. Args: inputs: A 3d tensor with shape of [N, T, C]. num_units: A list of two integers. scope: Optional scope for `variable_scope`. reuse: Boolean, whether to r...
[ "def", "feedforward", "(", "inputs", ",", "num_units", ",", "scope", "=", "\"multihead_attention\"", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ")", ":", "# Inner layer", "params", "=", "{", "\"inputs\"", ":", "inputs", ",", "\"filters\"", ...
Point-wise feed forward net. Args: inputs: A 3d tensor with shape of [N, T, C]. num_units: A list of two integers. scope: Optional scope for `variable_scope`. reuse: Boolean, whether to reuse the weights of a previous layer by the same name. Returns: A 3d tensor with the ...
[ "Point", "-", "wise", "feed", "forward", "net", "." ]
python
train
30.727273
saltstack/salt
salt/utils/gitfs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1919-L1940
def setup_callbacks(self): ''' Assign attributes for pygit2 callbacks ''' if PYGIT2_VERSION >= _LooseVersion('0.23.2'): self.remotecallbacks = pygit2.RemoteCallbacks( credentials=self.credentials) if not self.ssl_verify: # Override ...
[ "def", "setup_callbacks", "(", "self", ")", ":", "if", "PYGIT2_VERSION", ">=", "_LooseVersion", "(", "'0.23.2'", ")", ":", "self", ".", "remotecallbacks", "=", "pygit2", ".", "RemoteCallbacks", "(", "credentials", "=", "self", ".", "credentials", ")", "if", ...
Assign attributes for pygit2 callbacks
[ "Assign", "attributes", "for", "pygit2", "callbacks" ]
python
train
43.318182