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
IBMStreams/pypi.streamsx
streamsx/rest.py
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L309-L342
def _get_vcap_services(vcap_services=None): """Retrieves the VCAP Services information from the `ConfigParams.VCAP_SERVICES` field in the config object. If `vcap_services` is not specified, it takes the information from VCAP_SERVICES environment variable. Args: vcap_services (str): Try to parse as ...
[ "def", "_get_vcap_services", "(", "vcap_services", "=", "None", ")", ":", "vcap_services", "=", "vcap_services", "or", "os", ".", "environ", ".", "get", "(", "'VCAP_SERVICES'", ")", "if", "not", "vcap_services", ":", "raise", "ValueError", "(", "\"VCAP_SERVICES ...
Retrieves the VCAP Services information from the `ConfigParams.VCAP_SERVICES` field in the config object. If `vcap_services` is not specified, it takes the information from VCAP_SERVICES environment variable. Args: vcap_services (str): Try to parse as a JSON string, otherwise, try open it as a file. ...
[ "Retrieves", "the", "VCAP", "Services", "information", "from", "the", "ConfigParams", ".", "VCAP_SERVICES", "field", "in", "the", "config", "object", ".", "If", "vcap_services", "is", "not", "specified", "it", "takes", "the", "information", "from", "VCAP_SERVICES"...
python
train
46.058824
thomasvandoren/bugzscout-py
bugzscout/ext/cli.py
https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/bugzscout/ext/cli.py#L63-L94
def _parse_args(): """Parse and return command line arguments.""" parser = argparse.ArgumentParser( description=__doc__, formatter_class=_CliFormatter) parser.add_argument('-v', '--verbose', action='store_true', help='Enable verbose output.') fb_group = parser.ad...
[ "def", "_parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "__doc__", ",", "formatter_class", "=", "_CliFormatter", ")", "parser", ".", "add_argument", "(", "'-v'", ",", "'--verbose'", ",", "action", "=", ...
Parse and return command line arguments.
[ "Parse", "and", "return", "command", "line", "arguments", "." ]
python
train
41.78125
angr/claripy
claripy/vsa/discrete_strided_interval_set.py
https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/vsa/discrete_strided_interval_set.py#L536-L552
def _union_with_dsis(self, dsis): """ Union with another DiscreteStridedIntervalSet. :param dsis: :return: """ copied = self.copy() for a in dsis._si_set: copied = copied.union(a) if isinstance(copied, DiscreteStridedIntervalSet): ...
[ "def", "_union_with_dsis", "(", "self", ",", "dsis", ")", ":", "copied", "=", "self", ".", "copy", "(", ")", "for", "a", "in", "dsis", ".", "_si_set", ":", "copied", "=", "copied", ".", "union", "(", "a", ")", "if", "isinstance", "(", "copied", ","...
Union with another DiscreteStridedIntervalSet. :param dsis: :return:
[ "Union", "with", "another", "DiscreteStridedIntervalSet", "." ]
python
train
21.705882
MaxStrange/AudioSegment
audiosegment.py
https://github.com/MaxStrange/AudioSegment/blob/1daefb8de626ddff3ff7016697c3ad31d262ecd6/audiosegment.py#L1142-L1151
def silent(duration=1000, frame_rate=11025): """ Creates an AudioSegment object of the specified duration/frame_rate filled with digital silence. :param duration: The duration of the returned object in ms. :param frame_rate: The samples per second of the returned object. :returns: AudioSegment obje...
[ "def", "silent", "(", "duration", "=", "1000", ",", "frame_rate", "=", "11025", ")", ":", "seg", "=", "pydub", ".", "AudioSegment", ".", "silent", "(", "duration", "=", "duration", ",", "frame_rate", "=", "frame_rate", ")", "return", "AudioSegment", "(", ...
Creates an AudioSegment object of the specified duration/frame_rate filled with digital silence. :param duration: The duration of the returned object in ms. :param frame_rate: The samples per second of the returned object. :returns: AudioSegment object filled with pure digital silence.
[ "Creates", "an", "AudioSegment", "object", "of", "the", "specified", "duration", "/", "frame_rate", "filled", "with", "digital", "silence", "." ]
python
test
46.6
alfred82santa/dirty-models
dirty_models/model_types.py
https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/model_types.py#L395-L426
def get_attrs_by_path(self, field_path, stop_first=False): """ It returns list of values looked up by field path. Field path is dot-formatted string path: ``parent_field.child_field``. :param field_path: field path. It allows ``*`` as wildcard. :type field_path: list or None. ...
[ "def", "get_attrs_by_path", "(", "self", ",", "field_path", ",", "stop_first", "=", "False", ")", ":", "index_list", ",", "next_field", "=", "self", ".", "_get_indexes_by_path", "(", "field_path", ")", "values", "=", "[", "]", "for", "idx", "in", "index_list...
It returns list of values looked up by field path. Field path is dot-formatted string path: ``parent_field.child_field``. :param field_path: field path. It allows ``*`` as wildcard. :type field_path: list or None. :param stop_first: Stop iteration on first value looked up. Default: Fals...
[ "It", "returns", "list", "of", "values", "looked", "up", "by", "field", "path", ".", "Field", "path", "is", "dot", "-", "formatted", "string", "path", ":", "parent_field", ".", "child_field", "." ]
python
train
35.28125
keon/algorithms
algorithms/arrays/three_sum.py
https://github.com/keon/algorithms/blob/4d6569464a62a75c1357acc97e2dd32ee2f9f4a3/algorithms/arrays/three_sum.py#L18-L48
def three_sum(array): """ :param array: List[int] :return: Set[ Tuple[int, int, int] ] """ res = set() array.sort() for i in range(len(array) - 2): if i > 0 and array[i] == array[i - 1]: continue l, r = i + 1, len(array) - 1 while l < r: s = ar...
[ "def", "three_sum", "(", "array", ")", ":", "res", "=", "set", "(", ")", "array", ".", "sort", "(", ")", "for", "i", "in", "range", "(", "len", "(", "array", ")", "-", "2", ")", ":", "if", "i", ">", "0", "and", "array", "[", "i", "]", "==",...
:param array: List[int] :return: Set[ Tuple[int, int, int] ]
[ ":", "param", "array", ":", "List", "[", "int", "]", ":", "return", ":", "Set", "[", "Tuple", "[", "int", "int", "int", "]", "]" ]
python
train
25.419355
Tanganelli/CoAPthon3
coapthon/caching/cache.py
https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/caching/cache.py#L89-L113
def search_response(self, request): """ creates a key from the request and searches the cache with it :param request: :return CacheElement: returns None if there's a cache miss """ logger.debug("Cache Search Response") if self.cache.is_empty() is True: ...
[ "def", "search_response", "(", "self", ",", "request", ")", ":", "logger", ".", "debug", "(", "\"Cache Search Response\"", ")", "if", "self", ".", "cache", ".", "is_empty", "(", ")", "is", "True", ":", "logger", ".", "debug", "(", "\"Empty Cache\"", ")", ...
creates a key from the request and searches the cache with it :param request: :return CacheElement: returns None if there's a cache miss
[ "creates", "a", "key", "from", "the", "request", "and", "searches", "the", "cache", "with", "it" ]
python
train
26
vertexproject/synapse
synapse/lib/certdir.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/certdir.py#L729-L745
def isUserCert(self, name): ''' Checks if a user certificate exists. Args: name (str): The name of the user keypair. Examples: Check if the user cert "myuser" exists: exists = cdir.isUserCert('myuser') Returns: bool: True if...
[ "def", "isUserCert", "(", "self", ",", "name", ")", ":", "crtpath", "=", "self", ".", "_getPathJoin", "(", "'users'", ",", "'%s.crt'", "%", "name", ")", "return", "os", ".", "path", ".", "isfile", "(", "crtpath", ")" ]
Checks if a user certificate exists. Args: name (str): The name of the user keypair. Examples: Check if the user cert "myuser" exists: exists = cdir.isUserCert('myuser') Returns: bool: True if the certificate is present, False otherwise.
[ "Checks", "if", "a", "user", "certificate", "exists", "." ]
python
train
27.176471
SwoopSearch/pyaddress
address/address.py
https://github.com/SwoopSearch/pyaddress/blob/62ebb07a6840e710d256406a8ec1d06abec0e1c4/address/address.py#L348-L375
def check_apartment_number(self, token): """ Finds apartment, unit, #, etc, regardless of spot in string. This needs to come after everything else has been ruled out, because it has a lot of false positives. """ apartment_regexes = [r'#\w+ & \w+', '#\w+ rm \w+', "#\w+-\w", r'apt ...
[ "def", "check_apartment_number", "(", "self", ",", "token", ")", ":", "apartment_regexes", "=", "[", "r'#\\w+ & \\w+'", ",", "'#\\w+ rm \\w+'", ",", "\"#\\w+-\\w\"", ",", "r'apt #{0,1}\\w+'", ",", "r'apartment #{0,1}\\w+'", ",", "r'#\\w+'", ",", "r'# \\w+'", ",", "r...
Finds apartment, unit, #, etc, regardless of spot in string. This needs to come after everything else has been ruled out, because it has a lot of false positives.
[ "Finds", "apartment", "unit", "#", "etc", "regardless", "of", "spot", "in", "string", ".", "This", "needs", "to", "come", "after", "everything", "else", "has", "been", "ruled", "out", "because", "it", "has", "a", "lot", "of", "false", "positives", "." ]
python
train
56.214286
tensorflow/tensor2tensor
tensor2tensor/layers/modalities.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L552-L566
def video_bitwise_bottom(x, model_hparams, vocab_size): """Bottom transformation for embedding video bitwise.""" pixel_embedding_size = 64 inputs = x with tf.variable_scope("video_modality_bitwise", reuse=tf.AUTO_REUSE): common_layers.summarize_video(inputs, "bottom") # Embed bitwise. assert vocab_s...
[ "def", "video_bitwise_bottom", "(", "x", ",", "model_hparams", ",", "vocab_size", ")", ":", "pixel_embedding_size", "=", "64", "inputs", "=", "x", "with", "tf", ".", "variable_scope", "(", "\"video_modality_bitwise\"", ",", "reuse", "=", "tf", ".", "AUTO_REUSE",...
Bottom transformation for embedding video bitwise.
[ "Bottom", "transformation", "for", "embedding", "video", "bitwise", "." ]
python
train
38.866667
MoseleyBioinformaticsLab/nmrstarlib
nmrstarlib/nmrstarlib.py
https://github.com/MoseleyBioinformaticsLab/nmrstarlib/blob/f2adabbca04d5a134ce6ba3211099d1457787ff2/nmrstarlib/nmrstarlib.py#L399-L423
def _build_loop(self, lexer): """Build saveframe loop. :param lexer: instance of lexical analyzer. :type lexer: :func:`~nmrstarlib.bmrblex.bmrblex` :return: Fields and values of the loop. :rtype: :py:class:`tuple` """ fields = [] values = [] toke...
[ "def", "_build_loop", "(", "self", ",", "lexer", ")", ":", "fields", "=", "[", "]", "values", "=", "[", "]", "token", "=", "next", "(", "lexer", ")", "while", "token", "[", "0", "]", "==", "u\"_\"", ":", "fields", ".", "append", "(", "token", "["...
Build saveframe loop. :param lexer: instance of lexical analyzer. :type lexer: :func:`~nmrstarlib.bmrblex.bmrblex` :return: Fields and values of the loop. :rtype: :py:class:`tuple`
[ "Build", "saveframe", "loop", "." ]
python
train
32.64
veltzer/pylogconf
config/helpers.py
https://github.com/veltzer/pylogconf/blob/a3e230a073380b43b5d5096f40bb37ae28f3e430/config/helpers.py#L24-L35
def find_packages(path: str) -> List[str]: """ A better version of find_packages than what setuptools offers This function needs to be deterministic. :param path: :return: """ ret = [] for root, _dir, files in os.walk(path): if '__init__.py' in files: ret.append(root....
[ "def", "find_packages", "(", "path", ":", "str", ")", "->", "List", "[", "str", "]", ":", "ret", "=", "[", "]", "for", "root", ",", "_dir", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "if", "'__init__.py'", "in", "files", ":", ...
A better version of find_packages than what setuptools offers This function needs to be deterministic. :param path: :return:
[ "A", "better", "version", "of", "find_packages", "than", "what", "setuptools", "offers", "This", "function", "needs", "to", "be", "deterministic", ".", ":", "param", "path", ":", ":", "return", ":" ]
python
train
29.166667
Robpol86/sphinxcontrib-versioning
sphinxcontrib/versioning/git.py
https://github.com/Robpol86/sphinxcontrib-versioning/blob/920edec0ac764081b583a2ecf4e6952762b9dbf2/sphinxcontrib/versioning/git.py#L181-L209
def list_remote(local_root): """Get remote branch/tag latest SHAs. :raise GitError: When git ls-remote fails. :param str local_root: Local path to git root directory. :return: List of tuples containing strings. Each tuple is sha, name, kind. :rtype: list """ command = ['git', 'ls-remote',...
[ "def", "list_remote", "(", "local_root", ")", ":", "command", "=", "[", "'git'", ",", "'ls-remote'", ",", "'--heads'", ",", "'--tags'", "]", "try", ":", "output", "=", "run_command", "(", "local_root", ",", "command", ")", "except", "CalledProcessError", "as...
Get remote branch/tag latest SHAs. :raise GitError: When git ls-remote fails. :param str local_root: Local path to git root directory. :return: List of tuples containing strings. Each tuple is sha, name, kind. :rtype: list
[ "Get", "remote", "branch", "/", "tag", "latest", "SHAs", "." ]
python
train
39.172414
GoogleCloudPlatform/appengine-gcs-client
python/src/cloudstorage/storage_api.py
https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/d11078331ecd915d753c886e96a80133599f3f98/python/src/cloudstorage/storage_api.py#L374-L419
def read(self, size=-1): """Read data from RAW file. Args: size: Number of bytes to read as integer. Actual number of bytes read is always equal to size unless EOF is reached. If size is negative or unspecified, read the entire file. Returns: data read as str. Raises: ...
[ "def", "read", "(", "self", ",", "size", "=", "-", "1", ")", ":", "self", ".", "_check_open", "(", ")", "if", "not", "self", ".", "_remaining", "(", ")", ":", "return", "''", "data_list", "=", "[", "]", "while", "True", ":", "remaining", "=", "se...
Read data from RAW file. Args: size: Number of bytes to read as integer. Actual number of bytes read is always equal to size unless EOF is reached. If size is negative or unspecified, read the entire file. Returns: data read as str. Raises: IOError: When this buffer is c...
[ "Read", "data", "from", "RAW", "file", "." ]
python
train
27.021739
PyCQA/pylint
pylint/checkers/base.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/base.py#L2236-L2243
def register(linter): """required method to auto register this checker""" linter.register_checker(BasicErrorChecker(linter)) linter.register_checker(BasicChecker(linter)) linter.register_checker(NameChecker(linter)) linter.register_checker(DocStringChecker(linter)) linter.register_checker(PassCh...
[ "def", "register", "(", "linter", ")", ":", "linter", ".", "register_checker", "(", "BasicErrorChecker", "(", "linter", ")", ")", "linter", ".", "register_checker", "(", "BasicChecker", "(", "linter", ")", ")", "linter", ".", "register_checker", "(", "NameChec...
required method to auto register this checker
[ "required", "method", "to", "auto", "register", "this", "checker" ]
python
test
47.75
SBRG/ssbio
ssbio/protein/structure/structprop.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L620-L666
def view_structure(self, only_chains=None, opacity=1.0, recolor=False, gui=False): """Use NGLviewer to display a structure in a Jupyter notebook Args: only_chains (str, list): Chain ID or IDs to display opacity (float): Opacity of the structure recolor (bool): If str...
[ "def", "view_structure", "(", "self", ",", "only_chains", "=", "None", ",", "opacity", "=", "1.0", ",", "recolor", "=", "False", ",", "gui", "=", "False", ")", ":", "# TODO: show_structure_file does not work for MMTF files - need to check for that and load accordingly", ...
Use NGLviewer to display a structure in a Jupyter notebook Args: only_chains (str, list): Chain ID or IDs to display opacity (float): Opacity of the structure recolor (bool): If structure should be cleaned and recolored to silver gui (bool): If the NGLview GUI sh...
[ "Use", "NGLviewer", "to", "display", "a", "structure", "in", "a", "Jupyter", "notebook" ]
python
train
39.659574
AguaClara/aguaclara
aguaclara/design/cdc.py
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/design/cdc.py#L102-L110
def _len_tube(Flow, Diam, HeadLoss, conc_chem, temp, en_chem, KMinor): """Length of tube required to get desired head loss at maximum flow based on the Hagen-Poiseuille equation.""" num1 = pc.gravity.magnitude * HeadLoss * np.pi * (Diam**4) denom1 = 128 * viscosity_kinematic_chem(conc_chem, temp, en_che...
[ "def", "_len_tube", "(", "Flow", ",", "Diam", ",", "HeadLoss", ",", "conc_chem", ",", "temp", ",", "en_chem", ",", "KMinor", ")", ":", "num1", "=", "pc", ".", "gravity", ".", "magnitude", "*", "HeadLoss", "*", "np", ".", "pi", "*", "(", "Diam", "**...
Length of tube required to get desired head loss at maximum flow based on the Hagen-Poiseuille equation.
[ "Length", "of", "tube", "required", "to", "get", "desired", "head", "loss", "at", "maximum", "flow", "based", "on", "the", "Hagen", "-", "Poiseuille", "equation", "." ]
python
train
54.444444
avihad/twistes
twistes/client.py
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L63-L79
def get(self, index, id, fields=None, doc_type=EsConst.ALL_VALUES, **query_params): """ Retrieve specific record by id `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name to query :param id: the id of the record :...
[ "def", "get", "(", "self", ",", "index", ",", "id", ",", "fields", "=", "None", ",", "doc_type", "=", "EsConst", ".", "ALL_VALUES", ",", "*", "*", "query_params", ")", ":", "if", "fields", ":", "query_params", "[", "EsConst", ".", "FIELDS", "]", "=",...
Retrieve specific record by id `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name to query :param id: the id of the record :param fields: the fields you what to fetch from the record (str separated by comma's) :param doc...
[ "Retrieve", "specific", "record", "by", "id", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "docs", "-", "get", ".", "html", ">", "_", ":", "param", "index"...
python
train
44.294118
tensorflow/cleverhans
cleverhans/utils.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils.py#L167-L173
def pair_visual(*args, **kwargs): """Deprecation wrapper""" warnings.warn("`pair_visual` has moved to `cleverhans.plot.pyplot_image`. " "cleverhans.utils.pair_visual may be removed on or after " "2019-04-24.") from cleverhans.plot.pyplot_image import pair_visual as new_pair_visual ...
[ "def", "pair_visual", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "\"`pair_visual` has moved to `cleverhans.plot.pyplot_image`. \"", "\"cleverhans.utils.pair_visual may be removed on or after \"", "\"2019-04-24.\"", ")", "from", "cleverh...
Deprecation wrapper
[ "Deprecation", "wrapper" ]
python
train
50.714286
google/grr
grr/server/grr_response_server/gui/wsgiapp.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/wsgiapp.py#L226-L269
def _HandleHomepage(self, request): """Renders GRR home page by rendering base.html Jinja template.""" _ = request env = jinja2.Environment( loader=jinja2.FileSystemLoader(config.CONFIG["AdminUI.template_root"]), autoescape=True) create_time = psutil.Process(os.getpid()).create_time()...
[ "def", "_HandleHomepage", "(", "self", ",", "request", ")", ":", "_", "=", "request", "env", "=", "jinja2", ".", "Environment", "(", "loader", "=", "jinja2", ".", "FileSystemLoader", "(", "config", ".", "CONFIG", "[", "\"AdminUI.template_root\"", "]", ")", ...
Renders GRR home page by rendering base.html Jinja template.
[ "Renders", "GRR", "home", "page", "by", "rendering", "base", ".", "html", "Jinja", "template", "." ]
python
train
33.590909
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L19375-L19388
def environment_schedule_unset(self, name): """Schedules unsetting (removing) an environment variable when creating the next guest process. This affects the :py:func:`IGuestSession.environment_changes` attribute. in name of type str Name of the environment variable to unse...
[ "def", "environment_schedule_unset", "(", "self", ",", "name", ")", ":", "if", "not", "isinstance", "(", "name", ",", "basestring", ")", ":", "raise", "TypeError", "(", "\"name can only be an instance of type basestring\"", ")", "self", ".", "_call", "(", "\"envir...
Schedules unsetting (removing) an environment variable when creating the next guest process. This affects the :py:func:`IGuestSession.environment_changes` attribute. in name of type str Name of the environment variable to unset. This cannot be empty nor can it contain...
[ "Schedules", "unsetting", "(", "removing", ")", "an", "environment", "variable", "when", "creating", "the", "next", "guest", "process", ".", "This", "affects", "the", ":", "py", ":", "func", ":", "IGuestSession", ".", "environment_changes", "attribute", "." ]
python
train
42.642857
harlowja/fasteners
fasteners/lock.py
https://github.com/harlowja/fasteners/blob/8f3bbab0204a50037448a8fad7a6bf12eb1a2695/fasteners/lock.py#L205-L238
def write_lock(self): """Context manager that grants a write lock. Will wait until no active readers. Blocks readers after acquiring. Guaranteed for locks to be processed in fair order (FIFO). Raises a ``RuntimeError`` if an active reader attempts to acquire a lock. ""...
[ "def", "write_lock", "(", "self", ")", ":", "me", "=", "self", ".", "_current_thread", "(", ")", "i_am_writer", "=", "self", ".", "is_writer", "(", "check_pending", "=", "False", ")", "if", "self", ".", "is_reader", "(", ")", "and", "not", "i_am_writer",...
Context manager that grants a write lock. Will wait until no active readers. Blocks readers after acquiring. Guaranteed for locks to be processed in fair order (FIFO). Raises a ``RuntimeError`` if an active reader attempts to acquire a lock.
[ "Context", "manager", "that", "grants", "a", "write", "lock", "." ]
python
train
38.852941
saltstack/salt
salt/modules/boto_elasticache.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L390-L400
def list_cache_subnet_groups(name=None, region=None, key=None, keyid=None, profile=None): ''' Return a list of all cache subnet group names CLI example:: salt myminion boto_elasticache.list_subnet_groups region=us-east-1 ''' return [g['CacheSubnetGroupName'] fo...
[ "def", "list_cache_subnet_groups", "(", "name", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "return", "[", "g", "[", "'CacheSubnetGroupName'", "]", "for", "g", "in"...
Return a list of all cache subnet group names CLI example:: salt myminion boto_elasticache.list_subnet_groups region=us-east-1
[ "Return", "a", "list", "of", "all", "cache", "subnet", "group", "names" ]
python
train
35.636364
videntity/django-djmongo
djmongo/console/utils.py
https://github.com/videntity/django-djmongo/blob/7534e0981a2bc12634cf3f1ed03353623dc57565/djmongo/console/utils.py#L89-L108
def create_mongo_db(database_name, collection_name, initial_document): """Create a new database and collection by inserting one document.""" response_dict = {} try: mongodb_client_url = getattr(settings, 'MONGODB_CLIENT', 'mongodb://localhost:27017/') mc = Mo...
[ "def", "create_mongo_db", "(", "database_name", ",", "collection_name", ",", "initial_document", ")", ":", "response_dict", "=", "{", "}", "try", ":", "mongodb_client_url", "=", "getattr", "(", "settings", ",", "'MONGODB_CLIENT'", ",", "'mongodb://localhost:27017/'", ...
Create a new database and collection by inserting one document.
[ "Create", "a", "new", "database", "and", "collection", "by", "inserting", "one", "document", "." ]
python
train
33.55
fastai/fastai
fastai/train.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/train.py#L144-L147
def from_learner(cls, learn: Learner, ds_type:DatasetType=DatasetType.Valid): "Create an instance of `ClassificationInterpretation`" preds = learn.get_preds(ds_type=ds_type, with_loss=True) return cls(learn, *preds)
[ "def", "from_learner", "(", "cls", ",", "learn", ":", "Learner", ",", "ds_type", ":", "DatasetType", "=", "DatasetType", ".", "Valid", ")", ":", "preds", "=", "learn", ".", "get_preds", "(", "ds_type", "=", "ds_type", ",", "with_loss", "=", "True", ")", ...
Create an instance of `ClassificationInterpretation`
[ "Create", "an", "instance", "of", "ClassificationInterpretation" ]
python
train
59.25
pycontribs/pyrax
pyrax/cloudmonitoring.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L720-L731
def update_entity(self, entity, agent=None, metadata=None): """ Updates the specified entity's values with the supplied parameters. """ body = {} if agent: body["agent_id"] = utils.get_id(agent) if metadata: body["metadata"] = metadata if b...
[ "def", "update_entity", "(", "self", ",", "entity", ",", "agent", "=", "None", ",", "metadata", "=", "None", ")", ":", "body", "=", "{", "}", "if", "agent", ":", "body", "[", "\"agent_id\"", "]", "=", "utils", ".", "get_id", "(", "agent", ")", "if"...
Updates the specified entity's values with the supplied parameters.
[ "Updates", "the", "specified", "entity", "s", "values", "with", "the", "supplied", "parameters", "." ]
python
train
36.75
oscarbranson/latools
latools/latools.py
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/latools.py#L2490-L2525
def filter_defragment(self, threshold, mode='include', filt=True, samples=None, subset=None): """ Remove 'fragments' from the calculated filter Parameters ---------- threshold : int Contiguous data regions that contain this number or fewer points are cons...
[ "def", "filter_defragment", "(", "self", ",", "threshold", ",", "mode", "=", "'include'", ",", "filt", "=", "True", ",", "samples", "=", "None", ",", "subset", "=", "None", ")", ":", "if", "samples", "is", "not", "None", ":", "subset", "=", "self", "...
Remove 'fragments' from the calculated filter Parameters ---------- threshold : int Contiguous data regions that contain this number or fewer points are considered 'fragments' mode : str Specifies wither to 'include' or 'exclude' the identified ...
[ "Remove", "fragments", "from", "the", "calculated", "filter" ]
python
test
39.083333
alex-kostirin/pyatomac
atomac/ooldtp/__init__.py
https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/ooldtp/__init__.py#L570-L583
def deregisterevent(self, event_name): """ Remove callback of registered event @param event_name: Event name in at-spi format. @type event_name: string @return: 1 if registration was successful, 0 if not. @rtype: integer """ if event_name in self._pollE...
[ "def", "deregisterevent", "(", "self", ",", "event_name", ")", ":", "if", "event_name", "in", "self", ".", "_pollEvents", ".", "_callback", ":", "del", "self", ".", "_pollEvents", ".", "_callback", "[", "event_name", "]", "return", "self", ".", "_remote_dere...
Remove callback of registered event @param event_name: Event name in at-spi format. @type event_name: string @return: 1 if registration was successful, 0 if not. @rtype: integer
[ "Remove", "callback", "of", "registered", "event" ]
python
valid
31
materialsproject/pymatgen
pymatgen/electronic_structure/boltztrap.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/boltztrap.py#L1696-L1707
def get_carrier_concentration(self): """ gives the carrier concentration (in cm^-3) Returns a dictionary {temp:[]} with an array of carrier concentration (in cm^-3) at each temperature The array relates to each step of electron chemical potential """ ...
[ "def", "get_carrier_concentration", "(", "self", ")", ":", "return", "{", "temp", ":", "[", "1e24", "*", "i", "/", "self", ".", "vol", "for", "i", "in", "self", ".", "_carrier_conc", "[", "temp", "]", "]", "for", "temp", "in", "self", ".", "_carrier_...
gives the carrier concentration (in cm^-3) Returns a dictionary {temp:[]} with an array of carrier concentration (in cm^-3) at each temperature The array relates to each step of electron chemical potential
[ "gives", "the", "carrier", "concentration", "(", "in", "cm^", "-", "3", ")" ]
python
train
36.25
fedora-infra/datanommer
datanommer.models/alembic/versions/1d4feffd78fe_add_historic_user_an.py
https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/datanommer.models/alembic/versions/1d4feffd78fe_add_historic_user_an.py#L48-L61
def _page(q, chunk=1000): """ Quick utility to page a query, 1000 items at a time. We need this so we don't OOM (out of memory) ourselves loading the world. """ offset = 0 while True: r = False for elem in q.limit(chunk).offset(offset): r = True yield elem ...
[ "def", "_page", "(", "q", ",", "chunk", "=", "1000", ")", ":", "offset", "=", "0", "while", "True", ":", "r", "=", "False", "for", "elem", "in", "q", ".", "limit", "(", "chunk", ")", ".", "offset", "(", "offset", ")", ":", "r", "=", "True", "...
Quick utility to page a query, 1000 items at a time. We need this so we don't OOM (out of memory) ourselves loading the world.
[ "Quick", "utility", "to", "page", "a", "query", "1000", "items", "at", "a", "time", ".", "We", "need", "this", "so", "we", "don", "t", "OOM", "(", "out", "of", "memory", ")", "ourselves", "loading", "the", "world", "." ]
python
train
26
angr/angr
angr/state_plugins/symbolic_memory.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L1234-L1247
def permissions(self, addr, permissions=None): """ Retrieve the permissions of the page at address `addr`. :param addr: address to get the page permissions :param permissions: Integer or BVV to optionally set page permissions to :return: AST representing the pe...
[ "def", "permissions", "(", "self", ",", "addr", ",", "permissions", "=", "None", ")", ":", "out", "=", "self", ".", "mem", ".", "permissions", "(", "addr", ",", "permissions", ")", "# if unicorn is in play and we've marked a page writable, it must be uncached", "if"...
Retrieve the permissions of the page at address `addr`. :param addr: address to get the page permissions :param permissions: Integer or BVV to optionally set page permissions to :return: AST representing the permissions on the page
[ "Retrieve", "the", "permissions", "of", "the", "page", "at", "address", "addr", "." ]
python
train
49.285714
learningequality/ricecooker
ricecooker/managers/tree.py
https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/managers/tree.py#L281-L300
def commit_channel(self, channel_id): """ commit_channel: commits channel to Kolibri Studio Args: channel_id (str): channel's id on Kolibri Studio Returns: channel id and link to uploadedchannel """ payload = { "channel_id":channel_id, ...
[ "def", "commit_channel", "(", "self", ",", "channel_id", ")", ":", "payload", "=", "{", "\"channel_id\"", ":", "channel_id", ",", "\"stage\"", ":", "config", ".", "STAGE", ",", "}", "response", "=", "config", ".", "SESSION", ".", "post", "(", "config", "...
commit_channel: commits channel to Kolibri Studio Args: channel_id (str): channel's id on Kolibri Studio Returns: channel id and link to uploadedchannel
[ "commit_channel", ":", "commits", "channel", "to", "Kolibri", "Studio", "Args", ":", "channel_id", "(", "str", ")", ":", "channel", "s", "id", "on", "Kolibri", "Studio", "Returns", ":", "channel", "id", "and", "link", "to", "uploadedchannel" ]
python
train
50.2
cs01/gdbgui
gdbgui/backend.py
https://github.com/cs01/gdbgui/blob/5367f87554f8f7c671d1f4596c133bf1303154f0/gdbgui/backend.py#L369-L382
def send_msg_to_clients(client_ids, msg, error=False): """Send message to all clients""" if error: stream = "stderr" else: stream = "stdout" response = [{"message": None, "type": "console", "payload": msg, "stream": stream}] for client_id in client_ids: logger.info("emiting...
[ "def", "send_msg_to_clients", "(", "client_ids", ",", "msg", ",", "error", "=", "False", ")", ":", "if", "error", ":", "stream", "=", "\"stderr\"", "else", ":", "stream", "=", "\"stdout\"", "response", "=", "[", "{", "\"message\"", ":", "None", ",", "\"t...
Send message to all clients
[ "Send", "message", "to", "all", "clients" ]
python
train
33.285714
senaite/senaite.core
bika/lims/content/abstractanalysis.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/abstractanalysis.py#L748-L767
def getAllowedInstruments(self): """Returns the allowed instruments for this analysis, either if the instrument was assigned directly (by using "Allows instrument entry of results") or indirectly via Method (by using "Allows manual entry of results") in Analysis Service edit view. ...
[ "def", "getAllowedInstruments", "(", "self", ")", ":", "service", "=", "self", ".", "getAnalysisService", "(", ")", "if", "not", "service", ":", "return", "[", "]", "instruments", "=", "[", "]", "if", "self", ".", "getInstrumentEntryOfResults", "(", ")", "...
Returns the allowed instruments for this analysis, either if the instrument was assigned directly (by using "Allows instrument entry of results") or indirectly via Method (by using "Allows manual entry of results") in Analysis Service edit view. :return: A list of instruments allowed for...
[ "Returns", "the", "allowed", "instruments", "for", "this", "analysis", "either", "if", "the", "instrument", "was", "assigned", "directly", "(", "by", "using", "Allows", "instrument", "entry", "of", "results", ")", "or", "indirectly", "via", "Method", "(", "by"...
python
train
40.3
jpscaletti/solution
solution/fields/color.py
https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/fields/color.py#L74-L87
def normalize_rgb(r, g, b, a): """Transform a rgb[a] color to #hex[a]. """ r = int(r, 10) g = int(g, 10) b = int(b, 10) if a: a = float(a) * 256 if r > 255 or g > 255 or b > 255 or (a and a > 255): return None color = '#%02x%02x%02x' % (r, g, b) if a: color +=...
[ "def", "normalize_rgb", "(", "r", ",", "g", ",", "b", ",", "a", ")", ":", "r", "=", "int", "(", "r", ",", "10", ")", "g", "=", "int", "(", "g", ",", "10", ")", "b", "=", "int", "(", "b", ",", "10", ")", "if", "a", ":", "a", "=", "floa...
Transform a rgb[a] color to #hex[a].
[ "Transform", "a", "rgb", "[", "a", "]", "color", "to", "#hex", "[", "a", "]", "." ]
python
train
24.285714
horazont/aioxmpp
aioxmpp/pep/service.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pep/service.py#L326-L338
def close(self): """ Unclaim the PEP node and unregister the registered features. It is not necessary to call close if this claim is managed by :class:`~aioxmpp.pep.register_pep_node`. """ if self._closed: return self._closed = True self._pep...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_closed", "=", "True", "self", ".", "_pep_service", ".", "_unclaim", "(", "self", ".", "node_namespace", ")", "self", ".", "_unregister", "(", ")" ]
Unclaim the PEP node and unregister the registered features. It is not necessary to call close if this claim is managed by :class:`~aioxmpp.pep.register_pep_node`.
[ "Unclaim", "the", "PEP", "node", "and", "unregister", "the", "registered", "features", "." ]
python
train
28.692308
bitesofcode/projexui
projexui/widgets/xloaderwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xloaderwidget.py#L202-L207
def incrementSub(self, amount=1): """ Increments the sub-progress bar by amount. """ self._subProgressBar.setValue(self.subValue() + amount) QApplication.instance().processEvents()
[ "def", "incrementSub", "(", "self", ",", "amount", "=", "1", ")", ":", "self", ".", "_subProgressBar", ".", "setValue", "(", "self", ".", "subValue", "(", ")", "+", "amount", ")", "QApplication", ".", "instance", "(", ")", ".", "processEvents", "(", ")...
Increments the sub-progress bar by amount.
[ "Increments", "the", "sub", "-", "progress", "bar", "by", "amount", "." ]
python
train
36
erget/StereoVision
stereovision/stereo_cameras.py
https://github.com/erget/StereoVision/blob/1adff45e291362f52188e0fd0211265845a4461a/stereovision/stereo_cameras.py#L79-L88
def get_frames_singleimage(self): """ Get current left and right frames from a single image, by splitting the image in half. """ frame = self.captures[0].read()[1] height, width, colors = frame.shape left_frame = frame[:, :width/2, :] right_frame = frame[:...
[ "def", "get_frames_singleimage", "(", "self", ")", ":", "frame", "=", "self", ".", "captures", "[", "0", "]", ".", "read", "(", ")", "[", "1", "]", "height", ",", "width", ",", "colors", "=", "frame", ".", "shape", "left_frame", "=", "frame", "[", ...
Get current left and right frames from a single image, by splitting the image in half.
[ "Get", "current", "left", "and", "right", "frames", "from", "a", "single", "image", "by", "splitting", "the", "image", "in", "half", "." ]
python
train
36.6
vtraag/leidenalg
src/VertexPartition.py
https://github.com/vtraag/leidenalg/blob/a9e15116973a81048edf02ef7cf800d54debe1cc/src/VertexPartition.py#L376-L384
def weight_from_comm(self, v, comm): """ The total number of edges (or sum of weights) to node ``v`` from community ``comm``. See Also -------- :func:`~VertexPartition.MutableVertexPartition.weight_to_comm` """ return _c_leiden._MutableVertexPartition_weight_from_comm(self._partition, v, co...
[ "def", "weight_from_comm", "(", "self", ",", "v", ",", "comm", ")", ":", "return", "_c_leiden", ".", "_MutableVertexPartition_weight_from_comm", "(", "self", ".", "_partition", ",", "v", ",", "comm", ")" ]
The total number of edges (or sum of weights) to node ``v`` from community ``comm``. See Also -------- :func:`~VertexPartition.MutableVertexPartition.weight_to_comm`
[ "The", "total", "number", "of", "edges", "(", "or", "sum", "of", "weights", ")", "to", "node", "v", "from", "community", "comm", "." ]
python
train
35
kolypto/py-good
good/schema/compiler.py
https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L331-L338
def _compile_schema(self, schema): """ Compile another schema """ assert self.matcher == schema.matcher self.name = schema.name self.compiled_type = schema.compiled_type return schema.compiled
[ "def", "_compile_schema", "(", "self", ",", "schema", ")", ":", "assert", "self", ".", "matcher", "==", "schema", ".", "matcher", "self", ".", "name", "=", "schema", ".", "name", "self", ".", "compiled_type", "=", "schema", ".", "compiled_type", "return", ...
Compile another schema
[ "Compile", "another", "schema" ]
python
train
28.375
automl/HpBandSter
hpbandster/core/base_iteration.py
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/base_iteration.py#L105-L139
def register_result(self, job, skip_sanity_checks=False): """ function to register the result of a job This function is called from HB_master, don't call this from your script. """ if self.is_finished: raise RuntimeError("This HB iteration is finished, you can't register more results!") config_id = ...
[ "def", "register_result", "(", "self", ",", "job", ",", "skip_sanity_checks", "=", "False", ")", ":", "if", "self", ".", "is_finished", ":", "raise", "RuntimeError", "(", "\"This HB iteration is finished, you can't register more results!\"", ")", "config_id", "=", "jo...
function to register the result of a job This function is called from HB_master, don't call this from your script.
[ "function", "to", "register", "the", "result", "of", "a", "job" ]
python
train
27.885714
erdc/RAPIDpy
RAPIDpy/rapid.py
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L632-L800
def run(self, rapid_namelist_file=""): """ Run RAPID program and generate file based on inputs This will generate your rapid_namelist file and run RAPID from wherever you call this script (your working directory). Parameters ---------- rapid_namelist_file: str, o...
[ "def", "run", "(", "self", ",", "rapid_namelist_file", "=", "\"\"", ")", ":", "if", "not", "self", ".", "_rapid_executable_location", ":", "log", "(", "\"Missing rapid_executable_location. \"", "\"Please set before running this function ...\"", ",", "\"ERROR\"", ")", "t...
Run RAPID program and generate file based on inputs This will generate your rapid_namelist file and run RAPID from wherever you call this script (your working directory). Parameters ---------- rapid_namelist_file: str, optional Path of namelist file to use in the sim...
[ "Run", "RAPID", "program", "and", "generate", "file", "based", "on", "inputs", "This", "will", "generate", "your", "rapid_namelist", "file", "and", "run", "RAPID", "from", "wherever", "you", "call", "this", "script", "(", "your", "working", "directory", ")", ...
python
train
36.686391
inveniosoftware/invenio-stats
invenio_stats/ext.py
https://github.com/inveniosoftware/invenio-stats/blob/d877ae5462084abb4a28a20f1ebb3d636769c1bc/invenio_stats/ext.py#L189-L192
def publish(self, event_type, events): """Publish events.""" assert event_type in self.events current_queues.queues['stats-{}'.format(event_type)].publish(events)
[ "def", "publish", "(", "self", ",", "event_type", ",", "events", ")", ":", "assert", "event_type", "in", "self", ".", "events", "current_queues", ".", "queues", "[", "'stats-{}'", ".", "format", "(", "event_type", ")", "]", ".", "publish", "(", "events", ...
Publish events.
[ "Publish", "events", "." ]
python
valid
45.75
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/decoder.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/decoder.py#L794-L802
def _SkipGroup(buffer, pos, end): """Skip sub-group. Returns the new position.""" while 1: (tag_bytes, pos) = ReadTag(buffer, pos) new_pos = SkipField(buffer, pos, end, tag_bytes) if new_pos == -1: return pos pos = new_pos
[ "def", "_SkipGroup", "(", "buffer", ",", "pos", ",", "end", ")", ":", "while", "1", ":", "(", "tag_bytes", ",", "pos", ")", "=", "ReadTag", "(", "buffer", ",", "pos", ")", "new_pos", "=", "SkipField", "(", "buffer", ",", "pos", ",", "end", ",", "...
Skip sub-group. Returns the new position.
[ "Skip", "sub", "-", "group", ".", "Returns", "the", "new", "position", "." ]
python
train
26.888889
moremoban/moban
setup.py
https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/setup.py#L157-L163
def read(afile): """Read a file into setup""" the_relative_file = os.path.join(HERE, afile) with codecs.open(the_relative_file, 'r', 'utf-8') as opened_file: content = filter_out_test_code(opened_file) content = "".join(list(content)) return content
[ "def", "read", "(", "afile", ")", ":", "the_relative_file", "=", "os", ".", "path", ".", "join", "(", "HERE", ",", "afile", ")", "with", "codecs", ".", "open", "(", "the_relative_file", ",", "'r'", ",", "'utf-8'", ")", "as", "opened_file", ":", "conten...
Read a file into setup
[ "Read", "a", "file", "into", "setup" ]
python
train
39.857143
openstack/proliantutils
proliantutils/ilo/ris.py
https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ris.py#L199-L213
def _get_host_details(self): """Get the system details.""" # Assuming only one system present as part of collection, # as we are dealing with iLO's here. status, headers, system = self._rest_get('/rest/v1/Systems/1') if status < 300: stype = self._get_type(system) ...
[ "def", "_get_host_details", "(", "self", ")", ":", "# Assuming only one system present as part of collection,", "# as we are dealing with iLO's here.", "status", ",", "headers", ",", "system", "=", "self", ".", "_rest_get", "(", "'/rest/v1/Systems/1'", ")", "if", "status", ...
Get the system details.
[ "Get", "the", "system", "details", "." ]
python
train
40.733333
picklepete/pyicloud
pyicloud/base.py
https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/base.py#L195-L230
def authenticate(self): """ Handles authentication, and persists the X-APPLE-WEB-KB cookie so that subsequent logins will not cause additional e-mails from Apple. """ logger.info("Authenticating as %s", self.user['apple_id']) data = dict(self.user) # We authent...
[ "def", "authenticate", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Authenticating as %s\"", ",", "self", ".", "user", "[", "'apple_id'", "]", ")", "data", "=", "dict", "(", "self", ".", "user", ")", "# We authenticate every time, so \"remember me\" is ...
Handles authentication, and persists the X-APPLE-WEB-KB cookie so that subsequent logins will not cause additional e-mails from Apple.
[ "Handles", "authentication", "and", "persists", "the", "X", "-", "APPLE", "-", "WEB", "-", "KB", "cookie", "so", "that", "subsequent", "logins", "will", "not", "cause", "additional", "e", "-", "mails", "from", "Apple", "." ]
python
train
33.138889
tommyod/streprogen
streprogen/program.py
https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/program.py#L715-L732
def to_html(self, table_width=5): """Write the program information to HTML code, which can be saved, printed and brought to the gym. Parameters ---------- table_width The table with of the HTML code. Returns ------- string HTML co...
[ "def", "to_html", "(", "self", ",", "table_width", "=", "5", ")", ":", "env", "=", "self", ".", "jinja2_environment", "template", "=", "env", ".", "get_template", "(", "self", ".", "TEMPLATE_NAMES", "[", "'html'", "]", ")", "return", "template", ".", "re...
Write the program information to HTML code, which can be saved, printed and brought to the gym. Parameters ---------- table_width The table with of the HTML code. Returns ------- string HTML code.
[ "Write", "the", "program", "information", "to", "HTML", "code", "which", "can", "be", "saved", "printed", "and", "brought", "to", "the", "gym", "." ]
python
train
27.333333
dbcli/athenacli
athenacli/packages/special/iocommands.py
https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/packages/special/iocommands.py#L123-L154
def open_external_editor(filename=None, sql=None): """Open external editor, wait for the user to type in their query, return the query. :return: list with one tuple, query as first element. """ message = None filename = filename.strip().split(' ', 1)[0] if filename else None sql = sql or '...
[ "def", "open_external_editor", "(", "filename", "=", "None", ",", "sql", "=", "None", ")", ":", "message", "=", "None", "filename", "=", "filename", ".", "strip", "(", ")", ".", "split", "(", "' '", ",", "1", ")", "[", "0", "]", "if", "filename", "...
Open external editor, wait for the user to type in their query, return the query. :return: list with one tuple, query as first element.
[ "Open", "external", "editor", "wait", "for", "the", "user", "to", "type", "in", "their", "query", "return", "the", "query", ".", ":", "return", ":", "list", "with", "one", "tuple", "query", "as", "first", "element", "." ]
python
train
31.625
Julius2342/pyvlx
old_api/pyvlx/devices.py
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/devices.py#L79-L82
def load_blind(self, item): """Load blind from JSON.""" blind = Blind.from_config(self.pyvlx, item) self.add(blind)
[ "def", "load_blind", "(", "self", ",", "item", ")", ":", "blind", "=", "Blind", ".", "from_config", "(", "self", ".", "pyvlx", ",", "item", ")", "self", ".", "add", "(", "blind", ")" ]
Load blind from JSON.
[ "Load", "blind", "from", "JSON", "." ]
python
train
34
davidfokkema/artist
artist/multi_plot.py
https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/multi_plot.py#L559-L576
def set_scalebar_for_all(self, row_column_list=None, location='lower right'): """Show marker area scale for subplots. :param row_column_list: a list containing (row, column) tuples to specify the subplots, or None to indicate *all* subplots. :param locat...
[ "def", "set_scalebar_for_all", "(", "self", ",", "row_column_list", "=", "None", ",", "location", "=", "'lower right'", ")", ":", "if", "row_column_list", "is", "None", ":", "for", "subplot", "in", "self", ".", "subplots", ":", "subplot", ".", "set_scalebar", ...
Show marker area scale for subplots. :param row_column_list: a list containing (row, column) tuples to specify the subplots, or None to indicate *all* subplots. :param location: the location of the label inside the plot. May be one of 'center', 'upper right', 'lower right', 'up...
[ "Show", "marker", "area", "scale", "for", "subplots", "." ]
python
train
42.388889
spacetelescope/drizzlepac
drizzlepac/util.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/util.py#L329-L343
def endStep(self,key): """ Record the end time for the step. If key==None, simply record ptime as end time for class to represent the overall runtime since the initialization of the class. """ ptime = _ptime() if key is not None: self.steps[key]['end'...
[ "def", "endStep", "(", "self", ",", "key", ")", ":", "ptime", "=", "_ptime", "(", ")", "if", "key", "is", "not", "None", ":", "self", ".", "steps", "[", "key", "]", "[", "'end'", "]", "=", "ptime", "self", ".", "steps", "[", "key", "]", "[", ...
Record the end time for the step. If key==None, simply record ptime as end time for class to represent the overall runtime since the initialization of the class.
[ "Record", "the", "end", "time", "for", "the", "step", "." ]
python
train
33.8
iotaledger/iota.lib.py
iota/api.py
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/api.py#L732-L789
def get_new_addresses( self, index=0, count=1, security_level=AddressGenerator.DEFAULT_SECURITY_LEVEL, checksum=False, ): # type: (int, Optional[int], int, bool) -> dict """ Generates one or more new addresses from the seed. ...
[ "def", "get_new_addresses", "(", "self", ",", "index", "=", "0", ",", "count", "=", "1", ",", "security_level", "=", "AddressGenerator", ".", "DEFAULT_SECURITY_LEVEL", ",", "checksum", "=", "False", ",", ")", ":", "# type: (int, Optional[int], int, bool) -> dict", ...
Generates one or more new addresses from the seed. :param index: The key index of the first new address to generate (must be >= 1). :param count: Number of addresses to generate (must be >= 1). .. tip:: This is more efficient than callin...
[ "Generates", "one", "or", "more", "new", "addresses", "from", "the", "seed", "." ]
python
test
29.758621
tkem/uritools
uritools/defrag.py
https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/defrag.py#L33-L41
def uridefrag(uristring): """Remove an existing fragment component from a URI reference string. """ if isinstance(uristring, bytes): parts = uristring.partition(b'#') else: parts = uristring.partition(u'#') return DefragResult(parts[0], parts[2] if parts[1] else None)
[ "def", "uridefrag", "(", "uristring", ")", ":", "if", "isinstance", "(", "uristring", ",", "bytes", ")", ":", "parts", "=", "uristring", ".", "partition", "(", "b'#'", ")", "else", ":", "parts", "=", "uristring", ".", "partition", "(", "u'#'", ")", "re...
Remove an existing fragment component from a URI reference string.
[ "Remove", "an", "existing", "fragment", "component", "from", "a", "URI", "reference", "string", "." ]
python
train
33
project-rig/rig
rig/place_and_route/route/ner.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/route/ner.py#L517-L577
def route(vertices_resources, nets, machine, constraints, placements, allocations={}, core_resource=Cores, radius=20): """Routing algorithm based on Neighbour Exploring Routing (NER). Algorithm refrence: J. Navaridas et al. SpiNNaker: Enhanced multicast routing, Parallel Computing (2014). htt...
[ "def", "route", "(", "vertices_resources", ",", "nets", ",", "machine", ",", "constraints", ",", "placements", ",", "allocations", "=", "{", "}", ",", "core_resource", "=", "Cores", ",", "radius", "=", "20", ")", ":", "wrap_around", "=", "machine", ".", ...
Routing algorithm based on Neighbour Exploring Routing (NER). Algorithm refrence: J. Navaridas et al. SpiNNaker: Enhanced multicast routing, Parallel Computing (2014). http://dx.doi.org/10.1016/j.parco.2015.01.002 This algorithm attempts to use NER to generate routing trees for all nets and routes...
[ "Routing", "algorithm", "based", "on", "Neighbour", "Exploring", "Routing", "(", "NER", ")", "." ]
python
train
44.442623
voxpupuli/pypuppetdb
pypuppetdb/types.py
https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/types.py#L454-L459
def facts(self, **kwargs): """Get all facts of this node. Additional arguments may also be specified that will be passed to the query function. """ return self.__api.facts(query=EqualsOperator("certname", self.name), **kwargs)
[ "def", "facts", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__api", ".", "facts", "(", "query", "=", "EqualsOperator", "(", "\"certname\"", ",", "self", ".", "name", ")", ",", "*", "*", "kwargs", ")" ]
Get all facts of this node. Additional arguments may also be specified that will be passed to the query function.
[ "Get", "all", "facts", "of", "this", "node", ".", "Additional", "arguments", "may", "also", "be", "specified", "that", "will", "be", "passed", "to", "the", "query", "function", "." ]
python
valid
47.5
Knio/dominate
dominate/util.py
https://github.com/Knio/dominate/blob/1eb88f9fd797658eef83568a548e2ef9b546807d/dominate/util.py#L44-L51
def system(cmd, data=None): ''' pipes the output of a program ''' import subprocess s = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) out, err = s.communicate(data) return out.decode('utf8')
[ "def", "system", "(", "cmd", ",", "data", "=", "None", ")", ":", "import", "subprocess", "s", "=", "subprocess", ".", "Popen", "(", "cmd", ",", "shell", "=", "True", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stdin", "=", "subprocess", ".",...
pipes the output of a program
[ "pipes", "the", "output", "of", "a", "program" ]
python
valid
29
quantopian/zipline
zipline/data/history_loader.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/history_loader.py#L48-L63
def load_pricing_adjustments(self, columns, dts, assets): """ Returns ------- adjustments : list[dict[int -> Adjustment]] A list, where each element corresponds to the `columns`, of mappings from index to adjustment objects to apply at that index. """ ...
[ "def", "load_pricing_adjustments", "(", "self", ",", "columns", ",", "dts", ",", "assets", ")", ":", "out", "=", "[", "None", "]", "*", "len", "(", "columns", ")", "for", "i", ",", "column", "in", "enumerate", "(", "columns", ")", ":", "adjs", "=", ...
Returns ------- adjustments : list[dict[int -> Adjustment]] A list, where each element corresponds to the `columns`, of mappings from index to adjustment objects to apply at that index.
[ "Returns", "-------", "adjustments", ":", "list", "[", "dict", "[", "int", "-", ">", "Adjustment", "]]", "A", "list", "where", "each", "element", "corresponds", "to", "the", "columns", "of", "mappings", "from", "index", "to", "adjustment", "objects", "to", ...
python
train
36.375
Clinical-Genomics/scout
scout/adapter/mongo/variant.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/variant.py#L525-L588
def get_region_vcf(self, case_obj, chrom=None, start=None, end=None, gene_obj=None, variant_type='clinical', category='snv', rank_threshold=None): """Produce a reduced vcf with variants from the specified coordinates This is used for the alignment viewer....
[ "def", "get_region_vcf", "(", "self", ",", "case_obj", ",", "chrom", "=", "None", ",", "start", "=", "None", ",", "end", "=", "None", ",", "gene_obj", "=", "None", ",", "variant_type", "=", "'clinical'", ",", "category", "=", "'snv'", ",", "rank_threshol...
Produce a reduced vcf with variants from the specified coordinates This is used for the alignment viewer. Args: case_obj(dict): A case from the scout database variant_type(str): 'clinical' or 'research'. Default: 'clinical' category(str): 'snv' or 'sv'. Default: '...
[ "Produce", "a", "reduced", "vcf", "with", "variants", "from", "the", "specified", "coordinates", "This", "is", "used", "for", "the", "alignment", "viewer", "." ]
python
test
38.5625
hootnot/oanda-api-v20
oandapyV20/oandapyV20.py
https://github.com/hootnot/oanda-api-v20/blob/f300734238a6a3958e07e60456155fbc53748aa8/oandapyV20/oandapyV20.py#L262-L324
def request(self, endpoint): """Perform a request for the APIRequest instance 'endpoint'. Parameters ---------- endpoint : APIRequest The endpoint parameter contains an instance of an APIRequest containing the endpoint, method and optionally other parameters ...
[ "def", "request", "(", "self", ",", "endpoint", ")", ":", "method", "=", "endpoint", ".", "method", "method", "=", "method", ".", "lower", "(", ")", "params", "=", "None", "try", ":", "params", "=", "getattr", "(", "endpoint", ",", "\"params\"", ")", ...
Perform a request for the APIRequest instance 'endpoint'. Parameters ---------- endpoint : APIRequest The endpoint parameter contains an instance of an APIRequest containing the endpoint, method and optionally other parameters or body data. Raises ...
[ "Perform", "a", "request", "for", "the", "APIRequest", "instance", "endpoint", "." ]
python
train
33.68254
csvsoundsystem/pytreasuryio
treasuryio/tweetbot.py
https://github.com/csvsoundsystem/pytreasuryio/blob/728caf815d16cd2f3548d8b67c84313de76f9be7/treasuryio/tweetbot.py#L16-L41
def tweet(tweet_text_func): ''' A decorator to make a function Tweet Parameters - `tweet_text_func` is a function that takes no parameters and returns a tweetable string For example:: @tweet def total_deposits_this_week(): # ... @tweet def not_an_inte...
[ "def", "tweet", "(", "tweet_text_func", ")", ":", "def", "tweet_func", "(", ")", ":", "api", "=", "_connect_to_twitter", "(", ")", "tweet", "=", "tweet_text_func", "(", ")", "print", "\"Tweeting: %s\"", "%", "tweet", "api", ".", "update_status", "(", "tweet"...
A decorator to make a function Tweet Parameters - `tweet_text_func` is a function that takes no parameters and returns a tweetable string For example:: @tweet def total_deposits_this_week(): # ... @tweet def not_an_interesting_tweet(): return 'Thi...
[ "A", "decorator", "to", "make", "a", "function", "Tweet" ]
python
train
22.192308
python-openxml/python-docx
docx/oxml/text/run.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/text/run.py#L145-L160
def add_char(self, char): """ Process the next character of input through the translation finite state maching (FSM). There are two possible states, buffer pending and not pending, but those are hidden behind the ``.flush()`` method which must be called at the end of text to ensu...
[ "def", "add_char", "(", "self", ",", "char", ")", ":", "if", "char", "==", "'\\t'", ":", "self", ".", "flush", "(", ")", "self", ".", "_r", ".", "add_tab", "(", ")", "elif", "char", "in", "'\\r\\n'", ":", "self", ".", "flush", "(", ")", "self", ...
Process the next character of input through the translation finite state maching (FSM). There are two possible states, buffer pending and not pending, but those are hidden behind the ``.flush()`` method which must be called at the end of text to ensure any pending ``<w:t>`` element is wr...
[ "Process", "the", "next", "character", "of", "input", "through", "the", "translation", "finite", "state", "maching", "(", "FSM", ")", ".", "There", "are", "two", "possible", "states", "buffer", "pending", "and", "not", "pending", "but", "those", "are", "hidd...
python
train
36.3125
markovmodel/PyEMMA
pyemma/coordinates/api.py
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/api.py#L439-L524
def pipeline(stages, run=True, stride=1, chunksize=None): r""" Data analysis pipeline. Constructs a data analysis :class:`Pipeline <pyemma.coordinates.pipelines.Pipeline>` and parametrizes it (unless prevented). If this function takes too long, consider loading data in memory. Alternatively if the ...
[ "def", "pipeline", "(", "stages", ",", "run", "=", "True", ",", "stride", "=", "1", ",", "chunksize", "=", "None", ")", ":", "from", "pyemma", ".", "coordinates", ".", "pipelines", "import", "Pipeline", "if", "not", "isinstance", "(", "stages", ",", "l...
r""" Data analysis pipeline. Constructs a data analysis :class:`Pipeline <pyemma.coordinates.pipelines.Pipeline>` and parametrizes it (unless prevented). If this function takes too long, consider loading data in memory. Alternatively if the data is to large to be loaded into memory make use of the ...
[ "r", "Data", "analysis", "pipeline", "." ]
python
train
38.418605
PMBio/limix-backup
limix/varDecomp/varianceDecomposition.py
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/varDecomp/varianceDecomposition.py#L385-L395
def _det_inference(self): """ Internal method for determining the inference method """ # 2 random effects with complete design -> gp2KronSum # TODO: add check for low-rankness, use GP3KronSumLR and GP2KronSumLR when possible if (self.n_randEffs==2) and (~sp.isnan(self.Y)....
[ "def", "_det_inference", "(", "self", ")", ":", "# 2 random effects with complete design -> gp2KronSum", "# TODO: add check for low-rankness, use GP3KronSumLR and GP2KronSumLR when possible", "if", "(", "self", ".", "n_randEffs", "==", "2", ")", "and", "(", "~", "sp", ".", ...
Internal method for determining the inference method
[ "Internal", "method", "for", "determining", "the", "inference", "method" ]
python
train
36.454545
rjdkmr/do_x3dna
dnaMD/dnaMD/dnaEY.py
https://github.com/rjdkmr/do_x3dna/blob/fe910335eefcada76737f9e7cd6f25036cd32ab6/dnaMD/dnaMD/dnaEY.py#L1269-L1412
def getLocalDeformationEnergy(self, bp, complexDna, freeDnaFrames=None, boundDnaFrames=None, helical=False, unit='kT', which='all', outFile=None): r"""Deformation energy of the input DNA using local elastic properties The deformation energy of a base-step/s for probe D...
[ "def", "getLocalDeformationEnergy", "(", "self", ",", "bp", ",", "complexDna", ",", "freeDnaFrames", "=", "None", ",", "boundDnaFrames", "=", "None", ",", "helical", "=", "False", ",", "unit", "=", "'kT'", ",", "which", "=", "'all'", ",", "outFile", "=", ...
r"""Deformation energy of the input DNA using local elastic properties The deformation energy of a base-step/s for probe DNA object with reference to the same base-step/s DNA present in the current DNA object. The deformation free energy is calculated using elastic matrix as follows ....
[ "r", "Deformation", "energy", "of", "the", "input", "DNA", "using", "local", "elastic", "properties" ]
python
train
39.930556
bcbio/bcbio-nextgen
bcbio/variation/population.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/population.py#L389-L417
def prep_db_parallel(samples, parallel_fn): """Prepares gemini databases in parallel, handling jointly called populations. """ batch_groups, singles, out_retrieve, extras = _group_by_batches(samples, _has_variant_calls) to_process = [] has_batches = False for (name, caller), info in batch_groups...
[ "def", "prep_db_parallel", "(", "samples", ",", "parallel_fn", ")", ":", "batch_groups", ",", "singles", ",", "out_retrieve", ",", "extras", "=", "_group_by_batches", "(", "samples", ",", "_has_variant_calls", ")", "to_process", "=", "[", "]", "has_batches", "="...
Prepares gemini databases in parallel, handling jointly called populations.
[ "Prepares", "gemini", "databases", "in", "parallel", "handling", "jointly", "called", "populations", "." ]
python
train
41.241379
mitsei/dlkit
dlkit/handcar/learning/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/objects.py#L575-L586
def get_assessment_ids(self): """Gets the Ids of any assessments associated with this activity. return: (osid.id.IdList) - list of assessment Ids raise: IllegalState - is_assessment_based_activity() is false compliance: mandatory - This method must be implemented. """ ...
[ "def", "get_assessment_ids", "(", "self", ")", ":", "if", "not", "self", ".", "is_assessment_based_activity", "(", ")", ":", "raise", "IllegalState", "(", ")", "else", ":", "return", "[", "Id", "(", "a", ")", "for", "a", "in", "self", ".", "_my_map", "...
Gets the Ids of any assessments associated with this activity. return: (osid.id.IdList) - list of assessment Ids raise: IllegalState - is_assessment_based_activity() is false compliance: mandatory - This method must be implemented.
[ "Gets", "the", "Ids", "of", "any", "assessments", "associated", "with", "this", "activity", "." ]
python
train
38.75
Pixelapse/pyglass
pyglass/api.py
https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/api.py#L9-L23
def preview(src_path): ''' Generates a preview of src_path in the requested format. :returns: A list of preview paths, one for each page. ''' previews = [] if sketch.is_sketchfile(src_path): previews = sketch.preview(src_path) if not previews: previews = quicklook.preview(src_path) previews = [...
[ "def", "preview", "(", "src_path", ")", ":", "previews", "=", "[", "]", "if", "sketch", ".", "is_sketchfile", "(", "src_path", ")", ":", "previews", "=", "sketch", ".", "preview", "(", "src_path", ")", "if", "not", "previews", ":", "previews", "=", "qu...
Generates a preview of src_path in the requested format. :returns: A list of preview paths, one for each page.
[ "Generates", "a", "preview", "of", "src_path", "in", "the", "requested", "format", ".", ":", "returns", ":", "A", "list", "of", "preview", "paths", "one", "for", "each", "page", "." ]
python
train
24.8
projectatomic/atomic-reactor
atomic_reactor/rpm_util.py
https://github.com/projectatomic/atomic-reactor/blob/fd31c01b964097210bf169960d051e5f04019a80/atomic_reactor/rpm_util.py#L36-L95
def parse_rpm_output(output, tags=None, separator=';'): """ Parse output of the rpm query. :param output: list, decoded output (str) from the rpm subprocess :param tags: list, str fields used for query output :return: list, dicts describing each rpm package """ if tags is None: tag...
[ "def", "parse_rpm_output", "(", "output", ",", "tags", "=", "None", ",", "separator", "=", "';'", ")", ":", "if", "tags", "is", "None", ":", "tags", "=", "image_component_rpm_tags", "def", "field", "(", "tag", ")", ":", "\"\"\"\n Get a field value by na...
Parse output of the rpm query. :param output: list, decoded output (str) from the rpm subprocess :param tags: list, str fields used for query output :return: list, dicts describing each rpm package
[ "Parse", "output", "of", "the", "rpm", "query", "." ]
python
train
25.9
coldfix/udiskie
udiskie/mount.py
https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L611-L628
async def delete(self, device, remove=True): """ Detach the loop device. :param device: device object, block device path or mount path :param bool remove: whether to unmount the partition etc. :returns: whether the loop device is deleted """ device = self._find_d...
[ "async", "def", "delete", "(", "self", ",", "device", ",", "remove", "=", "True", ")", ":", "device", "=", "self", ".", "_find_device", "(", "device", ")", "if", "not", "self", ".", "is_handleable", "(", "device", ")", "or", "not", "device", ".", "is...
Detach the loop device. :param device: device object, block device path or mount path :param bool remove: whether to unmount the partition etc. :returns: whether the loop device is deleted
[ "Detach", "the", "loop", "device", "." ]
python
train
39.222222
wharris/dougrain
dougrain/builder.py
https://github.com/wharris/dougrain/blob/45062a1562fc34793e40c6253a93aa91eb4cf855/dougrain/builder.py#L106-L151
def add_link(self, rel, target, wrap=False, **kwargs): """Adds a link to the document. This method adds a link to the given ``target`` to the document with the given ``rel``. If one or more links are already present for that link relationship type, the new link will be added to the exis...
[ "def", "add_link", "(", "self", ",", "rel", ",", "target", ",", "wrap", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "target", ",", "bytes", ")", ":", "target", "=", "target", ".", "decode", "(", "'utf-8'", ")", "if", ...
Adds a link to the document. This method adds a link to the given ``target`` to the document with the given ``rel``. If one or more links are already present for that link relationship type, the new link will be added to the existing links for that link relationship type. Unlik...
[ "Adds", "a", "link", "to", "the", "document", "." ]
python
train
43.173913
vsjha18/nsetools
utils.py
https://github.com/vsjha18/nsetools/blob/c306b568471701c19195d2f17e112cc92022d3e0/utils.py#L29-L44
def byte_adaptor(fbuffer): """ provides py3 compatibility by converting byte based file stream to string based file stream Arguments: fbuffer: file like objects containing bytes Returns: string buffer """ if six.PY3: strings = fbuffer.read().decode('latin-1') fb...
[ "def", "byte_adaptor", "(", "fbuffer", ")", ":", "if", "six", ".", "PY3", ":", "strings", "=", "fbuffer", ".", "read", "(", ")", ".", "decode", "(", "'latin-1'", ")", "fbuffer", "=", "six", ".", "StringIO", "(", "strings", ")", "return", "fbuffer", "...
provides py3 compatibility by converting byte based file stream to string based file stream Arguments: fbuffer: file like objects containing bytes Returns: string buffer
[ "provides", "py3", "compatibility", "by", "converting", "byte", "based", "file", "stream", "to", "string", "based", "file", "stream" ]
python
train
24.375
openstack/horizon
openstack_dashboard/api/neutron.py
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L471-L480
def list_by_instance(self, instance_id): """Gets security groups of an instance. :returns: List of SecurityGroup objects associated with the instance """ ports = port_list(self.request, device_id=instance_id) sg_ids = [] for p in ports: sg_ids += p.security_g...
[ "def", "list_by_instance", "(", "self", ",", "instance_id", ")", ":", "ports", "=", "port_list", "(", "self", ".", "request", ",", "device_id", "=", "instance_id", ")", "sg_ids", "=", "[", "]", "for", "p", "in", "ports", ":", "sg_ids", "+=", "p", ".", ...
Gets security groups of an instance. :returns: List of SecurityGroup objects associated with the instance
[ "Gets", "security", "groups", "of", "an", "instance", "." ]
python
train
37.6
rosscdh/hellosign
hellosign/hellosign.py
https://github.com/rosscdh/hellosign/blob/4061c2733fa9f1b6ebefa99bed69df8373eb93b3/hellosign/hellosign.py#L43-L51
def add_doc(self, doc): """ Simple dict of {'name': '@filename.pdf'}""" if isinstance(doc, HelloDoc) and doc.validate(): self.docs.append(doc) else: if not doc.validate(): raise Exception("HelloDoc Errors %s" % (doc.errors,)) else: ...
[ "def", "add_doc", "(", "self", ",", "doc", ")", ":", "if", "isinstance", "(", "doc", ",", "HelloDoc", ")", "and", "doc", ".", "validate", "(", ")", ":", "self", ".", "docs", ".", "append", "(", "doc", ")", "else", ":", "if", "not", "doc", ".", ...
Simple dict of {'name': '@filename.pdf'}
[ "Simple", "dict", "of", "{", "name", ":" ]
python
train
42.666667
portfors-lab/sparkle
sparkle/data/open.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/data/open.py#L5-L29
def open_acqdata(filename, user='unknown', filemode='w-'): """Opens and returns the correct AcquisitionData object according to filename extention. Supported extentions: * .hdf5, .h5 for sparkle data * .pst, .raw for batlab data. Both the .pst and .raw file must be co-located and share the same base fi...
[ "def", "open_acqdata", "(", "filename", ",", "user", "=", "'unknown'", ",", "filemode", "=", "'w-'", ")", ":", "if", "filename", ".", "lower", "(", ")", ".", "endswith", "(", "(", "\".hdf5\"", ",", "\".h5\"", ")", ")", ":", "return", "HDF5Data", "(", ...
Opens and returns the correct AcquisitionData object according to filename extention. Supported extentions: * .hdf5, .h5 for sparkle data * .pst, .raw for batlab data. Both the .pst and .raw file must be co-located and share the same base file name, but only one should be provided to this function ...
[ "Opens", "and", "returns", "the", "correct", "AcquisitionData", "object", "according", "to", "filename", "extention", "." ]
python
train
38.52
molmod/molmod
molmod/molecules.py
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecules.py#L278-L292
def compute_rotsym(self, threshold=1e-3*angstrom): """Compute the rotational symmetry number. Optional argument: | ``threshold`` -- only when a rotation results in an rmsd below the given threshold, the rotation is considered to transform the ...
[ "def", "compute_rotsym", "(", "self", ",", "threshold", "=", "1e-3", "*", "angstrom", ")", ":", "# Generate a graph with a more permissive threshold for bond lengths:", "# (is convenient in case of transition state geometries)", "graph", "=", "MolecularGraph", ".", "from_geometry...
Compute the rotational symmetry number. Optional argument: | ``threshold`` -- only when a rotation results in an rmsd below the given threshold, the rotation is considered to transform the molecule onto itself.
[ "Compute", "the", "rotational", "symmetry", "number", "." ]
python
train
52.4
imjoey/pyhaproxy
pyhaproxy/parse.py
https://github.com/imjoey/pyhaproxy/blob/4f0904acfc6bdb29ba6104ce2f6724c0330441d3/pyhaproxy/parse.py#L57-L69
def build_global(self, global_node): """parse `global` section, and return the config.Global Args: global_node (TreeNode): `global` section treenode Returns: config.Global: an object """ config_block_lines = self.__build_config_block( globa...
[ "def", "build_global", "(", "self", ",", "global_node", ")", ":", "config_block_lines", "=", "self", ".", "__build_config_block", "(", "global_node", ".", "config_block", ")", "return", "config", ".", "Global", "(", "config_block", "=", "config_block_lines", ")" ]
parse `global` section, and return the config.Global Args: global_node (TreeNode): `global` section treenode Returns: config.Global: an object
[ "parse", "global", "section", "and", "return", "the", "config", ".", "Global" ]
python
train
30
thebigmunch/gmusicapi-wrapper
gmusicapi_wrapper/musicmanager.py
https://github.com/thebigmunch/gmusicapi-wrapper/blob/8708683cd33955def1378fc28319ef37805b851d/gmusicapi_wrapper/musicmanager.py#L265-L369
def upload(self, filepaths, enable_matching=False, transcode_quality='320k', delete_on_success=False): """Upload local songs to Google Music. Parameters: filepaths (list or str): Filepath(s) to upload. enable_matching (bool): If ``True`` attempt to use `scan and match <http://support.google.com/googlepl...
[ "def", "upload", "(", "self", ",", "filepaths", ",", "enable_matching", "=", "False", ",", "transcode_quality", "=", "'320k'", ",", "delete_on_success", "=", "False", ")", ":", "filenum", "=", "0", "total", "=", "len", "(", "filepaths", ")", "results", "="...
Upload local songs to Google Music. Parameters: filepaths (list or str): Filepath(s) to upload. enable_matching (bool): If ``True`` attempt to use `scan and match <http://support.google.com/googleplay/bin/answer.py?hl=en&answer=2920799&topic=2450455>`__. This requieres ffmpeg or avconv. transcode_...
[ "Upload", "local", "songs", "to", "Google", "Music", "." ]
python
valid
37.685714
msikma/kanaconv
kanaconv/utils.py
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/utils.py#L72-L95
def _switch_charset_list(characters, target=''): ''' Switches the character set of a list. If a character does not have an equivalent in the target script (e.g. ヹ when converting to hiragana), the original character is kept. ''' # Copy the list to avoid modifying the existing one. characters...
[ "def", "_switch_charset_list", "(", "characters", ",", "target", "=", "''", ")", ":", "# Copy the list to avoid modifying the existing one.", "characters", "=", "characters", "[", ":", "]", "offset", "=", "block_offset", "*", "offsets", "[", "target", "]", "[", "'...
Switches the character set of a list. If a character does not have an equivalent in the target script (e.g. ヹ when converting to hiragana), the original character is kept.
[ "Switches", "the", "character", "set", "of", "a", "list", ".", "If", "a", "character", "does", "not", "have", "an", "equivalent", "in", "the", "target", "script", "(", "e", ".", "g", ".", "ヹ", "when", "converting", "to", "hiragana", ")", "the", "origin...
python
train
34.583333
SMTG-UCL/sumo
sumo/plotting/dos_plotter.py
https://github.com/SMTG-UCL/sumo/blob/47aec6bbfa033a624435a65bd4edabd18bfb437f/sumo/plotting/dos_plotter.py#L190-L320
def get_plot(self, subplot=False, width=None, height=None, xmin=-6., xmax=6., yscale=1, colours=None, plot_total=True, legend_on=True, num_columns=2, legend_frame_on=False, legend_cutoff=3, xlabel='Energy (eV)', ylabel='Arb. units', zero_to_efermi=True...
[ "def", "get_plot", "(", "self", ",", "subplot", "=", "False", ",", "width", "=", "None", ",", "height", "=", "None", ",", "xmin", "=", "-", "6.", ",", "xmax", "=", "6.", ",", "yscale", "=", "1", ",", "colours", "=", "None", ",", "plot_total", "="...
Get a :obj:`matplotlib.pyplot` object of the density of states. Args: subplot (:obj:`bool`, optional): Plot the density of states for each element on separate subplots. Defaults to ``False``. width (:obj:`float`, optional): The width of the plot. height (:obj...
[ "Get", "a", ":", "obj", ":", "matplotlib", ".", "pyplot", "object", "of", "the", "density", "of", "states", "." ]
python
train
46.984733
ktbyers/netmiko
netmiko/paloalto/paloalto_panos.py
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L141-L158
def strip_context_items(self, a_string): """Strip PaloAlto-specific output. PaloAlto will also put a configuration context: [edit] This method removes those lines. """ strings_to_strip = [r"\[edit.*\]"] response_list = a_string.split(self.RESPONSE_RETURN) ...
[ "def", "strip_context_items", "(", "self", ",", "a_string", ")", ":", "strings_to_strip", "=", "[", "r\"\\[edit.*\\]\"", "]", "response_list", "=", "a_string", ".", "split", "(", "self", ".", "RESPONSE_RETURN", ")", "last_line", "=", "response_list", "[", "-", ...
Strip PaloAlto-specific output. PaloAlto will also put a configuration context: [edit] This method removes those lines.
[ "Strip", "PaloAlto", "-", "specific", "output", "." ]
python
train
28.722222
codelv/enaml-native-cli
enamlnativecli/main.py
https://github.com/codelv/enaml-native-cli/blob/81d6faa7e3dd437956f661c512031e49c0d44b63/enamlnativecli/main.py#L868-L881
def find_packages(path): """ Find all java files matching the "*Package.java" pattern within the given enaml package directory relative to the java source path. """ matches = [] root = join(path, 'src', 'main', 'java') for folder, dirnames, filenames in os.walk(root): ...
[ "def", "find_packages", "(", "path", ")", ":", "matches", "=", "[", "]", "root", "=", "join", "(", "path", ",", "'src'", ",", "'main'", ",", "'java'", ")", "for", "folder", ",", "dirnames", ",", "filenames", "in", "os", ".", "walk", "(", "root", ")...
Find all java files matching the "*Package.java" pattern within the given enaml package directory relative to the java source path.
[ "Find", "all", "java", "files", "matching", "the", "*", "Package", ".", "java", "pattern", "within", "the", "given", "enaml", "package", "directory", "relative", "to", "the", "java", "source", "path", "." ]
python
train
51.5
tensorflow/cleverhans
cleverhans/train.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/train.py#L38-L274
def train(sess, loss, x_train, y_train, init_all=False, evaluate=None, feed=None, args=None, rng=None, var_list=None, fprop_args=None, optimizer=None, devices=None, x_batch_preprocessor=None, use_ema=False, ema_decay=.998, run_canary=None, loss_threshold=1e5, dataset_tr...
[ "def", "train", "(", "sess", ",", "loss", ",", "x_train", ",", "y_train", ",", "init_all", "=", "False", ",", "evaluate", "=", "None", ",", "feed", "=", "None", ",", "args", "=", "None", ",", "rng", "=", "None", ",", "var_list", "=", "None", ",", ...
Run (optionally multi-replica, synchronous) training to minimize `loss` :param sess: TF session to use when training the graph :param loss: tensor, the loss to minimize :param x_train: numpy array with training inputs or tf Dataset :param y_train: numpy array with training outputs or tf Dataset :param init_al...
[ "Run", "(", "optionally", "multi", "-", "replica", "synchronous", ")", "training", "to", "minimize", "loss", ":", "param", "sess", ":", "TF", "session", "to", "use", "when", "training", "the", "graph", ":", "param", "loss", ":", "tensor", "the", "loss", ...
python
train
41.696203
vaexio/vaex
packages/vaex-core/vaex/dataframe.py
https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/dataframe.py#L5080-L5103
def export(self, path, column_names=None, byteorder="=", shuffle=False, selection=False, progress=None, virtual=False, sort=None, ascending=True): """Exports the DataFrame to a file written with arrow :param DataFrameLocal df: DataFrame to export :param str path: path for file :param li...
[ "def", "export", "(", "self", ",", "path", ",", "column_names", "=", "None", ",", "byteorder", "=", "\"=\"", ",", "shuffle", "=", "False", ",", "selection", "=", "False", ",", "progress", "=", "None", ",", "virtual", "=", "False", ",", "sort", "=", "...
Exports the DataFrame to a file written with arrow :param DataFrameLocal df: DataFrame to export :param str path: path for file :param lis[str] column_names: list of column names to export or None for all columns :param str byteorder: = for native, < for little endian and > for big endi...
[ "Exports", "the", "DataFrame", "to", "a", "file", "written", "with", "arrow" ]
python
test
71.75
cdriehuys/django-rest-email-auth
rest_email_auth/serializers.py
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L241-L262
def save(self): """ Send out a password reset if the provided data is valid. If the provided email address exists and is verified, a reset email is sent to the address. Returns: The password reset token if it was returned and ``None`` otherwise. ...
[ "def", "save", "(", "self", ")", ":", "try", ":", "email", "=", "models", ".", "EmailAddress", ".", "objects", ".", "get", "(", "email", "=", "self", ".", "validated_data", "[", "\"email\"", "]", ",", "is_verified", "=", "True", ")", "except", "models"...
Send out a password reset if the provided data is valid. If the provided email address exists and is verified, a reset email is sent to the address. Returns: The password reset token if it was returned and ``None`` otherwise.
[ "Send", "out", "a", "password", "reset", "if", "the", "provided", "data", "is", "valid", "." ]
python
valid
29
intelsdi-x/snap-plugin-lib-py
examples/processor/tag.py
https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/examples/processor/tag.py#L34-L55
def process(self, metrics, config): """Processes metrics. This method is called by the Snap deamon during the process phase of the execution of a Snap workflow. Examples of processing metrics include applying filtering, max, min, average functions as well as adding additional c...
[ "def", "process", "(", "self", ",", "metrics", ",", "config", ")", ":", "LOG", ".", "debug", "(", "\"Process called\"", ")", "for", "metric", "in", "metrics", ":", "metric", ".", "tags", "[", "\"instance-id\"", "]", "=", "config", "[", "\"instance-id\"", ...
Processes metrics. This method is called by the Snap deamon during the process phase of the execution of a Snap workflow. Examples of processing metrics include applying filtering, max, min, average functions as well as adding additional context to the metrics to name just a few. ...
[ "Processes", "metrics", "." ]
python
train
37.363636
CI-WATER/gsshapy
gsshapy/orm/wms_dataset.py
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/wms_dataset.py#L236-L306
def getAsKmlPngAnimation(self, session, projectFile=None, path=None, documentName=None, colorRamp=None, alpha=1.0, noDataValue=0, drawOrder=0, cellSize=None, resampleMethod='NearestNeighbour'): """ Retrieve the WMS dataset as a PNG time stamped KMZ Args: ...
[ "def", "getAsKmlPngAnimation", "(", "self", ",", "session", ",", "projectFile", "=", "None", ",", "path", "=", "None", ",", "documentName", "=", "None", ",", "colorRamp", "=", "None", ",", "alpha", "=", "1.0", ",", "noDataValue", "=", "0", ",", "drawOrde...
Retrieve the WMS dataset as a PNG time stamped KMZ Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database. projectFile(:class:`gsshapy.orm.ProjectFile`): Project file object for the GSSHA project to which the WMS dataset belong...
[ "Retrieve", "the", "WMS", "dataset", "as", "a", "PNG", "time", "stamped", "KMZ" ]
python
train
64.690141
venthur/python-debianbts
debianbts/debianbts.py
https://github.com/venthur/python-debianbts/blob/72cf11ae3458a8544142e9f365aaafe25634dd4f/debianbts/debianbts.py#L249-L282
def get_usertag(email, *tags): """Get buglists by usertags. Parameters ---------- email : str tags : tuple of strings If tags are given the dictionary is limited to the matching tags, if no tags are given all available tags are returned. Returns ------- mapping : dict ...
[ "def", "get_usertag", "(", "email", ",", "*", "tags", ")", ":", "reply", "=", "_soap_client_call", "(", "'get_usertag'", ",", "email", ",", "*", "tags", ")", "map_el", "=", "reply", "(", "'s-gensym3'", ")", "mapping", "=", "{", "}", "# element <s-gensys3> ...
Get buglists by usertags. Parameters ---------- email : str tags : tuple of strings If tags are given the dictionary is limited to the matching tags, if no tags are given all available tags are returned. Returns ------- mapping : dict a mapping of usertag -> buglist
[ "Get", "buglists", "by", "usertags", "." ]
python
train
36.323529
jorgenschaefer/elpy
elpy/server.py
https://github.com/jorgenschaefer/elpy/blob/ffd982f829b11e53f2be187c7b770423341f29bc/elpy/server.py#L217-L222
def rpc_fix_code_with_yapf(self, source, directory): """Formats Python code to conform to the PEP 8 style guide. """ source = get_source(source) return fix_code_with_yapf(source, directory)
[ "def", "rpc_fix_code_with_yapf", "(", "self", ",", "source", ",", "directory", ")", ":", "source", "=", "get_source", "(", "source", ")", "return", "fix_code_with_yapf", "(", "source", ",", "directory", ")" ]
Formats Python code to conform to the PEP 8 style guide.
[ "Formats", "Python", "code", "to", "conform", "to", "the", "PEP", "8", "style", "guide", "." ]
python
train
36.166667
Crypto-toolbox/bitex
bitex/api/WSS/bitfinex.py
https://github.com/Crypto-toolbox/bitex/blob/56d46ea3db6de5219a72dad9b052fbabc921232f/bitex/api/WSS/bitfinex.py#L215-L253
def stop(self): """ Stop all threads and modules of the client. :return: """ super(BitfinexWSS, self).stop() log.info("BitfinexWSS.stop(): Stopping client..") log.info("BitfinexWSS.stop(): Joining receiver thread..") try: self.receiver_thread...
[ "def", "stop", "(", "self", ")", ":", "super", "(", "BitfinexWSS", ",", "self", ")", ".", "stop", "(", ")", "log", ".", "info", "(", "\"BitfinexWSS.stop(): Stopping client..\"", ")", "log", ".", "info", "(", "\"BitfinexWSS.stop(): Joining receiver thread..\"", "...
Stop all threads and modules of the client. :return:
[ "Stop", "all", "threads", "and", "modules", "of", "the", "client", ".", ":", "return", ":" ]
python
train
30.74359
paperhive/ansible-ec2-inventory
ansible_ec2_inventory/ec2inventory.py
https://github.com/paperhive/ansible-ec2-inventory/blob/6a13f9de61c089a7b13bce494adceb7507971059/ansible_ec2_inventory/ec2inventory.py#L328-L333
def boto_fix_security_token_in_profile(self, connect_args): ''' monkey patch for boto issue boto/boto#2100 ''' profile = 'profile ' + self.boto_profile if boto.config.has_option(profile, 'aws_security_token'): connect_args['security_token'] = boto.config.get(profile, 'aws_security_to...
[ "def", "boto_fix_security_token_in_profile", "(", "self", ",", "connect_args", ")", ":", "profile", "=", "'profile '", "+", "self", ".", "boto_profile", "if", "boto", ".", "config", ".", "has_option", "(", "profile", ",", "'aws_security_token'", ")", ":", "conne...
monkey patch for boto issue boto/boto#2100
[ "monkey", "patch", "for", "boto", "issue", "boto", "/", "boto#2100" ]
python
train
58
bambinos/bambi
bambi/results.py
https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/results.py#L369-L402
def to_df(self, varnames=None, ranefs=False, transformed=False, chains=None): ''' Returns the MCMC samples in a nice, neat pandas DataFrame with all MCMC chains concatenated. Args: varnames (list): List of variable names to include; if None (def...
[ "def", "to_df", "(", "self", ",", "varnames", "=", "None", ",", "ranefs", "=", "False", ",", "transformed", "=", "False", ",", "chains", "=", "None", ")", ":", "# filter out unwanted variables", "names", "=", "self", ".", "_filter_names", "(", "varnames", ...
Returns the MCMC samples in a nice, neat pandas DataFrame with all MCMC chains concatenated. Args: varnames (list): List of variable names to include; if None (default), all eligible variables are included. ranefs (bool): Whether or not to include random effects ...
[ "Returns", "the", "MCMC", "samples", "in", "a", "nice", "neat", "pandas", "DataFrame", "with", "all", "MCMC", "chains", "concatenated", "." ]
python
train
42.029412
Chyroc/WechatSogou
wechatsogou/request.py
https://github.com/Chyroc/WechatSogou/blob/2e0e9886f555fd8bcfc7ae9718ced6ce955cd24a/wechatsogou/request.py#L115-L158
def gen_hot_url(hot_index, page=1): """拼接 首页热门文章 URL Parameters ---------- hot_index : WechatSogouConst.hot_index 首页热门文章的分类(常量):WechatSogouConst.hot_index.xxx page : int 页数 Returns ------- str 热门文章分类的url """ ...
[ "def", "gen_hot_url", "(", "hot_index", ",", "page", "=", "1", ")", ":", "assert", "hasattr", "(", "WechatSogouConst", ".", "hot_index", ",", "hot_index", ")", "assert", "isinstance", "(", "page", ",", "int", ")", "and", "page", ">", "0", "index_urls", "...
拼接 首页热门文章 URL Parameters ---------- hot_index : WechatSogouConst.hot_index 首页热门文章的分类(常量):WechatSogouConst.hot_index.xxx page : int 页数 Returns ------- str 热门文章分类的url
[ "拼接", "首页热门文章", "URL" ]
python
train
39.386364
SmokinCaterpillar/pypet
examples/example_05_custom_parameter.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/examples/example_05_custom_parameter.py#L128-L144
def diff_lorenz(value_array, sigma, beta, rho): """The Lorenz attractor differential equation :param value_array: 3d array containing the x,y, and z component values. :param sigma: Constant attractor parameter :param beta: FConstant attractor parameter :param rho: Constant attractor parameter ...
[ "def", "diff_lorenz", "(", "value_array", ",", "sigma", ",", "beta", ",", "rho", ")", ":", "diff_array", "=", "np", ".", "zeros", "(", "3", ")", "diff_array", "[", "0", "]", "=", "sigma", "*", "(", "value_array", "[", "1", "]", "-", "value_array", ...
The Lorenz attractor differential equation :param value_array: 3d array containing the x,y, and z component values. :param sigma: Constant attractor parameter :param beta: FConstant attractor parameter :param rho: Constant attractor parameter :return: 3d array of the Lorenz system evaluated at `va...
[ "The", "Lorenz", "attractor", "differential", "equation" ]
python
test
37.823529
a1ezzz/wasp-general
wasp_general/uri.py
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/uri.py#L478-L487
def strict_parse(cls, query_str, *specs, extra_parameters=True): """ Parse query and return :class:`.WStrictURIQuery` object :param query_str: query component of URI to parse :param specs: list of parameters specifications :param extra_parameters: whether parameters that was not specified in "specs" are allowe...
[ "def", "strict_parse", "(", "cls", ",", "query_str", ",", "*", "specs", ",", "extra_parameters", "=", "True", ")", ":", "plain_result", "=", "cls", ".", "parse", "(", "query_str", ")", "return", "WStrictURIQuery", "(", "plain_result", ",", "*", "specs", ",...
Parse query and return :class:`.WStrictURIQuery` object :param query_str: query component of URI to parse :param specs: list of parameters specifications :param extra_parameters: whether parameters that was not specified in "specs" are allowed :return: WStrictURIQuery
[ "Parse", "query", "and", "return", ":", "class", ":", ".", "WStrictURIQuery", "object" ]
python
train
46.5
wtsi-hgi/python-git-subrepo
gitsubrepo/_git.py
https://github.com/wtsi-hgi/python-git-subrepo/blob/bb2eb2bd9a7e51b862298ddb4168cc5b8633dad0/gitsubrepo/_git.py#L41-L47
def get_directory_relative_to_git_root(directory: str): """ Gets the path to the given directory relative to the git repository root in which it is a subdirectory. :param directory: the directory within a git repository :return: the path to the directory relative to the git repository root """ r...
[ "def", "get_directory_relative_to_git_root", "(", "directory", ":", "str", ")", ":", "return", "os", ".", "path", ".", "relpath", "(", "os", ".", "path", ".", "realpath", "(", "directory", ")", ",", "get_git_root_directory", "(", "directory", ")", ")" ]
Gets the path to the given directory relative to the git repository root in which it is a subdirectory. :param directory: the directory within a git repository :return: the path to the directory relative to the git repository root
[ "Gets", "the", "path", "to", "the", "given", "directory", "relative", "to", "the", "git", "repository", "root", "in", "which", "it", "is", "a", "subdirectory", ".", ":", "param", "directory", ":", "the", "directory", "within", "a", "git", "repository", ":"...
python
train
57
cloudmesh-cmd3/cmd3
cmd3/plugins/clear.py
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/clear.py#L29-L60
def do_banner(self, arg, arguments): """ :: Usage: banner [-c CHAR] [-n WIDTH] [-i INDENT] [-r COLOR] TEXT Arguments: TEXT The text message from which to create the banner CHAR The character for the frame. WID...
[ "def", "do_banner", "(", "self", ",", "arg", ",", "arguments", ")", ":", "print", "arguments", "n", "=", "int", "(", "arguments", "[", "'-n'", "]", ")", "c", "=", "arguments", "[", "'-c'", "]", "i", "=", "int", "(", "arguments", "[", "'-i'", "]", ...
:: Usage: banner [-c CHAR] [-n WIDTH] [-i INDENT] [-r COLOR] TEXT Arguments: TEXT The text message from which to create the banner CHAR The character for the frame. WIDTH Width of the banner INDENT indentatio...
[ "::" ]
python
train
34.9375
mlperf/training
rnn_translator/pytorch/seq2seq/train/fp_optimizers.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/train/fp_optimizers.py#L14-L24
def set_grads(params, params_with_grad): """ Copies gradients from param_with_grad to params :param params: dst parameters :param params_with_grad: src parameters """ for param, param_w_grad in zip(params, params_with_grad): if param.grad is None: ...
[ "def", "set_grads", "(", "params", ",", "params_with_grad", ")", ":", "for", "param", ",", "param_w_grad", "in", "zip", "(", "params", ",", "params_with_grad", ")", ":", "if", "param", ".", "grad", "is", "None", ":", "param", ".", "grad", "=", "torch", ...
Copies gradients from param_with_grad to params :param params: dst parameters :param params_with_grad: src parameters
[ "Copies", "gradients", "from", "param_with_grad", "to", "params" ]
python
train
39
googleapis/google-cloud-python
spanner/google/cloud/spanner_v1/pool.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/spanner/google/cloud/spanner_v1/pool.py#L346-L358
def bind(self, database): """Associate the pool with a database. :type database: :class:`~google.cloud.spanner_v1.database.Database` :param database: database used by the pool: used to create sessions when needed. """ self._database = database ...
[ "def", "bind", "(", "self", ",", "database", ")", ":", "self", ".", "_database", "=", "database", "for", "_", "in", "xrange", "(", "self", ".", "size", ")", ":", "session", "=", "self", ".", "_new_session", "(", ")", "session", ".", "create", "(", ...
Associate the pool with a database. :type database: :class:`~google.cloud.spanner_v1.database.Database` :param database: database used by the pool: used to create sessions when needed.
[ "Associate", "the", "pool", "with", "a", "database", "." ]
python
train
33.538462
pandas-dev/pandas
pandas/core/series.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L2069-L2132
def quantile(self, q=0.5, interpolation='linear'): """ Return value at the given quantile. Parameters ---------- q : float or array-like, default 0.5 (50% quantile) 0 <= q <= 1, the quantile(s) to compute. interpolation : {'linear', 'lower', 'higher', 'midpoi...
[ "def", "quantile", "(", "self", ",", "q", "=", "0.5", ",", "interpolation", "=", "'linear'", ")", ":", "self", ".", "_check_percentile", "(", "q", ")", "# We dispatch to DataFrame so that core.internals only has to worry", "# about 2D cases.", "df", "=", "self", "....
Return value at the given quantile. Parameters ---------- q : float or array-like, default 0.5 (50% quantile) 0 <= q <= 1, the quantile(s) to compute. interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'} .. versionadded:: 0.18.0 This ...
[ "Return", "value", "at", "the", "given", "quantile", "." ]
python
train
31.421875