repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
BerkeleyAutomation/perception
perception/image.py
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1306-L1346
def segment_kmeans(self, rgb_weight, num_clusters, hue_weight=0.0): """ Segment a color image using KMeans based on spatial and color distances. Black pixels will automatically be assigned to their own 'background' cluster. Parameters ---------- rgb_weight : float ...
[ "def", "segment_kmeans", "(", "self", ",", "rgb_weight", ",", "num_clusters", ",", "hue_weight", "=", "0.0", ")", ":", "# form features array", "label_offset", "=", "1", "nonzero_px", "=", "np", ".", "where", "(", "self", ".", "data", "!=", "0.0", ")", "no...
Segment a color image using KMeans based on spatial and color distances. Black pixels will automatically be assigned to their own 'background' cluster. Parameters ---------- rgb_weight : float weighting of RGB distance relative to spatial and hue distance num_cluster...
[ "Segment", "a", "color", "image", "using", "KMeans", "based", "on", "spatial", "and", "color", "distances", ".", "Black", "pixels", "will", "automatically", "be", "assigned", "to", "their", "own", "background", "cluster", "." ]
python
train
expfactory/expfactory
expfactory/variables.py
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/variables.py#L263-L294
def validate_header(header, required_fields=None): '''validate_header ensures that the first row contains the exp_id, var_name, var_value, and token. Capitalization isn't important, but ordering is. This criteria is very strict, but it's reasonable to require. Parameters =======...
[ "def", "validate_header", "(", "header", ",", "required_fields", "=", "None", ")", ":", "if", "required_fields", "is", "None", ":", "required_fields", "=", "[", "'exp_id'", ",", "'var_name'", ",", "'var_value'", ",", "'token'", "]", "# The required length of the h...
validate_header ensures that the first row contains the exp_id, var_name, var_value, and token. Capitalization isn't important, but ordering is. This criteria is very strict, but it's reasonable to require. Parameters ========== header: the header row, as a list requir...
[ "validate_header", "ensures", "that", "the", "first", "row", "contains", "the", "exp_id", "var_name", "var_value", "and", "token", ".", "Capitalization", "isn", "t", "important", "but", "ordering", "is", ".", "This", "criteria", "is", "very", "strict", "but", ...
python
train
Azure/azure-multiapi-storage-python
azure/multiapi/storage/v2015_04_05/table/_request.py
https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2015_04_05/table/_request.py#L49-L62
def _insert_entity(entity): ''' Constructs an insert entity request. ''' _validate_entity(entity) request = HTTPRequest() request.method = 'POST' request.headers = [_DEFAULT_CONTENT_TYPE_HEADER, _DEFAULT_PREFER_HEADER, _DEFAULT_ACCEPT_HEADER] ...
[ "def", "_insert_entity", "(", "entity", ")", ":", "_validate_entity", "(", "entity", ")", "request", "=", "HTTPRequest", "(", ")", "request", ".", "method", "=", "'POST'", "request", ".", "headers", "=", "[", "_DEFAULT_CONTENT_TYPE_HEADER", ",", "_DEFAULT_PREFER...
Constructs an insert entity request.
[ "Constructs", "an", "insert", "entity", "request", "." ]
python
train
pywavefront/PyWavefront
pywavefront/visualization.py
https://github.com/pywavefront/PyWavefront/blob/39ee5186cb37750d4654d19ebe43f723ecd01e2f/pywavefront/visualization.py#L134-L138
def load_image(name): """Load an image""" image = pyglet.image.load(name).texture verify_dimensions(image) return image
[ "def", "load_image", "(", "name", ")", ":", "image", "=", "pyglet", ".", "image", ".", "load", "(", "name", ")", ".", "texture", "verify_dimensions", "(", "image", ")", "return", "image" ]
Load an image
[ "Load", "an", "image" ]
python
train
pallets/werkzeug
examples/simplewiki/actions.py
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/examples/simplewiki/actions.py#L96-L139
def on_diff(request, page_name): """Show the diff between two revisions.""" old = request.args.get("old", type=int) new = request.args.get("new", type=int) error = "" diff = page = old_rev = new_rev = None if not (old and new): error = "No revisions specified." else: revisio...
[ "def", "on_diff", "(", "request", ",", "page_name", ")", ":", "old", "=", "request", ".", "args", ".", "get", "(", "\"old\"", ",", "type", "=", "int", ")", "new", "=", "request", ".", "args", ".", "get", "(", "\"new\"", ",", "type", "=", "int", "...
Show the diff between two revisions.
[ "Show", "the", "diff", "between", "two", "revisions", "." ]
python
train
rackerlabs/simpl
simpl/config.py
https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/config.py#L685-L703
def load_options(self, argv=None, keyring_namespace=None): """Find settings from all sources. Only performs data type validation. Does not perform validation on required, extra/unknown, or mutually exclusive options. To perform that call `validate_config`. """ defaults =...
[ "def", "load_options", "(", "self", ",", "argv", "=", "None", ",", "keyring_namespace", "=", "None", ")", ":", "defaults", "=", "self", ".", "get_defaults", "(", ")", "args", "=", "self", ".", "cli_values", "(", "argv", "=", "argv", ")", "env", "=", ...
Find settings from all sources. Only performs data type validation. Does not perform validation on required, extra/unknown, or mutually exclusive options. To perform that call `validate_config`.
[ "Find", "settings", "from", "all", "sources", "." ]
python
train
coderholic/pyradio
pyradio/radio.py
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L442-L468
def _goto_playing_station(self, changing_playlist=False): """ make sure playing station is visible """ if (self.player.isPlaying() or self.operation_mode == PLAYLIST_MODE) and \ (self.selection != self.playing or changing_playlist): if changing_playlist: self.star...
[ "def", "_goto_playing_station", "(", "self", ",", "changing_playlist", "=", "False", ")", ":", "if", "(", "self", ".", "player", ".", "isPlaying", "(", ")", "or", "self", ".", "operation_mode", "==", "PLAYLIST_MODE", ")", "and", "(", "self", ".", "selectio...
make sure playing station is visible
[ "make", "sure", "playing", "station", "is", "visible" ]
python
train
wmayner/pyphi
pyphi/validate.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/validate.py#L74-L90
def conditionally_independent(tpm): """Validate that the TPM is conditionally independent.""" if not config.VALIDATE_CONDITIONAL_INDEPENDENCE: return True tpm = np.array(tpm) if is_state_by_state(tpm): there_and_back_again = convert.state_by_node2state_by_state( convert.state...
[ "def", "conditionally_independent", "(", "tpm", ")", ":", "if", "not", "config", ".", "VALIDATE_CONDITIONAL_INDEPENDENCE", ":", "return", "True", "tpm", "=", "np", ".", "array", "(", "tpm", ")", "if", "is_state_by_state", "(", "tpm", ")", ":", "there_and_back_...
Validate that the TPM is conditionally independent.
[ "Validate", "that", "the", "TPM", "is", "conditionally", "independent", "." ]
python
train
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L350-L399
def convert_ages(Recs, data_model=3): """ converts ages to Ma Parameters _________ Recs : list of dictionaries in data model by data_model data_model : MagIC data model (default is 3) """ if data_model == 3: site_key = 'site' agekey = "age" keybase = "" else: ...
[ "def", "convert_ages", "(", "Recs", ",", "data_model", "=", "3", ")", ":", "if", "data_model", "==", "3", ":", "site_key", "=", "'site'", "agekey", "=", "\"age\"", "keybase", "=", "\"\"", "else", ":", "site_key", "=", "'er_site_names'", "agekey", "=", "f...
converts ages to Ma Parameters _________ Recs : list of dictionaries in data model by data_model data_model : MagIC data model (default is 3)
[ "converts", "ages", "to", "Ma", "Parameters", "_________", "Recs", ":", "list", "of", "dictionaries", "in", "data", "model", "by", "data_model", "data_model", ":", "MagIC", "data", "model", "(", "default", "is", "3", ")" ]
python
train
ev3dev/ev3dev-lang-python
ev3dev2/motor.py
https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/motor.py#L2434-L2584
def angle_to_speed_percentage(angle): """ The following graphic illustrates the **motor power outputs** for the left and right motors based on where the joystick is pointing, of the form ``(left power, right power)``:: (1, 1) ...
[ "def", "angle_to_speed_percentage", "(", "angle", ")", ":", "if", "0", "<=", "angle", "<=", "45", ":", "# left motor stays at 1", "left_speed_percentage", "=", "1", "# right motor transitions from -1 to 0", "right_speed_percentage", "=", "-", "1", "+", "(", "angle", ...
The following graphic illustrates the **motor power outputs** for the left and right motors based on where the joystick is pointing, of the form ``(left power, right power)``:: (1, 1) . . . . . . . . ...
[ "The", "following", "graphic", "illustrates", "the", "**", "motor", "power", "outputs", "**", "for", "the", "left", "and", "right", "motors", "based", "on", "where", "the", "joystick", "is", "pointing", "of", "the", "form", "(", "left", "power", "right", "...
python
train
saltstack/salt
salt/states/pip_state.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pip_state.py#L184-L273
def _check_if_installed(prefix, state_pkg_name, version_spec, ignore_installed, force_reinstall, upgrade, user, cwd, bin_env, ...
[ "def", "_check_if_installed", "(", "prefix", ",", "state_pkg_name", ",", "version_spec", ",", "ignore_installed", ",", "force_reinstall", ",", "upgrade", ",", "user", ",", "cwd", ",", "bin_env", ",", "env_vars", ",", "index_url", ",", "extra_index_url", ",", "pi...
Takes a package name and version specification (if any) and checks it is installed Keyword arguments include: pip_list: optional dict of installed pip packages, and their versions, to search through to check if the package is installed. If not provided, one will be generated in ...
[ "Takes", "a", "package", "name", "and", "version", "specification", "(", "if", "any", ")", "and", "checks", "it", "is", "installed" ]
python
train
mar10/pyftpsync
ftpsync/targets.py
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/targets.py#L62-L73
def _get_encoding_opt(synchronizer, extra_opts, default): """Helper to figure out encoding setting inside constructors.""" encoding = default # if synchronizer and "encoding" in synchronizer.options: # encoding = synchronizer.options.get("encoding") if extra_opts and "encoding" in extra_opts: ...
[ "def", "_get_encoding_opt", "(", "synchronizer", ",", "extra_opts", ",", "default", ")", ":", "encoding", "=", "default", "# if synchronizer and \"encoding\" in synchronizer.options:", "# encoding = synchronizer.options.get(\"encoding\")", "if", "extra_opts", "and", "\"encodi...
Helper to figure out encoding setting inside constructors.
[ "Helper", "to", "figure", "out", "encoding", "setting", "inside", "constructors", "." ]
python
train
tensorflow/tensor2tensor
tensor2tensor/models/research/transformer_sketch.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/transformer_sketch.py#L55-L62
def transformer_sketch(): """Basic transformer_sketch hparams.""" hparams = transformer.transformer_small() hparams.num_compress_steps = 4 hparams.batch_size = 32 hparams.clip_grad_norm = 2. hparams.sampling_method = "random" return hparams
[ "def", "transformer_sketch", "(", ")", ":", "hparams", "=", "transformer", ".", "transformer_small", "(", ")", "hparams", ".", "num_compress_steps", "=", "4", "hparams", ".", "batch_size", "=", "32", "hparams", ".", "clip_grad_norm", "=", "2.", "hparams", ".",...
Basic transformer_sketch hparams.
[ "Basic", "transformer_sketch", "hparams", "." ]
python
train
donovan-duplessis/pwnurl
pwnurl/models/base.py
https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/models/base.py#L38-L44
def get_by_id(cls, id): """ Get model by identifier """ if any((isinstance(id, basestring) and id.isdigit(), isinstance(id, (int, float)))): return cls.query.get(int(id)) return None
[ "def", "get_by_id", "(", "cls", ",", "id", ")", ":", "if", "any", "(", "(", "isinstance", "(", "id", ",", "basestring", ")", "and", "id", ".", "isdigit", "(", ")", ",", "isinstance", "(", "id", ",", "(", "int", ",", "float", ")", ")", ")", ")",...
Get model by identifier
[ "Get", "model", "by", "identifier" ]
python
train
madzak/python-json-logger
src/pythonjsonlogger/jsonlogger.py
https://github.com/madzak/python-json-logger/blob/687cc52260876fd2189cbb7c5856e3fbaff65279/src/pythonjsonlogger/jsonlogger.py#L25-L39
def merge_record_extra(record, target, reserved): """ Merges extra attributes from LogRecord object into target dictionary :param record: logging.LogRecord :param target: dict to update :param reserved: dict or list with reserved keys to skip """ for key, value in record.__dict__.items(): ...
[ "def", "merge_record_extra", "(", "record", ",", "target", ",", "reserved", ")", ":", "for", "key", ",", "value", "in", "record", ".", "__dict__", ".", "items", "(", ")", ":", "# this allows to have numeric keys", "if", "(", "key", "not", "in", "reserved", ...
Merges extra attributes from LogRecord object into target dictionary :param record: logging.LogRecord :param target: dict to update :param reserved: dict or list with reserved keys to skip
[ "Merges", "extra", "attributes", "from", "LogRecord", "object", "into", "target", "dictionary" ]
python
train
SatelliteQE/nailgun
nailgun/entity_fields.py
https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entity_fields.py#L156-L161
def gen_value(self): """Return a value suitable for a :class:`StringField`.""" return gen_string( gen_choice(self.str_type), gen_integer(self.min_len, self.max_len) )
[ "def", "gen_value", "(", "self", ")", ":", "return", "gen_string", "(", "gen_choice", "(", "self", ".", "str_type", ")", ",", "gen_integer", "(", "self", ".", "min_len", ",", "self", ".", "max_len", ")", ")" ]
Return a value suitable for a :class:`StringField`.
[ "Return", "a", "value", "suitable", "for", "a", ":", "class", ":", "StringField", "." ]
python
train
witchard/grole
grole.py
https://github.com/witchard/grole/blob/54c0bd13e4d4c74a2997ec4254527d937d6e0565/grole.py#L77-L86
async def _buffer_body(self, reader): """ Buffers the body of the request """ remaining = int(self.headers.get('Content-Length', 0)) if remaining > 0: try: self.data = await reader.readexactly(remaining) except asyncio.IncompleteReadError: ...
[ "async", "def", "_buffer_body", "(", "self", ",", "reader", ")", ":", "remaining", "=", "int", "(", "self", ".", "headers", ".", "get", "(", "'Content-Length'", ",", "0", ")", ")", "if", "remaining", ">", "0", ":", "try", ":", "self", ".", "data", ...
Buffers the body of the request
[ "Buffers", "the", "body", "of", "the", "request" ]
python
train
drewsonne/aws-autodiscovery-templater
awsautodiscoverytemplater/command.py
https://github.com/drewsonne/aws-autodiscovery-templater/blob/9ef2edd6a373aeb5d343b841550c210966efe079/awsautodiscoverytemplater/command.py#L128-L146
def generate_file_template_load(path): """ Generate calleable to return the content of the template on disk :param path: :return: """ path = os.path.expanduser(os.path.abspath( path )) def read_file(): """ Read file...
[ "def", "generate_file_template_load", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", "def", "read_file", "(", ")", ":", "\"\"\"\n Read file from path and retur...
Generate calleable to return the content of the template on disk :param path: :return:
[ "Generate", "calleable", "to", "return", "the", "content", "of", "the", "template", "on", "disk", ":", "param", "path", ":", ":", "return", ":" ]
python
train
alex-kostirin/pyatomac
atomac/ldtpd/text.py
https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/ldtpd/text.py#L429-L456
def pastetext(self, window_name, object_name, position=0): """ paste text from start position to end position @param window_name: Window name to type in, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Objec...
[ "def", "pastetext", "(", "self", ",", "window_name", ",", "object_name", ",", "position", "=", "0", ")", ":", "object_handle", "=", "self", ".", "_get_object_handle", "(", "window_name", ",", "object_name", ")", "if", "not", "object_handle", ".", "AXEnabled", ...
paste text from start position to end position @param window_name: Window name to type in, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to type in, either full name, LDTP's name convention, or a Unix ...
[ "paste", "text", "from", "start", "position", "to", "end", "position", "@param", "window_name", ":", "Window", "name", "to", "type", "in", "either", "full", "name", "LDTP", "s", "name", "convention", "or", "a", "Unix", "glob", ".", "@type", "window_name", ...
python
valid
CivicSpleen/ambry
ambry/bundle/bundle.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/bundle.py#L763-L772
def warn(self, message): """Log an error messsage. :param message: Log message. """ if message not in self._warnings: self._warnings.append(message) self.logger.warn(message)
[ "def", "warn", "(", "self", ",", "message", ")", ":", "if", "message", "not", "in", "self", ".", "_warnings", ":", "self", ".", "_warnings", ".", "append", "(", "message", ")", "self", ".", "logger", ".", "warn", "(", "message", ")" ]
Log an error messsage. :param message: Log message.
[ "Log", "an", "error", "messsage", "." ]
python
train
ssato/python-anyconfig
src/anyconfig/backend/ini.py
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/ini.py#L103-L121
def _make_parser(**kwargs): """ :return: (keyword args to be used, parser object) """ # Optional arguements for configparser.SafeConfigParser{,readfp} kwargs_0 = filter_options(("defaults", "dict_type", "allow_no_value"), kwargs) kwargs_1 = filter_options(("filename...
[ "def", "_make_parser", "(", "*", "*", "kwargs", ")", ":", "# Optional arguements for configparser.SafeConfigParser{,readfp}", "kwargs_0", "=", "filter_options", "(", "(", "\"defaults\"", ",", "\"dict_type\"", ",", "\"allow_no_value\"", ")", ",", "kwargs", ")", "kwargs_1...
:return: (keyword args to be used, parser object)
[ ":", "return", ":", "(", "keyword", "args", "to", "be", "used", "parser", "object", ")" ]
python
train
praekeltfoundation/seed-message-sender
message_sender/serializers.py
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/serializers.py#L97-L104
def to_internal_value(self, data): """ Adds extra data to the helper_metadata field. """ if "session_event" in data: data["helper_metadata"]["session_event"] = data["session_event"] return super(InboundSerializer, self).to_internal_value(data)
[ "def", "to_internal_value", "(", "self", ",", "data", ")", ":", "if", "\"session_event\"", "in", "data", ":", "data", "[", "\"helper_metadata\"", "]", "[", "\"session_event\"", "]", "=", "data", "[", "\"session_event\"", "]", "return", "super", "(", "InboundSe...
Adds extra data to the helper_metadata field.
[ "Adds", "extra", "data", "to", "the", "helper_metadata", "field", "." ]
python
train
VingtCinq/python-mailchimp
mailchimp3/entities/storeorders.py
https://github.com/VingtCinq/python-mailchimp/blob/1b472f1b64fdde974732ac4b7ed48908bb707260/mailchimp3/entities/storeorders.py#L50-L109
def create(self, store_id, data): """ Add a new order to a store. :param store_id: The store id. :type store_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "id": string*, "customer": obje...
[ "def", "create", "(", "self", ",", "store_id", ",", "data", ")", ":", "self", ".", "store_id", "=", "store_id", "if", "'id'", "not", "in", "data", ":", "raise", "KeyError", "(", "'The order must have an id'", ")", "if", "'customer'", "not", "in", "data", ...
Add a new order to a store. :param store_id: The store id. :type store_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "id": string*, "customer": object* { "'id": string* ...
[ "Add", "a", "new", "order", "to", "a", "store", "." ]
python
valid
pgmpy/pgmpy
pgmpy/readwrite/PomdpX.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L86-L152
def get_variables(self): """ Returns list of variables of the network Example ------- >>> reader = PomdpXReader("pomdpx.xml") >>> reader.get_variables() {'StateVar': [ {'vnamePrev': 'rover_0', 'vnameCurr': 'rover_1...
[ "def", "get_variables", "(", "self", ")", ":", "self", ".", "variables", "=", "defaultdict", "(", "list", ")", "for", "variable", "in", "self", ".", "network", ".", "findall", "(", "'Variable'", ")", ":", "_variables", "=", "defaultdict", "(", "list", ")...
Returns list of variables of the network Example ------- >>> reader = PomdpXReader("pomdpx.xml") >>> reader.get_variables() {'StateVar': [ {'vnamePrev': 'rover_0', 'vnameCurr': 'rover_1', 'ValueEnum': ['s0...
[ "Returns", "list", "of", "variables", "of", "the", "network" ]
python
train
pantsbuild/pants
src/python/pants/engine/native.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/engine/native.py#L211-L224
def _extern_decl(return_type, arg_types): """A decorator for methods corresponding to extern functions. All types should be strings. The _FFISpecification class is able to automatically convert these into method declarations for cffi. """ def wrapper(func): signature = _ExternSignature( return_type...
[ "def", "_extern_decl", "(", "return_type", ",", "arg_types", ")", ":", "def", "wrapper", "(", "func", ")", ":", "signature", "=", "_ExternSignature", "(", "return_type", "=", "str", "(", "return_type", ")", ",", "method_name", "=", "str", "(", "func", ".",...
A decorator for methods corresponding to extern functions. All types should be strings. The _FFISpecification class is able to automatically convert these into method declarations for cffi.
[ "A", "decorator", "for", "methods", "corresponding", "to", "extern", "functions", ".", "All", "types", "should", "be", "strings", "." ]
python
train
Chilipp/psyplot
psyplot/project.py
https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/project.py#L2345-L2392
def close(num=None, figs=True, data=True, ds=True, remove_only=False): """ Close the project This method closes the current project (figures, data and datasets) or the project specified by `num` Parameters ---------- num: int, None or 'all' if :class:`int`, it specifies the number ...
[ "def", "close", "(", "num", "=", "None", ",", "figs", "=", "True", ",", "data", "=", "True", ",", "ds", "=", "True", ",", "remove_only", "=", "False", ")", ":", "kws", "=", "dict", "(", "figs", "=", "figs", ",", "data", "=", "data", ",", "ds", ...
Close the project This method closes the current project (figures, data and datasets) or the project specified by `num` Parameters ---------- num: int, None or 'all' if :class:`int`, it specifies the number of the project, if None, the current subproject is closed, if ``'all'``, al...
[ "Close", "the", "project" ]
python
train
gijzelaerr/python-snap7
example/example.py
https://github.com/gijzelaerr/python-snap7/blob/a6db134c7a3a2ef187b9eca04669221d6fc634c3/example/example.py#L37-L49
def get_db_row(db, start, size): """ Here you see and example of readying out a part of a DB Args: db (int): The db to use start (int): The index of where to start in db data size (int): The size of the db data to read """ type_ = snap7.snap7types.wordlen_to_ctypes[snap7.sna...
[ "def", "get_db_row", "(", "db", ",", "start", ",", "size", ")", ":", "type_", "=", "snap7", ".", "snap7types", ".", "wordlen_to_ctypes", "[", "snap7", ".", "snap7types", ".", "S7WLByte", "]", "data", "=", "client", ".", "db_read", "(", "db", ",", "star...
Here you see and example of readying out a part of a DB Args: db (int): The db to use start (int): The index of where to start in db data size (int): The size of the db data to read
[ "Here", "you", "see", "and", "example", "of", "readying", "out", "a", "part", "of", "a", "DB" ]
python
train
datosgobar/pydatajson
pydatajson/core.py
https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L153-L189
def _build_index(self): """Itera todos los datasets, distribucioens y fields indexandolos.""" datasets_index = {} distributions_index = {} fields_index = {} # recorre todos los datasets for dataset_index, dataset in enumerate(self.datasets): if "identifier" ...
[ "def", "_build_index", "(", "self", ")", ":", "datasets_index", "=", "{", "}", "distributions_index", "=", "{", "}", "fields_index", "=", "{", "}", "# recorre todos los datasets", "for", "dataset_index", ",", "dataset", "in", "enumerate", "(", "self", ".", "da...
Itera todos los datasets, distribucioens y fields indexandolos.
[ "Itera", "todos", "los", "datasets", "distribucioens", "y", "fields", "indexandolos", "." ]
python
train
tobgu/pyrsistent
pyrsistent/_plist.py
https://github.com/tobgu/pyrsistent/blob/c84dab0daaa44973cbe83830d14888827b307632/pyrsistent/_plist.py#L288-L303
def plist(iterable=(), reverse=False): """ Creates a new persistent list containing all elements of iterable. Optional parameter reverse specifies if the elements should be inserted in reverse order or not. >>> plist([1, 2, 3]) plist([1, 2, 3]) >>> plist([1, 2, 3], reverse=True) plist([...
[ "def", "plist", "(", "iterable", "=", "(", ")", ",", "reverse", "=", "False", ")", ":", "if", "not", "reverse", ":", "iterable", "=", "list", "(", "iterable", ")", "iterable", ".", "reverse", "(", ")", "return", "reduce", "(", "lambda", "pl", ",", ...
Creates a new persistent list containing all elements of iterable. Optional parameter reverse specifies if the elements should be inserted in reverse order or not. >>> plist([1, 2, 3]) plist([1, 2, 3]) >>> plist([1, 2, 3], reverse=True) plist([3, 2, 1])
[ "Creates", "a", "new", "persistent", "list", "containing", "all", "elements", "of", "iterable", ".", "Optional", "parameter", "reverse", "specifies", "if", "the", "elements", "should", "be", "inserted", "in", "reverse", "order", "or", "not", "." ]
python
train
harvard-nrg/yaxil
yaxil/functools/__init__.py
https://github.com/harvard-nrg/yaxil/blob/af594082258e62d1904d6e6841fce0bb5c0bf309/yaxil/functools/__init__.py#L4-L25
def lru_cache(fn): ''' Memoization wrapper that can handle function attributes, mutable arguments, and can be applied either as a decorator or at runtime. :param fn: Function :type fn: function :returns: Memoized function :rtype: function ''' @wraps(fn) def memoized_fn(*args): ...
[ "def", "lru_cache", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "memoized_fn", "(", "*", "args", ")", ":", "pargs", "=", "pickle", ".", "dumps", "(", "args", ")", "if", "pargs", "not", "in", "memoized_fn", ".", "cache", ":", "memoized...
Memoization wrapper that can handle function attributes, mutable arguments, and can be applied either as a decorator or at runtime. :param fn: Function :type fn: function :returns: Memoized function :rtype: function
[ "Memoization", "wrapper", "that", "can", "handle", "function", "attributes", "mutable", "arguments", "and", "can", "be", "applied", "either", "as", "a", "decorator", "or", "at", "runtime", "." ]
python
train
ronaldguillen/wave
wave/authentication.py
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/authentication.py#L132-L139
def enforce_csrf(self, request): """ Enforce CSRF validation for session based authentication. """ reason = CSRFCheck().process_view(request, None, (), {}) if reason: # CSRF failed, bail with explicit error message raise exceptions.PermissionDenied('CSRF F...
[ "def", "enforce_csrf", "(", "self", ",", "request", ")", ":", "reason", "=", "CSRFCheck", "(", ")", ".", "process_view", "(", "request", ",", "None", ",", "(", ")", ",", "{", "}", ")", "if", "reason", ":", "# CSRF failed, bail with explicit error message", ...
Enforce CSRF validation for session based authentication.
[ "Enforce", "CSRF", "validation", "for", "session", "based", "authentication", "." ]
python
train
Robin8Put/pmes
pdms/views.py
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L1359-L1399
async def post(self, public_key): """Writes contents review """ if settings.SIGNATURE_VERIFICATION: super().verify() try: body = json.loads(self.request.body) except: self.set_status(400) self.write({"error":400, "reason":"Unexpected data format. JSON required"}) raise tornado.web.Finish ...
[ "async", "def", "post", "(", "self", ",", "public_key", ")", ":", "if", "settings", ".", "SIGNATURE_VERIFICATION", ":", "super", "(", ")", ".", "verify", "(", ")", "try", ":", "body", "=", "json", ".", "loads", "(", "self", ".", "request", ".", "body...
Writes contents review
[ "Writes", "contents", "review" ]
python
train
wq/html-json-forms
html_json_forms/utils.py
https://github.com/wq/html-json-forms/blob/4dfbfabeee924ba832a7a387ab3b02b6d51d9701/html_json_forms/utils.py#L304-L315
def get_all_items(obj): """ dict.items() but with a separate row for each value in a MultiValueDict """ if hasattr(obj, 'getlist'): items = [] for key in obj: for value in obj.getlist(key): items.append((key, value)) return items else: retu...
[ "def", "get_all_items", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'getlist'", ")", ":", "items", "=", "[", "]", "for", "key", "in", "obj", ":", "for", "value", "in", "obj", ".", "getlist", "(", "key", ")", ":", "items", ".", "appen...
dict.items() but with a separate row for each value in a MultiValueDict
[ "dict", ".", "items", "()", "but", "with", "a", "separate", "row", "for", "each", "value", "in", "a", "MultiValueDict" ]
python
valid
mrooney/mintapi
mintapi/api.py
https://github.com/mrooney/mintapi/blob/44fddbeac79a68da657ad8118e02fcde968f8dfe/mintapi/api.py#L380-L392
def close(self): """Logs out and quits the current web driver/selenium session.""" if not self.driver: return try: self.driver.implicitly_wait(1) self.driver.find_element_by_id('link-logout').click() except NoSuchElementException: pass ...
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "driver", ":", "return", "try", ":", "self", ".", "driver", ".", "implicitly_wait", "(", "1", ")", "self", ".", "driver", ".", "find_element_by_id", "(", "'link-logout'", ")", ".", "click...
Logs out and quits the current web driver/selenium session.
[ "Logs", "out", "and", "quits", "the", "current", "web", "driver", "/", "selenium", "session", "." ]
python
train
sprockets/sprockets.mixins.statsd
sprockets/mixins/statsd/__init__.py
https://github.com/sprockets/sprockets.mixins.statsd/blob/98dcce37d275a3ab96ef618b4756d7c4618a550a/sprockets/mixins/statsd/__init__.py#L89-L130
def on_finish(self): """Invoked once the request has been finished. Increments a counter created in the format: .. code:: <PREFIX>.counters.<host>.package[.module].Class.METHOD.STATUS sprockets.counters.localhost.tornado.web.RequestHandler.GET.200 Adds a value ...
[ "def", "on_finish", "(", "self", ")", ":", "if", "self", ".", "statsd_prefix", "!=", "statsd", ".", "STATSD_PREFIX", ":", "statsd", ".", "set_prefix", "(", "self", ".", "statsd_prefix", ")", "if", "hasattr", "(", "self", ",", "'request'", ")", "and", "se...
Invoked once the request has been finished. Increments a counter created in the format: .. code:: <PREFIX>.counters.<host>.package[.module].Class.METHOD.STATUS sprockets.counters.localhost.tornado.web.RequestHandler.GET.200 Adds a value to a timer in the following form...
[ "Invoked", "once", "the", "request", "has", "been", "finished", ".", "Increments", "a", "counter", "created", "in", "the", "format", ":" ]
python
train
saltstack/salt
salt/modules/debuild_pkgbuild.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/debuild_pkgbuild.py#L594-L945
def make_repo(repodir, keyid=None, env=None, use_passphrase=False, gnupghome='/etc/salt/gpgkeys', runas='root', timeout=15.0): ''' Make a package repository and optionally sign it and packages present Given the repodir (dir...
[ "def", "make_repo", "(", "repodir", ",", "keyid", "=", "None", ",", "env", "=", "None", ",", "use_passphrase", "=", "False", ",", "gnupghome", "=", "'/etc/salt/gpgkeys'", ",", "runas", "=", "'root'", ",", "timeout", "=", "15.0", ")", ":", "res", "=", "...
Make a package repository and optionally sign it and packages present Given the repodir (directory to create repository in), create a Debian repository and optionally sign it and packages present. This state is best used with onchanges linked to your package building states. repodir The direct...
[ "Make", "a", "package", "repository", "and", "optionally", "sign", "it", "and", "packages", "present" ]
python
train
pypa/pipenv
pipenv/vendor/vistir/path.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/path.py#L400-L455
def handle_remove_readonly(func, path, exc): """Error handler for shutil.rmtree. Windows source repo folders are read-only by default, so this error handler attempts to set them as writeable and then proceed with deletion. :param function func: The caller function :param str path: The target path ...
[ "def", "handle_remove_readonly", "(", "func", ",", "path", ",", "exc", ")", ":", "# Check for read-only attribute", "from", ".", "compat", "import", "ResourceWarning", ",", "FileNotFoundError", ",", "PermissionError", "PERM_ERRORS", "=", "(", "errno", ".", "EACCES",...
Error handler for shutil.rmtree. Windows source repo folders are read-only by default, so this error handler attempts to set them as writeable and then proceed with deletion. :param function func: The caller function :param str path: The target path for removal :param Exception exc: The raised exc...
[ "Error", "handler", "for", "shutil", ".", "rmtree", "." ]
python
train
Qiskit/qiskit-terra
qiskit/pulse/pulse_lib/discrete.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L74-L88
def sawtooth(duration: int, amp: complex, period: float = None, phase: float = 0, name: str = None) -> SamplePulse: """Generates sawtooth wave `SamplePulse`. Args: duration: Duration of pulse. Must be greater than zero. amp: Pulse amplitude. Wave range is [-amp, amp]. perio...
[ "def", "sawtooth", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "period", ":", "float", "=", "None", ",", "phase", ":", "float", "=", "0", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "if", "period", "is", ...
Generates sawtooth wave `SamplePulse`. Args: duration: Duration of pulse. Must be greater than zero. amp: Pulse amplitude. Wave range is [-amp, amp]. period: Pulse period, units of dt. If `None` defaults to single cycle. phase: Pulse phase. name: Name of pulse.
[ "Generates", "sawtooth", "wave", "SamplePulse", "." ]
python
test
bsolomon1124/pyfinance
pyfinance/general.py
https://github.com/bsolomon1124/pyfinance/blob/c95925209a809b4e648e79cbeaf7711d8e5ff1a6/pyfinance/general.py#L715-L722
def loadings(self): """Loadings = eigenvectors times sqrt(eigenvalues).""" loadings = self.v[:, : self.keep] * np.sqrt(self.eigenvalues) cols = ["PC%s" % i for i in range(1, self.keep + 1)] loadings = pd.DataFrame( loadings, columns=cols, index=self.feature_names ...
[ "def", "loadings", "(", "self", ")", ":", "loadings", "=", "self", ".", "v", "[", ":", ",", ":", "self", ".", "keep", "]", "*", "np", ".", "sqrt", "(", "self", ".", "eigenvalues", ")", "cols", "=", "[", "\"PC%s\"", "%", "i", "for", "i", "in", ...
Loadings = eigenvectors times sqrt(eigenvalues).
[ "Loadings", "=", "eigenvectors", "times", "sqrt", "(", "eigenvalues", ")", "." ]
python
train
yvesalexandre/bandicoot
bandicoot/individual.py
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/individual.py#L88-L103
def interactions_per_contact(records, direction=None): """ The number of interactions a user had with each of its contacts. Parameters ---------- direction : str, optional Filters the records by their direction: ``None`` for all records, ``'in'`` for incoming, and ``'out'`` for outg...
[ "def", "interactions_per_contact", "(", "records", ",", "direction", "=", "None", ")", ":", "if", "direction", "is", "None", ":", "counter", "=", "Counter", "(", "r", ".", "correspondent_id", "for", "r", "in", "records", ")", "else", ":", "counter", "=", ...
The number of interactions a user had with each of its contacts. Parameters ---------- direction : str, optional Filters the records by their direction: ``None`` for all records, ``'in'`` for incoming, and ``'out'`` for outgoing.
[ "The", "number", "of", "interactions", "a", "user", "had", "with", "each", "of", "its", "contacts", "." ]
python
train
nfcpy/nfcpy
src/nfc/snep/client.py
https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/snep/client.py#L254-L268
def put_records(self, records, timeout=1.0): """Send NDEF message records to a SNEP Server. .. versionadded:: 0.13 The :class:`ndef.Record` list given by *records* is encoded and then send via :meth:`put_octets`. Same as:: import ndef octets = ndef.message_enco...
[ "def", "put_records", "(", "self", ",", "records", ",", "timeout", "=", "1.0", ")", ":", "octets", "=", "b''", ".", "join", "(", "ndef", ".", "message_encoder", "(", "records", ")", ")", "return", "self", ".", "put_octets", "(", "octets", ",", "timeout...
Send NDEF message records to a SNEP Server. .. versionadded:: 0.13 The :class:`ndef.Record` list given by *records* is encoded and then send via :meth:`put_octets`. Same as:: import ndef octets = ndef.message_encoder(records) snep_client.put_octets(octets, ...
[ "Send", "NDEF", "message", "records", "to", "a", "SNEP", "Server", "." ]
python
train
rueckstiess/mtools
mtools/mloginfo/sections/restart_section.py
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/mloginfo/sections/restart_section.py#L35-L47
def run(self): """Run this section and print out information.""" if ProfileCollection and isinstance(self.mloginfo.logfile, ProfileCollection): print("\n not available for system.profile collections\n") return for version, l...
[ "def", "run", "(", "self", ")", ":", "if", "ProfileCollection", "and", "isinstance", "(", "self", ".", "mloginfo", ".", "logfile", ",", "ProfileCollection", ")", ":", "print", "(", "\"\\n not available for system.profile collections\\n\"", ")", "return", "for", ...
Run this section and print out information.
[ "Run", "this", "section", "and", "print", "out", "information", "." ]
python
train
nesdis/djongo
djongo/models/fields.py
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/models/fields.py#L507-L517
def to_python(self, value): """ Overrides Django's default to_python to allow correct translation to instance. """ if value is None or isinstance(value, self.model_container): return value assert isinstance(value, dict) instance = make_mdl(se...
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", "or", "isinstance", "(", "value", ",", "self", ".", "model_container", ")", ":", "return", "value", "assert", "isinstance", "(", "value", ",", "dict", ")", "instance", ...
Overrides Django's default to_python to allow correct translation to instance.
[ "Overrides", "Django", "s", "default", "to_python", "to", "allow", "correct", "translation", "to", "instance", "." ]
python
test
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/pymongo/collection.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/collection.py#L1628-L1673
def drop_index(self, index_or_name): """Drops the specified index on this collection. Can be used on non-existant collections or collections with no indexes. Raises OperationFailure on an error (e.g. trying to drop an index that does not exist). `index_or_name` can be either an...
[ "def", "drop_index", "(", "self", ",", "index_or_name", ")", ":", "name", "=", "index_or_name", "if", "isinstance", "(", "index_or_name", ",", "list", ")", ":", "name", "=", "helpers", ".", "_gen_index_name", "(", "index_or_name", ")", "if", "not", "isinstan...
Drops the specified index on this collection. Can be used on non-existant collections or collections with no indexes. Raises OperationFailure on an error (e.g. trying to drop an index that does not exist). `index_or_name` can be either an index name (as returned by `create_index`), ...
[ "Drops", "the", "specified", "index", "on", "this", "collection", "." ]
python
train
ggaughan/pipe2py
pipe2py/modules/piperegex.py
https://github.com/ggaughan/pipe2py/blob/4767d6d1fd354d2a35e6528594b8deb8a033eed4/pipe2py/modules/piperegex.py#L47-L79
def asyncPipeRegex(context=None, _INPUT=None, conf=None, **kwargs): """An operator that asynchronously replaces text in items using regexes. Each has the general format: "In [field] replace [match] with [replace]". Not loopable. Parameters ---------- context : pipe2py.Context object _INPUT ...
[ "def", "asyncPipeRegex", "(", "context", "=", "None", ",", "_INPUT", "=", "None", ",", "conf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "splits", "=", "yield", "asyncGetSplits", "(", "_INPUT", ",", "conf", "[", "'RULE'", "]", ",", "*", "*", ...
An operator that asynchronously replaces text in items using regexes. Each has the general format: "In [field] replace [match] with [replace]". Not loopable. Parameters ---------- context : pipe2py.Context object _INPUT : asyncPipe like object (twisted Deferred iterable of items) conf : { ...
[ "An", "operator", "that", "asynchronously", "replaces", "text", "in", "items", "using", "regexes", ".", "Each", "has", "the", "general", "format", ":", "In", "[", "field", "]", "replace", "[", "match", "]", "with", "[", "replace", "]", ".", "Not", "loopa...
python
train
ejhigson/nestcheck
nestcheck/estimators.py
https://github.com/ejhigson/nestcheck/blob/29151c314deb89746fd674f27f6ce54b77603189/nestcheck/estimators.py#L141-L173
def param_cred(ns_run, logw=None, simulate=False, probability=0.5, param_ind=0): """One-tailed credible interval on the value of a single parameter (component of theta). Parameters ---------- ns_run: dict Nested sampling run dict (see the data_processing module docstr...
[ "def", "param_cred", "(", "ns_run", ",", "logw", "=", "None", ",", "simulate", "=", "False", ",", "probability", "=", "0.5", ",", "param_ind", "=", "0", ")", ":", "if", "logw", "is", "None", ":", "logw", "=", "nestcheck", ".", "ns_run_utils", ".", "g...
One-tailed credible interval on the value of a single parameter (component of theta). Parameters ---------- ns_run: dict Nested sampling run dict (see the data_processing module docstring for more details). logw: None or 1d numpy array, optional Log weights of samples. s...
[ "One", "-", "tailed", "credible", "interval", "on", "the", "value", "of", "a", "single", "parameter", "(", "component", "of", "theta", ")", "." ]
python
train
log2timeline/plaso
plaso/lib/lexer.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/lib/lexer.py#L307-L313
def PrintTree(self, depth=''): """Print the tree.""" result = '{0:s}{1:s}\n'.format(depth, self.operator) for part in self.args: result += '{0:s}-{1:s}\n'.format(depth, part.PrintTree(depth + ' ')) return result
[ "def", "PrintTree", "(", "self", ",", "depth", "=", "''", ")", ":", "result", "=", "'{0:s}{1:s}\\n'", ".", "format", "(", "depth", ",", "self", ".", "operator", ")", "for", "part", "in", "self", ".", "args", ":", "result", "+=", "'{0:s}-{1:s}\\n'", "."...
Print the tree.
[ "Print", "the", "tree", "." ]
python
train
spacetelescope/pysynphot
pysynphot/reddening.py
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/reddening.py#L79-L109
def reddening(self,extval): """Compute the reddening for the given extinction. .. math:: A(V) = R(V) \\; \\times \\; E(B-V) \\textnormal{THRU} = 10^{-0.4 \\; A(V)} .. note:: ``self.litref`` is passed into ``ans.citation``. Parameters ----...
[ "def", "reddening", "(", "self", ",", "extval", ")", ":", "T", "=", "10.0", "**", "(", "-", "0.4", "*", "extval", "*", "self", ".", "obscuration", ")", "ans", "=", "ExtinctionSpectralElement", "(", "wave", "=", "self", ".", "wave", ",", "waveunits", ...
Compute the reddening for the given extinction. .. math:: A(V) = R(V) \\; \\times \\; E(B-V) \\textnormal{THRU} = 10^{-0.4 \\; A(V)} .. note:: ``self.litref`` is passed into ``ans.citation``. Parameters ---------- extval : float ...
[ "Compute", "the", "reddening", "for", "the", "given", "extinction", "." ]
python
train
minio/minio-py
minio/parsers.py
https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/parsers.py#L80-L87
def findall(self, name): """Similar to ElementTree.Element.findall() """ return [ S3Element(self.root_name, elem) for elem in self.element.findall('s3:{}'.format(name), _S3_NS) ]
[ "def", "findall", "(", "self", ",", "name", ")", ":", "return", "[", "S3Element", "(", "self", ".", "root_name", ",", "elem", ")", "for", "elem", "in", "self", ".", "element", ".", "findall", "(", "'s3:{}'", ".", "format", "(", "name", ")", ",", "_...
Similar to ElementTree.Element.findall()
[ "Similar", "to", "ElementTree", ".", "Element", ".", "findall", "()" ]
python
train
GNS3/gns3-server
gns3server/compute/qemu/qcow2.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qcow2.py#L91-L106
def rebase(self, qemu_img, base_image): """ Rebase a linked clone in order to use the correct disk :param qemu_img: Path to the qemu-img binary :param base_image: Path to the base image """ if not os.path.exists(base_image): raise FileNotFoundError(base_imag...
[ "def", "rebase", "(", "self", ",", "qemu_img", ",", "base_image", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "base_image", ")", ":", "raise", "FileNotFoundError", "(", "base_image", ")", "command", "=", "[", "qemu_img", ",", "\"rebase\...
Rebase a linked clone in order to use the correct disk :param qemu_img: Path to the qemu-img binary :param base_image: Path to the base image
[ "Rebase", "a", "linked", "clone", "in", "order", "to", "use", "the", "correct", "disk" ]
python
train
consbio/parserutils
parserutils/elements.py
https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L480-L497
def set_element_attributes(elem_to_parse, **attrib_kwargs): """ Adds the specified key/value pairs to the element's attributes, and returns the updated set of attributes. If the element already contains any of the attributes specified in attrib_kwargs, they are updated accordingly. """ ele...
[ "def", "set_element_attributes", "(", "elem_to_parse", ",", "*", "*", "attrib_kwargs", ")", ":", "element", "=", "get_element", "(", "elem_to_parse", ")", "if", "element", "is", "None", ":", "return", "element", "if", "len", "(", "attrib_kwargs", ")", ":", "...
Adds the specified key/value pairs to the element's attributes, and returns the updated set of attributes. If the element already contains any of the attributes specified in attrib_kwargs, they are updated accordingly.
[ "Adds", "the", "specified", "key", "/", "value", "pairs", "to", "the", "element", "s", "attributes", "and", "returns", "the", "updated", "set", "of", "attributes", "." ]
python
train
knipknap/exscript
Exscript/queue.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/queue.py#L693-L711
def force_run(self, hosts, function, attempts=1): """ Like priority_run(), but starts the task immediately even if that max_threads is exceeded. :type hosts: string|list(string)|Host|list(Host) :param hosts: A hostname or Host object, or a list of them. :type function:...
[ "def", "force_run", "(", "self", ",", "hosts", ",", "function", ",", "attempts", "=", "1", ")", ":", "return", "self", ".", "_run", "(", "hosts", ",", "function", ",", "self", ".", "workqueue", ".", "priority_enqueue", ",", "True", ",", "attempts", ")"...
Like priority_run(), but starts the task immediately even if that max_threads is exceeded. :type hosts: string|list(string)|Host|list(Host) :param hosts: A hostname or Host object, or a list of them. :type function: function :param function: The function to execute. :t...
[ "Like", "priority_run", "()", "but", "starts", "the", "task", "immediately", "even", "if", "that", "max_threads", "is", "exceeded", "." ]
python
train
jason-weirather/py-seq-tools
seqtools/errors.py
https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/errors.py#L53-L60
def close(self): """Set some objects to None to hopefully free up some memory.""" self._target_context_errors = None self._query_context_errors = None self._general_errors = None for ae in self._alignment_errors: ae.close() self._alignment_errors = None
[ "def", "close", "(", "self", ")", ":", "self", ".", "_target_context_errors", "=", "None", "self", ".", "_query_context_errors", "=", "None", "self", ".", "_general_errors", "=", "None", "for", "ae", "in", "self", ".", "_alignment_errors", ":", "ae", ".", ...
Set some objects to None to hopefully free up some memory.
[ "Set", "some", "objects", "to", "None", "to", "hopefully", "free", "up", "some", "memory", "." ]
python
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/loh.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/loh.py#L29-L49
def get_coords(data): """Retrieve coordinates of genes of interest for prioritization. Can read from CIViC input data or a supplied BED file of chrom, start, end and gene information. """ for category, vtypes in [("LOH", {"LOSS", "HETEROZYGOSITY"}), ("amplification", {"...
[ "def", "get_coords", "(", "data", ")", ":", "for", "category", ",", "vtypes", "in", "[", "(", "\"LOH\"", ",", "{", "\"LOSS\"", ",", "\"HETEROZYGOSITY\"", "}", ")", ",", "(", "\"amplification\"", ",", "{", "\"AMPLIFICATION\"", "}", ")", "]", ":", "out", ...
Retrieve coordinates of genes of interest for prioritization. Can read from CIViC input data or a supplied BED file of chrom, start, end and gene information.
[ "Retrieve", "coordinates", "of", "genes", "of", "interest", "for", "prioritization", "." ]
python
train
openai/pachi-py
pachi_py/pachi/tools/sgflib/sgflib.py
https://github.com/openai/pachi-py/blob/65f29fdd28747d34f2c3001f4016913e4aaeb8fc/pachi_py/pachi/tools/sgflib/sgflib.py#L164-L172
def parseOneGame(self): """ Parses one game from 'self.data'. Returns a 'GameTree' containing one game, or 'None' if the end of 'self.data' has been reached.""" if self.index < self.datalen: match = self.reGameTreeStart.match(self.data, self.index) if match: self.index = match.end() return self.par...
[ "def", "parseOneGame", "(", "self", ")", ":", "if", "self", ".", "index", "<", "self", ".", "datalen", ":", "match", "=", "self", ".", "reGameTreeStart", ".", "match", "(", "self", ".", "data", ",", "self", ".", "index", ")", "if", "match", ":", "s...
Parses one game from 'self.data'. Returns a 'GameTree' containing one game, or 'None' if the end of 'self.data' has been reached.
[ "Parses", "one", "game", "from", "self", ".", "data", ".", "Returns", "a", "GameTree", "containing", "one", "game", "or", "None", "if", "the", "end", "of", "self", ".", "data", "has", "been", "reached", "." ]
python
train
pgxcentre/geneparse
geneparse/readers/vcf.py
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/vcf.py#L58-L76
def iter_genotypes(self): """Iterates on available markers. Returns: Genotypes instances. """ for v in self.get_vcf(): alleles = {v.REF} | set(v.ALT) if self.quality_field: variant = ImputedVariant(v.ID, v.CHROM, v.POS, alleles, ...
[ "def", "iter_genotypes", "(", "self", ")", ":", "for", "v", "in", "self", ".", "get_vcf", "(", ")", ":", "alleles", "=", "{", "v", ".", "REF", "}", "|", "set", "(", "v", ".", "ALT", ")", "if", "self", ".", "quality_field", ":", "variant", "=", ...
Iterates on available markers. Returns: Genotypes instances.
[ "Iterates", "on", "available", "markers", "." ]
python
train
log2timeline/plaso
plaso/parsers/manager.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/manager.py#L354-L392
def GetParsers(cls, parser_filter_expression=None): """Retrieves the registered parsers and plugins. Retrieves a dictionary of all registered parsers and associated plugins from a parser filter string. The filter string can contain direct names of parsers, presets or plugins. The filter string can also...
[ "def", "GetParsers", "(", "cls", ",", "parser_filter_expression", "=", "None", ")", ":", "includes", ",", "excludes", "=", "cls", ".", "_GetParserFilters", "(", "parser_filter_expression", ")", "for", "parser_name", ",", "parser_class", "in", "iter", "(", "cls",...
Retrieves the registered parsers and plugins. Retrieves a dictionary of all registered parsers and associated plugins from a parser filter string. The filter string can contain direct names of parsers, presets or plugins. The filter string can also negate selection if prepended with an exclamation poin...
[ "Retrieves", "the", "registered", "parsers", "and", "plugins", "." ]
python
train
mar10/wsgidav
wsgidav/util.py
https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/util.py#L874-L935
def add_property_response(multistatusEL, href, propList): """Append <response> element to <multistatus> element. <prop> node depends on the value type: - str or unicode: add element with this content - None: add an empty element - etree.Element: add XML element as child - DAVError: add ...
[ "def", "add_property_response", "(", "multistatusEL", ",", "href", ",", "propList", ")", ":", "# Split propList by status code and build a unique list of namespaces", "nsCount", "=", "1", "nsDict", "=", "{", "}", "nsMap", "=", "{", "}", "propDict", "=", "{", "}", ...
Append <response> element to <multistatus> element. <prop> node depends on the value type: - str or unicode: add element with this content - None: add an empty element - etree.Element: add XML element as child - DAVError: add an empty element to an own <propstatus> for this status code ...
[ "Append", "<response", ">", "element", "to", "<multistatus", ">", "element", "." ]
python
valid
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L1181-L1197
def btc_tx_sign_input(tx, idx, prevout_script, prevout_amount, private_key_info, hashcode=SIGHASH_ALL, hashcodes=None, segwit=None, scriptsig_type=None, redeem_script=None, witness_script=None, **blockchain_opts): """ Sign a particular input in the given transaction. @private_key_info can either be a privat...
[ "def", "btc_tx_sign_input", "(", "tx", ",", "idx", ",", "prevout_script", ",", "prevout_amount", ",", "private_key_info", ",", "hashcode", "=", "SIGHASH_ALL", ",", "hashcodes", "=", "None", ",", "segwit", "=", "None", ",", "scriptsig_type", "=", "None", ",", ...
Sign a particular input in the given transaction. @private_key_info can either be a private key, or it can be a dict with 'redeem_script' and 'private_keys' defined Returns the tx with the signed input
[ "Sign", "a", "particular", "input", "in", "the", "given", "transaction", ".", "@private_key_info", "can", "either", "be", "a", "private", "key", "or", "it", "can", "be", "a", "dict", "with", "redeem_script", "and", "private_keys", "defined" ]
python
train
thombashi/SimpleSQLite
simplesqlite/core.py
https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L503-L519
def insert(self, table_name, record, attr_names=None): """ Send an INSERT query to the database. :param str table_name: Table name of executing the query. :param record: Record to be inserted. :type record: |dict|/|namedtuple|/|list|/|tuple| :raises IOError: |raises_writ...
[ "def", "insert", "(", "self", ",", "table_name", ",", "record", ",", "attr_names", "=", "None", ")", ":", "self", ".", "insert_many", "(", "table_name", ",", "records", "=", "[", "record", "]", ",", "attr_names", "=", "attr_names", ")" ]
Send an INSERT query to the database. :param str table_name: Table name of executing the query. :param record: Record to be inserted. :type record: |dict|/|namedtuple|/|list|/|tuple| :raises IOError: |raises_write_permission| :raises simplesqlite.NullDatabaseConnectionError: ...
[ "Send", "an", "INSERT", "query", "to", "the", "database", "." ]
python
train
pyviz/holoviews
holoviews/core/spaces.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/spaces.py#L1894-L1908
def keys(self, full_grid=False): """Returns the keys of the GridSpace Args: full_grid (bool, optional): Return full cross-product of keys Returns: List of keys """ keys = super(GridSpace, self).keys() if self.ndims == 1 or not full_grid: ...
[ "def", "keys", "(", "self", ",", "full_grid", "=", "False", ")", ":", "keys", "=", "super", "(", "GridSpace", ",", "self", ")", ".", "keys", "(", ")", "if", "self", ".", "ndims", "==", "1", "or", "not", "full_grid", ":", "return", "keys", "dim1_key...
Returns the keys of the GridSpace Args: full_grid (bool, optional): Return full cross-product of keys Returns: List of keys
[ "Returns", "the", "keys", "of", "the", "GridSpace" ]
python
train
quantumlib/Cirq
cirq/ops/linear_combinations.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/linear_combinations.py#L94-L107
def matrix(self) -> np.ndarray: """Reconstructs matrix of self using unitaries of underlying gates. Raises: TypeError: if any of the gates in self does not provide a unitary. """ num_qubits = self.num_qubits() if num_qubits is None: raise ValueError('Unkn...
[ "def", "matrix", "(", "self", ")", "->", "np", ".", "ndarray", ":", "num_qubits", "=", "self", ".", "num_qubits", "(", ")", "if", "num_qubits", "is", "None", ":", "raise", "ValueError", "(", "'Unknown number of qubits'", ")", "num_dim", "=", "2", "**", "...
Reconstructs matrix of self using unitaries of underlying gates. Raises: TypeError: if any of the gates in self does not provide a unitary.
[ "Reconstructs", "matrix", "of", "self", "using", "unitaries", "of", "underlying", "gates", "." ]
python
train
PrefPy/prefpy
prefpy/mechanismMcmc.py
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L328-L339
def createBinaryRelation(self, m): """ Initialize a two-dimensional array of size m by m. :ivar int m: A value for m. """ binaryRelation = [] for i in range(m): binaryRelation.append(range(m)) binaryRelation[i][i] = 0 return binaryRel...
[ "def", "createBinaryRelation", "(", "self", ",", "m", ")", ":", "binaryRelation", "=", "[", "]", "for", "i", "in", "range", "(", "m", ")", ":", "binaryRelation", ".", "append", "(", "range", "(", "m", ")", ")", "binaryRelation", "[", "i", "]", "[", ...
Initialize a two-dimensional array of size m by m. :ivar int m: A value for m.
[ "Initialize", "a", "two", "-", "dimensional", "array", "of", "size", "m", "by", "m", ".", ":", "ivar", "int", "m", ":", "A", "value", "for", "m", "." ]
python
train
Chilipp/psyplot
psyplot/data.py
https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L3263-L3268
def coords_intersect(self): """Coordinates of the arrays in this list that are used in all arrays """ return set.intersection(*map( set, (getattr(arr, 'coords_intersect', arr.coords) for arr in self) ))
[ "def", "coords_intersect", "(", "self", ")", ":", "return", "set", ".", "intersection", "(", "*", "map", "(", "set", ",", "(", "getattr", "(", "arr", ",", "'coords_intersect'", ",", "arr", ".", "coords", ")", "for", "arr", "in", "self", ")", ")", ")"...
Coordinates of the arrays in this list that are used in all arrays
[ "Coordinates", "of", "the", "arrays", "in", "this", "list", "that", "are", "used", "in", "all", "arrays" ]
python
train
KrzyHonk/bpmn-python
bpmn_python/bpmn_diagram_export.py
https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_export.py#L174-L190
def export_boundary_event_info(node_params, output_element): """ Adds IntermediateCatchEvent attributes to exported XML element :param node_params: dictionary with given intermediate catch event parameters, :param output_element: object representing BPMN XML 'intermediateCatchEvent' ele...
[ "def", "export_boundary_event_info", "(", "node_params", ",", "output_element", ")", ":", "output_element", ".", "set", "(", "consts", ".", "Consts", ".", "parallel_multiple", ",", "node_params", "[", "consts", ".", "Consts", ".", "parallel_multiple", "]", ")", ...
Adds IntermediateCatchEvent attributes to exported XML element :param node_params: dictionary with given intermediate catch event parameters, :param output_element: object representing BPMN XML 'intermediateCatchEvent' element.
[ "Adds", "IntermediateCatchEvent", "attributes", "to", "exported", "XML", "element" ]
python
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L91-L100
def printDatawraps() : """print all available datawraps for bootstraping""" l = listDatawraps() printf("Available datawraps for boostraping\n") for k, v in l.iteritems() : printf(k) printf("~"*len(k) + "|") for vv in v : printf(" "*len(k) + "|" + "~~~:> " + vv) printf('\n')
[ "def", "printDatawraps", "(", ")", ":", "l", "=", "listDatawraps", "(", ")", "printf", "(", "\"Available datawraps for boostraping\\n\"", ")", "for", "k", ",", "v", "in", "l", ".", "iteritems", "(", ")", ":", "printf", "(", "k", ")", "printf", "(", "\"~\...
print all available datawraps for bootstraping
[ "print", "all", "available", "datawraps", "for", "bootstraping" ]
python
train
delph-in/pydelphin
delphin/mrs/query.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/query.py#L297-L303
def intrinsic_variables(xmrs): """Return the list of all intrinsic variables in *xmrs*""" ivs = set( ep.intrinsic_variable for ep in xmrs.eps() if not ep.is_quantifier() and ep.intrinsic_variable is not None ) return sorted(ivs, key=var_id)
[ "def", "intrinsic_variables", "(", "xmrs", ")", ":", "ivs", "=", "set", "(", "ep", ".", "intrinsic_variable", "for", "ep", "in", "xmrs", ".", "eps", "(", ")", "if", "not", "ep", ".", "is_quantifier", "(", ")", "and", "ep", ".", "intrinsic_variable", "i...
Return the list of all intrinsic variables in *xmrs*
[ "Return", "the", "list", "of", "all", "intrinsic", "variables", "in", "*", "xmrs", "*" ]
python
train
pgmpy/pgmpy
pgmpy/models/BayesianModel.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L456-L509
def fit(self, data, estimator=None, state_names=[], complete_samples_only=True, **kwargs): """ Estimates the CPD for each variable based on a given data set. Parameters ---------- data: pandas DataFrame object DataFrame object with column names identical to the varia...
[ "def", "fit", "(", "self", ",", "data", ",", "estimator", "=", "None", ",", "state_names", "=", "[", "]", ",", "complete_samples_only", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", "pgmpy", ".", "estimators", "import", "MaximumLikelihoodEstimato...
Estimates the CPD for each variable based on a given data set. Parameters ---------- data: pandas DataFrame object DataFrame object with column names identical to the variable names of the network. (If some values in the data are missing the data cells should be set to `...
[ "Estimates", "the", "CPD", "for", "each", "variable", "based", "on", "a", "given", "data", "set", "." ]
python
train
aouyar/PyMunin
pysysinfo/asterisk.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/asterisk.py#L339-L348
def hasApplication(self, app): """Returns True if app is among the loaded modules. @param app: Module name. @return: Boolean """ if self._applications is None: self._initApplicationList() return app in self._applications
[ "def", "hasApplication", "(", "self", ",", "app", ")", ":", "if", "self", ".", "_applications", "is", "None", ":", "self", ".", "_initApplicationList", "(", ")", "return", "app", "in", "self", ".", "_applications" ]
Returns True if app is among the loaded modules. @param app: Module name. @return: Boolean
[ "Returns", "True", "if", "app", "is", "among", "the", "loaded", "modules", "." ]
python
train
python-rope/rope
rope/contrib/autoimport.py
https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/contrib/autoimport.py#L160-L169
def update_module(self, modname, underlined=None): """Update the cache for global names in `modname` module `modname` is the name of a module. """ try: pymodule = self.project.get_module(modname) self._add_names(pymodule, modname, underlined) except excep...
[ "def", "update_module", "(", "self", ",", "modname", ",", "underlined", "=", "None", ")", ":", "try", ":", "pymodule", "=", "self", ".", "project", ".", "get_module", "(", "modname", ")", "self", ".", "_add_names", "(", "pymodule", ",", "modname", ",", ...
Update the cache for global names in `modname` module `modname` is the name of a module.
[ "Update", "the", "cache", "for", "global", "names", "in", "modname", "module" ]
python
train
trailofbits/manticore
manticore/platforms/linux.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/linux.py#L1574-L1587
def sys_dup(self, fd): """ Duplicates an open file descriptor :rtype: int :param fd: the open file descriptor to duplicate. :return: the new file descriptor. """ if not self._is_fd_open(fd): logger.info("DUP: Passed fd is not open. Returning EBADF") ...
[ "def", "sys_dup", "(", "self", ",", "fd", ")", ":", "if", "not", "self", ".", "_is_fd_open", "(", "fd", ")", ":", "logger", ".", "info", "(", "\"DUP: Passed fd is not open. Returning EBADF\"", ")", "return", "-", "errno", ".", "EBADF", "newfd", "=", "self"...
Duplicates an open file descriptor :rtype: int :param fd: the open file descriptor to duplicate. :return: the new file descriptor.
[ "Duplicates", "an", "open", "file", "descriptor", ":", "rtype", ":", "int", ":", "param", "fd", ":", "the", "open", "file", "descriptor", "to", "duplicate", ".", ":", "return", ":", "the", "new", "file", "descriptor", "." ]
python
valid
alej0varas/django-registration-rest-framework
registration_api/serializers.py
https://github.com/alej0varas/django-registration-rest-framework/blob/485be6bd9c366c79d9974a4cdeb6d4931d6c6183/registration_api/serializers.py#L11-L15
def to_native(self, obj): """Remove password field when serializing an object""" ret = super(UserSerializer, self).to_native(obj) del ret['password'] return ret
[ "def", "to_native", "(", "self", ",", "obj", ")", ":", "ret", "=", "super", "(", "UserSerializer", ",", "self", ")", ".", "to_native", "(", "obj", ")", "del", "ret", "[", "'password'", "]", "return", "ret" ]
Remove password field when serializing an object
[ "Remove", "password", "field", "when", "serializing", "an", "object" ]
python
train
hannorein/rebound
rebound/simulation.py
https://github.com/hannorein/rebound/blob/bb0f814c98e629401acaab657cae2304b0e003f7/rebound/simulation.py#L176-L190
def coordinates(self): """ Get or set the internal coordinate system. Available coordinate systems are: - ``'jacobi'`` (default) - ``'democraticheliocentric'`` - ``'whds'`` """ i = self._coordinates for name, _i in COORDINATES.items(): ...
[ "def", "coordinates", "(", "self", ")", ":", "i", "=", "self", ".", "_coordinates", "for", "name", ",", "_i", "in", "COORDINATES", ".", "items", "(", ")", ":", "if", "i", "==", "_i", ":", "return", "name", "return", "i" ]
Get or set the internal coordinate system. Available coordinate systems are: - ``'jacobi'`` (default) - ``'democraticheliocentric'`` - ``'whds'``
[ "Get", "or", "set", "the", "internal", "coordinate", "system", "." ]
python
train
trevisanj/f311
f311/explorer/vis/plotsp.py
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/vis/plotsp.py#L239-L300
def draw_spectra_stacked(ss, title=None, num_rows=None, setup=_default_setup): """Same as plot_spectra_stacked(), but does not call plt.show(); returns figure""" n = len(ss) assert n > 0, "ss is empty" if not num_rows: num_rows = n num_cols = 1 else: num_cols = int(np.ceil(fl...
[ "def", "draw_spectra_stacked", "(", "ss", ",", "title", "=", "None", ",", "num_rows", "=", "None", ",", "setup", "=", "_default_setup", ")", ":", "n", "=", "len", "(", "ss", ")", "assert", "n", ">", "0", ",", "\"ss is empty\"", "if", "not", "num_rows",...
Same as plot_spectra_stacked(), but does not call plt.show(); returns figure
[ "Same", "as", "plot_spectra_stacked", "()", "but", "does", "not", "call", "plt", ".", "show", "()", ";", "returns", "figure" ]
python
train
SpriteLink/NIPAP
nipap-cli/nipap_cli/nipap_cli.py
https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/nipap-cli/nipap_cli/nipap_cli.py#L1279-L1302
def remove_pool(arg, opts, shell_opts): """ Remove pool """ remove_confirmed = shell_opts.force res = Pool.list({ 'name': arg }) if len(res) < 1: print("No pool with name '%s' found." % arg, file=sys.stderr) sys.exit(1) p = res[0] if not remove_confirmed: res = in...
[ "def", "remove_pool", "(", "arg", ",", "opts", ",", "shell_opts", ")", ":", "remove_confirmed", "=", "shell_opts", ".", "force", "res", "=", "Pool", ".", "list", "(", "{", "'name'", ":", "arg", "}", ")", "if", "len", "(", "res", ")", "<", "1", ":",...
Remove pool
[ "Remove", "pool" ]
python
train
wmayner/pyphi
pyphi/models/actual_causation.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/actual_causation.py#L248-L251
def irreducible_causes(self): """The set of irreducible causes in this |Account|.""" return tuple(link for link in self if link.direction is Direction.CAUSE)
[ "def", "irreducible_causes", "(", "self", ")", ":", "return", "tuple", "(", "link", "for", "link", "in", "self", "if", "link", ".", "direction", "is", "Direction", ".", "CAUSE", ")" ]
The set of irreducible causes in this |Account|.
[ "The", "set", "of", "irreducible", "causes", "in", "this", "|Account|", "." ]
python
train
proversity-org/bibblio-api-python
bibbliothon/enrichment.py
https://github.com/proversity-org/bibblio-api-python/blob/d619223ad80a4bcd32f90ba64d93370260601b60/bibbliothon/enrichment.py#L76-L95
def update_content_item(access_token, content_item_id, payload): ''' Name: update_content_item Parameters: access_token, content_item_id, payload (dict) Return: dictionary ''' headers = {'Authorization': 'Bearer ' + str(access_token)} content_item_url =\ construct_content_item_url(enrichment_url, content_item...
[ "def", "update_content_item", "(", "access_token", ",", "content_item_id", ",", "payload", ")", ":", "headers", "=", "{", "'Authorization'", ":", "'Bearer '", "+", "str", "(", "access_token", ")", "}", "content_item_url", "=", "construct_content_item_url", "(", "e...
Name: update_content_item Parameters: access_token, content_item_id, payload (dict) Return: dictionary
[ "Name", ":", "update_content_item", "Parameters", ":", "access_token", "content_item_id", "payload", "(", "dict", ")", "Return", ":", "dictionary" ]
python
train
JasonKessler/scattertext
scattertext/PriorFactory.py
https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/PriorFactory.py#L95-L103
def use_all_categories(self): ''' Returns ------- PriorFactory ''' term_df = self.term_ranker.get_ranks() self.priors += term_df.sum(axis=1).fillna(0.) return self
[ "def", "use_all_categories", "(", "self", ")", ":", "term_df", "=", "self", ".", "term_ranker", ".", "get_ranks", "(", ")", "self", ".", "priors", "+=", "term_df", ".", "sum", "(", "axis", "=", "1", ")", ".", "fillna", "(", "0.", ")", "return", "self...
Returns ------- PriorFactory
[ "Returns", "-------", "PriorFactory" ]
python
train
seleniumbase/SeleniumBase
seleniumbase/utilities/selenium_grid/download_selenium_server.py
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/utilities/selenium_grid/download_selenium_server.py#L20-L35
def download_selenium_server(): """ Downloads the Selenium Server JAR file from its online location and stores it locally. """ try: local_file = open(JAR_FILE, 'wb') remote_file = urlopen(SELENIUM_JAR) print('Downloading the Selenium Server JAR file...\n') local_file....
[ "def", "download_selenium_server", "(", ")", ":", "try", ":", "local_file", "=", "open", "(", "JAR_FILE", ",", "'wb'", ")", "remote_file", "=", "urlopen", "(", "SELENIUM_JAR", ")", "print", "(", "'Downloading the Selenium Server JAR file...\\n'", ")", "local_file", ...
Downloads the Selenium Server JAR file from its online location and stores it locally.
[ "Downloads", "the", "Selenium", "Server", "JAR", "file", "from", "its", "online", "location", "and", "stores", "it", "locally", "." ]
python
train
nylas/nylas-python
nylas/utils.py
https://github.com/nylas/nylas-python/blob/c3e4dfc152b09bb8f886b1c64c6919b1f642cbc8/nylas/utils.py#L5-L12
def timestamp_from_dt(dt, epoch=datetime(1970, 1, 1)): """ Convert a datetime to a timestamp. https://stackoverflow.com/a/8778548/141395 """ delta = dt - epoch # return delta.total_seconds() return delta.seconds + delta.days * 86400
[ "def", "timestamp_from_dt", "(", "dt", ",", "epoch", "=", "datetime", "(", "1970", ",", "1", ",", "1", ")", ")", ":", "delta", "=", "dt", "-", "epoch", "# return delta.total_seconds()", "return", "delta", ".", "seconds", "+", "delta", ".", "days", "*", ...
Convert a datetime to a timestamp. https://stackoverflow.com/a/8778548/141395
[ "Convert", "a", "datetime", "to", "a", "timestamp", ".", "https", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "8778548", "/", "141395" ]
python
train
miso-belica/sumy
sumy/evaluation/rouge.py
https://github.com/miso-belica/sumy/blob/099ab4938e2c1b6a011297375586bac2953641b9/sumy/evaluation/rouge.py#L220-L251
def _union_lcs(evaluated_sentences, reference_sentence): """ Returns LCS_u(r_i, C) which is the LCS score of the union longest common subsequence between reference sentence ri and candidate summary C. For example, if r_i= w1 w2 w3 w4 w5, and C contains two sentences: c1 = w1 w2 w6 w7 w8 and c2 = w1 ...
[ "def", "_union_lcs", "(", "evaluated_sentences", ",", "reference_sentence", ")", ":", "if", "len", "(", "evaluated_sentences", ")", "<=", "0", ":", "raise", "(", "ValueError", "(", "\"Collections must contain at least 1 sentence.\"", ")", ")", "lcs_union", "=", "set...
Returns LCS_u(r_i, C) which is the LCS score of the union longest common subsequence between reference sentence ri and candidate summary C. For example, if r_i= w1 w2 w3 w4 w5, and C contains two sentences: c1 = w1 w2 w6 w7 w8 and c2 = w1 w3 w8 w9 w5, then the longest common subsequence of r_i and c1 is ...
[ "Returns", "LCS_u", "(", "r_i", "C", ")", "which", "is", "the", "LCS", "score", "of", "the", "union", "longest", "common", "subsequence", "between", "reference", "sentence", "ri", "and", "candidate", "summary", "C", ".", "For", "example", "if", "r_i", "=",...
python
train
HPENetworking/PYHPEIMC
build/lib/pyhpeimc/wsm/acinfo.py
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/wsm/acinfo.py#L15-L76
def get_ac_info_all(auth, url): """ function takes no input as input to RESTFUL call to HP IMC :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :return: list of dictionaries ...
[ "def", "get_ac_info_all", "(", "auth", ",", "url", ")", ":", "get_ac_info_all_url", "=", "\"/imcrs/wlan/acInfo/queryAcBasicInfo\"", "f_url", "=", "url", "+", "get_ac_info_all_url", "payload", "=", "None", "r", "=", "requests", ".", "get", "(", "f_url", ",", "aut...
function takes no input as input to RESTFUL call to HP IMC :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :return: list of dictionaries where each element of the list represents a ...
[ "function", "takes", "no", "input", "as", "input", "to", "RESTFUL", "call", "to", "HP", "IMC" ]
python
train
optimizely/python-sdk
optimizely/event_builder.py
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/event_builder.py#L272-L293
def create_impression_event(self, experiment, variation_id, user_id, attributes): """ Create impression Event to be sent to the logging endpoint. Args: experiment: Experiment for which impression needs to be recorded. variation_id: ID for variation which would be presented to user. user_id: I...
[ "def", "create_impression_event", "(", "self", ",", "experiment", ",", "variation_id", ",", "user_id", ",", "attributes", ")", ":", "params", "=", "self", ".", "_get_common_params", "(", "user_id", ",", "attributes", ")", "impression_params", "=", "self", ".", ...
Create impression Event to be sent to the logging endpoint. Args: experiment: Experiment for which impression needs to be recorded. variation_id: ID for variation which would be presented to user. user_id: ID for user. attributes: Dict representing user attributes and values which need to b...
[ "Create", "impression", "Event", "to", "be", "sent", "to", "the", "logging", "endpoint", "." ]
python
train
Netflix-Skunkworks/historical
historical/historical-cookiecutter/historical_{{cookiecutter.technology_slug}}/{{cookiecutter.technology_slug}}/collector.py
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/historical-cookiecutter/historical_{{cookiecutter.technology_slug}}/{{cookiecutter.technology_slug}}/collector.py#L47-L58
def group_records_by_type(records): """Break records into two lists; create/update events and delete events.""" update_records, delete_records = [], [] for r in records: if isinstance(r, str): break if r['detail']['eventName'] in UPDATE_EVENTS: update_records.append(...
[ "def", "group_records_by_type", "(", "records", ")", ":", "update_records", ",", "delete_records", "=", "[", "]", ",", "[", "]", "for", "r", "in", "records", ":", "if", "isinstance", "(", "r", ",", "str", ")", ":", "break", "if", "r", "[", "'detail'", ...
Break records into two lists; create/update events and delete events.
[ "Break", "records", "into", "two", "lists", ";", "create", "/", "update", "events", "and", "delete", "events", "." ]
python
train
cqparts/cqparts
src/cqparts/params/parametric_object.py
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/params/parametric_object.py#L103-L123
def class_params(cls, hidden=True): """ Gets all class parameters, and their :class:`Parameter` instances. :return: dict of the form: ``{<name>: <Parameter instance>, ... }`` :rtype: :class:`dict` .. note:: The :class:`Parameter` instances returned do not have a va...
[ "def", "class_params", "(", "cls", ",", "hidden", "=", "True", ")", ":", "param_names", "=", "cls", ".", "class_param_names", "(", "hidden", "=", "hidden", ")", "return", "dict", "(", "(", "name", ",", "getattr", "(", "cls", ",", "name", ")", ")", "f...
Gets all class parameters, and their :class:`Parameter` instances. :return: dict of the form: ``{<name>: <Parameter instance>, ... }`` :rtype: :class:`dict` .. note:: The :class:`Parameter` instances returned do not have a value, only a default value. To g...
[ "Gets", "all", "class", "parameters", "and", "their", ":", "class", ":", "Parameter", "instances", "." ]
python
train
ellmetha/django-machina
machina/apps/forum_tracking/views.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_tracking/views.py#L117-L121
def mark_topics_read(self, request, pk): """ Marks forum topics as read. """ track_handler.mark_forums_read([self.forum, ], request.user) messages.success(request, self.success_message) return HttpResponseRedirect(self.get_forum_url())
[ "def", "mark_topics_read", "(", "self", ",", "request", ",", "pk", ")", ":", "track_handler", ".", "mark_forums_read", "(", "[", "self", ".", "forum", ",", "]", ",", "request", ".", "user", ")", "messages", ".", "success", "(", "request", ",", "self", ...
Marks forum topics as read.
[ "Marks", "forum", "topics", "as", "read", "." ]
python
train
biocore/burrito
burrito/util.py
https://github.com/biocore/burrito/blob/3b1dcc560431cc2b7a4856b99aafe36d32082356/burrito/util.py#L447-L469
def _error_on_missing_application(self, params): """ Raise an ApplicationNotFoundError if the app is not accessible This method checks in the system path (usually $PATH) or for the existence of self._command. If self._command is not found in either place, an ApplicationNotFo...
[ "def", "_error_on_missing_application", "(", "self", ",", "params", ")", ":", "command", "=", "self", ".", "_command", "# strip off \" characters, in case we got a FilePath object", "found_in_path", "=", "which", "(", "command", ".", "strip", "(", "'\"'", ")", ")", ...
Raise an ApplicationNotFoundError if the app is not accessible This method checks in the system path (usually $PATH) or for the existence of self._command. If self._command is not found in either place, an ApplicationNotFoundError is raised to inform the user that the ap...
[ "Raise", "an", "ApplicationNotFoundError", "if", "the", "app", "is", "not", "accessible" ]
python
train
mohabusama/pyguacamole
guacamole/client.py
https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/client.py#L131-L136
def send_instruction(self, instruction): """ Send instruction after encoding. """ self.logger.debug('Sending instruction: %s' % str(instruction)) return self.send(instruction.encode())
[ "def", "send_instruction", "(", "self", ",", "instruction", ")", ":", "self", ".", "logger", ".", "debug", "(", "'Sending instruction: %s'", "%", "str", "(", "instruction", ")", ")", "return", "self", ".", "send", "(", "instruction", ".", "encode", "(", ")...
Send instruction after encoding.
[ "Send", "instruction", "after", "encoding", "." ]
python
test
quantopian/qgrid
qgrid/pd_json/json.py
https://github.com/quantopian/qgrid/blob/c193f66945d9cd83b80f9ed0ce9f557404c66d81/qgrid/pd_json/json.py#L441-L513
def _try_convert_data(self, name, data, use_dtypes=True, convert_dates=True): """ try to parse a ndarray like into a column by inferring dtype """ # don't try to coerce, unless a force conversion if use_dtypes: if self.dtype is False: return...
[ "def", "_try_convert_data", "(", "self", ",", "name", ",", "data", ",", "use_dtypes", "=", "True", ",", "convert_dates", "=", "True", ")", ":", "# don't try to coerce, unless a force conversion", "if", "use_dtypes", ":", "if", "self", ".", "dtype", "is", "False"...
try to parse a ndarray like into a column by inferring dtype
[ "try", "to", "parse", "a", "ndarray", "like", "into", "a", "column", "by", "inferring", "dtype" ]
python
train
pylast/pylast
src/pylast/__init__.py
https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L1032-L1048
def _get_web_auth_token(self): """ Retrieves a token from the network for web authentication. The token then has to be authorized from getAuthURL before creating session. """ request = _Request(self.network, "auth.getToken") # default action is that a request is...
[ "def", "_get_web_auth_token", "(", "self", ")", ":", "request", "=", "_Request", "(", "self", ".", "network", ",", "\"auth.getToken\"", ")", "# default action is that a request is signed only when", "# a session key is provided.", "request", ".", "sign_it", "(", ")", "d...
Retrieves a token from the network for web authentication. The token then has to be authorized from getAuthURL before creating session.
[ "Retrieves", "a", "token", "from", "the", "network", "for", "web", "authentication", ".", "The", "token", "then", "has", "to", "be", "authorized", "from", "getAuthURL", "before", "creating", "session", "." ]
python
train
yougov/openpack
openpack/basepack.py
https://github.com/yougov/openpack/blob/1412ec34c1bab6ba6c8ae5490c2205d696f13717/openpack/basepack.py#L507-L518
def from_element(cls, element): "given an element, parse out the proper ContentType" # disambiguate the subclass ns, class_name = parse_tag(element.tag) class_ = getattr(ContentType, class_name) if not class_: msg = 'Invalid Types child element: %(class_name)s' % vars() raise ValueError(msg) # constru...
[ "def", "from_element", "(", "cls", ",", "element", ")", ":", "# disambiguate the subclass", "ns", ",", "class_name", "=", "parse_tag", "(", "element", ".", "tag", ")", "class_", "=", "getattr", "(", "ContentType", ",", "class_name", ")", "if", "not", "class_...
given an element, parse out the proper ContentType
[ "given", "an", "element", "parse", "out", "the", "proper", "ContentType" ]
python
test
couchbase/couchbase-python-client
couchbase/deprecation.py
https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/deprecation.py#L4-L19
def deprecate_module_attribute(mod, deprecated): """Return a wrapped object that warns about deprecated accesses""" deprecated = set(deprecated) class Wrapper(object): def __getattr__(self, attr): if attr in deprecated: warnings.warn("Property %s is deprecated" % attr) ...
[ "def", "deprecate_module_attribute", "(", "mod", ",", "deprecated", ")", ":", "deprecated", "=", "set", "(", "deprecated", ")", "class", "Wrapper", "(", "object", ")", ":", "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "if", "attr", "in", "de...
Return a wrapped object that warns about deprecated accesses
[ "Return", "a", "wrapped", "object", "that", "warns", "about", "deprecated", "accesses" ]
python
train
great-expectations/great_expectations
great_expectations/data_asset/base.py
https://github.com/great-expectations/great_expectations/blob/08385c40529d4f14a1c46916788aecc47f33ee9d/great_expectations/data_asset/base.py#L962-L1056
def _format_map_output(self, result_format, success, element_count, nonnull_count, unexpected_count, unexpected_list, unexpected_index_list ): ...
[ "def", "_format_map_output", "(", "self", ",", "result_format", ",", "success", ",", "element_count", ",", "nonnull_count", ",", "unexpected_count", ",", "unexpected_list", ",", "unexpected_index_list", ")", ":", "# NB: unexpected_count parameter is explicit some implementing...
Helper function to construct expectation result objects for map_expectations (such as column_map_expectation and file_lines_map_expectation). Expectations support four result_formats: BOOLEAN_ONLY, BASIC, SUMMARY, and COMPLETE. In each case, the object returned has a different set of populated ...
[ "Helper", "function", "to", "construct", "expectation", "result", "objects", "for", "map_expectations", "(", "such", "as", "column_map_expectation", "and", "file_lines_map_expectation", ")", "." ]
python
train
jason-weirather/py-seq-tools
seqtools/structure/transcript/__init__.py
https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/structure/transcript/__init__.py#L164-L170
def set_strand(self,dir): """Set the strand (direction) :param dir: direction + or - :type dir: char """ self._options = self._options._replace(direction = dir)
[ "def", "set_strand", "(", "self", ",", "dir", ")", ":", "self", ".", "_options", "=", "self", ".", "_options", ".", "_replace", "(", "direction", "=", "dir", ")" ]
Set the strand (direction) :param dir: direction + or - :type dir: char
[ "Set", "the", "strand", "(", "direction", ")" ]
python
train
slightlynybbled/tk_tools
tk_tools/groups.py
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L447-L458
def get(self): """ Retrieve the GUI elements for program use. :return: a dictionary containing all \ of the data from the key/value entries """ data = dict() for label, entry in zip(self.keys, self.values): data[label.cget('text')] = entry.get() ...
[ "def", "get", "(", "self", ")", ":", "data", "=", "dict", "(", ")", "for", "label", ",", "entry", "in", "zip", "(", "self", ".", "keys", ",", "self", ".", "values", ")", ":", "data", "[", "label", ".", "cget", "(", "'text'", ")", "]", "=", "e...
Retrieve the GUI elements for program use. :return: a dictionary containing all \ of the data from the key/value entries
[ "Retrieve", "the", "GUI", "elements", "for", "program", "use", "." ]
python
train
dpgaspar/Flask-AppBuilder
flask_appbuilder/cli.py
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/cli.py#L113-L123
def version(): """ Flask-AppBuilder package version """ click.echo( click.style( "F.A.B Version: {0}.".format(current_app.appbuilder.version), bg="blue", fg="white" ) )
[ "def", "version", "(", ")", ":", "click", ".", "echo", "(", "click", ".", "style", "(", "\"F.A.B Version: {0}.\"", ".", "format", "(", "current_app", ".", "appbuilder", ".", "version", ")", ",", "bg", "=", "\"blue\"", ",", "fg", "=", "\"white\"", ")", ...
Flask-AppBuilder package version
[ "Flask", "-", "AppBuilder", "package", "version" ]
python
train
ska-sa/katcp-python
katcp/sampling.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/sampling.py#L109-L156
def get_strategy(cls, strategyName, inform_callback, sensor, *params, **kwargs): """Factory method to create a strategy object. Parameters ---------- strategyName : str Name of strategy. inform_callback : callable, signature inform_callback(senso...
[ "def", "get_strategy", "(", "cls", ",", "strategyName", ",", "inform_callback", ",", "sensor", ",", "*", "params", ",", "*", "*", "kwargs", ")", ":", "if", "strategyName", "not", "in", "cls", ".", "SAMPLING_LOOKUP_REV", ":", "raise", "ValueError", "(", "\"...
Factory method to create a strategy object. Parameters ---------- strategyName : str Name of strategy. inform_callback : callable, signature inform_callback(sensor, reading) Callback to receive inform messages. sensor : Sensor object Sensor to...
[ "Factory", "method", "to", "create", "a", "strategy", "object", "." ]
python
train
redhat-cip/python-dciclient
dciclient/v1/shell_commands/topic.py
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/topic.py#L207-L222
def list_attached_team(context, id, sort, limit, where, verbose): """list_attached_team(context, id, sort, limit. where. verbose) List teams attached to a topic. >>> dcictl topic-list-team :param string id: ID of the topic to list teams for [required] :param string sort: Field to apply sort :...
[ "def", "list_attached_team", "(", "context", ",", "id", ",", "sort", ",", "limit", ",", "where", ",", "verbose", ")", ":", "result", "=", "topic", ".", "list_teams", "(", "context", ",", "id", "=", "id", ",", "sort", "=", "sort", ",", "limit", "=", ...
list_attached_team(context, id, sort, limit. where. verbose) List teams attached to a topic. >>> dcictl topic-list-team :param string id: ID of the topic to list teams for [required] :param string sort: Field to apply sort :param integer limit: Max number of rows to return :param string where...
[ "list_attached_team", "(", "context", "id", "sort", "limit", ".", "where", ".", "verbose", ")" ]
python
train
RobotStudio/bors
bors/api/websock.py
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/websock.py#L54-L57
def _on_set_auth(self, sock, token): """Set Auth request received from websocket""" self.log.info(f"Token received: {token}") sock.setAuthtoken(token)
[ "def", "_on_set_auth", "(", "self", ",", "sock", ",", "token", ")", ":", "self", ".", "log", ".", "info", "(", "f\"Token received: {token}\"", ")", "sock", ".", "setAuthtoken", "(", "token", ")" ]
Set Auth request received from websocket
[ "Set", "Auth", "request", "received", "from", "websocket" ]
python
train
rueckstiess/mtools
mtools/util/logevent.py
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L839-L842
def to_json(self, labels=None): """Convert LogEvent object to valid JSON.""" output = self.to_dict(labels) return json.dumps(output, cls=DateTimeEncoder, ensure_ascii=False)
[ "def", "to_json", "(", "self", ",", "labels", "=", "None", ")", ":", "output", "=", "self", ".", "to_dict", "(", "labels", ")", "return", "json", ".", "dumps", "(", "output", ",", "cls", "=", "DateTimeEncoder", ",", "ensure_ascii", "=", "False", ")" ]
Convert LogEvent object to valid JSON.
[ "Convert", "LogEvent", "object", "to", "valid", "JSON", "." ]
python
train