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
dropbox/stone
stone/backend.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backend.py#L381-L451
def generate_multiline_list( self, items, # type: typing.List[typing.Text] before='', # type: typing.Text after='', # type: typing.Text delim=('(', ')'), # type: DelimTuple compact=True, # type: bool sep=',', ...
[ "def", "generate_multiline_list", "(", "self", ",", "items", ",", "# type: typing.List[typing.Text]", "before", "=", "''", ",", "# type: typing.Text", "after", "=", "''", ",", "# type: typing.Text", "delim", "=", "(", "'('", ",", "')'", ")", ",", "# type: DelimTup...
Given a list of items, emits one item per line. This is convenient for function prototypes and invocations, as well as for instantiating arrays, sets, and maps in some languages. TODO(kelkabany): A backend that uses tabs cannot be used with this if compact is false. Args: ...
[ "Given", "a", "list", "of", "items", "emits", "one", "item", "per", "line", "." ]
python
train
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker_stats.py#L115-L130
def dump_stats(self, fdump, close=True): """ Dump the logged data to a file. The argument `file` can be either a filename or an open file object that requires write access. `close` controls if the file is closed before leaving this method (the default behaviour). """ ...
[ "def", "dump_stats", "(", "self", ",", "fdump", ",", "close", "=", "True", ")", ":", "if", "self", ".", "tracker", ":", "self", ".", "tracker", ".", "stop_periodic_snapshots", "(", ")", "if", "isinstance", "(", "fdump", ",", "type", "(", "''", ")", "...
Dump the logged data to a file. The argument `file` can be either a filename or an open file object that requires write access. `close` controls if the file is closed before leaving this method (the default behaviour).
[ "Dump", "the", "logged", "data", "to", "a", "file", ".", "The", "argument", "file", "can", "be", "either", "a", "filename", "or", "an", "open", "file", "object", "that", "requires", "write", "access", ".", "close", "controls", "if", "the", "file", "is", ...
python
train
SheffieldML/GPy
GPy/util/netpbmfile.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/util/netpbmfile.py#L156-L160
def close(self): """Close open file. Future asarray calls might fail.""" if self._filename and self._fh: self._fh.close() self._fh = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_filename", "and", "self", ".", "_fh", ":", "self", ".", "_fh", ".", "close", "(", ")", "self", ".", "_fh", "=", "None" ]
Close open file. Future asarray calls might fail.
[ "Close", "open", "file", ".", "Future", "asarray", "calls", "might", "fail", "." ]
python
train
msiemens/tinydb
tinydb/middlewares.py
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/middlewares.py#L106-L112
def flush(self): """ Flush all unwritten data to disk. """ if self._cache_modified_count > 0: self.storage.write(self.cache) self._cache_modified_count = 0
[ "def", "flush", "(", "self", ")", ":", "if", "self", ".", "_cache_modified_count", ">", "0", ":", "self", ".", "storage", ".", "write", "(", "self", ".", "cache", ")", "self", ".", "_cache_modified_count", "=", "0" ]
Flush all unwritten data to disk.
[ "Flush", "all", "unwritten", "data", "to", "disk", "." ]
python
train
JoelBender/bacpypes
py25/bacpypes/appservice.py
https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/appservice.py#L212-L222
def append_segment(self, apdu): """This function appends the apdu content to the end of the current APDU being built. The segmentAPDU is the context.""" if _debug: SSM._debug("append_segment %r", apdu) # check for no context if not self.segmentAPDU: raise RuntimeErr...
[ "def", "append_segment", "(", "self", ",", "apdu", ")", ":", "if", "_debug", ":", "SSM", ".", "_debug", "(", "\"append_segment %r\"", ",", "apdu", ")", "# check for no context", "if", "not", "self", ".", "segmentAPDU", ":", "raise", "RuntimeError", "(", "\"n...
This function appends the apdu content to the end of the current APDU being built. The segmentAPDU is the context.
[ "This", "function", "appends", "the", "apdu", "content", "to", "the", "end", "of", "the", "current", "APDU", "being", "built", ".", "The", "segmentAPDU", "is", "the", "context", "." ]
python
train
LogicalDash/LiSE
LiSE/LiSE/query.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/query.py#L312-L340
def slow_iter_turns_eval_cmp(qry, oper, start_branch=None, engine=None): """Iterate over all turns on which a comparison holds. This is expensive. It evaluates the query for every turn in history. """ def mungeside(side): if isinstance(side, Query): return side.iter_turns e...
[ "def", "slow_iter_turns_eval_cmp", "(", "qry", ",", "oper", ",", "start_branch", "=", "None", ",", "engine", "=", "None", ")", ":", "def", "mungeside", "(", "side", ")", ":", "if", "isinstance", "(", "side", ",", "Query", ")", ":", "return", "side", "....
Iterate over all turns on which a comparison holds. This is expensive. It evaluates the query for every turn in history.
[ "Iterate", "over", "all", "turns", "on", "which", "a", "comparison", "holds", "." ]
python
train
palantir/python-jsonrpc-server
pyls_jsonrpc/streams.py
https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/streams.py#L59-L69
def _content_length(line): """Extract the content length from an input line.""" if line.startswith(b'Content-Length: '): _, value = line.split(b'Content-Length: ') value = value.strip() try: return int(value) except ValueError: ...
[ "def", "_content_length", "(", "line", ")", ":", "if", "line", ".", "startswith", "(", "b'Content-Length: '", ")", ":", "_", ",", "value", "=", "line", ".", "split", "(", "b'Content-Length: '", ")", "value", "=", "value", ".", "strip", "(", ")", "try", ...
Extract the content length from an input line.
[ "Extract", "the", "content", "length", "from", "an", "input", "line", "." ]
python
train
numenta/nupic
src/nupic/algorithms/temporal_memory.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/temporal_memory.py#L912-L924
def getPredictiveCells(self): """ Returns the indices of the predictive cells. :returns: (list) Indices of predictive cells. """ previousCell = None predictiveCells = [] for segment in self.activeSegments: if segment.cell != previousCell: predictiveCells.append(segment.cell) ...
[ "def", "getPredictiveCells", "(", "self", ")", ":", "previousCell", "=", "None", "predictiveCells", "=", "[", "]", "for", "segment", "in", "self", ".", "activeSegments", ":", "if", "segment", ".", "cell", "!=", "previousCell", ":", "predictiveCells", ".", "a...
Returns the indices of the predictive cells. :returns: (list) Indices of predictive cells.
[ "Returns", "the", "indices", "of", "the", "predictive", "cells", "." ]
python
valid
elastic/elasticsearch-py
elasticsearch/helpers/actions.py
https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/helpers/actions.py#L56-L92
def _chunk_actions(actions, chunk_size, max_chunk_bytes, serializer): """ Split actions into chunks by number or size, serialize them into strings in the process. """ bulk_actions, bulk_data = [], [] size, action_count = 0, 0 for action, data in actions: raw_data, raw_action = data, ...
[ "def", "_chunk_actions", "(", "actions", ",", "chunk_size", ",", "max_chunk_bytes", ",", "serializer", ")", ":", "bulk_actions", ",", "bulk_data", "=", "[", "]", ",", "[", "]", "size", ",", "action_count", "=", "0", ",", "0", "for", "action", ",", "data"...
Split actions into chunks by number or size, serialize them into strings in the process.
[ "Split", "actions", "into", "chunks", "by", "number", "or", "size", "serialize", "them", "into", "strings", "in", "the", "process", "." ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/thread.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/thread.py#L1496-L1511
def read_code_bytes(self, size = 128, offset = 0): """ Tries to read some bytes of the code currently being executed. @type size: int @param size: Number of bytes to read. @type offset: int @param offset: Offset from the program counter to begin reading. @rty...
[ "def", "read_code_bytes", "(", "self", ",", "size", "=", "128", ",", "offset", "=", "0", ")", ":", "return", "self", ".", "get_process", "(", ")", ".", "read", "(", "self", ".", "get_pc", "(", ")", "+", "offset", ",", "size", ")" ]
Tries to read some bytes of the code currently being executed. @type size: int @param size: Number of bytes to read. @type offset: int @param offset: Offset from the program counter to begin reading. @rtype: str @return: Bytes read from the process memory. ...
[ "Tries", "to", "read", "some", "bytes", "of", "the", "code", "currently", "being", "executed", "." ]
python
train
astropy/photutils
photutils/psf/epsf_stars.py
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf_stars.py#L687-L777
def _extract_stars(data, catalog, size=(11, 11), use_xy=True): """ Extract cutout images from a single image centered on stars defined in the single input catalog. Parameters ---------- data : `~astropy.nddata.NDData` A `~astropy.nddata.NDData` object containing the 2D image from ...
[ "def", "_extract_stars", "(", "data", ",", "catalog", ",", "size", "=", "(", "11", ",", "11", ")", ",", "use_xy", "=", "True", ")", ":", "colnames", "=", "catalog", ".", "colnames", "if", "(", "'x'", "not", "in", "colnames", "or", "'y'", "not", "in...
Extract cutout images from a single image centered on stars defined in the single input catalog. Parameters ---------- data : `~astropy.nddata.NDData` A `~astropy.nddata.NDData` object containing the 2D image from which to extract the stars. If the input ``catalog`` contains on...
[ "Extract", "cutout", "images", "from", "a", "single", "image", "centered", "on", "stars", "defined", "in", "the", "single", "input", "catalog", "." ]
python
train
hydpy-dev/hydpy
hydpy/models/arma/arma_derived.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/arma/arma_derived.py#L94-L106
def update(self): """Determine the total number of AR coefficients. >>> from hydpy.models.arma import * >>> parameterstep('1d') >>> responses(((1., 2.), (1.,)), th_3=((1.,), (1., 2., 3.))) >>> derived.ar_order.update() >>> derived.ar_order ar_order(2, 1) ...
[ "def", "update", "(", "self", ")", ":", "responses", "=", "self", ".", "subpars", ".", "pars", ".", "control", ".", "responses", "self", ".", "shape", "=", "len", "(", "responses", ")", "self", "(", "responses", ".", "ar_orders", ")" ]
Determine the total number of AR coefficients. >>> from hydpy.models.arma import * >>> parameterstep('1d') >>> responses(((1., 2.), (1.,)), th_3=((1.,), (1., 2., 3.))) >>> derived.ar_order.update() >>> derived.ar_order ar_order(2, 1)
[ "Determine", "the", "total", "number", "of", "AR", "coefficients", "." ]
python
train
databuild/databuild
databuild/adapters/locmem/models.py
https://github.com/databuild/databuild/blob/4c8ee04fad1748f5b966753057ac05efbc289b10/databuild/adapters/locmem/models.py#L24-L31
def _match(self, doc, where): """Return True if 'doc' matches the 'where' condition.""" assert isinstance(where, dict), "where is not a dictionary" assert isinstance(doc, dict), "doc is not a dictionary" try: return all([doc[k] == v for k, v in where.items()]) except ...
[ "def", "_match", "(", "self", ",", "doc", ",", "where", ")", ":", "assert", "isinstance", "(", "where", ",", "dict", ")", ",", "\"where is not a dictionary\"", "assert", "isinstance", "(", "doc", ",", "dict", ")", ",", "\"doc is not a dictionary\"", "try", "...
Return True if 'doc' matches the 'where' condition.
[ "Return", "True", "if", "doc", "matches", "the", "where", "condition", "." ]
python
train
kislyuk/ensure
ensure/main.py
https://github.com/kislyuk/ensure/blob/0a562a4b469ffbaf71c75dc4d394e94334c831f0/ensure/main.py#L289-L295
def contains_no(self, prototype): """ Ensures no item of :attr:`subject` is of class *prototype*. """ for element in self._subject: self._run(unittest_case.assertNotIsInstance, (element, prototype)) return ChainInspector(self._subject)
[ "def", "contains_no", "(", "self", ",", "prototype", ")", ":", "for", "element", "in", "self", ".", "_subject", ":", "self", ".", "_run", "(", "unittest_case", ".", "assertNotIsInstance", ",", "(", "element", ",", "prototype", ")", ")", "return", "ChainIns...
Ensures no item of :attr:`subject` is of class *prototype*.
[ "Ensures", "no", "item", "of", ":", "attr", ":", "subject", "is", "of", "class", "*", "prototype", "*", "." ]
python
train
tensorflow/datasets
tensorflow_datasets/image/svhn.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/svhn.py#L92-L113
def _generate_examples(self, filepath): """Generate examples as dicts. Args: filepath: `str` path of the file to process. Yields: Generator yielding the next samples """ with tf.io.gfile.GFile(filepath, "rb") as f: data = tfds.core.lazy_imports.scipy.io.loadmat(f) # Maybe sh...
[ "def", "_generate_examples", "(", "self", ",", "filepath", ")", ":", "with", "tf", ".", "io", ".", "gfile", ".", "GFile", "(", "filepath", ",", "\"rb\"", ")", "as", "f", ":", "data", "=", "tfds", ".", "core", ".", "lazy_imports", ".", "scipy", ".", ...
Generate examples as dicts. Args: filepath: `str` path of the file to process. Yields: Generator yielding the next samples
[ "Generate", "examples", "as", "dicts", "." ]
python
train
reillysiemens/layabout
layabout.py
https://github.com/reillysiemens/layabout/blob/a146c47f2558e66bb51cf708d39909b93eaea7f4/layabout.py#L291-L296
def _create_slack_with_env_var(env_var: EnvVar) -> SlackClient: """ Create a :obj:`SlackClient` with a token from an env var. """ token = os.getenv(env_var) if token: return SlackClient(token=token) raise MissingToken(f"Could not acquire token from {env_var}")
[ "def", "_create_slack_with_env_var", "(", "env_var", ":", "EnvVar", ")", "->", "SlackClient", ":", "token", "=", "os", ".", "getenv", "(", "env_var", ")", "if", "token", ":", "return", "SlackClient", "(", "token", "=", "token", ")", "raise", "MissingToken", ...
Create a :obj:`SlackClient` with a token from an env var.
[ "Create", "a", ":", "obj", ":", "SlackClient", "with", "a", "token", "from", "an", "env", "var", "." ]
python
train
nabetama/slacky
slacky/rest/rest.py
https://github.com/nabetama/slacky/blob/dde62ce49af9b8f581729c36d2ac790310b570e4/slacky/rest/rest.py#L819-L823
def messages(self, query, **kwargs): """ https://api.slack.com/methods/search.messages """ self.url = 'https://slack.com/api/search.messages' return super(Search, self).search_from_url(query, **kwargs)
[ "def", "messages", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "self", ".", "url", "=", "'https://slack.com/api/search.messages'", "return", "super", "(", "Search", ",", "self", ")", ".", "search_from_url", "(", "query", ",", "*", "*", ...
https://api.slack.com/methods/search.messages
[ "https", ":", "//", "api", ".", "slack", ".", "com", "/", "methods", "/", "search", ".", "messages" ]
python
train
CloverHealth/temple
temple/utils.py
https://github.com/CloverHealth/temple/blob/d7b75da2459f72ba74d6f3b6e1ab95c3d1b92ccd/temple/utils.py#L85-L102
def set_cmd_env_var(value): """Decorator that sets the temple command env var to value""" def func_decorator(function): @functools.wraps(function) def wrapper(*args, **kwargs): previous_cmd_env_var = os.getenv(temple.constants.TEMPLE_ENV_VAR) os.environ[temple.constants.T...
[ "def", "set_cmd_env_var", "(", "value", ")", ":", "def", "func_decorator", "(", "function", ")", ":", "@", "functools", ".", "wraps", "(", "function", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "previous_cmd_env_var", "="...
Decorator that sets the temple command env var to value
[ "Decorator", "that", "sets", "the", "temple", "command", "env", "var", "to", "value" ]
python
valid
jobovy/galpy
galpy/util/leung_dop853.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/util/leung_dop853.py#L211-L238
def hinit(func, x, t, pos_neg, f0, iord, hmax, rtol, atol, args): """ Estimate initial step size """ sk = atol + rtol * np.fabs(x) dnf = np.sum(np.square(f0 / sk), axis=0) dny = np.sum(np.square(x / sk), axis=0) h = np.sqrt(dny / dnf) * 0.01 h = np.min([h, np.fabs(hmax)]) h = custo...
[ "def", "hinit", "(", "func", ",", "x", ",", "t", ",", "pos_neg", ",", "f0", ",", "iord", ",", "hmax", ",", "rtol", ",", "atol", ",", "args", ")", ":", "sk", "=", "atol", "+", "rtol", "*", "np", ".", "fabs", "(", "x", ")", "dnf", "=", "np", ...
Estimate initial step size
[ "Estimate", "initial", "step", "size" ]
python
train
numberoverzero/bloop
bloop/session.py
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L271-L286
def enable_ttl(self, table_name, model): """Calls UpdateTimeToLive on the table according to model.Meta["ttl"] :param table_name: The name of the table to enable the TTL setting on :param model: The model to get TTL settings from """ self._tables.pop(table_name, None) tt...
[ "def", "enable_ttl", "(", "self", ",", "table_name", ",", "model", ")", ":", "self", ".", "_tables", ".", "pop", "(", "table_name", ",", "None", ")", "ttl_name", "=", "model", ".", "Meta", ".", "ttl", "[", "\"column\"", "]", ".", "dynamo_name", "reques...
Calls UpdateTimeToLive on the table according to model.Meta["ttl"] :param table_name: The name of the table to enable the TTL setting on :param model: The model to get TTL settings from
[ "Calls", "UpdateTimeToLive", "on", "the", "table", "according", "to", "model", ".", "Meta", "[", "ttl", "]" ]
python
train
caseyjlaw/rtpipe
rtpipe/RT.py
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L732-L930
def set_pipeline(filename, scan, fileroot='', paramfile='', **kwargs): """ Function defines pipeline state for search. Takes data/scan as input. fileroot is base name for associated products (cal files, noise, cands). if blank, it is set to filename. paramfile is name of file that defines all pipeline param...
[ "def", "set_pipeline", "(", "filename", ",", "scan", ",", "fileroot", "=", "''", ",", "paramfile", "=", "''", ",", "*", "*", "kwargs", ")", ":", "workdir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "filena...
Function defines pipeline state for search. Takes data/scan as input. fileroot is base name for associated products (cal files, noise, cands). if blank, it is set to filename. paramfile is name of file that defines all pipeline parameters (python-like syntax). kwargs used to overload paramfile definitions. ...
[ "Function", "defines", "pipeline", "state", "for", "search", ".", "Takes", "data", "/", "scan", "as", "input", ".", "fileroot", "is", "base", "name", "for", "associated", "products", "(", "cal", "files", "noise", "cands", ")", ".", "if", "blank", "it", "...
python
train
xolox/python-coloredlogs
coloredlogs/__init__.py
https://github.com/xolox/python-coloredlogs/blob/1cbf0c6bbee400c6ddbc43008143809934ec3e79/coloredlogs/__init__.py#L888-L911
def walk_propagation_tree(logger): """ Walk through the propagation hierarchy of the given logger. :param logger: The logger whose hierarchy to walk (a :class:`~logging.Logger` object). :returns: A generator of :class:`~logging.Logger` objects. .. note:: This uses the undocument...
[ "def", "walk_propagation_tree", "(", "logger", ")", ":", "while", "isinstance", "(", "logger", ",", "logging", ".", "Logger", ")", ":", "# Yield the logger to our caller.", "yield", "logger", "# Check if the logger has propagation enabled.", "if", "logger", ".", "propag...
Walk through the propagation hierarchy of the given logger. :param logger: The logger whose hierarchy to walk (a :class:`~logging.Logger` object). :returns: A generator of :class:`~logging.Logger` objects. .. note:: This uses the undocumented :class:`logging.Logger.parent` ...
[ "Walk", "through", "the", "propagation", "hierarchy", "of", "the", "given", "logger", "." ]
python
train
raiden-network/raiden
raiden/tasks.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L122-L133
def check_network_id(network_id, web3: Web3): """ Check periodically if the underlying ethereum client's network id has changed""" while True: current_id = int(web3.version.network) if network_id != current_id: raise RuntimeError( f'Raiden was running on network with ...
[ "def", "check_network_id", "(", "network_id", ",", "web3", ":", "Web3", ")", ":", "while", "True", ":", "current_id", "=", "int", "(", "web3", ".", "version", ".", "network", ")", "if", "network_id", "!=", "current_id", ":", "raise", "RuntimeError", "(", ...
Check periodically if the underlying ethereum client's network id has changed
[ "Check", "periodically", "if", "the", "underlying", "ethereum", "client", "s", "network", "id", "has", "changed" ]
python
train
moderngl/moderngl
examples/window/sdl2/window.py
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/sdl2/window.py#L124-L130
def destroy(self): """ Gracefully close the window """ sdl2.SDL_GL_DeleteContext(self.context) sdl2.SDL_DestroyWindow(self.window) sdl2.SDL_Quit()
[ "def", "destroy", "(", "self", ")", ":", "sdl2", ".", "SDL_GL_DeleteContext", "(", "self", ".", "context", ")", "sdl2", ".", "SDL_DestroyWindow", "(", "self", ".", "window", ")", "sdl2", ".", "SDL_Quit", "(", ")" ]
Gracefully close the window
[ "Gracefully", "close", "the", "window" ]
python
train
dswah/pyGAM
pygam/terms.py
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/terms.py#L1632-L1655
def pop(self, i=None): """remove the ith term from the term list Parameters --------- i : int, optional term to remove from term list by default the last term is popped. Returns ------- term : Term """ if i == None: ...
[ "def", "pop", "(", "self", ",", "i", "=", "None", ")", ":", "if", "i", "==", "None", ":", "i", "=", "len", "(", "self", ")", "-", "1", "if", "i", ">=", "len", "(", "self", ".", "_terms", ")", "or", "i", "<", "0", ":", "raise", "ValueError",...
remove the ith term from the term list Parameters --------- i : int, optional term to remove from term list by default the last term is popped. Returns ------- term : Term
[ "remove", "the", "ith", "term", "from", "the", "term", "list" ]
python
train
thespacedoctor/sloancone
build/lib/sloancone/image.py
https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/image.py#L136-L194
def _download_sdss_image( self): """*download sdss image* """ self.log.info('starting the ``_download_sdss_image`` method') opt = "" if self.grid: opt += "G" if self.label: opt += "L" if self.photocat: opt += "P" ...
[ "def", "_download_sdss_image", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "'starting the ``_download_sdss_image`` method'", ")", "opt", "=", "\"\"", "if", "self", ".", "grid", ":", "opt", "+=", "\"G\"", "if", "self", ".", "label", ":", "o...
*download sdss image*
[ "*", "download", "sdss", "image", "*" ]
python
train
SCIP-Interfaces/PySCIPOpt
examples/tutorial/logical.py
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/tutorial/logical.py#L50-L58
def or_constraint(v=0, sense="maximize"): """ OR constraint""" assert v in [0,1], "v must be 0 or 1 instead of %s" % v.__repr__() model, x, y, z = _init() r = model.addVar("r", "B") model.addConsOr([x,y,z], r) model.addCons(x==v) model.setObjective(r, sense=sense) _optimize("OR", model)
[ "def", "or_constraint", "(", "v", "=", "0", ",", "sense", "=", "\"maximize\"", ")", ":", "assert", "v", "in", "[", "0", ",", "1", "]", ",", "\"v must be 0 or 1 instead of %s\"", "%", "v", ".", "__repr__", "(", ")", "model", ",", "x", ",", "y", ",", ...
OR constraint
[ "OR", "constraint" ]
python
train
hubo1016/vlcp
vlcp/protocol/http.py
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/protocol/http.py#L165-L181
def date_time_string(timestamp=None): """Return the current date and time formatted for a message header.""" global _last_date_time_string _last_timestamp, _last_str = _last_date_time_string if timestamp is None: timestamp = time.time() _curr_timestamp = int(timestamp) if _curr_timestamp...
[ "def", "date_time_string", "(", "timestamp", "=", "None", ")", ":", "global", "_last_date_time_string", "_last_timestamp", ",", "_last_str", "=", "_last_date_time_string", "if", "timestamp", "is", "None", ":", "timestamp", "=", "time", ".", "time", "(", ")", "_c...
Return the current date and time formatted for a message header.
[ "Return", "the", "current", "date", "and", "time", "formatted", "for", "a", "message", "header", "." ]
python
train
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L238-L254
def _do_pi(self, node): '''_do_pi(self, node) -> None Process a PI node. Render a leading or trailing #xA if the document order of the PI is greater or lesser (respectively) than the document element. ''' if not _in_subset(self.subset, node): return W = self.write...
[ "def", "_do_pi", "(", "self", ",", "node", ")", ":", "if", "not", "_in_subset", "(", "self", ".", "subset", ",", "node", ")", ":", "return", "W", "=", "self", ".", "write", "if", "self", ".", "documentOrder", "==", "_GreaterElement", ":", "W", "(", ...
_do_pi(self, node) -> None Process a PI node. Render a leading or trailing #xA if the document order of the PI is greater or lesser (respectively) than the document element.
[ "_do_pi", "(", "self", "node", ")", "-", ">", "None", "Process", "a", "PI", "node", ".", "Render", "a", "leading", "or", "trailing", "#xA", "if", "the", "document", "order", "of", "the", "PI", "is", "greater", "or", "lesser", "(", "respectively", ")", ...
python
train
click-contrib/click-configfile
click_configfile.py
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L203-L222
def select_params_from_section_schema(section_schema, param_class=Param, deep=False): """Selects the parameters of a config section schema. :param section_schema: Configuration file section schema to use. :return: Generator of params """ # pylint: disable=inva...
[ "def", "select_params_from_section_schema", "(", "section_schema", ",", "param_class", "=", "Param", ",", "deep", "=", "False", ")", ":", "# pylint: disable=invalid-name", "for", "name", ",", "value", "in", "inspect", ".", "getmembers", "(", "section_schema", ")", ...
Selects the parameters of a config section schema. :param section_schema: Configuration file section schema to use. :return: Generator of params
[ "Selects", "the", "parameters", "of", "a", "config", "section", "schema", "." ]
python
train
kdeldycke/maildir-deduplicate
maildir_deduplicate/cli.py
https://github.com/kdeldycke/maildir-deduplicate/blob/f1c6ff25b80c6c1a4dc2dc7a65b34d808b0b7733/maildir_deduplicate/cli.py#L224-L235
def hash(ctx, message_id, message): """ Take a single mail message and show its canonicalised form and hash. Mainly used to debug message hashing. """ conf = Config(message_id=message_id) mail = Mail(message, conf) logger.info(mail.header_text) logger.info('-' * 70) logger.info('Hash:...
[ "def", "hash", "(", "ctx", ",", "message_id", ",", "message", ")", ":", "conf", "=", "Config", "(", "message_id", "=", "message_id", ")", "mail", "=", "Mail", "(", "message", ",", "conf", ")", "logger", ".", "info", "(", "mail", ".", "header_text", "...
Take a single mail message and show its canonicalised form and hash. Mainly used to debug message hashing.
[ "Take", "a", "single", "mail", "message", "and", "show", "its", "canonicalised", "form", "and", "hash", "." ]
python
train
miso-belica/sumy
sumy/summarizers/lex_rank.py
https://github.com/miso-belica/sumy/blob/099ab4938e2c1b6a011297375586bac2953641b9/sumy/summarizers/lex_rank.py#L120-L157
def cosine_similarity(sentence1, sentence2, tf1, tf2, idf_metrics): """ We compute idf-modified-cosine(sentence1, sentence2) here. It's cosine similarity of these two sentences (vectors) A, B computed as cos(x, y) = A . B / (|A| . |B|) Sentences are represented as vector TF*IDF metrics. ...
[ "def", "cosine_similarity", "(", "sentence1", ",", "sentence2", ",", "tf1", ",", "tf2", ",", "idf_metrics", ")", ":", "unique_words1", "=", "frozenset", "(", "sentence1", ")", "unique_words2", "=", "frozenset", "(", "sentence2", ")", "common_words", "=", "uniq...
We compute idf-modified-cosine(sentence1, sentence2) here. It's cosine similarity of these two sentences (vectors) A, B computed as cos(x, y) = A . B / (|A| . |B|) Sentences are represented as vector TF*IDF metrics. :param sentence1: Iterable object where every item represents word ...
[ "We", "compute", "idf", "-", "modified", "-", "cosine", "(", "sentence1", "sentence2", ")", "here", ".", "It", "s", "cosine", "similarity", "of", "these", "two", "sentences", "(", "vectors", ")", "A", "B", "computed", "as", "cos", "(", "x", "y", ")", ...
python
train
pybel/pybel
src/pybel/struct/filters/edge_predicate_builders.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/filters/edge_predicate_builders.py#L101-L109
def build_upstream_edge_predicate(nodes: Iterable[BaseEntity]) -> EdgePredicate: """Build an edge predicate that pass for relations for which one of the given nodes is the object.""" nodes = set(nodes) def upstream_filter(graph: BELGraph, u: BaseEntity, v: BaseEntity, k: str) -> bool: """Pass for r...
[ "def", "build_upstream_edge_predicate", "(", "nodes", ":", "Iterable", "[", "BaseEntity", "]", ")", "->", "EdgePredicate", ":", "nodes", "=", "set", "(", "nodes", ")", "def", "upstream_filter", "(", "graph", ":", "BELGraph", ",", "u", ":", "BaseEntity", ",",...
Build an edge predicate that pass for relations for which one of the given nodes is the object.
[ "Build", "an", "edge", "predicate", "that", "pass", "for", "relations", "for", "which", "one", "of", "the", "given", "nodes", "is", "the", "object", "." ]
python
train
Genida/django-meerkat
src/meerkat/utils/time.py
https://github.com/Genida/django-meerkat/blob/486502a75bb0800266db785fd32717d8c0eb8deb/src/meerkat/utils/time.py#L21-L33
def daterange(start_date, end_date): """ Yield one date per day from starting date to ending date. Args: start_date (date): starting date. end_date (date): ending date. Yields: date: a date for each day within the range. """ for n in range(int((end_date - start_date).da...
[ "def", "daterange", "(", "start_date", ",", "end_date", ")", ":", "for", "n", "in", "range", "(", "int", "(", "(", "end_date", "-", "start_date", ")", ".", "days", ")", ")", ":", "yield", "start_date", "+", "timedelta", "(", "n", ")" ]
Yield one date per day from starting date to ending date. Args: start_date (date): starting date. end_date (date): ending date. Yields: date: a date for each day within the range.
[ "Yield", "one", "date", "per", "day", "from", "starting", "date", "to", "ending", "date", "." ]
python
train
razor-x/scipy-data_fitting
scipy_data_fitting/figure/plot.py
https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/figure/plot.py#L88-L92
def plot_fit(self): """ Add the fit to the plot. """ self.plt.plot(*self.fit.fit, **self.options['fit'])
[ "def", "plot_fit", "(", "self", ")", ":", "self", ".", "plt", ".", "plot", "(", "*", "self", ".", "fit", ".", "fit", ",", "*", "*", "self", ".", "options", "[", "'fit'", "]", ")" ]
Add the fit to the plot.
[ "Add", "the", "fit", "to", "the", "plot", "." ]
python
train
akissa/clamavmirror
setup.py
https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/setup.py#L39-L72
def main(): """Main""" opts = dict( name="clamavmirror", version='0.0.4', description="ClamAV Signature Mirroring Tool", long_description=get_readme(), keywords="clamav mirror mirroring mirror-tool signatures", author="Andrew Colin Kissa", author_email="a...
[ "def", "main", "(", ")", ":", "opts", "=", "dict", "(", "name", "=", "\"clamavmirror\"", ",", "version", "=", "'0.0.4'", ",", "description", "=", "\"ClamAV Signature Mirroring Tool\"", ",", "long_description", "=", "get_readme", "(", ")", ",", "keywords", "=",...
Main
[ "Main" ]
python
train
aio-libs/aiohttp
aiohttp/multipart.py
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L399-L405
async def text(self, *, encoding: Optional[str]=None) -> str: """Like read(), but assumes that body part contains text data.""" data = await self.read(decode=True) # see https://www.w3.org/TR/html5/forms.html#multipart/form-data-encoding-algorithm # NOQA # and https://dvcs.w3.org/hg/xhr/...
[ "async", "def", "text", "(", "self", ",", "*", ",", "encoding", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "data", "=", "await", "self", ".", "read", "(", "decode", "=", "True", ")", "# see https://www.w3.org/TR/html5/forms.htm...
Like read(), but assumes that body part contains text data.
[ "Like", "read", "()", "but", "assumes", "that", "body", "part", "contains", "text", "data", "." ]
python
train
jaraco/jaraco.windows
jaraco/windows/filesystem/__init__.py
https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/filesystem/__init__.py#L48-L54
def _is_target_a_directory(link, rel_target): """ If creating a symlink from link to a target, determine if target is a directory (relative to dirname(link)). """ target = os.path.join(os.path.dirname(link), rel_target) return os.path.isdir(target)
[ "def", "_is_target_a_directory", "(", "link", ",", "rel_target", ")", ":", "target", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "link", ")", ",", "rel_target", ")", "return", "os", ".", "path", ".", "isdir", "("...
If creating a symlink from link to a target, determine if target is a directory (relative to dirname(link)).
[ "If", "creating", "a", "symlink", "from", "link", "to", "a", "target", "determine", "if", "target", "is", "a", "directory", "(", "relative", "to", "dirname", "(", "link", "))", "." ]
python
train
OCHA-DAP/hdx-python-utilities
src/hdx/utilities/useragent.py
https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/useragent.py#L146-L160
def set_global(cls, user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None, **kwargs): # type: (Optional[str], Optional[str], Optional[str], Any) -> None """ Set global user agent string Args: user_agent (Optional[str]): User agent string. HD...
[ "def", "set_global", "(", "cls", ",", "user_agent", "=", "None", ",", "user_agent_config_yaml", "=", "None", ",", "user_agent_lookup", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# type: (Optional[str], Optional[str], Optional[str], Any) -> None", "cls", ".", "...
Set global user agent string Args: user_agent (Optional[str]): User agent string. HDXPythonLibrary/X.X.X- is prefixed. user_agent_config_yaml (Optional[str]): Path to YAML user agent configuration. Ignored if user_agent supplied. Defaults to ~/.useragent.yml. user_agent_look...
[ "Set", "global", "user", "agent", "string" ]
python
train
saltstack/salt
salt/utils/master.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/master.py#L648-L767
def run(self): ''' Main loop of the ConCache, starts updates in intervals and answers requests from the MWorkers ''' context = zmq.Context() # the socket for incoming cache requests creq_in = context.socket(zmq.REP) creq_in.setsockopt(zmq.LINGER, 100) ...
[ "def", "run", "(", "self", ")", ":", "context", "=", "zmq", ".", "Context", "(", ")", "# the socket for incoming cache requests", "creq_in", "=", "context", ".", "socket", "(", "zmq", ".", "REP", ")", "creq_in", ".", "setsockopt", "(", "zmq", ".", "LINGER"...
Main loop of the ConCache, starts updates in intervals and answers requests from the MWorkers
[ "Main", "loop", "of", "the", "ConCache", "starts", "updates", "in", "intervals", "and", "answers", "requests", "from", "the", "MWorkers" ]
python
train
ckan/ckan-service-provider
ckanserviceprovider/web.py
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L344-L397
def job_list(): '''List all jobs. :param _limit: maximum number of jobs to show (default 100) :type _limit: int :param _offset: how many jobs to skip before showin the first one (default 0) :type _offset: int :param _status: filter jobs by status (complete, error) :type _status: string ...
[ "def", "job_list", "(", ")", ":", "args", "=", "dict", "(", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "flask", ".", "request", ".", "args", ".", "items", "(", ")", ")", "limit", "=", "args", ".", "pop", "(", "'_limit'", "...
List all jobs. :param _limit: maximum number of jobs to show (default 100) :type _limit: int :param _offset: how many jobs to skip before showin the first one (default 0) :type _offset: int :param _status: filter jobs by status (complete, error) :type _status: string Also, you can filter t...
[ "List", "all", "jobs", "." ]
python
train
DLR-RM/RAFCON
source/rafcon/gui/models/selection.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/selection.py#L170-L177
def add(self, models): """ Adds the passed model(s) to the selection""" if models is None: return models = self._check_model_types(models) self._selected.update(models) self._selected = reduce_to_parent_states(self._selected)
[ "def", "add", "(", "self", ",", "models", ")", ":", "if", "models", "is", "None", ":", "return", "models", "=", "self", ".", "_check_model_types", "(", "models", ")", "self", ".", "_selected", ".", "update", "(", "models", ")", "self", ".", "_selected"...
Adds the passed model(s) to the selection
[ "Adds", "the", "passed", "model", "(", "s", ")", "to", "the", "selection" ]
python
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L274-L292
def _disconnect(self, mqttc, userdata, rc): """ The callback for when a DISCONNECT occurs. :param mqttc: The client instance for this callback :param userdata: The private userdata for the mqtt client. Not used in Polyglot :param rc: Result code of connection, 0 = Graceful, anyt...
[ "def", "_disconnect", "(", "self", ",", "mqttc", ",", "userdata", ",", "rc", ")", ":", "self", ".", "connected", "=", "False", "if", "rc", "!=", "0", ":", "LOGGER", ".", "info", "(", "\"MQTT Unexpected disconnection. Trying reconnect.\"", ")", "try", ":", ...
The callback for when a DISCONNECT occurs. :param mqttc: The client instance for this callback :param userdata: The private userdata for the mqtt client. Not used in Polyglot :param rc: Result code of connection, 0 = Graceful, anything else is unclean
[ "The", "callback", "for", "when", "a", "DISCONNECT", "occurs", "." ]
python
train
vtemian/buffpy
buffpy/models/link.py
https://github.com/vtemian/buffpy/blob/6c9236fd3b6a8f9e2d70dbf1bc01529242b73075/buffpy/models/link.py#L18-L28
def get_shares(self): ''' Returns an object with a the numbers of shares a link has had using Buffer. www will be stripped, but other subdomains will not. ''' self.shares = self.api.get(url=PATHS['GET_SHARES'] % self.url)['shares'] return self.shares
[ "def", "get_shares", "(", "self", ")", ":", "self", ".", "shares", "=", "self", ".", "api", ".", "get", "(", "url", "=", "PATHS", "[", "'GET_SHARES'", "]", "%", "self", ".", "url", ")", "[", "'shares'", "]", "return", "self", ".", "shares" ]
Returns an object with a the numbers of shares a link has had using Buffer. www will be stripped, but other subdomains will not.
[ "Returns", "an", "object", "with", "a", "the", "numbers", "of", "shares", "a", "link", "has", "had", "using", "Buffer", "." ]
python
valid
darkfeline/animanager
animanager/animecmd.py
https://github.com/darkfeline/animanager/blob/55d92e4cbdc12aac8ebe302420d2cff3fa9fa148/animanager/animecmd.py#L86-L109
def cmdloop(self): """Start CLI REPL.""" while True: cmdline = input(self.prompt) tokens = shlex.split(cmdline) if not tokens: if self.last_cmd: tokens = self.last_cmd else: print('No previous com...
[ "def", "cmdloop", "(", "self", ")", ":", "while", "True", ":", "cmdline", "=", "input", "(", "self", ".", "prompt", ")", "tokens", "=", "shlex", ".", "split", "(", "cmdline", ")", "if", "not", "tokens", ":", "if", "self", ".", "last_cmd", ":", "tok...
Start CLI REPL.
[ "Start", "CLI", "REPL", "." ]
python
train
suds-community/suds
suds/umx/core.py
https://github.com/suds-community/suds/blob/6fb0a829337b5037a66c20aae6f89b41acd77e40/suds/umx/core.py#L66-L101
def postprocess(self, content): """ Perform final processing of the resulting data structure as follows: - Mixed values (children and text) will have a result of the I{content.node}. - Simi-simple values (attributes, no-children and text) will have a result of a property...
[ "def", "postprocess", "(", "self", ",", "content", ")", ":", "node", "=", "content", ".", "node", "if", "len", "(", "node", ".", "children", ")", "and", "node", ".", "hasText", "(", ")", ":", "return", "node", "attributes", "=", "AttrList", "(", "nod...
Perform final processing of the resulting data structure as follows: - Mixed values (children and text) will have a result of the I{content.node}. - Simi-simple values (attributes, no-children and text) will have a result of a property object. - Simple values (no-attributes, n...
[ "Perform", "final", "processing", "of", "the", "resulting", "data", "structure", "as", "follows", ":", "-", "Mixed", "values", "(", "children", "and", "text", ")", "will", "have", "a", "result", "of", "the", "I", "{", "content", ".", "node", "}", ".", ...
python
train
thombashi/SimpleSQLite
simplesqlite/core.py
https://github.com/thombashi/SimpleSQLite/blob/b16f212132b9b98773e68bf7395abc2f60f56fe5/simplesqlite/core.py#L1546-L1560
def __verify_db_file_existence(self, database_path): """ :raises SimpleSQLite.OperationalError: If unable to open database file. """ self.__validate_db_path(database_path) if not os.path.isfile(os.path.realpath(database_path)): raise IOError("file not found: " + data...
[ "def", "__verify_db_file_existence", "(", "self", ",", "database_path", ")", ":", "self", ".", "__validate_db_path", "(", "database_path", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "realpath", "(", "database_path", ")",...
:raises SimpleSQLite.OperationalError: If unable to open database file.
[ ":", "raises", "SimpleSQLite", ".", "OperationalError", ":", "If", "unable", "to", "open", "database", "file", "." ]
python
train
emory-libraries/eulcommon
eulcommon/djangoextras/taskresult/models.py
https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/djangoextras/taskresult/models.py#L76-L83
def status_icon(self): 'glyphicon for task status; requires bootstrap' icon = self.status_icon_map.get(self.status.lower(), self.unknown_icon) style = self.status_style.get(self.status.lower(), '') return mark_safe( '<span class="glyphi...
[ "def", "status_icon", "(", "self", ")", ":", "icon", "=", "self", ".", "status_icon_map", ".", "get", "(", "self", ".", "status", ".", "lower", "(", ")", ",", "self", ".", "unknown_icon", ")", "style", "=", "self", ".", "status_style", ".", "get", "(...
glyphicon for task status; requires bootstrap
[ "glyphicon", "for", "task", "status", ";", "requires", "bootstrap" ]
python
train
ellmetha/django-machina
machina/apps/forum_tracking/managers.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_tracking/managers.py#L20-L48
def get_unread_forums_from_list(self, forums, user): """ Filter a list of forums and return only those which are unread. Given a list of forums find and returns the list of forums that are unread for the passed user. If a forum is unread all of its ancestors are also unread and will be included...
[ "def", "get_unread_forums_from_list", "(", "self", ",", "forums", ",", "user", ")", ":", "unread_forums", "=", "[", "]", "visibility_contents", "=", "ForumVisibilityContentTree", ".", "from_forums", "(", "forums", ")", "forum_ids_to_visibility_nodes", "=", "visibility...
Filter a list of forums and return only those which are unread. Given a list of forums find and returns the list of forums that are unread for the passed user. If a forum is unread all of its ancestors are also unread and will be included in the final list.
[ "Filter", "a", "list", "of", "forums", "and", "return", "only", "those", "which", "are", "unread", "." ]
python
train
pycampers/ampy
ampy/cli.py
https://github.com/pycampers/ampy/blob/6851f8b177c334f5ff7bd43bf07307a437433ba2/ampy/cli.py#L290-L304
def rmdir(remote_folder, missing_okay): """Forcefully remove a folder and all its children from the board. Remove the specified folder from the board's filesystem. Must specify one argument which is the path to the folder to delete. This will delete the directory and ALL of its children recursively, ...
[ "def", "rmdir", "(", "remote_folder", ",", "missing_okay", ")", ":", "# Delete the provided file/directory on the board.", "board_files", "=", "files", ".", "Files", "(", "_board", ")", "board_files", ".", "rmdir", "(", "remote_folder", ",", "missing_okay", "=", "mi...
Forcefully remove a folder and all its children from the board. Remove the specified folder from the board's filesystem. Must specify one argument which is the path to the folder to delete. This will delete the directory and ALL of its children recursively, use with caution! For example to delete ev...
[ "Forcefully", "remove", "a", "folder", "and", "all", "its", "children", "from", "the", "board", "." ]
python
train
VasilyStepanov/pywidl
pywidl/grammar.py
https://github.com/VasilyStepanov/pywidl/blob/8d84b2e53157bfe276bf16301c19e8b6b32e861e/pywidl/grammar.py#L971-L974
def p_ExtendedAttributeNoArgs(p): """ExtendedAttributeNoArgs : IDENTIFIER""" p[0] = model.ExtendedAttribute( value=model.ExtendedAttributeValue(name=p[1]))
[ "def", "p_ExtendedAttributeNoArgs", "(", "p", ")", ":", "p", "[", "0", "]", "=", "model", ".", "ExtendedAttribute", "(", "value", "=", "model", ".", "ExtendedAttributeValue", "(", "name", "=", "p", "[", "1", "]", ")", ")" ]
ExtendedAttributeNoArgs : IDENTIFIER
[ "ExtendedAttributeNoArgs", ":", "IDENTIFIER" ]
python
train
ricardosasilva/pagseguro-python
pagseguro/api/v2/payment.py
https://github.com/ricardosasilva/pagseguro-python/blob/8e39d1b0585684c460b86073d1fb3f33112b5b3d/pagseguro/api/v2/payment.py#L152-L177
def request(self): ''' Faz a requisição de pagamento ao servidor do PagSeguro. ''' # try: payment_v2_schema(self) # except MultipleInvalid as e: # raise PagSeguroPaymentValidationException(u'Erro na validação dos dados: %s' % e.msg) params = self._build_p...
[ "def", "request", "(", "self", ")", ":", "# try:", "payment_v2_schema", "(", "self", ")", "# except MultipleInvalid as e:", "# raise PagSeguroPaymentValidationException(u'Erro na validação dos dados: %s' % e.msg)", "params", "=", "self", ".", "_build_params...
Faz a requisição de pagamento ao servidor do PagSeguro.
[ "Faz", "a", "requisição", "de", "pagamento", "ao", "servidor", "do", "PagSeguro", "." ]
python
train
twisted/axiom
axiom/item.py
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/item.py#L744-L817
def checkpoint(self): """ Update the database to reflect in-memory changes made to this item; for example, to make it show up in store.query() calls where it is now valid, but was not the last time it was persisted to the database. This is called automatically when in 'autocommi...
[ "def", "checkpoint", "(", "self", ")", ":", "if", "self", ".", "store", "is", "None", ":", "raise", "NotInStore", "(", "\"You can't checkpoint %r: not in a store\"", "%", "(", "self", ",", ")", ")", "if", "self", ".", "__deleting", ":", "if", "not", "self"...
Update the database to reflect in-memory changes made to this item; for example, to make it show up in store.query() calls where it is now valid, but was not the last time it was persisted to the database. This is called automatically when in 'autocommit mode' (i.e. not in a transaction...
[ "Update", "the", "database", "to", "reflect", "in", "-", "memory", "changes", "made", "to", "this", "item", ";", "for", "example", "to", "make", "it", "show", "up", "in", "store", ".", "query", "()", "calls", "where", "it", "is", "now", "valid", "but",...
python
train
pymoca/pymoca
src/pymoca/backends/xml/model.py
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L70-L76
def create_function_f_c(self): """condition function""" return ca.Function( 'f_c', [self.t, self.x, self.y, self.m, self.p, self.ng, self.nu], [self.f_c], ['t', 'x', 'y', 'm', 'p', 'ng', 'nu'], ['c'], self.func_opt)
[ "def", "create_function_f_c", "(", "self", ")", ":", "return", "ca", ".", "Function", "(", "'f_c'", ",", "[", "self", ".", "t", ",", "self", ".", "x", ",", "self", ".", "y", ",", "self", ".", "m", ",", "self", ".", "p", ",", "self", ".", "ng", ...
condition function
[ "condition", "function" ]
python
train
Kozea/pygal
pygal/graph/public.py
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/public.py#L49-L56
def render(self, is_unicode=False, **kwargs): """Render the graph, and return the svg string""" self.setup(**kwargs) svg = self.svg.render( is_unicode=is_unicode, pretty_print=self.pretty_print ) self.teardown() return svg
[ "def", "render", "(", "self", ",", "is_unicode", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "setup", "(", "*", "*", "kwargs", ")", "svg", "=", "self", ".", "svg", ".", "render", "(", "is_unicode", "=", "is_unicode", ",", "pretty_...
Render the graph, and return the svg string
[ "Render", "the", "graph", "and", "return", "the", "svg", "string" ]
python
train
globocom/GloboNetworkAPI-client-python
networkapiclient/TipoRede.py
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/TipoRede.py#L57-L76
def inserir(self, name): """Insert new network type and return its identifier. :param name: Network type name. :return: Following dictionary: {'net_type': {'id': < id >}} :raise InvalidParameterError: Network type is none or invalid. :raise NomeTipoRedeDuplicadoError: A networ...
[ "def", "inserir", "(", "self", ",", "name", ")", ":", "net_type_map", "=", "dict", "(", ")", "net_type_map", "[", "'name'", "]", "=", "name", "code", ",", "xml", "=", "self", ".", "submit", "(", "{", "'net_type'", ":", "net_type_map", "}", ",", "'POS...
Insert new network type and return its identifier. :param name: Network type name. :return: Following dictionary: {'net_type': {'id': < id >}} :raise InvalidParameterError: Network type is none or invalid. :raise NomeTipoRedeDuplicadoError: A network type with this name already exists...
[ "Insert", "new", "network", "type", "and", "return", "its", "identifier", "." ]
python
train
manns/pyspread
pyspread/src/gui/_widgets.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_widgets.py#L1088-L1093
def Reposition(self): """Reposition the checkbox""" rect = self.GetFieldRect(1) self.safemode_staticbmp.SetPosition((rect.x, rect.y)) self.size_changed = False
[ "def", "Reposition", "(", "self", ")", ":", "rect", "=", "self", ".", "GetFieldRect", "(", "1", ")", "self", ".", "safemode_staticbmp", ".", "SetPosition", "(", "(", "rect", ".", "x", ",", "rect", ".", "y", ")", ")", "self", ".", "size_changed", "=",...
Reposition the checkbox
[ "Reposition", "the", "checkbox" ]
python
train
bukun/TorCMS
torcms/model/post_model.py
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L26-L37
def query_recent_most(num=8, recent=30): ''' Query the records from database that recently updated. :param num: the number that will returned. :param recent: the number of days recent. ''' time_that = int(time.time()) - recent * 24 * 3600 return TabPost.select().w...
[ "def", "query_recent_most", "(", "num", "=", "8", ",", "recent", "=", "30", ")", ":", "time_that", "=", "int", "(", "time", ".", "time", "(", ")", ")", "-", "recent", "*", "24", "*", "3600", "return", "TabPost", ".", "select", "(", ")", ".", "whe...
Query the records from database that recently updated. :param num: the number that will returned. :param recent: the number of days recent.
[ "Query", "the", "records", "from", "database", "that", "recently", "updated", ".", ":", "param", "num", ":", "the", "number", "that", "will", "returned", ".", ":", "param", "recent", ":", "the", "number", "of", "days", "recent", "." ]
python
train
ozak/georasters
georasters/georasters.py
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L1041-L1060
def pysal_Moran_Local(self, **kwargs): """ Compute Local Moran's I measure of local spatial autocorrelation for GeoRaster Usage: geo.pysal_Moran_Local(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Moran_Local See help(gr.raster_weights),...
[ "def", "pysal_Moran_Local", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "weights", "is", "None", ":", "self", ".", "raster_weights", "(", "*", "*", "kwargs", ")", "rasterf", "=", "self", ".", "raster", ".", "flatten", "(", ")",...
Compute Local Moran's I measure of local spatial autocorrelation for GeoRaster Usage: geo.pysal_Moran_Local(permutations = 1000, rook=True) arguments passed to raster_weights() and pysal.Moran_Local See help(gr.raster_weights), help(pysal.Moran_Local) for options
[ "Compute", "Local", "Moran", "s", "I", "measure", "of", "local", "spatial", "autocorrelation", "for", "GeoRaster" ]
python
train
pgmpy/pgmpy
pgmpy/readwrite/ProbModelXML.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/ProbModelXML.py#L723-L766
def create_probnet(self): """ Returns a BayesianModel or MarkovModel object depending on the type of ProbModelXML passed to ProbModelXMLReader class. """ self.probnet = {} # Add general properties probnet_elem = self.xml.find('ProbNet') self.probnet['type'...
[ "def", "create_probnet", "(", "self", ")", ":", "self", ".", "probnet", "=", "{", "}", "# Add general properties", "probnet_elem", "=", "self", ".", "xml", ".", "find", "(", "'ProbNet'", ")", "self", ".", "probnet", "[", "'type'", "]", "=", "probnet_elem",...
Returns a BayesianModel or MarkovModel object depending on the type of ProbModelXML passed to ProbModelXMLReader class.
[ "Returns", "a", "BayesianModel", "or", "MarkovModel", "object", "depending", "on", "the", "type", "of", "ProbModelXML", "passed", "to", "ProbModelXMLReader", "class", "." ]
python
train
matthewdeanmartin/jiggle_version
extra/vendorized/pep440.py
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/extra/vendorized/pep440.py#L50-L56
def is_canonical(version, loosedev=False): # type: (str, bool) -> bool """ Return whether or not the version string is canonical according to Pep 440 """ if loosedev: return loose440re.match(version) is not None return pep440re.match(version) is not None
[ "def", "is_canonical", "(", "version", ",", "loosedev", "=", "False", ")", ":", "# type: (str, bool) -> bool", "if", "loosedev", ":", "return", "loose440re", ".", "match", "(", "version", ")", "is", "not", "None", "return", "pep440re", ".", "match", "(", "ve...
Return whether or not the version string is canonical according to Pep 440
[ "Return", "whether", "or", "not", "the", "version", "string", "is", "canonical", "according", "to", "Pep", "440" ]
python
train
CybOXProject/mixbox
mixbox/fields.py
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/fields.py#L50-L62
def iterfields(klass): """Iterate over the input class members and yield its TypedFields. Args: klass: A class (usually an Entity subclass). Yields: (class attribute name, TypedField instance) tuples. """ is_field = lambda x: isinstance(x, TypedField) for name, field in inspec...
[ "def", "iterfields", "(", "klass", ")", ":", "is_field", "=", "lambda", "x", ":", "isinstance", "(", "x", ",", "TypedField", ")", "for", "name", ",", "field", "in", "inspect", ".", "getmembers", "(", "klass", ",", "predicate", "=", "is_field", ")", ":"...
Iterate over the input class members and yield its TypedFields. Args: klass: A class (usually an Entity subclass). Yields: (class attribute name, TypedField instance) tuples.
[ "Iterate", "over", "the", "input", "class", "members", "and", "yield", "its", "TypedFields", "." ]
python
train
Qiskit/qiskit-terra
qiskit/extensions/standard/s.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/s.py#L60-L71
def _define(self): """ gate sdg a { u1(-pi/2) a; } """ definition = [] q = QuantumRegister(1, "q") rule = [ (U1Gate(-pi/2), [q[0]], []) ] for inst in rule: definition.append(inst) self.definition = definition
[ "def", "_define", "(", "self", ")", ":", "definition", "=", "[", "]", "q", "=", "QuantumRegister", "(", "1", ",", "\"q\"", ")", "rule", "=", "[", "(", "U1Gate", "(", "-", "pi", "/", "2", ")", ",", "[", "q", "[", "0", "]", "]", ",", "[", "]"...
gate sdg a { u1(-pi/2) a; }
[ "gate", "sdg", "a", "{", "u1", "(", "-", "pi", "/", "2", ")", "a", ";", "}" ]
python
test
chrislit/abydos
abydos/phonetic/_onca.py
https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/phonetic/_onca.py#L93-L124
def onca(word, max_length=4, zero_pad=True): """Return the Oxford Name Compression Algorithm (ONCA) code for a word. This is a wrapper for :py:meth:`ONCA.encode`. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 5) of the code ...
[ "def", "onca", "(", "word", ",", "max_length", "=", "4", ",", "zero_pad", "=", "True", ")", ":", "return", "ONCA", "(", ")", ".", "encode", "(", "word", ",", "max_length", ",", "zero_pad", ")" ]
Return the Oxford Name Compression Algorithm (ONCA) code for a word. This is a wrapper for :py:meth:`ONCA.encode`. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 5) of the code to return zero_pad : bool Pad the end of...
[ "Return", "the", "Oxford", "Name", "Compression", "Algorithm", "(", "ONCA", ")", "code", "for", "a", "word", "." ]
python
valid
globality-corp/microcosm-postgres
microcosm_postgres/store.py
https://github.com/globality-corp/microcosm-postgres/blob/43dd793b1fc9b84e4056700f350e79e0df5ff501/microcosm_postgres/store.py#L124-L137
def update_with_diff(self, identifier, new_instance): """ Update an existing model with a new one. :raises `ModelNotFoundError` if there is no existing model """ with self.flushing(): instance = self.retrieve(identifier) before = Version(instance) ...
[ "def", "update_with_diff", "(", "self", ",", "identifier", ",", "new_instance", ")", ":", "with", "self", ".", "flushing", "(", ")", ":", "instance", "=", "self", ".", "retrieve", "(", "identifier", ")", "before", "=", "Version", "(", "instance", ")", "s...
Update an existing model with a new one. :raises `ModelNotFoundError` if there is no existing model
[ "Update", "an", "existing", "model", "with", "a", "new", "one", "." ]
python
train
trehn/termdown
termdown.py
https://github.com/trehn/termdown/blob/aa0c4e39d9864fd1466ef9d76947fb93d0cf5be2/termdown.py#L98-L118
def format_seconds(seconds, hide_seconds=False): """ Returns a human-readable string representation of the given amount of seconds. """ if seconds <= 60: return str(seconds) output = "" for period, period_seconds in ( ('y', 31557600), ('d', 86400), ('h', 3600)...
[ "def", "format_seconds", "(", "seconds", ",", "hide_seconds", "=", "False", ")", ":", "if", "seconds", "<=", "60", ":", "return", "str", "(", "seconds", ")", "output", "=", "\"\"", "for", "period", ",", "period_seconds", "in", "(", "(", "'y'", ",", "31...
Returns a human-readable string representation of the given amount of seconds.
[ "Returns", "a", "human", "-", "readable", "string", "representation", "of", "the", "given", "amount", "of", "seconds", "." ]
python
train
bambinos/bambi
bambi/models.py
https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/models.py#L548-L574
def _match_derived_terms(self, name): ''' Returns all (random) terms whose named are derived from the specified string. For example, 'condition|subject' should match the terms with names '1|subject', 'condition[T.1]|subject', and so on. Only works for strings with grouping operat...
[ "def", "_match_derived_terms", "(", "self", ",", "name", ")", ":", "if", "'|'", "not", "in", "name", ":", "return", "None", "patt", "=", "r'^([01]+)*[\\s\\+]*([^\\|]+)*\\|(.*)'", "intcpt", ",", "pred", ",", "grpr", "=", "re", ".", "search", "(", "patt", ",...
Returns all (random) terms whose named are derived from the specified string. For example, 'condition|subject' should match the terms with names '1|subject', 'condition[T.1]|subject', and so on. Only works for strings with grouping operator ('|').
[ "Returns", "all", "(", "random", ")", "terms", "whose", "named", "are", "derived", "from", "the", "specified", "string", ".", "For", "example", "condition|subject", "should", "match", "the", "terms", "with", "names", "1|subject", "condition", "[", "T", ".", ...
python
train
mitsei/dlkit
dlkit/handcar/repository/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/repository/managers.py#L1222-L1244
def get_asset_composition_session(self): """Gets the session for retrieving asset compositions. return: (osid.repository.AssetCompositionSession) - an AssetCompositionSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_comp...
[ "def", "get_asset_composition_session", "(", "self", ")", ":", "if", "not", "self", ".", "supports_asset_composition", "(", ")", ":", "raise", "Unimplemented", "(", ")", "try", ":", "from", ".", "import", "sessions", "except", "ImportError", ":", "raise", "# O...
Gets the session for retrieving asset compositions. return: (osid.repository.AssetCompositionSession) - an AssetCompositionSession raise: OperationFailed - unable to complete request raise: Unimplemented - supports_asset_composition() is false compliance: optional - Th...
[ "Gets", "the", "session", "for", "retrieving", "asset", "compositions", "." ]
python
train
rlabbe/filterpy
filterpy/kalman/information_filter.py
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/information_filter.py#L291-L363
def batch_filter(self, zs, Rs=None, update_first=False, saver=None): """ Batch processes a sequences of measurements. Parameters ---------- zs : list-like list of measurements at each time step `self.dt` Missing measurements must be represented by 'None'. ...
[ "def", "batch_filter", "(", "self", ",", "zs", ",", "Rs", "=", "None", ",", "update_first", "=", "False", ",", "saver", "=", "None", ")", ":", "raise", "NotImplementedError", "(", "\"this is not implemented yet\"", ")", "#pylint: disable=unreachable, no-member", "...
Batch processes a sequences of measurements. Parameters ---------- zs : list-like list of measurements at each time step `self.dt` Missing measurements must be represented by 'None'. Rs : list-like, optional optional list of values to use for the me...
[ "Batch", "processes", "a", "sequences", "of", "measurements", "." ]
python
train
gpoulter/fablib
fablib.py
https://github.com/gpoulter/fablib/blob/5d14c4d998f79dd1aa3207063c3d06e30e3e2bf9/fablib.py#L126-L140
def rsync(local_path, remote_path, exclude=None, extra_opts=None): """Helper to rsync submodules across""" if not local_path.endswith('/'): local_path += '/' exclude = exclude or [] exclude.extend(['*.egg-info', '*.pyc', '.git', '.gitignore', '.gitmodules', '/build/', '/dist/...
[ "def", "rsync", "(", "local_path", ",", "remote_path", ",", "exclude", "=", "None", ",", "extra_opts", "=", "None", ")", ":", "if", "not", "local_path", ".", "endswith", "(", "'/'", ")", ":", "local_path", "+=", "'/'", "exclude", "=", "exclude", "or", ...
Helper to rsync submodules across
[ "Helper", "to", "rsync", "submodules", "across" ]
python
train
textmagic/textmagic-rest-python
textmagic/rest/models/contacts.py
https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/contacts.py#L247-L262
def delete_contacts(self, uid, **kwargs): """ Unassign contacts from the specified list. If contacts assign only to the specified list, then delete permanently. Returns True if success. :Example: client.lists.delete_contacts(uid=1901010, contacts="1723812,1239912") ...
[ "def", "delete_contacts", "(", "self", ",", "uid", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "\"%s/%s/contacts\"", "%", "(", "self", ".", "uri", ",", "uid", ")", "response", ",", "instance", "=", "self", ".", "request", "(", "\"DELETE\"", ",", "...
Unassign contacts from the specified list. If contacts assign only to the specified list, then delete permanently. Returns True if success. :Example: client.lists.delete_contacts(uid=1901010, contacts="1723812,1239912") :param int uid: The unique id of the List. Required....
[ "Unassign", "contacts", "from", "the", "specified", "list", ".", "If", "contacts", "assign", "only", "to", "the", "specified", "list", "then", "delete", "permanently", ".", "Returns", "True", "if", "success", "." ]
python
train
google/python-gflags
gflags/flagvalues.py
https://github.com/google/python-gflags/blob/4f06c3d0d6cbe9b1fb90ee9fb1c082b3bf9285f6/gflags/flagvalues.py#L245-L263
def _CleanupUnregisteredFlagFromModuleDicts(self, flag_obj): """Cleanup unregistered flags from all module -> [flags] dictionaries. If flag_obj is registered under either its long name or short name, it won't be removed from the dictionaries. Args: flag_obj: A flag object. """ if self._F...
[ "def", "_CleanupUnregisteredFlagFromModuleDicts", "(", "self", ",", "flag_obj", ")", ":", "if", "self", ".", "_FlagIsRegistered", "(", "flag_obj", ")", ":", "return", "for", "flags_by_module_dict", "in", "(", "self", ".", "FlagsByModuleDict", "(", ")", ",", "sel...
Cleanup unregistered flags from all module -> [flags] dictionaries. If flag_obj is registered under either its long name or short name, it won't be removed from the dictionaries. Args: flag_obj: A flag object.
[ "Cleanup", "unregistered", "flags", "from", "all", "module", "-", ">", "[", "flags", "]", "dictionaries", "." ]
python
train
santoshphilip/eppy
eppy/bunch_subclass.py
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/bunch_subclass.py#L459-L475
def isequal(bch, fieldname, value, places=7): """return True if the field is equal to value""" def equalalphanumeric(bch, fieldname, value): if bch.get_retaincase(fieldname): return bch[fieldname] == value else: return bch[fieldname].upper() == value.upper() fieldidd...
[ "def", "isequal", "(", "bch", ",", "fieldname", ",", "value", ",", "places", "=", "7", ")", ":", "def", "equalalphanumeric", "(", "bch", ",", "fieldname", ",", "value", ")", ":", "if", "bch", ".", "get_retaincase", "(", "fieldname", ")", ":", "return",...
return True if the field is equal to value
[ "return", "True", "if", "the", "field", "is", "equal", "to", "value" ]
python
train
symphonyoss/python-symphony
symphony/RESTful/nopkcs.py
https://github.com/symphonyoss/python-symphony/blob/b939f35fbda461183ec0c01790c754f89a295be0/symphony/RESTful/nopkcs.py#L43-L65
def POST_query(self, req_hook, req_args): ''' Generic POST query method ''' # HTTP POST queries require keyManagerTokens and sessionTokens headers = {'Content-Type': 'application/json', 'sessionToken': self.__session__, 'keyManagerToken': self.__keymngr__} ...
[ "def", "POST_query", "(", "self", ",", "req_hook", ",", "req_args", ")", ":", "# HTTP POST queries require keyManagerTokens and sessionTokens", "headers", "=", "{", "'Content-Type'", ":", "'application/json'", ",", "'sessionToken'", ":", "self", ".", "__session__", ",",...
Generic POST query method
[ "Generic", "POST", "query", "method" ]
python
train
Neurita/boyle
boyle/utils/strings.py
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/utils/strings.py#L167-L181
def is_fnmatch_regex(string): """ Returns True if the given string is considered a fnmatch regular expression, False otherwise. It will look for :param string: str """ is_regex = False regex_chars = ['!', '*', '$'] for c in regex_chars: if string.find(c) > -1: r...
[ "def", "is_fnmatch_regex", "(", "string", ")", ":", "is_regex", "=", "False", "regex_chars", "=", "[", "'!'", ",", "'*'", ",", "'$'", "]", "for", "c", "in", "regex_chars", ":", "if", "string", ".", "find", "(", "c", ")", ">", "-", "1", ":", "return...
Returns True if the given string is considered a fnmatch regular expression, False otherwise. It will look for :param string: str
[ "Returns", "True", "if", "the", "given", "string", "is", "considered", "a", "fnmatch", "regular", "expression", "False", "otherwise", ".", "It", "will", "look", "for" ]
python
valid
HydraChain/hydrachain
hydrachain/native_contracts.py
https://github.com/HydraChain/hydrachain/blob/6c0919b0575dc8aa481f3a8c703e1a7f0575ecc3/hydrachain/native_contracts.py#L587-L606
def chain_nac_proxy(chain, sender, contract_address, value=0): "create an object which acts as a proxy for the contract on the chain" klass = registry[contract_address].im_self assert issubclass(klass, NativeABIContract) def mk_method(method): def m(s, *args): data = abi_encode_args...
[ "def", "chain_nac_proxy", "(", "chain", ",", "sender", ",", "contract_address", ",", "value", "=", "0", ")", ":", "klass", "=", "registry", "[", "contract_address", "]", ".", "im_self", "assert", "issubclass", "(", "klass", ",", "NativeABIContract", ")", "de...
create an object which acts as a proxy for the contract on the chain
[ "create", "an", "object", "which", "acts", "as", "a", "proxy", "for", "the", "contract", "on", "the", "chain" ]
python
test
ssato/python-anyconfig
src/anyconfig/backend/xml.py
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/xml.py#L160-L174
def _merge_dicts(dics, container=dict): """ :param dics: [<dict/-like object must not have same keys each other>] :param container: callble to make a container object :return: <container> object >>> _merge_dicts(({}, )) {} >>> _merge_dicts(({'a': 1}, )) {'a': 1} >>> sorted(kv for kv...
[ "def", "_merge_dicts", "(", "dics", ",", "container", "=", "dict", ")", ":", "dic_itr", "=", "anyconfig", ".", "compat", ".", "from_iterable", "(", "d", ".", "items", "(", ")", "for", "d", "in", "dics", ")", "return", "container", "(", "anyconfig", "."...
:param dics: [<dict/-like object must not have same keys each other>] :param container: callble to make a container object :return: <container> object >>> _merge_dicts(({}, )) {} >>> _merge_dicts(({'a': 1}, )) {'a': 1} >>> sorted(kv for kv in _merge_dicts(({'a': 1}, {'b': 2})).items()) ...
[ ":", "param", "dics", ":", "[", "<dict", "/", "-", "like", "object", "must", "not", "have", "same", "keys", "each", "other", ">", "]", ":", "param", "container", ":", "callble", "to", "make", "a", "container", "object", ":", "return", ":", "<container"...
python
train
matiasb/demiurge
demiurge/demiurge.py
https://github.com/matiasb/demiurge/blob/4cfbb24f0519ab99b9bf36fa4c20283ae6e7b9fe/demiurge/demiurge.py#L250-L254
def all(cls, path=''): """Return all ocurrences of the item.""" url = urljoin(cls._meta.base_url, path) pq_items = cls._get_items(url=url, **cls._meta._pyquery_kwargs) return [cls(item=i) for i in pq_items.items()]
[ "def", "all", "(", "cls", ",", "path", "=", "''", ")", ":", "url", "=", "urljoin", "(", "cls", ".", "_meta", ".", "base_url", ",", "path", ")", "pq_items", "=", "cls", ".", "_get_items", "(", "url", "=", "url", ",", "*", "*", "cls", ".", "_meta...
Return all ocurrences of the item.
[ "Return", "all", "ocurrences", "of", "the", "item", "." ]
python
train
crdoconnor/strictyaml
strictyaml/representation.py
https://github.com/crdoconnor/strictyaml/blob/efdac7f89e81679fc95686288cd32b9563fde609/strictyaml/representation.py#L240-L245
def as_yaml(self): """ Render the YAML node and subnodes as string. """ dumped = dump(self.as_marked_up(), Dumper=StrictYAMLDumper, allow_unicode=True) return dumped if sys.version_info[0] == 3 else dumped.decode("utf8")
[ "def", "as_yaml", "(", "self", ")", ":", "dumped", "=", "dump", "(", "self", ".", "as_marked_up", "(", ")", ",", "Dumper", "=", "StrictYAMLDumper", ",", "allow_unicode", "=", "True", ")", "return", "dumped", "if", "sys", ".", "version_info", "[", "0", ...
Render the YAML node and subnodes as string.
[ "Render", "the", "YAML", "node", "and", "subnodes", "as", "string", "." ]
python
train
tensorflow/cleverhans
examples/nips17_adversarial_competition/eval_infra/code/eval_lib/classification_results.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/nips17_adversarial_competition/eval_infra/code/eval_lib/classification_results.py#L192-L215
def save_to_file(self, filename, remap_dim0=None, remap_dim1=None): """Saves matrix to the file. Args: filename: name of the file where to save matrix remap_dim0: dictionary with mapping row indices to row names which should be saved to file. If none then indices will be used as names. ...
[ "def", "save_to_file", "(", "self", ",", "filename", ",", "remap_dim0", "=", "None", ",", "remap_dim1", "=", "None", ")", ":", "# rows - first index", "# columns - second index", "with", "open", "(", "filename", ",", "'w'", ")", "as", "fobj", ":", "columns", ...
Saves matrix to the file. Args: filename: name of the file where to save matrix remap_dim0: dictionary with mapping row indices to row names which should be saved to file. If none then indices will be used as names. remap_dim1: dictionary with mapping column indices to column names which ...
[ "Saves", "matrix", "to", "the", "file", "." ]
python
train
anrosent/LT-code
lt/sampler.py
https://github.com/anrosent/LT-code/blob/e13a4c927effc90f9d41ab3884f9fcbd95b9450d/lt/sampler.py#L25-L32
def gen_tau(S, K, delta): """The Robust part of the RSD, we precompute an array for speed """ pivot = floor(K/S) return [S/K * 1/d for d in range(1, pivot)] \ + [S/K * log(S/delta)] \ + [0 for d in range(pivot, K)]
[ "def", "gen_tau", "(", "S", ",", "K", ",", "delta", ")", ":", "pivot", "=", "floor", "(", "K", "/", "S", ")", "return", "[", "S", "/", "K", "*", "1", "/", "d", "for", "d", "in", "range", "(", "1", ",", "pivot", ")", "]", "+", "[", "S", ...
The Robust part of the RSD, we precompute an array for speed
[ "The", "Robust", "part", "of", "the", "RSD", "we", "precompute", "an", "array", "for", "speed" ]
python
train
dswah/pyGAM
pygam/pygam.py
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/pygam.py#L1572-L1661
def summary(self): """produce a summary of the model statistics Parameters ---------- None Returns ------- None """ if not self._is_fitted: raise AttributeError('GAM has not been fitted. Call fit first.') # high-level model s...
[ "def", "summary", "(", "self", ")", ":", "if", "not", "self", ".", "_is_fitted", ":", "raise", "AttributeError", "(", "'GAM has not been fitted. Call fit first.'", ")", "# high-level model summary", "width_details", "=", "47", "width_results", "=", "58", "model_fmt", ...
produce a summary of the model statistics Parameters ---------- None Returns ------- None
[ "produce", "a", "summary", "of", "the", "model", "statistics" ]
python
train
thunder-project/thunder
thunder/readers.py
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L233-L278
def parse_query(query, delim='/'): """ Parse a boto query """ key = '' prefix = '' postfix = '' parsed = urlparse(query) query = parsed.path.lstrip(delim) bucket = parsed.netloc if not parsed.scheme.lower() in ('', "gs", "s3", "s3n"): ...
[ "def", "parse_query", "(", "query", ",", "delim", "=", "'/'", ")", ":", "key", "=", "''", "prefix", "=", "''", "postfix", "=", "''", "parsed", "=", "urlparse", "(", "query", ")", "query", "=", "parsed", ".", "path", ".", "lstrip", "(", "delim", ")"...
Parse a boto query
[ "Parse", "a", "boto", "query" ]
python
train
inonit/drf-haystack
drf_haystack/serializers.py
https://github.com/inonit/drf-haystack/blob/ceabd0f6318f129758341ab08292a20205d6f4cd/drf_haystack/serializers.py#L156-L163
def _get_index_class_name(self, index_cls): """ Converts in index model class to a name suitable for use as a field name prefix. A user may optionally specify custom aliases via an 'index_aliases' attribute on the Meta class """ cls_name = index_cls.__name__ aliases = sel...
[ "def", "_get_index_class_name", "(", "self", ",", "index_cls", ")", ":", "cls_name", "=", "index_cls", ".", "__name__", "aliases", "=", "self", ".", "Meta", ".", "index_aliases", "return", "aliases", ".", "get", "(", "cls_name", ",", "cls_name", ".", "split"...
Converts in index model class to a name suitable for use as a field name prefix. A user may optionally specify custom aliases via an 'index_aliases' attribute on the Meta class
[ "Converts", "in", "index", "model", "class", "to", "a", "name", "suitable", "for", "use", "as", "a", "field", "name", "prefix", ".", "A", "user", "may", "optionally", "specify", "custom", "aliases", "via", "an", "index_aliases", "attribute", "on", "the", "...
python
train
ssato/python-anyconfig
src/anyconfig/processors.py
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L142-L157
def find_by_fileext(fileext, prs): """ :param fileext: File extension :param prs: A list of :class:`anyconfig.models.processor.Processor` classes :return: A list of processor class to processor files with given extension :raises: UnknownFileTypeError """ def pred(pcls): """Predicate"...
[ "def", "find_by_fileext", "(", "fileext", ",", "prs", ")", ":", "def", "pred", "(", "pcls", ")", ":", "\"\"\"Predicate\"\"\"", "return", "fileext", "in", "pcls", ".", "extensions", "(", ")", "pclss", "=", "findall_with_pred", "(", "pred", ",", "prs", ")", ...
:param fileext: File extension :param prs: A list of :class:`anyconfig.models.processor.Processor` classes :return: A list of processor class to processor files with given extension :raises: UnknownFileTypeError
[ ":", "param", "fileext", ":", "File", "extension", ":", "param", "prs", ":", "A", "list", "of", ":", "class", ":", "anyconfig", ".", "models", ".", "processor", ".", "Processor", "classes", ":", "return", ":", "A", "list", "of", "processor", "class", "...
python
train
MoseleyBioinformaticsLab/ctfile
ctfile/ctfile.py
https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L82-L93
def write(self, filehandle, file_format): """Write :class:`~ctfile.ctfile.CTfile` data into file. :param filehandle: File-like object. :param str file_format: Format to use to write data: ``ctfile`` or ``json``. :return: None. :rtype: :py:obj:`None`. """ try: ...
[ "def", "write", "(", "self", ",", "filehandle", ",", "file_format", ")", ":", "try", ":", "filehandle", ".", "write", "(", "self", ".", "writestr", "(", "file_format", "=", "file_format", ")", ")", "except", "IOError", ":", "raise", "IOError", "(", "'\"f...
Write :class:`~ctfile.ctfile.CTfile` data into file. :param filehandle: File-like object. :param str file_format: Format to use to write data: ``ctfile`` or ``json``. :return: None. :rtype: :py:obj:`None`.
[ "Write", ":", "class", ":", "~ctfile", ".", "ctfile", ".", "CTfile", "data", "into", "file", "." ]
python
train
rasbt/biopandas
biopandas/mol2/pandas_mol2.py
https://github.com/rasbt/biopandas/blob/615a7cf272692c12bbcfd9d1f217eab440120235/biopandas/mol2/pandas_mol2.py#L67-L86
def _load_mol2(self, mol2_lines, mol2_code, columns): """Load mol2 contents into assert_raise_message instance""" if columns is None: col_names = COLUMN_NAMES col_types = COLUMN_TYPES else: col_names, col_types = [], [] for i in range(len(columns))...
[ "def", "_load_mol2", "(", "self", ",", "mol2_lines", ",", "mol2_code", ",", "columns", ")", ":", "if", "columns", "is", "None", ":", "col_names", "=", "COLUMN_NAMES", "col_types", "=", "COLUMN_TYPES", "else", ":", "col_names", ",", "col_types", "=", "[", "...
Load mol2 contents into assert_raise_message instance
[ "Load", "mol2", "contents", "into", "assert_raise_message", "instance" ]
python
train
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/base.py
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/base.py#L66-L92
def coerce(val: t.Any, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None) -> t.Any: """ Casts a type of ``val`` to ``coerce_type`` with ``coercer``. If ``coerce_type`` is bool and no ``coercer`` specified it uses :func:`~django_...
[ "def", "coerce", "(", "val", ":", "t", ".", "Any", ",", "coerce_type", ":", "t", ".", "Optional", "[", "t", ".", "Type", "]", "=", "None", ",", "coercer", ":", "t", ".", "Optional", "[", "t", ".", "Callable", "]", "=", "None", ")", "->", "t", ...
Casts a type of ``val`` to ``coerce_type`` with ``coercer``. If ``coerce_type`` is bool and no ``coercer`` specified it uses :func:`~django_docker_helpers.utils.coerce_str_to_bool` by default. :param val: a value of any type :param coerce_type: any type :param coercer: provide ...
[ "Casts", "a", "type", "of", "val", "to", "coerce_type", "with", "coercer", "." ]
python
train
neighbordog/deviantart
deviantart/api.py
https://github.com/neighbordog/deviantart/blob/5612f1d5e2139a48c9d793d7fd19cde7e162d7b1/deviantart/api.py#L1590-L1620
def send_note(self, to, subject="", body="", noetid=""): """Send a note :param to: The username(s) that this note is to :param subject: The subject of the note :param body: The body of the note :param noetid: The UUID of the note that is being responded to """ ...
[ "def", "send_note", "(", "self", ",", "to", ",", "subject", "=", "\"\"", ",", "body", "=", "\"\"", ",", "noetid", "=", "\"\"", ")", ":", "if", "self", ".", "standard_grant_type", "is", "not", "\"authorization_code\"", ":", "raise", "DeviantartError", "(", ...
Send a note :param to: The username(s) that this note is to :param subject: The subject of the note :param body: The body of the note :param noetid: The UUID of the note that is being responded to
[ "Send", "a", "note" ]
python
train
lcharleux/argiope
argiope/utils.py
https://github.com/lcharleux/argiope/blob/8170e431362dc760589f7d141090fd133dece259/argiope/utils.py#L52-L66
def list_to_string(l = range(200), width = 40, indent = " "): """ Converts a list-like to string with given line width. """ l = [str(v) + "," for v in l] counter = 0 out = "" + indent for w in l: s = len(w) if counter + s > width: out += "\n" + indent ...
[ "def", "list_to_string", "(", "l", "=", "range", "(", "200", ")", ",", "width", "=", "40", ",", "indent", "=", "\" \"", ")", ":", "l", "=", "[", "str", "(", "v", ")", "+", "\",\"", "for", "v", "in", "l", "]", "counter", "=", "0", "out", "=",...
Converts a list-like to string with given line width.
[ "Converts", "a", "list", "-", "like", "to", "string", "with", "given", "line", "width", "." ]
python
test
FNNDSC/med2image
med2image/systemMisc.py
https://github.com/FNNDSC/med2image/blob/638d5d230de47608af20f9764acf8e382c2bf2ff/med2image/systemMisc.py#L1199-L1214
def str2lst(astr_input, astr_separator=" "): """ Breaks a string at <astr_separator> and joins into a list. Steps along all list elements and strips white space. The list elements are explicitly ascii encoded. """ alistI = astr_input.split(astr_separator) alistJ = [] for i in range(0, len(alistI)): ...
[ "def", "str2lst", "(", "astr_input", ",", "astr_separator", "=", "\" \"", ")", ":", "alistI", "=", "astr_input", ".", "split", "(", "astr_separator", ")", "alistJ", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "alistI", ")", "...
Breaks a string at <astr_separator> and joins into a list. Steps along all list elements and strips white space. The list elements are explicitly ascii encoded.
[ "Breaks", "a", "string", "at", "<astr_separator", ">", "and", "joins", "into", "a", "list", ".", "Steps", "along", "all", "list", "elements", "and", "strips", "white", "space", "." ]
python
train
secdev/scapy
scapy/automaton.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L96-L102
def wait_return(self, callback): """Entry point of SelectableObject: register the callback""" if self.check_recv(): return callback(self) _t = threading.Thread(target=self._wait_non_ressources, args=(callback,)) # noqa: E501 _t.setDaemon(True) _t.start()
[ "def", "wait_return", "(", "self", ",", "callback", ")", ":", "if", "self", ".", "check_recv", "(", ")", ":", "return", "callback", "(", "self", ")", "_t", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_wait_non_ressources", ",", "...
Entry point of SelectableObject: register the callback
[ "Entry", "point", "of", "SelectableObject", ":", "register", "the", "callback" ]
python
train
chrisspen/weka
weka/arff.py
https://github.com/chrisspen/weka/blob/c86fc4b8eef1afd56f89ec28283bdf9e2fdc453b/weka/arff.py#L404-L422
def open_stream(self, class_attr_name=None, fn=None): """ Save an arff structure to a file, leaving the file object open for writing of new data samples. This prevents you from directly accessing the data via Python, but when generating a huge file, this prevents all your data ...
[ "def", "open_stream", "(", "self", ",", "class_attr_name", "=", "None", ",", "fn", "=", "None", ")", ":", "if", "fn", ":", "self", ".", "fout_fn", "=", "fn", "else", ":", "fd", ",", "self", ".", "fout_fn", "=", "tempfile", ".", "mkstemp", "(", ")",...
Save an arff structure to a file, leaving the file object open for writing of new data samples. This prevents you from directly accessing the data via Python, but when generating a huge file, this prevents all your data from being stored in memory.
[ "Save", "an", "arff", "structure", "to", "a", "file", "leaving", "the", "file", "object", "open", "for", "writing", "of", "new", "data", "samples", ".", "This", "prevents", "you", "from", "directly", "accessing", "the", "data", "via", "Python", "but", "whe...
python
train
wohlgejm/accountable
accountable/cli.py
https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L181-L188
def checkout(accountable, issue_key): """ Checkout a new branch or checkout to a branch for a given issue. """ issue = accountable.checkout(issue_key) headers = issue.keys() rows = [headers, [v for k, v in issue.items()]] print_table(SingleTable(rows))
[ "def", "checkout", "(", "accountable", ",", "issue_key", ")", ":", "issue", "=", "accountable", ".", "checkout", "(", "issue_key", ")", "headers", "=", "issue", ".", "keys", "(", ")", "rows", "=", "[", "headers", ",", "[", "v", "for", "k", ",", "v", ...
Checkout a new branch or checkout to a branch for a given issue.
[ "Checkout", "a", "new", "branch", "or", "checkout", "to", "a", "branch", "for", "a", "given", "issue", "." ]
python
train
nefarioustim/parker
parker/redisset.py
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/redisset.py#L51-L61
def add(self, value): """Add value to set.""" added = self.redis.sadd( self.key, value ) if self.redis.scard(self.key) < 2: self.redis.expire(self.key, self.expire) return added
[ "def", "add", "(", "self", ",", "value", ")", ":", "added", "=", "self", ".", "redis", ".", "sadd", "(", "self", ".", "key", ",", "value", ")", "if", "self", ".", "redis", ".", "scard", "(", "self", ".", "key", ")", "<", "2", ":", "self", "."...
Add value to set.
[ "Add", "value", "to", "set", "." ]
python
train
ageitgey/face_recognition
examples/face_recognition_knn.py
https://github.com/ageitgey/face_recognition/blob/c96b010c02f15e8eeb0f71308c641179ac1f19bb/examples/face_recognition_knn.py#L111-L150
def predict(X_img_path, knn_clf=None, model_path=None, distance_threshold=0.6): """ Recognizes faces in given image using a trained KNN classifier :param X_img_path: path to image to be recognized :param knn_clf: (optional) a knn classifier object. if not specified, model_save_path must be specified. ...
[ "def", "predict", "(", "X_img_path", ",", "knn_clf", "=", "None", ",", "model_path", "=", "None", ",", "distance_threshold", "=", "0.6", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "X_img_path", ")", "or", "os", ".", "path", ".", "s...
Recognizes faces in given image using a trained KNN classifier :param X_img_path: path to image to be recognized :param knn_clf: (optional) a knn classifier object. if not specified, model_save_path must be specified. :param model_path: (optional) path to a pickled knn classifier. if not specified, model_s...
[ "Recognizes", "faces", "in", "given", "image", "using", "a", "trained", "KNN", "classifier" ]
python
train
tanghaibao/jcvi
jcvi/utils/orderedcollections.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/utils/orderedcollections.py#L184-L197
def parse_qs(qs, keep_blank_values=0, strict_parsing=0, keep_attr_order=True): """ Kind of like urlparse.parse_qs, except returns an ordered dict. Also avoids replicating that function's bad habit of overriding the built-in 'dict' type. Taken from below with modification: <https://bitbucket.org...
[ "def", "parse_qs", "(", "qs", ",", "keep_blank_values", "=", "0", ",", "strict_parsing", "=", "0", ",", "keep_attr_order", "=", "True", ")", ":", "od", "=", "DefaultOrderedDict", "(", "list", ")", "if", "keep_attr_order", "else", "defaultdict", "(", "list", ...
Kind of like urlparse.parse_qs, except returns an ordered dict. Also avoids replicating that function's bad habit of overriding the built-in 'dict' type. Taken from below with modification: <https://bitbucket.org/btubbs/thumpy/raw/8cdece404f15/thumpy.py>
[ "Kind", "of", "like", "urlparse", ".", "parse_qs", "except", "returns", "an", "ordered", "dict", ".", "Also", "avoids", "replicating", "that", "function", "s", "bad", "habit", "of", "overriding", "the", "built", "-", "in", "dict", "type", "." ]
python
train
openclimatedata/pyhector
pyhector/__init__.py
https://github.com/openclimatedata/pyhector/blob/1649efcc0ed19dc66d8de8dec7a5105fa08df01a/pyhector/__init__.py#L47-L78
def set_value(self, section, variable, value): """ Set config input value directly, see :mod:`pyhector.emissions` for possible values. Parameters ---------- section : str Component in Hector config. variable : str Name of emissions variabl...
[ "def", "set_value", "(", "self", ",", "section", ",", "variable", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "pd", ".", "Series", ")", ":", "# values with time as Series", "values", "=", "list", "(", "zip", "(", "value", ".", "index",...
Set config input value directly, see :mod:`pyhector.emissions` for possible values. Parameters ---------- section : str Component in Hector config. variable : str Name of emissions variable. value : pandas.Series, list, tuple, float, or str ...
[ "Set", "config", "input", "value", "directly", "see", ":", "mod", ":", "pyhector", ".", "emissions", "for", "possible", "values", "." ]
python
train
pyrogram/pyrogram
pyrogram/client/methods/messages/send_message.py
https://github.com/pyrogram/pyrogram/blob/e7258a341ba905cfa86264c22040654db732ec1c/pyrogram/client/methods/messages/send_message.py#L27-L123
def send_message( self, chat_id: Union[int, str], text: str, parse_mode: str = "", disable_web_page_preview: bool = None, disable_notification: bool = None, reply_to_message_id: int = None, reply_markup: Union[ "pyrogram.InlineKeyboardMarkup", ...
[ "def", "send_message", "(", "self", ",", "chat_id", ":", "Union", "[", "int", ",", "str", "]", ",", "text", ":", "str", ",", "parse_mode", ":", "str", "=", "\"\"", ",", "disable_web_page_preview", ":", "bool", "=", "None", ",", "disable_notification", ":...
Use this method to send text messages. Args: chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of the target chat. For your personal cloud (Saved Messages) you can simply use "me" or "self". For a contact that exists in your Teleg...
[ "Use", "this", "method", "to", "send", "text", "messages", "." ]
python
train
Fizzadar/pyinfra
pyinfra/modules/apt.py
https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/modules/apt.py#L230-L279
def packages( state, host, packages=None, present=True, latest=False, update=False, cache_time=None, upgrade=False, force=False, no_recommends=False, allow_downgrades=False, ): ''' Install/remove/update packages & update apt. + packages: list of packages to ensure + present: whether...
[ "def", "packages", "(", "state", ",", "host", ",", "packages", "=", "None", ",", "present", "=", "True", ",", "latest", "=", "False", ",", "update", "=", "False", ",", "cache_time", "=", "None", ",", "upgrade", "=", "False", ",", "force", "=", "False...
Install/remove/update packages & update apt. + packages: list of packages to ensure + present: whether the packages should be installed + latest: whether to upgrade packages without a specified version + update: run apt update + cache_time: when used with update, cache for this many seconds + u...
[ "Install", "/", "remove", "/", "update", "packages", "&", "update", "apt", "." ]
python
train