repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
bfrog/whizzer
whizzer/rpc/picklerpc.py
https://github.com/bfrog/whizzer/blob/a1e43084b3ac8c1f3fb4ada081777cdbf791fd77/whizzer/rpc/picklerpc.py#L218-L221
def send_response(self, msgid, response): """Send a response.""" msg = dumps([2, msgid, response]) self.send(msg)
[ "def", "send_response", "(", "self", ",", "msgid", ",", "response", ")", ":", "msg", "=", "dumps", "(", "[", "2", ",", "msgid", ",", "response", "]", ")", "self", ".", "send", "(", "msg", ")" ]
Send a response.
[ "Send", "a", "response", "." ]
python
train
33.5
ungarj/mapchete
mapchete/_core.py
https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/_core.py#L642-L661
def open(self, input_id, **kwargs): """ Open input data. Parameters ---------- input_id : string input identifier from configuration file or file path kwargs : driver specific parameters (e.g. resampling) Returns ------- tiled input d...
[ "def", "open", "(", "self", ",", "input_id", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "input_id", ",", "str", ")", ":", "return", "input_id", ".", "open", "(", "self", ".", "tile", ",", "*", "*", "kwargs", ")", "if", "in...
Open input data. Parameters ---------- input_id : string input identifier from configuration file or file path kwargs : driver specific parameters (e.g. resampling) Returns ------- tiled input data : InputTile reprojected input data withi...
[ "Open", "input", "data", "." ]
python
valid
33.6
pytorch/text
torchtext/datasets/sequence_tagging.py
https://github.com/pytorch/text/blob/26bfce6869dc704f1d86792f9a681d453d7e7bb8/torchtext/datasets/sequence_tagging.py#L78-L103
def splits(cls, fields, root=".data", train="train.txt", test="test.txt", validation_frac=0.1, **kwargs): """Downloads and loads the CoNLL 2000 Chunking dataset. NOTE: There is only a train and test dataset so we use 10% of the train set as validation """ tr...
[ "def", "splits", "(", "cls", ",", "fields", ",", "root", "=", "\".data\"", ",", "train", "=", "\"train.txt\"", ",", "test", "=", "\"test.txt\"", ",", "validation_frac", "=", "0.1", ",", "*", "*", "kwargs", ")", ":", "train", ",", "test", "=", "super", ...
Downloads and loads the CoNLL 2000 Chunking dataset. NOTE: There is only a train and test dataset so we use 10% of the train set as validation
[ "Downloads", "and", "loads", "the", "CoNLL", "2000", "Chunking", "dataset", ".", "NOTE", ":", "There", "is", "only", "a", "train", "and", "test", "dataset", "so", "we", "use", "10%", "of", "the", "train", "set", "as", "validation" ]
python
train
36.153846
usc-isi-i2/etk
etk/data_extractors/htiExtractors/parser_helpers.py
https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/data_extractors/htiExtractors/parser_helpers.py#L70-L103
def clean_part_ethn(body): """ Prepare a string to be parsed for ethnicities. Returns a "translated" string (e.g. all instances of "china" converted to "chinese") """ # patterns that can create false positive situations patterns_to_remove = [r'black ?or ?african', r'african ?or ?black', r'no ?black', ...
[ "def", "clean_part_ethn", "(", "body", ")", ":", "# patterns that can create false positive situations", "patterns_to_remove", "=", "[", "r'black ?or ?african'", ",", "r'african ?or ?black'", ",", "r'no ?black'", ",", "r'no ?african'", ",", "r'no ?aa'", ",", "r'white ?men'", ...
Prepare a string to be parsed for ethnicities. Returns a "translated" string (e.g. all instances of "china" converted to "chinese")
[ "Prepare", "a", "string", "to", "be", "parsed", "for", "ethnicities", "." ]
python
train
36.911765
econ-ark/HARK
HARK/interpolation.py
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/interpolation.py#L2139-L2161
def derivativeZ(self,x,y,z): ''' Evaluate the first derivative with respect to z of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shap...
[ "def", "derivativeZ", "(", "self", ",", "x", ",", "y", ",", "z", ")", ":", "xShift", "=", "self", ".", "lowerBound", "(", "y", ")", "dfdz_out", "=", "self", ".", "func", ".", "derivativeZ", "(", "x", "-", "xShift", ",", "y", ",", "z", ")", "ret...
Evaluate the first derivative with respect to z of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. z : np.array Third i...
[ "Evaluate", "the", "first", "derivative", "with", "respect", "to", "z", "of", "the", "function", "at", "given", "state", "space", "points", "." ]
python
train
30.869565
tgbugs/pyontutils
ilxutils/ilxutils/interlex_sql.py
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_sql.py#L218-L240
def get_terms_complete(self) -> pd.DataFrame: ''' Gets complete entity data like term/view ''' if not self.terms_complete.empty: return self.terms_complete if self.from_backup: self.terms_complete = open_pickle(TERMS_COMPLETE_BACKUP_PATH) return self.terms_com...
[ "def", "get_terms_complete", "(", "self", ")", "->", "pd", ".", "DataFrame", ":", "if", "not", "self", ".", "terms_complete", ".", "empty", ":", "return", "self", ".", "terms_complete", "if", "self", ".", "from_backup", ":", "self", ".", "terms_complete", ...
Gets complete entity data like term/view
[ "Gets", "complete", "entity", "data", "like", "term", "/", "view" ]
python
train
51.391304
pudo/dataset
dataset/util.py
https://github.com/pudo/dataset/blob/a008d120c7f3c48ccba98a282c0c67d6e719c0e5/dataset/util.py#L76-L83
def normalize_table_name(name): """Check if the table name is obviously invalid.""" if not isinstance(name, six.string_types): raise ValueError("Invalid table name: %r" % name) name = name.strip()[:63] if not len(name): raise ValueError("Invalid table name: %r" % name) return name
[ "def", "normalize_table_name", "(", "name", ")", ":", "if", "not", "isinstance", "(", "name", ",", "six", ".", "string_types", ")", ":", "raise", "ValueError", "(", "\"Invalid table name: %r\"", "%", "name", ")", "name", "=", "name", ".", "strip", "(", ")"...
Check if the table name is obviously invalid.
[ "Check", "if", "the", "table", "name", "is", "obviously", "invalid", "." ]
python
train
38.75
pydsigner/pygu
pygu/pyslim.py
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyslim.py#L33-L42
def load(filename, default=None): ''' Try to load @filename. If there is no loader for @filename's filetype, return @default. ''' ext = get_ext(filename) if ext in ldict: return ldict[ext](filename) else: return default
[ "def", "load", "(", "filename", ",", "default", "=", "None", ")", ":", "ext", "=", "get_ext", "(", "filename", ")", "if", "ext", "in", "ldict", ":", "return", "ldict", "[", "ext", "]", "(", "filename", ")", "else", ":", "return", "default" ]
Try to load @filename. If there is no loader for @filename's filetype, return @default.
[ "Try", "to", "load" ]
python
train
25.5
bwohlberg/sporco
sporco/admm/cbpdntv.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/cbpdntv.py#L437-L444
def obfn_reg(self): """Compute regularisation term and contribution to objective function. """ rl1 = np.linalg.norm((self.Wl1 * self.obfn_g1var()).ravel(), 1) rtv = np.sum(np.sqrt(np.sum(self.obfn_g0var()**2, axis=-1))) return (self.lmbda*rl1 + self.mu*rtv, rl1, rtv)
[ "def", "obfn_reg", "(", "self", ")", ":", "rl1", "=", "np", ".", "linalg", ".", "norm", "(", "(", "self", ".", "Wl1", "*", "self", ".", "obfn_g1var", "(", ")", ")", ".", "ravel", "(", ")", ",", "1", ")", "rtv", "=", "np", ".", "sum", "(", "...
Compute regularisation term and contribution to objective function.
[ "Compute", "regularisation", "term", "and", "contribution", "to", "objective", "function", "." ]
python
train
38.625
pypa/pipenv
pipenv/patched/notpip/_vendor/ipaddress.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1307-L1320
def _string_from_ip_int(cls, ip_int): """Turns a 32-bit integer into dotted decimal notation. Args: ip_int: An integer, the IP address. Returns: The IP address as a string in dotted decimal notation. """ return '.'.join(_compat_str(struct.unpack(b'!B', ...
[ "def", "_string_from_ip_int", "(", "cls", ",", "ip_int", ")", ":", "return", "'.'", ".", "join", "(", "_compat_str", "(", "struct", ".", "unpack", "(", "b'!B'", ",", "b", ")", "[", "0", "]", "if", "isinstance", "(", "b", ",", "bytes", ")", "else", ...
Turns a 32-bit integer into dotted decimal notation. Args: ip_int: An integer, the IP address. Returns: The IP address as a string in dotted decimal notation.
[ "Turns", "a", "32", "-", "bit", "integer", "into", "dotted", "decimal", "notation", "." ]
python
train
34.642857
mwouts/jupytext
jupytext/contentsmanager.py
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L439-L468
def rename_file(self, old_path, new_path): """Rename the current notebook, as well as its alternative representations""" if old_path not in self.paired_notebooks: try: # we do not know yet if this is a paired notebook (#190) # -> to get this information we ope...
[ "def", "rename_file", "(", "self", ",", "old_path", ",", "new_path", ")", ":", "if", "old_path", "not", "in", "self", ".", "paired_notebooks", ":", "try", ":", "# we do not know yet if this is a paired notebook (#190)", "# -> to get this information we open the notebook", ...
Rename the current notebook, as well as its alternative representations
[ "Rename", "the", "current", "notebook", "as", "well", "as", "its", "alternative", "representations" ]
python
train
40.666667
quantmind/pulsar
pulsar/utils/system/winprocess.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/system/winprocess.py#L9-L37
def get_preparation_data(name): ''' Return info about parent needed by child to unpickle process object. Monkey-patch from ''' d = dict( name=name, sys_path=sys.path, sys_argv=sys.argv, log_to_stderr=_log_to_stderr, orig_dir=process.ORIGINAL_DIR, ...
[ "def", "get_preparation_data", "(", "name", ")", ":", "d", "=", "dict", "(", "name", "=", "name", ",", "sys_path", "=", "sys", ".", "path", ",", "sys_argv", "=", "sys", ".", "argv", ",", "log_to_stderr", "=", "_log_to_stderr", ",", "orig_dir", "=", "pr...
Return info about parent needed by child to unpickle process object. Monkey-patch from
[ "Return", "info", "about", "parent", "needed", "by", "child", "to", "unpickle", "process", "object", ".", "Monkey", "-", "patch", "from" ]
python
train
33.310345
leancloud/python-sdk
leancloud/query.py
https://github.com/leancloud/python-sdk/blob/fea3240257ce65e6a32c7312a5cee1f94a51a587/leancloud/query.py#L446-L458
def matches_query(self, key, query): """ 增加查询条件,限制查询结果对象指定字段的值,与另外一个查询对象的返回结果相同。 :param key: 查询条件字段名 :param query: 查询对象 :type query: Query :rtype: Query """ dumped = query.dump() dumped['className'] = query._query_class._class_name self._a...
[ "def", "matches_query", "(", "self", ",", "key", ",", "query", ")", ":", "dumped", "=", "query", ".", "dump", "(", ")", "dumped", "[", "'className'", "]", "=", "query", ".", "_query_class", ".", "_class_name", "self", ".", "_add_condition", "(", "key", ...
增加查询条件,限制查询结果对象指定字段的值,与另外一个查询对象的返回结果相同。 :param key: 查询条件字段名 :param query: 查询对象 :type query: Query :rtype: Query
[ "增加查询条件,限制查询结果对象指定字段的值,与另外一个查询对象的返回结果相同。" ]
python
train
28.076923
aio-libs/aiohttp
aiohttp/client_reqrep.py
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L956-L965
async def text(self, encoding: Optional[str]=None, errors: str='strict') -> str: """Read response payload and decode.""" if self._body is None: await self.read() if encoding is None: encoding = self.get_encoding() return self._body.decode(enco...
[ "async", "def", "text", "(", "self", ",", "encoding", ":", "Optional", "[", "str", "]", "=", "None", ",", "errors", ":", "str", "=", "'strict'", ")", "->", "str", ":", "if", "self", ".", "_body", "is", "None", ":", "await", "self", ".", "read", "...
Read response payload and decode.
[ "Read", "response", "payload", "and", "decode", "." ]
python
train
33.1
rodluger/everest
everest/user.py
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/user.py#L927-L938
def get_pipeline(self, *args, **kwargs): ''' Returns the `time` and `flux` arrays for the target obtained by a given pipeline. Options :py:obj:`args` and :py:obj:`kwargs` are passed directly to the :py:func:`pipelines.get` function of the mission. ''' return ge...
[ "def", "get_pipeline", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "getattr", "(", "missions", ",", "self", ".", "mission", ")", ".", "pipelines", ".", "get", "(", "self", ".", "ID", ",", "*", "args", ",", "*", "*"...
Returns the `time` and `flux` arrays for the target obtained by a given pipeline. Options :py:obj:`args` and :py:obj:`kwargs` are passed directly to the :py:func:`pipelines.get` function of the mission.
[ "Returns", "the", "time", "and", "flux", "arrays", "for", "the", "target", "obtained", "by", "a", "given", "pipeline", "." ]
python
train
36.583333
hyperledger/indy-plenum
plenum/server/replicas.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replicas.py#L138-L142
def _new_replica(self, instance_id: int, is_master: bool, bls_bft: BlsBft) -> Replica: """ Create a new replica with the specified parameters. """ return self._replica_class(self._node, instance_id, self._config, is_master, bls_bft, self._metrics)
[ "def", "_new_replica", "(", "self", ",", "instance_id", ":", "int", ",", "is_master", ":", "bool", ",", "bls_bft", ":", "BlsBft", ")", "->", "Replica", ":", "return", "self", ".", "_replica_class", "(", "self", ".", "_node", ",", "instance_id", ",", "sel...
Create a new replica with the specified parameters.
[ "Create", "a", "new", "replica", "with", "the", "specified", "parameters", "." ]
python
train
55
tdryer/hangups
hangups/event.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/event.py#L53-L59
async def fire(self, *args, **kwargs): """Fire this event, calling all observers with the same arguments.""" logger.debug('Fired {}'.format(self)) for observer in self._observers: gen = observer(*args, **kwargs) if asyncio.iscoroutinefunction(observer): aw...
[ "async", "def", "fire", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Fired {}'", ".", "format", "(", "self", ")", ")", "for", "observer", "in", "self", ".", "_observers", ":", "gen", "=", "observe...
Fire this event, calling all observers with the same arguments.
[ "Fire", "this", "event", "calling", "all", "observers", "with", "the", "same", "arguments", "." ]
python
valid
45.857143
klen/python-scss
scss/function.py
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/function.py#L349-L361
def _invert(color, **kwargs): """ Returns the inverse (negative) of a color. The red, green, and blue values are inverted, while the opacity is left alone. """ col = ColorValue(color) args = [ 255.0 - col.value[0], 255.0 - col.value[1], 255.0 - col.value[2], col.v...
[ "def", "_invert", "(", "color", ",", "*", "*", "kwargs", ")", ":", "col", "=", "ColorValue", "(", "color", ")", "args", "=", "[", "255.0", "-", "col", ".", "value", "[", "0", "]", ",", "255.0", "-", "col", ".", "value", "[", "1", "]", ",", "2...
Returns the inverse (negative) of a color. The red, green, and blue values are inverted, while the opacity is left alone.
[ "Returns", "the", "inverse", "(", "negative", ")", "of", "a", "color", ".", "The", "red", "green", "and", "blue", "values", "are", "inverted", "while", "the", "opacity", "is", "left", "alone", "." ]
python
train
28.769231
StackStorm/pybind
pybind/slxos/v17r_1_01a/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/__init__.py#L5825-L5846
def _set_mac_group(self, v, load=False): """ Setter method for mac_group, mapped from YANG variable /mac_group (list) If this variable is read-only (config: false) in the source YANG file, then _set_mac_group is considered as a private method. Backends looking to populate this variable should do...
[ "def", "_set_mac_group", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base...
Setter method for mac_group, mapped from YANG variable /mac_group (list) If this variable is read-only (config: false) in the source YANG file, then _set_mac_group is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_mac_group() directly.
[ "Setter", "method", "for", "mac_group", "mapped", "from", "YANG", "variable", "/", "mac_group", "(", "list", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "file", "then", "_set_...
python
train
119.272727
troeger/opensubmit
web/opensubmit/cmdline.py
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/cmdline.py#L183-L226
def check_web_config_consistency(config): ''' Check the web application config file for consistency. ''' login_conf_deps = { 'LOGIN_TWITTER_OAUTH_KEY': ['LOGIN_TWITTER_OAUTH_SECRET'], 'LOGIN_GOOGLE_OAUTH_KEY': ['LOGIN_GOOGLE_OAUTH_SECRET'], 'LOGIN_GITHUB_OAUTH_KEY': ['LOGIN_G...
[ "def", "check_web_config_consistency", "(", "config", ")", ":", "login_conf_deps", "=", "{", "'LOGIN_TWITTER_OAUTH_KEY'", ":", "[", "'LOGIN_TWITTER_OAUTH_SECRET'", "]", ",", "'LOGIN_GOOGLE_OAUTH_KEY'", ":", "[", "'LOGIN_GOOGLE_OAUTH_SECRET'", "]", ",", "'LOGIN_GITHUB_OAUTH_...
Check the web application config file for consistency.
[ "Check", "the", "web", "application", "config", "file", "for", "consistency", "." ]
python
train
52.090909
nerdvegas/rez
src/rez/vendor/pyparsing/pyparsing.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pyparsing/pyparsing.py#L3366-L3393
def _makeTags(tagStr, xml): """Internal helper to construct opening and closing tag expressions, given a tag name""" if isinstance(tagStr,basestring): resname = tagStr tagStr = Keyword(tagStr, caseless=not xml) else: resname = tagStr.name tagAttrName = Word(alphas,alphan...
[ "def", "_makeTags", "(", "tagStr", ",", "xml", ")", ":", "if", "isinstance", "(", "tagStr", ",", "basestring", ")", ":", "resname", "=", "tagStr", "tagStr", "=", "Keyword", "(", "tagStr", ",", "caseless", "=", "not", "xml", ")", "else", ":", "resname",...
Internal helper to construct opening and closing tag expressions, given a tag name
[ "Internal", "helper", "to", "construct", "opening", "and", "closing", "tag", "expressions", "given", "a", "tag", "name" ]
python
train
56.25
TheHive-Project/Cortex-Analyzers
analyzers/GreyNoise/greynoise.py
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/GreyNoise/greynoise.py#L62-L136
def summary(self, raw): """ Return one taxonomy summarizing the reported tags If there is only one tag, use it as the predicate If there are multiple tags, use "entries" as the predicate Use the total count as the value Use the most malicious level found ...
[ "def", "summary", "(", "self", ",", "raw", ")", ":", "try", ":", "taxonomies", "=", "[", "]", "if", "raw", ".", "get", "(", "'records'", ")", ":", "final_level", "=", "None", "taxonomy_data", "=", "defaultdict", "(", "int", ")", "for", "record", "in"...
Return one taxonomy summarizing the reported tags If there is only one tag, use it as the predicate If there are multiple tags, use "entries" as the predicate Use the total count as the value Use the most malicious level found Examples: Input {...
[ "Return", "one", "taxonomy", "summarizing", "the", "reported", "tags", "If", "there", "is", "only", "one", "tag", "use", "it", "as", "the", "predicate", "If", "there", "are", "multiple", "tags", "use", "entries", "as", "the", "predicate", "Use", "the", "to...
python
train
28.4
petl-developers/petl
petl/util/counting.py
https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/util/counting.py#L434-L466
def rowlengths(table): """ Report on row lengths found in the table. E.g.:: >>> import petl as etl >>> table = [['foo', 'bar', 'baz'], ... ['A', 1, 2], ... ['B', '2', '3.4'], ... [u'B', u'3', u'7.8', True], ... ['D', 'xyz', 9.0...
[ "def", "rowlengths", "(", "table", ")", ":", "counter", "=", "Counter", "(", ")", "for", "row", "in", "data", "(", "table", ")", ":", "counter", "[", "len", "(", "row", ")", "]", "+=", "1", "output", "=", "[", "(", "'length'", ",", "'count'", ")"...
Report on row lengths found in the table. E.g.:: >>> import petl as etl >>> table = [['foo', 'bar', 'baz'], ... ['A', 1, 2], ... ['B', '2', '3.4'], ... [u'B', u'3', u'7.8', True], ... ['D', 'xyz', 9.0], ... ['E', None]...
[ "Report", "on", "row", "lengths", "found", "in", "the", "table", ".", "E", ".", "g", ".", "::" ]
python
train
26.757576
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/spv.py
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L464-L486
def read_header_at( cls, f): """ Given an open file-like object, read a block header from it and return it as a dict containing: * version (int) * prev_block_hash (hex str) * merkle_root (hex str) * timestamp (int) * bits (int) * nonce (ini) ...
[ "def", "read_header_at", "(", "cls", ",", "f", ")", ":", "header_parser", "=", "BlockHeaderSerializer", "(", ")", "hdr", "=", "header_parser", ".", "deserialize", "(", "f", ")", "h", "=", "{", "}", "h", "[", "'version'", "]", "=", "hdr", ".", "version"...
Given an open file-like object, read a block header from it and return it as a dict containing: * version (int) * prev_block_hash (hex str) * merkle_root (hex str) * timestamp (int) * bits (int) * nonce (ini) * hash (hex str)
[ "Given", "an", "open", "file", "-", "like", "object", "read", "a", "block", "header", "from", "it", "and", "return", "it", "as", "a", "dict", "containing", ":", "*", "version", "(", "int", ")", "*", "prev_block_hash", "(", "hex", "str", ")", "*", "me...
python
train
32.043478
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/mavproxy.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/mavproxy.py#L259-L265
def cmd_status(args): '''show status''' if len(args) == 0: mpstate.status.show(sys.stdout, pattern=None) else: for pattern in args: mpstate.status.show(sys.stdout, pattern=pattern)
[ "def", "cmd_status", "(", "args", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "mpstate", ".", "status", ".", "show", "(", "sys", ".", "stdout", ",", "pattern", "=", "None", ")", "else", ":", "for", "pattern", "in", "args", ":", "mpst...
show status
[ "show", "status" ]
python
train
30.571429
graphql-python/graphql-core-next
graphql/type/schema.py
https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/type/schema.py#L264-L276
def type_map_directive_reducer( map_: TypeMap, directive: GraphQLDirective = None ) -> TypeMap: """Reducer function for creating the type map from given directives.""" # Directives are not validated until validate_schema() is called. if not is_directive(directive): return map_ directive = ca...
[ "def", "type_map_directive_reducer", "(", "map_", ":", "TypeMap", ",", "directive", ":", "GraphQLDirective", "=", "None", ")", "->", "TypeMap", ":", "# Directives are not validated until validate_schema() is called.", "if", "not", "is_directive", "(", "directive", ")", ...
Reducer function for creating the type map from given directives.
[ "Reducer", "function", "for", "creating", "the", "type", "map", "from", "given", "directives", "." ]
python
train
38.076923
pydsigner/taskit
taskit/frontend.py
https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L131-L150
def _package(self, task, *args, **kw): """ Used internally. Simply wraps the arguments up in a list and encodes the list. """ # Implementation note: it is faster to use a tuple than a list here, # because json does the list-like check like so (json/encoder.py:424): ...
[ "def", "_package", "(", "self", ",", "task", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "# Implementation note: it is faster to use a tuple than a list here, ", "# because json does the list-like check like so (json/encoder.py:424):", "# isinstance(o, (list, tuple))", "# ...
Used internally. Simply wraps the arguments up in a list and encodes the list.
[ "Used", "internally", ".", "Simply", "wraps", "the", "arguments", "up", "in", "a", "list", "and", "encodes", "the", "list", "." ]
python
train
49
barryp/py-amqplib
amqplib/client_0_8/serialization.py
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/serialization.py#L403-L409
def write_timestamp(self, v): """ Write out a Python datetime.datetime object as a 64-bit integer representing seconds since the Unix epoch. """ self.out.write(pack('>q', long(mktime(v.timetuple()))))
[ "def", "write_timestamp", "(", "self", ",", "v", ")", ":", "self", ".", "out", ".", "write", "(", "pack", "(", "'>q'", ",", "long", "(", "mktime", "(", "v", ".", "timetuple", "(", ")", ")", ")", ")", ")" ]
Write out a Python datetime.datetime object as a 64-bit integer representing seconds since the Unix epoch.
[ "Write", "out", "a", "Python", "datetime", ".", "datetime", "object", "as", "a", "64", "-", "bit", "integer", "representing", "seconds", "since", "the", "Unix", "epoch", "." ]
python
train
33.571429
NiklasRosenstein/myo-python
myo/utils.py
https://github.com/NiklasRosenstein/myo-python/blob/89a7480f8058061da7a3dd98ccec57a6b134ddf3/myo/utils.py#L37-L44
def check(self): """ Returns #True if the time interval has passed. """ if self.value is None: return True return (time.clock() - self.start) >= self.value
[ "def", "check", "(", "self", ")", ":", "if", "self", ".", "value", "is", "None", ":", "return", "True", "return", "(", "time", ".", "clock", "(", ")", "-", "self", ".", "start", ")", ">=", "self", ".", "value" ]
Returns #True if the time interval has passed.
[ "Returns", "#True", "if", "the", "time", "interval", "has", "passed", "." ]
python
train
21.875
jmwri/simplejwt
simplejwt/util.py
https://github.com/jmwri/simplejwt/blob/0828eaace0846918d2d202f5a60167a003e88b71/simplejwt/util.py#L29-L38
def to_bytes(data: Union[str, bytes]) -> bytes: """ :param data: Data to convert to bytes. :type data: Union[str, bytes] :return: `data` encoded to UTF8. :rtype: bytes """ if isinstance(data, bytes): return data return data.encode('utf-8')
[ "def", "to_bytes", "(", "data", ":", "Union", "[", "str", ",", "bytes", "]", ")", "->", "bytes", ":", "if", "isinstance", "(", "data", ",", "bytes", ")", ":", "return", "data", "return", "data", ".", "encode", "(", "'utf-8'", ")" ]
:param data: Data to convert to bytes. :type data: Union[str, bytes] :return: `data` encoded to UTF8. :rtype: bytes
[ ":", "param", "data", ":", "Data", "to", "convert", "to", "bytes", ".", ":", "type", "data", ":", "Union", "[", "str", "bytes", "]", ":", "return", ":", "data", "encoded", "to", "UTF8", ".", ":", "rtype", ":", "bytes" ]
python
valid
27
swimlane/swimlane-python
swimlane/core/fields/reference.py
https://github.com/swimlane/swimlane-python/blob/588fc503a76799bcdb5aecdf2f64a6ee05e3922d/swimlane/core/fields/reference.py#L47-L51
def add(self, record): """Add a reference to the provided record""" self._field.validate_value(record) self._elements[record.id] = record self._sync_field()
[ "def", "add", "(", "self", ",", "record", ")", ":", "self", ".", "_field", ".", "validate_value", "(", "record", ")", "self", ".", "_elements", "[", "record", ".", "id", "]", "=", "record", "self", ".", "_sync_field", "(", ")" ]
Add a reference to the provided record
[ "Add", "a", "reference", "to", "the", "provided", "record" ]
python
train
36.8
takuti/flurs
flurs/utils/feature_hash.py
https://github.com/takuti/flurs/blob/a998fc180b45db7eaf38dbbbf8125a93100b8a8c/flurs/utils/feature_hash.py#L5-L24
def n_feature_hash(feature, dims, seeds): """N-hot-encoded feature hashing. Args: feature (str): Target feature represented as string. dims (list of int): Number of dimensions for each hash value. seeds (list of float): Seed of each hash function (mmh3). Returns: numpy 1d a...
[ "def", "n_feature_hash", "(", "feature", ",", "dims", ",", "seeds", ")", ":", "vec", "=", "np", ".", "zeros", "(", "sum", "(", "dims", ")", ")", "offset", "=", "0", "for", "seed", ",", "dim", "in", "zip", "(", "seeds", ",", "dims", ")", ":", "v...
N-hot-encoded feature hashing. Args: feature (str): Target feature represented as string. dims (list of int): Number of dimensions for each hash value. seeds (list of float): Seed of each hash function (mmh3). Returns: numpy 1d array: n-hot-encoded feature vector for `s`.
[ "N", "-", "hot", "-", "encoded", "feature", "hashing", "." ]
python
train
27.3
raamana/pyradigm
pyradigm/pyradigm.py
https://github.com/raamana/pyradigm/blob/8ffb7958329c88b09417087b86887a3c92f438c2/pyradigm/pyradigm.py#L150-L176
def data_and_labels(self): """ Dataset features and labels in a matrix form for learning. Also returns sample_ids in the same order. Returns ------- data_matrix : ndarray 2D array of shape [num_samples, num_features] with features corresponding r...
[ "def", "data_and_labels", "(", "self", ")", ":", "sample_ids", "=", "np", ".", "array", "(", "self", ".", "keys", ")", "label_dict", "=", "self", ".", "labels", "matrix", "=", "np", ".", "full", "(", "[", "self", ".", "num_samples", ",", "self", ".",...
Dataset features and labels in a matrix form for learning. Also returns sample_ids in the same order. Returns ------- data_matrix : ndarray 2D array of shape [num_samples, num_features] with features corresponding row-wise to sample_ids labels : ndarray ...
[ "Dataset", "features", "and", "labels", "in", "a", "matrix", "form", "for", "learning", "." ]
python
train
33.185185
mozilla-services/amo2kinto
amo2kinto/exporter.py
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L88-L143
def write_addons_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the addons blocklists. <emItem blockID="i372" id="5nc3QHFgcb@r06Ws9gvNNVRfH.com"> <versionRange minVersion="0" maxVersion="*" severity="3"> <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"> ...
[ "def", "write_addons_items", "(", "xml_tree", ",", "records", ",", "app_id", ",", "api_ver", "=", "3", ",", "app_ver", "=", "None", ")", ":", "if", "not", "records", ":", "return", "emItems", "=", "etree", ".", "SubElement", "(", "xml_tree", ",", "'emIte...
Generate the addons blocklists. <emItem blockID="i372" id="5nc3QHFgcb@r06Ws9gvNNVRfH.com"> <versionRange minVersion="0" maxVersion="*" severity="3"> <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"> <versionRange minVersion="39.0a1" maxVersion="*"/> </targetApplication...
[ "Generate", "the", "addons", "blocklists", "." ]
python
train
43.142857
CyberReboot/vent
vent/menus/tools.py
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/menus/tools.py#L82-L202
def create(self, group_view=False): """ Update with current tools """ self.add_handlers({'^T': self.quit, '^Q': self.quit}) self.add(npyscreen.TitleText, name='Select which tools to ' + self.action['action'] + ':', editable=False) togglable = ['remove'] ...
[ "def", "create", "(", "self", ",", "group_view", "=", "False", ")", ":", "self", ".", "add_handlers", "(", "{", "'^T'", ":", "self", ".", "quit", ",", "'^Q'", ":", "self", ".", "quit", "}", ")", "self", ".", "add", "(", "npyscreen", ".", "TitleText...
Update with current tools
[ "Update", "with", "current", "tools" ]
python
train
47.909091
Gorialis/jishaku
jishaku/cog.py
https://github.com/Gorialis/jishaku/blob/fc7c479b9d510ede189a929c8aa6f7c8ef7f9a6e/jishaku/cog.py#L187-L196
async def jsk_show(self, ctx: commands.Context): """ Shows Jishaku in the help command. """ if not self.jsk.hidden: return await ctx.send("Jishaku is already visible.") self.jsk.hidden = False await ctx.send("Jishaku is now visible.")
[ "async", "def", "jsk_show", "(", "self", ",", "ctx", ":", "commands", ".", "Context", ")", ":", "if", "not", "self", ".", "jsk", ".", "hidden", ":", "return", "await", "ctx", ".", "send", "(", "\"Jishaku is already visible.\"", ")", "self", ".", "jsk", ...
Shows Jishaku in the help command.
[ "Shows", "Jishaku", "in", "the", "help", "command", "." ]
python
train
28.7
PMEAL/OpenPNM
openpnm/models/misc/misc.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/models/misc/misc.py#L207-L250
def weibull(target, seeds, shape, scale, loc): r""" Produces values from a Weibull distribution given a set of random numbers. Parameters ---------- target : OpenPNM Object The object which this model is associated with. This controls the length of the calculated array, and also pro...
[ "def", "weibull", "(", "target", ",", "seeds", ",", "shape", ",", "scale", ",", "loc", ")", ":", "seeds", "=", "target", "[", "seeds", "]", "value", "=", "spts", ".", "weibull_min", ".", "ppf", "(", "q", "=", "seeds", ",", "c", "=", "shape", ",",...
r""" Produces values from a Weibull distribution given a set of random numbers. Parameters ---------- target : OpenPNM Object The object which this model is associated with. This controls the length of the calculated array, and also provides access to other necessary properties....
[ "r", "Produces", "values", "from", "a", "Weibull", "distribution", "given", "a", "set", "of", "random", "numbers", "." ]
python
train
36.886364
CI-WATER/gsshapy
gsshapy/orm/snw.py
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/snw.py#L56-L87
def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile): """ NWSRFS Read from File Method """ # Set file extension property self.fileExtension = extension # Open file and parse with open(path, 'r') as nw...
[ "def", "_read", "(", "self", ",", "directory", ",", "filename", ",", "session", ",", "path", ",", "name", ",", "extension", ",", "spatial", ",", "spatialReferenceID", ",", "replaceParamFile", ")", ":", "# Set file extension property", "self", ".", "fileExtension...
NWSRFS Read from File Method
[ "NWSRFS", "Read", "from", "File", "Method" ]
python
train
42.78125
cloud9ers/gurumate
environment/share/doc/ipython/examples/parallel/pi/pidigits.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/share/doc/ipython/examples/parallel/pi/pidigits.py#L64-L70
def compute_n_digit_freqs(filename, n): """ Read digits of pi from a file and compute the n digit frequencies. """ d = txt_file_to_digits(filename) freqs = n_digit_freqs(d, n) return freqs
[ "def", "compute_n_digit_freqs", "(", "filename", ",", "n", ")", ":", "d", "=", "txt_file_to_digits", "(", "filename", ")", "freqs", "=", "n_digit_freqs", "(", "d", ",", "n", ")", "return", "freqs" ]
Read digits of pi from a file and compute the n digit frequencies.
[ "Read", "digits", "of", "pi", "from", "a", "file", "and", "compute", "the", "n", "digit", "frequencies", "." ]
python
test
29.428571
SandstoneHPC/sandstone-ide
sandstone/lib/filesystem/handlers.py
https://github.com/SandstoneHPC/sandstone-ide/blob/7a47947fb07281c3e3018042863dc67e7e56dc04/sandstone/lib/filesystem/handlers.py#L44-L54
def _copy(self): """ Called during a PUT request where the action specifies a copy operation. Returns resource URI of the new file. """ copypath = self.action['copypath'] try: self.fs.copy(self.fp,copypath) except OSError: raise tornado.web...
[ "def", "_copy", "(", "self", ")", ":", "copypath", "=", "self", ".", "action", "[", "'copypath'", "]", "try", ":", "self", ".", "fs", ".", "copy", "(", "self", ".", "fp", ",", "copypath", ")", "except", "OSError", ":", "raise", "tornado", ".", "web...
Called during a PUT request where the action specifies a copy operation. Returns resource URI of the new file.
[ "Called", "during", "a", "PUT", "request", "where", "the", "action", "specifies", "a", "copy", "operation", ".", "Returns", "resource", "URI", "of", "the", "new", "file", "." ]
python
train
31.727273
open-homeautomation/pknx
knxip/ip.py
https://github.com/open-homeautomation/pknx/blob/a8aed8271563923c447aa330ba7c1c2927286f7a/knxip/ip.py#L508-L548
def send_tunnelling_request(self, cemi, auto_connect=True): """Sends a tunneling request based on the given CEMI data. This method does not wait for an acknowledge or result frame. """ if not self.connected: if auto_connect: if not self.connect(): ...
[ "def", "send_tunnelling_request", "(", "self", ",", "cemi", ",", "auto_connect", "=", "True", ")", ":", "if", "not", "self", ".", "connected", ":", "if", "auto_connect", ":", "if", "not", "self", ".", "connect", "(", ")", ":", "raise", "KNXException", "(...
Sends a tunneling request based on the given CEMI data. This method does not wait for an acknowledge or result frame.
[ "Sends", "a", "tunneling", "request", "based", "on", "the", "given", "CEMI", "data", "." ]
python
train
37.219512
roycoding/slots
slots/slots.py
https://github.com/roycoding/slots/blob/1ed9b203fa02002c09b9dad73e2a97c04a45ef20/slots/slots.py#L330-L343
def est_payouts(self): ''' Calculate current estimate of average payout for each bandit. Returns ------- array of floats or None ''' if len(self.choices) < 1: print('slots: No trials run so far.') return None else: ret...
[ "def", "est_payouts", "(", "self", ")", ":", "if", "len", "(", "self", ".", "choices", ")", "<", "1", ":", "print", "(", "'slots: No trials run so far.'", ")", "return", "None", "else", ":", "return", "self", ".", "wins", "/", "(", "self", ".", "pulls"...
Calculate current estimate of average payout for each bandit. Returns ------- array of floats or None
[ "Calculate", "current", "estimate", "of", "average", "payout", "for", "each", "bandit", "." ]
python
train
24.071429
mokelly/wabbit_wappa
wabbit_wappa/__init__.py
https://github.com/mokelly/wabbit_wappa/blob/dfe5bf6d6036079e473c4148335cd6f339d0299b/wabbit_wappa/__init__.py#L116-L127
def add_feature(self, label, value=None): """ label: A VW label (not containing characters from escape_dict.keys(), unless 'escape' mode is on) value: float giving the weight or magnitude of this feature """ if self.escape: label = escape_vw_string(label) ...
[ "def", "add_feature", "(", "self", ",", "label", ",", "value", "=", "None", ")", ":", "if", "self", ".", "escape", ":", "label", "=", "escape_vw_string", "(", "label", ")", "elif", "self", ".", "validate", ":", "validate_vw_string", "(", "label", ")", ...
label: A VW label (not containing characters from escape_dict.keys(), unless 'escape' mode is on) value: float giving the weight or magnitude of this feature
[ "label", ":", "A", "VW", "label", "(", "not", "containing", "characters", "from", "escape_dict", ".", "keys", "()", "unless", "escape", "mode", "is", "on", ")", "value", ":", "float", "giving", "the", "weight", "or", "magnitude", "of", "this", "feature" ]
python
train
37.083333
djtaylor/python-lsbinit
lsbinit/pid.py
https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/pid.py#L43-L78
def ps(self): """ Get the process information from the system PS command. """ # Get the process ID pid = self.get() # Parent / child processes parent = None children = [] # If the process is running if pid: ...
[ "def", "ps", "(", "self", ")", ":", "# Get the process ID", "pid", "=", "self", ".", "get", "(", ")", "# Parent / child processes", "parent", "=", "None", "children", "=", "[", "]", "# If the process is running", "if", "pid", ":", "proc", "=", "Popen", "(", ...
Get the process information from the system PS command.
[ "Get", "the", "process", "information", "from", "the", "system", "PS", "command", "." ]
python
train
34.388889
askedrelic/libgreader
libgreader/googlereader.py
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/googlereader.py#L316-L324
def _clearLists(self): """ Clear all list before sync : feeds and categories """ self.feedsById = {} self.feeds = [] self.categoriesById = {} self.categories = [] self.orphanFeeds = []
[ "def", "_clearLists", "(", "self", ")", ":", "self", ".", "feedsById", "=", "{", "}", "self", ".", "feeds", "=", "[", "]", "self", ".", "categoriesById", "=", "{", "}", "self", ".", "categories", "=", "[", "]", "self", ".", "orphanFeeds", "=", "[",...
Clear all list before sync : feeds and categories
[ "Clear", "all", "list", "before", "sync", ":", "feeds", "and", "categories" ]
python
train
29
gbowerman/azurerm
docs/py2md.py
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/docs/py2md.py#L126-L162
def main(): '''Main routine.''' # validate command line arguments arg_parser = argparse.ArgumentParser() arg_parser.add_argument('--sourcedir', '-s', required=True, action='store', help='Source folder containing python files.') arg_parser.add_argument('--docfile', '-o', ...
[ "def", "main", "(", ")", ":", "# validate command line arguments", "arg_parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "arg_parser", ".", "add_argument", "(", "'--sourcedir'", ",", "'-s'", ",", "required", "=", "True", ",", "action", "=", "'store'", ...
Main routine.
[ "Main", "routine", "." ]
python
train
38.891892
aholkner/bacon
native/Vendor/FreeType/src/tools/docmaker/content.py
https://github.com/aholkner/bacon/blob/edf3810dcb211942d392a8637945871399b0650d/native/Vendor/FreeType/src/tools/docmaker/content.py#L353-L360
def set_section( self, section_name ): """set current section during parsing""" if not self.sections.has_key( section_name ): section = DocSection( section_name ) self.sections[section_name] = section self.section = section else: se...
[ "def", "set_section", "(", "self", ",", "section_name", ")", ":", "if", "not", "self", ".", "sections", ".", "has_key", "(", "section_name", ")", ":", "section", "=", "DocSection", "(", "section_name", ")", "self", ".", "sections", "[", "section_name", "]"...
set current section during parsing
[ "set", "current", "section", "during", "parsing" ]
python
test
44.125
uw-it-aca/uw-restclients-canvas
uw_canvas/accounts.py
https://github.com/uw-it-aca/uw-restclients-canvas/blob/9845faf33d49a8f06908efc22640c001116d6ea2/uw_canvas/accounts.py#L60-L69
def update_account(self, account): """ Update the passed account. Returns the updated account. https://canvas.instructure.com/doc/api/accounts.html#method.accounts.update """ url = ACCOUNTS_API.format(account.account_id) body = {"account": {"name": account.name}} ...
[ "def", "update_account", "(", "self", ",", "account", ")", ":", "url", "=", "ACCOUNTS_API", ".", "format", "(", "account", ".", "account_id", ")", "body", "=", "{", "\"account\"", ":", "{", "\"name\"", ":", "account", ".", "name", "}", "}", "return", "...
Update the passed account. Returns the updated account. https://canvas.instructure.com/doc/api/accounts.html#method.accounts.update
[ "Update", "the", "passed", "account", ".", "Returns", "the", "updated", "account", "." ]
python
test
36.9
sprockets/sprockets-influxdb
sprockets_influxdb.py
https://github.com/sprockets/sprockets-influxdb/blob/cce73481b8f26b02e65e3f9914a9a22eceff3063/sprockets_influxdb.py#L121-L130
def _get_path_pattern_tornado4(self): """Return the path pattern used when routing a request. (Tornado<4.5) :rtype: str """ for host, handlers in self.application.handlers: if host.match(self.request.host): for handler in handlers: if hand...
[ "def", "_get_path_pattern_tornado4", "(", "self", ")", ":", "for", "host", ",", "handlers", "in", "self", ".", "application", ".", "handlers", ":", "if", "host", ".", "match", "(", "self", ".", "request", ".", "host", ")", ":", "for", "handler", "in", ...
Return the path pattern used when routing a request. (Tornado<4.5) :rtype: str
[ "Return", "the", "path", "pattern", "used", "when", "routing", "a", "request", ".", "(", "Tornado<4", ".", "5", ")" ]
python
train
39.9
spyder-ide/spyder
spyder/utils/workers.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/workers.py#L243-L247
def _clean_workers(self): """Delete periodically workers in workers bag.""" while self._bag_collector: self._bag_collector.popleft() self._timer_worker_delete.stop()
[ "def", "_clean_workers", "(", "self", ")", ":", "while", "self", ".", "_bag_collector", ":", "self", ".", "_bag_collector", ".", "popleft", "(", ")", "self", ".", "_timer_worker_delete", ".", "stop", "(", ")" ]
Delete periodically workers in workers bag.
[ "Delete", "periodically", "workers", "in", "workers", "bag", "." ]
python
train
39.4
gem/oq-engine
openquake/server/db/actions.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L107-L120
def import_job(db, calc_id, calc_mode, description, user_name, status, hc_id, datadir): """ Insert a calculation inside the database, if calc_id is not taken """ job = dict(id=calc_id, calculation_mode=calc_mode, description=description, user_n...
[ "def", "import_job", "(", "db", ",", "calc_id", ",", "calc_mode", ",", "description", ",", "user_name", ",", "status", ",", "hc_id", ",", "datadir", ")", ":", "job", "=", "dict", "(", "id", "=", "calc_id", ",", "calculation_mode", "=", "calc_mode", ",", ...
Insert a calculation inside the database, if calc_id is not taken
[ "Insert", "a", "calculation", "inside", "the", "database", "if", "calc_id", "is", "not", "taken" ]
python
train
40.642857
pyviz/holoviews
holoviews/ipython/archive.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/ipython/archive.py#L101-L111
def get_namespace(self): """ Find the name the user is using to access holoviews. """ if 'holoviews' not in sys.modules: raise ImportError('HoloViews does not seem to be imported') matches = [k for k,v in get_ipython().user_ns.items() # noqa (get_ipython) i...
[ "def", "get_namespace", "(", "self", ")", ":", "if", "'holoviews'", "not", "in", "sys", ".", "modules", ":", "raise", "ImportError", "(", "'HoloViews does not seem to be imported'", ")", "matches", "=", "[", "k", "for", "k", ",", "v", "in", "get_ipython", "(...
Find the name the user is using to access holoviews.
[ "Find", "the", "name", "the", "user", "is", "using", "to", "access", "holoviews", "." ]
python
train
46.818182
dstufft/crust
crust/query.py
https://github.com/dstufft/crust/blob/5d4011ecace12fd3f68a03a17dbefb78390a9fc0/crust/query.py#L101-L132
def results(self, limit=100): """ Yields the results from the API, efficiently handling the pagination and properly passing all paramaters. """ limited = True if self.high_mark is not None else False rmax = self.high_mark - self.low_mark if limited else None rnum ...
[ "def", "results", "(", "self", ",", "limit", "=", "100", ")", ":", "limited", "=", "True", "if", "self", ".", "high_mark", "is", "not", "None", "else", "False", "rmax", "=", "self", ".", "high_mark", "-", "self", ".", "low_mark", "if", "limited", "el...
Yields the results from the API, efficiently handling the pagination and properly passing all paramaters.
[ "Yields", "the", "results", "from", "the", "API", "efficiently", "handling", "the", "pagination", "and", "properly", "passing", "all", "paramaters", "." ]
python
train
35.9375
numberoverzero/bloop
bloop/stream/shard.py
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/stream/shard.py#L175-L204
def seek_to(self, position): """Move the Shard's iterator to the earliest record after the :class:`~datetime.datetime` time. Returns the first records at or past ``position``. If the list is empty, the seek failed to find records, either because the Shard is exhausted or it reached the...
[ "def", "seek_to", "(", "self", ",", "position", ")", ":", "# 0) We have no way to associate the date with a position,", "# so we have to scan the shard from the beginning.", "self", ".", "jump_to", "(", "iterator_type", "=", "\"trim_horizon\"", ")", "position", "=", "int",...
Move the Shard's iterator to the earliest record after the :class:`~datetime.datetime` time. Returns the first records at or past ``position``. If the list is empty, the seek failed to find records, either because the Shard is exhausted or it reached the HEAD of an open Shard. :param ...
[ "Move", "the", "Shard", "s", "iterator", "to", "the", "earliest", "record", "after", "the", ":", "class", ":", "~datetime", ".", "datetime", "time", "." ]
python
train
49.3
odlgroup/odl
odl/solvers/functional/default_functionals.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/solvers/functional/default_functionals.py#L310-L324
def proximal(self): """Return the ``proximal factory`` of the functional. See Also -------- odl.solvers.nonsmooth.proximal_operators.proximal_l1 : `proximal factory` for the L1-norm. """ if self.pointwise_norm.exponent == 1: return proximal_l1(spa...
[ "def", "proximal", "(", "self", ")", ":", "if", "self", ".", "pointwise_norm", ".", "exponent", "==", "1", ":", "return", "proximal_l1", "(", "space", "=", "self", ".", "domain", ")", "elif", "self", ".", "pointwise_norm", ".", "exponent", "==", "2", "...
Return the ``proximal factory`` of the functional. See Also -------- odl.solvers.nonsmooth.proximal_operators.proximal_l1 : `proximal factory` for the L1-norm.
[ "Return", "the", "proximal", "factory", "of", "the", "functional", "." ]
python
train
37.4
slacy/minimongo
minimongo/collection.py
https://github.com/slacy/minimongo/blob/29f38994831163b17bc625c82258068f1f90efa5/minimongo/collection.py#L44-L48
def find(self, *args, **kwargs): """Same as :meth:`pymongo.collection.Collection.find`, except it returns the right document class. """ return Cursor(self, *args, wrap=self.document_class, **kwargs)
[ "def", "find", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "Cursor", "(", "self", ",", "*", "args", ",", "wrap", "=", "self", ".", "document_class", ",", "*", "*", "kwargs", ")" ]
Same as :meth:`pymongo.collection.Collection.find`, except it returns the right document class.
[ "Same", "as", ":", "meth", ":", "pymongo", ".", "collection", ".", "Collection", ".", "find", "except", "it", "returns", "the", "right", "document", "class", "." ]
python
test
45.2
justquick/django-native-tags
native_tags/contrib/_markup.py
https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/_markup.py#L7-L19
def textile(text, **kwargs): """ Applies Textile conversion to a string, and returns the HTML. This is simply a pass-through to the ``textile`` template filter included in ``django.contrib.markup``, which works around issues PyTextile has with Unicode strings. If you're not using Django but ...
[ "def", "textile", "(", "text", ",", "*", "*", "kwargs", ")", ":", "from", "django", ".", "contrib", ".", "markup", ".", "templatetags", ".", "markup", "import", "textile", "return", "textile", "(", "text", ")" ]
Applies Textile conversion to a string, and returns the HTML. This is simply a pass-through to the ``textile`` template filter included in ``django.contrib.markup``, which works around issues PyTextile has with Unicode strings. If you're not using Django but want to use Textile with ``MarkupFormatt...
[ "Applies", "Textile", "conversion", "to", "a", "string", "and", "returns", "the", "HTML", ".", "This", "is", "simply", "a", "pass", "-", "through", "to", "the", "textile", "template", "filter", "included", "in", "django", ".", "contrib", ".", "markup", "wh...
python
train
39.153846
wavycloud/pyboto3
pyboto3/rds.py
https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/rds.py#L5541-L5638
def describe_reserved_db_instances_offerings(ReservedDBInstancesOfferingId=None, DBInstanceClass=None, Duration=None, ProductDescription=None, OfferingType=None, MultiAZ=None, Filters=None, MaxRecords=None, Marker=None): """ Lists available reserved DB instance offerings. See also: AWS API Documentation ...
[ "def", "describe_reserved_db_instances_offerings", "(", "ReservedDBInstancesOfferingId", "=", "None", ",", "DBInstanceClass", "=", "None", ",", "Duration", "=", "None", ",", "ProductDescription", "=", "None", ",", "OfferingType", "=", "None", ",", "MultiAZ", "=", "N...
Lists available reserved DB instance offerings. See also: AWS API Documentation Examples This example lists information for all reserved DB instance offerings for the specified DB instance class, duration, product, offering type, and availability zone settings. Expected Output: :example: r...
[ "Lists", "available", "reserved", "DB", "instance", "offerings", ".", "See", "also", ":", "AWS", "API", "Documentation", "Examples", "This", "example", "lists", "information", "for", "all", "reserved", "DB", "instance", "offerings", "for", "the", "specified", "D...
python
train
41.714286
opencobra/cobrapy
cobra/io/mat.py
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L94-L117
def save_matlab_model(model, file_name, varname=None): """Save the cobra model as a .mat file. This .mat file can be used directly in the MATLAB version of COBRA. Parameters ---------- model : cobra.core.Model.Model object The model to save file_name : str or file-like object T...
[ "def", "save_matlab_model", "(", "model", ",", "file_name", ",", "varname", "=", "None", ")", ":", "if", "not", "scipy_io", ":", "raise", "ImportError", "(", "'load_matlab_model requires scipy'", ")", "if", "varname", "is", "None", ":", "varname", "=", "str", ...
Save the cobra model as a .mat file. This .mat file can be used directly in the MATLAB version of COBRA. Parameters ---------- model : cobra.core.Model.Model object The model to save file_name : str or file-like object The file to save to varname : string The name of the...
[ "Save", "the", "cobra", "model", "as", "a", ".", "mat", "file", "." ]
python
valid
32.041667
apache/spark
python/pyspark/rdd.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L635-L689
def sortByKey(self, ascending=True, numPartitions=None, keyfunc=lambda x: x): """ Sorts this RDD, which is assumed to consist of (key, value) pairs. >>> tmp = [('a', 1), ('b', 2), ('1', 3), ('d', 4), ('2', 5)] >>> sc.parallelize(tmp).sortByKey().first() ('1', 3) >>> sc.p...
[ "def", "sortByKey", "(", "self", ",", "ascending", "=", "True", ",", "numPartitions", "=", "None", ",", "keyfunc", "=", "lambda", "x", ":", "x", ")", ":", "if", "numPartitions", "is", "None", ":", "numPartitions", "=", "self", ".", "_defaultReducePartition...
Sorts this RDD, which is assumed to consist of (key, value) pairs. >>> tmp = [('a', 1), ('b', 2), ('1', 3), ('d', 4), ('2', 5)] >>> sc.parallelize(tmp).sortByKey().first() ('1', 3) >>> sc.parallelize(tmp).sortByKey(True, 1).collect() [('1', 3), ('2', 5), ('a', 1), ('b', 2), ('d'...
[ "Sorts", "this", "RDD", "which", "is", "assumed", "to", "consist", "of", "(", "key", "value", ")", "pairs", "." ]
python
train
45.745455
blockstack/blockstack-core
blockstack/lib/nameset/virtualchain_hooks.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/virtualchain_hooks.py#L559-L573
def db_continue( block_id, consensus_hash ): """ (required by virtualchain state engine) Called when virtualchain has synchronized all state for this block. Blockstack uses this as a preemption point where it can safely exit if the user has so requested. """ # every so often, clean up ...
[ "def", "db_continue", "(", "block_id", ",", "consensus_hash", ")", ":", "# every so often, clean up", "if", "(", "block_id", "%", "20", ")", "==", "0", ":", "log", ".", "debug", "(", "\"Pre-emptive garbage collection at %s\"", "%", "block_id", ")", "gc", ".", ...
(required by virtualchain state engine) Called when virtualchain has synchronized all state for this block. Blockstack uses this as a preemption point where it can safely exit if the user has so requested.
[ "(", "required", "by", "virtualchain", "state", "engine", ")" ]
python
train
32.666667
admiralobvious/vyper
vyper/vyper.py
https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L713-L729
def debug(self): # pragma: no cover """Prints all configuration registries for debugging purposes.""" print("Aliases:") pprint.pprint(self._aliases) print("Override:") pprint.pprint(self._override) print("Args:") pprint.pprint(self._args) print("Env:") ...
[ "def", "debug", "(", "self", ")", ":", "# pragma: no cover", "print", "(", "\"Aliases:\"", ")", "pprint", ".", "pprint", "(", "self", ".", "_aliases", ")", "print", "(", "\"Override:\"", ")", "pprint", ".", "pprint", "(", "self", ".", "_override", ")", "...
Prints all configuration registries for debugging purposes.
[ "Prints", "all", "configuration", "registries", "for", "debugging", "purposes", "." ]
python
train
31.294118
inveniosoftware/invenio-rest
invenio_rest/views.py
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L140-L156
def _match_serializers_by_query_arg(self, serializers): """Match serializer by query arg.""" # if the format query argument is present, match the serializer arg_name = current_app.config.get('REST_MIMETYPE_QUERY_ARG_NAME') if arg_name: arg_value = request.args.get(arg_name, N...
[ "def", "_match_serializers_by_query_arg", "(", "self", ",", "serializers", ")", ":", "# if the format query argument is present, match the serializer", "arg_name", "=", "current_app", ".", "config", ".", "get", "(", "'REST_MIMETYPE_QUERY_ARG_NAME'", ")", "if", "arg_name", "...
Match serializer by query arg.
[ "Match", "serializer", "by", "query", "arg", "." ]
python
train
39.117647
OSSOS/MOP
src/ossos/core/ossos/coding.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/coding.py#L17-L41
def encode(number, alphabet): """ Converts an integer to a base n string where n is the length of the provided alphabet. Modified from http://en.wikipedia.org/wiki/Base_36 """ if not isinstance(number, (int, long)): raise TypeError("Number must be an integer.") base_n = "" sign...
[ "def", "encode", "(", "number", ",", "alphabet", ")", ":", "if", "not", "isinstance", "(", "number", ",", "(", "int", ",", "long", ")", ")", ":", "raise", "TypeError", "(", "\"Number must be an integer.\"", ")", "base_n", "=", "\"\"", "sign", "=", "\"\""...
Converts an integer to a base n string where n is the length of the provided alphabet. Modified from http://en.wikipedia.org/wiki/Base_36
[ "Converts", "an", "integer", "to", "a", "base", "n", "string", "where", "n", "is", "the", "length", "of", "the", "provided", "alphabet", "." ]
python
train
23.16
saltstack/salt
salt/modules/vsphere.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L7255-L7307
def get_vm_config_file(name, datacenter, placement, datastore, service_instance=None): ''' Queries the virtual machine config file and returns vim.host.DatastoreBrowser.SearchResults object on success None on failure name Name of the virtual machine datacenter ...
[ "def", "get_vm_config_file", "(", "name", ",", "datacenter", ",", "placement", ",", "datastore", ",", "service_instance", "=", "None", ")", ":", "browser_spec", "=", "vim", ".", "host", ".", "DatastoreBrowser", ".", "SearchSpec", "(", ")", "directory", "=", ...
Queries the virtual machine config file and returns vim.host.DatastoreBrowser.SearchResults object on success None on failure name Name of the virtual machine datacenter Datacenter name datastore Datastore where the virtual machine files are stored service_instance ...
[ "Queries", "the", "virtual", "machine", "config", "file", "and", "returns", "vim", ".", "host", ".", "DatastoreBrowser", ".", "SearchResults", "object", "on", "success", "None", "on", "failure" ]
python
train
38.867925
tensorflow/tensorboard
tensorboard/notebook.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/notebook.py#L38-L74
def _get_context(): """Determine the most specific context that we're in. Returns: _CONTEXT_COLAB: If in Colab with an IPython notebook context. _CONTEXT_IPYTHON: If not in Colab, but we are in an IPython notebook context (e.g., from running `jupyter notebook` at the command line). _CONTEXT...
[ "def", "_get_context", "(", ")", ":", "# In Colab, the `google.colab` module is available, but the shell", "# returned by `IPython.get_ipython` does not have a `get_trait`", "# method.", "try", ":", "import", "google", ".", "colab", "import", "IPython", "except", "ImportError", "...
Determine the most specific context that we're in. Returns: _CONTEXT_COLAB: If in Colab with an IPython notebook context. _CONTEXT_IPYTHON: If not in Colab, but we are in an IPython notebook context (e.g., from running `jupyter notebook` at the command line). _CONTEXT_NONE: Otherwise (e.g., b...
[ "Determine", "the", "most", "specific", "context", "that", "we", "re", "in", "." ]
python
train
31.513514
msmbuilder/msmbuilder
msmbuilder/msm/core.py
https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/msm/core.py#L29-L87
def partial_transform(self, sequence, mode='clip'): """Transform a sequence to internal indexing Recall that `sequence` can be arbitrary labels, whereas ``transmat_`` and ``countsmat_`` are indexed with integers between 0 and ``n_states - 1``. This methods maps a set of sequences from t...
[ "def", "partial_transform", "(", "self", ",", "sequence", ",", "mode", "=", "'clip'", ")", ":", "if", "mode", "not", "in", "[", "'clip'", ",", "'fill'", "]", ":", "raise", "ValueError", "(", "'mode must be one of [\"clip\", \"fill\"]: %s'", "%", "mode", ")", ...
Transform a sequence to internal indexing Recall that `sequence` can be arbitrary labels, whereas ``transmat_`` and ``countsmat_`` are indexed with integers between 0 and ``n_states - 1``. This methods maps a set of sequences from the labels onto this internal indexing. Paramet...
[ "Transform", "a", "sequence", "to", "internal", "indexing" ]
python
train
39.79661
Opentrons/opentrons
api/src/opentrons/legacy_api/instruments/pipette.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/legacy_api/instruments/pipette.py#L680-L721
def blow_out(self, location=None): """ Force any remaining liquid to dispense, by moving this pipette's plunger to the calibrated `blow_out` position Notes ----- If no `location` is passed, the pipette will blow_out from it's current position. Parameters...
[ "def", "blow_out", "(", "self", ",", "location", "=", "None", ")", ":", "if", "not", "self", ".", "tip_attached", ":", "log", ".", "warning", "(", "\"Cannot 'blow out' without a tip attached.\"", ")", "self", ".", "move_to", "(", "location", ")", "self", "."...
Force any remaining liquid to dispense, by moving this pipette's plunger to the calibrated `blow_out` position Notes ----- If no `location` is passed, the pipette will blow_out from it's current position. Parameters ---------- location : :any:`Placeable`...
[ "Force", "any", "remaining", "liquid", "to", "dispense", "by", "moving", "this", "pipette", "s", "plunger", "to", "the", "calibrated", "blow_out", "position" ]
python
train
32.52381
hyperledger/indy-sdk
wrappers/python/indy/crypto.py
https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/crypto.py#L199-L253
async def auth_crypt(wallet_handle: int, sender_vk: str, recipient_vk: str, msg: bytes) -> bytes: """ **** THIS FUNCTION WILL BE DEPRECATED USE pack_message INSTEAD **** Encrypt a message by authenticated-encryption scheme. Sender can encr...
[ "async", "def", "auth_crypt", "(", "wallet_handle", ":", "int", ",", "sender_vk", ":", "str", ",", "recipient_vk", ":", "str", ",", "msg", ":", "bytes", ")", "->", "bytes", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ...
**** THIS FUNCTION WILL BE DEPRECATED USE pack_message INSTEAD **** Encrypt a message by authenticated-encryption scheme. Sender can encrypt a confidential message specifically for Recipient, using Sender's public key. Using Recipient's public key, Sender can compute a shared secret key. Using Sender'...
[ "****", "THIS", "FUNCTION", "WILL", "BE", "DEPRECATED", "USE", "pack_message", "INSTEAD", "****" ]
python
train
40.509091
bioidiap/gridtk
gridtk/models.py
https://github.com/bioidiap/gridtk/blob/9e3291b8b50388682908927231b2730db1da147d/gridtk/models.py#L111-L124
def submit(self, new_queue = None): """Sets the status of this job to 'submitted'.""" self.status = 'submitted' self.result = None self.machine_name = None if new_queue is not None: self.queue_name = new_queue for array_job in self.array: array_job.status = 'submitted' array_jo...
[ "def", "submit", "(", "self", ",", "new_queue", "=", "None", ")", ":", "self", ".", "status", "=", "'submitted'", "self", ".", "result", "=", "None", "self", ".", "machine_name", "=", "None", "if", "new_queue", "is", "not", "None", ":", "self", ".", ...
Sets the status of this job to 'submitted'.
[ "Sets", "the", "status", "of", "this", "job", "to", "submitted", "." ]
python
train
32.214286
project-rig/rig
rig/bitfield.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/bitfield.py#L350-L394
def _select_by_field_or_tag(self, tag=None, field=None): """For internal use only. Returns an OrderedDict of {identifier: field} representing fields which match the supplied field/tag. Parameters ---------- tag : str Optionally specifies that the mask should only inc...
[ "def", "_select_by_field_or_tag", "(", "self", ",", "tag", "=", "None", ",", "field", "=", "None", ")", ":", "# Get the set of fields whose values will be included in the value", "if", "field", "is", "not", "None", ":", "# Select just the specified field (checking the field...
For internal use only. Returns an OrderedDict of {identifier: field} representing fields which match the supplied field/tag. Parameters ---------- tag : str Optionally specifies that the mask should only include fields with the specified tag. field : str ...
[ "For", "internal", "use", "only", ".", "Returns", "an", "OrderedDict", "of", "{", "identifier", ":", "field", "}", "representing", "fields", "which", "match", "the", "supplied", "field", "/", "tag", "." ]
python
train
42.422222
IdentityPython/pysaml2
src/saml2/sigver.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/sigver.py#L325-L349
def make_temp(string, suffix='', decode=True, delete=True): """ xmlsec needs files in some cases where only strings exist, hence the need for this function. It creates a temporary file with the string as only content. :param string: The information to be placed in the file :param suffix: The tempor...
[ "def", "make_temp", "(", "string", ",", "suffix", "=", "''", ",", "decode", "=", "True", ",", "delete", "=", "True", ")", ":", "ntf", "=", "NamedTemporaryFile", "(", "suffix", "=", "suffix", ",", "delete", "=", "delete", ")", "# Python3 tempfile requires b...
xmlsec needs files in some cases where only strings exist, hence the need for this function. It creates a temporary file with the string as only content. :param string: The information to be placed in the file :param suffix: The temporary file might have to have a specific suffix in certain cir...
[ "xmlsec", "needs", "files", "in", "some", "cases", "where", "only", "strings", "exist", "hence", "the", "need", "for", "this", "function", ".", "It", "creates", "a", "temporary", "file", "with", "the", "string", "as", "only", "content", "." ]
python
train
41.04
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L801-L820
def remove_profile(self): """Remove the current profile. Make sure the user is sure. """ profile_name = self.profile_combo.currentText() # noinspection PyTypeChecker button_selected = QMessageBox.warning( None, 'Remove Profile', self.t...
[ "def", "remove_profile", "(", "self", ")", ":", "profile_name", "=", "self", ".", "profile_combo", ".", "currentText", "(", ")", "# noinspection PyTypeChecker", "button_selected", "=", "QMessageBox", ".", "warning", "(", "None", ",", "'Remove Profile'", ",", "self...
Remove the current profile. Make sure the user is sure.
[ "Remove", "the", "current", "profile", "." ]
python
train
34.05
lambdalisue/django-roughpages
src/roughpages/views.py
https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/views.py#L50-L61
def render_roughpage(request, t): """ Internal interface to the rough page view. """ import django if django.VERSION >= (1, 8): c = {} response = HttpResponse(t.render(c, request)) else: c = RequestContext(request) response = HttpResponse(t.render(c)) return r...
[ "def", "render_roughpage", "(", "request", ",", "t", ")", ":", "import", "django", "if", "django", ".", "VERSION", ">=", "(", "1", ",", "8", ")", ":", "c", "=", "{", "}", "response", "=", "HttpResponse", "(", "t", ".", "render", "(", "c", ",", "r...
Internal interface to the rough page view.
[ "Internal", "interface", "to", "the", "rough", "page", "view", "." ]
python
train
26.333333
MycroftAI/mycroft-precise
precise/scripts/train_generated.py
https://github.com/MycroftAI/mycroft-precise/blob/e17cebdd171906dbd8a16e282d8a7966fba2eeba/precise/scripts/train_generated.py#L116-L120
def layer_with(self, sample: np.ndarray, value: int) -> np.ndarray: """Create an identical 2d array where the second row is filled with value""" b = np.full((2, len(sample)), value, dtype=float) b[0] = sample return b
[ "def", "layer_with", "(", "self", ",", "sample", ":", "np", ".", "ndarray", ",", "value", ":", "int", ")", "->", "np", ".", "ndarray", ":", "b", "=", "np", ".", "full", "(", "(", "2", ",", "len", "(", "sample", ")", ")", ",", "value", ",", "d...
Create an identical 2d array where the second row is filled with value
[ "Create", "an", "identical", "2d", "array", "where", "the", "second", "row", "is", "filled", "with", "value" ]
python
train
49
LonamiWebs/Telethon
telethon/tl/custom/inlineresult.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/inlineresult.py#L69-L76
def url(self): """ The URL present in this inline results. If you want to "click" this URL to open it in your browser, you should use Python's `webbrowser.open(url)` for such task. """ if isinstance(self.result, types.BotInlineResult): return self.result.url
[ "def", "url", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "result", ",", "types", ".", "BotInlineResult", ")", ":", "return", "self", ".", "result", ".", "url" ]
The URL present in this inline results. If you want to "click" this URL to open it in your browser, you should use Python's `webbrowser.open(url)` for such task.
[ "The", "URL", "present", "in", "this", "inline", "results", ".", "If", "you", "want", "to", "click", "this", "URL", "to", "open", "it", "in", "your", "browser", "you", "should", "use", "Python", "s", "webbrowser", ".", "open", "(", "url", ")", "for", ...
python
train
38.875
bcbio/bcbio-nextgen
bcbio/structural/seq2c.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/seq2c.py#L290-L309
def _combine_coverages(items, work_dir, input_backs=None): """Combine coverage cnns calculated for individual inputs into single file. Optionally moves over pre-calculated coverage samples from a background file. """ out_file = os.path.join(work_dir, "sample_coverages.txt") if not utils.file_exists...
[ "def", "_combine_coverages", "(", "items", ",", "work_dir", ",", "input_backs", "=", "None", ")", ":", "out_file", "=", "os", ".", "path", ".", "join", "(", "work_dir", ",", "\"sample_coverages.txt\"", ")", "if", "not", "utils", ".", "file_exists", "(", "o...
Combine coverage cnns calculated for individual inputs into single file. Optionally moves over pre-calculated coverage samples from a background file.
[ "Combine", "coverage", "cnns", "calculated", "for", "individual", "inputs", "into", "single", "file", "." ]
python
train
48.25
pennersr/django-allauth
allauth/socialaccount/providers/mailchimp/provider.py
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/mailchimp/provider.py#L35-L45
def extract_common_fields(self, data): """Extract fields from a metadata query.""" return dict( dc=data.get('dc'), role=data.get('role'), account_name=data.get('accountname'), user_id=data.get('user_id'), login=data.get('login'), lo...
[ "def", "extract_common_fields", "(", "self", ",", "data", ")", ":", "return", "dict", "(", "dc", "=", "data", ".", "get", "(", "'dc'", ")", ",", "role", "=", "data", ".", "get", "(", "'role'", ")", ",", "account_name", "=", "data", ".", "get", "(",...
Extract fields from a metadata query.
[ "Extract", "fields", "from", "a", "metadata", "query", "." ]
python
train
36.454545
yyuu/botornado
botornado/s3/key.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/botornado/s3/key.py#L317-L402
def set_contents_from_stream(self, fp, headers=None, replace=True, cb=None, num_cb=10, policy=None, reduced_redundancy=False, query_args=None, callback=None): """ Store an object using the name of the Key object as the key in clou...
[ "def", "set_contents_from_stream", "(", "self", ",", "fp", ",", "headers", "=", "None", ",", "replace", "=", "True", ",", "cb", "=", "None", ",", "num_cb", "=", "10", ",", "policy", "=", "None", ",", "reduced_redundancy", "=", "False", ",", "query_args",...
Store an object using the name of the Key object as the key in cloud and the contents of the data stream pointed to by 'fp' as the contents. The stream object is not seekable and total size is not known. This has the implication that we can't specify the Content-Size and Content-...
[ "Store", "an", "object", "using", "the", "name", "of", "the", "Key", "object", "as", "the", "key", "in", "cloud", "and", "the", "contents", "of", "the", "data", "stream", "pointed", "to", "by", "fp", "as", "the", "contents", ".", "The", "stream", "obje...
python
train
46.348837
openstates/billy
billy/importers/names.py
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/names.py#L120-L131
def _normalize(self, name): """ Normalizes a legislator name by stripping titles from the front, converting to lowercase and removing punctuation. """ name = re.sub( r'^(Senator|Representative|Sen\.?|Rep\.?|' 'Hon\.?|Right Hon\.?|Mr\.?|Mrs\.?|Ms\.?|L\'hon\...
[ "def", "_normalize", "(", "self", ",", "name", ")", ":", "name", "=", "re", ".", "sub", "(", "r'^(Senator|Representative|Sen\\.?|Rep\\.?|'", "'Hon\\.?|Right Hon\\.?|Mr\\.?|Mrs\\.?|Ms\\.?|L\\'hon\\.?|'", "'Assembly(member|man|woman)) '", ",", "''", ",", "name", ")", "retur...
Normalizes a legislator name by stripping titles from the front, converting to lowercase and removing punctuation.
[ "Normalizes", "a", "legislator", "name", "by", "stripping", "titles", "from", "the", "front", "converting", "to", "lowercase", "and", "removing", "punctuation", "." ]
python
train
37
Capitains/MyCapytain
MyCapytain/resources/texts/local/capitains/cts.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/texts/local/capitains/cts.py#L111-L145
def _getSimplePassage(self, reference=None): """ Retrieve a single node representing the passage. .. warning:: Range support is awkward. :param reference: Identifier of the subreference / passages :type reference: list, reference :returns: Asked passage :rtype: Capitain...
[ "def", "_getSimplePassage", "(", "self", ",", "reference", "=", "None", ")", ":", "if", "reference", "is", "None", ":", "return", "_SimplePassage", "(", "resource", "=", "self", ".", "resource", ",", "reference", "=", "None", ",", "urn", "=", "self", "."...
Retrieve a single node representing the passage. .. warning:: Range support is awkward. :param reference: Identifier of the subreference / passages :type reference: list, reference :returns: Asked passage :rtype: CapitainsCtsPassage
[ "Retrieve", "a", "single", "node", "representing", "the", "passage", "." ]
python
train
28.771429
MolSSI-BSE/basis_set_exchange
basis_set_exchange/converters/turbomole.py
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/converters/turbomole.py#L8-L86
def write_turbomole(basis): '''Converts a basis set to Gaussian format ''' s = '$basis\n' s += '*\n' # TM basis sets are completely uncontracted basis = manip.uncontract_general(basis, True) basis = manip.uncontract_spdf(basis, 0, False) basis = sort.sort_basis(basis, False) # Ele...
[ "def", "write_turbomole", "(", "basis", ")", ":", "s", "=", "'$basis\\n'", "s", "+=", "'*\\n'", "# TM basis sets are completely uncontracted", "basis", "=", "manip", ".", "uncontract_general", "(", "basis", ",", "True", ")", "basis", "=", "manip", ".", "uncontra...
Converts a basis set to Gaussian format
[ "Converts", "a", "basis", "set", "to", "Gaussian", "format" ]
python
train
35.43038
MDAnalysis/GridDataFormats
gridData/OpenDX.py
https://github.com/MDAnalysis/GridDataFormats/blob/3eeb0432f8cf856912436e4f3e7aba99d3c916be/gridData/OpenDX.py#L486-L495
def read(self,file): """Read DX field from file. dx = OpenDX.field.read(dxfile) The classid is discarded and replaced with the one from the file. """ DXfield = self p = DXParser(file) p.parse(DXfield)
[ "def", "read", "(", "self", ",", "file", ")", ":", "DXfield", "=", "self", "p", "=", "DXParser", "(", "file", ")", "p", ".", "parse", "(", "DXfield", ")" ]
Read DX field from file. dx = OpenDX.field.read(dxfile) The classid is discarded and replaced with the one from the file.
[ "Read", "DX", "field", "from", "file", "." ]
python
valid
25.3
wdbm/shijian
shijian.py
https://github.com/wdbm/shijian/blob/ad6aea877e1eb99fe148127ea185f39f1413ed4f/shijian.py#L1723-L1738
def add_rolling_statistics_variables( df = None, variable = None, window = 20, upper_factor = 2, lower_factor = 2 ): """ Add rolling statistics variables derived from a specified variable in a DataFrame. """ df[variable + "_rolling_mean"] = p...
[ "def", "add_rolling_statistics_variables", "(", "df", "=", "None", ",", "variable", "=", "None", ",", "window", "=", "20", ",", "upper_factor", "=", "2", ",", "lower_factor", "=", "2", ")", ":", "df", "[", "variable", "+", "\"_rolling_mean\"", "]", "=", ...
Add rolling statistics variables derived from a specified variable in a DataFrame.
[ "Add", "rolling", "statistics", "variables", "derived", "from", "a", "specified", "variable", "in", "a", "DataFrame", "." ]
python
train
47.4375
nerdvegas/rez
src/rez/solver.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L2125-L2135
def get_fail_graph(self, failure_index=None): """Returns a graph showing a solve failure. Args: failure_index: See `failure_reason` Returns: A pygraph.digraph object. """ phase, _ = self._get_failed_phase(failure_index) return phase.get_graph()
[ "def", "get_fail_graph", "(", "self", ",", "failure_index", "=", "None", ")", ":", "phase", ",", "_", "=", "self", ".", "_get_failed_phase", "(", "failure_index", ")", "return", "phase", ".", "get_graph", "(", ")" ]
Returns a graph showing a solve failure. Args: failure_index: See `failure_reason` Returns: A pygraph.digraph object.
[ "Returns", "a", "graph", "showing", "a", "solve", "failure", "." ]
python
train
28
dswah/pyGAM
pygam/pygam.py
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/pygam.py#L1375-L1456
def generate_X_grid(self, term, n=100, meshgrid=False): """create a nice grid of X data array is sorted by feature and uniformly spaced, so the marginal and joint distributions are likely wrong if term is >= 0, we generate n samples per feature, which results in n^deg samples, ...
[ "def", "generate_X_grid", "(", "self", ",", "term", ",", "n", "=", "100", ",", "meshgrid", "=", "False", ")", ":", "if", "not", "self", ".", "_is_fitted", ":", "raise", "AttributeError", "(", "'GAM has not been fitted. Call fit first.'", ")", "# cant do Intercep...
create a nice grid of X data array is sorted by feature and uniformly spaced, so the marginal and joint distributions are likely wrong if term is >= 0, we generate n samples per feature, which results in n^deg samples, where deg is the degree of the interaction of the term ...
[ "create", "a", "nice", "grid", "of", "X", "data" ]
python
train
33.378049
decryptus/httpdis
httpdis/httpdis.py
https://github.com/decryptus/httpdis/blob/5d198cdc5558f416634602689b3df2c8aeb34984/httpdis/httpdis.py#L489-L523
def send_error_explain(self, code, message=None, headers=None, content_type=None): "do not use directly" if headers is None: headers = {} if code in self.responses: if message is None: message = self.responses[code][0] explain = self.response...
[ "def", "send_error_explain", "(", "self", ",", "code", ",", "message", "=", "None", ",", "headers", "=", "None", ",", "content_type", "=", "None", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "{", "}", "if", "code", "in", "self", "."...
do not use directly
[ "do", "not", "use", "directly" ]
python
train
29.2
ray-project/ray
python/ray/autoscaler/commands.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L160-L283
def get_or_create_head_node(config, config_file, no_restart, restart_only, yes, override_cluster_name): """Create the cluster head node, which in turn creates the workers.""" provider = get_node_provider(config["provider"], config["cluster_name"]) try: head_node_tags = { ...
[ "def", "get_or_create_head_node", "(", "config", ",", "config_file", ",", "no_restart", ",", "restart_only", ",", "yes", ",", "override_cluster_name", ")", ":", "provider", "=", "get_node_provider", "(", "config", "[", "\"provider\"", "]", ",", "config", "[", "\...
Create the cluster head node, which in turn creates the workers.
[ "Create", "the", "cluster", "head", "node", "which", "in", "turn", "creates", "the", "workers", "." ]
python
train
42.782258
zero-os/0-core
client/py-client/zeroos/core0/client/client.py
https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1987-L1998
def subvol_delete(self, path): """ Delete a btrfs subvolume in the specified path :param path: path to delete """ args = { 'path': path } self._subvol_chk.check(args) self._client.sync('btrfs.subvol_delete', args)
[ "def", "subvol_delete", "(", "self", ",", "path", ")", ":", "args", "=", "{", "'path'", ":", "path", "}", "self", ".", "_subvol_chk", ".", "check", "(", "args", ")", "self", ".", "_client", ".", "sync", "(", "'btrfs.subvol_delete'", ",", "args", ")" ]
Delete a btrfs subvolume in the specified path :param path: path to delete
[ "Delete", "a", "btrfs", "subvolume", "in", "the", "specified", "path", ":", "param", "path", ":", "path", "to", "delete" ]
python
train
23.333333
django-extensions/django-extensions
django_extensions/management/utils.py
https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/utils.py#L9-L21
def _make_writeable(filename): """ Make sure that the file is writeable. Useful if our source is read-only. """ import stat if sys.platform.startswith('java'): # On Jython there is no os.access() return if not os.access(filename, os.W_OK): st = os.stat(filename) ...
[ "def", "_make_writeable", "(", "filename", ")", ":", "import", "stat", "if", "sys", ".", "platform", ".", "startswith", "(", "'java'", ")", ":", "# On Jython there is no os.access()", "return", "if", "not", "os", ".", "access", "(", "filename", ",", "os", "....
Make sure that the file is writeable. Useful if our source is read-only.
[ "Make", "sure", "that", "the", "file", "is", "writeable", ".", "Useful", "if", "our", "source", "is", "read", "-", "only", "." ]
python
train
31.692308
angr/angr
angr/project.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L447-L460
def hooked_by(self, addr): """ Returns the current hook for `addr`. :param addr: An address. :returns: None if the address is not hooked. """ if not self.is_hooked(addr): l.warning("Address %s is not hooked", self._addr_to_str(addr)) return N...
[ "def", "hooked_by", "(", "self", ",", "addr", ")", ":", "if", "not", "self", ".", "is_hooked", "(", "addr", ")", ":", "l", ".", "warning", "(", "\"Address %s is not hooked\"", ",", "self", ".", "_addr_to_str", "(", "addr", ")", ")", "return", "None", "...
Returns the current hook for `addr`. :param addr: An address. :returns: None if the address is not hooked.
[ "Returns", "the", "current", "hook", "for", "addr", "." ]
python
train
25.214286
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_image.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_image.py#L254-L259
def image_coordinates(self, point): '''given a point in window coordinates, calculate image coordinates''' # the dragpos is the top left position in image coordinates ret = wx.Point(int(self.dragpos.x + point.x/self.zoom), int(self.dragpos.y + point.y/self.zoom)) r...
[ "def", "image_coordinates", "(", "self", ",", "point", ")", ":", "# the dragpos is the top left position in image coordinates", "ret", "=", "wx", ".", "Point", "(", "int", "(", "self", ".", "dragpos", ".", "x", "+", "point", ".", "x", "/", "self", ".", "zoom...
given a point in window coordinates, calculate image coordinates
[ "given", "a", "point", "in", "window", "coordinates", "calculate", "image", "coordinates" ]
python
train
54
saltstack/salt
salt/utils/dictupdate.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dictupdate.py#L305-L340
def extend_dict_key_value( in_dict, keys, value, delimiter=DEFAULT_TARGET_DELIM, ordered_dict=False): ''' Ensures that in_dict contains the series of recursive keys defined in keys. Also extends the list, that is at the end of `in_dict` traversed with `keys`, with...
[ "def", "extend_dict_key_value", "(", "in_dict", ",", "keys", ",", "value", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ",", "ordered_dict", "=", "False", ")", ":", "dict_pointer", ",", "last_key", "=", "_dict_rpartition", "(", "in_dict", ",", "keys", ",", "...
Ensures that in_dict contains the series of recursive keys defined in keys. Also extends the list, that is at the end of `in_dict` traversed with `keys`, with `value`. :param dict in_dict: The dictionary to work with :param str keys: The delimited string with one or more keys. :param any value: The...
[ "Ensures", "that", "in_dict", "contains", "the", "series", "of", "recursive", "keys", "defined", "in", "keys", ".", "Also", "extends", "the", "list", "that", "is", "at", "the", "end", "of", "in_dict", "traversed", "with", "keys", "with", "value", "." ]
python
train
39.833333
h2oai/h2o-3
h2o-py/h2o/h2o.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/h2o.py#L310-L363
def upload_file(path, destination_frame=None, header=0, sep=None, col_names=None, col_types=None, na_strings=None, skipped_columns=None): """ Upload a dataset from the provided local path to the H2O cluster. Does a single-threaded push to H2O. Also see :meth:`import_file`. :param path:...
[ "def", "upload_file", "(", "path", ",", "destination_frame", "=", "None", ",", "header", "=", "0", ",", "sep", "=", "None", ",", "col_names", "=", "None", ",", "col_types", "=", "None", ",", "na_strings", "=", "None", ",", "skipped_columns", "=", "None",...
Upload a dataset from the provided local path to the H2O cluster. Does a single-threaded push to H2O. Also see :meth:`import_file`. :param path: A path specifying the location of the data to upload. :param destination_frame: The unique hex key assigned to the imported file. If none is given, a key will ...
[ "Upload", "a", "dataset", "from", "the", "provided", "local", "path", "to", "the", "H2O", "cluster", "." ]
python
test
60.574074
Crypto-toolbox/bitex
bitex/api/WSS/bitstamp.py
https://github.com/Crypto-toolbox/bitex/blob/56d46ea3db6de5219a72dad9b052fbabc921232f/bitex/api/WSS/bitstamp.py#L243-L257
def _register_live_trades_channels(self): """ Registers the binding for the live_trades_channels channels. :return: """ channels = {'live_trades': self.btcusd_lt_callback, 'live_trades_btceur': self.btceur_lt_callback, 'live_trades_eurusd'...
[ "def", "_register_live_trades_channels", "(", "self", ")", ":", "channels", "=", "{", "'live_trades'", ":", "self", ".", "btcusd_lt_callback", ",", "'live_trades_btceur'", ":", "self", ".", "btceur_lt_callback", ",", "'live_trades_eurusd'", ":", "self", ".", "eurusd...
Registers the binding for the live_trades_channels channels. :return:
[ "Registers", "the", "binding", "for", "the", "live_trades_channels", "channels", ".", ":", "return", ":" ]
python
train
40.2
mieubrisse/wunderpy2
wunderpy2/endpoint_helpers.py
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/endpoint_helpers.py#L1-L4
def get_endpoint_obj(client, endpoint, object_id): ''' Tiny helper function that gets used all over the place to join the object ID to the endpoint and run a GET request, returning the result ''' endpoint = '/'.join([endpoint, str(object_id)]) return client.authenticated_request(endpoint).json()
[ "def", "get_endpoint_obj", "(", "client", ",", "endpoint", ",", "object_id", ")", ":", "endpoint", "=", "'/'", ".", "join", "(", "[", "endpoint", ",", "str", "(", "object_id", ")", "]", ")", "return", "client", ".", "authenticated_request", "(", "endpoint"...
Tiny helper function that gets used all over the place to join the object ID to the endpoint and run a GET request, returning the result
[ "Tiny", "helper", "function", "that", "gets", "used", "all", "over", "the", "place", "to", "join", "the", "object", "ID", "to", "the", "endpoint", "and", "run", "a", "GET", "request", "returning", "the", "result" ]
python
train
76.25
googleapis/google-cloud-python
websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_client.py#L105-L111
def scan_config_path(cls, project, scan_config): """Return a fully-qualified scan_config string.""" return google.api_core.path_template.expand( "projects/{project}/scanConfigs/{scan_config}", project=project, scan_config=scan_config, )
[ "def", "scan_config_path", "(", "cls", ",", "project", ",", "scan_config", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "\"projects/{project}/scanConfigs/{scan_config}\"", ",", "project", "=", "project", ",", "scan_config"...
Return a fully-qualified scan_config string.
[ "Return", "a", "fully", "-", "qualified", "scan_config", "string", "." ]
python
train
41.428571
xiyouMc/ncmbot
ncmbot/core.py
https://github.com/xiyouMc/ncmbot/blob/c4832f3ee7630ba104a89559f09c1fc366d1547b/ncmbot/core.py#L305-L320
def user_follows(uid, offset='0', limit=30): """获取用户关注列表 :param uid: 用户的ID,可通过登录或者其他接口获取 :param offset: (optional) 分段起始位置,默认 0 :param limit: (optional) 数据上限多少行,默认 30 """ if uid is None: raise ParamsError() r = NCloudBot() r.method = 'USER_FOLLOWS' r.params = {'uid': uid} ...
[ "def", "user_follows", "(", "uid", ",", "offset", "=", "'0'", ",", "limit", "=", "30", ")", ":", "if", "uid", "is", "None", ":", "raise", "ParamsError", "(", ")", "r", "=", "NCloudBot", "(", ")", "r", ".", "method", "=", "'USER_FOLLOWS'", "r", ".",...
获取用户关注列表 :param uid: 用户的ID,可通过登录或者其他接口获取 :param offset: (optional) 分段起始位置,默认 0 :param limit: (optional) 数据上限多少行,默认 30
[ "获取用户关注列表" ]
python
train
25
Kortemme-Lab/klab
klab/bio/pdb.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdb.py#L1376-L1540
def _get_ATOM_sequences(self): '''Creates the ATOM Sequences.''' # Get a list of all residues with ATOM or HETATM records atom_sequences = {} structural_residue_IDs_set = set() # use a set for a quicker lookup ignore_HETATMs = True # todo: fix this if we need to deal with HETATM...
[ "def", "_get_ATOM_sequences", "(", "self", ")", ":", "# Get a list of all residues with ATOM or HETATM records", "atom_sequences", "=", "{", "}", "structural_residue_IDs_set", "=", "set", "(", ")", "# use a set for a quicker lookup", "ignore_HETATMs", "=", "True", "# todo: fi...
Creates the ATOM Sequences.
[ "Creates", "the", "ATOM", "Sequences", "." ]
python
train
50.636364
dddomodossola/remi
remi/gui.py
https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/gui.py#L2365-L2375
def new_from_list(cls, content, fill_title=True, **kwargs): """Populates the Table with a list of tuples of strings. Args: content (list): list of tuples of strings. Each tuple is a row. fill_title (bool): if true, the first tuple in the list will be set as title...
[ "def", "new_from_list", "(", "cls", ",", "content", ",", "fill_title", "=", "True", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "cls", "(", "*", "*", "kwargs", ")", "obj", ".", "append_from_list", "(", "content", ",", "fill_title", ")", "return", ...
Populates the Table with a list of tuples of strings. Args: content (list): list of tuples of strings. Each tuple is a row. fill_title (bool): if true, the first tuple in the list will be set as title
[ "Populates", "the", "Table", "with", "a", "list", "of", "tuples", "of", "strings", "." ]
python
train
38.090909