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
kejbaly2/metrique
metrique/sqlalchemy.py
https://github.com/kejbaly2/metrique/blob/a10b076097441b7dde687949139f702f5c1e1b35/metrique/sqlalchemy.py#L877-L888
def ls(self, startswith=None): ''' List all cubes available to the calling client. :param startswith: string to use in a simple "startswith" query filter :returns list: sorted list of cube names ''' logger.info('Listing cubes starting with "%s")' % startswith) st...
[ "def", "ls", "(", "self", ",", "startswith", "=", "None", ")", ":", "logger", ".", "info", "(", "'Listing cubes starting with \"%s\")'", "%", "startswith", ")", "startswith", "=", "unicode", "(", "startswith", "or", "''", ")", "tables", "=", "sorted", "(", ...
List all cubes available to the calling client. :param startswith: string to use in a simple "startswith" query filter :returns list: sorted list of cube names
[ "List", "all", "cubes", "available", "to", "the", "calling", "client", "." ]
python
train
gmr/tinman
tinman/handlers/base.py
https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L145-L170
def write(self, chunk): """Writes the given chunk to the output buffer. Checks for curl in the user-agent and if set, provides indented output if returning JSON. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON an...
[ "def", "write", "(", "self", ",", "chunk", ")", ":", "if", "self", ".", "_finished", ":", "raise", "RuntimeError", "(", "\"Cannot write() after finish(). May be caused \"", "\"by using async operations without the \"", "\"@asynchronous decorator.\"", ")", "if", "isinstance...
Writes the given chunk to the output buffer. Checks for curl in the user-agent and if set, provides indented output if returning JSON. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of t...
[ "Writes", "the", "given", "chunk", "to", "the", "output", "buffer", ".", "Checks", "for", "curl", "in", "the", "user", "-", "agent", "and", "if", "set", "provides", "indented", "output", "if", "returning", "JSON", "." ]
python
train
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulated_tile.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulated_tile.py#L359-L374
async def reset(self): """Synchronously reset a tile. This method must be called from the emulation loop and will synchronously shut down all background tasks running this tile, clear it to reset state and then restart the initialization background task. """ await self....
[ "async", "def", "reset", "(", "self", ")", ":", "await", "self", ".", "_device", ".", "emulator", ".", "stop_tasks", "(", "self", ".", "address", ")", "self", ".", "_handle_reset", "(", ")", "self", ".", "_logger", ".", "info", "(", "\"Tile at address %d...
Synchronously reset a tile. This method must be called from the emulation loop and will synchronously shut down all background tasks running this tile, clear it to reset state and then restart the initialization background task.
[ "Synchronously", "reset", "a", "tile", "." ]
python
train
drongo-framework/drongo
drongo/utils/dict2.py
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/utils/dict2.py#L77-L100
def to_dict(self, val=UNSET): """Creates dict object from dict2 object Args: val (:obj:`dict2`): Value to create from Returns: Equivalent dict object. """ if val is UNSET: val = self if isinstance(val, dict2) or isinstance(val, dict)...
[ "def", "to_dict", "(", "self", ",", "val", "=", "UNSET", ")", ":", "if", "val", "is", "UNSET", ":", "val", "=", "self", "if", "isinstance", "(", "val", ",", "dict2", ")", "or", "isinstance", "(", "val", ",", "dict", ")", ":", "res", "=", "dict", ...
Creates dict object from dict2 object Args: val (:obj:`dict2`): Value to create from Returns: Equivalent dict object.
[ "Creates", "dict", "object", "from", "dict2", "object" ]
python
train
RiotGames/cloud-inquisitor
backend/cloud_inquisitor/plugins/views/config.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/backend/cloud_inquisitor/plugins/views/config.py#L77-L95
def post(self): """Create a new config item""" self.reqparse.add_argument('namespacePrefix', type=str, required=True) self.reqparse.add_argument('description', type=str, required=True) self.reqparse.add_argument('key', type=str, required=True) self.reqparse.add_argument('value', ...
[ "def", "post", "(", "self", ")", ":", "self", ".", "reqparse", ".", "add_argument", "(", "'namespacePrefix'", ",", "type", "=", "str", ",", "required", "=", "True", ")", "self", ".", "reqparse", ".", "add_argument", "(", "'description'", ",", "type", "="...
Create a new config item
[ "Create", "a", "new", "config", "item" ]
python
train
secdev/scapy
scapy/arch/unix.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L149-L181
def _in6_getifaddr(ifname): """ Returns a list of IPv6 addresses configured on the interface ifname. """ # Get the output of ifconfig try: f = os.popen("%s %s" % (conf.prog.ifconfig, ifname)) except OSError: log_interactive.warning("Failed to execute ifconfig.") return [...
[ "def", "_in6_getifaddr", "(", "ifname", ")", ":", "# Get the output of ifconfig", "try", ":", "f", "=", "os", ".", "popen", "(", "\"%s %s\"", "%", "(", "conf", ".", "prog", ".", "ifconfig", ",", "ifname", ")", ")", "except", "OSError", ":", "log_interactiv...
Returns a list of IPv6 addresses configured on the interface ifname.
[ "Returns", "a", "list", "of", "IPv6", "addresses", "configured", "on", "the", "interface", "ifname", "." ]
python
train
PmagPy/PmagPy
programs/conversion_scripts2/iodp_dscr_magic2.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/conversion_scripts2/iodp_dscr_magic2.py#L9-L197
def main(command_line=True, **kwargs): """ NAME iodp_dscr_magic.py DESCRIPTION converts ODP LIMS discrete sample format files to magic_measurements format files SYNTAX iodp_descr_magic.py [command line options] OPTIONS -h: prints the help message and quits. ...
[ "def", "main", "(", "command_line", "=", "True", ",", "*", "*", "kwargs", ")", ":", "#", "# initialize defaults", "version_num", "=", "pmag", ".", "get_version", "(", ")", "meas_file", "=", "'magic_measurements.txt'", "csv_file", "=", "''", "MagRecs", ",", "...
NAME iodp_dscr_magic.py DESCRIPTION converts ODP LIMS discrete sample format files to magic_measurements format files SYNTAX iodp_descr_magic.py [command line options] OPTIONS -h: prints the help message and quits. -f FILE: specify input .csv file, default is all ...
[ "NAME", "iodp_dscr_magic", ".", "py" ]
python
train
AlecAivazis/graphql-over-kafka
nautilus/api/util/graph_entity.py
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/api/util/graph_entity.py#L102-L122
async def _has_id(self, *args, **kwds): """ Equality checks are overwitten to perform the actual check in a semantic way. """ # if there is only one positional argument if len(args) == 1: # parse the appropriate query result = await parse_s...
[ "async", "def", "_has_id", "(", "self", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "# if there is only one positional argument", "if", "len", "(", "args", ")", "==", "1", ":", "# parse the appropriate query", "result", "=", "await", "parse_string", "("...
Equality checks are overwitten to perform the actual check in a semantic way.
[ "Equality", "checks", "are", "overwitten", "to", "perform", "the", "actual", "check", "in", "a", "semantic", "way", "." ]
python
train
rcbops/flake8-filename
flake8_filename/rules.py
https://github.com/rcbops/flake8-filename/blob/5718d4af394c318d376de7434193543e0da45651/flake8_filename/rules.py#L7-L18
def _generate_mark_code(rule_name): """Generates a two digit string based on a provided string Args: rule_name (str): A configured rule name 'pytest_mark3'. Returns: str: A two digit code based on the provided string '03' """ code = ''.join([i for i in str(rule_name) if i.isdigit()...
[ "def", "_generate_mark_code", "(", "rule_name", ")", ":", "code", "=", "''", ".", "join", "(", "[", "i", "for", "i", "in", "str", "(", "rule_name", ")", "if", "i", ".", "isdigit", "(", ")", "]", ")", "code", "=", "code", ".", "zfill", "(", "2", ...
Generates a two digit string based on a provided string Args: rule_name (str): A configured rule name 'pytest_mark3'. Returns: str: A two digit code based on the provided string '03'
[ "Generates", "a", "two", "digit", "string", "based", "on", "a", "provided", "string" ]
python
train
odlgroup/odl
odl/operator/default_ops.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/operator/default_ops.py#L856-L872
def derivative(self, point): """Derivative of this operator, always zero. Returns ------- derivative : `ZeroOperator` Examples -------- >>> r3 = odl.rn(3) >>> x = r3.element([1, 2, 3]) >>> op = ConstantOperator(x) >>> deriv = op.derivativ...
[ "def", "derivative", "(", "self", ",", "point", ")", ":", "return", "ZeroOperator", "(", "domain", "=", "self", ".", "domain", ",", "range", "=", "self", ".", "range", ")" ]
Derivative of this operator, always zero. Returns ------- derivative : `ZeroOperator` Examples -------- >>> r3 = odl.rn(3) >>> x = r3.element([1, 2, 3]) >>> op = ConstantOperator(x) >>> deriv = op.derivative([1, 1, 1]) >>> deriv([2, 2, 2]...
[ "Derivative", "of", "this", "operator", "always", "zero", "." ]
python
train
jd/tenacity
tenacity/compat.py
https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L120-L136
def stop_func_accept_retry_state(stop_func): """Wrap "stop" function to accept "retry_state" parameter.""" if not six.callable(stop_func): return stop_func if func_takes_retry_state(stop_func): return stop_func @_utils.wraps(stop_func) def wrapped_stop_func(retry_state): wa...
[ "def", "stop_func_accept_retry_state", "(", "stop_func", ")", ":", "if", "not", "six", ".", "callable", "(", "stop_func", ")", ":", "return", "stop_func", "if", "func_takes_retry_state", "(", "stop_func", ")", ":", "return", "stop_func", "@", "_utils", ".", "w...
Wrap "stop" function to accept "retry_state" parameter.
[ "Wrap", "stop", "function", "to", "accept", "retry_state", "parameter", "." ]
python
train
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1865-L1868
def p_instance_port_arg(self, p): 'instance_port_arg : DOT ID LPAREN identifier RPAREN' p[0] = PortArg(p[2], p[4], lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_instance_port_arg", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "PortArg", "(", "p", "[", "2", "]", ",", "p", "[", "4", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", "p", ".", "set_lineno", "(", "0...
instance_port_arg : DOT ID LPAREN identifier RPAREN
[ "instance_port_arg", ":", "DOT", "ID", "LPAREN", "identifier", "RPAREN" ]
python
train
blockstack/blockstack-core
api/search/substring_search.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/search/substring_search.py#L79-L105
def substring_search(query, list_of_strings, limit_results=DEFAULT_LIMIT): """ main function to call for searching """ matching = [] query_words = query.split(' ') # sort by longest word (higest probability of not finding a match) query_words.sort(key=len, reverse=True) counter = 0 ...
[ "def", "substring_search", "(", "query", ",", "list_of_strings", ",", "limit_results", "=", "DEFAULT_LIMIT", ")", ":", "matching", "=", "[", "]", "query_words", "=", "query", ".", "split", "(", "' '", ")", "# sort by longest word (higest probability of not finding a m...
main function to call for searching
[ "main", "function", "to", "call", "for", "searching" ]
python
train
pandas-dev/pandas
pandas/util/_validators.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/util/_validators.py#L325-L358
def validate_fillna_kwargs(value, method, validate_scalar_dict_value=True): """Validate the keyword arguments to 'fillna'. This checks that exactly one of 'value' and 'method' is specified. If 'method' is specified, this validates that it's a valid method. Parameters ---------- value, method :...
[ "def", "validate_fillna_kwargs", "(", "value", ",", "method", ",", "validate_scalar_dict_value", "=", "True", ")", ":", "from", "pandas", ".", "core", ".", "missing", "import", "clean_fill_method", "if", "value", "is", "None", "and", "method", "is", "None", ":...
Validate the keyword arguments to 'fillna'. This checks that exactly one of 'value' and 'method' is specified. If 'method' is specified, this validates that it's a valid method. Parameters ---------- value, method : object The 'value' and 'method' keyword arguments for 'fillna'. valida...
[ "Validate", "the", "keyword", "arguments", "to", "fillna", "." ]
python
train
scanny/python-pptx
spec/gen_spec/gen_spec.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/spec/gen_spec/gen_spec.py#L205-L209
def print_mso_auto_shape_type_constants(): """print symbolic constant definitions for msoAutoShapeType""" auto_shape_types = MsoAutoShapeTypeCollection.load(sort='const_name') out = render_mso_auto_shape_type_constants(auto_shape_types) print out
[ "def", "print_mso_auto_shape_type_constants", "(", ")", ":", "auto_shape_types", "=", "MsoAutoShapeTypeCollection", ".", "load", "(", "sort", "=", "'const_name'", ")", "out", "=", "render_mso_auto_shape_type_constants", "(", "auto_shape_types", ")", "print", "out" ]
print symbolic constant definitions for msoAutoShapeType
[ "print", "symbolic", "constant", "definitions", "for", "msoAutoShapeType" ]
python
train
alephdata/memorious
memorious/logic/check.py
https://github.com/alephdata/memorious/blob/b4033c5064447ed5f696f9c2bbbc6c12062d2fa4/memorious/logic/check.py#L68-L73
def must_contain(self, value, q, strict=False): """if value must contain q""" if value is not None: if value.find(q) != -1: return self.shout('Value %r does not contain %r', strict, value, q)
[ "def", "must_contain", "(", "self", ",", "value", ",", "q", ",", "strict", "=", "False", ")", ":", "if", "value", "is", "not", "None", ":", "if", "value", ".", "find", "(", "q", ")", "!=", "-", "1", ":", "return", "self", ".", "shout", "(", "'V...
if value must contain q
[ "if", "value", "must", "contain", "q" ]
python
train
jobovy/galpy
galpy/potential/CosmphiDiskPotential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/CosmphiDiskPotential.py#L151-L170
def _phiforce(self,R,phi=0.,t=0.): """ NAME: _phiforce PURPOSE: evaluate the azimuthal force for this potential INPUT: R - Galactocentric cylindrical radius phi - azimuth t - time OUTPUT: the azimuthal force ...
[ "def", "_phiforce", "(", "self", ",", "R", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "if", "R", "<", "self", ".", "_rb", ":", "return", "self", ".", "_mphio", "*", "math", ".", "sin", "(", "self", ".", "_m", "*", "phi", "-", "se...
NAME: _phiforce PURPOSE: evaluate the azimuthal force for this potential INPUT: R - Galactocentric cylindrical radius phi - azimuth t - time OUTPUT: the azimuthal force HISTORY: 2011-10-19 - Written - Bovy (IAS)
[ "NAME", ":", "_phiforce", "PURPOSE", ":", "evaluate", "the", "azimuthal", "force", "for", "this", "potential", "INPUT", ":", "R", "-", "Galactocentric", "cylindrical", "radius", "phi", "-", "azimuth", "t", "-", "time", "OUTPUT", ":", "the", "azimuthal", "for...
python
train
PetrochukM/PyTorch-NLP
torchnlp/metrics/accuracy.py
https://github.com/PetrochukM/PyTorch-NLP/blob/5f7320da5c8d781df072fab3f7e421c6347e5bfa/torchnlp/metrics/accuracy.py#L53-L102
def get_token_accuracy(targets, outputs, ignore_index=None): """ Get the accuracy token accuracy between two tensors. Args: targets (1 - 2D :class:`torch.Tensor`): Target or true vector against which to measure saccuracy outputs (1 - 3D :class:`torch.Tensor`): Prediction or output vector ...
[ "def", "get_token_accuracy", "(", "targets", ",", "outputs", ",", "ignore_index", "=", "None", ")", ":", "n_correct", "=", "0.0", "n_total", "=", "0.0", "for", "target", ",", "output", "in", "zip", "(", "targets", ",", "outputs", ")", ":", "if", "not", ...
Get the accuracy token accuracy between two tensors. Args: targets (1 - 2D :class:`torch.Tensor`): Target or true vector against which to measure saccuracy outputs (1 - 3D :class:`torch.Tensor`): Prediction or output vector ignore_index (int, optional): Specifies a target index that is ...
[ "Get", "the", "accuracy", "token", "accuracy", "between", "two", "tensors", "." ]
python
train
cocoakekeyu/cancan
cancan/rule.py
https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/rule.py#L42-L46
def is_relevant(self, action, subject): """ Matches both the subject and action, not necessarily the conditions. """ return self.matches_action(action) and self.matches_subject(subject)
[ "def", "is_relevant", "(", "self", ",", "action", ",", "subject", ")", ":", "return", "self", ".", "matches_action", "(", "action", ")", "and", "self", ".", "matches_subject", "(", "subject", ")" ]
Matches both the subject and action, not necessarily the conditions.
[ "Matches", "both", "the", "subject", "and", "action", "not", "necessarily", "the", "conditions", "." ]
python
train
consbio/ncdjango
ncdjango/interfaces/arcgis/views.py
https://github.com/consbio/ncdjango/blob/f807bfd1e4083ab29fbc3c4d4418be108383a710/ncdjango/interfaces/arcgis/views.py#L303-L315
def _get_form_defaults(self): """Returns default values for the identify form""" return { 'response_format': 'html', 'geometry_type': 'esriGeometryPoint', 'projection': pyproj.Proj(str(self.service.projection)), 'return_geometry': True, 'maxim...
[ "def", "_get_form_defaults", "(", "self", ")", ":", "return", "{", "'response_format'", ":", "'html'", ",", "'geometry_type'", ":", "'esriGeometryPoint'", ",", "'projection'", ":", "pyproj", ".", "Proj", "(", "str", "(", "self", ".", "service", ".", "projectio...
Returns default values for the identify form
[ "Returns", "default", "values", "for", "the", "identify", "form" ]
python
train
Jaymon/prom
prom/cli/dump.py
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/dump.py#L81-L96
def get_orm_classes(path): """this will return prom.Orm classes found in the given path (classpath or modulepath)""" ret = set() try: m = importlib.import_module(path) except ImportError: # we have a classpath m, klass = get_objects(path) if issubclass(klass, Orm): ...
[ "def", "get_orm_classes", "(", "path", ")", ":", "ret", "=", "set", "(", ")", "try", ":", "m", "=", "importlib", ".", "import_module", "(", "path", ")", "except", "ImportError", ":", "# we have a classpath", "m", ",", "klass", "=", "get_objects", "(", "p...
this will return prom.Orm classes found in the given path (classpath or modulepath)
[ "this", "will", "return", "prom", ".", "Orm", "classes", "found", "in", "the", "given", "path", "(", "classpath", "or", "modulepath", ")" ]
python
train
amcat/amcatclient
demo_wikinews_scraper.py
https://github.com/amcat/amcatclient/blob/bda525f7ace0c26a09fa56d2baf7550f639e62ee/demo_wikinews_scraper.py#L118-L133
def scrape_wikinews(conn, project, articleset, query): """ Scrape wikinews articles from the given query @param conn: The AmcatAPI object @param articleset: The target articleset ID @param category: The wikinews category name """ url = "http://en.wikinews.org/w/index.php?search={}&limit=50"....
[ "def", "scrape_wikinews", "(", "conn", ",", "project", ",", "articleset", ",", "query", ")", ":", "url", "=", "\"http://en.wikinews.org/w/index.php?search={}&limit=50\"", ".", "format", "(", "query", ")", "logging", ".", "info", "(", "url", ")", "for", "page", ...
Scrape wikinews articles from the given query @param conn: The AmcatAPI object @param articleset: The target articleset ID @param category: The wikinews category name
[ "Scrape", "wikinews", "articles", "from", "the", "given", "query" ]
python
train
wummel/linkchecker
linkcheck/containers.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/containers.py#L106-L113
def get_true (self, key, default): """Return default element if key is not in the dict, or if self[key] evaluates to False. Useful for example if value is None, but default value should be an empty string. """ if key not in self or not self[key]: return default ...
[ "def", "get_true", "(", "self", ",", "key", ",", "default", ")", ":", "if", "key", "not", "in", "self", "or", "not", "self", "[", "key", "]", ":", "return", "default", "return", "self", "[", "key", "]" ]
Return default element if key is not in the dict, or if self[key] evaluates to False. Useful for example if value is None, but default value should be an empty string.
[ "Return", "default", "element", "if", "key", "is", "not", "in", "the", "dict", "or", "if", "self", "[", "key", "]", "evaluates", "to", "False", ".", "Useful", "for", "example", "if", "value", "is", "None", "but", "default", "value", "should", "be", "an...
python
train
pyparsing/pyparsing
examples/pymicko.py
https://github.com/pyparsing/pyparsing/blob/f0264bd8d1a548a50b3e5f7d99cfefd577942d14/examples/pymicko.py#L992-L999
def function_body_action(self, text, loc, fun): """Code executed after recognising the beginning of function's body""" exshared.setpos(loc, text) if DEBUG > 0: print("FUN_BODY:",fun) if DEBUG == 2: self.symtab.display() if DEBUG > 2: return self...
[ "def", "function_body_action", "(", "self", ",", "text", ",", "loc", ",", "fun", ")", ":", "exshared", ".", "setpos", "(", "loc", ",", "text", ")", "if", "DEBUG", ">", "0", ":", "print", "(", "\"FUN_BODY:\"", ",", "fun", ")", "if", "DEBUG", "==", "...
Code executed after recognising the beginning of function's body
[ "Code", "executed", "after", "recognising", "the", "beginning", "of", "function", "s", "body" ]
python
train
hayd/ctox
ctox/subst.py
https://github.com/hayd/ctox/blob/6f032488ad67170d57d025a830d7b967075b0d7f/ctox/subst.py#L33-L44
def expand_curlys(s): """Takes string and returns list of options: Example ------- >>> expand_curlys("py{26, 27}") ["py26", "py27"] """ from functools import reduce curleys = list(re.finditer(r"{[^{}]*}", s)) return reduce(_replace_curly, reversed(curleys), [s])
[ "def", "expand_curlys", "(", "s", ")", ":", "from", "functools", "import", "reduce", "curleys", "=", "list", "(", "re", ".", "finditer", "(", "r\"{[^{}]*}\"", ",", "s", ")", ")", "return", "reduce", "(", "_replace_curly", ",", "reversed", "(", "curleys", ...
Takes string and returns list of options: Example ------- >>> expand_curlys("py{26, 27}") ["py26", "py27"]
[ "Takes", "string", "and", "returns", "list", "of", "options", ":" ]
python
train
spyder-ide/spyder
spyder/plugins/projects/plugin.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L405-L410
def get_active_project_path(self): """Get path of the active project""" active_project_path = None if self.current_active_project: active_project_path = self.current_active_project.root_path return active_project_path
[ "def", "get_active_project_path", "(", "self", ")", ":", "active_project_path", "=", "None", "if", "self", ".", "current_active_project", ":", "active_project_path", "=", "self", ".", "current_active_project", ".", "root_path", "return", "active_project_path" ]
Get path of the active project
[ "Get", "path", "of", "the", "active", "project" ]
python
train
nerdvegas/rez
src/rez/solver.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2275-L2284
def _short_req_str(package_request): """print shortened version of '==X|==Y|==Z' ranged requests.""" if not package_request.conflict: versions = package_request.range.to_versions() if versions and len(versions) == len(package_request.range) \ and len(versions) > 1: re...
[ "def", "_short_req_str", "(", "package_request", ")", ":", "if", "not", "package_request", ".", "conflict", ":", "versions", "=", "package_request", ".", "range", ".", "to_versions", "(", ")", "if", "versions", "and", "len", "(", "versions", ")", "==", "len"...
print shortened version of '==X|==Y|==Z' ranged requests.
[ "print", "shortened", "version", "of", "==", "X|", "==", "Y|", "==", "Z", "ranged", "requests", "." ]
python
train
wickman/pystachio
pystachio/typing.py
https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/typing.py#L77-L86
def new(type_dict, type_factory, *type_parameters): """ Create a fully reified type from a type schema. """ type_tuple = (type_factory,) + type_parameters if type_tuple not in type_dict: factory = TypeFactory.get_factory(type_factory) reified_type = factory.create(type_dict, *type_para...
[ "def", "new", "(", "type_dict", ",", "type_factory", ",", "*", "type_parameters", ")", ":", "type_tuple", "=", "(", "type_factory", ",", ")", "+", "type_parameters", "if", "type_tuple", "not", "in", "type_dict", ":", "factory", "=", "TypeFactory", ".", "get_...
Create a fully reified type from a type schema.
[ "Create", "a", "fully", "reified", "type", "from", "a", "type", "schema", "." ]
python
train
django-ses/django-ses
django_ses/views.py
https://github.com/django-ses/django-ses/blob/2f0fd8e3fdc76d3512982c0bb8e2f6e93e09fa3c/django_ses/views.py#L73-L82
def emails_parse(emails_dict): """ Parse the output of ``SESConnection.list_verified_emails()`` and get a list of emails. """ result = emails_dict['ListVerifiedEmailAddressesResponse'][ 'ListVerifiedEmailAddressesResult'] emails = [email for email in result['VerifiedEmailAddresses']] ...
[ "def", "emails_parse", "(", "emails_dict", ")", ":", "result", "=", "emails_dict", "[", "'ListVerifiedEmailAddressesResponse'", "]", "[", "'ListVerifiedEmailAddressesResult'", "]", "emails", "=", "[", "email", "for", "email", "in", "result", "[", "'VerifiedEmailAddres...
Parse the output of ``SESConnection.list_verified_emails()`` and get a list of emails.
[ "Parse", "the", "output", "of", "SESConnection", ".", "list_verified_emails", "()", "and", "get", "a", "list", "of", "emails", "." ]
python
train
cathalgarvey/deadlock
deadlock/passwords/zxcvbn/scoring.py
https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/passwords/zxcvbn/scoring.py#L7-L21
def binom(n, k): """ Returns binomial coefficient (n choose k). """ # http://blog.plover.com/math/choose.html if k > n: return 0 if k == 0: return 1 result = 1 for denom in range(1, k + 1): result *= n result /= denom n -= 1 return result
[ "def", "binom", "(", "n", ",", "k", ")", ":", "# http://blog.plover.com/math/choose.html", "if", "k", ">", "n", ":", "return", "0", "if", "k", "==", "0", ":", "return", "1", "result", "=", "1", "for", "denom", "in", "range", "(", "1", ",", "k", "+"...
Returns binomial coefficient (n choose k).
[ "Returns", "binomial", "coefficient", "(", "n", "choose", "k", ")", "." ]
python
train
GaryLee/cmdlet
cmdlet/cmds.py
https://github.com/GaryLee/cmdlet/blob/5852a63fc2c7dd723a3d7abe18455f8dacb49433/cmdlet/cmds.py#L686-L688
def join(prev, sep, *args, **kw): '''alias of str.join''' yield sep.join(prev, *args, **kw)
[ "def", "join", "(", "prev", ",", "sep", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "yield", "sep", ".", "join", "(", "prev", ",", "*", "args", ",", "*", "*", "kw", ")" ]
alias of str.join
[ "alias", "of", "str", ".", "join" ]
python
valid
matrix-org/matrix-python-sdk
matrix_client/api.py
https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/api.py#L287-L307
def send_message_event(self, room_id, event_type, content, txn_id=None, timestamp=None): """Perform PUT /rooms/$room_id/send/$event_type Args: room_id (str): The room ID to send the message event in. event_type (str): The event type to send. ...
[ "def", "send_message_event", "(", "self", ",", "room_id", ",", "event_type", ",", "content", ",", "txn_id", "=", "None", ",", "timestamp", "=", "None", ")", ":", "if", "not", "txn_id", ":", "txn_id", "=", "self", ".", "_make_txn_id", "(", ")", "path", ...
Perform PUT /rooms/$room_id/send/$event_type Args: room_id (str): The room ID to send the message event in. event_type (str): The event type to send. content (dict): The JSON content to send. txn_id (int): Optional. The transaction ID to use. timestam...
[ "Perform", "PUT", "/", "rooms", "/", "$room_id", "/", "send", "/", "$event_type" ]
python
train
PmagPy/PmagPy
programs/chartmaker.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/chartmaker.py#L9-L33
def main(): """ Welcome to the thellier-thellier experiment automatic chart maker. Please select desired step interval and upper bound for which it is valid. e.g., 50 500 10 600 a blank entry signals the end of data entry. which would generate steps with 50 degree in...
[ "def", "main", "(", ")", ":", "print", "(", "main", ".", "__doc__", ")", "if", "'-h'", "in", "sys", ".", "argv", ":", "sys", ".", "exit", "(", ")", "cont", ",", "Int", ",", "Top", "=", "1", ",", "[", "]", ",", "[", "]", "while", "cont", "==...
Welcome to the thellier-thellier experiment automatic chart maker. Please select desired step interval and upper bound for which it is valid. e.g., 50 500 10 600 a blank entry signals the end of data entry. which would generate steps with 50 degree intervals up to 500, follo...
[ "Welcome", "to", "the", "thellier", "-", "thellier", "experiment", "automatic", "chart", "maker", ".", "Please", "select", "desired", "step", "interval", "and", "upper", "bound", "for", "which", "it", "is", "valid", ".", "e", ".", "g", ".", "50", "500", ...
python
train
zsethna/OLGA
olga/generation_probability.py
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L472-L601
def list_seqs_from_regex(self, regex_seq, print_warnings = True, raise_overload_warning = True): """List sequences that match regular expression template. This function parses a limited regular expression vocabulary, and lists all the sequences consistent with the regular expression. Suppo...
[ "def", "list_seqs_from_regex", "(", "self", ",", "regex_seq", ",", "print_warnings", "=", "True", ",", "raise_overload_warning", "=", "True", ")", ":", "aa_symbols", "=", "''", ".", "join", "(", "self", ".", "codons_dict", ")", "default_max_reps", "=", "40", ...
List sequences that match regular expression template. This function parses a limited regular expression vocabulary, and lists all the sequences consistent with the regular expression. Supported regex syntax: [] and {}. Cannot have two {} in a row. Note we can't use Kline star (*...
[ "List", "sequences", "that", "match", "regular", "expression", "template", ".", "This", "function", "parses", "a", "limited", "regular", "expression", "vocabulary", "and", "lists", "all", "the", "sequences", "consistent", "with", "the", "regular", "expression", "....
python
train
jtwhite79/pyemu
pyemu/sc.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/sc.py#L501-L532
def get_par_group_contribution(self, include_prior_results=False): """get the forecast uncertainty contribution from each parameter group. Just some sugar for get_contribution_dataframe() - this method automatically constructs the parlist_dict argument where the keys are the group names...
[ "def", "get_par_group_contribution", "(", "self", ",", "include_prior_results", "=", "False", ")", ":", "pargrp_dict", "=", "{", "}", "par", "=", "self", ".", "pst", ".", "parameter_data", "groups", "=", "par", ".", "groupby", "(", "\"pargp\"", ")", ".", "...
get the forecast uncertainty contribution from each parameter group. Just some sugar for get_contribution_dataframe() - this method automatically constructs the parlist_dict argument where the keys are the group names and the values are the adjustable parameters in the groups Parameter...
[ "get", "the", "forecast", "uncertainty", "contribution", "from", "each", "parameter", "group", ".", "Just", "some", "sugar", "for", "get_contribution_dataframe", "()", "-", "this", "method", "automatically", "constructs", "the", "parlist_dict", "argument", "where", ...
python
train
DAI-Lab/Copulas
copulas/multivariate/vine.py
https://github.com/DAI-Lab/Copulas/blob/821df61c3d36a6b81ef2883935f935c2eaaa862c/copulas/multivariate/vine.py#L139-L219
def _sample_row(self): """Generate a single sampled row from vine model. Returns: numpy.ndarray """ unis = np.random.uniform(0, 1, self.n_var) # randomly select a node to start with first_ind = np.random.randint(0, self.n_var) adj = self.trees[0].get_...
[ "def", "_sample_row", "(", "self", ")", ":", "unis", "=", "np", ".", "random", ".", "uniform", "(", "0", ",", "1", ",", "self", ".", "n_var", ")", "# randomly select a node to start with", "first_ind", "=", "np", ".", "random", ".", "randint", "(", "0", ...
Generate a single sampled row from vine model. Returns: numpy.ndarray
[ "Generate", "a", "single", "sampled", "row", "from", "vine", "model", "." ]
python
train
ns1/ns1-python
ns1/__init__.py
https://github.com/ns1/ns1-python/blob/f3e1d90a3b76a1bd18f855f2c622a8a49d4b585e/ns1/__init__.py#L62-L69
def addresses(self): """ Return a new raw REST interface to address resources :rtype: :py:class:`ns1.rest.ipam.Adresses` """ import ns1.rest.ipam return ns1.rest.ipam.Addresses(self.config)
[ "def", "addresses", "(", "self", ")", ":", "import", "ns1", ".", "rest", ".", "ipam", "return", "ns1", ".", "rest", ".", "ipam", ".", "Addresses", "(", "self", ".", "config", ")" ]
Return a new raw REST interface to address resources :rtype: :py:class:`ns1.rest.ipam.Adresses`
[ "Return", "a", "new", "raw", "REST", "interface", "to", "address", "resources" ]
python
train
cbrand/vpnchooser
src/vpnchooser/connection/client.py
https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/connection/client.py#L137-L151
def _write_to_server(self, rules: list): """ Writes the given ruleset to the server configuration file. :type rules: collections.Iterable[Rule] """ self._create_directory_structure() config_data = '\n'.join(rule.config_string for rule in rules) sftp = self...
[ "def", "_write_to_server", "(", "self", ",", "rules", ":", "list", ")", ":", "self", ".", "_create_directory_structure", "(", ")", "config_data", "=", "'\\n'", ".", "join", "(", "rule", ".", "config_string", "for", "rule", "in", "rules", ")", "sftp", "=", ...
Writes the given ruleset to the server configuration file. :type rules: collections.Iterable[Rule]
[ "Writes", "the", "given", "ruleset", "to", "the", "server", "configuration", "file", ".", ":", "type", "rules", ":", "collections", ".", "Iterable", "[", "Rule", "]" ]
python
train
ton/stash
stash/stash.py
https://github.com/ton/stash/blob/31cd8269aa8e051f094eccb094946eda6f6d428e/stash/stash.py#L39-L47
def remove_patch(cls, patch_name): """Removes patch *patch_name* from the stash (in case it exists). :raises: :py:exc:`~stash.exception.StashException` in case *patch_name* does not exist. """ try: os.unlink(cls._get_patch_path(patch_name)) except: raise ...
[ "def", "remove_patch", "(", "cls", ",", "patch_name", ")", ":", "try", ":", "os", ".", "unlink", "(", "cls", ".", "_get_patch_path", "(", "patch_name", ")", ")", "except", ":", "raise", "StashException", "(", "\"patch '%s' does not exist\"", "%", "patch_name",...
Removes patch *patch_name* from the stash (in case it exists). :raises: :py:exc:`~stash.exception.StashException` in case *patch_name* does not exist.
[ "Removes", "patch", "*", "patch_name", "*", "from", "the", "stash", "(", "in", "case", "it", "exists", ")", "." ]
python
train
Alignak-monitoring/alignak
alignak/objects/timeperiod.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L899-L914
def check_exclude_rec(self): # pylint: disable=access-member-before-definition """ Check if this timeperiod is tagged :return: if tagged return false, if not true :rtype: bool """ if self.rec_tag: msg = "[timeentry::%s] is in a loop in exclude paramet...
[ "def", "check_exclude_rec", "(", "self", ")", ":", "# pylint: disable=access-member-before-definition", "if", "self", ".", "rec_tag", ":", "msg", "=", "\"[timeentry::%s] is in a loop in exclude parameter\"", "%", "(", "self", ".", "get_name", "(", ")", ")", "self", "....
Check if this timeperiod is tagged :return: if tagged return false, if not true :rtype: bool
[ "Check", "if", "this", "timeperiod", "is", "tagged" ]
python
train
miku/gluish
gluish/common.py
https://github.com/miku/gluish/blob/56d3ac4f41a944e31ecac0aa3b6d1dc2ce705e29/gluish/common.py#L51-L60
def getfirstline(file, default): """ Returns the first line of a file. """ with open(file, 'rb') as fh: content = fh.readlines() if len(content) == 1: return content[0].decode('utf-8').strip('\n') return default
[ "def", "getfirstline", "(", "file", ",", "default", ")", ":", "with", "open", "(", "file", ",", "'rb'", ")", "as", "fh", ":", "content", "=", "fh", ".", "readlines", "(", ")", "if", "len", "(", "content", ")", "==", "1", ":", "return", "content", ...
Returns the first line of a file.
[ "Returns", "the", "first", "line", "of", "a", "file", "." ]
python
train
TestInABox/stackInABox
stackinabox/services/service.py
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/services/service.py#L425-L438
def register(self, method, uri, call_back): """Register a class instance function to handle a request. :param method: string - HTTP Verb :param uri: string - URI for the request :param call_back: class instance function that handles the request :returns: n/a """ ...
[ "def", "register", "(", "self", ",", "method", ",", "uri", ",", "call_back", ")", ":", "found", "=", "False", "self", ".", "create_route", "(", "uri", ",", "False", ")", "self", ".", "routes", "[", "uri", "]", "[", "'handlers'", "]", ".", "register_m...
Register a class instance function to handle a request. :param method: string - HTTP Verb :param uri: string - URI for the request :param call_back: class instance function that handles the request :returns: n/a
[ "Register", "a", "class", "instance", "function", "to", "handle", "a", "request", "." ]
python
train
python-diamond/Diamond
src/collectors/nfsd/nfsd.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nfsd/nfsd.py#L36-L199
def collect(self): """ Collect stats """ if os.access(self.PROC, os.R_OK): results = {} # Open file file = open(self.PROC) for line in file: line = line.split() if line[0] == 'rc': resu...
[ "def", "collect", "(", "self", ")", ":", "if", "os", ".", "access", "(", "self", ".", "PROC", ",", "os", ".", "R_OK", ")", ":", "results", "=", "{", "}", "# Open file", "file", "=", "open", "(", "self", ".", "PROC", ")", "for", "line", "in", "f...
Collect stats
[ "Collect", "stats" ]
python
train
log2timeline/plaso
plaso/engine/zeromq_queue.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/engine/zeromq_queue.py#L751-L783
def PushItem(self, item, block=True): """Push an item on to the queue. If no ZeroMQ socket has been created, one will be created the first time this method is called. Args: item (object): item to push on the queue. block (Optional[bool]): whether the push should be performed in blocking ...
[ "def", "PushItem", "(", "self", ",", "item", ",", "block", "=", "True", ")", ":", "if", "not", "self", ".", "_closed_event", ":", "raise", "RuntimeError", "(", "'Missing closed event.'", ")", "if", "self", ".", "_closed_event", ".", "is_set", "(", ")", "...
Push an item on to the queue. If no ZeroMQ socket has been created, one will be created the first time this method is called. Args: item (object): item to push on the queue. block (Optional[bool]): whether the push should be performed in blocking or non-blocking mode. Raises: ...
[ "Push", "an", "item", "on", "to", "the", "queue", "." ]
python
train
mdiener/grace
grace/py27/slimit/parser.py
https://github.com/mdiener/grace/blob/2dab13a2cf636da5da989904c5885166fc94d36d/grace/py27/slimit/parser.py#L375-L382
def p_new_expr_nobf(self, p): """new_expr_nobf : member_expr_nobf | NEW new_expr """ if len(p) == 2: p[0] = p[1] else: p[0] = ast.NewExpr(p[2])
[ "def", "p_new_expr_nobf", "(", "self", ",", "p", ")", ":", "if", "len", "(", "p", ")", "==", "2", ":", "p", "[", "0", "]", "=", "p", "[", "1", "]", "else", ":", "p", "[", "0", "]", "=", "ast", ".", "NewExpr", "(", "p", "[", "2", "]", ")...
new_expr_nobf : member_expr_nobf | NEW new_expr
[ "new_expr_nobf", ":", "member_expr_nobf", "|", "NEW", "new_expr" ]
python
train
MacHu-GWU/single_file_module-project
sfm/matplot_mate.py
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/matplot_mate.py#L207-L226
def preprocess_x_y(x, y): """Preprocess x, y input data. Returns list of list style. **中文文档** 预处理输入的x, y数据。 """ def is_iterable_slicable(a): if hasattr(a, "__iter__") and hasattr(a, "__getitem__"): return True else: return False if is_iterable_slicable(...
[ "def", "preprocess_x_y", "(", "x", ",", "y", ")", ":", "def", "is_iterable_slicable", "(", "a", ")", ":", "if", "hasattr", "(", "a", ",", "\"__iter__\"", ")", "and", "hasattr", "(", "a", ",", "\"__getitem__\"", ")", ":", "return", "True", "else", ":", ...
Preprocess x, y input data. Returns list of list style. **中文文档** 预处理输入的x, y数据。
[ "Preprocess", "x", "y", "input", "data", ".", "Returns", "list", "of", "list", "style", "." ]
python
train
dmlc/gluon-nlp
src/gluonnlp/data/transforms.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/data/transforms.py#L1144-L1157
def _truncate_seq_pair(self, tokens_a, tokens_b, max_length): """Truncates a sequence pair in place to the maximum length.""" # This is a simple heuristic which will always truncate the longer sequence # one token at a time. This makes more sense than truncating an equal percent # of tok...
[ "def", "_truncate_seq_pair", "(", "self", ",", "tokens_a", ",", "tokens_b", ",", "max_length", ")", ":", "# This is a simple heuristic which will always truncate the longer sequence", "# one token at a time. This makes more sense than truncating an equal percent", "# of tokens from each,...
Truncates a sequence pair in place to the maximum length.
[ "Truncates", "a", "sequence", "pair", "in", "place", "to", "the", "maximum", "length", "." ]
python
train
brian-rose/climlab
climlab/radiation/cam3/cam3.py
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/radiation/cam3/cam3.py#L115-L128
def _cam3_to_climlab(self, field): ''' Output is either (KM, JM, 1) or (JM, 1). Transform this to... - (KM,) or (1,) if JM==1 - (KM, JM) or (JM, 1) if JM>1 (longitude dimension IM not yet implemented).''' if self.JM > 1: if len(field.shape)==2: ...
[ "def", "_cam3_to_climlab", "(", "self", ",", "field", ")", ":", "if", "self", ".", "JM", ">", "1", ":", "if", "len", "(", "field", ".", "shape", ")", "==", "2", ":", "return", "field", "elif", "len", "(", "field", ".", "shape", ")", "==", "3", ...
Output is either (KM, JM, 1) or (JM, 1). Transform this to... - (KM,) or (1,) if JM==1 - (KM, JM) or (JM, 1) if JM>1 (longitude dimension IM not yet implemented).
[ "Output", "is", "either", "(", "KM", "JM", "1", ")", "or", "(", "JM", "1", ")", ".", "Transform", "this", "to", "...", "-", "(", "KM", ")", "or", "(", "1", ")", "if", "JM", "==", "1", "-", "(", "KM", "JM", ")", "or", "(", "JM", "1", ")", ...
python
train
AirSage/Petrel
petrel/petrel/rdebug.py
https://github.com/AirSage/Petrel/blob/c4be9b7da5916dcc028ddb88850e7703203eeb79/petrel/petrel/rdebug.py#L125-L135
def debug_process(pid): """Interrupt a running process and debug it.""" os.kill(pid, signal.SIGUSR1) # Signal process. pipe = NamedPipe(pipename(pid), 1) try: while pipe.is_open(): txt=raw_input(pipe.get()) + '\n' pipe.put(txt) except EOFError: pass # Exit. ...
[ "def", "debug_process", "(", "pid", ")", ":", "os", ".", "kill", "(", "pid", ",", "signal", ".", "SIGUSR1", ")", "# Signal process.", "pipe", "=", "NamedPipe", "(", "pipename", "(", "pid", ")", ",", "1", ")", "try", ":", "while", "pipe", ".", "is_ope...
Interrupt a running process and debug it.
[ "Interrupt", "a", "running", "process", "and", "debug", "it", "." ]
python
train
rauenzi/discordbot.py
discordbot/cogs/botadmin.py
https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L297-L304
async def unignore_all(self, ctx): """Unignores all channels in this server from being processed. To use this command you must have the Manage Channels permission or have the Bot Admin role. """ channels = [c for c in ctx.message.server.channels if c.type is discord.ChannelType....
[ "async", "def", "unignore_all", "(", "self", ",", "ctx", ")", ":", "channels", "=", "[", "c", "for", "c", "in", "ctx", ".", "message", ".", "server", ".", "channels", "if", "c", ".", "type", "is", "discord", ".", "ChannelType", ".", "text", "]", "a...
Unignores all channels in this server from being processed. To use this command you must have the Manage Channels permission or have the Bot Admin role.
[ "Unignores", "all", "channels", "in", "this", "server", "from", "being", "processed", "." ]
python
train
jonathf/chaospy
chaospy/quad/collection/leja.py
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/quad/collection/leja.py#L29-L76
def quad_leja(order, dist): """ Generate Leja quadrature node. Example: >>> abscisas, weights = quad_leja(3, chaospy.Normal(0, 1)) >>> print(numpy.around(abscisas, 4)) [[-2.7173 -1.4142 0. 1.7635]] >>> print(numpy.around(weights, 4)) [0.022 0.1629 0.6506 0.164...
[ "def", "quad_leja", "(", "order", ",", "dist", ")", ":", "from", "chaospy", ".", "distributions", "import", "evaluation", "if", "len", "(", "dist", ")", ">", "1", "and", "evaluation", ".", "get_dependencies", "(", "*", "list", "(", "dist", ")", ")", ":...
Generate Leja quadrature node. Example: >>> abscisas, weights = quad_leja(3, chaospy.Normal(0, 1)) >>> print(numpy.around(abscisas, 4)) [[-2.7173 -1.4142 0. 1.7635]] >>> print(numpy.around(weights, 4)) [0.022 0.1629 0.6506 0.1645]
[ "Generate", "Leja", "quadrature", "node", "." ]
python
train
Kortemme-Lab/klab
klab/rosetta/input_files.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/input_files.py#L123-L126
def add(self, start, end, cut_point = None, skip_rate = None, extend_loop = None): '''Add a new loop definition.''' self.data.append(self.parse_loop_line(['LOOP', start, end, cut_point, skip_rate, extend_loop])) assert(start <= end)
[ "def", "add", "(", "self", ",", "start", ",", "end", ",", "cut_point", "=", "None", ",", "skip_rate", "=", "None", ",", "extend_loop", "=", "None", ")", ":", "self", ".", "data", ".", "append", "(", "self", ".", "parse_loop_line", "(", "[", "'LOOP'",...
Add a new loop definition.
[ "Add", "a", "new", "loop", "definition", "." ]
python
train
mila/pyoo
pyoo.py
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1865-L1883
def open_spreadsheet(self, path, as_template=False, read_only=False): """ Opens an exiting spreadsheet document on the local file system. """ extra = () if as_template: pv = uno.createUnoStruct('com.sun.star.beans.PropertyValue') pv.Name = 'AsTemplate' ...
[ "def", "open_spreadsheet", "(", "self", ",", "path", ",", "as_template", "=", "False", ",", "read_only", "=", "False", ")", ":", "extra", "=", "(", ")", "if", "as_template", ":", "pv", "=", "uno", ".", "createUnoStruct", "(", "'com.sun.star.beans.PropertyVal...
Opens an exiting spreadsheet document on the local file system.
[ "Opens", "an", "exiting", "spreadsheet", "document", "on", "the", "local", "file", "system", "." ]
python
train
mkoura/dump2polarion
dump2polarion/results/csvtools.py
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/csvtools.py#L83-L107
def _get_results(csv_reader, fieldnames): """Maps data to fieldnames. The reader needs to be at position after fieldnames, before the results data. """ fieldnames_count = len(fieldnames) results = [] for row in csv_reader: for col in row: if col: break ...
[ "def", "_get_results", "(", "csv_reader", ",", "fieldnames", ")", ":", "fieldnames_count", "=", "len", "(", "fieldnames", ")", "results", "=", "[", "]", "for", "row", "in", "csv_reader", ":", "for", "col", "in", "row", ":", "if", "col", ":", "break", "...
Maps data to fieldnames. The reader needs to be at position after fieldnames, before the results data.
[ "Maps", "data", "to", "fieldnames", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py#L835-L859
def _append_custom(self, insert, input, before_prompt=False): """ A low-level method for appending content to the end of the buffer. If 'before_prompt' is enabled, the content will be inserted before the current prompt, if there is one. """ # Determine where to insert the conten...
[ "def", "_append_custom", "(", "self", ",", "insert", ",", "input", ",", "before_prompt", "=", "False", ")", ":", "# Determine where to insert the content.", "cursor", "=", "self", ".", "_control", ".", "textCursor", "(", ")", "if", "before_prompt", "and", "(", ...
A low-level method for appending content to the end of the buffer. If 'before_prompt' is enabled, the content will be inserted before the current prompt, if there is one.
[ "A", "low", "-", "level", "method", "for", "appending", "content", "to", "the", "end", "of", "the", "buffer", "." ]
python
test
crcresearch/py-utils
crc_nd/utils/file_io.py
https://github.com/crcresearch/py-utils/blob/04caf0425a047baf900da726cf47c42413b0dd81/crc_nd/utils/file_io.py#L14-L23
def clean_out_dir(directory): """ Delete all the files and subdirectories in a directory. """ if not isinstance(directory, path): directory = path(directory) for file_path in directory.files(): file_path.remove() for dir_path in directory.dirs(): dir_path.rmtree()
[ "def", "clean_out_dir", "(", "directory", ")", ":", "if", "not", "isinstance", "(", "directory", ",", "path", ")", ":", "directory", "=", "path", "(", "directory", ")", "for", "file_path", "in", "directory", ".", "files", "(", ")", ":", "file_path", ".",...
Delete all the files and subdirectories in a directory.
[ "Delete", "all", "the", "files", "and", "subdirectories", "in", "a", "directory", "." ]
python
train
RiotGames/cloud-inquisitor
backend/cloud_inquisitor/schema/resource.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/backend/cloud_inquisitor/schema/resource.py#L72-L101
def get(cls, resource_type): """Returns the ResourceType object for `resource_type`. If no existing object was found, a new type will be created in the database and returned Args: resource_type (str): Resource type name Returns: :obj:`ResourceType` """ ...
[ "def", "get", "(", "cls", ",", "resource_type", ")", ":", "if", "isinstance", "(", "resource_type", ",", "str", ")", ":", "obj", "=", "getattr", "(", "db", ",", "cls", ".", "__name__", ")", ".", "find_one", "(", "cls", ".", "resource_type", "==", "re...
Returns the ResourceType object for `resource_type`. If no existing object was found, a new type will be created in the database and returned Args: resource_type (str): Resource type name Returns: :obj:`ResourceType`
[ "Returns", "the", "ResourceType", "object", "for", "resource_type", ".", "If", "no", "existing", "object", "was", "found", "a", "new", "type", "will", "be", "created", "in", "the", "database", "and", "returned" ]
python
train
Azure/azure-sdk-for-python
azure-servicemanagement-legacy/azure/servicemanagement/websitemanagementservice.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/websitemanagementservice.py#L210-L237
def get_historical_usage_metrics(self, webspace_name, website_name, metrics = None, start_time=None, end_time=None, time_grain=None): ''' Get historical usage metrics. webspace_name: The name of the webspace. website_name: The...
[ "def", "get_historical_usage_metrics", "(", "self", ",", "webspace_name", ",", "website_name", ",", "metrics", "=", "None", ",", "start_time", "=", "None", ",", "end_time", "=", "None", ",", "time_grain", "=", "None", ")", ":", "metrics", "=", "(", "'names='...
Get historical usage metrics. webspace_name: The name of the webspace. website_name: The name of the website. metrics: Optional. List of metrics name. Otherwise, all metrics returned. start_time: Optional. An ISO8601 date. Otherwise, curre...
[ "Get", "historical", "usage", "metrics", "." ]
python
test
databio/pypiper
pypiper/ngstk.py
https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/ngstk.py#L1426-L1440
def calc_frip(self, input_bam, input_bed, threads=4): """ Calculate fraction of reads in peaks. A file of with a pool of sequencing reads and a file with peak call regions define the operation that will be performed. Thread count for samtools can be specified as well. :...
[ "def", "calc_frip", "(", "self", ",", "input_bam", ",", "input_bed", ",", "threads", "=", "4", ")", ":", "cmd", "=", "self", ".", "simple_frip", "(", "input_bam", ",", "input_bed", ",", "threads", ")", "return", "subprocess", ".", "check_output", "(", "c...
Calculate fraction of reads in peaks. A file of with a pool of sequencing reads and a file with peak call regions define the operation that will be performed. Thread count for samtools can be specified as well. :param str input_bam: sequencing reads file :param str input_bed: f...
[ "Calculate", "fraction", "of", "reads", "in", "peaks", "." ]
python
train
timothycrosley/deprecated.frosted
frosted/checker.py
https://github.com/timothycrosley/deprecated.frosted/blob/61ba7f341fc55676c3580c8c4e52117986cd5e12/frosted/checker.py#L716-L733
def NAME(self, node): """Handle occurrence of Name (which can be a load/store/delete access.)""" # Locate the name in locals / function / globals scopes. if isinstance(node.ctx, (ast.Load, ast.AugLoad)): self.handle_node_load(node) if (node.id == 'locals' and isin...
[ "def", "NAME", "(", "self", ",", "node", ")", ":", "# Locate the name in locals / function / globals scopes.", "if", "isinstance", "(", "node", ".", "ctx", ",", "(", "ast", ".", "Load", ",", "ast", ".", "AugLoad", ")", ")", ":", "self", ".", "handle_node_loa...
Handle occurrence of Name (which can be a load/store/delete access.)
[ "Handle", "occurrence", "of", "Name", "(", "which", "can", "be", "a", "load", "/", "store", "/", "delete", "access", ".", ")" ]
python
train
Azure/blobxfer
blobxfer/operations/azure/__init__.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/azure/__init__.py#L176-L185
def endpoint(self, value): # type: (StorageAccount, str) -> None """Set endpoint :param StorageAccount self: this :param str value: endpoint """ tmp = value.split('.') if (len(tmp) <= 1 or not tmp[0].isalnum()): raise ValueError('endpoint is invalid: {...
[ "def", "endpoint", "(", "self", ",", "value", ")", ":", "# type: (StorageAccount, str) -> None", "tmp", "=", "value", ".", "split", "(", "'.'", ")", "if", "(", "len", "(", "tmp", ")", "<=", "1", "or", "not", "tmp", "[", "0", "]", ".", "isalnum", "(",...
Set endpoint :param StorageAccount self: this :param str value: endpoint
[ "Set", "endpoint", ":", "param", "StorageAccount", "self", ":", "this", ":", "param", "str", "value", ":", "endpoint" ]
python
train
uogbuji/amara3-xml
pylib/uxml/writer.py
https://github.com/uogbuji/amara3-xml/blob/88c18876418cffc89bb85b4a3193e5002b6b39a6/pylib/uxml/writer.py#L178-L191
def write(elem, a_writer): ''' Write a MicroXML element node (yes, even one representign a whole document) elem - Amara MicroXML element node to be written out writer - instance of amara3.uxml.writer to implement the writing process ''' a_writer.start_element(elem.xml_name, attribs=elem.xml_attr...
[ "def", "write", "(", "elem", ",", "a_writer", ")", ":", "a_writer", ".", "start_element", "(", "elem", ".", "xml_name", ",", "attribs", "=", "elem", ".", "xml_attributes", ")", "for", "node", "in", "elem", ".", "xml_children", ":", "if", "isinstance", "(...
Write a MicroXML element node (yes, even one representign a whole document) elem - Amara MicroXML element node to be written out writer - instance of amara3.uxml.writer to implement the writing process
[ "Write", "a", "MicroXML", "element", "node", "(", "yes", "even", "one", "representign", "a", "whole", "document", ")", "elem", "-", "Amara", "MicroXML", "element", "node", "to", "be", "written", "out", "writer", "-", "instance", "of", "amara3", ".", "uxml"...
python
test
trickvi/economics
economics/inflation.py
https://github.com/trickvi/economics/blob/18da5ce7169472ca1ba6022272a389b933f76edd/economics/inflation.py#L54-L70
def get(self, reference, country, target=datetime.date.today()): """ Get the inflation/deflation value change for the target date based on the reference date. Target defaults to today and the instance's reference and country will be used if they are not provided as parameters ...
[ "def", "get", "(", "self", ",", "reference", ",", "country", ",", "target", "=", "datetime", ".", "date", ".", "today", "(", ")", ")", ":", "# Set country & reference to object's country & reference respectively", "reference", "=", "self", ".", "reference", "if", ...
Get the inflation/deflation value change for the target date based on the reference date. Target defaults to today and the instance's reference and country will be used if they are not provided as parameters
[ "Get", "the", "inflation", "/", "deflation", "value", "change", "for", "the", "target", "date", "based", "on", "the", "reference", "date", ".", "Target", "defaults", "to", "today", "and", "the", "instance", "s", "reference", "and", "country", "will", "be", ...
python
train
saltstack/salt
salt/roster/terraform.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/roster/terraform.py#L119-L125
def _cast_output_to_type(value, typ): '''cast the value depending on the terraform type''' if typ == 'b': return bool(value) if typ == 'i': return int(value) return value
[ "def", "_cast_output_to_type", "(", "value", ",", "typ", ")", ":", "if", "typ", "==", "'b'", ":", "return", "bool", "(", "value", ")", "if", "typ", "==", "'i'", ":", "return", "int", "(", "value", ")", "return", "value" ]
cast the value depending on the terraform type
[ "cast", "the", "value", "depending", "on", "the", "terraform", "type" ]
python
train
StackStorm/pybind
pybind/nos/v6_0_2f/brocade_system_rpc/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/brocade_system_rpc/__init__.py#L97-L121
def _set_get_system_uptime(self, v, load=False): """ Setter method for get_system_uptime, mapped from YANG variable /brocade_system_rpc/get_system_uptime (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_get_system_uptime is considered as a private method. Backen...
[ "def", "_set_get_system_uptime", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",",...
Setter method for get_system_uptime, mapped from YANG variable /brocade_system_rpc/get_system_uptime (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_get_system_uptime is considered as a private method. Backends looking to populate this variable should do so via cal...
[ "Setter", "method", "for", "get_system_uptime", "mapped", "from", "YANG", "variable", "/", "brocade_system_rpc", "/", "get_system_uptime", "(", "rpc", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "s...
python
train
hyperledger/sawtooth-core
validator/sawtooth_validator/execution/scheduler_parallel.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L91-L105
def update(self, address, updater, prune=False): ''' Walk to ADDRESS, creating nodes if necessary, and set the data there to UPDATER(data). Arguments: address (str): the address to be updated ''' node = self._get_or_create(address) node.data = updat...
[ "def", "update", "(", "self", ",", "address", ",", "updater", ",", "prune", "=", "False", ")", ":", "node", "=", "self", ".", "_get_or_create", "(", "address", ")", "node", ".", "data", "=", "updater", "(", "node", ".", "data", ")", "if", "prune", ...
Walk to ADDRESS, creating nodes if necessary, and set the data there to UPDATER(data). Arguments: address (str): the address to be updated
[ "Walk", "to", "ADDRESS", "creating", "nodes", "if", "necessary", "and", "set", "the", "data", "there", "to", "UPDATER", "(", "data", ")", "." ]
python
train
grahambell/pymoc
lib/pymoc/io/json.py
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/io/json.py#L22-L39
def write_moc_json(moc, filename=None, file=None): """Write a MOC in JSON encoding. Either a filename, or an open file object can be specified. """ moc.normalize() obj = {} for (order, cells) in moc: obj['{0}'.format(order)] = sorted(cells) if file is not None: _write_js...
[ "def", "write_moc_json", "(", "moc", ",", "filename", "=", "None", ",", "file", "=", "None", ")", ":", "moc", ".", "normalize", "(", ")", "obj", "=", "{", "}", "for", "(", "order", ",", "cells", ")", "in", "moc", ":", "obj", "[", "'{0}'", ".", ...
Write a MOC in JSON encoding. Either a filename, or an open file object can be specified.
[ "Write", "a", "MOC", "in", "JSON", "encoding", "." ]
python
train
acutesoftware/AIKIF
scripts/run.py
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/run.py#L49-L60
def start_aikif(): """ starts the web interface and possibly other processes """ if sys.platform[0:3] == 'win': os.system("start go_web_aikif.bat") else: os.system("../aikif/web_app/web_aikif.py") import webbrowser import time time.sleep(1) webbrowser...
[ "def", "start_aikif", "(", ")", ":", "if", "sys", ".", "platform", "[", "0", ":", "3", "]", "==", "'win'", ":", "os", ".", "system", "(", "\"start go_web_aikif.bat\"", ")", "else", ":", "os", ".", "system", "(", "\"../aikif/web_app/web_aikif.py\"", ")", ...
starts the web interface and possibly other processes
[ "starts", "the", "web", "interface", "and", "possibly", "other", "processes" ]
python
train
edeposit/edeposit.amqp.storage
src/edeposit/amqp/storage/web_tools.py
https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/web_tools.py#L107-L124
def compose_tree_url(tree, issn_url=False): """ Compose full url for given `tree`, with protocol, server's address and port. Args: tree (obj): :class:`.Tree` instance. issn_url (bool, default False): Compose URL using ISSN. Returns: str: URL of the tree """ url = co...
[ "def", "compose_tree_url", "(", "tree", ",", "issn_url", "=", "False", ")", ":", "url", "=", "compose_tree_path", "(", "tree", ",", "issn_url", ")", "if", "WEB_PORT", "==", "80", ":", "return", "\"%s://%s%s\"", "%", "(", "_PROTOCOL", ",", "WEB_ADDR", ",", ...
Compose full url for given `tree`, with protocol, server's address and port. Args: tree (obj): :class:`.Tree` instance. issn_url (bool, default False): Compose URL using ISSN. Returns: str: URL of the tree
[ "Compose", "full", "url", "for", "given", "tree", "with", "protocol", "server", "s", "address", "and", "port", "." ]
python
train
BenjaminSchubert/NitPycker
nitpycker/runner.py
https://github.com/BenjaminSchubert/NitPycker/blob/3ac2b3bf06f1d704b4853167a967311b0465a76f/nitpycker/runner.py#L182-L217
def print_summary(self, result, time_taken): """ Prints the test summary, how many tests failed, how long it took, etc :param result: result class to use to print summary :param time_taken: the time all tests took to run """ if hasattr(result, "separator2"): ...
[ "def", "print_summary", "(", "self", ",", "result", ",", "time_taken", ")", ":", "if", "hasattr", "(", "result", ",", "\"separator2\"", ")", ":", "self", ".", "stream", ".", "writeln", "(", "result", ".", "separator2", ")", "self", ".", "stream", ".", ...
Prints the test summary, how many tests failed, how long it took, etc :param result: result class to use to print summary :param time_taken: the time all tests took to run
[ "Prints", "the", "test", "summary", "how", "many", "tests", "failed", "how", "long", "it", "took", "etc" ]
python
train
wummel/dosage
dosagelib/events.py
https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/events.py#L256-L264
def getComicData(self, comic): """Return dictionary with comic info.""" if comic not in self.data: if os.path.exists(self.jsonFn(comic)): with codecs.open(self.jsonFn(comic), 'r', self.encoding) as f: self.data[comic] = json.load(f) else: ...
[ "def", "getComicData", "(", "self", ",", "comic", ")", ":", "if", "comic", "not", "in", "self", ".", "data", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "jsonFn", "(", "comic", ")", ")", ":", "with", "codecs", ".", "open", "(",...
Return dictionary with comic info.
[ "Return", "dictionary", "with", "comic", "info", "." ]
python
train
ghukill/pyfc4
pyfc4/models.py
https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L269-L314
def get_txn(self, txn_name, txn_uri): ''' Retrieves known transaction and adds to self.txns. TODO: Perhaps this should send a keep-alive request as well? Obviously still needed, and would reset timer. Args: txn_prefix (str, rdflib.term.URIRef): uri of the transaction. e.g. http://localhost:8080/rest/t...
[ "def", "get_txn", "(", "self", ",", "txn_name", ",", "txn_uri", ")", ":", "# parse uri", "txn_uri", "=", "self", ".", "parse_uri", "(", "txn_uri", ")", "# request new transaction", "txn_response", "=", "self", ".", "api", ".", "http_request", "(", "'GET'", "...
Retrieves known transaction and adds to self.txns. TODO: Perhaps this should send a keep-alive request as well? Obviously still needed, and would reset timer. Args: txn_prefix (str, rdflib.term.URIRef): uri of the transaction. e.g. http://localhost:8080/rest/txn:123456789 txn_name (str): local, human na...
[ "Retrieves", "known", "transaction", "and", "adds", "to", "self", ".", "txns", "." ]
python
train
saltstack/salt
salt/modules/xml.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xml.py#L66-L82
def get_attribute(file, element): ''' Return the attributes of the matched xpath element. CLI Example: .. code-block:: bash salt '*' xml.get_attribute /tmp/test.xml ".//element[@id='3']" ''' try: root = ET.parse(file) element = root.find(element) return element...
[ "def", "get_attribute", "(", "file", ",", "element", ")", ":", "try", ":", "root", "=", "ET", ".", "parse", "(", "file", ")", "element", "=", "root", ".", "find", "(", "element", ")", "return", "element", ".", "attrib", "except", "AttributeError", ":",...
Return the attributes of the matched xpath element. CLI Example: .. code-block:: bash salt '*' xml.get_attribute /tmp/test.xml ".//element[@id='3']"
[ "Return", "the", "attributes", "of", "the", "matched", "xpath", "element", "." ]
python
train
jbasko/configmanager
configmanager/sections.py
https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L228-L244
def get_item(self, *key): """ The recommended way of retrieving an item by key when extending configmanager's behaviour. Attribute and dictionary key access is configurable and may not always return items (see PlainConfig for example), whereas this method will always return the correspon...
[ "def", "get_item", "(", "self", ",", "*", "key", ")", ":", "item", "=", "self", ".", "_get_item_or_section", "(", "key", ")", "if", "not", "item", ".", "is_item", ":", "raise", "RuntimeError", "(", "'{} is a section, not an item'", ".", "format", "(", "key...
The recommended way of retrieving an item by key when extending configmanager's behaviour. Attribute and dictionary key access is configurable and may not always return items (see PlainConfig for example), whereas this method will always return the corresponding Item as long as NOT_FOUND hook ca...
[ "The", "recommended", "way", "of", "retrieving", "an", "item", "by", "key", "when", "extending", "configmanager", "s", "behaviour", ".", "Attribute", "and", "dictionary", "key", "access", "is", "configurable", "and", "may", "not", "always", "return", "items", ...
python
train
pmacosta/pexdoc
pexdoc/pinspect.py
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pinspect.py#L129-L156
def get_module_name(module_obj): r""" Retrieve the module name from a module object. :param module_obj: Module object :type module_obj: object :rtype: string :raises: * RuntimeError (Argument \`module_obj\` is not valid) * RuntimeError (Module object \`*[module_name]*\` could not ...
[ "def", "get_module_name", "(", "module_obj", ")", ":", "if", "not", "is_object_module", "(", "module_obj", ")", ":", "raise", "RuntimeError", "(", "\"Argument `module_obj` is not valid\"", ")", "name", "=", "module_obj", ".", "__name__", "msg", "=", "\"Module object...
r""" Retrieve the module name from a module object. :param module_obj: Module object :type module_obj: object :rtype: string :raises: * RuntimeError (Argument \`module_obj\` is not valid) * RuntimeError (Module object \`*[module_name]*\` could not be found in loaded modules) ...
[ "r", "Retrieve", "the", "module", "name", "from", "a", "module", "object", "." ]
python
train
apache/incubator-heron
heron/tools/tracker/src/python/handlers/metricsqueryhandler.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/tracker/src/python/handlers/metricsqueryhandler.py#L78-L120
def executeMetricsQuery(self, tmaster, queryString, start_time, end_time, callback=None): """ Get the specified metrics for the given query in this topology. Returns the following dict on success: { "timeline": [{ "instance": <instance>, "data": { <start_time> : <numeric ...
[ "def", "executeMetricsQuery", "(", "self", ",", "tmaster", ",", "queryString", ",", "start_time", ",", "end_time", ",", "callback", "=", "None", ")", ":", "query", "=", "Query", "(", "self", ".", "tracker", ")", "metrics", "=", "yield", "query", ".", "ex...
Get the specified metrics for the given query in this topology. Returns the following dict on success: { "timeline": [{ "instance": <instance>, "data": { <start_time> : <numeric value>, <start_time> : <numeric value>, ... } }, { ... ...
[ "Get", "the", "specified", "metrics", "for", "the", "given", "query", "in", "this", "topology", ".", "Returns", "the", "following", "dict", "on", "success", ":", "{", "timeline", ":", "[", "{", "instance", ":", "<instance", ">", "data", ":", "{", "<start...
python
valid
slundberg/shap
shap/benchmark/metrics.py
https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L56-L90
def local_accuracy(X, y, model_generator, method_name): """ Local Accuracy transform = "identity" sort_order = 2 """ def score_map(true, pred): """ Converts local accuracy from % of standard deviation to numerical scores for coloring. """ v = min(1.0, np.std(pred - true) / ...
[ "def", "local_accuracy", "(", "X", ",", "y", ",", "model_generator", ",", "method_name", ")", ":", "def", "score_map", "(", "true", ",", "pred", ")", ":", "\"\"\" Converts local accuracy from % of standard deviation to numerical scores for coloring.\n \"\"\"", "v", ...
Local Accuracy transform = "identity" sort_order = 2
[ "Local", "Accuracy", "transform", "=", "identity", "sort_order", "=", "2" ]
python
train
dossier/dossier.web
dossier/web/routes.py
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L394-L412
def v1_subfolder_list(request, response, kvlclient, fid): '''Retrieves a list of subfolders in a folder for the current user. The route for this endpoint is: ``GET /dossier/v1/folder/<fid>/subfolder``. (Temporarily, the "current user" can be set via the ``annotator_id`` query parameter.) The ...
[ "def", "v1_subfolder_list", "(", "request", ",", "response", ",", "kvlclient", ",", "fid", ")", ":", "fid", "=", "urllib", ".", "unquote", "(", "fid", ")", "try", ":", "return", "sorted", "(", "imap", "(", "attrgetter", "(", "'name'", ")", ",", "ifilte...
Retrieves a list of subfolders in a folder for the current user. The route for this endpoint is: ``GET /dossier/v1/folder/<fid>/subfolder``. (Temporarily, the "current user" can be set via the ``annotator_id`` query parameter.) The payload returned is a list of subfolder identifiers.
[ "Retrieves", "a", "list", "of", "subfolders", "in", "a", "folder", "for", "the", "current", "user", "." ]
python
train
ronaldguillen/wave
wave/views.py
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/views.py#L369-L386
def initial(self, request, *args, **kwargs): """ Runs anything that needs to occur prior to calling the method handler. """ self.format_kwarg = self.get_format_suffix(**kwargs) # Ensure that the incoming request is permitted self.perform_authentication(request) s...
[ "def", "initial", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "format_kwarg", "=", "self", ".", "get_format_suffix", "(", "*", "*", "kwargs", ")", "# Ensure that the incoming request is permitted", "self", "...
Runs anything that needs to occur prior to calling the method handler.
[ "Runs", "anything", "that", "needs", "to", "occur", "prior", "to", "calling", "the", "method", "handler", "." ]
python
train
saltstack/salt
salt/modules/restartcheck.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/restartcheck.py#L348-L357
def _check_timeout(start_time, timeout): ''' Name of the last installed kernel, for Red Hat based systems. Returns: List with name of last installed kernel as it is interpreted in output of `uname -a` command. ''' timeout_milisec = timeout * 60000 if timeout_milisec < (int(round(tim...
[ "def", "_check_timeout", "(", "start_time", ",", "timeout", ")", ":", "timeout_milisec", "=", "timeout", "*", "60000", "if", "timeout_milisec", "<", "(", "int", "(", "round", "(", "time", ".", "time", "(", ")", "*", "1000", ")", ")", "-", "start_time", ...
Name of the last installed kernel, for Red Hat based systems. Returns: List with name of last installed kernel as it is interpreted in output of `uname -a` command.
[ "Name", "of", "the", "last", "installed", "kernel", "for", "Red", "Hat", "based", "systems", "." ]
python
train
yhat/db.py
db/db.py
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L279-L305
def load_credentials(self, profile="default"): """ Loads crentials for a given profile. Profiles are stored in ~/.db.py_{profile_name} and are a base64 encoded JSON file. This is not to say this a secure way to store sensitive data, but it will probably stop your little sister fr...
[ "def", "load_credentials", "(", "self", ",", "profile", "=", "\"default\"", ")", ":", "f", "=", "profile_path", "(", "DBPY_PROFILE_ID", ",", "profile", ")", "if", "f", ":", "creds", "=", "load_from_json", "(", "f", ")", "self", ".", "username", "=", "cre...
Loads crentials for a given profile. Profiles are stored in ~/.db.py_{profile_name} and are a base64 encoded JSON file. This is not to say this a secure way to store sensitive data, but it will probably stop your little sister from stealing your passwords. Parameters ---------- ...
[ "Loads", "crentials", "for", "a", "given", "profile", ".", "Profiles", "are", "stored", "in", "~", "/", ".", "db", ".", "py_", "{", "profile_name", "}", "and", "are", "a", "base64", "encoded", "JSON", "file", ".", "This", "is", "not", "to", "say", "t...
python
train
gem/oq-engine
openquake/commonlib/source.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/source.py#L419-L424
def get_weight(self, weight=operator.attrgetter('weight')): """ :param weight: source weight function :returns: total weight of the source model """ return sum(weight(src) for src in self.get_sources())
[ "def", "get_weight", "(", "self", ",", "weight", "=", "operator", ".", "attrgetter", "(", "'weight'", ")", ")", ":", "return", "sum", "(", "weight", "(", "src", ")", "for", "src", "in", "self", ".", "get_sources", "(", ")", ")" ]
:param weight: source weight function :returns: total weight of the source model
[ ":", "param", "weight", ":", "source", "weight", "function", ":", "returns", ":", "total", "weight", "of", "the", "source", "model" ]
python
train
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L385-L412
def get_context_data(self, **kwargs): """ Return a dictionary containing all of the values needed to render the menu instance to a template, including values that might be used by the 'sub_menu' tag to render any additional levels. """ ctx_vals = self._contextual_vals ...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ctx_vals", "=", "self", ".", "_contextual_vals", "opt_vals", "=", "self", ".", "_option_vals", "data", "=", "self", ".", "create_dict_from_parent_context", "(", ")", "data", ".", "up...
Return a dictionary containing all of the values needed to render the menu instance to a template, including values that might be used by the 'sub_menu' tag to render any additional levels.
[ "Return", "a", "dictionary", "containing", "all", "of", "the", "values", "needed", "to", "render", "the", "menu", "instance", "to", "a", "template", "including", "values", "that", "might", "be", "used", "by", "the", "sub_menu", "tag", "to", "render", "any", ...
python
train
tensorforce/tensorforce
tensorforce/core/preprocessors/preprocessor.py
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/preprocessors/preprocessor.py#L139-L150
def processed_shape(self, shape): """ Shape of preprocessed state given original shape. Args: shape: original state shape Returns: processed state shape """ for processor in self.preprocessors: shape = processor.processed_shape(shape=shape) ...
[ "def", "processed_shape", "(", "self", ",", "shape", ")", ":", "for", "processor", "in", "self", ".", "preprocessors", ":", "shape", "=", "processor", ".", "processed_shape", "(", "shape", "=", "shape", ")", "return", "shape" ]
Shape of preprocessed state given original shape. Args: shape: original state shape Returns: processed state shape
[ "Shape", "of", "preprocessed", "state", "given", "original", "shape", "." ]
python
valid
knipknap/SpiffWorkflow
SpiffWorkflow/bpmn/parser/TaskParser.py
https://github.com/knipknap/SpiffWorkflow/blob/f0af7f59a332e0619e4f3c00a7d4a3d230760e00/SpiffWorkflow/bpmn/parser/TaskParser.py#L58-L129
def parse_node(self): """ Parse this node, and all children, returning the connected task spec. """ try: self.task = self.create_task() self.task.documentation = self.parser._parse_documentation( self.node, xpath=self.xpath, task_parser=self) ...
[ "def", "parse_node", "(", "self", ")", ":", "try", ":", "self", ".", "task", "=", "self", ".", "create_task", "(", ")", "self", ".", "task", ".", "documentation", "=", "self", ".", "parser", ".", "_parse_documentation", "(", "self", ".", "node", ",", ...
Parse this node, and all children, returning the connected task spec.
[ "Parse", "this", "node", "and", "all", "children", "returning", "the", "connected", "task", "spec", "." ]
python
valid
wiheto/teneto
teneto/communitydetection/tctc.py
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/communitydetection/tctc.py#L8-L114
def partition_inference(tctc_mat, comp, tau, sigma, kappa): r""" Takes tctc trajectory matrix and returns dataframe where all multi-label communities are listed Can take a little bit of time with large datasets and optimizaiton could remove some for loops. """ communityinfo = {} communityinfo[...
[ "def", "partition_inference", "(", "tctc_mat", ",", "comp", ",", "tau", ",", "sigma", ",", "kappa", ")", ":", "communityinfo", "=", "{", "}", "communityinfo", "[", "'community'", "]", "=", "[", "]", "communityinfo", "[", "'start'", "]", "=", "np", ".", ...
r""" Takes tctc trajectory matrix and returns dataframe where all multi-label communities are listed Can take a little bit of time with large datasets and optimizaiton could remove some for loops.
[ "r", "Takes", "tctc", "trajectory", "matrix", "and", "returns", "dataframe", "where", "all", "multi", "-", "label", "communities", "are", "listed" ]
python
train
NatLibFi/Skosify
skosify/infer.py
https://github.com/NatLibFi/Skosify/blob/1d269987f10df08e706272dcf6a86aef4abebcde/skosify/infer.py#L72-L91
def skos_hierarchical_mappings(rdf, narrower=True): """Infer skos:broadMatch/skos:narrowMatch (S43) and add the super-properties skos:broader/skos:narrower (S41). :param bool narrower: If set to False, skos:narrowMatch will not be added, but rather removed. """ for s, o in rdf.subject_objec...
[ "def", "skos_hierarchical_mappings", "(", "rdf", ",", "narrower", "=", "True", ")", ":", "for", "s", ",", "o", "in", "rdf", ".", "subject_objects", "(", "SKOS", ".", "broadMatch", ")", ":", "rdf", ".", "add", "(", "(", "s", ",", "SKOS", ".", "broader...
Infer skos:broadMatch/skos:narrowMatch (S43) and add the super-properties skos:broader/skos:narrower (S41). :param bool narrower: If set to False, skos:narrowMatch will not be added, but rather removed.
[ "Infer", "skos", ":", "broadMatch", "/", "skos", ":", "narrowMatch", "(", "S43", ")", "and", "add", "the", "super", "-", "properties", "skos", ":", "broader", "/", "skos", ":", "narrower", "(", "S41", ")", "." ]
python
train
shalabhms/reliable-collections-cli
rcctl/rcctl/custom_reliablecollections.py
https://github.com/shalabhms/reliable-collections-cli/blob/195d69816fb5a6e1e9ab0ab66b606b1248b4780d/rcctl/rcctl/custom_reliablecollections.py#L126-L145
def execute_reliabledictionary(client, application_name, service_name, input_file): """Execute create, update, delete operations on existing reliable dictionaries. carry out create, update and delete operations on existing reliable dictionaries for given application and service. :param application_name: N...
[ "def", "execute_reliabledictionary", "(", "client", ",", "application_name", ",", "service_name", ",", "input_file", ")", ":", "cluster", "=", "Cluster", ".", "from_sfclient", "(", "client", ")", "service", "=", "cluster", ".", "get_application", "(", "application...
Execute create, update, delete operations on existing reliable dictionaries. carry out create, update and delete operations on existing reliable dictionaries for given application and service. :param application_name: Name of the application. :type application_name: str :param service_name: Name of th...
[ "Execute", "create", "update", "delete", "operations", "on", "existing", "reliable", "dictionaries", "." ]
python
valid
futurecolors/django-geoip
django_geoip/base.py
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/base.py#L73-L86
def _get_ip_range(self): """ Fetches IpRange instance if request IP is found in database. :param request: A ususal request object :type request: HttpRequest :return: IpRange object or None """ ip = self._get_real_ip() try: geobase_entry = IpRa...
[ "def", "_get_ip_range", "(", "self", ")", ":", "ip", "=", "self", ".", "_get_real_ip", "(", ")", "try", ":", "geobase_entry", "=", "IpRange", ".", "objects", ".", "by_ip", "(", "ip", ")", "except", "IpRange", ".", "DoesNotExist", ":", "geobase_entry", "=...
Fetches IpRange instance if request IP is found in database. :param request: A ususal request object :type request: HttpRequest :return: IpRange object or None
[ "Fetches", "IpRange", "instance", "if", "request", "IP", "is", "found", "in", "database", "." ]
python
train
opencobra/cobrapy
cobra/core/model.py
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L1055-L1082
def optimize(self, objective_sense=None, raise_error=False): """ Optimize the model using flux balance analysis. Parameters ---------- objective_sense : {None, 'maximize' 'minimize'}, optional Whether fluxes should be maximized or minimized. In case of None, ...
[ "def", "optimize", "(", "self", ",", "objective_sense", "=", "None", ",", "raise_error", "=", "False", ")", ":", "original_direction", "=", "self", ".", "objective", ".", "direction", "self", ".", "objective", ".", "direction", "=", "{", "\"maximize\"", ":",...
Optimize the model using flux balance analysis. Parameters ---------- objective_sense : {None, 'maximize' 'minimize'}, optional Whether fluxes should be maximized or minimized. In case of None, the previous direction is used. raise_error : bool If tru...
[ "Optimize", "the", "model", "using", "flux", "balance", "analysis", "." ]
python
valid
FujiMakoto/AgentML
agentml/parser/trigger/condition/types/topic.py
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/trigger/condition/types/topic.py#L14-L33
def get(self, agentml, user=None, key=None): """ Evaluate and return the current active topic :param user: The active user object :type user: agentml.User or None :param agentml: The active AgentML instance :type agentml: AgentML :param key: The user id (defau...
[ "def", "get", "(", "self", ",", "agentml", ",", "user", "=", "None", ",", "key", "=", "None", ")", ":", "user", "=", "agentml", ".", "get_user", "(", "key", ")", "if", "key", "else", "user", "if", "not", "user", ":", "return", "return", "user", "...
Evaluate and return the current active topic :param user: The active user object :type user: agentml.User or None :param agentml: The active AgentML instance :type agentml: AgentML :param key: The user id (defaults to the current user if None) :type key: str ...
[ "Evaluate", "and", "return", "the", "current", "active", "topic", ":", "param", "user", ":", "The", "active", "user", "object", ":", "type", "user", ":", "agentml", ".", "User", "or", "None" ]
python
train
numenta/nupic
src/nupic/data/dict_utils.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/dict_utils.py#L128-L173
def dictDiff(da, db): """ Compares two python dictionaries at the top level and return differences da: first dictionary db: second dictionary Returns: None if dictionaries test equal; otherwise returns a dictionary as follows: { ...
[ "def", "dictDiff", "(", "da", ",", "db", ")", ":", "different", "=", "False", "resultDict", "=", "dict", "(", ")", "resultDict", "[", "'inAButNotInB'", "]", "=", "set", "(", "da", ")", "-", "set", "(", "db", ")", "if", "resultDict", "[", "'inAButNotI...
Compares two python dictionaries at the top level and return differences da: first dictionary db: second dictionary Returns: None if dictionaries test equal; otherwise returns a dictionary as follows: { 'inAButNotInB': ...
[ "Compares", "two", "python", "dictionaries", "at", "the", "top", "level", "and", "return", "differences" ]
python
valid
childsish/lhc-python
lhc/misc/performance_measures.py
https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/misc/performance_measures.py#L64-L79
def mcc(tp, tn, fp, fn): """ Matthew's Correlation Coefficient [-1, 1] 0 = you're just guessing :param int tp: number of true positives :param int tn: number of true negatives :param int fp: number of false positives :param int fn: number of false negatives :rtype: float """ ...
[ "def", "mcc", "(", "tp", ",", "tn", ",", "fp", ",", "fn", ")", ":", "if", "tp", "+", "fp", "==", "0", "or", "tp", "+", "fn", "==", "0", "or", "tn", "+", "fp", "==", "0", "or", "tn", "+", "fn", "==", "0", ":", "den", "=", "1.0", "else", ...
Matthew's Correlation Coefficient [-1, 1] 0 = you're just guessing :param int tp: number of true positives :param int tn: number of true negatives :param int fp: number of false positives :param int fn: number of false negatives :rtype: float
[ "Matthew", "s", "Correlation", "Coefficient", "[", "-", "1", "1", "]", "0", "=", "you", "re", "just", "guessing", ":", "param", "int", "tp", ":", "number", "of", "true", "positives", ":", "param", "int", "tn", ":", "number", "of", "true", "negatives", ...
python
train
pyQode/pyqode.core
pyqode/core/widgets/menu_recents.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/menu_recents.py#L34-L42
def remove(self, filename): """ Remove a file path from the list of recent files. :param filename: Path of the file to remove """ files = self.get_value('list', []) files.remove(filename) self.set_value('list', files) self.updated.emit()
[ "def", "remove", "(", "self", ",", "filename", ")", ":", "files", "=", "self", ".", "get_value", "(", "'list'", ",", "[", "]", ")", "files", ".", "remove", "(", "filename", ")", "self", ".", "set_value", "(", "'list'", ",", "files", ")", "self", "....
Remove a file path from the list of recent files. :param filename: Path of the file to remove
[ "Remove", "a", "file", "path", "from", "the", "list", "of", "recent", "files", ".", ":", "param", "filename", ":", "Path", "of", "the", "file", "to", "remove" ]
python
train
quodlibet/mutagen
mutagen/id3/_file.py
https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/id3/_file.py#L223-L274
def save(self, filething=None, v1=1, v2_version=4, v23_sep='/', padding=None): """save(filething=None, v1=1, v2_version=4, v23_sep='/', padding=None) Save changes to a file. Args: filething (filething): Filename to save the tag to. If no filename is giv...
[ "def", "save", "(", "self", ",", "filething", "=", "None", ",", "v1", "=", "1", ",", "v2_version", "=", "4", ",", "v23_sep", "=", "'/'", ",", "padding", "=", "None", ")", ":", "f", "=", "filething", ".", "fileobj", "try", ":", "header", "=", "ID3...
save(filething=None, v1=1, v2_version=4, v23_sep='/', padding=None) Save changes to a file. Args: filething (filething): Filename to save the tag to. If no filename is given, the one most recently loaded is used. v1 (ID3v1SaveOptions): ...
[ "save", "(", "filething", "=", "None", "v1", "=", "1", "v2_version", "=", "4", "v23_sep", "=", "/", "padding", "=", "None", ")" ]
python
train
numenta/nupic
src/nupic/algorithms/knn_classifier.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L309-L321
def removeIds(self, idsToRemove): """ There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. :param idsToRemove: A list of row indices to remove. """ # Form a list of all categories to remove rowsToRemove =...
[ "def", "removeIds", "(", "self", ",", "idsToRemove", ")", ":", "# Form a list of all categories to remove", "rowsToRemove", "=", "[", "k", "for", "k", ",", "rowID", "in", "enumerate", "(", "self", ".", "_categoryRecencyList", ")", "if", "rowID", "in", "idsToRemo...
There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. :param idsToRemove: A list of row indices to remove.
[ "There", "are", "two", "caveats", ".", "First", "this", "is", "a", "potentially", "slow", "operation", ".", "Second", "pattern", "indices", "will", "shift", "if", "patterns", "before", "them", "are", "removed", "." ]
python
valid
flying-sheep/smart-progress
smart_progress.py
https://github.com/flying-sheep/smart-progress/blob/1091a0a9cc2d7a6304f992d13cb718d5150a64c6/smart_progress.py#L58-L74
def progressbar( iterable=None, length=None, label=None, show_eta=True, show_percent=None, show_pos=False, item_show_func=None, fill_char='#', empty_char='-', bar_template='%(label)s [%(bar)s] %(info)s', info_sep=' ', width=36, file=None, color=None): """Create a progressbar that works in Jupyter/IPython noteb...
[ "def", "progressbar", "(", "iterable", "=", "None", ",", "length", "=", "None", ",", "label", "=", "None", ",", "show_eta", "=", "True", ",", "show_percent", "=", "None", ",", "show_pos", "=", "False", ",", "item_show_func", "=", "None", ",", "fill_char"...
Create a progressbar that works in Jupyter/IPython notebooks and the terminal
[ "Create", "a", "progressbar", "that", "works", "in", "Jupyter", "/", "IPython", "notebooks", "and", "the", "terminal" ]
python
train
basho/riak-python-client
riak/client/transport.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/transport.py#L76-L95
def retry_count(self, retries): """ retry_count(retries) Modifies the number of retries for the scope of the ``with`` statement (in the current thread). Example:: with client.retry_count(10): client.ping() """ if not isinstance(retri...
[ "def", "retry_count", "(", "self", ",", "retries", ")", ":", "if", "not", "isinstance", "(", "retries", ",", "int", ")", ":", "raise", "TypeError", "(", "\"retries must be an integer\"", ")", "old_retries", ",", "self", ".", "retries", "=", "self", ".", "r...
retry_count(retries) Modifies the number of retries for the scope of the ``with`` statement (in the current thread). Example:: with client.retry_count(10): client.ping()
[ "retry_count", "(", "retries", ")" ]
python
train
pandas-dev/pandas
pandas/io/pytables.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L975-L1055
def append_to_multiple(self, d, value, selector, data_columns=None, axes=None, dropna=False, **kwargs): """ Append to multiple tables Parameters ---------- d : a dict of table_name to table_columns, None is acceptable as the values of one n...
[ "def", "append_to_multiple", "(", "self", ",", "d", ",", "value", ",", "selector", ",", "data_columns", "=", "None", ",", "axes", "=", "None", ",", "dropna", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "axes", "is", "not", "None", ":", "...
Append to multiple tables Parameters ---------- d : a dict of table_name to table_columns, None is acceptable as the values of one node (this will get all the remaining columns) value : a pandas object selector : a string that designates the indexable table; all of i...
[ "Append", "to", "multiple", "tables" ]
python
train
ikegami-yukino/madoka-python
madoka/madoka.py
https://github.com/ikegami-yukino/madoka-python/blob/a9a1efecbc85ac4a24a78cbb19f9aed77b7162d3/madoka/madoka.py#L588-L597
def create(self, width=0, max_value=0, path=None, flags=0, seed=0): """Create new sketch Params: <int> width <int> max_value <str> path <int> flags <int> seed """ return _madoka.Sketch_create(self, width, max_value, path, flags,...
[ "def", "create", "(", "self", ",", "width", "=", "0", ",", "max_value", "=", "0", ",", "path", "=", "None", ",", "flags", "=", "0", ",", "seed", "=", "0", ")", ":", "return", "_madoka", ".", "Sketch_create", "(", "self", ",", "width", ",", "max_v...
Create new sketch Params: <int> width <int> max_value <str> path <int> flags <int> seed
[ "Create", "new", "sketch", "Params", ":", "<int", ">", "width", "<int", ">", "max_value", "<str", ">", "path", "<int", ">", "flags", "<int", ">", "seed" ]
python
train