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
minio/minio-py
minio/error.py
https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/error.py#L239-L251
def _set_amz_headers(self): """ Sets x-amz-* error response fields from response headers. """ if self._response.headers: # keeping x-amz-id-2 as part of amz_host_id. if 'x-amz-id-2' in self._response.headers: self.host_id = self._response.headers['...
[ "def", "_set_amz_headers", "(", "self", ")", ":", "if", "self", ".", "_response", ".", "headers", ":", "# keeping x-amz-id-2 as part of amz_host_id.", "if", "'x-amz-id-2'", "in", "self", ".", "_response", ".", "headers", ":", "self", ".", "host_id", "=", "self",...
Sets x-amz-* error response fields from response headers.
[ "Sets", "x", "-", "amz", "-", "*", "error", "response", "fields", "from", "response", "headers", "." ]
python
train
51.461538
GPflow/GPflow
gpflow/models/gplvm.py
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/gplvm.py#L123-L166
def _build_likelihood(self): """ Construct a tensorflow function to compute the bound on the marginal likelihood. """ pX = DiagonalGaussian(self.X_mean, self.X_var) num_inducing = len(self.feature) psi0 = tf.reduce_sum(expectation(pX, self.kern)) psi1 = e...
[ "def", "_build_likelihood", "(", "self", ")", ":", "pX", "=", "DiagonalGaussian", "(", "self", ".", "X_mean", ",", "self", ".", "X_var", ")", "num_inducing", "=", "len", "(", "self", ".", "feature", ")", "psi0", "=", "tf", ".", "reduce_sum", "(", "expe...
Construct a tensorflow function to compute the bound on the marginal likelihood.
[ "Construct", "a", "tensorflow", "function", "to", "compute", "the", "bound", "on", "the", "marginal", "likelihood", "." ]
python
train
47.909091
mozilla/treeherder
treeherder/webapp/api/seta.py
https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/webapp/api/seta.py#L10-L27
def list(self, request, project): ''' Routing to /api/project/{project}/seta/job-priorities/ This API can potentially have these consumers: * Buildbot * build_system_type=buildbot * priority=5 * format=json * TaskCluster (Gecko decision ...
[ "def", "list", "(", "self", ",", "request", ",", "project", ")", ":", "build_system_type", "=", "request", ".", "query_params", ".", "get", "(", "'build_system_type'", ",", "'*'", ")", "priority", "=", "request", ".", "query_params", ".", "get", "(", "'pri...
Routing to /api/project/{project}/seta/job-priorities/ This API can potentially have these consumers: * Buildbot * build_system_type=buildbot * priority=5 * format=json * TaskCluster (Gecko decision task) * build_system_type=taskcl...
[ "Routing", "to", "/", "api", "/", "project", "/", "{", "project", "}", "/", "seta", "/", "job", "-", "priorities", "/" ]
python
train
40.666667
materialsvirtuallab/monty
monty/shutil.py
https://github.com/materialsvirtuallab/monty/blob/d99d6f3c68372d83489d28ff515566c93cd569e2/monty/shutil.py#L87-L100
def compress_dir(path, compression="gz"): """ Recursively compresses all files in a directory. Note that this compresses all files singly, i.e., it does not create a tar archive. For that, just use Python tarfile class. Args: path (str): Path to parent directory. compression (str): ...
[ "def", "compress_dir", "(", "path", ",", "compression", "=", "\"gz\"", ")", ":", "for", "parent", ",", "subdirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "f", "in", "files", ":", "compress_file", "(", "os", ".", "path", ...
Recursively compresses all files in a directory. Note that this compresses all files singly, i.e., it does not create a tar archive. For that, just use Python tarfile class. Args: path (str): Path to parent directory. compression (str): A compression mode. Valid options are "gz" or ...
[ "Recursively", "compresses", "all", "files", "in", "a", "directory", ".", "Note", "that", "this", "compresses", "all", "files", "singly", "i", ".", "e", ".", "it", "does", "not", "create", "a", "tar", "archive", ".", "For", "that", "just", "use", "Python...
python
train
38.857143
tensorpack/tensorpack
examples/SimilarityLearning/mnist-embeddings.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/SimilarityLearning/mnist-embeddings.py#L138-L171
def soft_triplet_loss(anchor, positive, negative, extra=True, scope="soft_triplet_loss"): r"""Loss for triplet networks as described in the paper: `Deep Metric Learning using Triplet Network <https://arxiv.org/abs/1412.6622>`_ by Hoffer et al. It is a softmax loss using :math:`(anchor-positive)^2` and ...
[ "def", "soft_triplet_loss", "(", "anchor", ",", "positive", ",", "negative", ",", "extra", "=", "True", ",", "scope", "=", "\"soft_triplet_loss\"", ")", ":", "eps", "=", "1e-10", "with", "tf", ".", "name_scope", "(", "scope", ")", ":", "d_pos", "=", "tf"...
r"""Loss for triplet networks as described in the paper: `Deep Metric Learning using Triplet Network <https://arxiv.org/abs/1412.6622>`_ by Hoffer et al. It is a softmax loss using :math:`(anchor-positive)^2` and :math:`(anchor-negative)^2` as logits. Args: anchor (tf.Tensor): anchor featu...
[ "r", "Loss", "for", "triplet", "networks", "as", "described", "in", "the", "paper", ":", "Deep", "Metric", "Learning", "using", "Triplet", "Network", "<https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1412", ".", "6622", ">", "_", "by", "Hoffe...
python
train
40.882353
funilrys/PyFunceble
PyFunceble/http_code.py
https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/http_code.py#L157-L204
def get(self): """ Return the HTTP code status. :return: The matched and formatted status code. :rtype: str|int|None """ if PyFunceble.HTTP_CODE["active"]: # The http status code extraction is activated. # We get the http status code. ...
[ "def", "get", "(", "self", ")", ":", "if", "PyFunceble", ".", "HTTP_CODE", "[", "\"active\"", "]", ":", "# The http status code extraction is activated.", "# We get the http status code.", "http_code", "=", "self", ".", "_access", "(", ")", "# We initiate a variable whi...
Return the HTTP code status. :return: The matched and formatted status code. :rtype: str|int|None
[ "Return", "the", "HTTP", "code", "status", "." ]
python
test
34.208333
sorgerlab/indra
indra/belief/__init__.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L393-L409
def set_linked_probs(self, linked_statements): """Sets the belief probabilities for a list of linked INDRA Statements. The list of LinkedStatement objects is assumed to come from the MechanismLinker. The belief probability of the inferred Statement is assigned the joint probability of i...
[ "def", "set_linked_probs", "(", "self", ",", "linked_statements", ")", ":", "for", "st", "in", "linked_statements", ":", "source_probs", "=", "[", "s", ".", "belief", "for", "s", "in", "st", ".", "source_stmts", "]", "st", ".", "inferred_stmt", ".", "belie...
Sets the belief probabilities for a list of linked INDRA Statements. The list of LinkedStatement objects is assumed to come from the MechanismLinker. The belief probability of the inferred Statement is assigned the joint probability of its source Statements. Parameters --------...
[ "Sets", "the", "belief", "probabilities", "for", "a", "list", "of", "linked", "INDRA", "Statements", "." ]
python
train
48.411765
RiotGames/cloud-inquisitor
backend/cloud_inquisitor/json_utils.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/backend/cloud_inquisitor/json_utils.py#L24-L47
def default(self, obj): """Default object encoder function Args: obj (:obj:`Any`): Object to be serialized Returns: JSON string """ if isinstance(obj, datetime): return obj.isoformat() if issubclass(obj.__class__, Enum.__class__): ...
[ "def", "default", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "datetime", ")", ":", "return", "obj", ".", "isoformat", "(", ")", "if", "issubclass", "(", "obj", ".", "__class__", ",", "Enum", ".", "__class__", ")", ":", ...
Default object encoder function Args: obj (:obj:`Any`): Object to be serialized Returns: JSON string
[ "Default", "object", "encoder", "function" ]
python
train
25.291667
saltstack/salt
salt/modules/riak.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/riak.py#L20-L26
def __execute_cmd(name, cmd): ''' Execute Riak commands ''' return __salt__['cmd.run_all']( '{0} {1}'.format(salt.utils.path.which(name), cmd) )
[ "def", "__execute_cmd", "(", "name", ",", "cmd", ")", ":", "return", "__salt__", "[", "'cmd.run_all'", "]", "(", "'{0} {1}'", ".", "format", "(", "salt", ".", "utils", ".", "path", ".", "which", "(", "name", ")", ",", "cmd", ")", ")" ]
Execute Riak commands
[ "Execute", "Riak", "commands" ]
python
train
23.714286
enkore/i3pystatus
i3pystatus/core/command.py
https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/core/command.py#L53-L83
def execute(command, detach=False): """ Runs a command in background. No output is retrieved. Useful for running GUI applications that would block click events. :param command: A string or a list of strings containing the name and arguments of the program. :param detach: If set to `True` the p...
[ "def", "execute", "(", "command", ",", "detach", "=", "False", ")", ":", "if", "detach", ":", "if", "not", "isinstance", "(", "command", ",", "str", ")", ":", "msg", "=", "\"Detached mode expects a string as command, not {}\"", ".", "format", "(", "command", ...
Runs a command in background. No output is retrieved. Useful for running GUI applications that would block click events. :param command: A string or a list of strings containing the name and arguments of the program. :param detach: If set to `True` the program will be executed using the `i3-msg` ...
[ "Runs", "a", "command", "in", "background", ".", "No", "output", "is", "retrieved", ".", "Useful", "for", "running", "GUI", "applications", "that", "would", "block", "click", "events", "." ]
python
train
41.967742
SamLau95/nbinteract
nbinteract/util.py
https://github.com/SamLau95/nbinteract/blob/9f346452283831aad3f4416c04879f1d187ec3b7/nbinteract/util.py#L36-L43
def maybe_curry(maybe_fn, first_arg) -> 'Function | Any': """ If maybe_fn is a function, curries it and passes in first_arg. Otherwise returns maybe_fn. """ if not callable(maybe_fn): return maybe_fn return tz.curry(maybe_fn)(first_arg)
[ "def", "maybe_curry", "(", "maybe_fn", ",", "first_arg", ")", "->", "'Function | Any'", ":", "if", "not", "callable", "(", "maybe_fn", ")", ":", "return", "maybe_fn", "return", "tz", ".", "curry", "(", "maybe_fn", ")", "(", "first_arg", ")" ]
If maybe_fn is a function, curries it and passes in first_arg. Otherwise returns maybe_fn.
[ "If", "maybe_fn", "is", "a", "function", "curries", "it", "and", "passes", "in", "first_arg", ".", "Otherwise", "returns", "maybe_fn", "." ]
python
train
32.625
awacha/sastool
sastool/fitting/fitfunctions/basic.py
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L76-L91
def Cube(x, a, b, c, d): """Third order polynomial Inputs: ------- ``x``: independent variable ``a``: coefficient of the third-order term ``b``: coefficient of the second-order term ``c``: coefficient of the first-order term ``d``: additive constant Formula: ...
[ "def", "Cube", "(", "x", ",", "a", ",", "b", ",", "c", ",", "d", ")", ":", "return", "a", "*", "x", "**", "3", "+", "b", "*", "x", "**", "2", "+", "c", "*", "x", "+", "d" ]
Third order polynomial Inputs: ------- ``x``: independent variable ``a``: coefficient of the third-order term ``b``: coefficient of the second-order term ``c``: coefficient of the first-order term ``d``: additive constant Formula: -------- ``a*x^3 + b*x^...
[ "Third", "order", "polynomial" ]
python
train
25.3125
PatrikValkovic/grammpy
grammpy/representation/Grammar.py
https://github.com/PatrikValkovic/grammpy/blob/879ce0ef794ac2823acc19314fcd7a8aba53e50f/grammpy/representation/Grammar.py#L85-L94
def start(self, s): # type: (Optional[Type[Nonterminal]]) -> None """ Set start symbol of the grammar. :param s: Start symbol to set. :raise NonterminalDoesNotExistsException: If the start symbol is not in nonterminals. """ if s is not None and s not in self.nonte...
[ "def", "start", "(", "self", ",", "s", ")", ":", "# type: (Optional[Type[Nonterminal]]) -> None", "if", "s", "is", "not", "None", "and", "s", "not", "in", "self", ".", "nonterminals", ":", "raise", "NonterminalDoesNotExistsException", "(", "None", ",", "s", ",...
Set start symbol of the grammar. :param s: Start symbol to set. :raise NonterminalDoesNotExistsException: If the start symbol is not in nonterminals.
[ "Set", "start", "symbol", "of", "the", "grammar", ".", ":", "param", "s", ":", "Start", "symbol", "to", "set", ".", ":", "raise", "NonterminalDoesNotExistsException", ":", "If", "the", "start", "symbol", "is", "not", "in", "nonterminals", "." ]
python
train
41.7
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwk/hmac.py
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/hmac.py#L90-L122
def encryption_key(self, alg, **kwargs): """ Return an encryption key as per http://openid.net/specs/openid-connect-core-1_0.html#Encryption :param alg: encryption algorithm :param kwargs: :return: encryption key as byte string """ if not self.key: ...
[ "def", "encryption_key", "(", "self", ",", "alg", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "key", ":", "self", ".", "deserialize", "(", ")", "try", ":", "tsize", "=", "ALG2KEYLEN", "[", "alg", "]", "except", "KeyError", ":", "ra...
Return an encryption key as per http://openid.net/specs/openid-connect-core-1_0.html#Encryption :param alg: encryption algorithm :param kwargs: :return: encryption key as byte string
[ "Return", "an", "encryption", "key", "as", "per", "http", ":", "//", "openid", ".", "net", "/", "specs", "/", "openid", "-", "connect", "-", "core", "-", "1_0", ".", "html#Encryption" ]
python
train
28.848485
PMBio/limix-backup
limix/mtSet/iset_strat.py
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/iset_strat.py#L165-L175
def getVC(self): """ Variance componenrs """ _Cr = decompose_GxE(self.full['Cr']) RV = {} for key in list(_Cr.keys()): RV['var_%s' % key] = sp.array([var_CoXX(_Cr[key], self.Xr)]) RV['var_c'] = self.full['var_c'] RV['var_n'] = self.full['var_n...
[ "def", "getVC", "(", "self", ")", ":", "_Cr", "=", "decompose_GxE", "(", "self", ".", "full", "[", "'Cr'", "]", ")", "RV", "=", "{", "}", "for", "key", "in", "list", "(", "_Cr", ".", "keys", "(", ")", ")", ":", "RV", "[", "'var_%s'", "%", "ke...
Variance componenrs
[ "Variance", "componenrs" ]
python
train
30.090909
helixyte/everest
everest/ini.py
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/ini.py#L32-L44
def options(self, parser, env=None): """ Adds command-line options for this plugin. """ if env is None: env = os.environ env_opt_name = 'NOSE_%s' % self.__dest_opt_name.upper() parser.add_option("--%s" % self.__opt_name, dest=self.__d...
[ "def", "options", "(", "self", ",", "parser", ",", "env", "=", "None", ")", ":", "if", "env", "is", "None", ":", "env", "=", "os", ".", "environ", "env_opt_name", "=", "'NOSE_%s'", "%", "self", ".", "__dest_opt_name", ".", "upper", "(", ")", "parser"...
Adds command-line options for this plugin.
[ "Adds", "command", "-", "line", "options", "for", "this", "plugin", "." ]
python
train
42.538462
bwohlberg/sporco
sporco/admm/pdcsc.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/pdcsc.py#L422-L432
def block_sep1(self, Y): r"""Separate variable into component corresponding to :math:`\mathbf{y}_1` in :math:`\mathbf{y}\;\;`. """ # This method is overridden because we have to change the # mechanism for combining the Y0 and Y1 blocks into a single # array (see comment ...
[ "def", "block_sep1", "(", "self", ",", "Y", ")", ":", "# This method is overridden because we have to change the", "# mechanism for combining the Y0 and Y1 blocks into a single", "# array (see comment in the __init__ method).", "shp", "=", "Y", ".", "shape", "[", "0", ":", "sel...
r"""Separate variable into component corresponding to :math:`\mathbf{y}_1` in :math:`\mathbf{y}\;\;`.
[ "r", "Separate", "variable", "into", "component", "corresponding", "to", ":", "math", ":", "\\", "mathbf", "{", "y", "}", "_1", "in", ":", "math", ":", "\\", "mathbf", "{", "y", "}", "\\", ";", "\\", ";", "." ]
python
train
46.272727
BD2KGenomics/toil-scripts
src/toil_scripts/bwa_alignment/old_alignment_script/batch_align.py
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/bwa_alignment/old_alignment_script/batch_align.py#L180-L238
def alignment(job, ids, input_args, sample): """ Runs BWA and then Bamsort on the supplied fastqs for this sample Input1: Toil Job instance Input2: jobstore id dictionary Input3: Input arguments dictionary Input4: Sample tuple -- contains uuid and urls for the sample """ uuid, urls = sa...
[ "def", "alignment", "(", "job", ",", "ids", ",", "input_args", ",", "sample", ")", ":", "uuid", ",", "urls", "=", "sample", "# ids['bam'] = job.fileStore.getEmptyFileStoreID()", "work_dir", "=", "job", ".", "fileStore", ".", "getLocalTempDir", "(", ")", "output_...
Runs BWA and then Bamsort on the supplied fastqs for this sample Input1: Toil Job instance Input2: jobstore id dictionary Input3: Input arguments dictionary Input4: Sample tuple -- contains uuid and urls for the sample
[ "Runs", "BWA", "and", "then", "Bamsort", "on", "the", "supplied", "fastqs", "for", "this", "sample" ]
python
train
43.576271
senaite/senaite.core
bika/lims/content/abstractbaseanalysis.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/abstractbaseanalysis.py#L815-L822
def getTotalDiscountedBulkPrice(self): """Compute total discounted corporate bulk price """ price = self.getDiscountedCorporatePrice() vat = self.getVAT() price = price and price or 0 vat = vat and vat or 0 return float(price) + (float(price) * float(vat)) / 100
[ "def", "getTotalDiscountedBulkPrice", "(", "self", ")", ":", "price", "=", "self", ".", "getDiscountedCorporatePrice", "(", ")", "vat", "=", "self", ".", "getVAT", "(", ")", "price", "=", "price", "and", "price", "or", "0", "vat", "=", "vat", "and", "vat...
Compute total discounted corporate bulk price
[ "Compute", "total", "discounted", "corporate", "bulk", "price" ]
python
train
38.875
google/grumpy
third_party/stdlib/textwrap.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/textwrap.py#L247-L317
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string] Wrap a sequence of text chunks and return a list of lines of length 'self.width' or less. (If 'break_long_words' is false, some lines may be longer than this.) Chunks correspond roughly to words and...
[ "def", "_wrap_chunks", "(", "self", ",", "chunks", ")", ":", "lines", "=", "[", "]", "if", "self", ".", "width", "<=", "0", ":", "raise", "ValueError", "(", "\"invalid width %r (must be > 0)\"", "%", "self", ".", "width", ")", "# Arrange in reverse order so it...
_wrap_chunks(chunks : [string]) -> [string] Wrap a sequence of text chunks and return a list of lines of length 'self.width' or less. (If 'break_long_words' is false, some lines may be longer than this.) Chunks correspond roughly to words and the whitespace between them: each chunk is...
[ "_wrap_chunks", "(", "chunks", ":", "[", "string", "]", ")", "-", ">", "[", "string", "]" ]
python
valid
38.661972
matthewdeanmartin/jiggle_version
jiggle_version/find_version_class.py
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/find_version_class.py#L186-L214
def validate_current_versions(self): # type: () -> bool """ Can a version be found? Are all versions currently the same? Are they valid sem ver? :return: """ versions = self.all_current_versions() for _, version in versions.items(): if "Invalid Semantic Versi...
[ "def", "validate_current_versions", "(", "self", ")", ":", "# type: () -> bool", "versions", "=", "self", ".", "all_current_versions", "(", ")", "for", "_", ",", "version", "in", "versions", ".", "items", "(", ")", ":", "if", "\"Invalid Semantic Version\"", "in"...
Can a version be found? Are all versions currently the same? Are they valid sem ver? :return:
[ "Can", "a", "version", "be", "found?", "Are", "all", "versions", "currently", "the", "same?", "Are", "they", "valid", "sem", "ver?", ":", "return", ":" ]
python
train
38.103448
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_ppp.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_ppp.py#L35-L53
def start_ppp_link(self): '''startup the link''' cmd = ['pppd'] cmd.extend(self.command) (self.pid, self.ppp_fd) = pty.fork() if self.pid == 0: os.execvp("pppd", cmd) raise RuntimeError("pppd exited") if self.ppp_fd == -1: print("Failed...
[ "def", "start_ppp_link", "(", "self", ")", ":", "cmd", "=", "[", "'pppd'", "]", "cmd", ".", "extend", "(", "self", ".", "command", ")", "(", "self", ".", "pid", ",", "self", ".", "ppp_fd", ")", "=", "pty", ".", "fork", "(", ")", "if", "self", "...
startup the link
[ "startup", "the", "link" ]
python
train
35.315789
agabrown/PyGaia
examples/parallax_errors.py
https://github.com/agabrown/PyGaia/blob/ae972b0622a15f713ffae471f925eac25ccdae47/examples/parallax_errors.py#L33-L42
def parseCommandLineArguments(): """ Set up command line parsing. """ parser = argparse.ArgumentParser(description="Calculate parallax error for given G and (V-I)") parser.add_argument("gmag", help="G-band magnitude of source", type=float) parser.add_argument("vmini", help="(V-I) colour of source", type=flo...
[ "def", "parseCommandLineArguments", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Calculate parallax error for given G and (V-I)\"", ")", "parser", ".", "add_argument", "(", "\"gmag\"", ",", "help", "=", "\"G-band magnitude...
Set up command line parsing.
[ "Set", "up", "command", "line", "parsing", "." ]
python
test
36.2
ralphje/imagemounter
imagemounter/parser.py
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/parser.py#L141-L150
def get_by_index(self, index): """Returns a Volume or Disk by its index.""" try: return self[index] except KeyError: for v in self.get_volumes(): if v.index == str(index): return v raise KeyError(index)
[ "def", "get_by_index", "(", "self", ",", "index", ")", ":", "try", ":", "return", "self", "[", "index", "]", "except", "KeyError", ":", "for", "v", "in", "self", ".", "get_volumes", "(", ")", ":", "if", "v", ".", "index", "==", "str", "(", "index",...
Returns a Volume or Disk by its index.
[ "Returns", "a", "Volume", "or", "Disk", "by", "its", "index", "." ]
python
train
28.6
numenta/nupic
src/nupic/data/generators/pattern_machine.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L183-L192
def _getW(self): """ Gets a value of `w` for use in generating a pattern. """ w = self._w if type(w) is list: return w[self._random.getUInt32(len(w))] else: return w
[ "def", "_getW", "(", "self", ")", ":", "w", "=", "self", ".", "_w", "if", "type", "(", "w", ")", "is", "list", ":", "return", "w", "[", "self", ".", "_random", ".", "getUInt32", "(", "len", "(", "w", ")", ")", "]", "else", ":", "return", "w" ...
Gets a value of `w` for use in generating a pattern.
[ "Gets", "a", "value", "of", "w", "for", "use", "in", "generating", "a", "pattern", "." ]
python
valid
19.3
ArchiveTeam/wpull
wpull/warc/recorder.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/warc/recorder.py#L154-L162
def _start_new_cdx_file(self): '''Create and set current CDX file.''' self._cdx_filename = '{0}.cdx'.format(self._prefix_filename) if not self._params.appending: wpull.util.truncate_file(self._cdx_filename) self._write_cdx_header() elif not os.path.exists(self._c...
[ "def", "_start_new_cdx_file", "(", "self", ")", ":", "self", ".", "_cdx_filename", "=", "'{0}.cdx'", ".", "format", "(", "self", ".", "_prefix_filename", ")", "if", "not", "self", ".", "_params", ".", "appending", ":", "wpull", ".", "util", ".", "truncate_...
Create and set current CDX file.
[ "Create", "and", "set", "current", "CDX", "file", "." ]
python
train
40.222222
widdowquinn/pyani
pyani/anim.py
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/anim.py#L169-L244
def process_deltadir(delta_dir, org_lengths, logger=None): """Returns a tuple of ANIm results for .deltas in passed directory. - delta_dir - path to the directory containing .delta files - org_lengths - dictionary of total sequence lengths, keyed by sequence Returns the following pandas dataframes in ...
[ "def", "process_deltadir", "(", "delta_dir", ",", "org_lengths", ",", "logger", "=", "None", ")", ":", "# Process directory to identify input files - as of v0.2.4 we use the", "# .filter files that result from delta-filter (1:1 alignments)", "deltafiles", "=", "pyani_files", ".", ...
Returns a tuple of ANIm results for .deltas in passed directory. - delta_dir - path to the directory containing .delta files - org_lengths - dictionary of total sequence lengths, keyed by sequence Returns the following pandas dataframes in an ANIResults object; query sequences are rows, subject sequen...
[ "Returns", "a", "tuple", "of", "ANIm", "results", "for", ".", "deltas", "in", "passed", "directory", "." ]
python
train
44.855263
mozilla/treeherder
treeherder/webapp/api/jobs.py
https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/webapp/api/jobs.py#L323-L341
def text_log_errors(self, request, project, pk=None): """ Gets a list of steps associated with this job """ try: job = Job.objects.get(repository__name=project, id=pk) except Job.DoesNotExist: return Response("No job with ...
[ "def", "text_log_errors", "(", "self", ",", "request", ",", "project", ",", "pk", "=", "None", ")", ":", "try", ":", "job", "=", "Job", ".", "objects", ".", "get", "(", "repository__name", "=", "project", ",", "id", "=", "pk", ")", "except", "Job", ...
Gets a list of steps associated with this job
[ "Gets", "a", "list", "of", "steps", "associated", "with", "this", "job" ]
python
train
49.684211
pantsbuild/pants
src/python/pants/backend/jvm/tasks/classpath_util.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/classpath_util.py#L89-L102
def internal_classpath(cls, targets, classpath_products, confs=('default',)): """Return the list of internal classpath entries for a classpath covering all `targets`. Any classpath entries contributed by external dependencies will be omitted. :param targets: Targets to build an aggregated classpath for. ...
[ "def", "internal_classpath", "(", "cls", ",", "targets", ",", "classpath_products", ",", "confs", "=", "(", "'default'", ",", ")", ")", ":", "classpath_tuples", "=", "classpath_products", ".", "get_internal_classpath_entries_for_targets", "(", "targets", ")", "filte...
Return the list of internal classpath entries for a classpath covering all `targets`. Any classpath entries contributed by external dependencies will be omitted. :param targets: Targets to build an aggregated classpath for. :param ClasspathProducts classpath_products: Product containing classpath elements...
[ "Return", "the", "list", "of", "internal", "classpath", "entries", "for", "a", "classpath", "covering", "all", "targets", "." ]
python
train
57.714286
bmihelac/django-cruds
cruds/utils.py
https://github.com/bmihelac/django-cruds/blob/7828aac3eb2b4c02e5f3843c4cbff654d57cf1e7/cruds/utils.py#L112-L126
def crud_permission_name(model, action, convert=True): """Returns permission name using Django naming convention: app_label.action_object. If `convert` is True, `create` and `update` actions would be renamed to `add` and `change`. """ app_label = model._meta.app_label model_lower = model.__name...
[ "def", "crud_permission_name", "(", "model", ",", "action", ",", "convert", "=", "True", ")", ":", "app_label", "=", "model", ".", "_meta", ".", "app_label", "model_lower", "=", "model", ".", "__name__", ".", "lower", "(", ")", "if", "convert", ":", "act...
Returns permission name using Django naming convention: app_label.action_object. If `convert` is True, `create` and `update` actions would be renamed to `add` and `change`.
[ "Returns", "permission", "name", "using", "Django", "naming", "convention", ":", "app_label", ".", "action_object", "." ]
python
train
31.933333
assemblerflow/flowcraft
flowcraft/templates/assembly_report.py
https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/templates/assembly_report.py#L318-L334
def _gc_prop(s, length): """Get proportion of GC from a string Parameters ---------- s : str Arbitrary string Returns ------- x : float GC proportion. """ gc = sum(map(s.count, ["c", "g"])) return gc / length
[ "def", "_gc_prop", "(", "s", ",", "length", ")", ":", "gc", "=", "sum", "(", "map", "(", "s", ".", "count", ",", "[", "\"c\"", ",", "\"g\"", "]", ")", ")", "return", "gc", "/", "length" ]
Get proportion of GC from a string Parameters ---------- s : str Arbitrary string Returns ------- x : float GC proportion.
[ "Get", "proportion", "of", "GC", "from", "a", "string" ]
python
test
17.647059
Opentrons/opentrons
api/src/opentrons/deck_calibration/dc_main.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/deck_calibration/dc_main.py#L492-L542
def main(): """ A CLI application for performing factory calibration of an Opentrons robot Instructions: - Robot must be set up with two 300ul or 50ul single-channel pipettes installed on the right-hand and left-hand mount. - Put a GEB 300ul tip onto the pipette. - Use the...
[ "def", "main", "(", ")", ":", "prompt", "=", "input", "(", "\">>> Warning! Running this tool backup and clear any previous \"", "\"calibration data. Proceed (y/[n])? \"", ")", "if", "prompt", "not", "in", "[", "'y'", ",", "'Y'", ",", "'yes'", "]", ":", "print", "(",...
A CLI application for performing factory calibration of an Opentrons robot Instructions: - Robot must be set up with two 300ul or 50ul single-channel pipettes installed on the right-hand and left-hand mount. - Put a GEB 300ul tip onto the pipette. - Use the arrow keys to jog the r...
[ "A", "CLI", "application", "for", "performing", "factory", "calibration", "of", "an", "Opentrons", "robot" ]
python
train
43.686275
sernst/cauldron
cauldron/session/exposed.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L125-L146
def get_internal_project( self, timeout: float = 1 ) -> typing.Union['projects.Project', None]: """ Attempts to return the internally loaded project. This function prevents race condition issues where projects are loaded via threads because the internal loop w...
[ "def", "get_internal_project", "(", "self", ",", "timeout", ":", "float", "=", "1", ")", "->", "typing", ".", "Union", "[", "'projects.Project'", ",", "None", "]", ":", "count", "=", "int", "(", "timeout", "/", "0.1", ")", "for", "_", "in", "range", ...
Attempts to return the internally loaded project. This function prevents race condition issues where projects are loaded via threads because the internal loop will try to continuously load the internal project until it is available or until the timeout is reached. :param timeout: ...
[ "Attempts", "to", "return", "the", "internally", "loaded", "project", ".", "This", "function", "prevents", "race", "condition", "issues", "where", "projects", "are", "loaded", "via", "threads", "because", "the", "internal", "loop", "will", "try", "to", "continuo...
python
train
35.181818
ModisWorks/modis
modis/discord_modis/modules/tableflip/on_message.py
https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/tableflip/on_message.py#L6-L30
async def on_message(message): """The on_message event handler for this module Args: message (discord.Message): Input message """ # Simplify message info server = message.server author = message.author channel = message.channel content = message.content data = datatools.ge...
[ "async", "def", "on_message", "(", "message", ")", ":", "# Simplify message info", "server", "=", "message", ".", "server", "author", "=", "message", ".", "author", "channel", "=", "message", ".", "channel", "content", "=", "message", ".", "content", "data", ...
The on_message event handler for this module Args: message (discord.Message): Input message
[ "The", "on_message", "event", "handler", "for", "this", "module" ]
python
train
29.36
TheGhouls/oct
oct/core/devices.py
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/core/devices.py#L7-L31
def forwarder(frontend, backend): """Simple pub/sub forwarder :param int frontend: fontend zeromq port :param int backend: backend zeromq port """ try: context = zmq.Context() front_sub = context.socket(zmq.SUB) front_sub.bind("tcp://*:%d" % frontend) front_sub.set...
[ "def", "forwarder", "(", "frontend", ",", "backend", ")", ":", "try", ":", "context", "=", "zmq", ".", "Context", "(", ")", "front_sub", "=", "context", ".", "socket", "(", "zmq", ".", "SUB", ")", "front_sub", ".", "bind", "(", "\"tcp://*:%d\"", "%", ...
Simple pub/sub forwarder :param int frontend: fontend zeromq port :param int backend: backend zeromq port
[ "Simple", "pub", "/", "sub", "forwarder" ]
python
train
27.64
spyder-ide/spyder
spyder/plugins/console/widgets/internalshell.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/widgets/internalshell.py#L373-L384
def execute_lines(self, lines): """ Execute a set of lines as multiple command lines: multiple lines of text to be executed as single commands """ for line in lines.splitlines(): stripped_line = line.strip() if stripped_line.startswith('#'): ...
[ "def", "execute_lines", "(", "self", ",", "lines", ")", ":", "for", "line", "in", "lines", ".", "splitlines", "(", ")", ":", "stripped_line", "=", "line", ".", "strip", "(", ")", "if", "stripped_line", ".", "startswith", "(", "'#'", ")", ":", "continue...
Execute a set of lines as multiple command lines: multiple lines of text to be executed as single commands
[ "Execute", "a", "set", "of", "lines", "as", "multiple", "command", "lines", ":", "multiple", "lines", "of", "text", "to", "be", "executed", "as", "single", "commands" ]
python
train
37.583333
wandb/client
wandb/summary.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/summary.py#L271-L307
def _encode(self, value, path_from_root): """Normalize, compress, and encode sub-objects for backend storage. value: Object to encode. path_from_root: `tuple` of key strings from the top-level summary to the current `value`. Returns: A new tree of dict's with la...
[ "def", "_encode", "(", "self", ",", "value", ",", "path_from_root", ")", ":", "# Constructs a new `dict` tree in `json_value` that discards and/or", "# encodes objects that aren't JSON serializable.", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "json_value", "=...
Normalize, compress, and encode sub-objects for backend storage. value: Object to encode. path_from_root: `tuple` of key strings from the top-level summary to the current `value`. Returns: A new tree of dict's with large objects replaced with dictionaries wi...
[ "Normalize", "compress", "and", "encode", "sub", "-", "objects", "for", "backend", "storage", "." ]
python
train
41.162162
rocky/python-uncompyle6
uncompyle6/parsers/parse3.py
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parsers/parse3.py#L527-L1164
def customize_grammar_rules(self, tokens, customize): """The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. Here, we add additional grammar rules based on specific...
[ "def", "customize_grammar_rules", "(", "self", ",", "tokens", ",", "customize", ")", ":", "is_pypy", "=", "False", "# For a rough break out on the first word. This may", "# include instructions that don't need customization,", "# but we'll do a finer check after the rough breakout.", ...
The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. Here, we add additional grammar rules based on specific instructions that are in the instruction/token stream. I...
[ "The", "base", "grammar", "we", "start", "out", "for", "a", "Python", "version", "even", "with", "the", "subclassing", "is", "well", "is", "pretty", "base", ".", "And", "we", "want", "it", "that", "way", ":", "lean", "and", "mean", "so", "that", "parsi...
python
train
52.382445
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/__init__.py
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L167-L176
def get_absolute_path(some_path): """ This function will return an appropriate absolute path for the path it is given. If the input is absolute, it will return unmodified; if the input is relative, it will be rendered as relative to the current working directory. """ if os.path.isabs(some_path):...
[ "def", "get_absolute_path", "(", "some_path", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "some_path", ")", ":", "return", "some_path", "else", ":", "return", "evaluate_relative_path", "(", "os", ".", "getcwd", "(", ")", ",", "some_path", ")" ]
This function will return an appropriate absolute path for the path it is given. If the input is absolute, it will return unmodified; if the input is relative, it will be rendered as relative to the current working directory.
[ "This", "function", "will", "return", "an", "appropriate", "absolute", "path", "for", "the", "path", "it", "is", "given", ".", "If", "the", "input", "is", "absolute", "it", "will", "return", "unmodified", ";", "if", "the", "input", "is", "relative", "it", ...
python
train
40.8
knipknap/exscript
Exscript/protocols/__init__.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/protocols/__init__.py#L54-L66
def create_protocol(name, **kwargs): """ Returns an instance of the protocol with the given name. :type name: str :param name: The name of the protocol. :rtype: Protocol :return: An instance of the protocol. """ cls = protocol_map.get(name) if not cls: raise ValueError('Un...
[ "def", "create_protocol", "(", "name", ",", "*", "*", "kwargs", ")", ":", "cls", "=", "protocol_map", ".", "get", "(", "name", ")", "if", "not", "cls", ":", "raise", "ValueError", "(", "'Unsupported protocol \"%s\".'", "%", "name", ")", "return", "cls", ...
Returns an instance of the protocol with the given name. :type name: str :param name: The name of the protocol. :rtype: Protocol :return: An instance of the protocol.
[ "Returns", "an", "instance", "of", "the", "protocol", "with", "the", "given", "name", "." ]
python
train
28.153846
ProjetPP/PPP-datamodel-Python
ppp_datamodel/utils/serializableattributesholder.py
https://github.com/ProjetPP/PPP-datamodel-Python/blob/0c7958fb4df75468fd3137240a5065925c239776/ppp_datamodel/utils/serializableattributesholder.py#L30-L36
def from_json(cls, data): """Decode a JSON string and inflate a node instance.""" # Decode JSON string assert isinstance(data, str) data = json.loads(data) assert isinstance(data, dict) return cls.from_dict(data)
[ "def", "from_json", "(", "cls", ",", "data", ")", ":", "# Decode JSON string", "assert", "isinstance", "(", "data", ",", "str", ")", "data", "=", "json", ".", "loads", "(", "data", ")", "assert", "isinstance", "(", "data", ",", "dict", ")", "return", "...
Decode a JSON string and inflate a node instance.
[ "Decode", "a", "JSON", "string", "and", "inflate", "a", "node", "instance", "." ]
python
train
36.285714
Kozea/pygal
pygal/graph/stackedline.py
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/stackedline.py#L52-L59
def _fill(self, values): """Add extra values to fill the line""" if not self._previous_line: self._previous_line = values return super(StackedLine, self)._fill(values) new_values = values + list(reversed(self._previous_line)) self._previous_line = values r...
[ "def", "_fill", "(", "self", ",", "values", ")", ":", "if", "not", "self", ".", "_previous_line", ":", "self", ".", "_previous_line", "=", "values", "return", "super", "(", "StackedLine", ",", "self", ")", ".", "_fill", "(", "values", ")", "new_values", ...
Add extra values to fill the line
[ "Add", "extra", "values", "to", "fill", "the", "line" ]
python
train
41.125
ewels/MultiQC
multiqc/modules/verifybamid/verifybamid.py
https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/verifybamid/verifybamid.py#L78-L116
def parse_selfsm(self, f): """ Go through selfSM file and create a dictionary with the sample name as a key, """ #create a dictionary to populate from this sample's file parsed_data = dict() # set a empty variable which denotes if the headers have been read headers = None # for each line in the file for l...
[ "def", "parse_selfsm", "(", "self", ",", "f", ")", ":", "#create a dictionary to populate from this sample's file", "parsed_data", "=", "dict", "(", ")", "# set a empty variable which denotes if the headers have been read", "headers", "=", "None", "# for each line in the file", ...
Go through selfSM file and create a dictionary with the sample name as a key,
[ "Go", "through", "selfSM", "file", "and", "create", "a", "dictionary", "with", "the", "sample", "name", "as", "a", "key" ]
python
train
41.769231
jelmer/python-fastimport
fastimport/processors/info_processor.py
https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/processors/info_processor.py#L238-L246
def reset_handler(self, cmd): """Process a ResetCommand.""" self.cmd_counts[cmd.name] += 1 if cmd.ref.startswith('refs/tags/'): self.lightweight_tags += 1 else: if cmd.from_ is not None: self.reftracker.track_heads_for_ref( cmd....
[ "def", "reset_handler", "(", "self", ",", "cmd", ")", ":", "self", ".", "cmd_counts", "[", "cmd", ".", "name", "]", "+=", "1", "if", "cmd", ".", "ref", ".", "startswith", "(", "'refs/tags/'", ")", ":", "self", ".", "lightweight_tags", "+=", "1", "els...
Process a ResetCommand.
[ "Process", "a", "ResetCommand", "." ]
python
train
36.333333
angr/angr
angr/storage/memory.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/storage/memory.py#L129-L171
def map(self, absolute_address, region_id, related_function_address=None): """ Add a mapping between an absolute address and a region ID. If this is a stack region map, all stack regions beyond (lower than) this newly added regions will be discarded. :param absolute_address: ...
[ "def", "map", "(", "self", ",", "absolute_address", ",", "region_id", ",", "related_function_address", "=", "None", ")", ":", "if", "self", ".", "is_stack", ":", "# Sanity check", "if", "not", "region_id", ".", "startswith", "(", "'stack_'", ")", ":", "raise...
Add a mapping between an absolute address and a region ID. If this is a stack region map, all stack regions beyond (lower than) this newly added regions will be discarded. :param absolute_address: An absolute memory address. :param region_id: ID of the memory region...
[ "Add", "a", "mapping", "between", "an", "absolute", "address", "and", "a", "region", "ID", ".", "If", "this", "is", "a", "stack", "region", "map", "all", "stack", "regions", "beyond", "(", "lower", "than", ")", "this", "newly", "added", "regions", "will"...
python
train
45.069767
learningequality/ricecooker
ricecooker/commands.py
https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/commands.py#L260-L269
def get_file_diff(tree, files_to_diff): """ get_file_diff: Download files from nodes Args: tree (ChannelManager): manager to handle communication to Kolibri Studio Returns: list of files that are not on Kolibri Studio """ # Determine which files have not yet been uploaded to the ...
[ "def", "get_file_diff", "(", "tree", ",", "files_to_diff", ")", ":", "# Determine which files have not yet been uploaded to the CC server", "config", ".", "LOGGER", ".", "info", "(", "\"\\nChecking if files exist on Kolibri Studio...\"", ")", "file_diff", "=", "tree", ".", ...
get_file_diff: Download files from nodes Args: tree (ChannelManager): manager to handle communication to Kolibri Studio Returns: list of files that are not on Kolibri Studio
[ "get_file_diff", ":", "Download", "files", "from", "nodes", "Args", ":", "tree", "(", "ChannelManager", ")", ":", "manager", "to", "handle", "communication", "to", "Kolibri", "Studio", "Returns", ":", "list", "of", "files", "that", "are", "not", "on", "Kolib...
python
train
46.4
numenta/nupic
src/nupic/encoders/scalar.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/scalar.py#L421-L468
def encodeIntoArray(self, input, output, learn=True): """ See method description in base.py """ if input is not None and not isinstance(input, numbers.Number): raise TypeError( "Expected a scalar input but got input of type %s" % type(input)) if type(input) is float and math.isnan(input): ...
[ "def", "encodeIntoArray", "(", "self", ",", "input", ",", "output", ",", "learn", "=", "True", ")", ":", "if", "input", "is", "not", "None", "and", "not", "isinstance", "(", "input", ",", "numbers", ".", "Number", ")", ":", "raise", "TypeError", "(", ...
See method description in base.py
[ "See", "method", "description", "in", "base", ".", "py" ]
python
valid
33.625
google/google-visualization-python
gviz_api.py
https://github.com/google/google-visualization-python/blob/cbfb4d69ad2f4ca30dc55791629280aa3214c8e3/gviz_api.py#L593-L642
def _InnerAppendData(self, prev_col_values, data, col_index): """Inner function to assist LoadData.""" # We first check that col_index has not exceeded the columns size if col_index >= len(self.__columns): raise DataTableException("The data does not match description, too deep") # Dealing with th...
[ "def", "_InnerAppendData", "(", "self", ",", "prev_col_values", ",", "data", ",", "col_index", ")", ":", "# We first check that col_index has not exceeded the columns size", "if", "col_index", ">=", "len", "(", "self", ".", "__columns", ")", ":", "raise", "DataTableEx...
Inner function to assist LoadData.
[ "Inner", "function", "to", "assist", "LoadData", "." ]
python
train
44.78
jcrobak/parquet-python
parquet/encoding.py
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L110-L126
def read_rle(file_obj, header, bit_width, debug_logging): """Read a run-length encoded run from the given fo with the given header and bit_width. The count is determined from the header and the width is used to grab the value that's repeated. Yields the value repeated count times. """ count = heade...
[ "def", "read_rle", "(", "file_obj", ",", "header", ",", "bit_width", ",", "debug_logging", ")", ":", "count", "=", "header", ">>", "1", "zero_data", "=", "b\"\\x00\\x00\\x00\\x00\"", "width", "=", "(", "bit_width", "+", "7", ")", "//", "8", "data", "=", ...
Read a run-length encoded run from the given fo with the given header and bit_width. The count is determined from the header and the width is used to grab the value that's repeated. Yields the value repeated count times.
[ "Read", "a", "run", "-", "length", "encoded", "run", "from", "the", "given", "fo", "with", "the", "given", "header", "and", "bit_width", "." ]
python
train
40.411765
cocagne/txdbus
txdbus/objects.py
https://github.com/cocagne/txdbus/blob/eb424918764b7b93eecd2a4e2e5c2d0b2944407b/txdbus/objects.py#L740-L896
def handleMethodCallMessage(self, msg): """ Handles DBus MethodCall messages on behalf of the DBus Connection and dispatches them to the appropriate exported object """ if ( msg.interface == 'org.freedesktop.DBus.Peer' and msg.member == 'Ping' ): ...
[ "def", "handleMethodCallMessage", "(", "self", ",", "msg", ")", ":", "if", "(", "msg", ".", "interface", "==", "'org.freedesktop.DBus.Peer'", "and", "msg", ".", "member", "==", "'Ping'", ")", ":", "r", "=", "message", ".", "MethodReturnMessage", "(", "msg", ...
Handles DBus MethodCall messages on behalf of the DBus Connection and dispatches them to the appropriate exported object
[ "Handles", "DBus", "MethodCall", "messages", "on", "behalf", "of", "the", "DBus", "Connection", "and", "dispatches", "them", "to", "the", "appropriate", "exported", "object" ]
python
train
29.598726
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L99-L103
def getEditorBinary(self, cmdVersion=False): """ Determines the location of the UE4Editor binary """ return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', self.getPlatformIdentifier(), 'UE4Editor' + self._editorPathSuffix(cmdVersion))
[ "def", "getEditorBinary", "(", "self", ",", "cmdVersion", "=", "False", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "getEngineRoot", "(", ")", ",", "'Engine'", ",", "'Binaries'", ",", "self", ".", "getPlatformIdentifier", "(", "...
Determines the location of the UE4Editor binary
[ "Determines", "the", "location", "of", "the", "UE4Editor", "binary" ]
python
train
49.6
xtuml/pyxtuml
xtuml/meta.py
https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/xtuml/meta.py#L275-L292
def cardinality(self): ''' Obtain the cardinality string. Example: '1C' for a conditional link with a single instance [0..1] 'MC' for a link with any number of instances [0..*] 'M' for a more than one instance [1..*] 'M' for a link wi...
[ "def", "cardinality", "(", "self", ")", ":", "if", "self", ".", "many", ":", "s", "=", "'M'", "else", ":", "s", "=", "'1'", "if", "self", ".", "conditional", ":", "s", "+=", "'C'", "return", "s" ]
Obtain the cardinality string. Example: '1C' for a conditional link with a single instance [0..1] 'MC' for a link with any number of instances [0..*] 'M' for a more than one instance [1..*] 'M' for a link with exactly one instance [1]
[ "Obtain", "the", "cardinality", "string", ".", "Example", ":", "1C", "for", "a", "conditional", "link", "with", "a", "single", "instance", "[", "0", "..", "1", "]", "MC", "for", "a", "link", "with", "any", "number", "of", "instances", "[", "0", "..", ...
python
test
28.388889
hobson/pug-dj
pug/dj/db.py
https://github.com/hobson/pug-dj/blob/55678b08755a55366ce18e7d3b8ea8fa4491ab04/pug/dj/db.py#L1737-L1761
def dataframe_from_excel(path, sheetname=0, header=0, skiprows=None): # , parse_dates=False): """Thin wrapper for pandas.io.excel.read_excel() that accepts a file path and sheet index/name Arguments: path (str): file or folder to retrieve CSV files and `pandas.DataFrame`s from ext (str): file name...
[ "def", "dataframe_from_excel", "(", "path", ",", "sheetname", "=", "0", ",", "header", "=", "0", ",", "skiprows", "=", "None", ")", ":", "# , parse_dates=False):", "sheetname", "=", "sheetname", "or", "0", "if", "isinstance", "(", "sheetname", ",", "(", "b...
Thin wrapper for pandas.io.excel.read_excel() that accepts a file path and sheet index/name Arguments: path (str): file or folder to retrieve CSV files and `pandas.DataFrame`s from ext (str): file name extension (to filter files by) date_parser (function): if the MultiIndex can be interpretted as...
[ "Thin", "wrapper", "for", "pandas", ".", "io", ".", "excel", ".", "read_excel", "()", "that", "accepts", "a", "file", "path", "and", "sheet", "index", "/", "name" ]
python
train
47.36
geophysics-ubonn/crtomo_tools
src/td_correct_temperature.py
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L213-L232
def main(): """Function to add or substract the temperature effect to data in a tomodir """ options = handle_options() # read in temperature and resistivity data tempdata = readin_temp(options.temp_file) magdata = readin_rho(options.filename, options.rhofile, ...
[ "def", "main", "(", ")", ":", "options", "=", "handle_options", "(", ")", "# read in temperature and resistivity data", "tempdata", "=", "readin_temp", "(", "options", ".", "temp_file", ")", "magdata", "=", "readin_rho", "(", "options", ".", "filename", ",", "op...
Function to add or substract the temperature effect to data in a tomodir
[ "Function", "to", "add", "or", "substract", "the", "temperature", "effect", "to", "data", "in", "a", "tomodir" ]
python
train
36.2
log2timeline/dfvfs
dfvfs/helpers/file_system_searcher.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/helpers/file_system_searcher.py#L188-L199
def _CheckIsLink(self, file_entry): """Checks the is_link find specification. Args: file_entry (FileEntry): file entry. Returns: bool: True if the file entry matches the find specification, False if not. """ if definitions.FILE_ENTRY_TYPE_LINK not in self._file_entry_types: retur...
[ "def", "_CheckIsLink", "(", "self", ",", "file_entry", ")", ":", "if", "definitions", ".", "FILE_ENTRY_TYPE_LINK", "not", "in", "self", ".", "_file_entry_types", ":", "return", "False", "return", "file_entry", ".", "IsLink", "(", ")" ]
Checks the is_link find specification. Args: file_entry (FileEntry): file entry. Returns: bool: True if the file entry matches the find specification, False if not.
[ "Checks", "the", "is_link", "find", "specification", "." ]
python
train
28.916667
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L236-L240
def remove(self): """ Remove the directory. """ lib.gp_camera_folder_remove_dir( self._cam._cam, self.parent.path.encode(), self.name.encode(), self._cam._ctx)
[ "def", "remove", "(", "self", ")", ":", "lib", ".", "gp_camera_folder_remove_dir", "(", "self", ".", "_cam", ".", "_cam", ",", "self", ".", "parent", ".", "path", ".", "encode", "(", ")", ",", "self", ".", "name", ".", "encode", "(", ")", ",", "sel...
Remove the directory.
[ "Remove", "the", "directory", "." ]
python
train
39
pyros-dev/pyzmp
pyzmp/coprocess.py
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/pyzmp/coprocess.py#L377-L429
def eventloop(self, *args, **kwargs): """ Hand crafted event loop, with only one event possible : exit More events ( and signals ) can be added later, after converting to asyncio. """ # Setting status status = None # Starting the clock start = time.time(...
[ "def", "eventloop", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Setting status", "status", "=", "None", "# Starting the clock", "start", "=", "time", ".", "time", "(", ")", "first_loop", "=", "True", "# loop running target, maybe more ...
Hand crafted event loop, with only one event possible : exit More events ( and signals ) can be added later, after converting to asyncio.
[ "Hand", "crafted", "event", "loop", "with", "only", "one", "event", "possible", ":", "exit", "More", "events", "(", "and", "signals", ")", "can", "be", "added", "later", "after", "converting", "to", "asyncio", "." ]
python
train
40.132075
bitesofcode/projexui
projexui/widgets/xchart/xchart.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchart.py#L245-L256
def axes(self): """ Returns all the axes that have been defined for this chart. :return [<projexui.widgets.xchart.XChartAxis>, ..] """ out = self._axes[:] if self._horizontalAxis: out.append(self._horizontalAxis) if self._vertical...
[ "def", "axes", "(", "self", ")", ":", "out", "=", "self", ".", "_axes", "[", ":", "]", "if", "self", ".", "_horizontalAxis", ":", "out", ".", "append", "(", "self", ".", "_horizontalAxis", ")", "if", "self", ".", "_verticalAxis", ":", "out", ".", "...
Returns all the axes that have been defined for this chart. :return [<projexui.widgets.xchart.XChartAxis>, ..]
[ "Returns", "all", "the", "axes", "that", "have", "been", "defined", "for", "this", "chart", ".", ":", "return", "[", "<projexui", ".", "widgets", ".", "xchart", ".", "XChartAxis", ">", "..", "]" ]
python
train
31.5
tensorflow/probability
tensorflow_probability/examples/latent_dirichlet_allocation_distributions.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/examples/latent_dirichlet_allocation_distributions.py#L225-L255
def make_prior(num_topics, initial_value): """Create the prior distribution. Args: num_topics: Number of topics. initial_value: The starting value for the prior parameters. Returns: prior: A `callable` that returns a `tf.distribution.Distribution` instance, the prior distribution. prior_...
[ "def", "make_prior", "(", "num_topics", ",", "initial_value", ")", ":", "def", "_softplus_inverse", "(", "x", ")", ":", "return", "np", ".", "log", "(", "np", ".", "expm1", "(", "x", ")", ")", "logit_concentration", "=", "tf", ".", "compat", ".", "v1",...
Create the prior distribution. Args: num_topics: Number of topics. initial_value: The starting value for the prior parameters. Returns: prior: A `callable` that returns a `tf.distribution.Distribution` instance, the prior distribution. prior_variables: A `list` of `Variable` objects, the t...
[ "Create", "the", "prior", "distribution", "." ]
python
test
30.129032
NYUCCL/psiTurk
psiturk/command_line.py
https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/command_line.py#L25-L37
def install_from_exchange(): ''' Install from experiment exchange. ''' parser = argparse.ArgumentParser( description='Download experiment from the psiturk.org experiment\ exchange (http://psiturk.org/ee).' ) parser.add_argument( 'exp_id', metavar='exp_id', type=str, help='the id ...
[ "def", "install_from_exchange", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Download experiment from the psiturk.org experiment\\\n exchange (http://psiturk.org/ee).'", ")", "parser", ".", "add_argument", "(", "'exp_id'", ...
Install from experiment exchange.
[ "Install", "from", "experiment", "exchange", "." ]
python
train
37.307692
cthoyt/ols-client
src/ols_client/client.py
https://github.com/cthoyt/ols-client/blob/8c6bb54888675652d25324184967392d00d128fc/src/ols_client/client.py#L67-L77
def get_term(self, ontology, iri): """Gets the data for a given term :param str ontology: The name of the ontology :param str iri: The IRI of a term :rtype: dict """ url = self.ontology_term_fmt.format(ontology, iri) response = requests.get(url) return r...
[ "def", "get_term", "(", "self", ",", "ontology", ",", "iri", ")", ":", "url", "=", "self", ".", "ontology_term_fmt", ".", "format", "(", "ontology", ",", "iri", ")", "response", "=", "requests", ".", "get", "(", "url", ")", "return", "response", ".", ...
Gets the data for a given term :param str ontology: The name of the ontology :param str iri: The IRI of a term :rtype: dict
[ "Gets", "the", "data", "for", "a", "given", "term" ]
python
test
29.454545
pmacosta/pexdoc
pexdoc/exh.py
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L150-L154
def _sorted_keys_items(dobj): """Return dictionary items sorted by key.""" keys = sorted(dobj.keys()) for key in keys: yield key, dobj[key]
[ "def", "_sorted_keys_items", "(", "dobj", ")", ":", "keys", "=", "sorted", "(", "dobj", ".", "keys", "(", ")", ")", "for", "key", "in", "keys", ":", "yield", "key", ",", "dobj", "[", "key", "]" ]
Return dictionary items sorted by key.
[ "Return", "dictionary", "items", "sorted", "by", "key", "." ]
python
train
31
ponty/eagexp
eagexp/airwires.py
https://github.com/ponty/eagexp/blob/1dd5108c1d8112cc87d1bda64fa6c2784ccf0ff2/eagexp/airwires.py#L27-L51
def airwires(board, showgui=0): 'search for airwires in eagle board' board = Path(board).expand().abspath() file_out = tempfile.NamedTemporaryFile(suffix='.txt', delete=0) file_out.close() ulp = ulp_templ.replace('FILE_NAME', file_out.name) file_ulp = tempfile.NamedTemporaryFile(suffix='.ulp'...
[ "def", "airwires", "(", "board", ",", "showgui", "=", "0", ")", ":", "board", "=", "Path", "(", "board", ")", ".", "expand", "(", ")", ".", "abspath", "(", ")", "file_out", "=", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "'.txt'", ","...
search for airwires in eagle board
[ "search", "for", "airwires", "in", "eagle", "board" ]
python
train
24.92
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_io.py
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_io.py#L75-L86
def to_latex(self, buf=None, upper_triangle=True, **kwargs): """Render a DataFrame to a tabular environment table. You can splice this into a LaTeX document. Requires ``\\usepackage{booktabs}``. Wrapper around the :meth:`pandas.DataFrame.to_latex` method. """ out = self....
[ "def", "to_latex", "(", "self", ",", "buf", "=", "None", ",", "upper_triangle", "=", "True", ",", "*", "*", "kwargs", ")", ":", "out", "=", "self", ".", "_sympy_formatter", "(", ")", "out", "=", "out", ".", "_abs_ref_formatter", "(", "format_as", "=", ...
Render a DataFrame to a tabular environment table. You can splice this into a LaTeX document. Requires ``\\usepackage{booktabs}``. Wrapper around the :meth:`pandas.DataFrame.to_latex` method.
[ "Render", "a", "DataFrame", "to", "a", "tabular", "environment", "table", "." ]
python
train
42.916667
OpenKMIP/PyKMIP
kmip/services/server/auth/utils.py
https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/services/server/auth/utils.py#L59-L75
def get_client_identity_from_certificate(certificate): """ Given an X.509 certificate, extract and return the client identity. """ client_ids = get_common_names_from_certificate(certificate) if len(client_ids) > 0: if len(client_ids) > 1: raise exceptions.PermissionDenied( ...
[ "def", "get_client_identity_from_certificate", "(", "certificate", ")", ":", "client_ids", "=", "get_common_names_from_certificate", "(", "certificate", ")", "if", "len", "(", "client_ids", ")", ">", "0", ":", "if", "len", "(", "client_ids", ")", ">", "1", ":", ...
Given an X.509 certificate, extract and return the client identity.
[ "Given", "an", "X", ".", "509", "certificate", "extract", "and", "return", "the", "client", "identity", "." ]
python
test
33.647059
crunchyroll/ef-open
efopen/ef_generate.py
https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_generate.py#L366-L392
def conditionally_inline_policies(role_name, sr_entry): """ If 'policies' key lists the filename prefixes of policies to bind to the role, load them from the expected path and inline them onto the role Args: role_name: name of the role to attach the policies to sr_entry: service registry entry """ s...
[ "def", "conditionally_inline_policies", "(", "role_name", ",", "sr_entry", ")", ":", "service_type", "=", "sr_entry", "[", "'type'", "]", "if", "not", "(", "service_type", "in", "SERVICE_TYPE_ROLE", "and", "\"policies\"", "in", "sr_entry", ")", ":", "print_if_verb...
If 'policies' key lists the filename prefixes of policies to bind to the role, load them from the expected path and inline them onto the role Args: role_name: name of the role to attach the policies to sr_entry: service registry entry
[ "If", "policies", "key", "lists", "the", "filename", "prefixes", "of", "policies", "to", "bind", "to", "the", "role", "load", "them", "from", "the", "expected", "path", "and", "inline", "them", "onto", "the", "role", "Args", ":", "role_name", ":", "name", ...
python
train
45.407407
lsbardel/python-stdnet
stdnet/odm/struct.py
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L630-L633
def difference_update(self, values): '''Remove an iterable of *values* from the set.''' d = self.value_pickler.dumps return self.cache.remove(tuple((d(v) for v in values)))
[ "def", "difference_update", "(", "self", ",", "values", ")", ":", "d", "=", "self", ".", "value_pickler", ".", "dumps", "return", "self", ".", "cache", ".", "remove", "(", "tuple", "(", "(", "d", "(", "v", ")", "for", "v", "in", "values", ")", ")",...
Remove an iterable of *values* from the set.
[ "Remove", "an", "iterable", "of", "*", "values", "*", "from", "the", "set", "." ]
python
train
49
postmanlabs/httpbin
httpbin/helpers.py
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L85-L106
def json_safe(string, content_type='application/octet-stream'): """Returns JSON-safe version of `string`. If `string` is a Unicode string or a valid UTF-8, it is returned unmodified, as it can safely be encoded to JSON string. If `string` contains raw/binary data, it is Base64-encoded, formatted and ...
[ "def", "json_safe", "(", "string", ",", "content_type", "=", "'application/octet-stream'", ")", ":", "try", ":", "string", "=", "string", ".", "decode", "(", "'utf-8'", ")", "json", ".", "dumps", "(", "string", ")", "return", "string", "except", "(", "Valu...
Returns JSON-safe version of `string`. If `string` is a Unicode string or a valid UTF-8, it is returned unmodified, as it can safely be encoded to JSON string. If `string` contains raw/binary data, it is Base64-encoded, formatted and returned according to "data" URL scheme (RFC2397). Since JSON is not...
[ "Returns", "JSON", "-", "safe", "version", "of", "string", "." ]
python
train
37
nion-software/nionswift
nion/swift/LineGraphCanvasItem.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/LineGraphCanvasItem.py#L869-L892
def size_to_content(self, get_font_metrics_fn): """ Size the canvas item to the proper width, the maximum of any label. """ new_sizing = self.copy_sizing() new_sizing.minimum_width = 0 new_sizing.maximum_width = 0 axes = self.__axes if axes and axes.is_valid: ...
[ "def", "size_to_content", "(", "self", ",", "get_font_metrics_fn", ")", ":", "new_sizing", "=", "self", ".", "copy_sizing", "(", ")", "new_sizing", ".", "minimum_width", "=", "0", "new_sizing", ".", "maximum_width", "=", "0", "axes", "=", "self", ".", "__axe...
Size the canvas item to the proper width, the maximum of any label.
[ "Size", "the", "canvas", "item", "to", "the", "proper", "width", "the", "maximum", "of", "any", "label", "." ]
python
train
40.416667
cloudbase/python-hnvclient
hnv/client.py
https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/client.py#L2983-L2994
def process_raw_data(cls, raw_data): """Create a new model using raw API response.""" properties = raw_data.get("properties", {}) bgp_peers = [] for raw_content in properties.get("bgpPeers", []): raw_content["parentResourceID"] = raw_data["resourceId"] raw_conten...
[ "def", "process_raw_data", "(", "cls", ",", "raw_data", ")", ":", "properties", "=", "raw_data", ".", "get", "(", "\"properties\"", ",", "{", "}", ")", "bgp_peers", "=", "[", "]", "for", "raw_content", "in", "properties", ".", "get", "(", "\"bgpPeers\"", ...
Create a new model using raw API response.
[ "Create", "a", "new", "model", "using", "raw", "API", "response", "." ]
python
train
45.083333
cmheisel/basecampreporting
src/basecampreporting/basecamp.py
https://github.com/cmheisel/basecampreporting/blob/88ecfc6e835608650ff6be23cbf2421d224c122b/src/basecampreporting/basecamp.py#L511-L521
def create_milestones(self, project_id, milestones): """ With this function you can create multiple milestones in a single request. See the "create" function for a description of the individual fields in the milestone. """ path = '/projects/%u/milestones/create' % project...
[ "def", "create_milestones", "(", "self", ",", "project_id", ",", "milestones", ")", ":", "path", "=", "'/projects/%u/milestones/create'", "%", "project_id", "req", "=", "ET", ".", "Element", "(", "'request'", ")", "for", "milestone", "in", "milestones", ":", "...
With this function you can create multiple milestones in a single request. See the "create" function for a description of the individual fields in the milestone.
[ "With", "this", "function", "you", "can", "create", "multiple", "milestones", "in", "a", "single", "request", ".", "See", "the", "create", "function", "for", "a", "description", "of", "the", "individual", "fields", "in", "the", "milestone", "." ]
python
train
44.545455
Chilipp/funcargparse
funcargparse/__init__.py
https://github.com/Chilipp/funcargparse/blob/398ce8e7fa5aa35c465215446bda151cf1ecf7ad/funcargparse/__init__.py#L892-L924
def parse_known2func(self, args=None, func=None): """Parse the command line arguments to the setup function This method parses the given command line arguments to the function used in the :meth:`setup_args` method to setup up this parser Parameters ---------- args: list...
[ "def", "parse_known2func", "(", "self", ",", "args", "=", "None", ",", "func", "=", "None", ")", ":", "ns", ",", "remainder", "=", "self", ".", "parse_known_args", "(", "args", ")", "kws", "=", "vars", "(", "ns", ")", "if", "func", "is", "None", ":...
Parse the command line arguments to the setup function This method parses the given command line arguments to the function used in the :meth:`setup_args` method to setup up this parser Parameters ---------- args: list The list of command line arguments func:...
[ "Parse", "the", "command", "line", "arguments", "to", "the", "setup", "function" ]
python
train
33.484848
maljovec/topopy
topopy/MorseSmaleComplex.py
https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MorseSmaleComplex.py#L354-L365
def get_sample_size(self, key=None): """ Returns the number of samples in the input data @ In, key, an optional 2-tuple specifying a min-max id pair used for determining which partition size should be returned. If not specified then the size of the entire data set...
[ "def", "get_sample_size", "(", "self", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "return", "len", "(", "self", ".", "Y", ")", "else", ":", "return", "len", "(", "self", ".", "get_partitions", "(", "self", ".", "persistence", ...
Returns the number of samples in the input data @ In, key, an optional 2-tuple specifying a min-max id pair used for determining which partition size should be returned. If not specified then the size of the entire data set will be returned. @ Out, an integer ...
[ "Returns", "the", "number", "of", "samples", "in", "the", "input", "data" ]
python
train
44.916667
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L2412-L2450
def Create(self, body, path, type, id, initial_headers, options=None): """Creates a Azure Cosmos resource and returns it. :param dict body: :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request ...
[ "def", "Create", "(", "self", ",", "body", ",", "path", ",", "type", ",", "id", ",", "initial_headers", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "{", "}", "initial_headers", "=", "initial_headers", "or"...
Creates a Azure Cosmos resource and returns it. :param dict body: :param str path: :param str type: :param str id: :param dict initial_headers: :param dict options: The request options for the request. :return: The created Azure Cosmos re...
[ "Creates", "a", "Azure", "Cosmos", "resource", "and", "returns", "it", "." ]
python
train
35.769231
renweizhukov/pytwis
pytwis/pytwis.py
https://github.com/renweizhukov/pytwis/blob/1bc45b038d7e5343824c520f89f644bbd6faab0a/pytwis/pytwis.py#L273-L352
def change_password(self, auth_secret, old_password, new_password): """Change the user password. Parameters ---------- auth_secret: str The authentication secret which will be used for user authentication. old_password: str The old password before the cha...
[ "def", "change_password", "(", "self", ",", "auth_secret", ",", "old_password", ",", "new_password", ")", ":", "result", "=", "{", "pytwis_constants", ".", "ERROR_KEY", ":", "None", "}", "if", "old_password", "==", "new_password", ":", "result", "[", "pytwis_c...
Change the user password. Parameters ---------- auth_secret: str The authentication secret which will be used for user authentication. old_password: str The old password before the change. new_password: str The new password after the change. ...
[ "Change", "the", "user", "password", "." ]
python
train
39.9125
Parisson/TimeSide
timeside/server/models.py
https://github.com/Parisson/TimeSide/blob/0618d75cd2f16021afcfd3d5b77f692adad76ea5/timeside/server/models.py#L192-L198
def get_audio_duration(self): """ Return item audio duration """ decoder = timeside.core.get_processor('file_decoder')( uri=self.get_uri()) return decoder.uri_total_duration
[ "def", "get_audio_duration", "(", "self", ")", ":", "decoder", "=", "timeside", ".", "core", ".", "get_processor", "(", "'file_decoder'", ")", "(", "uri", "=", "self", ".", "get_uri", "(", ")", ")", "return", "decoder", ".", "uri_total_duration" ]
Return item audio duration
[ "Return", "item", "audio", "duration" ]
python
train
31.285714
reportportal/client-Python
reportportal_client/service_async.py
https://github.com/reportportal/client-Python/blob/8d22445d0de73f46fb23d0c0e49ac309335173ce/reportportal_client/service_async.py#L108-L126
def stop(self, nowait=False): """Stop the listener. This asks the thread to terminate, and then waits for it to do so. Note that if you don't call this before your application exits, there may be some records still left on the queue, which won't be processed. If nowait is False ...
[ "def", "stop", "(", "self", ",", "nowait", "=", "False", ")", ":", "self", ".", "_stop", ".", "set", "(", ")", "if", "nowait", ":", "self", ".", "_stop_nowait", ".", "set", "(", ")", "self", ".", "queue", ".", "put_nowait", "(", "self", ".", "_se...
Stop the listener. This asks the thread to terminate, and then waits for it to do so. Note that if you don't call this before your application exits, there may be some records still left on the queue, which won't be processed. If nowait is False then thread will handle remaining items i...
[ "Stop", "the", "listener", "." ]
python
train
40.842105
Jaymon/pyt
pyt/__init__.py
https://github.com/Jaymon/pyt/blob/801581fd0ae238158134bde1c937fa199fa626b2/pyt/__init__.py#L43-L51
def is_single_class(): """Returns True if only a single class is being run or some tests within a single class""" ret = False counts = get_counts() if counts["classes"] < 1 and counts["modules"] < 1: ret = counts["tests"] > 0 else: ret = counts["classes"] <= 1 and counts["modules"] <...
[ "def", "is_single_class", "(", ")", ":", "ret", "=", "False", "counts", "=", "get_counts", "(", ")", "if", "counts", "[", "\"classes\"", "]", "<", "1", "and", "counts", "[", "\"modules\"", "]", "<", "1", ":", "ret", "=", "counts", "[", "\"tests\"", "...
Returns True if only a single class is being run or some tests within a single class
[ "Returns", "True", "if", "only", "a", "single", "class", "is", "being", "run", "or", "some", "tests", "within", "a", "single", "class" ]
python
test
36.666667
niemasd/TreeSwift
treeswift/Tree.py
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L299-L337
def distance_matrix(self, leaf_labels=False): '''Return a distance matrix (2D dictionary) of the leaves of this ``Tree`` Args: ``leaf_labels`` (``bool``): ``True`` to have keys be labels of leaf ``Node`` objects, otherwise ``False`` to have keys be ``Node`` objects Returns: ...
[ "def", "distance_matrix", "(", "self", ",", "leaf_labels", "=", "False", ")", ":", "M", "=", "dict", "(", ")", "leaf_dists", "=", "dict", "(", ")", "for", "node", "in", "self", ".", "traverse_postorder", "(", ")", ":", "if", "node", ".", "is_leaf", "...
Return a distance matrix (2D dictionary) of the leaves of this ``Tree`` Args: ``leaf_labels`` (``bool``): ``True`` to have keys be labels of leaf ``Node`` objects, otherwise ``False`` to have keys be ``Node`` objects Returns: ``dict``: Distance matrix (2D dictionary) of the lea...
[ "Return", "a", "distance", "matrix", "(", "2D", "dictionary", ")", "of", "the", "leaves", "of", "this", "Tree" ]
python
train
53.589744
totalgood/pugnlp
src/pugnlp/util.py
https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/util.py#L2031-L2061
def string_stats(strs, valid_chars='012346789', left_pad='0', right_pad='', strip=True): """ Count the occurrence of a category of valid characters within an iterable of serial/model no, etc """ if left_pad is None: left_pad = ''.join(c for c in rex.ASCII_CHARACTERS if c not in valid_chars) if right...
[ "def", "string_stats", "(", "strs", ",", "valid_chars", "=", "'012346789'", ",", "left_pad", "=", "'0'", ",", "right_pad", "=", "''", ",", "strip", "=", "True", ")", ":", "if", "left_pad", "is", "None", ":", "left_pad", "=", "''", ".", "join", "(", "...
Count the occurrence of a category of valid characters within an iterable of serial/model no, etc
[ "Count", "the", "occurrence", "of", "a", "category", "of", "valid", "characters", "within", "an", "iterable", "of", "serial", "/", "model", "no", "etc" ]
python
train
39.193548
RudolfCardinal/pythonlib
cardinal_pythonlib/django/admin.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/admin.py#L43-L67
def disable_bool_icon( fieldname: str, model) -> Callable[[Any], bool]: """ Disable boolean icons for a Django ModelAdmin field. The '_meta' attribute is present on Django model classes and instances. model_class: ``Union[Model, Type[Model]]`` ... only the type checker in Py3.5 is ...
[ "def", "disable_bool_icon", "(", "fieldname", ":", "str", ",", "model", ")", "->", "Callable", "[", "[", "Any", "]", ",", "bool", "]", ":", "# noinspection PyUnusedLocal", "def", "func", "(", "self", ",", "obj", ")", ":", "return", "getattr", "(", "obj",...
Disable boolean icons for a Django ModelAdmin field. The '_meta' attribute is present on Django model classes and instances. model_class: ``Union[Model, Type[Model]]`` ... only the type checker in Py3.5 is broken; see ``files.py``
[ "Disable", "boolean", "icons", "for", "a", "Django", "ModelAdmin", "field", ".", "The", "_meta", "attribute", "is", "present", "on", "Django", "model", "classes", "and", "instances", "." ]
python
train
35.36
atztogo/phonopy
phonopy/structure/tetrahedron_method.py
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/tetrahedron_method.py#L69-L85
def get_tetrahedra_relative_grid_address(microzone_lattice): """Returns relative (differences of) grid addresses from the central Parameter --------- microzone_lattice : ndarray or list of list column vectors of parallel piped microzone lattice, i.e., microzone_lattice = np.linalg.inv(c...
[ "def", "get_tetrahedra_relative_grid_address", "(", "microzone_lattice", ")", ":", "relative_grid_address", "=", "np", ".", "zeros", "(", "(", "24", ",", "4", ",", "3", ")", ",", "dtype", "=", "'intc'", ")", "phonoc", ".", "tetrahedra_relative_grid_address", "("...
Returns relative (differences of) grid addresses from the central Parameter --------- microzone_lattice : ndarray or list of list column vectors of parallel piped microzone lattice, i.e., microzone_lattice = np.linalg.inv(cell.get_cell()) / mesh
[ "Returns", "relative", "(", "differences", "of", ")", "grid", "addresses", "from", "the", "central" ]
python
train
33.705882
todbot/blink1-python
blink1/blink1.py
https://github.com/todbot/blink1-python/blob/7a5183becd9662f88da3c29afd3447403f4ef82f/blink1/blink1.py#L222-L227
def stop(self): """Stop internal color pattern playing """ if ( self.dev == None ): return '' buf = [REPORT_ID, ord('p'), 0, 0, 0, 0, 0, 0, 0] return self.write(buf);
[ "def", "stop", "(", "self", ")", ":", "if", "(", "self", ".", "dev", "==", "None", ")", ":", "return", "''", "buf", "=", "[", "REPORT_ID", ",", "ord", "(", "'p'", ")", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ...
Stop internal color pattern playing
[ "Stop", "internal", "color", "pattern", "playing" ]
python
train
33.5
deanmalmgren/textract
textract/parsers/html_parser.py
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/html_parser.py#L88-L116
def _replace_tables(self, soup, v_separator=' | ', h_separator='-'): """Replaces <table> elements with its ASCII equivalent. """ tables = self._parse_tables(soup) v_sep_len = len(v_separator) v_left_sep = v_separator.lstrip() for t in tables: html = '' ...
[ "def", "_replace_tables", "(", "self", ",", "soup", ",", "v_separator", "=", "' | '", ",", "h_separator", "=", "'-'", ")", ":", "tables", "=", "self", ".", "_parse_tables", "(", "soup", ")", "v_sep_len", "=", "len", "(", "v_separator", ")", "v_left_sep", ...
Replaces <table> elements with its ASCII equivalent.
[ "Replaces", "<table", ">", "elements", "with", "its", "ASCII", "equivalent", "." ]
python
train
42.655172
physacco/reverse
reverse.py
https://github.com/physacco/reverse/blob/bb900e4831a3e33745d15265fbbbb2502397ebfd/reverse.py#L74-L80
def reverse_file(infile, outfile): '''Reverse the content of infile, write to outfile. Both infile and outfile are filenames or filepaths. ''' with open(infile, 'rb') as inf: with open(outfile, 'wb') as outf: reverse_fd(inf, outf)
[ "def", "reverse_file", "(", "infile", ",", "outfile", ")", ":", "with", "open", "(", "infile", ",", "'rb'", ")", "as", "inf", ":", "with", "open", "(", "outfile", ",", "'wb'", ")", "as", "outf", ":", "reverse_fd", "(", "inf", ",", "outf", ")" ]
Reverse the content of infile, write to outfile. Both infile and outfile are filenames or filepaths.
[ "Reverse", "the", "content", "of", "infile", "write", "to", "outfile", ".", "Both", "infile", "and", "outfile", "are", "filenames", "or", "filepaths", "." ]
python
train
37.142857
UCL-INGI/INGInious
inginious/frontend/pages/tasks.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/tasks.py#L291-L374
def submission_to_json(self, task, data, debug, reloading=False, replace=False, tags={}): """ Converts a submission to json (keeps only needed fields) """ if "ssh_host" in data: return json.dumps({'status': "waiting", 'text': "<b>SSH server active</b>", 'ssh_h...
[ "def", "submission_to_json", "(", "self", ",", "task", ",", "data", ",", "debug", ",", "reloading", "=", "False", ",", "replace", "=", "False", ",", "tags", "=", "{", "}", ")", ":", "if", "\"ssh_host\"", "in", "data", ":", "return", "json", ".", "dum...
Converts a submission to json (keeps only needed fields)
[ "Converts", "a", "submission", "to", "json", "(", "keeps", "only", "needed", "fields", ")" ]
python
train
53.559524
paylogic/pip-accel
pip_accel/__init__.py
https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/__init__.py#L215-L251
def install_from_arguments(self, arguments, **kw): """ Download, unpack, build and install the specified requirements. This function is a simple wrapper for :func:`get_requirements()`, :func:`install_requirements()` and :func:`cleanup_temporary_directories()` that implements the...
[ "def", "install_from_arguments", "(", "self", ",", "arguments", ",", "*", "*", "kw", ")", ":", "try", ":", "requirements", "=", "self", ".", "get_requirements", "(", "arguments", ",", "use_wheels", "=", "self", ".", "arguments_allow_wheels", "(", "arguments", ...
Download, unpack, build and install the specified requirements. This function is a simple wrapper for :func:`get_requirements()`, :func:`install_requirements()` and :func:`cleanup_temporary_directories()` that implements the default behavior of the pip accelerator. If you're extending o...
[ "Download", "unpack", "build", "and", "install", "the", "specified", "requirements", "." ]
python
train
52.189189
bcbio/bcbio-nextgen
bcbio/pipeline/variation.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/variation.py#L140-L152
def _symlink_to_workdir(data, key): """For CWL support, symlink files into a working directory if in read-only imports. """ orig_file = tz.get_in(key, data) if orig_file and not orig_file.startswith(dd.get_work_dir(data)): variantcaller = genotype.get_variantcaller(data, require_bam=False) ...
[ "def", "_symlink_to_workdir", "(", "data", ",", "key", ")", ":", "orig_file", "=", "tz", ".", "get_in", "(", "key", ",", "data", ")", "if", "orig_file", "and", "not", "orig_file", ".", "startswith", "(", "dd", ".", "get_work_dir", "(", "data", ")", ")"...
For CWL support, symlink files into a working directory if in read-only imports.
[ "For", "CWL", "support", "symlink", "files", "into", "a", "working", "directory", "if", "in", "read", "-", "only", "imports", "." ]
python
train
49.846154
saltstack/salt
salt/engines/logentries.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/logentries.py#L174-L215
def start(endpoint='data.logentries.com', port=10000, token=None, tag='salt/engines/logentries'): ''' Listen to salt events and forward them to Logentries ''' if __opts__.get('id').endswith('_master'): event_bus = salt.utils.event.get_master_event( __opt...
[ "def", "start", "(", "endpoint", "=", "'data.logentries.com'", ",", "port", "=", "10000", ",", "token", "=", "None", ",", "tag", "=", "'salt/engines/logentries'", ")", ":", "if", "__opts__", ".", "get", "(", "'id'", ")", ".", "endswith", "(", "'_master'", ...
Listen to salt events and forward them to Logentries
[ "Listen", "to", "salt", "events", "and", "forward", "them", "to", "Logentries" ]
python
train
30.428571
gabstopper/smc-python
smc/api/session.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/api/session.py#L621-L646
def switch_domain(self, domain): """ Switch from one domain to another. You can call session.login() with a domain key value to log directly into the domain of choice or alternatively switch from domain to domain. The user must have permissions to the domain or unauthorized will ...
[ "def", "switch_domain", "(", "self", ",", "domain", ")", ":", "if", "self", ".", "domain", "!=", "domain", ":", "if", "self", "in", "self", ".", "manager", ":", "# Exit current domain", "self", ".", "logout", "(", ")", "logger", ".", "info", "(", "'Swi...
Switch from one domain to another. You can call session.login() with a domain key value to log directly into the domain of choice or alternatively switch from domain to domain. The user must have permissions to the domain or unauthorized will be returned. In addition, when switching domains, you...
[ "Switch", "from", "one", "domain", "to", "another", ".", "You", "can", "call", "session", ".", "login", "()", "with", "a", "domain", "key", "value", "to", "log", "directly", "into", "the", "domain", "of", "choice", "or", "alternatively", "switch", "from", ...
python
train
46.807692
10gen/mongo-orchestration
mongo_orchestration/replica_sets.py
https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L606-L613
def restart(self, timeout=300, config_callback=None): """Restart each member of the replica set.""" for member_id in self.server_map: host = self.server_map[member_id] server_id = self._servers.host_to_server_id(host) server = self._servers._storage[server_id] ...
[ "def", "restart", "(", "self", ",", "timeout", "=", "300", ",", "config_callback", "=", "None", ")", ":", "for", "member_id", "in", "self", ".", "server_map", ":", "host", "=", "self", ".", "server_map", "[", "member_id", "]", "server_id", "=", "self", ...
Restart each member of the replica set.
[ "Restart", "each", "member", "of", "the", "replica", "set", "." ]
python
train
49.25
pilosus/ForgeryPy3
forgery_py/forgery/internet.py
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/internet.py#L72-L85
def email_address(user=None): """Return random e-mail address in a hopefully imaginary domain. If `user` is ``None`` :py:func:`~user_name()` will be used. Otherwise it will be lowercased and will have spaces replaced with ``_``. Domain name is created using :py:func:`~domain_name()`. """ if no...
[ "def", "email_address", "(", "user", "=", "None", ")", ":", "if", "not", "user", ":", "user", "=", "user_name", "(", ")", "else", ":", "user", "=", "user", ".", "strip", "(", ")", ".", "replace", "(", "' '", ",", "'_'", ")", ".", "lower", "(", ...
Return random e-mail address in a hopefully imaginary domain. If `user` is ``None`` :py:func:`~user_name()` will be used. Otherwise it will be lowercased and will have spaces replaced with ``_``. Domain name is created using :py:func:`~domain_name()`.
[ "Return", "random", "e", "-", "mail", "address", "in", "a", "hopefully", "imaginary", "domain", "." ]
python
valid
31.714286
saltstack/salt
salt/modules/kmod.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kmod.py#L99-L113
def _remove_persistent_module(mod, comment): ''' Remove module from configuration file. If comment is true only comment line where module is. ''' conf = _get_modules_conf() mod_name = _strip_module_name(mod) if not mod_name or mod_name not in mod_list(True): return set() escape_m...
[ "def", "_remove_persistent_module", "(", "mod", ",", "comment", ")", ":", "conf", "=", "_get_modules_conf", "(", ")", "mod_name", "=", "_strip_module_name", "(", "mod", ")", "if", "not", "mod_name", "or", "mod_name", "not", "in", "mod_list", "(", "True", ")"...
Remove module from configuration file. If comment is true only comment line where module is.
[ "Remove", "module", "from", "configuration", "file", ".", "If", "comment", "is", "true", "only", "comment", "line", "where", "module", "is", "." ]
python
train
35.6
yjzhang/uncurl_python
uncurl/run_se.py
https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/run_se.py#L11-L64
def run_state_estimation(data, clusters, dist='Poiss', reps=1, **kwargs): """ Runs state estimation for multiple initializations, returning the result with the highest log-likelihood. All the arguments are passed to the underlying state estimation functions (poisson_estimate_state, nb_estimate_state, zip_estima...
[ "def", "run_state_estimation", "(", "data", ",", "clusters", ",", "dist", "=", "'Poiss'", ",", "reps", "=", "1", ",", "*", "*", "kwargs", ")", ":", "clusters", "=", "int", "(", "clusters", ")", "func", "=", "poisson_estimate_state", "dist", "=", "dist", ...
Runs state estimation for multiple initializations, returning the result with the highest log-likelihood. All the arguments are passed to the underlying state estimation functions (poisson_estimate_state, nb_estimate_state, zip_estimate_state). Args: data (array): genes x cells clusters (int): numb...
[ "Runs", "state", "estimation", "for", "multiple", "initializations", "returning", "the", "result", "with", "the", "highest", "log", "-", "likelihood", ".", "All", "the", "arguments", "are", "passed", "to", "the", "underlying", "state", "estimation", "functions", ...
python
train
42.333333
GNS3/gns3-server
gns3server/compute/iou/iou_vm.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L447-L477
def _push_configs_to_nvram(self): """ Push the startup-config and private-config content to the NVRAM. """ startup_config_content = self.startup_config_content if startup_config_content: nvram_file = self._nvram_file() try: if not os.path....
[ "def", "_push_configs_to_nvram", "(", "self", ")", ":", "startup_config_content", "=", "self", ".", "startup_config_content", "if", "startup_config_content", ":", "nvram_file", "=", "self", ".", "_nvram_file", "(", ")", "try", ":", "if", "not", "os", ".", "path"...
Push the startup-config and private-config content to the NVRAM.
[ "Push", "the", "startup", "-", "config", "and", "private", "-", "config", "content", "to", "the", "NVRAM", "." ]
python
train
45.935484
numenta/nupic
src/nupic/database/client_jobs_dao.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/client_jobs_dao.py#L647-L925
def _initTables(self, cursor, deleteOldVersions, recreate): """ Initialize tables, if needed Parameters: ---------------------------------------------------------------- cursor: SQL cursor deleteOldVersions: if true, delete any old versions of the DB left on...
[ "def", "_initTables", "(", "self", ",", "cursor", ",", "deleteOldVersions", ",", "recreate", ")", ":", "# Delete old versions if they exist", "if", "deleteOldVersions", ":", "self", ".", "_logger", ".", "info", "(", "\"Dropping old versions of client_jobs DB; called from:...
Initialize tables, if needed Parameters: ---------------------------------------------------------------- cursor: SQL cursor deleteOldVersions: if true, delete any old versions of the DB left on the server recreate: if true, recreate the database ...
[ "Initialize", "tables", "if", "needed" ]
python
valid
48.827957
pypa/pipenv
pipenv/vendor/jinja2/nodes.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/nodes.py#L208-L217
def set_lineno(self, lineno, override=False): """Set the line numbers of the node and children.""" todo = deque([self]) while todo: node = todo.popleft() if 'lineno' in node.attributes: if node.lineno is None or override: node.lineno = ...
[ "def", "set_lineno", "(", "self", ",", "lineno", ",", "override", "=", "False", ")", ":", "todo", "=", "deque", "(", "[", "self", "]", ")", "while", "todo", ":", "node", "=", "todo", ".", "popleft", "(", ")", "if", "'lineno'", "in", "node", ".", ...
Set the line numbers of the node and children.
[ "Set", "the", "line", "numbers", "of", "the", "node", "and", "children", "." ]
python
train
38.6
djtaylor/python-lsbinit
lsbinit/pid.py
https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/pid.py#L86-L106
def age(self): """ Get the age of the PID file. """ # Created timestamp created = self.created() # Age in seconds / minutes / hours / days age_secs = time() - created age_mins = 0 if (age_secs < 60) else (age_secs / 60) age_hour...
[ "def", "age", "(", "self", ")", ":", "# Created timestamp", "created", "=", "self", ".", "created", "(", ")", "# Age in seconds / minutes / hours / days", "age_secs", "=", "time", "(", ")", "-", "created", "age_mins", "=", "0", "if", "(", "age_secs", "<", "6...
Get the age of the PID file.
[ "Get", "the", "age", "of", "the", "PID", "file", "." ]
python
train
28.142857
poppy-project/pypot
pypot/utils/interpolation.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/utils/interpolation.py#L50-L63
def nearest_keys(self, key): """Find the nearest_keys (l2 distance) thanks to a cKDTree query""" if not isinstance(key, tuple): _key = (key,) if self.__stale: self.generate_tree() d, idx = self.__tree.query( _key, self.k_neighbors, distance_upper_bound...
[ "def", "nearest_keys", "(", "self", ",", "key", ")", ":", "if", "not", "isinstance", "(", "key", ",", "tuple", ")", ":", "_key", "=", "(", "key", ",", ")", "if", "self", ".", "__stale", ":", "self", ".", "generate_tree", "(", ")", "d", ",", "idx"...
Find the nearest_keys (l2 distance) thanks to a cKDTree query
[ "Find", "the", "nearest_keys", "(", "l2", "distance", ")", "thanks", "to", "a", "cKDTree", "query" ]
python
train
39.357143
sorgerlab/indra
indra/tools/reading/submit_reading_pipeline.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L309-L335
def tag_instances_on_cluster(cluster_name, project='cwc'): """Adds project tag to untagged instances in a given cluster. Parameters ---------- cluster_name : str The name of the AWS ECS cluster in which running instances should be tagged. project : str The name of the projec...
[ "def", "tag_instances_on_cluster", "(", "cluster_name", ",", "project", "=", "'cwc'", ")", ":", "# Get the relevant instance ids from the ecs cluster", "ecs", "=", "boto3", ".", "client", "(", "'ecs'", ")", "task_arns", "=", "ecs", ".", "list_tasks", "(", "cluster",...
Adds project tag to untagged instances in a given cluster. Parameters ---------- cluster_name : str The name of the AWS ECS cluster in which running instances should be tagged. project : str The name of the project to tag instances with.
[ "Adds", "project", "tag", "to", "untagged", "instances", "in", "a", "given", "cluster", "." ]
python
train
38.777778