repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
mar10/pyftpsync
ftpsync/targets.py
https://github.com/mar10/pyftpsync/blob/bbdc94186975cdc1cc4f678474bdce08bce7bb76/ftpsync/targets.py#L172-L176
def get_options_dict(self): """Return options from synchronizer (possibly overridden by own extra_opts).""" d = self.synchronizer.options if self.synchronizer else {} d.update(self.extra_opts) return d
[ "def", "get_options_dict", "(", "self", ")", ":", "d", "=", "self", ".", "synchronizer", ".", "options", "if", "self", ".", "synchronizer", "else", "{", "}", "d", ".", "update", "(", "self", ".", "extra_opts", ")", "return", "d" ]
Return options from synchronizer (possibly overridden by own extra_opts).
[ "Return", "options", "from", "synchronizer", "(", "possibly", "overridden", "by", "own", "extra_opts", ")", "." ]
python
train
pokerregion/poker
poker/commands.py
https://github.com/pokerregion/poker/blob/2d8cf208fdf2b26bdc935972dcbe7a983a9e9768/poker/commands.py#L100-L119
def p5list(num): """List pocketfives ranked players, max 100 if no NUM, or NUM if specified.""" from .website.pocketfives import get_ranked_players format_str = '{:>4.4} {!s:<15.13}{!s:<18.15}{!s:<9.6}{!s:<10.7}'\ '{!s:<14.11}{!s:<12.9}{!s:<12.9}{!s:<12.9}{!s:<4.4}' click.echo(form...
[ "def", "p5list", "(", "num", ")", ":", "from", ".", "website", ".", "pocketfives", "import", "get_ranked_players", "format_str", "=", "'{:>4.4} {!s:<15.13}{!s:<18.15}{!s:<9.6}{!s:<10.7}'", "'{!s:<14.11}{!s:<12.9}{!s:<12.9}{!s:<12.9}{!s:<4.4}'", "click", ".", "echo", "(", ...
List pocketfives ranked players, max 100 if no NUM, or NUM if specified.
[ "List", "pocketfives", "ranked", "players", "max", "100", "if", "no", "NUM", "or", "NUM", "if", "specified", "." ]
python
train
django-ses/django-ses
django_ses/utils.py
https://github.com/django-ses/django-ses/blob/2f0fd8e3fdc76d3512982c0bb8e2f6e93e09fa3c/django_ses/utils.py#L117-L136
def _get_cert_url(self): """ Get the signing certificate URL. Only accept urls that match the domains set in the AWS_SNS_BOUNCE_CERT_TRUSTED_DOMAINS setting. Sub-domains are allowed. i.e. if amazonaws.com is in the trusted domains then sns.us-east-1.amazonaws.com will mat...
[ "def", "_get_cert_url", "(", "self", ")", ":", "cert_url", "=", "self", ".", "_data", ".", "get", "(", "'SigningCertURL'", ")", "if", "cert_url", ":", "if", "cert_url", ".", "startswith", "(", "'https://'", ")", ":", "url_obj", "=", "urlparse", "(", "cer...
Get the signing certificate URL. Only accept urls that match the domains set in the AWS_SNS_BOUNCE_CERT_TRUSTED_DOMAINS setting. Sub-domains are allowed. i.e. if amazonaws.com is in the trusted domains then sns.us-east-1.amazonaws.com will match.
[ "Get", "the", "signing", "certificate", "URL", ".", "Only", "accept", "urls", "that", "match", "the", "domains", "set", "in", "the", "AWS_SNS_BOUNCE_CERT_TRUSTED_DOMAINS", "setting", ".", "Sub", "-", "domains", "are", "allowed", ".", "i", ".", "e", ".", "if"...
python
train
pylast/pylast
src/pylast/__init__.py
https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L1334-L1346
def get_tags(self): """Returns a list of the tags set by the user to this object.""" # Uncacheable because it can be dynamically changed by the user. params = self._get_params() doc = self._request(self.ws_prefix + ".getTags", False, params) tag_names = _extract_all(doc, "name"...
[ "def", "get_tags", "(", "self", ")", ":", "# Uncacheable because it can be dynamically changed by the user.", "params", "=", "self", ".", "_get_params", "(", ")", "doc", "=", "self", ".", "_request", "(", "self", ".", "ws_prefix", "+", "\".getTags\"", ",", "False"...
Returns a list of the tags set by the user to this object.
[ "Returns", "a", "list", "of", "the", "tags", "set", "by", "the", "user", "to", "this", "object", "." ]
python
train
thespacedoctor/sherlock
sherlock/transient_catalogue_crossmatch.py
https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_catalogue_crossmatch.py#L88-L262
def match(self): """ *match the transients against the sherlock-catalogues according to the search algorithm and return matches alongside the predicted classification(s)* **Return:** - ``classification`` -- the crossmatch results and classifications assigned to the transients ...
[ "def", "match", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "'starting the ``match`` method'", ")", "classifications", "=", "[", "]", "# COUNT NUMBER OF TRANSIENT TO CROSSMATCH", "numberOfTransients", "=", "len", "(", "self", ".", "transients", "...
*match the transients against the sherlock-catalogues according to the search algorithm and return matches alongside the predicted classification(s)* **Return:** - ``classification`` -- the crossmatch results and classifications assigned to the transients See the class docstring for usage....
[ "*", "match", "the", "transients", "against", "the", "sherlock", "-", "catalogues", "according", "to", "the", "search", "algorithm", "and", "return", "matches", "alongside", "the", "predicted", "classification", "(", "s", ")", "*" ]
python
train
mixer/beam-interactive-python
beam_interactive/proto/rw.py
https://github.com/mixer/beam-interactive-python/blob/e035bc45515dea9315b77648a24b5ae8685aa5cf/beam_interactive/proto/rw.py#L35-L51
def decode(self, bytes): """ Decodes the packet off the byte string. """ self.buffer = bytes self._pos = 0 Packet = identifier.get_packet_from_id(self._read_variunt()) # unknown packets will be None from the identifier if Packet is None: ret...
[ "def", "decode", "(", "self", ",", "bytes", ")", ":", "self", ".", "buffer", "=", "bytes", "self", ".", "_pos", "=", "0", "Packet", "=", "identifier", ".", "get_packet_from_id", "(", "self", ".", "_read_variunt", "(", ")", ")", "# unknown packets will be N...
Decodes the packet off the byte string.
[ "Decodes", "the", "packet", "off", "the", "byte", "string", "." ]
python
train
materialsproject/pymatgen
pymatgen/analysis/elasticity/elastic.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/elasticity/elastic.py#L640-L662
def get_heat_capacity(self, temperature, structure, n, u, cutoff=1e2): """ Gets the directional heat capacity for a higher order tensor expansion as a function of direction and polarization. Args: temperature (float): Temperature in kelvin structure (float): Stru...
[ "def", "get_heat_capacity", "(", "self", ",", "temperature", ",", "structure", ",", "n", ",", "u", ",", "cutoff", "=", "1e2", ")", ":", "k", "=", "1.38065e-23", "kt", "=", "k", "*", "temperature", "hbar_w", "=", "1.05457e-34", "*", "self", ".", "omega"...
Gets the directional heat capacity for a higher order tensor expansion as a function of direction and polarization. Args: temperature (float): Temperature in kelvin structure (float): Structure to be used in directional heat capacity determination n (...
[ "Gets", "the", "directional", "heat", "capacity", "for", "a", "higher", "order", "tensor", "expansion", "as", "a", "function", "of", "direction", "and", "polarization", "." ]
python
train
phaethon/kamene
kamene/crypto/cert.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1957-L1980
def is_revoked(self, crl_list): """ Given a list of trusted CRL (their signature has already been verified with trusted anchors), this function returns True if the certificate is marked as revoked by one of those CRL. Note that if the Certificate was on hold in a previous CRL an...
[ "def", "is_revoked", "(", "self", ",", "crl_list", ")", ":", "for", "c", "in", "crl_list", ":", "if", "(", "self", ".", "authorityKeyID", "is", "not", "None", "and", "c", ".", "authorityKeyID", "is", "not", "None", "and", "self", ".", "authorityKeyID", ...
Given a list of trusted CRL (their signature has already been verified with trusted anchors), this function returns True if the certificate is marked as revoked by one of those CRL. Note that if the Certificate was on hold in a previous CRL and is now valid again in a new CRL and bot ar...
[ "Given", "a", "list", "of", "trusted", "CRL", "(", "their", "signature", "has", "already", "been", "verified", "with", "trusted", "anchors", ")", "this", "function", "returns", "True", "if", "the", "certificate", "is", "marked", "as", "revoked", "by", "one",...
python
train
zsimic/runez
src/runez/system.py
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/system.py#L21-L66
def abort(*args, **kwargs): """ Usage: return abort("...") => will sys.exit() by default return abort("...", fatal=True) => Will sys.exit() # Not fatal, but will log/print message: return abort("...", fatal=False) => Will return False return abort("...", fatal=(False, No...
[ "def", "abort", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "code", "=", "kwargs", ".", "pop", "(", "\"code\"", ",", "1", ")", "logger", "=", "kwargs", ".", "pop", "(", "\"logger\"", ",", "LOG", ".", "error", "if", "code", "else", "LOG",...
Usage: return abort("...") => will sys.exit() by default return abort("...", fatal=True) => Will sys.exit() # Not fatal, but will log/print message: return abort("...", fatal=False) => Will return False return abort("...", fatal=(False, None)) => Will return None return ...
[ "Usage", ":", "return", "abort", "(", "...", ")", "=", ">", "will", "sys", ".", "exit", "()", "by", "default", "return", "abort", "(", "...", "fatal", "=", "True", ")", "=", ">", "Will", "sys", ".", "exit", "()" ]
python
train
RiotGames/cloud-inquisitor
backend/cloud_inquisitor/config.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/backend/cloud_inquisitor/config.py#L121-L186
def set(self, namespace, key, value, description=None): """Set (create/update) a configuration item Args: namespace (`str`): Namespace for the item key (`str`): Key of the item value (`Any`): Value of the type, must by one of `DBCString`, `DBCFloat`, `DBCInt`, `DBCAr...
[ "def", "set", "(", "self", ",", "namespace", ",", "key", ",", "value", ",", "description", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "DBCChoice", ")", ":", "vtype", "=", "'choice'", "elif", "isinstance", "(", "value", ",", "DBCStrin...
Set (create/update) a configuration item Args: namespace (`str`): Namespace for the item key (`str`): Key of the item value (`Any`): Value of the type, must by one of `DBCString`, `DBCFloat`, `DBCInt`, `DBCArray`, `DBCJSON` or `bool` description (`str...
[ "Set", "(", "create", "/", "update", ")", "a", "configuration", "item" ]
python
train
tech-pi/doufo
src/python/doufo/convert.py
https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/convert.py#L96-L116
def tuple_type_compare(types0, types1): """doufo.tuple_type_compare: compare two types if `types0` is 'bigger' than `types1`, return negative (<0); otherwise, return positive (>0). Here 'bigger' is defined by whether they are 'parent and child', or ituitively bigger Args: ...
[ "def", "tuple_type_compare", "(", "types0", ",", "types1", ")", ":", "compares", "=", "[", "single_type_compare", "(", "types0", "[", "0", "]", ",", "types1", "[", "0", "]", ")", ",", "single_type_compare", "(", "types0", "[", "1", "]", ",", "types1", ...
doufo.tuple_type_compare: compare two types if `types0` is 'bigger' than `types1`, return negative (<0); otherwise, return positive (>0). Here 'bigger' is defined by whether they are 'parent and child', or ituitively bigger Args: types0 (`type`): types0 types1...
[ "doufo", ".", "tuple_type_compare", ":", "compare", "two", "types", "if", "types0", "is", "bigger", "than", "types1", "return", "negative", "(", "<0", ")", ";", "otherwise", "return", "positive", "(", ">", "0", ")", ".", "Here", "bigger", "is", "defined", ...
python
train
pandas-dev/pandas
pandas/core/generic.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/generic.py#L9309-L9471
def tz_localize(self, tz, axis=0, level=None, copy=True, ambiguous='raise', nonexistent='raise'): """ Localize tz-naive index of a Series or DataFrame to target time zone. This operation localizes the Index. To localize the values in a timezone-naive Series, use :met...
[ "def", "tz_localize", "(", "self", ",", "tz", ",", "axis", "=", "0", ",", "level", "=", "None", ",", "copy", "=", "True", ",", "ambiguous", "=", "'raise'", ",", "nonexistent", "=", "'raise'", ")", ":", "nonexistent_options", "=", "(", "'raise'", ",", ...
Localize tz-naive index of a Series or DataFrame to target time zone. This operation localizes the Index. To localize the values in a timezone-naive Series, use :meth:`Series.dt.tz_localize`. Parameters ---------- tz : string or pytz.timezone object axis : the axis to l...
[ "Localize", "tz", "-", "naive", "index", "of", "a", "Series", "or", "DataFrame", "to", "target", "time", "zone", "." ]
python
train
openstack/proliantutils
proliantutils/hpssa/objects.py
https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/hpssa/objects.py#L35-L62
def _get_key_value(string): """Return the (key, value) as a tuple from a string.""" # Normally all properties look like this: # Unique Identifier: 600508B1001CE4ACF473EE9C826230FF # Disk Name: /dev/sda # Mount Points: None key = '' value = '' try: key, value = string.split(...
[ "def", "_get_key_value", "(", "string", ")", ":", "# Normally all properties look like this:", "# Unique Identifier: 600508B1001CE4ACF473EE9C826230FF", "# Disk Name: /dev/sda", "# Mount Points: None", "key", "=", "''", "value", "=", "''", "try", ":", "key", ",", "value"...
Return the (key, value) as a tuple from a string.
[ "Return", "the", "(", "key", "value", ")", "as", "a", "tuple", "from", "a", "string", "." ]
python
train
msmbuilder/msmbuilder
basesetup.py
https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/basesetup.py#L18-L30
def find_packages(): """Find all of mdtraj's python packages. Adapted from IPython's setupbase.py. Copyright IPython contributors, licensed under the BSD license. """ packages = ['mdtraj.scripts'] for dir,subdirs,files in os.walk('MDTraj'): package = dir.replace(os.path.sep, '.') ...
[ "def", "find_packages", "(", ")", ":", "packages", "=", "[", "'mdtraj.scripts'", "]", "for", "dir", ",", "subdirs", ",", "files", "in", "os", ".", "walk", "(", "'MDTraj'", ")", ":", "package", "=", "dir", ".", "replace", "(", "os", ".", "path", ".", ...
Find all of mdtraj's python packages. Adapted from IPython's setupbase.py. Copyright IPython contributors, licensed under the BSD license.
[ "Find", "all", "of", "mdtraj", "s", "python", "packages", ".", "Adapted", "from", "IPython", "s", "setupbase", ".", "py", ".", "Copyright", "IPython", "contributors", "licensed", "under", "the", "BSD", "license", "." ]
python
train
angr/angr
angr/procedures/java_jni/__init__.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/procedures/java_jni/__init__.py#L79-L116
def _load_from_native_memory(self, addr, data_type=None, data_size=None, no_of_elements=1, return_as_list=False): """ Load from native memory. :param addr: Native load address. :param data_type: Java type of elements. ...
[ "def", "_load_from_native_memory", "(", "self", ",", "addr", ",", "data_type", "=", "None", ",", "data_size", "=", "None", ",", "no_of_elements", "=", "1", ",", "return_as_list", "=", "False", ")", ":", "# check if addr is symbolic", "if", "addr", "is", "not",...
Load from native memory. :param addr: Native load address. :param data_type: Java type of elements. If set, all loaded elements are casted to this type. :param data_size: Size of each element. If not set, siz...
[ "Load", "from", "native", "memory", "." ]
python
train
LonamiWebs/Telethon
telethon/tl/custom/message.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/message.py#L846-L869
def _needed_markup_bot(self): """ Returns the input peer of the bot that's needed for the reply markup. This is necessary for :tl:`KeyboardButtonSwitchInline` since we need to know what bot we want to start. Raises ``ValueError`` if the bot cannot be found but is needed. Returns...
[ "def", "_needed_markup_bot", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "reply_markup", ",", "(", "types", ".", "ReplyInlineMarkup", ",", "types", ".", "ReplyKeyboardMarkup", ")", ")", ":", "return", "None", "for", "row", "in", "se...
Returns the input peer of the bot that's needed for the reply markup. This is necessary for :tl:`KeyboardButtonSwitchInline` since we need to know what bot we want to start. Raises ``ValueError`` if the bot cannot be found but is needed. Returns ``None`` if it's not needed.
[ "Returns", "the", "input", "peer", "of", "the", "bot", "that", "s", "needed", "for", "the", "reply", "markup", "." ]
python
train
moderngl/moderngl
moderngl/context.py
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/context.py#L639-L660
def texture3d(self, size, components, data=None, *, alignment=1, dtype='f1') -> 'Texture3D': ''' Create a :py:class:`Texture3D` object. Args: size (tuple): The width, height and depth of the texture. components (int): The number of components 1, 2, 3 or 4...
[ "def", "texture3d", "(", "self", ",", "size", ",", "components", ",", "data", "=", "None", ",", "*", ",", "alignment", "=", "1", ",", "dtype", "=", "'f1'", ")", "->", "'Texture3D'", ":", "res", "=", "Texture3D", ".", "__new__", "(", "Texture3D", ")",...
Create a :py:class:`Texture3D` object. Args: size (tuple): The width, height and depth of the texture. components (int): The number of components 1, 2, 3 or 4. data (bytes): Content of the texture. Keyword Args: alignment (int): T...
[ "Create", "a", ":", "py", ":", "class", ":", "Texture3D", "object", "." ]
python
train
KelSolaar/Umbra
umbra/ui/completers.py
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/completers.py#L114-L125
def __set_cache(self, tokens): """ Sets the tokens cache. :param tokens: Completer tokens list. :type tokens: tuple or list """ if DefaultCompleter._DefaultCompleter__tokens.get(self.__language): return DefaultCompleter._DefaultCompleter__tokens[sel...
[ "def", "__set_cache", "(", "self", ",", "tokens", ")", ":", "if", "DefaultCompleter", ".", "_DefaultCompleter__tokens", ".", "get", "(", "self", ".", "__language", ")", ":", "return", "DefaultCompleter", ".", "_DefaultCompleter__tokens", "[", "self", ".", "__lan...
Sets the tokens cache. :param tokens: Completer tokens list. :type tokens: tuple or list
[ "Sets", "the", "tokens", "cache", "." ]
python
train
riga/tfdeploy
tfdeploy.py
https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1831-L1836
def Max(a, axis, keep_dims): """ Max reduction op. """ return np.amax(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
[ "def", "Max", "(", "a", ",", "axis", ",", "keep_dims", ")", ":", "return", "np", ".", "amax", "(", "a", ",", "axis", "=", "axis", "if", "not", "isinstance", "(", "axis", ",", "np", ".", "ndarray", ")", "else", "tuple", "(", "axis", ")", ",", "k...
Max reduction op.
[ "Max", "reduction", "op", "." ]
python
train
gem/oq-engine
openquake/commonlib/oqvalidation.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L468-L472
def lti(self): """ Dictionary extended_loss_type -> extended_loss_type index """ return {lt: i for i, (lt, dt) in enumerate(self.loss_dt_list())}
[ "def", "lti", "(", "self", ")", ":", "return", "{", "lt", ":", "i", "for", "i", ",", "(", "lt", ",", "dt", ")", "in", "enumerate", "(", "self", ".", "loss_dt_list", "(", ")", ")", "}" ]
Dictionary extended_loss_type -> extended_loss_type index
[ "Dictionary", "extended_loss_type", "-", ">", "extended_loss_type", "index" ]
python
train
mardix/Mocha
mocha/contrib/auth/models.py
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/models.py#L243-L254
def change_password(self, password): """ Change the password. :param password: :return: """ self.update(password_hash=self.encrypt_password(password), require_password_change=False) # Whenever the password is changed, reset the secret key to i...
[ "def", "change_password", "(", "self", ",", "password", ")", ":", "self", ".", "update", "(", "password_hash", "=", "self", ".", "encrypt_password", "(", "password", ")", ",", "require_password_change", "=", "False", ")", "# Whenever the password is changed, reset t...
Change the password. :param password: :return:
[ "Change", "the", "password", ".", ":", "param", "password", ":", ":", "return", ":" ]
python
train
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L501-L504
def _get_query(self, **query_dict): """Perform a GET query against Solr and return the response as a Python dict.""" param_dict = query_dict.copy() return self._send_query(do_post=False, **param_dict)
[ "def", "_get_query", "(", "self", ",", "*", "*", "query_dict", ")", ":", "param_dict", "=", "query_dict", ".", "copy", "(", ")", "return", "self", ".", "_send_query", "(", "do_post", "=", "False", ",", "*", "*", "param_dict", ")" ]
Perform a GET query against Solr and return the response as a Python dict.
[ "Perform", "a", "GET", "query", "against", "Solr", "and", "return", "the", "response", "as", "a", "Python", "dict", "." ]
python
train
moderngl/moderngl
moderngl/context.py
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/context.py#L321-L405
def info(self) -> Dict[str, object]: ''' dict: Information about the context Example:: { 'GL_VENDOR': 'NVIDIA Corporation', 'GL_RENDERER': 'NVIDIA GeForce GT 650M OpenGL Engine', 'GL_VERSION': '4.1 NVIDIA-10....
[ "def", "info", "(", "self", ")", "->", "Dict", "[", "str", ",", "object", "]", ":", "if", "self", ".", "_info", "is", "None", ":", "self", ".", "_info", "=", "self", ".", "mglo", ".", "info", "return", "self", ".", "_info" ]
dict: Information about the context Example:: { 'GL_VENDOR': 'NVIDIA Corporation', 'GL_RENDERER': 'NVIDIA GeForce GT 650M OpenGL Engine', 'GL_VERSION': '4.1 NVIDIA-10.32.0 355.11.10.10.40.102', 'GL_POINT_SIZ...
[ "dict", ":", "Information", "about", "the", "context" ]
python
train
linkedin/naarad
src/naarad/httpdownload.py
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/httpdownload.py#L141-L159
def download_url_single(inputs, outdir, outfile=None): """ Downloads a http(s) url to a local file :param str inputs: the absolute url :param str outdir: Required. the local directory to put the downloadedfiles. :param str outfile: // Optional. If this is given, the downloaded url will be renated to outfile;...
[ "def", "download_url_single", "(", "inputs", ",", "outdir", ",", "outfile", "=", "None", ")", ":", "if", "not", "inputs", "or", "type", "(", "inputs", ")", "!=", "str", "or", "not", "outdir", "or", "type", "(", "outdir", ")", "!=", "str", ":", "loggi...
Downloads a http(s) url to a local file :param str inputs: the absolute url :param str outdir: Required. the local directory to put the downloadedfiles. :param str outfile: // Optional. If this is given, the downloaded url will be renated to outfile; If this is not given, then the local file will be the orig...
[ "Downloads", "a", "http", "(", "s", ")", "url", "to", "a", "local", "file", ":", "param", "str", "inputs", ":", "the", "absolute", "url", ":", "param", "str", "outdir", ":", "Required", ".", "the", "local", "directory", "to", "put", "the", "downloadedf...
python
valid
urbn/Caesium
caesium/handler.py
https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L716-L733
def delete(self, bulk_id): """Update many objects with a single toa :param str bulk_id: The bulk id for the job you want to delete """ collection_name = self.request.headers.get("collection") if not collection_name: self.raise_error(400, "Missing a collection name ...
[ "def", "delete", "(", "self", ",", "bulk_id", ")", ":", "collection_name", "=", "self", ".", "request", ".", "headers", ".", "get", "(", "\"collection\"", ")", "if", "not", "collection_name", ":", "self", ".", "raise_error", "(", "400", ",", "\"Missing a c...
Update many objects with a single toa :param str bulk_id: The bulk id for the job you want to delete
[ "Update", "many", "objects", "with", "a", "single", "toa" ]
python
train
senaite/senaite.core
bika/lims/workflow/worksheet/guards.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/workflow/worksheet/guards.py#L60-L75
def guard_retract(worksheet): """Return whether the transition retract can be performed or not to the worksheet passed in. Since the retract transition from worksheet is a shortcut to retract transitions from all analyses the worksheet contains, this guard only returns True if retract transition is allo...
[ "def", "guard_retract", "(", "worksheet", ")", ":", "analyses", "=", "worksheet", ".", "getAnalyses", "(", ")", "detached", "=", "[", "'rejected'", ",", "'retracted'", "]", "num_detached", "=", "0", "for", "analysis", "in", "analyses", ":", "if", "api", "....
Return whether the transition retract can be performed or not to the worksheet passed in. Since the retract transition from worksheet is a shortcut to retract transitions from all analyses the worksheet contains, this guard only returns True if retract transition is allowed for all analyses the workshee...
[ "Return", "whether", "the", "transition", "retract", "can", "be", "performed", "or", "not", "to", "the", "worksheet", "passed", "in", ".", "Since", "the", "retract", "transition", "from", "worksheet", "is", "a", "shortcut", "to", "retract", "transitions", "fro...
python
train
ejeschke/ginga
ginga/rv/plugins/MultiDim.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/MultiDim.py#L444-L484
def set_naxis(self, idx, n): """Change the slice shown in the channel viewer. `idx` is the slice index (0-based); `n` is the axis (0-based) """ self.play_idx = idx self.logger.debug("naxis %d index is %d" % (n + 1, idx + 1)) image = self.fitsimage.get_image() sli...
[ "def", "set_naxis", "(", "self", ",", "idx", ",", "n", ")", ":", "self", ".", "play_idx", "=", "idx", "self", ".", "logger", ".", "debug", "(", "\"naxis %d index is %d\"", "%", "(", "n", "+", "1", ",", "idx", "+", "1", ")", ")", "image", "=", "se...
Change the slice shown in the channel viewer. `idx` is the slice index (0-based); `n` is the axis (0-based)
[ "Change", "the", "slice", "shown", "in", "the", "channel", "viewer", ".", "idx", "is", "the", "slice", "index", "(", "0", "-", "based", ")", ";", "n", "is", "the", "axis", "(", "0", "-", "based", ")" ]
python
train
glue-viz/echo
echo/core.py
https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L334-L372
def add_callback(instance, prop, callback, echo_old=False, priority=0): """ Attach a callback function to a property in an instance Parameters ---------- instance The instance to add the callback to prop : str Name of callback property in `instance` callback : func T...
[ "def", "add_callback", "(", "instance", ",", "prop", ",", "callback", ",", "echo_old", "=", "False", ",", "priority", "=", "0", ")", ":", "p", "=", "getattr", "(", "type", "(", "instance", ")", ",", "prop", ")", "if", "not", "isinstance", "(", "p", ...
Attach a callback function to a property in an instance Parameters ---------- instance The instance to add the callback to prop : str Name of callback property in `instance` callback : func The callback function to add echo_old : bool, optional If `True`, the cal...
[ "Attach", "a", "callback", "function", "to", "a", "property", "in", "an", "instance" ]
python
train
Valuehorizon/valuehorizon-companies
companies/models.py
https://github.com/Valuehorizon/valuehorizon-companies/blob/5366e230da69ee30fcdc1bf4beddc99310f6b767/companies/models.py#L266-L274
def cache_data(self): """ Cache some basic data such as financial statement metrics """ # Set Slug if not set if not self.slug_name: self.slug_name = slugify(self.name).strip() if len(self.slug_name) > 255: self.slug_name = self.slug_name[0...
[ "def", "cache_data", "(", "self", ")", ":", "# Set Slug if not set", "if", "not", "self", ".", "slug_name", ":", "self", ".", "slug_name", "=", "slugify", "(", "self", ".", "name", ")", ".", "strip", "(", ")", "if", "len", "(", "self", ".", "slug_name"...
Cache some basic data such as financial statement metrics
[ "Cache", "some", "basic", "data", "such", "as", "financial", "statement", "metrics" ]
python
train
mikusjelly/apkutils
apkutils/apkfile.py
https://github.com/mikusjelly/apkutils/blob/2db1ed0cdb610dfc55bfd77266e9a91e4764bba4/apkutils/apkfile.py#L1417-L1519
def write(self, filename, arcname=None, compress_type=None): """Put the bytes from filename into the archive under the name arcname.""" if not self.fp: raise RuntimeError( "Attempt to write to ZIP archive that was already closed") st = os.stat(filename) ...
[ "def", "write", "(", "self", ",", "filename", ",", "arcname", "=", "None", ",", "compress_type", "=", "None", ")", ":", "if", "not", "self", ".", "fp", ":", "raise", "RuntimeError", "(", "\"Attempt to write to ZIP archive that was already closed\"", ")", "st", ...
Put the bytes from filename into the archive under the name arcname.
[ "Put", "the", "bytes", "from", "filename", "into", "the", "archive", "under", "the", "name", "arcname", "." ]
python
train
daler/metaseq
metaseq/_genomic_signal.py
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/_genomic_signal.py#L50-L70
def genomic_signal(fn, kind): """ Factory function that makes the right class for the file format. Typically you'll only need this function to create a new genomic signal object. :param fn: Filename :param kind: String. Format of the file; see metaseq.genomic_signal._registry....
[ "def", "genomic_signal", "(", "fn", ",", "kind", ")", ":", "try", ":", "klass", "=", "_registry", "[", "kind", ".", "lower", "(", ")", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "'No support for %s format, choices are %s'", "%", "(", "kind",...
Factory function that makes the right class for the file format. Typically you'll only need this function to create a new genomic signal object. :param fn: Filename :param kind: String. Format of the file; see metaseq.genomic_signal._registry.keys()
[ "Factory", "function", "that", "makes", "the", "right", "class", "for", "the", "file", "format", "." ]
python
train
Kitware/tangelo
tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py
https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/pkgdata/plugin/watch/python/__init__.py#L55-L67
def module_getmtime(filename): """ Get the mtime associated with a module. If this is a .pyc or .pyo file and a corresponding .py file exists, the time of the .py file is returned. :param filename: filename of the module. :returns: mtime or None if the file doesn"t exist. """ if os.path.sp...
[ "def", "module_getmtime", "(", "filename", ")", ":", "if", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "1", "]", ".", "lower", "(", ")", "in", "(", "\".pyc\"", ",", "\".pyo\"", ")", "and", "os", ".", "path", ".", "exists", "(", ...
Get the mtime associated with a module. If this is a .pyc or .pyo file and a corresponding .py file exists, the time of the .py file is returned. :param filename: filename of the module. :returns: mtime or None if the file doesn"t exist.
[ "Get", "the", "mtime", "associated", "with", "a", "module", ".", "If", "this", "is", "a", ".", "pyc", "or", ".", "pyo", "file", "and", "a", "corresponding", ".", "py", "file", "exists", "the", "time", "of", "the", ".", "py", "file", "is", "returned",...
python
train
pybel/pybel
src/pybel/struct/filters/node_predicate_builders.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/filters/node_predicate_builders.py#L24-L35
def function_inclusion_filter_builder(func: Strings) -> NodePredicate: """Build a filter that only passes on nodes of the given function(s). :param func: A BEL Function or list/set/tuple of BEL functions """ if isinstance(func, str): return _single_function_inclusion_filter_builder(func) e...
[ "def", "function_inclusion_filter_builder", "(", "func", ":", "Strings", ")", "->", "NodePredicate", ":", "if", "isinstance", "(", "func", ",", "str", ")", ":", "return", "_single_function_inclusion_filter_builder", "(", "func", ")", "elif", "isinstance", "(", "fu...
Build a filter that only passes on nodes of the given function(s). :param func: A BEL Function or list/set/tuple of BEL functions
[ "Build", "a", "filter", "that", "only", "passes", "on", "nodes", "of", "the", "given", "function", "(", "s", ")", "." ]
python
train
mental32/spotify.py
spotify/models/player.py
https://github.com/mental32/spotify.py/blob/bb296cac7c3dd289908906b7069bd80f43950515/spotify/models/player.py#L111-L122
async def set_repeat(self, state, *, device: Optional[SomeDevice] = None): """Set the repeat mode for the user’s playback. Parameters ---------- state : str Options are repeat-track, repeat-context, and off device : Optional[:obj:`SomeDevice`] The Device ...
[ "async", "def", "set_repeat", "(", "self", ",", "state", ",", "*", ",", "device", ":", "Optional", "[", "SomeDevice", "]", "=", "None", ")", ":", "await", "self", ".", "_user", ".", "http", ".", "repeat_playback", "(", "state", ",", "device_id", "=", ...
Set the repeat mode for the user’s playback. Parameters ---------- state : str Options are repeat-track, repeat-context, and off device : Optional[:obj:`SomeDevice`] The Device object or id of the device this command is targeting. If not supplied, the...
[ "Set", "the", "repeat", "mode", "for", "the", "user’s", "playback", "." ]
python
test
markovmodel/PyEMMA
pyemma/_base/serialization/serialization.py
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/_base/serialization/serialization.py#L212-L249
def save(self, file_name, model_name='default', overwrite=False, save_streaming_chain=False): r""" saves the current state of this object to given file and name. Parameters ----------- file_name: str path to desired output file model_name: str, default='default' ...
[ "def", "save", "(", "self", ",", "file_name", ",", "model_name", "=", "'default'", ",", "overwrite", "=", "False", ",", "save_streaming_chain", "=", "False", ")", ":", "from", "pyemma", ".", "_base", ".", "serialization", ".", "h5file", "import", "H5File", ...
r""" saves the current state of this object to given file and name. Parameters ----------- file_name: str path to desired output file model_name: str, default='default' creates a group named 'model_name' in the given file, which will contain all of the data. ...
[ "r", "saves", "the", "current", "state", "of", "this", "object", "to", "given", "file", "and", "name", "." ]
python
train
genepattern/nbtools
nbtools/jsobject/jsobject.py
https://github.com/genepattern/nbtools/blob/2f74703f59926d8565f9714b1458dc87da8f8574/nbtools/jsobject/jsobject.py#L89-L104
def serialize(self, obj): """Serialize an object for sending to the front-end.""" if hasattr(obj, '_jsid'): return {'immutable': False, 'value': obj._jsid} else: obj_json = {'immutable': True} try: json.dumps(obj) obj_json['valu...
[ "def", "serialize", "(", "self", ",", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'_jsid'", ")", ":", "return", "{", "'immutable'", ":", "False", ",", "'value'", ":", "obj", ".", "_jsid", "}", "else", ":", "obj_json", "=", "{", "'immutable'",...
Serialize an object for sending to the front-end.
[ "Serialize", "an", "object", "for", "sending", "to", "the", "front", "-", "end", "." ]
python
train
phaethon/kamene
kamene/utils.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L41-L48
def str2bytes(x): """Convert input argument to bytes""" if type(x) is bytes: return x elif type(x) is str: return bytes([ ord(i) for i in x ]) else: return str2bytes(str(x))
[ "def", "str2bytes", "(", "x", ")", ":", "if", "type", "(", "x", ")", "is", "bytes", ":", "return", "x", "elif", "type", "(", "x", ")", "is", "str", ":", "return", "bytes", "(", "[", "ord", "(", "i", ")", "for", "i", "in", "x", "]", ")", "el...
Convert input argument to bytes
[ "Convert", "input", "argument", "to", "bytes" ]
python
train
tcalmant/ipopo
pelix/ipopo/instance.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/instance.py#L184-L192
def bind(self, dependency, svc, svc_ref): # type: (Any, Any, ServiceReference) -> None """ Called by a dependency manager to inject a new service and update the component life cycle. """ with self._lock: self.__set_binding(dependency, svc, svc_ref) ...
[ "def", "bind", "(", "self", ",", "dependency", ",", "svc", ",", "svc_ref", ")", ":", "# type: (Any, Any, ServiceReference) -> None", "with", "self", ".", "_lock", ":", "self", ".", "__set_binding", "(", "dependency", ",", "svc", ",", "svc_ref", ")", "self", ...
Called by a dependency manager to inject a new service and update the component life cycle.
[ "Called", "by", "a", "dependency", "manager", "to", "inject", "a", "new", "service", "and", "update", "the", "component", "life", "cycle", "." ]
python
train
StackStorm/pybind
pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/ldp/ldp_holder/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/mpls_config/router/mpls/mpls_cmds_holder/ldp/ldp_holder/__init__.py#L610-L631
def _set_ldp_rcv_label_silence_time(self, v, load=False): """ Setter method for ldp_rcv_label_silence_time, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/ldp/ldp_holder/ldp_rcv_label_silence_time (uint32) If this variable is read-only (config: false) in the source YANG file, then _...
[ "def", "_set_ldp_rcv_label_silence_time", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v...
Setter method for ldp_rcv_label_silence_time, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/ldp/ldp_holder/ldp_rcv_label_silence_time (uint32) If this variable is read-only (config: false) in the source YANG file, then _set_ldp_rcv_label_silence_time is considered as a private method. ...
[ "Setter", "method", "for", "ldp_rcv_label_silence_time", "mapped", "from", "YANG", "variable", "/", "mpls_config", "/", "router", "/", "mpls", "/", "mpls_cmds_holder", "/", "ldp", "/", "ldp_holder", "/", "ldp_rcv_label_silence_time", "(", "uint32", ")", "If", "thi...
python
train
citronneur/rdpy
rdpy/protocol/rfb/rfb.py
https://github.com/citronneur/rdpy/blob/4109b7a6fe2abf3ddbaed54e29d2f31e63ed97f6/rdpy/protocol/rfb/rfb.py#L350-L356
def recvServerInit(self, data): """ Read server init packet @param data: Stream that contains well formed packet """ data.readType(self._serverInit) self.expectWithHeader(4, self.recvServerName)
[ "def", "recvServerInit", "(", "self", ",", "data", ")", ":", "data", ".", "readType", "(", "self", ".", "_serverInit", ")", "self", ".", "expectWithHeader", "(", "4", ",", "self", ".", "recvServerName", ")" ]
Read server init packet @param data: Stream that contains well formed packet
[ "Read", "server", "init", "packet" ]
python
train
dourvaris/nano-python
src/nano/rpc.py
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L1430-L1449
def krai_from_raw(self, amount): """ Divide a raw amount down by the krai ratio. :param amount: Amount in raw to convert to krai :type amount: int :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.krai_from_raw(amount=1000000000000000000000000000) 1 """ ...
[ "def", "krai_from_raw", "(", "self", ",", "amount", ")", ":", "amount", "=", "self", ".", "_process_value", "(", "amount", ",", "'int'", ")", "payload", "=", "{", "\"amount\"", ":", "amount", "}", "resp", "=", "self", ".", "call", "(", "'krai_from_raw'",...
Divide a raw amount down by the krai ratio. :param amount: Amount in raw to convert to krai :type amount: int :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.krai_from_raw(amount=1000000000000000000000000000) 1
[ "Divide", "a", "raw", "amount", "down", "by", "the", "krai", "ratio", "." ]
python
train
openai/baselines
baselines/common/input.py
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/input.py#L5-L31
def observation_placeholder(ob_space, batch_size=None, name='Ob'): ''' Create placeholder to feed observations into of the size appropriate to the observation space Parameters: ---------- ob_space: gym.Space observation space batch_size: int size of the batch to be fed into input....
[ "def", "observation_placeholder", "(", "ob_space", ",", "batch_size", "=", "None", ",", "name", "=", "'Ob'", ")", ":", "assert", "isinstance", "(", "ob_space", ",", "Discrete", ")", "or", "isinstance", "(", "ob_space", ",", "Box", ")", "or", "isinstance", ...
Create placeholder to feed observations into of the size appropriate to the observation space Parameters: ---------- ob_space: gym.Space observation space batch_size: int size of the batch to be fed into input. Can be left None in most cases. name: str name of the place...
[ "Create", "placeholder", "to", "feed", "observations", "into", "of", "the", "size", "appropriate", "to", "the", "observation", "space" ]
python
valid
profitbricks/profitbricks-sdk-python
examples/pb_deleteServer.py
https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_deleteServer.py#L136-L173
def getServerStates(pbclient=None, dc_id=None, serverid=None, servername=None): ''' gets states of a server''' if pbclient is None: raise ValueError("argument 'pbclient' must not be None") if dc_id is None: raise ValueError("argument 'dc_id' must not be None") server = None if server...
[ "def", "getServerStates", "(", "pbclient", "=", "None", ",", "dc_id", "=", "None", ",", "serverid", "=", "None", ",", "servername", "=", "None", ")", ":", "if", "pbclient", "is", "None", ":", "raise", "ValueError", "(", "\"argument 'pbclient' must not be None\...
gets states of a server
[ "gets", "states", "of", "a", "server" ]
python
valid
NeuroanatomyAndConnectivity/surfdist
nipype/surfdist_nipype.py
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/nipype/surfdist_nipype.py#L20-L56
def calc_surfdist(surface, labels, annot, reg, origin, target): import nibabel as nib import numpy as np import os from surfdist import load, utils, surfdist import csv """ inputs: surface - surface file (e.g. lh.pial, with full path) labels - label file (e.g. lh.cortex.label, with full path) annot -...
[ "def", "calc_surfdist", "(", "surface", ",", "labels", ",", "annot", ",", "reg", ",", "origin", ",", "target", ")", ":", "import", "nibabel", "as", "nib", "import", "numpy", "as", "np", "import", "os", "from", "surfdist", "import", "load", ",", "utils", ...
inputs: surface - surface file (e.g. lh.pial, with full path) labels - label file (e.g. lh.cortex.label, with full path) annot - annot file (e.g. lh.aparc.a2009s.annot, with full path) reg - registration file (lh.sphere.reg) origin - the label from which we calculate distances target - target surface (e.g. ...
[ "inputs", ":", "surface", "-", "surface", "file", "(", "e", ".", "g", ".", "lh", ".", "pial", "with", "full", "path", ")", "labels", "-", "label", "file", "(", "e", ".", "g", ".", "lh", ".", "cortex", ".", "label", "with", "full", "path", ")", ...
python
train
google/grr
grr/client/grr_response_client/comms.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L468-L478
def Wait(self): """Wait until the next action is needed.""" time.sleep(self.sleep_time - int(self.sleep_time)) # Split a long sleep interval into 1 second intervals so we can heartbeat. for _ in range(int(self.sleep_time)): time.sleep(1) # Back off slowly at first and fast if no answer. ...
[ "def", "Wait", "(", "self", ")", ":", "time", ".", "sleep", "(", "self", ".", "sleep_time", "-", "int", "(", "self", ".", "sleep_time", ")", ")", "# Split a long sleep interval into 1 second intervals so we can heartbeat.", "for", "_", "in", "range", "(", "int",...
Wait until the next action is needed.
[ "Wait", "until", "the", "next", "action", "is", "needed", "." ]
python
train
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L291-L320
def create_html_link(urlbase, urlargd, link_label, linkattrd=None, escape_urlargd=True, escape_linkattrd=True, urlhash=None): """Creates a W3C compliant link. @param urlbase: base url (e.g. config.CFG_SITE_URL/search) @param urlargd: dictionary of parameters. (e.g. ...
[ "def", "create_html_link", "(", "urlbase", ",", "urlargd", ",", "link_label", ",", "linkattrd", "=", "None", ",", "escape_urlargd", "=", "True", ",", "escape_linkattrd", "=", "True", ",", "urlhash", "=", "None", ")", ":", "attributes_separator", "=", "' '", ...
Creates a W3C compliant link. @param urlbase: base url (e.g. config.CFG_SITE_URL/search) @param urlargd: dictionary of parameters. (e.g. p={'recid':3, 'of'='hb'}) @param link_label: text displayed in a browser (has to be already escaped) @param linkattrd: dictionary of attributes (e.g. a={'class': 'img'...
[ "Creates", "a", "W3C", "compliant", "link", "." ]
python
train
dourvaris/nano-python
src/nano/rpc.py
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L1475-L1495
def rai_from_raw(self, amount): """ Divide a raw amount down by the rai ratio. :param amount: Amount in raw to convert to rai :type amount: int :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.rai_from_raw(amount=1000000000000000000000000) 1 """ ...
[ "def", "rai_from_raw", "(", "self", ",", "amount", ")", ":", "amount", "=", "self", ".", "_process_value", "(", "amount", ",", "'int'", ")", "payload", "=", "{", "\"amount\"", ":", "amount", "}", "resp", "=", "self", ".", "call", "(", "'rai_from_raw'", ...
Divide a raw amount down by the rai ratio. :param amount: Amount in raw to convert to rai :type amount: int :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.rai_from_raw(amount=1000000000000000000000000) 1
[ "Divide", "a", "raw", "amount", "down", "by", "the", "rai", "ratio", "." ]
python
train
fukuball/fuku-ml
FukuML/Utility.py
https://github.com/fukuball/fuku-ml/blob/0da15ad7af76adf344b5a6b3f3dbabbbab3446b0/FukuML/Utility.py#L20-L40
def load(input_data_file='', data_type='float'): """load file""" X = [] Y = [] if data_type == 'float': with open(input_data_file) as f: for line in f: data = line.split() x = [1] + [float(v) for v in data[:-1]] ...
[ "def", "load", "(", "input_data_file", "=", "''", ",", "data_type", "=", "'float'", ")", ":", "X", "=", "[", "]", "Y", "=", "[", "]", "if", "data_type", "==", "'float'", ":", "with", "open", "(", "input_data_file", ")", "as", "f", ":", "for", "line...
load file
[ "load", "file" ]
python
test
plandes/actioncli
src/python/zensols/actioncli/persist.py
https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L602-L610
def shelve(self): """Return an opened shelve object. """ logger.info('creating shelve data') fname = str(self.create_path.absolute()) inst = sh.open(fname, writeback=self.writeback) self.is_open = True return inst
[ "def", "shelve", "(", "self", ")", ":", "logger", ".", "info", "(", "'creating shelve data'", ")", "fname", "=", "str", "(", "self", ".", "create_path", ".", "absolute", "(", ")", ")", "inst", "=", "sh", ".", "open", "(", "fname", ",", "writeback", "...
Return an opened shelve object.
[ "Return", "an", "opened", "shelve", "object", "." ]
python
train
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L396-L433
async def self_check(cls): """ Check that the configuration is correct - Presence of "token" in the settings - Presence of "BERNARD_BASE_URL" in the global configuration """ # noinspection PyTypeChecker async for check in super(Telegram, cls).self_check(): ...
[ "async", "def", "self_check", "(", "cls", ")", ":", "# noinspection PyTypeChecker", "async", "for", "check", "in", "super", "(", "Telegram", ",", "cls", ")", ".", "self_check", "(", ")", ":", "yield", "check", "s", "=", "cls", ".", "settings", "(", ")", ...
Check that the configuration is correct - Presence of "token" in the settings - Presence of "BERNARD_BASE_URL" in the global configuration
[ "Check", "that", "the", "configuration", "is", "correct" ]
python
train
pennersr/django-allauth
allauth/socialaccount/providers/bitbucket_oauth2/views.py
https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/bitbucket_oauth2/views.py#L29-L42
def get_email(self, token): """Fetches email address from email API endpoint""" resp = requests.get(self.emails_url, params={'access_token': token.token}) emails = resp.json().get('values', []) email = '' try: email = emails[0].get('email')...
[ "def", "get_email", "(", "self", ",", "token", ")", ":", "resp", "=", "requests", ".", "get", "(", "self", ".", "emails_url", ",", "params", "=", "{", "'access_token'", ":", "token", ".", "token", "}", ")", "emails", "=", "resp", ".", "json", "(", ...
Fetches email address from email API endpoint
[ "Fetches", "email", "address", "from", "email", "API", "endpoint" ]
python
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4826-L4928
def _update(self, es): """Test termination criteria and update dictionary """ if es is None: es = self.es assert es is not None if es.countiter == 0: # in this case termination tests fail self.__init__() return self self.lastiter = ...
[ "def", "_update", "(", "self", ",", "es", ")", ":", "if", "es", "is", "None", ":", "es", "=", "self", ".", "es", "assert", "es", "is", "not", "None", "if", "es", ".", "countiter", "==", "0", ":", "# in this case termination tests fail", "self", ".", ...
Test termination criteria and update dictionary
[ "Test", "termination", "criteria", "and", "update", "dictionary" ]
python
train
getpelican/pelican-plugins
yuicompressor/yuicompressor.py
https://github.com/getpelican/pelican-plugins/blob/cfc7a3f224f1743063b034561f89a6a712d13587/yuicompressor/yuicompressor.py#L15-L26
def minify(pelican): """ Minify CSS and JS with YUI Compressor :param pelican: The Pelican instance """ executable = pelican.settings.get('YUICOMPRESSOR_EXECUTABLE', 'yuicompressor') for dirpath, _, filenames in os.walk(pelican.settings['OUTPUT_PATH']): for name in filenames: ...
[ "def", "minify", "(", "pelican", ")", ":", "executable", "=", "pelican", ".", "settings", ".", "get", "(", "'YUICOMPRESSOR_EXECUTABLE'", ",", "'yuicompressor'", ")", "for", "dirpath", ",", "_", ",", "filenames", "in", "os", ".", "walk", "(", "pelican", "."...
Minify CSS and JS with YUI Compressor :param pelican: The Pelican instance
[ "Minify", "CSS", "and", "JS", "with", "YUI", "Compressor", ":", "param", "pelican", ":", "The", "Pelican", "instance" ]
python
train
globus/globus-cli
globus_cli/parsing/shared_options.py
https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/parsing/shared_options.py#L60-L89
def endpoint_id_arg(*args, **kwargs): """ This is the `ENDPOINT_ID` argument consumed by many Transfer endpoint related operations. It accepts alternate metavars for cases when another name is desirable (e.x. `SHARE_ID`, `HOST_ENDPOINT_ID`), but can also be applied as a direct decorator if no specia...
[ "def", "endpoint_id_arg", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorate", "(", "f", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Work of actually decorating a function -- wrapped in here because we\n want to dispatch depending on how th...
This is the `ENDPOINT_ID` argument consumed by many Transfer endpoint related operations. It accepts alternate metavars for cases when another name is desirable (e.x. `SHARE_ID`, `HOST_ENDPOINT_ID`), but can also be applied as a direct decorator if no specialized metavar is being passed. Usage: >>...
[ "This", "is", "the", "ENDPOINT_ID", "argument", "consumed", "by", "many", "Transfer", "endpoint", "related", "operations", ".", "It", "accepts", "alternate", "metavars", "for", "cases", "when", "another", "name", "is", "desirable", "(", "e", ".", "x", ".", "...
python
train
PyCQA/pylint-django
pylint_django/augmentations/__init__.py
https://github.com/PyCQA/pylint-django/blob/0bbee433519f48134df4a797341c4196546a454e/pylint_django/augmentations/__init__.py#L469-L480
def is_model_mpttmeta_subclass(node): """Checks that node is derivative of MPTTMeta class.""" if node.name != 'MPTTMeta' or not isinstance(node.parent, ClassDef): return False parents = ('django.db.models.base.Model', '.Model', # for the transformed version used in this plugin ...
[ "def", "is_model_mpttmeta_subclass", "(", "node", ")", ":", "if", "node", ".", "name", "!=", "'MPTTMeta'", "or", "not", "isinstance", "(", "node", ".", "parent", ",", "ClassDef", ")", ":", "return", "False", "parents", "=", "(", "'django.db.models.base.Model'"...
Checks that node is derivative of MPTTMeta class.
[ "Checks", "that", "node", "is", "derivative", "of", "MPTTMeta", "class", "." ]
python
train
Metatab/metatab
metatab/doc.py
https://github.com/Metatab/metatab/blob/8336ec3e4bd8da84a9a5cb86de1c1086e14b8b22/metatab/doc.py#L466-L515
def load_terms(self, terms): """Create a builder from a sequence of terms, usually a TermInterpreter""" #if self.root and len(self.root.children) > 0: # raise MetatabError("Can't run after adding terms to document.") for t in terms: t.doc = self if t.term_i...
[ "def", "load_terms", "(", "self", ",", "terms", ")", ":", "#if self.root and len(self.root.children) > 0:", "# raise MetatabError(\"Can't run after adding terms to document.\")", "for", "t", "in", "terms", ":", "t", ".", "doc", "=", "self", "if", "t", ".", "term_is",...
Create a builder from a sequence of terms, usually a TermInterpreter
[ "Create", "a", "builder", "from", "a", "sequence", "of", "terms", "usually", "a", "TermInterpreter" ]
python
train
spyder-ide/spyder
spyder/widgets/comboboxes.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/comboboxes.py#L59-L72
def keyPressEvent(self, event): """Qt Override. Handle key press events. """ if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter: if self.add_current_text_if_valid(): self.selected() self.hide_completer() elif event...
[ "def", "keyPressEvent", "(", "self", ",", "event", ")", ":", "if", "event", ".", "key", "(", ")", "==", "Qt", ".", "Key_Return", "or", "event", ".", "key", "(", ")", "==", "Qt", ".", "Key_Enter", ":", "if", "self", ".", "add_current_text_if_valid", "...
Qt Override. Handle key press events.
[ "Qt", "Override", ".", "Handle", "key", "press", "events", "." ]
python
train
grst/geos
geos/server.py
https://github.com/grst/geos/blob/ea15abcc5d8f86c9051df55e489b7d941b51a638/geos/server.py#L96-L101
def kml_region(map_source, z, x, y): """KML region fetched by a Google Earth network link. """ map = app.config["mapsources"][map_source] kml_doc = KMLRegion(app.config["url_formatter"], map, app.config["LOG_TILES_PER_ROW"], z, x, y) return kml_response(kml_doc)
[ "def", "kml_region", "(", "map_source", ",", "z", ",", "x", ",", "y", ")", ":", "map", "=", "app", ".", "config", "[", "\"mapsources\"", "]", "[", "map_source", "]", "kml_doc", "=", "KMLRegion", "(", "app", ".", "config", "[", "\"url_formatter\"", "]",...
KML region fetched by a Google Earth network link.
[ "KML", "region", "fetched", "by", "a", "Google", "Earth", "network", "link", "." ]
python
train
ianepperson/telnetsrvlib
telnetsrv/evtlet.py
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/evtlet.py#L16-L24
def setup(self): '''Called after instantiation''' TelnetHandlerBase.setup(self) # Spawn a greenlet to handle socket input self.greenlet_ic = eventlet.spawn(self.inputcooker) # Note that inputcooker exits on EOF # Sleep for 0.5 second to allow options negotiation ...
[ "def", "setup", "(", "self", ")", ":", "TelnetHandlerBase", ".", "setup", "(", "self", ")", "# Spawn a greenlet to handle socket input", "self", ".", "greenlet_ic", "=", "eventlet", ".", "spawn", "(", "self", ".", "inputcooker", ")", "# Note that inputcooker exits o...
Called after instantiation
[ "Called", "after", "instantiation" ]
python
train
rosenbrockc/fortpy
fortpy/elements.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/elements.py#L507-L519
def customtype(self): """If this variable is a user-derivedy type, return the CustomType instance that is its kind. """ result = None if self.is_custom: #Look for the module that declares this variable's kind in its public list. self.dependency() ...
[ "def", "customtype", "(", "self", ")", ":", "result", "=", "None", "if", "self", ".", "is_custom", ":", "#Look for the module that declares this variable's kind in its public list.", "self", ".", "dependency", "(", ")", "if", "self", ".", "_kind_module", "is", "not"...
If this variable is a user-derivedy type, return the CustomType instance that is its kind.
[ "If", "this", "variable", "is", "a", "user", "-", "derivedy", "type", "return", "the", "CustomType", "instance", "that", "is", "its", "kind", "." ]
python
train
dschep/ntfy
ntfy/backends/pushbullet.py
https://github.com/dschep/ntfy/blob/ecfeee960af406a27ebb123495e0ec2733286889/ntfy/backends/pushbullet.py#L6-L39
def notify(title, message, access_token, device_iden=None, email=None, retcode=None): """ Required parameter: * ``access_token`` - Your Pushbullet access token, created at https://www.pushbullet.com/#settings/account Optional parame...
[ "def", "notify", "(", "title", ",", "message", ",", "access_token", ",", "device_iden", "=", "None", ",", "email", "=", "None", ",", "retcode", "=", "None", ")", ":", "data", "=", "{", "'type'", ":", "'note'", ",", "'title'", ":", "title", ",", "'bod...
Required parameter: * ``access_token`` - Your Pushbullet access token, created at https://www.pushbullet.com/#settings/account Optional parameters: * ``device_iden`` - a device identifier, if omited, notification is sent to all devices * ``email`` - s...
[ "Required", "parameter", ":", "*", "access_token", "-", "Your", "Pushbullet", "access", "token", "created", "at", "https", ":", "//", "www", ".", "pushbullet", ".", "com", "/", "#settings", "/", "account" ]
python
train
aparo/pyes
pyes/managers.py
https://github.com/aparo/pyes/blob/712eb6095961755067b2b5baa262008ade6584b3/pyes/managers.py#L167-L178
def create_index_if_missing(self, index, settings=None): """Creates an index if it doesn't already exist. If supplied, settings must be a dictionary. :param index: the name of the index :keyword settings: a settings object or a dict containing settings """ try: ...
[ "def", "create_index_if_missing", "(", "self", ",", "index", ",", "settings", "=", "None", ")", ":", "try", ":", "return", "self", ".", "create_index", "(", "index", ",", "settings", ")", "except", "IndexAlreadyExistsException", "as", "e", ":", "return", "e"...
Creates an index if it doesn't already exist. If supplied, settings must be a dictionary. :param index: the name of the index :keyword settings: a settings object or a dict containing settings
[ "Creates", "an", "index", "if", "it", "doesn", "t", "already", "exist", "." ]
python
train
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L10323-L10343
def run_usb_device_filters(self, device): """Asks the server to run USB devices filters of the associated machine against the given USB device and tell if there is a match. Intended to be used only for remote USB devices. Local ones don't require to call this method (thi...
[ "def", "run_usb_device_filters", "(", "self", ",", "device", ")", ":", "if", "not", "isinstance", "(", "device", ",", "IUSBDevice", ")", ":", "raise", "TypeError", "(", "\"device can only be an instance of type IUSBDevice\"", ")", "(", "matched", ",", "masked_interf...
Asks the server to run USB devices filters of the associated machine against the given USB device and tell if there is a match. Intended to be used only for remote USB devices. Local ones don't require to call this method (this is done implicitly by the Host and USBProxy...
[ "Asks", "the", "server", "to", "run", "USB", "devices", "filters", "of", "the", "associated", "machine", "against", "the", "given", "USB", "device", "and", "tell", "if", "there", "is", "a", "match", ".", "Intended", "to", "be", "used", "only", "for", "re...
python
train
callowayproject/django-categories
categories/registration.py
https://github.com/callowayproject/django-categories/blob/3765851320a79b12c6d3306f3784a2302ea64812/categories/registration.py#L22-L89
def register_model(self, app, model_name, field_type, field_definitions): """ Process for Django 1.7 + app: app name/label model_name: name of the model field_definitions: a string, tuple or list of field configurations field_type: either 'ForeignKey' or 'ManyToManyField'...
[ "def", "register_model", "(", "self", ",", "app", ",", "model_name", ",", "field_type", ",", "field_definitions", ")", ":", "from", "django", ".", "apps", "import", "apps", "import", "collections", "app_label", "=", "app", "if", "isinstance", "(", "field_defin...
Process for Django 1.7 + app: app name/label model_name: name of the model field_definitions: a string, tuple or list of field configurations field_type: either 'ForeignKey' or 'ManyToManyField'
[ "Process", "for", "Django", "1", ".", "7", "+", "app", ":", "app", "name", "/", "label", "model_name", ":", "name", "of", "the", "model", "field_definitions", ":", "a", "string", "tuple", "or", "list", "of", "field", "configurations", "field_type", ":", ...
python
train
Alignak-monitoring/alignak
alignak/stats.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/stats.py#L308-L362
def flush(self, log=False): """Send inner stored metrics to the defined Graphite Returns False if the sending failed with a warning log if log parameter is set :return: bool """ if not self.my_metrics: logger.debug("Flushing - no metrics to send") return...
[ "def", "flush", "(", "self", ",", "log", "=", "False", ")", ":", "if", "not", "self", ".", "my_metrics", ":", "logger", ".", "debug", "(", "\"Flushing - no metrics to send\"", ")", "return", "True", "now", "=", "int", "(", "time", ".", "time", "(", ")"...
Send inner stored metrics to the defined Graphite Returns False if the sending failed with a warning log if log parameter is set :return: bool
[ "Send", "inner", "stored", "metrics", "to", "the", "defined", "Graphite" ]
python
train
jahuth/litus
spikes.py
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L302-L319
def space(self,bins=None,units=None,conversion_function=convert_time,resolution=None,end_at_end=True,scale=None): """ Computes adequat binning for the dimension (on the values). bins: number of bins or None units: str or None conversion_function: func...
[ "def", "space", "(", "self", ",", "bins", "=", "None", ",", "units", "=", "None", ",", "conversion_function", "=", "convert_time", ",", "resolution", "=", "None", ",", "end_at_end", "=", "True", ",", "scale", "=", "None", ")", ":", "if", "scale", "in",...
Computes adequat binning for the dimension (on the values). bins: number of bins or None units: str or None conversion_function: function to convert units to other units resolution: step size or None end_at_end: Boolean ...
[ "Computes", "adequat", "binning", "for", "the", "dimension", "(", "on", "the", "values", ")", "." ]
python
train
klen/peewee_migrate
peewee_migrate/router.py
https://github.com/klen/peewee_migrate/blob/b77895ab1c9be3121bc127e0c2dfb047eed8b24c/peewee_migrate/router.py#L243-L248
def clear(self): """Remove migrations from fs.""" super(Router, self).clear() for name in self.todo: filename = os.path.join(self.migrate_dir, name + '.py') os.remove(filename)
[ "def", "clear", "(", "self", ")", ":", "super", "(", "Router", ",", "self", ")", ".", "clear", "(", ")", "for", "name", "in", "self", ".", "todo", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "migrate_dir", ",", "name",...
Remove migrations from fs.
[ "Remove", "migrations", "from", "fs", "." ]
python
train
knipknap/exscript
Exscript/protocols/telnetlib.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/protocols/telnetlib.py#L282-L287
def close(self): """Close the connection.""" if self.sock: self.sock.close() self.sock = 0 self.eof = 1
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "sock", ":", "self", ".", "sock", ".", "close", "(", ")", "self", ".", "sock", "=", "0", "self", ".", "eof", "=", "1" ]
Close the connection.
[ "Close", "the", "connection", "." ]
python
train
hyperledger/sawtooth-core
rest_api/sawtooth_rest_api/route_handlers.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L319-L349
async def list_blocks(self, request): """Fetches list of blocks from validator, optionally filtered by id. Request: query: - head: The id of the block to use as the head of the chain - id: Comma separated list of block ids to include in results Respo...
[ "async", "def", "list_blocks", "(", "self", ",", "request", ")", ":", "paging_controls", "=", "self", ".", "_get_paging_controls", "(", "request", ")", "validator_query", "=", "client_block_pb2", ".", "ClientBlockListRequest", "(", "head_id", "=", "self", ".", "...
Fetches list of blocks from validator, optionally filtered by id. Request: query: - head: The id of the block to use as the head of the chain - id: Comma separated list of block ids to include in results Response: data: JSON array of fully expand...
[ "Fetches", "list", "of", "blocks", "from", "validator", "optionally", "filtered", "by", "id", "." ]
python
train
gwastro/pycbc
pycbc/tmpltbank/option_utils.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/option_utils.py#L223-L233
def from_argparse(cls, opts): """ Initialize an instance of the metricParameters class from an argparse.OptionParser instance. This assumes that insert_metric_calculation_options and verify_metric_calculation_options have already been called before initializing th...
[ "def", "from_argparse", "(", "cls", ",", "opts", ")", ":", "return", "cls", "(", "opts", ".", "pn_order", ",", "opts", ".", "f_low", ",", "opts", ".", "f_upper", ",", "opts", ".", "delta_f", ",", "f0", "=", "opts", ".", "f0", ",", "write_metric", "...
Initialize an instance of the metricParameters class from an argparse.OptionParser instance. This assumes that insert_metric_calculation_options and verify_metric_calculation_options have already been called before initializing the class.
[ "Initialize", "an", "instance", "of", "the", "metricParameters", "class", "from", "an", "argparse", ".", "OptionParser", "instance", ".", "This", "assumes", "that", "insert_metric_calculation_options", "and", "verify_metric_calculation_options", "have", "already", "been",...
python
train
openergy/oplus
oplus/util.py
https://github.com/openergy/oplus/blob/f095868d1990c1d126e906ada6acbab26348b3d3/oplus/util.py#L119-L153
def get_string_buffer(path_or_content, expected_extension): """ path_or_content: path or content_str or content_bts or string_io or bytes_io Returns ------- string_buffer, path path will be None if input was not a path """ buffer, path = None, None # path or content string if...
[ "def", "get_string_buffer", "(", "path_or_content", ",", "expected_extension", ")", ":", "buffer", ",", "path", "=", "None", ",", "None", "# path or content string", "if", "isinstance", "(", "path_or_content", ",", "str", ")", ":", "if", "path_or_content", "[", ...
path_or_content: path or content_str or content_bts or string_io or bytes_io Returns ------- string_buffer, path path will be None if input was not a path
[ "path_or_content", ":", "path", "or", "content_str", "or", "content_bts", "or", "string_io", "or", "bytes_io" ]
python
test
kwikteam/phy
phy/plot/transform.py
https://github.com/kwikteam/phy/blob/7e9313dc364304b7d2bd03b92938347343703003/phy/plot/transform.py#L300-L305
def remove(self, name): """Remove a transform in the chain.""" cpu_transforms = self._remove_transform(self.cpu_transforms, name) gpu_transforms = self._remove_transform(self.gpu_transforms, name) return (TransformChain().add_on_cpu(cpu_transforms). add_on_gpu(gpu_transfo...
[ "def", "remove", "(", "self", ",", "name", ")", ":", "cpu_transforms", "=", "self", ".", "_remove_transform", "(", "self", ".", "cpu_transforms", ",", "name", ")", "gpu_transforms", "=", "self", ".", "_remove_transform", "(", "self", ".", "gpu_transforms", "...
Remove a transform in the chain.
[ "Remove", "a", "transform", "in", "the", "chain", "." ]
python
train
AndreLouisCaron/runwith
runwith/__init__.py
https://github.com/AndreLouisCaron/runwith/blob/cfa2b6ae67d73ec5b24f1502a37060d838276e8b/runwith/__init__.py#L51-L94
def main(argv=None): """Program entry point.""" # If we're invoked directly (runwith ...), we'll get None here. if argv is None: argv = sys.argv[1:] # Parse command-line arguments. argv = cli.parse_args(argv) # Translate CLI arguments to Popen options. options = {} for k in ('...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "# If we're invoked directly (runwith ...), we'll get None here.", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", "# Parse command-line arguments.", "argv", "=", "cli", "."...
Program entry point.
[ "Program", "entry", "point", "." ]
python
train
saltstack/salt
salt/cloud/clouds/oneandone.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/oneandone.py#L408-L426
def avail_images(conn=None, call=None): ''' Return a list of the server appliances that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must be called with ' '-f or --function, or with the --list-images option' ) ...
[ "def", "avail_images", "(", "conn", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The avail_images function must be called with '", "'-f or --function, or with the --list-images option'", ")", ...
Return a list of the server appliances that are on the provider
[ "Return", "a", "list", "of", "the", "server", "appliances", "that", "are", "on", "the", "provider" ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py#L880-L896
def get_interface_detail_output_interface_line_protocol_exception_info(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_interface_detail = ET.Element("get_interface_detail") config = get_interface_detail output = ET.SubElement(get_interface_de...
[ "def", "get_interface_detail_output_interface_line_protocol_exception_info", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_interface_detail", "=", "ET", ".", "Element", "(", "\"get_interface_detail\""...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
nuagenetworks/bambou
bambou/nurest_modelcontroller.py
https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_modelcontroller.py#L87-L99
def get_first_model_with_rest_name(cls, rest_name): """ Get the first model corresponding to a rest_name Args: rest_name: the rest name """ models = cls.get_models_with_rest_name(rest_name) if len(models) > 0: return models[0] return No...
[ "def", "get_first_model_with_rest_name", "(", "cls", ",", "rest_name", ")", ":", "models", "=", "cls", ".", "get_models_with_rest_name", "(", "rest_name", ")", "if", "len", "(", "models", ")", ">", "0", ":", "return", "models", "[", "0", "]", "return", "No...
Get the first model corresponding to a rest_name Args: rest_name: the rest name
[ "Get", "the", "first", "model", "corresponding", "to", "a", "rest_name" ]
python
train
cmbruns/pyopenvr
src/openvr/__init__.py
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L2972-L2980
def pollNextEvent(self, pEvent): """ Returns true and fills the event with the next event on the queue if there is one. If there are no events this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct """ fn = self.function_table.pollNextEvent ...
[ "def", "pollNextEvent", "(", "self", ",", "pEvent", ")", ":", "fn", "=", "self", ".", "function_table", ".", "pollNextEvent", "result", "=", "fn", "(", "byref", "(", "pEvent", ")", ",", "sizeof", "(", "VREvent_t", ")", ")", "return", "result", "!=", "0...
Returns true and fills the event with the next event on the queue if there is one. If there are no events this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct
[ "Returns", "true", "and", "fills", "the", "event", "with", "the", "next", "event", "on", "the", "queue", "if", "there", "is", "one", ".", "If", "there", "are", "no", "events", "this", "method", "returns", "false", ".", "uncbVREvent", "should", "be", "the...
python
train
benley/butcher
butcher/cache.py
https://github.com/benley/butcher/blob/8b18828ea040af56b7835beab5fd03eab23cc9ee/butcher/cache.py#L128-L146
def get_obj(self, objpath, metahash, dst_path): """Get object from cache, write it to dst_path. Args: objpath: filename relative to buildroot (example: mini-boot/blahblah/somefile.bin) metahash: metahash. See targets/base.py dst_path: Absolute path where...
[ "def", "get_obj", "(", "self", ",", "objpath", ",", "metahash", ",", "dst_path", ")", ":", "incachepath", "=", "self", ".", "path_in_cache", "(", "objpath", ",", "metahash", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "incachepath", ")", "...
Get object from cache, write it to dst_path. Args: objpath: filename relative to buildroot (example: mini-boot/blahblah/somefile.bin) metahash: metahash. See targets/base.py dst_path: Absolute path where the file should be written. Raises: Cach...
[ "Get", "object", "from", "cache", "write", "it", "to", "dst_path", "." ]
python
train
craffel/mir_eval
mir_eval/io.py
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/io.py#L208-L242
def load_labeled_intervals(filename, delimiter=r'\s+'): r"""Import labeled intervals from an annotation file. The file should consist of three columns: Two consisting of numeric values corresponding to start and end time of each interval and a third corresponding to the label of each interval. This is...
[ "def", "load_labeled_intervals", "(", "filename", ",", "delimiter", "=", "r'\\s+'", ")", ":", "# Use our universal function to load in the events", "starts", ",", "ends", ",", "labels", "=", "load_delimited", "(", "filename", ",", "[", "float", ",", "float", ",", ...
r"""Import labeled intervals from an annotation file. The file should consist of three columns: Two consisting of numeric values corresponding to start and end time of each interval and a third corresponding to the label of each interval. This is primarily useful for processing events which span a dur...
[ "r", "Import", "labeled", "intervals", "from", "an", "annotation", "file", ".", "The", "file", "should", "consist", "of", "three", "columns", ":", "Two", "consisting", "of", "numeric", "values", "corresponding", "to", "start", "and", "end", "time", "of", "ea...
python
train
pudo/jsongraph
jsongraph/query.py
https://github.com/pudo/jsongraph/blob/35e4f397dbe69cd5553cf9cb9ab98859c3620f03/jsongraph/query.py#L154-L160
def base_object(self, data): """ Make sure to return all the existing filter fields for query results. """ obj = {'id': data.get(self.id)} if self.parent is not None: obj['$parent'] = data.get(self.parent.id) return obj
[ "def", "base_object", "(", "self", ",", "data", ")", ":", "obj", "=", "{", "'id'", ":", "data", ".", "get", "(", "self", ".", "id", ")", "}", "if", "self", ".", "parent", "is", "not", "None", ":", "obj", "[", "'$parent'", "]", "=", "data", ".",...
Make sure to return all the existing filter fields for query results.
[ "Make", "sure", "to", "return", "all", "the", "existing", "filter", "fields", "for", "query", "results", "." ]
python
train
ClimateImpactLab/DataFS
datafs/core/data_archive.py
https://github.com/ClimateImpactLab/DataFS/blob/0d32c2b4e18d300a11b748a552f6adbc3dd8f59d/datafs/core/data_archive.py#L299-L321
def _get_default_dependencies(self): ''' Get default dependencies for archive Get default dependencies from requirements file or (if no requirements file) from previous version ''' # Get default dependencies from requirements file default_dependencies = { ...
[ "def", "_get_default_dependencies", "(", "self", ")", ":", "# Get default dependencies from requirements file", "default_dependencies", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "self", ".", "api", ".", "default_versions", ".", "items", "(", ")", "if"...
Get default dependencies for archive Get default dependencies from requirements file or (if no requirements file) from previous version
[ "Get", "default", "dependencies", "for", "archive" ]
python
train
UDST/orca
orca/orca.py
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L2011-L2025
def injectables(**kwargs): """ Temporarily add injectables to the pipeline environment. Takes only keyword arguments. Injectables will be returned to their original state when the context manager exits. """ global _INJECTABLES original = _INJECTABLES.copy() _INJECTABLES.update(kwa...
[ "def", "injectables", "(", "*", "*", "kwargs", ")", ":", "global", "_INJECTABLES", "original", "=", "_INJECTABLES", ".", "copy", "(", ")", "_INJECTABLES", ".", "update", "(", "kwargs", ")", "yield", "_INJECTABLES", "=", "original" ]
Temporarily add injectables to the pipeline environment. Takes only keyword arguments. Injectables will be returned to their original state when the context manager exits.
[ "Temporarily", "add", "injectables", "to", "the", "pipeline", "environment", ".", "Takes", "only", "keyword", "arguments", "." ]
python
train
MonashBI/arcana
arcana/repository/tree.py
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L563-L589
def _fill_empty_sessions(self, fill_subjects, fill_visits): """ Fill in tree with additional empty subjects and/or visits to allow the study to pull its inputs from external repositories """ if fill_subjects is None: fill_subjects = [s.id for s in self.subjects] ...
[ "def", "_fill_empty_sessions", "(", "self", ",", "fill_subjects", ",", "fill_visits", ")", ":", "if", "fill_subjects", "is", "None", ":", "fill_subjects", "=", "[", "s", ".", "id", "for", "s", "in", "self", ".", "subjects", "]", "if", "fill_visits", "is", ...
Fill in tree with additional empty subjects and/or visits to allow the study to pull its inputs from external repositories
[ "Fill", "in", "tree", "with", "additional", "empty", "subjects", "and", "/", "or", "visits", "to", "allow", "the", "study", "to", "pull", "its", "inputs", "from", "external", "repositories" ]
python
train
vicalloy/lbutils
lbutils/utils.py
https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/utils.py#L21-L25
def fmt_num(num, zero_num=None): """ humanize number(9000 to 9,000) """ if zero_num is not None: num = floatformat(num, zero_num) return intcomma(num, False)
[ "def", "fmt_num", "(", "num", ",", "zero_num", "=", "None", ")", ":", "if", "zero_num", "is", "not", "None", ":", "num", "=", "floatformat", "(", "num", ",", "zero_num", ")", "return", "intcomma", "(", "num", ",", "False", ")" ]
humanize number(9000 to 9,000)
[ "humanize", "number", "(", "9000", "to", "9", "000", ")" ]
python
train
jjgomera/iapws
iapws/_iapws.py
https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/_iapws.py#L1183-L1229
def _D2O_ThCond(rho, T): """Equation for the thermal conductivity of heavy water Parameters ---------- rho : float Density, [kg/m³] T : float Temperature, [K] Returns ------- k : float Thermal conductivity, [W/mK] Examples -------- >>> _D2O_ThCond(9...
[ "def", "_D2O_ThCond", "(", "rho", ",", "T", ")", ":", "rhor", "=", "rho", "/", "358", "Tr", "=", "T", "/", "643.847", "tau", "=", "Tr", "/", "(", "abs", "(", "Tr", "-", "1.1", ")", "+", "1.1", ")", "no", "=", "[", "1.0", ",", "37.3223", ","...
Equation for the thermal conductivity of heavy water Parameters ---------- rho : float Density, [kg/m³] T : float Temperature, [K] Returns ------- k : float Thermal conductivity, [W/mK] Examples -------- >>> _D2O_ThCond(998, 298.15) 0.60771286758806...
[ "Equation", "for", "the", "thermal", "conductivity", "of", "heavy", "water" ]
python
train
thautwarm/Redy
Redy/Tools/PathLib.py
https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Tools/PathLib.py#L208-L233
def relative(self, start: typing.Optional[typing.Union['Path', str]] = None ) -> str: """ :param start: an object of NoneType or Path or str. :return: a string If `start` is None: returns the relative path of current Path object from ...
[ "def", "relative", "(", "self", ",", "start", ":", "typing", ".", "Optional", "[", "typing", ".", "Union", "[", "'Path'", ",", "str", "]", "]", "=", "None", ")", "->", "str", ":", "if", "start", "is", "None", ":", "return", "os", ".", "path", "."...
:param start: an object of NoneType or Path or str. :return: a string If `start` is None: returns the relative path of current Path object from its own directory. Else: returns the relative path of current Path object from the `start` path. e.g ...
[ ":", "param", "start", ":", "an", "object", "of", "NoneType", "or", "Path", "or", "str", ".", ":", "return", ":", "a", "string", "If", "start", "is", "None", ":", "returns", "the", "relative", "path", "of", "current", "Path", "object", "from", "its", ...
python
train
DataONEorg/d1_python
gmn/src/d1_gmn/app/auth.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/auth.py#L65-L72
def action_to_level(action): """Map action name to action level.""" try: return ACTION_LEVEL_MAP[action] except LookupError: raise d1_common.types.exceptions.InvalidRequest( 0, 'Unknown action. action="{}"'.format(action) )
[ "def", "action_to_level", "(", "action", ")", ":", "try", ":", "return", "ACTION_LEVEL_MAP", "[", "action", "]", "except", "LookupError", ":", "raise", "d1_common", ".", "types", ".", "exceptions", ".", "InvalidRequest", "(", "0", ",", "'Unknown action. action=\...
Map action name to action level.
[ "Map", "action", "name", "to", "action", "level", "." ]
python
train
tensorflow/tensor2tensor
tensor2tensor/models/transformer.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/transformer.py#L1921-L1931
def transformer_tall_pretrain_lm_tpu_adafactor_large(): """Hparams for transformer on LM pretraining on TPU, large model.""" hparams = transformer_tall_pretrain_lm_tpu_adafactor() hparams.hidden_size = 1024 hparams.num_heads = 16 hparams.filter_size = 32768 # max fitting in 16G memory is 49152, batch 2 hpa...
[ "def", "transformer_tall_pretrain_lm_tpu_adafactor_large", "(", ")", ":", "hparams", "=", "transformer_tall_pretrain_lm_tpu_adafactor", "(", ")", "hparams", ".", "hidden_size", "=", "1024", "hparams", ".", "num_heads", "=", "16", "hparams", ".", "filter_size", "=", "3...
Hparams for transformer on LM pretraining on TPU, large model.
[ "Hparams", "for", "transformer", "on", "LM", "pretraining", "on", "TPU", "large", "model", "." ]
python
train
pydata/xarray
xarray/core/missing.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/missing.py#L259-L272
def ffill(arr, dim=None, limit=None): '''forward fill missing values''' import bottleneck as bn axis = arr.get_axis_num(dim) # work around for bottleneck 178 _limit = limit if limit is not None else arr.shape[axis] return apply_ufunc(bn.push, arr, dask='parallelized', ...
[ "def", "ffill", "(", "arr", ",", "dim", "=", "None", ",", "limit", "=", "None", ")", ":", "import", "bottleneck", "as", "bn", "axis", "=", "arr", ".", "get_axis_num", "(", "dim", ")", "# work around for bottleneck 178", "_limit", "=", "limit", "if", "lim...
forward fill missing values
[ "forward", "fill", "missing", "values" ]
python
train
tsroten/pynlpir
pynlpir/__init__.py
https://github.com/tsroten/pynlpir/blob/8d5e994796a2b5d513f7db8d76d7d24a85d531b1/pynlpir/__init__.py#L50-L110
def open(data_dir=nlpir.PACKAGE_DIR, encoding=ENCODING, encoding_errors=ENCODING_ERRORS, license_code=None): """Initializes the NLPIR API. This calls the function :func:`~pynlpir.nlpir.Init`. :param str data_dir: The absolute path to the directory that has NLPIR's `Data` directory (defaul...
[ "def", "open", "(", "data_dir", "=", "nlpir", ".", "PACKAGE_DIR", ",", "encoding", "=", "ENCODING", ",", "encoding_errors", "=", "ENCODING_ERRORS", ",", "license_code", "=", "None", ")", ":", "if", "license_code", "is", "None", ":", "license_code", "=", "''"...
Initializes the NLPIR API. This calls the function :func:`~pynlpir.nlpir.Init`. :param str data_dir: The absolute path to the directory that has NLPIR's `Data` directory (defaults to :data:`pynlpir.nlpir.PACKAGE_DIR`). :param str encoding: The encoding that the Chinese source text will be in ...
[ "Initializes", "the", "NLPIR", "API", "." ]
python
train
pystorm/pystorm
pystorm/serializers/json_serializer.py
https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/serializers/json_serializer.py#L39-L91
def read_message(self): """The Storm multilang protocol consists of JSON messages followed by a newline and "end\n". All of Storm's messages (for either bolts or spouts) should be of the form:: '<command or task_id form prior emit>\\nend\\n' Command example, an inc...
[ "def", "read_message", "(", "self", ")", ":", "msg", "=", "\"\"", "num_blank_lines", "=", "0", "while", "True", ":", "# readline will return trailing \\n so that output is unambigious, we", "# should only have line == '' if we're at EOF", "with", "self", ".", "_reader_lock", ...
The Storm multilang protocol consists of JSON messages followed by a newline and "end\n". All of Storm's messages (for either bolts or spouts) should be of the form:: '<command or task_id form prior emit>\\nend\\n' Command example, an incoming Tuple to a bolt:: ...
[ "The", "Storm", "multilang", "protocol", "consists", "of", "JSON", "messages", "followed", "by", "a", "newline", "and", "end", "\\", "n", "." ]
python
train
apache/incubator-mxnet
python/mxnet/model.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L58-L80
def _create_sparse_kvstore(kvstore): """Create kvstore assuming some parameters' storage types are row_sparse. Parameters ---------- kvstore : KVStore or str The kvstore. Returns ------- kvstore : KVStore update_on_kvstore : bool. Always True. """ # always update on kvs...
[ "def", "_create_sparse_kvstore", "(", "kvstore", ")", ":", "# always update on kvstore", "update_on_kvstore", "=", "True", "if", "isinstance", "(", "kvstore", ",", "kvs", ".", "KVStore", ")", ":", "kv", "=", "kvstore", "elif", "isinstance", "(", "kvstore", ",", ...
Create kvstore assuming some parameters' storage types are row_sparse. Parameters ---------- kvstore : KVStore or str The kvstore. Returns ------- kvstore : KVStore update_on_kvstore : bool. Always True.
[ "Create", "kvstore", "assuming", "some", "parameters", "storage", "types", "are", "row_sparse", "." ]
python
train
ANTsX/ANTsPy
ants/core/ants_image.py
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L129-L138
def origin(self): """ Get image origin Returns ------- tuple """ libfn = utils.get_lib_fn('getOrigin%s'%self._libsuffix) return libfn(self.pointer)
[ "def", "origin", "(", "self", ")", ":", "libfn", "=", "utils", ".", "get_lib_fn", "(", "'getOrigin%s'", "%", "self", ".", "_libsuffix", ")", "return", "libfn", "(", "self", ".", "pointer", ")" ]
Get image origin Returns ------- tuple
[ "Get", "image", "origin" ]
python
train
rocky/python-xdis
xdis/dropbox/decrypt25.py
https://github.com/rocky/python-xdis/blob/46a2902ae8f5d8eee495eed67ac0690fd545453d/xdis/dropbox/decrypt25.py#L168-L175
def loads(s): """ xdis.marshal.load() but with its dispatch load_code() function replaced with our decoding version. """ um = xmarshal._FastUnmarshaller(s) um.dispatch[xmarshal.TYPE_CODE] = load_code return um.load()
[ "def", "loads", "(", "s", ")", ":", "um", "=", "xmarshal", ".", "_FastUnmarshaller", "(", "s", ")", "um", ".", "dispatch", "[", "xmarshal", ".", "TYPE_CODE", "]", "=", "load_code", "return", "um", ".", "load", "(", ")" ]
xdis.marshal.load() but with its dispatch load_code() function replaced with our decoding version.
[ "xdis", ".", "marshal", ".", "load", "()", "but", "with", "its", "dispatch", "load_code", "()", "function", "replaced", "with", "our", "decoding", "version", "." ]
python
train
rgs1/zk_shell
zk_shell/acl.py
https://github.com/rgs1/zk_shell/blob/bbf34fdfcf1f81100e2a5816fad8af6afc782a54/zk_shell/acl.py#L85-L91
def from_dict(cls, acl_dict): """ ACL from dict """ perms = acl_dict.get("perms", Permissions.ALL) id_dict = acl_dict.get("id", {}) id_scheme = id_dict.get("scheme", "world") id_id = id_dict.get("id", "anyone") return ACL(perms, Id(id_scheme, id_id))
[ "def", "from_dict", "(", "cls", ",", "acl_dict", ")", ":", "perms", "=", "acl_dict", ".", "get", "(", "\"perms\"", ",", "Permissions", ".", "ALL", ")", "id_dict", "=", "acl_dict", ".", "get", "(", "\"id\"", ",", "{", "}", ")", "id_scheme", "=", "id_d...
ACL from dict
[ "ACL", "from", "dict" ]
python
train
pypa/pipenv
pipenv/vendor/cerberus/validator.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/cerberus/validator.py#L341-L361
def _drop_nodes_from_errorpaths(self, _errors, dp_items, sp_items): """ Removes nodes by index from an errorpath, relatively to the basepaths of self. :param errors: A list of :class:`errors.ValidationError` instances. :param dp_items: A list of integers, pointing at the nodes to dr...
[ "def", "_drop_nodes_from_errorpaths", "(", "self", ",", "_errors", ",", "dp_items", ",", "sp_items", ")", ":", "dp_basedepth", "=", "len", "(", "self", ".", "document_path", ")", "sp_basedepth", "=", "len", "(", "self", ".", "schema_path", ")", "for", "error...
Removes nodes by index from an errorpath, relatively to the basepaths of self. :param errors: A list of :class:`errors.ValidationError` instances. :param dp_items: A list of integers, pointing at the nodes to drop from the :attr:`document_path`. :param sp_it...
[ "Removes", "nodes", "by", "index", "from", "an", "errorpath", "relatively", "to", "the", "basepaths", "of", "self", "." ]
python
train
mkouhei/bootstrap-py
bootstrap_py/commands.py
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/commands.py#L54-L69
def valid_url(url): """Validate url. :rtype: str :return: url :param str url: package homepage url. """ regex = re.compile( r'^(?:http)s?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+' r'(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?))' r'(?:/?|[/?]\S+)$', re.IGNORECA...
[ "def", "valid_url", "(", "url", ")", ":", "regex", "=", "re", ".", "compile", "(", "r'^(?:http)s?://'", "r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+'", "r'(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?))'", "r'(?:/?|[/?]\\S+)$'", ",", "re", ".", "IGNORECASE", ")", "if", "not",...
Validate url. :rtype: str :return: url :param str url: package homepage url.
[ "Validate", "url", "." ]
python
train
raamana/mrivis
mrivis/base.py
https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/base.py#L1110-L1126
def _apply_mask(self, roi_mask): """Removes voxels outside the given mask or ROI set.""" # TODO ensure compatible with input image # - must have < N dim and same size in moving dims. rows_to_delete = list() # to allow for additional masks to be applied in the future if isinsta...
[ "def", "_apply_mask", "(", "self", ",", "roi_mask", ")", ":", "# TODO ensure compatible with input image", "# - must have < N dim and same size in moving dims.", "rows_to_delete", "=", "list", "(", ")", "# to allow for additional masks to be applied in the future", "if", "isinsta...
Removes voxels outside the given mask or ROI set.
[ "Removes", "voxels", "outside", "the", "given", "mask", "or", "ROI", "set", "." ]
python
train
wummel/linkchecker
linkcheck/director/console.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/director/console.py#L143-L155
def print_app_info (out=stderr): """Print system and application info (output defaults to stderr).""" print(_("System info:"), file=out) print(configuration.App, file=out) print(_("Released on:"), configuration.ReleaseDate, file=out) print(_("Python %(version)s on %(platform)s") % ...
[ "def", "print_app_info", "(", "out", "=", "stderr", ")", ":", "print", "(", "_", "(", "\"System info:\"", ")", ",", "file", "=", "out", ")", "print", "(", "configuration", ".", "App", ",", "file", "=", "out", ")", "print", "(", "_", "(", "\"Released ...
Print system and application info (output defaults to stderr).
[ "Print", "system", "and", "application", "info", "(", "output", "defaults", "to", "stderr", ")", "." ]
python
train
tanghaibao/jcvi
jcvi/apps/base.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/base.py#L1228-L1257
def pushover(message, token, user, title="JCVI: Job Monitor", \ priority=0, timestamp=None): """ pushover.net python API <https://pushover.net/faq#library-python> """ assert -1 <= priority <= 2, \ "Priority should be an int() between -1 and 2" if timestamp == None: ...
[ "def", "pushover", "(", "message", ",", "token", ",", "user", ",", "title", "=", "\"JCVI: Job Monitor\"", ",", "priority", "=", "0", ",", "timestamp", "=", "None", ")", ":", "assert", "-", "1", "<=", "priority", "<=", "2", ",", "\"Priority should be an int...
pushover.net python API <https://pushover.net/faq#library-python>
[ "pushover", ".", "net", "python", "API" ]
python
train