repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
apache/spark
python/pyspark/sql/readwriter.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L116-L125
def option(self, key, value): """Adds an input option for the underlying data source. You can set the following option(s) for reading files: * ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps in the JSON/CSV datasources or partition valu...
[ "def", "option", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "_jreader", "=", "self", ".", "_jreader", ".", "option", "(", "key", ",", "to_str", "(", "value", ")", ")", "return", "self" ]
Adds an input option for the underlying data source. You can set the following option(s) for reading files: * ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps in the JSON/CSV datasources or partition values. If it isn't set, it u...
[ "Adds", "an", "input", "option", "for", "the", "underlying", "data", "source", "." ]
python
train
49.5
guaix-ucm/pyemir
emirdrp/products.py
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/products.py#L97-L105
def convert_out(self, obj): """Write EMIRUUID header on reduction""" newobj = super(ProcessedImageProduct, self).convert_out(obj) if newobj: hdulist = newobj.open() hdr = hdulist[0].header if 'EMIRUUID' not in hdr: hdr['EMIRUUID'] = str(uuid.uu...
[ "def", "convert_out", "(", "self", ",", "obj", ")", ":", "newobj", "=", "super", "(", "ProcessedImageProduct", ",", "self", ")", ".", "convert_out", "(", "obj", ")", "if", "newobj", ":", "hdulist", "=", "newobj", ".", "open", "(", ")", "hdr", "=", "h...
Write EMIRUUID header on reduction
[ "Write", "EMIRUUID", "header", "on", "reduction" ]
python
train
37.777778
odooku/odooku
odooku/services/websocket/requests.py
https://github.com/odooku/odooku/blob/52dff30a9b75299eaac043f06a4943c9be759bd6/odooku/services/websocket/requests.py#L48-L68
def _handle_exception(self, exception): """Called within an except block to allow converting exceptions to arbitrary responses. Anything returned (except None) will be used as response.""" try: return super(WebSocketRpcRequest, self)._handle_exception(exception) ...
[ "def", "_handle_exception", "(", "self", ",", "exception", ")", ":", "try", ":", "return", "super", "(", "WebSocketRpcRequest", ",", "self", ")", ".", "_handle_exception", "(", "exception", ")", "except", "Exception", ":", "if", "not", "isinstance", "(", "ex...
Called within an except block to allow converting exceptions to arbitrary responses. Anything returned (except None) will be used as response.
[ "Called", "within", "an", "except", "block", "to", "allow", "converting", "exceptions", "to", "arbitrary", "responses", ".", "Anything", "returned", "(", "except", "None", ")", "will", "be", "used", "as", "response", "." ]
python
train
52.333333
kivy/python-for-android
pythonforandroid/recipe.py
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/recipe.py#L440-L448
def prebuild_arch(self, arch): '''Run any pre-build tasks for the Recipe. By default, this checks if any prebuild_archname methods exist for the archname of the current architecture, and runs them if so.''' prebuild = "prebuild_{}".format(arch.arch.replace('-', '_')) if hasattr(s...
[ "def", "prebuild_arch", "(", "self", ",", "arch", ")", ":", "prebuild", "=", "\"prebuild_{}\"", ".", "format", "(", "arch", ".", "arch", ".", "replace", "(", "'-'", ",", "'_'", ")", ")", "if", "hasattr", "(", "self", ",", "prebuild", ")", ":", "getat...
Run any pre-build tasks for the Recipe. By default, this checks if any prebuild_archname methods exist for the archname of the current architecture, and runs them if so.
[ "Run", "any", "pre", "-", "build", "tasks", "for", "the", "Recipe", ".", "By", "default", "this", "checks", "if", "any", "prebuild_archname", "methods", "exist", "for", "the", "archname", "of", "the", "current", "architecture", "and", "runs", "them", "if", ...
python
train
50
avalente/appmetrics
appmetrics/histogram.py
https://github.com/avalente/appmetrics/blob/366fc7e1ca897e49a2227cbfa43bfa02a47f1acc/appmetrics/histogram.py#L272-L279
def _put(self, timestamp, value): """Replace the value associated with "timestamp" or add the new value""" idx = self._lookup(timestamp) if idx is not None: self._values[idx] = (timestamp, value) else: self._values.append((timestamp, value))
[ "def", "_put", "(", "self", ",", "timestamp", ",", "value", ")", ":", "idx", "=", "self", ".", "_lookup", "(", "timestamp", ")", "if", "idx", "is", "not", "None", ":", "self", ".", "_values", "[", "idx", "]", "=", "(", "timestamp", ",", "value", ...
Replace the value associated with "timestamp" or add the new value
[ "Replace", "the", "value", "associated", "with", "timestamp", "or", "add", "the", "new", "value" ]
python
train
36.375
senaite/senaite.core
bika/lims/idserver.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/idserver.py#L353-L358
def get_ids_with_prefix(portal_type, prefix): """Return a list of ids sharing the same portal type and prefix """ brains = search_by_prefix(portal_type, prefix) ids = map(api.get_id, brains) return ids
[ "def", "get_ids_with_prefix", "(", "portal_type", ",", "prefix", ")", ":", "brains", "=", "search_by_prefix", "(", "portal_type", ",", "prefix", ")", "ids", "=", "map", "(", "api", ".", "get_id", ",", "brains", ")", "return", "ids" ]
Return a list of ids sharing the same portal type and prefix
[ "Return", "a", "list", "of", "ids", "sharing", "the", "same", "portal", "type", "and", "prefix" ]
python
train
36
GoogleCloudPlatform/datastore-ndb-python
demo/app/fibo.py
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/app/fibo.py#L46-L63
def memoizing_fibonacci(n): """A memoizing recursive Fibonacci to exercise RPCs.""" if n <= 1: raise ndb.Return(n) key = ndb.Key(FibonacciMemo, str(n)) memo = yield key.get_async(ndb_should_cache=False) if memo is not None: assert memo.arg == n logging.info('memo hit: %d -> %d', n, memo.value) ...
[ "def", "memoizing_fibonacci", "(", "n", ")", ":", "if", "n", "<=", "1", ":", "raise", "ndb", ".", "Return", "(", "n", ")", "key", "=", "ndb", ".", "Key", "(", "FibonacciMemo", ",", "str", "(", "n", ")", ")", "memo", "=", "yield", "key", ".", "g...
A memoizing recursive Fibonacci to exercise RPCs.
[ "A", "memoizing", "recursive", "Fibonacci", "to", "exercise", "RPCs", "." ]
python
train
35.222222
rbarrois/django_xworkflows
django_xworkflows/models.py
https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L115-L123
def contribute_to_class(self, cls, name): """Contribute the state to a Model. Attaches a StateFieldProperty to wrap the attribute. """ super(StateField, self).contribute_to_class(cls, name) parent_property = getattr(cls, self.name, None) setattr(cls, self.name, StateFie...
[ "def", "contribute_to_class", "(", "self", ",", "cls", ",", "name", ")", ":", "super", "(", "StateField", ",", "self", ")", ".", "contribute_to_class", "(", "cls", ",", "name", ")", "parent_property", "=", "getattr", "(", "cls", ",", "self", ".", "name",...
Contribute the state to a Model. Attaches a StateFieldProperty to wrap the attribute.
[ "Contribute", "the", "state", "to", "a", "Model", "." ]
python
train
38.444444
wummel/patool
patoolib/__init__.py
https://github.com/wummel/patool/blob/d7e64d9fd60faaa4b3f824bd97c43ce59b185c40/patoolib/__init__.py#L427-L430
def make_file_readable (filename): """Make file user readable if it is not a link.""" if not os.path.islink(filename): util.set_mode(filename, stat.S_IRUSR)
[ "def", "make_file_readable", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "islink", "(", "filename", ")", ":", "util", ".", "set_mode", "(", "filename", ",", "stat", ".", "S_IRUSR", ")" ]
Make file user readable if it is not a link.
[ "Make", "file", "user", "readable", "if", "it", "is", "not", "a", "link", "." ]
python
train
42.25
rfarley3/Kibana
kibana/manager.py
https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/manager.py#L161-L163
def json_dumps(self, obj): """Serializer for consistency""" return json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': '))
[ "def", "json_dumps", "(", "self", ",", "obj", ")", ":", "return", "json", ".", "dumps", "(", "obj", ",", "sort_keys", "=", "True", ",", "indent", "=", "4", ",", "separators", "=", "(", "','", ",", "': '", ")", ")" ]
Serializer for consistency
[ "Serializer", "for", "consistency" ]
python
train
48.666667
kennethreitz/requests-html
requests_html.py
https://github.com/kennethreitz/requests-html/blob/b59a9f2fb9333d7d467154a0fd82978efdb9d23b/requests_html.py#L119-L136
def encoding(self) -> _Encoding: """The encoding string to be used, extracted from the HTML and :class:`HTMLResponse <HTMLResponse>` headers. """ if self._encoding: return self._encoding # Scan meta tags for charset. if self._html: self._encoding ...
[ "def", "encoding", "(", "self", ")", "->", "_Encoding", ":", "if", "self", ".", "_encoding", ":", "return", "self", ".", "_encoding", "# Scan meta tags for charset.", "if", "self", ".", "_html", ":", "self", ".", "_encoding", "=", "html_to_unicode", "(", "se...
The encoding string to be used, extracted from the HTML and :class:`HTMLResponse <HTMLResponse>` headers.
[ "The", "encoding", "string", "to", "be", "used", "extracted", "from", "the", "HTML", "and", ":", "class", ":", "HTMLResponse", "<HTMLResponse", ">", "headers", "." ]
python
train
38.222222
fhcrc/taxtastic
taxtastic/refpkg.py
https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/refpkg.py#L256-L260
def resource_md5(self, resource): """Return the stored MD5 sum for a particular named resource.""" if not(resource in self.contents['md5']): raise ValueError("No such resource %r in refpkg" % (resource,)) return self.contents['md5'][resource]
[ "def", "resource_md5", "(", "self", ",", "resource", ")", ":", "if", "not", "(", "resource", "in", "self", ".", "contents", "[", "'md5'", "]", ")", ":", "raise", "ValueError", "(", "\"No such resource %r in refpkg\"", "%", "(", "resource", ",", ")", ")", ...
Return the stored MD5 sum for a particular named resource.
[ "Return", "the", "stored", "MD5", "sum", "for", "a", "particular", "named", "resource", "." ]
python
train
54.8
thiagopbueno/pyrddl
pyrddl/parser.py
https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L343-L350
def p_pvar_list(self, p): '''pvar_list : pvar_list pvar_def | empty''' if p[1] is None: p[0] = [] else: p[1].append(p[2]) p[0] = p[1]
[ "def", "p_pvar_list", "(", "self", ",", "p", ")", ":", "if", "p", "[", "1", "]", "is", "None", ":", "p", "[", "0", "]", "=", "[", "]", "else", ":", "p", "[", "1", "]", ".", "append", "(", "p", "[", "2", "]", ")", "p", "[", "0", "]", "...
pvar_list : pvar_list pvar_def | empty
[ "pvar_list", ":", "pvar_list", "pvar_def", "|", "empty" ]
python
train
25.875
adamheins/r12
r12/arm.py
https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/arm.py#L36-L39
def r12_serial_port(port): ''' Create a serial connect to the arm. ''' return serial.Serial(port, baudrate=BAUD_RATE, parity=PARITY, stopbits=STOP_BITS, bytesize=BYTE_SIZE)
[ "def", "r12_serial_port", "(", "port", ")", ":", "return", "serial", ".", "Serial", "(", "port", ",", "baudrate", "=", "BAUD_RATE", ",", "parity", "=", "PARITY", ",", "stopbits", "=", "STOP_BITS", ",", "bytesize", "=", "BYTE_SIZE", ")" ]
Create a serial connect to the arm.
[ "Create", "a", "serial", "connect", "to", "the", "arm", "." ]
python
train
50.5
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/werkzeug/debug/tbtools.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/werkzeug/debug/tbtools.py#L152-L169
def get_current_traceback(ignore_system_exceptions=False, show_hidden_frames=False, skip=0): """Get the current exception info as `Traceback` object. Per default calling this method will reraise system exceptions such as generator exit, system exit or others. This behavior can be...
[ "def", "get_current_traceback", "(", "ignore_system_exceptions", "=", "False", ",", "show_hidden_frames", "=", "False", ",", "skip", "=", "0", ")", ":", "exc_type", ",", "exc_value", ",", "tb", "=", "sys", ".", "exc_info", "(", ")", "if", "ignore_system_except...
Get the current exception info as `Traceback` object. Per default calling this method will reraise system exceptions such as generator exit, system exit or others. This behavior can be disabled by passing `False` to the function as first parameter.
[ "Get", "the", "current", "exception", "info", "as", "Traceback", "object", ".", "Per", "default", "calling", "this", "method", "will", "reraise", "system", "exceptions", "such", "as", "generator", "exit", "system", "exit", "or", "others", ".", "This", "behavio...
python
test
40.666667
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L944-L971
def dump(self, indentation=0): """Returns a string representation of the structure.""" dump = [] dump.append('[%s]' % self.name) # Refer to the __set_format__ method for an explanation # of the following construct. for keys in self.__keys__: ...
[ "def", "dump", "(", "self", ",", "indentation", "=", "0", ")", ":", "dump", "=", "[", "]", "dump", ".", "append", "(", "'[%s]'", "%", "self", ".", "name", ")", "# Refer to the __set_format__ method for an explanation", "# of the following construct.", "for", "ke...
Returns a string representation of the structure.
[ "Returns", "a", "string", "representation", "of", "the", "structure", "." ]
python
train
40.321429
wummel/patool
patoolib/programs/cpio.py
https://github.com/wummel/patool/blob/d7e64d9fd60faaa4b3f824bd97c43ce59b185c40/patoolib/programs/cpio.py#L44-L56
def create_cpio(archive, compression, cmd, verbosity, interactive, filenames): """Create a CPIO archive.""" cmdlist = [util.shell_quote(cmd), '--create'] if verbosity > 1: cmdlist.append('-v') if len(filenames) != 0: findcmd = ['find'] findcmd.extend([util.shell_quote(x) for x in...
[ "def", "create_cpio", "(", "archive", ",", "compression", ",", "cmd", ",", "verbosity", ",", "interactive", ",", "filenames", ")", ":", "cmdlist", "=", "[", "util", ".", "shell_quote", "(", "cmd", ")", ",", "'--create'", "]", "if", "verbosity", ">", "1",...
Create a CPIO archive.
[ "Create", "a", "CPIO", "archive", "." ]
python
train
39.384615
PrefPy/prefpy
prefpy/aggregate.py
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/aggregate.py#L55-L69
def get_alternatives(self, rank): """ Description: Returns the alternative(s) with the given ranking in the computed aggregate ranking. An error is thrown if the ranking does not exist. """ if self.ranks_to_alts is None: raise Va...
[ "def", "get_alternatives", "(", "self", ",", "rank", ")", ":", "if", "self", ".", "ranks_to_alts", "is", "None", ":", "raise", "ValueError", "(", "\"Aggregate ranking must be created first\"", ")", "try", ":", "alts", "=", "self", ".", "ranks_to_alts", "[", "r...
Description: Returns the alternative(s) with the given ranking in the computed aggregate ranking. An error is thrown if the ranking does not exist.
[ "Description", ":", "Returns", "the", "alternative", "(", "s", ")", "with", "the", "given", "ranking", "in", "the", "computed", "aggregate", "ranking", ".", "An", "error", "is", "thrown", "if", "the", "ranking", "does", "not", "exist", "." ]
python
train
39.866667
char16t/wa
wa/api.py
https://github.com/char16t/wa/blob/ee28bf47665ea57f3a03a08dfc0a5daaa33d8121/wa/api.py#L130-L150
def copy_tree_and_replace_vars(self, src, dst): """ Если передается директория в качестве аргумента, то будет рассматриваться как шаблон именно её содержимое!! Оно же и будет копироваться """ if os.path.isdir(src): copy_tree(src, self.temp_dir) elif os...
[ "def", "copy_tree_and_replace_vars", "(", "self", ",", "src", ",", "dst", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "src", ")", ":", "copy_tree", "(", "src", ",", "self", ".", "temp_dir", ")", "elif", "os", ".", "path", ".", "isfile", "...
Если передается директория в качестве аргумента, то будет рассматриваться как шаблон именно её содержимое!! Оно же и будет копироваться
[ "Если", "передается", "директория", "в", "качестве", "аргумента", "то", "будет", "рассматриваться", "как", "шаблон", "именно", "её", "содержимое!!", "Оно", "же", "и", "будет", "копироваться" ]
python
train
36.714286
ethereum/web3.py
web3/pm.py
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/pm.py#L531-L539
def get_release_id(self, package_name: str, version: str) -> bytes: """ Returns the 32 byte identifier of a release for the given package name and version, if they are available on the current registry. """ validate_package_name(package_name) validate_package_version(vers...
[ "def", "get_release_id", "(", "self", ",", "package_name", ":", "str", ",", "version", ":", "str", ")", "->", "bytes", ":", "validate_package_name", "(", "package_name", ")", "validate_package_version", "(", "version", ")", "self", ".", "_validate_set_registry", ...
Returns the 32 byte identifier of a release for the given package name and version, if they are available on the current registry.
[ "Returns", "the", "32", "byte", "identifier", "of", "a", "release", "for", "the", "given", "package", "name", "and", "version", "if", "they", "are", "available", "on", "the", "current", "registry", "." ]
python
train
46.888889
b3j0f/aop
b3j0f/aop/advice/core.py
https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L208-L218
def _namematcher(regex): """Checks if a target name matches with an input regular expression.""" matcher = re_compile(regex) def match(target): target_name = getattr(target, '__name__', '') result = matcher.match(target_name) return result return match
[ "def", "_namematcher", "(", "regex", ")", ":", "matcher", "=", "re_compile", "(", "regex", ")", "def", "match", "(", "target", ")", ":", "target_name", "=", "getattr", "(", "target", ",", "'__name__'", ",", "''", ")", "result", "=", "matcher", ".", "ma...
Checks if a target name matches with an input regular expression.
[ "Checks", "if", "a", "target", "name", "matches", "with", "an", "input", "regular", "expression", "." ]
python
train
25.909091
hvac/hvac
hvac/api/secrets_engines/aws.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/secrets_engines/aws.py#L17-L68
def configure_root_iam_credentials(self, access_key, secret_key, region=None, iam_endpoint=None, sts_endpoint=None, max_retries=-1, mount_point=DEFAULT_MOUNT_POINT): """Configure the root IAM credentials to communicate with AWS. There are multiple ways to pass roo...
[ "def", "configure_root_iam_credentials", "(", "self", ",", "access_key", ",", "secret_key", ",", "region", "=", "None", ",", "iam_endpoint", "=", "None", ",", "sts_endpoint", "=", "None", ",", "max_retries", "=", "-", "1", ",", "mount_point", "=", "DEFAULT_MOU...
Configure the root IAM credentials to communicate with AWS. There are multiple ways to pass root IAM credentials to the Vault server, specified below with the highest precedence first. If credentials already exist, this will overwrite them. The official AWS SDK is used for sourcing credentials...
[ "Configure", "the", "root", "IAM", "credentials", "to", "communicate", "with", "AWS", "." ]
python
train
49.019231
hvac/hvac
hvac/v1/__init__.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/v1/__init__.py#L1313-L1329
def get_role_secret_id(self, role_name, secret_id, mount_point='approle'): """POST /auth/<mount_point>/role/<role name>/secret-id/lookup :param role_name: :type role_name: :param secret_id: :type secret_id: :param mount_point: :type mount_point: :return: ...
[ "def", "get_role_secret_id", "(", "self", ",", "role_name", ",", "secret_id", ",", "mount_point", "=", "'approle'", ")", ":", "url", "=", "'/v1/auth/{0}/role/{1}/secret-id/lookup'", ".", "format", "(", "mount_point", ",", "role_name", ")", "params", "=", "{", "'...
POST /auth/<mount_point>/role/<role name>/secret-id/lookup :param role_name: :type role_name: :param secret_id: :type secret_id: :param mount_point: :type mount_point: :return: :rtype:
[ "POST", "/", "auth", "/", "<mount_point", ">", "/", "role", "/", "<role", "name", ">", "/", "secret", "-", "id", "/", "lookup" ]
python
train
31.764706
flo-compbio/genometools
genometools/expression/gene_table.py
https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L97-L100
def genes(self): """Return a list of all genes.""" return [ExpGene.from_series(g) for i, g in self.reset_index().iterrows()]
[ "def", "genes", "(", "self", ")", ":", "return", "[", "ExpGene", ".", "from_series", "(", "g", ")", "for", "i", ",", "g", "in", "self", ".", "reset_index", "(", ")", ".", "iterrows", "(", ")", "]" ]
Return a list of all genes.
[ "Return", "a", "list", "of", "all", "genes", "." ]
python
train
38.25
tdryer/hangups
hangups/conversation.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/conversation.py#L825-L834
def _add_conversation(self, conversation, events=[], event_cont_token=None): """Add new conversation from hangouts_pb2.Conversation""" # pylint: disable=dangerous-default-value conv_id = conversation.conversation_id.id logger.debug('Adding new conversation: {}'....
[ "def", "_add_conversation", "(", "self", ",", "conversation", ",", "events", "=", "[", "]", ",", "event_cont_token", "=", "None", ")", ":", "# pylint: disable=dangerous-default-value", "conv_id", "=", "conversation", ".", "conversation_id", ".", "id", "logger", "....
Add new conversation from hangouts_pb2.Conversation
[ "Add", "new", "conversation", "from", "hangouts_pb2", ".", "Conversation" ]
python
valid
51.4
Jammy2211/PyAutoLens
autolens/model/profiles/light_profiles.py
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/light_profiles.py#L315-L327
def intensities_from_grid_radii(self, grid_radii): """ Calculate the intensity of the Sersic light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid. ...
[ "def", "intensities_from_grid_radii", "(", "self", ",", "grid_radii", ")", ":", "np", ".", "seterr", "(", "all", "=", "'ignore'", ")", "return", "np", ".", "multiply", "(", "self", ".", "intensity", ",", "np", ".", "exp", "(", "np", ".", "multiply", "(...
Calculate the intensity of the Sersic light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid.
[ "Calculate", "the", "intensity", "of", "the", "Sersic", "light", "profile", "on", "a", "grid", "of", "radial", "coordinates", "." ]
python
valid
43.538462
skorch-dev/skorch
skorch/toy.py
https://github.com/skorch-dev/skorch/blob/5b9b8b7b7712cb6e5aaa759d9608ea6269d5bcd3/skorch/toy.py#L69-L85
def reset_params(self): """(Re)set all parameters.""" units = [self.input_units] units += [self.hidden_units] * self.num_hidden units += [self.output_units] sequence = [] for u0, u1 in zip(units, units[1:]): sequence.append(nn.Linear(u0, u1)) sequ...
[ "def", "reset_params", "(", "self", ")", ":", "units", "=", "[", "self", ".", "input_units", "]", "units", "+=", "[", "self", ".", "hidden_units", "]", "*", "self", ".", "num_hidden", "units", "+=", "[", "self", ".", "output_units", "]", "sequence", "=...
(Re)set all parameters.
[ "(", "Re", ")", "set", "all", "parameters", "." ]
python
train
32.176471
noxdafox/vminspect
vminspect/comparator.py
https://github.com/noxdafox/vminspect/blob/e685282564877e2d1950f1e09b292f4f4db1dbcd/vminspect/comparator.py#L418-L423
def makedirs(path): """Creates the directory tree if non existing.""" path = Path(path) if not path.exists(): path.mkdir(parents=True)
[ "def", "makedirs", "(", "path", ")", ":", "path", "=", "Path", "(", "path", ")", "if", "not", "path", ".", "exists", "(", ")", ":", "path", ".", "mkdir", "(", "parents", "=", "True", ")" ]
Creates the directory tree if non existing.
[ "Creates", "the", "directory", "tree", "if", "non", "existing", "." ]
python
train
25
AguaClara/aguaclara
aguaclara/design/lfom.py
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/design/lfom.py#L108-L116
def n_orifices_per_row_max(self): """A bound on the number of orifices allowed in each row. The distance between consecutive orifices must be enough to retain structural integrity of the pipe. """ c = math.pi * pipe.ID_SDR(self.nom_diam_pipe, self.sdr) b = self.orifice_di...
[ "def", "n_orifices_per_row_max", "(", "self", ")", ":", "c", "=", "math", ".", "pi", "*", "pipe", ".", "ID_SDR", "(", "self", ".", "nom_diam_pipe", ",", "self", ".", "sdr", ")", "b", "=", "self", ".", "orifice_diameter", "+", "self", ".", "s_orifice", ...
A bound on the number of orifices allowed in each row. The distance between consecutive orifices must be enough to retain structural integrity of the pipe.
[ "A", "bound", "on", "the", "number", "of", "orifices", "allowed", "in", "each", "row", ".", "The", "distance", "between", "consecutive", "orifices", "must", "be", "enough", "to", "retain", "structural", "integrity", "of", "the", "pipe", "." ]
python
train
40.777778
sci-bots/svg-model
docs/generate_modules.py
https://github.com/sci-bots/svg-model/blob/2d119650f995e62b29ce0b3151a23f3b957cb072/docs/generate_modules.py#L215-L228
def is_excluded(root, excludes): """ Check if the directory is in the exclude list. Note: by having trailing slashes, we avoid common prefix issues, like e.g. an exlude "foo" also accidentally excluding "foobar". """ sep = os.path.sep if not root.endswith(sep): root += sep ...
[ "def", "is_excluded", "(", "root", ",", "excludes", ")", ":", "sep", "=", "os", ".", "path", ".", "sep", "if", "not", "root", ".", "endswith", "(", "sep", ")", ":", "root", "+=", "sep", "for", "exclude", "in", "excludes", ":", "if", "root", ".", ...
Check if the directory is in the exclude list. Note: by having trailing slashes, we avoid common prefix issues, like e.g. an exlude "foo" also accidentally excluding "foobar".
[ "Check", "if", "the", "directory", "is", "in", "the", "exclude", "list", "." ]
python
train
29.285714
archman/beamline
beamline/mathutils.py
https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/mathutils.py#L264-L278
def transFringe(beta=None, rho=None): """ Transport matrix of fringe field :param beta: angle of rotation of pole-face in [RAD] :param rho: bending radius in [m] :return: 6x6 numpy array """ m = np.eye(6, 6, dtype=np.float64) if None in (beta, rho): print("warning: 'theta', 'rho' sh...
[ "def", "transFringe", "(", "beta", "=", "None", ",", "rho", "=", "None", ")", ":", "m", "=", "np", ".", "eye", "(", "6", ",", "6", ",", "dtype", "=", "np", ".", "float64", ")", "if", "None", "in", "(", "beta", ",", "rho", ")", ":", "print", ...
Transport matrix of fringe field :param beta: angle of rotation of pole-face in [RAD] :param rho: bending radius in [m] :return: 6x6 numpy array
[ "Transport", "matrix", "of", "fringe", "field" ]
python
train
30.533333
senaite/senaite.core
bika/lims/api/security.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/api/security.py#L275-L299
def grant_permission_for(brain_or_object, permission, roles, acquire=0): """Grant the permission for the object to the defined roles Code extracted from `IRoleManager.manage_permission` :param brain_or_object: Catalog brain or object :param permission: The permission to be granted :param roles: Th...
[ "def", "grant_permission_for", "(", "brain_or_object", ",", "permission", ",", "roles", ",", "acquire", "=", "0", ")", ":", "obj", "=", "api", ".", "get_object", "(", "brain_or_object", ")", "valid_roles", "=", "get_valid_roles_for", "(", "obj", ")", "to_grant...
Grant the permission for the object to the defined roles Code extracted from `IRoleManager.manage_permission` :param brain_or_object: Catalog brain or object :param permission: The permission to be granted :param roles: The roles the permission to be granted to :param acquire: Flag to acquire the ...
[ "Grant", "the", "permission", "for", "the", "object", "to", "the", "defined", "roles" ]
python
train
36.48
offu/WeRoBot
werobot/client.py
https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/client.py#L82-L95
def grant_token(self): """ 获取 Access Token。 :return: 返回的 JSON 数据包 """ return self.get( url="https://api.weixin.qq.com/cgi-bin/token", params={ "grant_type": "client_credential", "appid": self.appid, "secret"...
[ "def", "grant_token", "(", "self", ")", ":", "return", "self", ".", "get", "(", "url", "=", "\"https://api.weixin.qq.com/cgi-bin/token\"", ",", "params", "=", "{", "\"grant_type\"", ":", "\"client_credential\"", ",", "\"appid\"", ":", "self", ".", "appid", ",", ...
获取 Access Token。 :return: 返回的 JSON 数据包
[ "获取", "Access", "Token。" ]
python
train
24.785714
mosdef-hub/mbuild
mbuild/utils/io.py
https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/utils/io.py#L81-L124
def import_(module): """Import a module, and issue a nice message to stderr if the module isn't installed. Parameters ---------- module : str The module you'd like to import, as a string Returns ------- module : {module, object} The module object Examples -------- ...
[ "def", "import_", "(", "module", ")", ":", "try", ":", "return", "importlib", ".", "import_module", "(", "module", ")", "except", "ImportError", "as", "e", ":", "try", ":", "message", "=", "MESSAGES", "[", "module", "]", "except", "KeyError", ":", "messa...
Import a module, and issue a nice message to stderr if the module isn't installed. Parameters ---------- module : str The module you'd like to import, as a string Returns ------- module : {module, object} The module object Examples -------- >>> # the following two ...
[ "Import", "a", "module", "and", "issue", "a", "nice", "message", "to", "stderr", "if", "the", "module", "isn", "t", "installed", "." ]
python
train
33.090909
project-ncl/pnc-cli
pnc_cli/buildrecords.py
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/buildrecords.py#L91-L97
def list_built_artifacts(id, page_size=200, page_index=0, sort="", q=""): """ List Artifacts associated with a BuildRecord """ data = list_built_artifacts_raw(id, page_size, page_index, sort, q) if data: return utils.format_json_list(data)
[ "def", "list_built_artifacts", "(", "id", ",", "page_size", "=", "200", ",", "page_index", "=", "0", ",", "sort", "=", "\"\"", ",", "q", "=", "\"\"", ")", ":", "data", "=", "list_built_artifacts_raw", "(", "id", ",", "page_size", ",", "page_index", ",", ...
List Artifacts associated with a BuildRecord
[ "List", "Artifacts", "associated", "with", "a", "BuildRecord" ]
python
train
37.285714
saltstack/salt
salt/utils/user.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/user.py#L232-L257
def chugid_and_umask(runas, umask, group=None): ''' Helper method for for subprocess.Popen to initialise uid/gid and umask for the new process. ''' set_runas = False set_grp = False current_user = getpass.getuser() if runas and runas != current_user: set_runas = True run...
[ "def", "chugid_and_umask", "(", "runas", ",", "umask", ",", "group", "=", "None", ")", ":", "set_runas", "=", "False", "set_grp", "=", "False", "current_user", "=", "getpass", ".", "getuser", "(", ")", "if", "runas", "and", "runas", "!=", "current_user", ...
Helper method for for subprocess.Popen to initialise uid/gid and umask for the new process.
[ "Helper", "method", "for", "for", "subprocess", ".", "Popen", "to", "initialise", "uid", "/", "gid", "and", "umask", "for", "the", "new", "process", "." ]
python
train
26.230769
saltstack/salt
salt/utils/gitfs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L590-L631
def clean_stale_refs(self): ''' Remove stale refs so that they are no longer seen as fileserver envs ''' cleaned = [] cmd_str = 'git remote prune origin' # Attempt to force all output to plain ascii english, which is what some parsing code # may expect. #...
[ "def", "clean_stale_refs", "(", "self", ")", ":", "cleaned", "=", "[", "]", "cmd_str", "=", "'git remote prune origin'", "# Attempt to force all output to plain ascii english, which is what some parsing code", "# may expect.", "# According to stackoverflow (http://goo.gl/l74GC8), we ar...
Remove stale refs so that they are no longer seen as fileserver envs
[ "Remove", "stale", "refs", "so", "that", "they", "are", "no", "longer", "seen", "as", "fileserver", "envs" ]
python
train
36.738095
grycap/RADL
radl/radl.py
https://github.com/grycap/RADL/blob/03ccabb0313a48a5aa0e20c1f7983fddcb95e9cb/radl/radl.py#L1190-L1200
def get(self, aspect): """Get a network, system or configure or contextualize with the same id as aspect passed.""" classification = [(network, self.networks), (system, self.systems), (configure, self.configures)] aspect_list = [l for t, l in classification if isinstan...
[ "def", "get", "(", "self", ",", "aspect", ")", ":", "classification", "=", "[", "(", "network", ",", "self", ".", "networks", ")", ",", "(", "system", ",", "self", ".", "systems", ")", ",", "(", "configure", ",", "self", ".", "configures", ")", "]"...
Get a network, system or configure or contextualize with the same id as aspect passed.
[ "Get", "a", "network", "system", "or", "configure", "or", "contextualize", "with", "the", "same", "id", "as", "aspect", "passed", "." ]
python
train
50.909091
gem/oq-engine
openquake/calculators/reportwriter.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L85-L117
def make_report(self): """Build the report and return a restructed text string""" oq, ds = self.oq, self.dstore for name in ('params', 'inputs'): self.add(name) if 'csm_info' in ds: self.add('csm_info') if ds['csm_info'].source_models[0].name != 'scena...
[ "def", "make_report", "(", "self", ")", ":", "oq", ",", "ds", "=", "self", ".", "oq", ",", "self", ".", "dstore", "for", "name", "in", "(", "'params'", ",", "'inputs'", ")", ":", "self", ".", "add", "(", "name", ")", "if", "'csm_info'", "in", "ds...
Build the report and return a restructed text string
[ "Build", "the", "report", "and", "return", "a", "restructed", "text", "string" ]
python
train
39.909091
UCSBarchlab/PyRTL
pyrtl/transform.py
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/transform.py#L73-L78
def all_wires(transform_func): """Decorator that wraps a wire transform function""" @functools.wraps(transform_func) def t_res(**kwargs): wire_transform(transform_func, **kwargs) return t_res
[ "def", "all_wires", "(", "transform_func", ")", ":", "@", "functools", ".", "wraps", "(", "transform_func", ")", "def", "t_res", "(", "*", "*", "kwargs", ")", ":", "wire_transform", "(", "transform_func", ",", "*", "*", "kwargs", ")", "return", "t_res" ]
Decorator that wraps a wire transform function
[ "Decorator", "that", "wraps", "a", "wire", "transform", "function" ]
python
train
35
tensorflow/tensor2tensor
tensor2tensor/data_generators/vqa_utils.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/vqa_utils.py#L98-L140
def _distort_color(image, color_ordering=0, scope=None): """Distort the color of a Tensor image. Each color distortion is non-commutative and thus ordering of the color ops matters. Ideally we would randomly permute the ordering of the color ops. Rather then adding that level of complication, we select a disti...
[ "def", "_distort_color", "(", "image", ",", "color_ordering", "=", "0", ",", "scope", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "scope", ",", "\"distort_color\"", ",", "[", "image", "]", ")", ":", "if", "color_ordering", "==", "0", "...
Distort the color of a Tensor image. Each color distortion is non-commutative and thus ordering of the color ops matters. Ideally we would randomly permute the ordering of the color ops. Rather then adding that level of complication, we select a distinct ordering of color ops for each preprocessing thread. ...
[ "Distort", "the", "color", "of", "a", "Tensor", "image", "." ]
python
train
47.418605
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/__init__.py
https://github.com/jbarlow83/OCRmyPDF/blob/79c84eefa353632a3d7ccddbd398c6678c1c1777/src/ocrmypdf/pdfinfo/__init__.py#L364-L370
def _find_inline_images(contentsinfo): "Find inline images in the contentstream" for n, inline in enumerate(contentsinfo.inline_images): yield ImageInfo( name='inline-%02d' % n, shorthand=inline.shorthand, inline=inline )
[ "def", "_find_inline_images", "(", "contentsinfo", ")", ":", "for", "n", ",", "inline", "in", "enumerate", "(", "contentsinfo", ".", "inline_images", ")", ":", "yield", "ImageInfo", "(", "name", "=", "'inline-%02d'", "%", "n", ",", "shorthand", "=", "inline"...
Find inline images in the contentstream
[ "Find", "inline", "images", "in", "the", "contentstream" ]
python
train
36
MrYsLab/PyMata
PyMata/pymata.py
https://github.com/MrYsLab/PyMata/blob/7e0ec34670b5a0d3d6b74bcbe4f3808c845cc429/PyMata/pymata.py#L718-L737
def reset(self): """ This command sends a reset message to the Arduino. The response tables will be reinitialized :return: No return value. """ # set all output pins to a value of 0 for pin in range(0, self._command_handler.total_pins_discovered): if self._com...
[ "def", "reset", "(", "self", ")", ":", "# set all output pins to a value of 0", "for", "pin", "in", "range", "(", "0", ",", "self", ".", "_command_handler", ".", "total_pins_discovered", ")", ":", "if", "self", ".", "_command_handler", ".", "digital_response_table...
This command sends a reset message to the Arduino. The response tables will be reinitialized :return: No return value.
[ "This", "command", "sends", "a", "reset", "message", "to", "the", "Arduino", ".", "The", "response", "tables", "will", "be", "reinitialized", ":", "return", ":", "No", "return", "value", "." ]
python
valid
51.15
dchaplinsky/aiohttp_validate
aiohttp_validate/__init__.py
https://github.com/dchaplinsky/aiohttp_validate/blob/e581cf51df6fcc377c7704315a487b10c3dd6000/aiohttp_validate/__init__.py#L32-L74
def _validate_data(data, schema, validator_cls): """ Validate the dict against given schema (using given validator class). """ validator = validator_cls(schema) _errors = defaultdict(list) for err in validator.iter_errors(data): path = err.schema_path # Code courtesy: Ruslan Kar...
[ "def", "_validate_data", "(", "data", ",", "schema", ",", "validator_cls", ")", ":", "validator", "=", "validator_cls", "(", "schema", ")", "_errors", "=", "defaultdict", "(", "list", ")", "for", "err", "in", "validator", ".", "iter_errors", "(", "data", "...
Validate the dict against given schema (using given validator class).
[ "Validate", "the", "dict", "against", "given", "schema", "(", "using", "given", "validator", "class", ")", "." ]
python
train
29.627907
bolt-project/bolt
bolt/spark/array.py
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L62-L83
def stack(self, size=None): """ Aggregates records of a distributed array. Stacking should improve the performance of vectorized operations, but the resulting StackedArray object only exposes a restricted set of operations (e.g. map, reduce). The unstack method can be used ...
[ "def", "stack", "(", "self", ",", "size", "=", "None", ")", ":", "stk", "=", "StackedArray", "(", "self", ".", "_rdd", ",", "shape", "=", "self", ".", "shape", ",", "split", "=", "self", ".", "split", ")", "return", "stk", ".", "stack", "(", "siz...
Aggregates records of a distributed array. Stacking should improve the performance of vectorized operations, but the resulting StackedArray object only exposes a restricted set of operations (e.g. map, reduce). The unstack method can be used to restore the full bolt array. Para...
[ "Aggregates", "records", "of", "a", "distributed", "array", "." ]
python
test
36.454545
baruwa-enterprise/BaruwaAPI
BaruwaAPI/resource.py
https://github.com/baruwa-enterprise/BaruwaAPI/blob/53335b377ccfd388e42f4f240f181eed72f51180/BaruwaAPI/resource.py#L353-L357
def get_radiussettings(self, domainid, serverid, settingsid): """Get RADIUS settings""" return self.api_call( ENDPOINTS['radiussettings']['get'], dict(domainid=domainid, serverid=serverid, settingsid=settingsid))
[ "def", "get_radiussettings", "(", "self", ",", "domainid", ",", "serverid", ",", "settingsid", ")", ":", "return", "self", ".", "api_call", "(", "ENDPOINTS", "[", "'radiussettings'", "]", "[", "'get'", "]", ",", "dict", "(", "domainid", "=", "domainid", ",...
Get RADIUS settings
[ "Get", "RADIUS", "settings" ]
python
train
49.6
liip/taxi
taxi/timesheet/parser.py
https://github.com/liip/taxi/blob/269423c1f1ab571bd01a522819afe3e325bfbff6/taxi/timesheet/parser.py#L307-L334
def parse_text(self, text): """ Parse the given text and return a list of :class:`~taxi.timesheet.lines.DateLine`, :class:`~taxi.timesheet.lines.Entry`, and :class:`~taxi.timesheet.lines.TextLine` objects. If there's an error during parsing, a :exc:`taxi.exceptions.ParseError` will be ra...
[ "def", "parse_text", "(", "self", ",", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", "lines", "=", "text", ".", "splitlines", "(", ")", "parsed_lines", "=", "[", "]", "encountered_date", "=", "False", "for", "(", "lineno", ",", "line...
Parse the given text and return a list of :class:`~taxi.timesheet.lines.DateLine`, :class:`~taxi.timesheet.lines.Entry`, and :class:`~taxi.timesheet.lines.TextLine` objects. If there's an error during parsing, a :exc:`taxi.exceptions.ParseError` will be raised.
[ "Parse", "the", "given", "text", "and", "return", "a", "list", "of", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "DateLine", ":", "class", ":", "~taxi", ".", "timesheet", ".", "lines", ".", "Entry", "and", ":", "class", ":", "~ta...
python
train
39.285714
Projectplace/basepage
basepage/wait.py
https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/wait.py#L46-L69
def until(self, func, message='', *args, **kwargs): """ Continues to execute the function until successful or time runs out. :param func: function to execute :param message: message to print if time ran out :param args: arguments :param kwargs: key word arguments ...
[ "def", "until", "(", "self", ",", "func", ",", "message", "=", "''", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "value", "=", "None", "end_time", "=", "time", ".", "time", "(", ")", "+", "self", ".", "_timeout", "while", "True", ":", ...
Continues to execute the function until successful or time runs out. :param func: function to execute :param message: message to print if time ran out :param args: arguments :param kwargs: key word arguments :return: result of function or None
[ "Continues", "to", "execute", "the", "function", "until", "successful", "or", "time", "runs", "out", "." ]
python
train
33.125
seomoz/qless-py
qless/workers/forking.py
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/workers/forking.py#L54-L63
def spawn(self, **kwargs): '''Return a new worker for a child process''' copy = dict(self.kwargs) copy.update(kwargs) # Apparently there's an issue with importing gevent in the parent # process and then using it int he child. This is meant to relieve that # problem by all...
[ "def", "spawn", "(", "self", ",", "*", "*", "kwargs", ")", ":", "copy", "=", "dict", "(", "self", ".", "kwargs", ")", "copy", ".", "update", "(", "kwargs", ")", "# Apparently there's an issue with importing gevent in the parent", "# process and then using it int he ...
Return a new worker for a child process
[ "Return", "a", "new", "worker", "for", "a", "child", "process" ]
python
train
51.7
iotaledger/iota.lib.py
iota/transaction/validator.py
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/validator.py#L41-L51
def errors(self): # type: () -> List[Text] """ Returns all errors found with the bundle. """ try: self._errors.extend(self._validator) # type: List[Text] except StopIteration: pass return self._errors
[ "def", "errors", "(", "self", ")", ":", "# type: () -> List[Text]", "try", ":", "self", ".", "_errors", ".", "extend", "(", "self", ".", "_validator", ")", "# type: List[Text]", "except", "StopIteration", ":", "pass", "return", "self", ".", "_errors" ]
Returns all errors found with the bundle.
[ "Returns", "all", "errors", "found", "with", "the", "bundle", "." ]
python
test
24.727273
DataBiosphere/toil
src/toil/__init__.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/__init__.py#L421-L667
def _monkey_patch_boto(): """ Boto 2 can't automatically assume roles. We want to replace its Provider class that manages credentials with one that uses the Boto 3 configuration and can assume roles. """ from boto import provider from botocore.session import Session from botocore.cr...
[ "def", "_monkey_patch_boto", "(", ")", ":", "from", "boto", "import", "provider", "from", "botocore", ".", "session", "import", "Session", "from", "botocore", ".", "credentials", "import", "create_credential_resolver", ",", "RefreshableCredentials", "# We cache the fina...
Boto 2 can't automatically assume roles. We want to replace its Provider class that manages credentials with one that uses the Boto 3 configuration and can assume roles.
[ "Boto", "2", "can", "t", "automatically", "assume", "roles", ".", "We", "want", "to", "replace", "its", "Provider", "class", "that", "manages", "credentials", "with", "one", "that", "uses", "the", "Boto", "3", "configuration", "and", "can", "assume", "roles"...
python
train
49.016194
mikedh/trimesh
trimesh/util.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/util.py#L1428-L1454
def jsonify(obj, **kwargs): """ A version of json.dumps that can handle numpy arrays by creating a custom encoder for numpy dtypes. Parameters -------------- obj : JSON- serializable blob **kwargs : Passed to json.dumps Returns -------------- dumped : str JSON dum...
[ "def", "jsonify", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "class", "NumpyEncoder", "(", "json", ".", "JSONEncoder", ")", ":", "def", "default", "(", "self", ",", "obj", ")", ":", "# will work for numpy.ndarrays", "# as well as their int64/etc objects", ...
A version of json.dumps that can handle numpy arrays by creating a custom encoder for numpy dtypes. Parameters -------------- obj : JSON- serializable blob **kwargs : Passed to json.dumps Returns -------------- dumped : str JSON dump of obj
[ "A", "version", "of", "json", ".", "dumps", "that", "can", "handle", "numpy", "arrays", "by", "creating", "a", "custom", "encoder", "for", "numpy", "dtypes", "." ]
python
train
26.666667
python-diamond/Diamond
src/diamond/utils/signals.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/signals.py#L6-L18
def signal_to_exception(signum, frame): """ Called by the timeout alarm during the collector run time """ if signum == signal.SIGALRM: raise SIGALRMException() if signum == signal.SIGHUP: raise SIGHUPException() if signum == signal.SIGUSR1: raise SIGUSR1Exception() if...
[ "def", "signal_to_exception", "(", "signum", ",", "frame", ")", ":", "if", "signum", "==", "signal", ".", "SIGALRM", ":", "raise", "SIGALRMException", "(", ")", "if", "signum", "==", "signal", ".", "SIGHUP", ":", "raise", "SIGHUPException", "(", ")", "if",...
Called by the timeout alarm during the collector run time
[ "Called", "by", "the", "timeout", "alarm", "during", "the", "collector", "run", "time" ]
python
train
30.846154
saltstack/salt
salt/modules/virt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3568-L3628
def vm_cputime(vm_=None, **kwargs): ''' Return cputime used by the vms on this hyper in a list of dicts: :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults ...
[ "def", "vm_cputime", "(", "vm_", "=", "None", ",", "*", "*", "kwargs", ")", ":", "conn", "=", "__get_conn", "(", "*", "*", "kwargs", ")", "host_cpus", "=", "conn", ".", "getInfo", "(", ")", "[", "2", "]", "def", "_info", "(", "dom", ")", ":", "...
Return cputime used by the vms on this hyper in a list of dicts: :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2.0 :param passw...
[ "Return", "cputime", "used", "by", "the", "vms", "on", "this", "hyper", "in", "a", "list", "of", "dicts", ":" ]
python
train
26.114754
Alignak-monitoring/alignak
alignak/daterange.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L929-L986
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for WeekDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
[ "def", "get_start_and_end_time", "(", "self", ",", "ref", "=", "None", ")", ":", "now", "=", "time", ".", "localtime", "(", "ref", ")", "# If no year, it's our year", "if", "self", ".", "syear", "==", "0", ":", "self", ".", "syear", "=", "now", ".", "t...
Specific function to get start time and end time for WeekDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int)
[ "Specific", "function", "to", "get", "start", "time", "and", "end", "time", "for", "WeekDayDaterange" ]
python
train
41.310345
ga4gh/ga4gh-server
ga4gh/server/frontend.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/frontend.py#L459-L483
def checkAuthentication(): """ The request will have a parameter 'key' if it came from the command line client, or have a session key of 'key' if it's the browser. If the token is not found, start the login process. If there is no oidcClient, we are running naked and we don't check. If we're be...
[ "def", "checkAuthentication", "(", ")", ":", "if", "app", ".", "oidcClient", "is", "None", ":", "return", "if", "flask", ".", "request", ".", "endpoint", "==", "'oidcCallback'", ":", "return", "key", "=", "flask", ".", "session", ".", "get", "(", "'key'"...
The request will have a parameter 'key' if it came from the command line client, or have a session key of 'key' if it's the browser. If the token is not found, start the login process. If there is no oidcClient, we are running naked and we don't check. If we're being redirected to the oidcCallback we d...
[ "The", "request", "will", "have", "a", "parameter", "key", "if", "it", "came", "from", "the", "command", "line", "client", "or", "have", "a", "session", "key", "of", "key", "if", "it", "s", "the", "browser", ".", "If", "the", "token", "is", "not", "f...
python
train
41.56
lemieuxl/pyGenClean
pyGenClean/run_data_clean_up.py
https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/run_data_clean_up.py#L3117-L3159
def count_markers_samples(prefix, file_type): """Counts the number of markers and samples in plink file. :param prefix: the prefix of the files. :param file_type: the file type. :type prefix: str :type file_type: str :returns: the number of markers and samples (in a tuple). """ # The...
[ "def", "count_markers_samples", "(", "prefix", ",", "file_type", ")", ":", "# The files that will need counting", "sample_file", "=", "None", "marker_file", "=", "None", "if", "file_type", "==", "\"bfile\"", ":", "# Binary files (.bed, .bim and .fam)", "sample_file", "=",...
Counts the number of markers and samples in plink file. :param prefix: the prefix of the files. :param file_type: the file type. :type prefix: str :type file_type: str :returns: the number of markers and samples (in a tuple).
[ "Counts", "the", "number", "of", "markers", "and", "samples", "in", "plink", "file", "." ]
python
train
25.511628
econ-ark/HARK
HARK/ConsumptionSaving/ConsGenIncProcessModel.py
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsGenIncProcessModel.py#L1109-L1130
def simBirth(self,which_agents): ''' Makes new consumers for the given indices. Initialized variables include aNrm and pLvl, as well as time variables t_age and t_cycle. Normalized assets and persistent income levels are drawn from lognormal distributions given by aNrmInitMean and aNrm...
[ "def", "simBirth", "(", "self", ",", "which_agents", ")", ":", "# Get and store states for newly born agents", "N", "=", "np", ".", "sum", "(", "which_agents", ")", "# Number of new consumers to make", "aNrmNow_new", "=", "drawLognormal", "(", "N", ",", "mu", "=", ...
Makes new consumers for the given indices. Initialized variables include aNrm and pLvl, as well as time variables t_age and t_cycle. Normalized assets and persistent income levels are drawn from lognormal distributions given by aNrmInitMean and aNrmInitStd (etc). Parameters ----------...
[ "Makes", "new", "consumers", "for", "the", "given", "indices", ".", "Initialized", "variables", "include", "aNrm", "and", "pLvl", "as", "well", "as", "time", "variables", "t_age", "and", "t_cycle", ".", "Normalized", "assets", "and", "persistent", "income", "l...
python
train
50.272727
sorgerlab/indra
indra/sources/biopax/processor.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/processor.py#L344-L433
def get_conversions(self): """Extract Conversion INDRA Statements from the BioPAX model. This method uses a custom BioPAX Pattern (one that is not implemented PatternBox) to query for BiochemicalReactions whose left and right hand sides are collections of SmallMolecules. This pa...
[ "def", "get_conversions", "(", "self", ")", ":", "# NOTE: This pattern gets all reactions in which a protein is the", "# controller and chemicals are converted. But with this pattern only", "# a single chemical is extracted from each side. This can be misleading", "# since we want to capture all i...
Extract Conversion INDRA Statements from the BioPAX model. This method uses a custom BioPAX Pattern (one that is not implemented PatternBox) to query for BiochemicalReactions whose left and right hand sides are collections of SmallMolecules. This pattern thereby extracts metabolic ...
[ "Extract", "Conversion", "INDRA", "Statements", "from", "the", "BioPAX", "model", "." ]
python
train
50.611111
chaoss/grimoirelab-elk
grimoire_elk/enriched/kitsune.py
https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/kitsune.py#L86-L99
def get_identities(self, item): """ Return the identities from an item """ item = item['data'] for identity in ['creator']: # Todo: questions has also involved and solved_by if identity in item and item[identity]: user = self.get_sh_identity(item[identit...
[ "def", "get_identities", "(", "self", ",", "item", ")", ":", "item", "=", "item", "[", "'data'", "]", "for", "identity", "in", "[", "'creator'", "]", ":", "# Todo: questions has also involved and solved_by", "if", "identity", "in", "item", "and", "item", "[", ...
Return the identities from an item
[ "Return", "the", "identities", "from", "an", "item" ]
python
train
37.5
respondcreate/django-versatileimagefield
versatileimagefield/utils.py
https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/utils.py#L107-L128
def get_resized_path(path_to_image, width, height, filename_key, storage): """ Return a `path_to_image` location on `storage` as dictated by `width`, `height` and `filename_key` """ containing_folder, filename = os.path.split(path_to_image) resized_filename = get_resized_fi...
[ "def", "get_resized_path", "(", "path_to_image", ",", "width", ",", "height", ",", "filename_key", ",", "storage", ")", ":", "containing_folder", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "path_to_image", ")", "resized_filename", "=", "get_re...
Return a `path_to_image` location on `storage` as dictated by `width`, `height` and `filename_key`
[ "Return", "a", "path_to_image", "location", "on", "storage", "as", "dictated", "by", "width", "height", "and", "filename_key" ]
python
test
27.909091
Kellel/ProxyMiddleware
ProxyMiddleware/ProxyMiddleware.py
https://github.com/Kellel/ProxyMiddleware/blob/cb3a8854cbcb0f2ddccf5a688feca3c2debec8a4/ProxyMiddleware/ProxyMiddleware.py#L62-L75
def force_slash(fn): """ Force Slash ----------- Wrap a bottle route with this decorator to force a trailing slash. This is useful for the root of your application or places where TrailingSlash doesn't work """ @wraps(fn) def wrapped(*args, **kwargs): if request.environ['PATH_INFO']...
[ "def", "force_slash", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "environ", "[", "'PATH_INFO'", "]", ".", "endswith", "(", "'/'", ")", ":", "retu...
Force Slash ----------- Wrap a bottle route with this decorator to force a trailing slash. This is useful for the root of your application or places where TrailingSlash doesn't work
[ "Force", "Slash", "-----------" ]
python
train
34.571429
molmod/molmod
molmod/io/gamess.py
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L55-L75
def _read(self, filename): """Internal routine that reads all data from the punch file.""" data = {} parsers = [ FirstDataParser(), CoordinateParser(), EnergyGradParser(), SkipApproxHessian(), HessianParser(), MassParser(), ] with open(filename) as f: ...
[ "def", "_read", "(", "self", ",", "filename", ")", ":", "data", "=", "{", "}", "parsers", "=", "[", "FirstDataParser", "(", ")", ",", "CoordinateParser", "(", ")", ",", "EnergyGradParser", "(", ")", ",", "SkipApproxHessian", "(", ")", ",", "HessianParser...
Internal routine that reads all data from the punch file.
[ "Internal", "routine", "that", "reads", "all", "data", "from", "the", "punch", "file", "." ]
python
train
42.095238
TeamHG-Memex/eli5
eli5/formatters/as_dataframe.py
https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dataframe.py#L93-L116
def format_as_dataframe(explanation): # type: (Explanation) -> Optional[pd.DataFrame] """ Export an explanation to a single ``pandas.DataFrame``. In case several dataframes could be exported by :func:`eli5.formatters.as_dataframe.format_as_dataframes`, a warning is raised. If no dataframe can be exp...
[ "def", "format_as_dataframe", "(", "explanation", ")", ":", "# type: (Explanation) -> Optional[pd.DataFrame]", "for", "attr", "in", "_EXPORTED_ATTRIBUTES", ":", "value", "=", "getattr", "(", "explanation", ",", "attr", ")", "if", "value", ":", "other_attrs", "=", "[...
Export an explanation to a single ``pandas.DataFrame``. In case several dataframes could be exported by :func:`eli5.formatters.as_dataframe.format_as_dataframes`, a warning is raised. If no dataframe can be exported, ``None`` is returned. This function also accepts some components of the explanation as ...
[ "Export", "an", "explanation", "to", "a", "single", "pandas", ".", "DataFrame", ".", "In", "case", "several", "dataframes", "could", "be", "exported", "by", ":", "func", ":", "eli5", ".", "formatters", ".", "as_dataframe", ".", "format_as_dataframes", "a", "...
python
train
51
gambogi/CSHLDAP
CSHLDAP.py
https://github.com/gambogi/CSHLDAP/blob/09cb754b1e72437834e0d8cb4c7ac1830cfa6829/CSHLDAP.py#L99-L103
def drinkAdmins(self, objects=False): """ Returns a list of drink admins uids """ admins = self.group('drink', objects=objects) return admins
[ "def", "drinkAdmins", "(", "self", ",", "objects", "=", "False", ")", ":", "admins", "=", "self", ".", "group", "(", "'drink'", ",", "objects", "=", "objects", ")", "return", "admins" ]
Returns a list of drink admins uids
[ "Returns", "a", "list", "of", "drink", "admins", "uids" ]
python
train
33.8
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py#L65-L79
def fcoe_get_interface_output_fcoe_intf_list_fcoe_intf_port_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") fcoe_get_interface = ET.Element("fcoe_get_interface") config = fcoe_get_interface output = ET.SubElement(fcoe_get_interface, "output"...
[ "def", "fcoe_get_interface_output_fcoe_intf_list_fcoe_intf_port_type", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "fcoe_get_interface", "=", "ET", ".", "Element", "(", "\"fcoe_get_interface\"", ")", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
52.466667
observermedia/django-wordpress-rest
wordpress/loading.py
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L864-L879
def process_post_many_to_many_field(existing_post, field, related_objects): """ Sync data for a many-to-many field related to a post using set differences. :param existing_post: Post object that needs to be sync'd :param field: the many-to-many field to update :param related_obj...
[ "def", "process_post_many_to_many_field", "(", "existing_post", ",", "field", ",", "related_objects", ")", ":", "to_add", "=", "set", "(", "related_objects", ".", "get", "(", "existing_post", ".", "wp_id", ",", "set", "(", ")", ")", ")", "-", "set", "(", "...
Sync data for a many-to-many field related to a post using set differences. :param existing_post: Post object that needs to be sync'd :param field: the many-to-many field to update :param related_objects: the list of objects for the field, that need to be sync'd to the Post :return: Non...
[ "Sync", "data", "for", "a", "many", "-", "to", "-", "many", "field", "related", "to", "a", "post", "using", "set", "differences", "." ]
python
train
50.0625
DLR-RM/RAFCON
source/rafcon/core/script.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/script.py#L107-L117
def _load_script(self): """Loads the script from the filesystem :raises exceptions.IOError: if the script file could not be opened """ script_text = filesystem.read_file(self.path, self.filename) if not script_text: raise IOError("Script file could not be opened or ...
[ "def", "_load_script", "(", "self", ")", ":", "script_text", "=", "filesystem", ".", "read_file", "(", "self", ".", "path", ",", "self", ".", "filename", ")", "if", "not", "script_text", ":", "raise", "IOError", "(", "\"Script file could not be opened or was emp...
Loads the script from the filesystem :raises exceptions.IOError: if the script file could not be opened
[ "Loads", "the", "script", "from", "the", "filesystem" ]
python
train
39.636364
earwig/mwparserfromhell
mwparserfromhell/parser/tokenizer.py
https://github.com/earwig/mwparserfromhell/blob/98dc30902d35c714a70aca8e6616f49d71cb24cc/mwparserfromhell/parser/tokenizer.py#L903-L913
def _parse_tag(self): """Parse an HTML tag at the head of the wikicode string.""" reset = self._head self._head += 1 try: tag = self._really_parse_tag() except BadRoute: self._head = reset self._emit_text("<") else: self._em...
[ "def", "_parse_tag", "(", "self", ")", ":", "reset", "=", "self", ".", "_head", "self", ".", "_head", "+=", "1", "try", ":", "tag", "=", "self", ".", "_really_parse_tag", "(", ")", "except", "BadRoute", ":", "self", ".", "_head", "=", "reset", "self"...
Parse an HTML tag at the head of the wikicode string.
[ "Parse", "an", "HTML", "tag", "at", "the", "head", "of", "the", "wikicode", "string", "." ]
python
train
29.181818
vpelletier/python-libaio
libaio/__init__.py
https://github.com/vpelletier/python-libaio/blob/5b5a2fed5418e2bd1ac9197fa46c69dae86c6fe3/libaio/__init__.py#L384-L393
def close(self): """ Cancels all pending IO blocks. Waits until all non-cancellable IO blocks finish. De-initialises AIO context. """ if self._ctx is not None: # Note: same as io_destroy self._io_queue_release(self._ctx) del self._ctx
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_ctx", "is", "not", "None", ":", "# Note: same as io_destroy", "self", ".", "_io_queue_release", "(", "self", ".", "_ctx", ")", "del", "self", ".", "_ctx" ]
Cancels all pending IO blocks. Waits until all non-cancellable IO blocks finish. De-initialises AIO context.
[ "Cancels", "all", "pending", "IO", "blocks", ".", "Waits", "until", "all", "non", "-", "cancellable", "IO", "blocks", "finish", ".", "De", "-", "initialises", "AIO", "context", "." ]
python
test
30.9
HazyResearch/fonduer
src/fonduer/candidates/matchers.py
https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/candidates/matchers.py#L472-L474
def _is_subspan(self, m, span): """Tests if mention m does exist""" return m.figure.document.id == span[0] and m.figure.position == span[1]
[ "def", "_is_subspan", "(", "self", ",", "m", ",", "span", ")", ":", "return", "m", ".", "figure", ".", "document", ".", "id", "==", "span", "[", "0", "]", "and", "m", ".", "figure", ".", "position", "==", "span", "[", "1", "]" ]
Tests if mention m does exist
[ "Tests", "if", "mention", "m", "does", "exist" ]
python
train
51
pytroll/satpy
satpy/writers/mitiff.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/writers/mitiff.py#L109-L154
def save_datasets(self, datasets, filename=None, fill_value=None, compute=True, **kwargs): """Save all datasets to one or more files. """ LOG.debug("Starting in mitiff save_datasets ... ") def _delayed_create(create_opts, datasets): LOG.debug("create_op...
[ "def", "save_datasets", "(", "self", ",", "datasets", ",", "filename", "=", "None", ",", "fill_value", "=", "None", ",", "compute", "=", "True", ",", "*", "*", "kwargs", ")", ":", "LOG", ".", "debug", "(", "\"Starting in mitiff save_datasets ... \"", ")", ...
Save all datasets to one or more files.
[ "Save", "all", "datasets", "to", "one", "or", "more", "files", "." ]
python
train
50.630435
janpipek/physt
physt/util.py
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/util.py#L9-L18
def all_subclasses(cls: type) -> Tuple[type, ...]: """All subclasses of a class. From: http://stackoverflow.com/a/17246726/2692780 """ subclasses = [] for subclass in cls.__subclasses__(): subclasses.append(subclass) subclasses.extend(all_subclasses(subclass)) return tuple(subcl...
[ "def", "all_subclasses", "(", "cls", ":", "type", ")", "->", "Tuple", "[", "type", ",", "...", "]", ":", "subclasses", "=", "[", "]", "for", "subclass", "in", "cls", ".", "__subclasses__", "(", ")", ":", "subclasses", ".", "append", "(", "subclass", ...
All subclasses of a class. From: http://stackoverflow.com/a/17246726/2692780
[ "All", "subclasses", "of", "a", "class", "." ]
python
train
31.7
nats-io/python-nats
nats/io/client.py
https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L465-L482
def publish_request(self, subject, reply, payload): """ Publishes a message tagging it with a reply subscription which can be used by those receiving the message to respond: ->> PUB hello _INBOX.2007314fe0fcb2cdc2a2914c1 5 ->> MSG_PAYLOAD: world <<- MSG hello 2 _...
[ "def", "publish_request", "(", "self", ",", "subject", ",", "reply", ",", "payload", ")", ":", "payload_size", "=", "len", "(", "payload", ")", "if", "payload_size", ">", "self", ".", "_max_payload_size", ":", "raise", "ErrMaxPayload", "if", "self", ".", "...
Publishes a message tagging it with a reply subscription which can be used by those receiving the message to respond: ->> PUB hello _INBOX.2007314fe0fcb2cdc2a2914c1 5 ->> MSG_PAYLOAD: world <<- MSG hello 2 _INBOX.2007314fe0fcb2cdc2a2914c1 5
[ "Publishes", "a", "message", "tagging", "it", "with", "a", "reply", "subscription", "which", "can", "be", "used", "by", "those", "receiving", "the", "message", "to", "respond", ":" ]
python
train
37.611111
andrey-git/pysensibo
pysensibo/__init__.py
https://github.com/andrey-git/pysensibo/blob/c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8/pysensibo/__init__.py#L38-L41
def async_get_device(self, uid, fields='*'): """Get specific device by ID.""" return (yield from self._get('/pods/{}'.format(uid), fields=fields))
[ "def", "async_get_device", "(", "self", ",", "uid", ",", "fields", "=", "'*'", ")", ":", "return", "(", "yield", "from", "self", ".", "_get", "(", "'/pods/{}'", ".", "format", "(", "uid", ")", ",", "fields", "=", "fields", ")", ")" ]
Get specific device by ID.
[ "Get", "specific", "device", "by", "ID", "." ]
python
train
49
zhmcclient/python-zhmcclient
zhmcclient/_partition.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_partition.py#L284-L328
def feature_enabled(self, feature_name): """ Indicates whether the specified feature is enabled for the CPC of this partition. The HMC must generally support features, and the specified feature must be available for the CPC. For a list of available features, see section...
[ "def", "feature_enabled", "(", "self", ",", "feature_name", ")", ":", "feature_list", "=", "self", ".", "prop", "(", "'available-features-list'", ",", "None", ")", "if", "feature_list", "is", "None", ":", "raise", "ValueError", "(", "\"Firmware features are not su...
Indicates whether the specified feature is enabled for the CPC of this partition. The HMC must generally support features, and the specified feature must be available for the CPC. For a list of available features, see section "Features" in the :term:`HMC API`, or use the :meth:...
[ "Indicates", "whether", "the", "specified", "feature", "is", "enabled", "for", "the", "CPC", "of", "this", "partition", "." ]
python
train
34.622222
apple/turicreate
src/unity/python/turicreate/toolkits/distances/_util.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/distances/_util.py#L232-L301
def build_address_distance(number=None, street=None, city=None, state=None, zip_code=None): """ Construct a composite distance appropriate for matching address data. NOTE: this utility function does not guarantee that the output composite distance will work with a particular d...
[ "def", "build_address_distance", "(", "number", "=", "None", ",", "street", "=", "None", ",", "city", "=", "None", ",", "state", "=", "None", ",", "zip_code", "=", "None", ")", ":", "## Validate inputs", "for", "param", "in", "[", "number", ",", "street"...
Construct a composite distance appropriate for matching address data. NOTE: this utility function does not guarantee that the output composite distance will work with a particular dataset and model. When the composite distance is applied in a particular context, the feature types and individual distance...
[ "Construct", "a", "composite", "distance", "appropriate", "for", "matching", "address", "data", ".", "NOTE", ":", "this", "utility", "function", "does", "not", "guarantee", "that", "the", "output", "composite", "distance", "will", "work", "with", "a", "particula...
python
train
33.7
ChrisCummins/labm8
modules.py
https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/modules.py#L28-L68
def import_foreign(name, custom_name=None): """ Import a module with a custom name. NOTE this is only needed for Python2. For Python3, import the module using the "as" keyword to declare the custom name. For implementation details, see: http://stackoverflow.com/a/6032023 Example: T...
[ "def", "import_foreign", "(", "name", ",", "custom_name", "=", "None", ")", ":", "if", "lab", ".", "is_python3", "(", ")", ":", "io", ".", "error", "(", "(", "\"Ignoring attempt to import foreign module '{mod}' \"", "\"using python version {major}.{minor}\"", ".", "...
Import a module with a custom name. NOTE this is only needed for Python2. For Python3, import the module using the "as" keyword to declare the custom name. For implementation details, see: http://stackoverflow.com/a/6032023 Example: To import the standard module "math" as "std_math": ...
[ "Import", "a", "module", "with", "a", "custom", "name", "." ]
python
train
28.804878
awslabs/sockeye
sockeye/encoder.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/encoder.py#L124-L174
def get_recurrent_encoder(config: RecurrentEncoderConfig, prefix: str) -> 'Encoder': """ Returns an encoder stack with a bi-directional RNN, and a variable number of uni-directional forward RNNs. :param config: Configuration for recurrent encoder. :param prefix: Prefix for variable names. :return: ...
[ "def", "get_recurrent_encoder", "(", "config", ":", "RecurrentEncoderConfig", ",", "prefix", ":", "str", ")", "->", "'Encoder'", ":", "# TODO give more control on encoder architecture", "encoder_seq", "=", "EncoderSequence", "(", "[", "]", ",", "config", ".", "dtype",...
Returns an encoder stack with a bi-directional RNN, and a variable number of uni-directional forward RNNs. :param config: Configuration for recurrent encoder. :param prefix: Prefix for variable names. :return: Encoder instance.
[ "Returns", "an", "encoder", "stack", "with", "a", "bi", "-", "directional", "RNN", "and", "a", "variable", "number", "of", "uni", "-", "directional", "forward", "RNNs", "." ]
python
train
50.45098
materialsproject/pymatgen-db
matgendb/builders/incr.py
https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/builders/incr.py#L390-L395
def _get(self, operation, field): """Get tracked position for a given operation and field.""" self._check_exists() query = {Mark.FLD_OP: operation.name, Mark.FLD_MARK + "." + field: {"$exists": True}} return self._track.find_one(query)
[ "def", "_get", "(", "self", ",", "operation", ",", "field", ")", ":", "self", ".", "_check_exists", "(", ")", "query", "=", "{", "Mark", ".", "FLD_OP", ":", "operation", ".", "name", ",", "Mark", ".", "FLD_MARK", "+", "\".\"", "+", "field", ":", "{...
Get tracked position for a given operation and field.
[ "Get", "tracked", "position", "for", "a", "given", "operation", "and", "field", "." ]
python
train
46.5
changecoin/changetip-python
changetip/bots/base.py
https://github.com/changecoin/changetip-python/blob/daa6e2f41712eb58d16c537af34f9f0a1b74a14e/changetip/bots/base.py#L49-L70
def send_tip(self, sender, receiver, message, context_uid, meta): """ Send a request to the ChangeTip API, to be delivered immediately. """ assert self.channel is not None, "channel must be defined" # Add extra data to meta meta["mention_bot"] = self.mention_bot() data = json.d...
[ "def", "send_tip", "(", "self", ",", "sender", ",", "receiver", ",", "message", ",", "context_uid", ",", "meta", ")", ":", "assert", "self", ".", "channel", "is", "not", "None", ",", "\"channel must be defined\"", "# Add extra data to meta", "meta", "[", "\"me...
Send a request to the ChangeTip API, to be delivered immediately.
[ "Send", "a", "request", "to", "the", "ChangeTip", "API", "to", "be", "delivered", "immediately", "." ]
python
train
42.954545
python-bugzilla/python-bugzilla
bugzilla/bug.py
https://github.com/python-bugzilla/python-bugzilla/blob/7de8b225104f24a1eee3e837bf1e02d60aefe69f/bugzilla/bug.py#L328-L344
def get_flag_status(self, name): """ Return a flag 'status' field This method works only for simple flags that have only a 'status' field with no "requestee" info, and no multiple values. For more complex flags, use get_flags() to get extended flag value information. """...
[ "def", "get_flag_status", "(", "self", ",", "name", ")", ":", "f", "=", "self", ".", "get_flags", "(", "name", ")", "if", "not", "f", ":", "return", "None", "# This method works only for simple flags that have only one", "# value set.", "assert", "len", "(", "f"...
Return a flag 'status' field This method works only for simple flags that have only a 'status' field with no "requestee" info, and no multiple values. For more complex flags, use get_flags() to get extended flag value information.
[ "Return", "a", "flag", "status", "field" ]
python
train
31.058824
saltstack/salt
salt/modules/jenkinsmod.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/jenkinsmod.py#L254-L295
def create_job(name=None, config_xml=None, saltenv='base'): ''' Return the configuration file. :param name: The name of the job is check if it exists. :param config_xml: The configuration file to use to create the job. :param saltenv: The environment to look for the fi...
[ "def", "create_job", "(", "name", "=", "None", ",", "config_xml", "=", "None", ",", "saltenv", "=", "'base'", ")", ":", "if", "not", "name", ":", "raise", "SaltInvocationError", "(", "'Required parameter \\'name\\' is missing'", ")", "if", "job_exists", "(", "...
Return the configuration file. :param name: The name of the job is check if it exists. :param config_xml: The configuration file to use to create the job. :param saltenv: The environment to look for the file in. :return: The configuration file used for the job. CLI Example: .. code-block:: ba...
[ "Return", "the", "configuration", "file", "." ]
python
train
30.166667
vxgmichel/aiostream
aiostream/stream/select.py
https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/select.py#L62-L78
async def skiplast(source, n): """Forward an asynchronous sequence, skipping the last ``n`` elements. If ``n`` is negative, no elements are skipped. Note: it is required to reach the ``n+1`` th element of the source before the first element is generated. """ queue = collections.deque(maxlen=n ...
[ "async", "def", "skiplast", "(", "source", ",", "n", ")", ":", "queue", "=", "collections", ".", "deque", "(", "maxlen", "=", "n", "if", "n", ">", "0", "else", "0", ")", "async", "with", "streamcontext", "(", "source", ")", "as", "streamer", ":", "...
Forward an asynchronous sequence, skipping the last ``n`` elements. If ``n`` is negative, no elements are skipped. Note: it is required to reach the ``n+1`` th element of the source before the first element is generated.
[ "Forward", "an", "asynchronous", "sequence", "skipping", "the", "last", "n", "elements", "." ]
python
train
33.823529
mitsei/dlkit
dlkit/services/authorization.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/authorization.py#L1145-L1153
def use_comparative_authorization_view(self): """Pass through to provider AuthorizationLookupSession.use_comparative_authorization_view""" self._object_views['authorization'] = COMPARATIVE # self._get_provider_session('authorization_lookup_session') # To make sure the session is tracked ...
[ "def", "use_comparative_authorization_view", "(", "self", ")", ":", "self", ".", "_object_views", "[", "'authorization'", "]", "=", "COMPARATIVE", "# self._get_provider_session('authorization_lookup_session') # To make sure the session is tracked", "for", "session", "in", "self",...
Pass through to provider AuthorizationLookupSession.use_comparative_authorization_view
[ "Pass", "through", "to", "provider", "AuthorizationLookupSession", ".", "use_comparative_authorization_view" ]
python
train
54.555556
tanghaibao/jcvi
jcvi/apps/base.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/base.py#L1305-L1353
def pushnotify(subject, message, api="pushover", priority=0, timestamp=None): """ Send push notifications using pre-existing APIs Requires a config `pushnotify.ini` file in the user home area containing the necessary api tokens and user keys. Default API: "pushover" Config file format: --...
[ "def", "pushnotify", "(", "subject", ",", "message", ",", "api", "=", "\"pushover\"", ",", "priority", "=", "0", ",", "timestamp", "=", "None", ")", ":", "import", "types", "assert", "type", "(", "priority", ")", "is", "int", "and", "-", "1", "<=", "...
Send push notifications using pre-existing APIs Requires a config `pushnotify.ini` file in the user home area containing the necessary api tokens and user keys. Default API: "pushover" Config file format: ------------------- [pushover] token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
[ "Send", "push", "notifications", "using", "pre", "-", "existing", "APIs" ]
python
train
33.408163
intel-analytics/BigDL
pyspark/bigdl/nn/layer.py
https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L329-L360
def evaluate(self, *args): """ No argument passed in: Evaluate the model to set train = false, useful when doing test/forward :return: layer itself Three arguments passed in: A method to benchmark the model quality. :param dataset: the input data :param ...
[ "def", "evaluate", "(", "self", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "callBigDlFunc", "(", "self", ".", "bigdl_type", ",", "\"evaluate\"", ",", "self", ".", "value", ")", "return", "self", "elif", "len", "(", "...
No argument passed in: Evaluate the model to set train = false, useful when doing test/forward :return: layer itself Three arguments passed in: A method to benchmark the model quality. :param dataset: the input data :param batch_size: batch size :param val_metho...
[ "No", "argument", "passed", "in", ":", "Evaluate", "the", "model", "to", "set", "train", "=", "false", "useful", "when", "doing", "test", "/", "forward", ":", "return", ":", "layer", "itself" ]
python
test
42.28125
vertexproject/synapse
synapse/lib/editatom.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/editatom.py#L85-L125
async def commit(self, snap): ''' Push the recorded changes to disk, notify all the listeners ''' if not self.npvs: # nothing to do return for node, prop, _, valu in self.npvs: node.props[prop.name] = valu node.proplayr[prop.name] = snap.wlyr...
[ "async", "def", "commit", "(", "self", ",", "snap", ")", ":", "if", "not", "self", ".", "npvs", ":", "# nothing to do", "return", "for", "node", ",", "prop", ",", "_", ",", "valu", "in", "self", ".", "npvs", ":", "node", ".", "props", "[", "prop", ...
Push the recorded changes to disk, notify all the listeners
[ "Push", "the", "recorded", "changes", "to", "disk", "notify", "all", "the", "listeners" ]
python
train
33.829268
NaturalHistoryMuseum/pyzbar
pyzbar/pyzbar.py
https://github.com/NaturalHistoryMuseum/pyzbar/blob/833b375c0e84077943b7100cc9dc22a7bd48754b/pyzbar/pyzbar.py#L90-L116
def _decode_symbols(symbols): """Generator of decoded symbol information. Args: symbols: iterable of instances of `POINTER(zbar_symbol)` Yields: Decoded: decoded symbol """ for symbol in symbols: data = string_at(zbar_symbol_get_data(symbol)) # The 'type' int in a v...
[ "def", "_decode_symbols", "(", "symbols", ")", ":", "for", "symbol", "in", "symbols", ":", "data", "=", "string_at", "(", "zbar_symbol_get_data", "(", "symbol", ")", ")", "# The 'type' int in a value in the ZBarSymbol enumeration", "symbol_type", "=", "ZBarSymbol", "(...
Generator of decoded symbol information. Args: symbols: iterable of instances of `POINTER(zbar_symbol)` Yields: Decoded: decoded symbol
[ "Generator", "of", "decoded", "symbol", "information", "." ]
python
train
29.148148
bwhite/hadoopy
hadoopy/_hdfs.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_hdfs.py#L81-L91
def isempty(path): """Check if a path has zero length (also true if it's a directory) :param path: A string for the path. This should not have any wildcards. :returns: True if the path has zero length, False otherwise. """ cmd = "hadoop fs -test -z %s" p = _hadoop_fs_command(cmd % (path)) ...
[ "def", "isempty", "(", "path", ")", ":", "cmd", "=", "\"hadoop fs -test -z %s\"", "p", "=", "_hadoop_fs_command", "(", "cmd", "%", "(", "path", ")", ")", "p", ".", "communicate", "(", ")", "rcode", "=", "p", ".", "returncode", "return", "bool", "(", "i...
Check if a path has zero length (also true if it's a directory) :param path: A string for the path. This should not have any wildcards. :returns: True if the path has zero length, False otherwise.
[ "Check", "if", "a", "path", "has", "zero", "length", "(", "also", "true", "if", "it", "s", "a", "directory", ")" ]
python
train
34.818182
has2k1/plotnine
plotnine/aes.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/aes.py#L343-L350
def is_position_aes(vars_): """ Figure out if an aesthetic is a position aesthetic or not """ try: return all([aes_to_scale(v) in {'x', 'y'} for v in vars_]) except TypeError: return aes_to_scale(vars_) in {'x', 'y'}
[ "def", "is_position_aes", "(", "vars_", ")", ":", "try", ":", "return", "all", "(", "[", "aes_to_scale", "(", "v", ")", "in", "{", "'x'", ",", "'y'", "}", "for", "v", "in", "vars_", "]", ")", "except", "TypeError", ":", "return", "aes_to_scale", "(",...
Figure out if an aesthetic is a position aesthetic or not
[ "Figure", "out", "if", "an", "aesthetic", "is", "a", "position", "aesthetic", "or", "not" ]
python
train
30.625
cosven/feeluown-core
fuocore/netease/api.py
https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/netease/api.py#L116-L129
def search(self, s, stype=1, offset=0, total='true', limit=60): """get songs list from search keywords""" action = uri + '/search/get' data = { 's': s, 'type': stype, 'offset': offset, 'total': total, 'limit': 60 } resp ...
[ "def", "search", "(", "self", ",", "s", ",", "stype", "=", "1", ",", "offset", "=", "0", ",", "total", "=", "'true'", ",", "limit", "=", "60", ")", ":", "action", "=", "uri", "+", "'/search/get'", "data", "=", "{", "'s'", ":", "s", ",", "'type'...
get songs list from search keywords
[ "get", "songs", "list", "from", "search", "keywords" ]
python
train
31.142857
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd5xx.py
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L85-L127
def thesis_info(self, key, value): """Populate the ``thesis_info`` key.""" def _get_degree_type(value): DEGREE_TYPES_MAP = { 'RAPPORT DE STAGE': 'other', 'INTERNSHIP REPORT': 'other', 'DIPLOMA': 'diploma', 'BACHELOR': 'bachelor', 'LAUREA': 'lau...
[ "def", "thesis_info", "(", "self", ",", "key", ",", "value", ")", ":", "def", "_get_degree_type", "(", "value", ")", ":", "DEGREE_TYPES_MAP", "=", "{", "'RAPPORT DE STAGE'", ":", "'other'", ",", "'INTERNSHIP REPORT'", ":", "'other'", ",", "'DIPLOMA'", ":", "...
Populate the ``thesis_info`` key.
[ "Populate", "the", "thesis_info", "key", "." ]
python
train
34.976744
tanghaibao/goatools
goatools/grouper/plotobj.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L44-L53
def get_kws_plt(self): """Get keyword args for GoSubDagPlot from self unless they are None.""" kws_plt = {} for key_plt in self.keys_plt: key_val = getattr(self, key_plt, None) if key_val is not None: kws_plt[key_plt] = key_val elif key_plt in ...
[ "def", "get_kws_plt", "(", "self", ")", ":", "kws_plt", "=", "{", "}", "for", "key_plt", "in", "self", ".", "keys_plt", ":", "key_val", "=", "getattr", "(", "self", ",", "key_plt", ",", "None", ")", "if", "key_val", "is", "not", "None", ":", "kws_plt...
Get keyword args for GoSubDagPlot from self unless they are None.
[ "Get", "keyword", "args", "for", "GoSubDagPlot", "from", "self", "unless", "they", "are", "None", "." ]
python
train
39.6
odrling/peony-twitter
examples/birthday.py
https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/examples/birthday.py#L23-L33
async def set_tz(self): """ set the environment timezone to the timezone set in your twitter settings """ settings = await self.api.account.settings.get() tz = settings.time_zone.tzinfo_name os.environ['TZ'] = tz time.tzset()
[ "async", "def", "set_tz", "(", "self", ")", ":", "settings", "=", "await", "self", ".", "api", ".", "account", ".", "settings", ".", "get", "(", ")", "tz", "=", "settings", ".", "time_zone", ".", "tzinfo_name", "os", ".", "environ", "[", "'TZ'", "]",...
set the environment timezone to the timezone set in your twitter settings
[ "set", "the", "environment", "timezone", "to", "the", "timezone", "set", "in", "your", "twitter", "settings" ]
python
valid
26.272727
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2225-L2229
def macro_show(self, id, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/macros#show-macro" api_path = "/api/v2/macros/{id}.json" api_path = api_path.format(id=id) return self.call(api_path, **kwargs)
[ "def", "macro_show", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/macros/{id}.json\"", "api_path", "=", "api_path", ".", "format", "(", "id", "=", "id", ")", "return", "self", ".", "call", "(", "api_path", ",", ...
https://developer.zendesk.com/rest_api/docs/core/macros#show-macro
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "macros#show", "-", "macro" ]
python
train
48.2
impact27/registrator
registrator/channel.py
https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/channel.py#L146-L175
def channel_angle(im, chanapproxangle=None, *, isshiftdftedge=False, truesize=None): """Extract the channel angle from the rfft Parameters: ----------- im: 2d array The channel image chanapproxangle: number, optional If not None, an approximation of the result ...
[ "def", "channel_angle", "(", "im", ",", "chanapproxangle", "=", "None", ",", "*", ",", "isshiftdftedge", "=", "False", ",", "truesize", "=", "None", ")", ":", "im", "=", "np", ".", "asarray", "(", "im", ")", "# Compute edge", "if", "not", "isshiftdftedge...
Extract the channel angle from the rfft Parameters: ----------- im: 2d array The channel image chanapproxangle: number, optional If not None, an approximation of the result isshiftdftedge: boolean, default False If The image has already been treated: (edge, dft, ffts...
[ "Extract", "the", "channel", "angle", "from", "the", "rfft" ]
python
train
28.833333
gem/oq-engine
openquake/hmtk/plotting/mapping.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/plotting/mapping.py#L274-L296
def _plot_simple_fault(self, source, border='k-', border_width=1.0): """ Plots the simple fault source as a composite of the fault trace and the surface projection of the fault. :param source: Fault source as instance of :class: mtkSimpleFaultSource :param str border:...
[ "def", "_plot_simple_fault", "(", "self", ",", "source", ",", "border", "=", "'k-'", ",", "border_width", "=", "1.0", ")", ":", "# Get the trace", "trace_lons", "=", "np", ".", "array", "(", "[", "pnt", ".", "longitude", "for", "pnt", "in", "source", "."...
Plots the simple fault source as a composite of the fault trace and the surface projection of the fault. :param source: Fault source as instance of :class: mtkSimpleFaultSource :param str border: Line properties of border (see matplotlib documentation for detail) ...
[ "Plots", "the", "simple", "fault", "source", "as", "a", "composite", "of", "the", "fault", "trace", "and", "the", "surface", "projection", "of", "the", "fault", ".", ":", "param", "source", ":", "Fault", "source", "as", "instance", "of", ":", "class", ":...
python
train
48.869565
jaraco/jaraco.logging
jaraco/logging.py
https://github.com/jaraco/jaraco.logging/blob/202d0d3b7c16503f9b8de83b6054f1306ae61930/jaraco/logging.py#L14-L25
def log_level(level_string): """ Return a log level for a string >>> log_level('DEBUG') == logging.DEBUG True >>> log_level('30') == logging.WARNING True """ if level_string.isdigit(): return int(level_string) return getattr(logging, level_string.upper())
[ "def", "log_level", "(", "level_string", ")", ":", "if", "level_string", ".", "isdigit", "(", ")", ":", "return", "int", "(", "level_string", ")", "return", "getattr", "(", "logging", ",", "level_string", ".", "upper", "(", ")", ")" ]
Return a log level for a string >>> log_level('DEBUG') == logging.DEBUG True >>> log_level('30') == logging.WARNING True
[ "Return", "a", "log", "level", "for", "a", "string", ">>>", "log_level", "(", "DEBUG", ")", "==", "logging", ".", "DEBUG", "True", ">>>", "log_level", "(", "30", ")", "==", "logging", ".", "WARNING", "True" ]
python
train
22.25
PagerDuty/pagerduty-api-python-client
pypd/log.py
https://github.com/PagerDuty/pagerduty-api-python-client/blob/f420b34ca9b29689cc2ecc9adca6dc5d56ae7161/pypd/log.py#L28-L31
def log(*args, **kwargs): """Log things with the global logger.""" level = kwargs.pop('level', logging.INFO) logger.log(level, *args, **kwargs)
[ "def", "log", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "level", "=", "kwargs", ".", "pop", "(", "'level'", ",", "logging", ".", "INFO", ")", "logger", ".", "log", "(", "level", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Log things with the global logger.
[ "Log", "things", "with", "the", "global", "logger", "." ]
python
train
38