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
jslang/responsys
responsys/client.py
https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/client.py#L304-L321
def delete_profile_extension_members(self, profile_extension, query_column, ids_to_delete): """ Responsys.deleteProfileExtensionRecords call Accepts: InteractObject profile_extension list field_list list ids_to_retrieve string query_column ...
[ "def", "delete_profile_extension_members", "(", "self", ",", "profile_extension", ",", "query_column", ",", "ids_to_delete", ")", ":", "profile_extension", "=", "profile_extension", ".", "get_soap_object", "(", "self", ".", "client", ")", "result", "=", "self", ".",...
Responsys.deleteProfileExtensionRecords call Accepts: InteractObject profile_extension list field_list list ids_to_retrieve string query_column default: 'RIID' Returns list of DeleteResults
[ "Responsys", ".", "deleteProfileExtensionRecords", "call" ]
python
train
40.055556
buildbot/buildbot
master/buildbot/www/change_hook.py
https://github.com/buildbot/buildbot/blob/5df3cfae6d760557d99156633c32b1822a1e130c/master/buildbot/www/change_hook.py#L113-L134
def makeHandler(self, dialect): """create and cache the handler object for this dialect""" if dialect not in self.dialects: m = "The dialect specified, '{}', wasn't whitelisted in change_hook".format(dialect) log.msg(m) log.msg( "Note: if dialect is 'b...
[ "def", "makeHandler", "(", "self", ",", "dialect", ")", ":", "if", "dialect", "not", "in", "self", ".", "dialects", ":", "m", "=", "\"The dialect specified, '{}', wasn't whitelisted in change_hook\"", ".", "format", "(", "dialect", ")", "log", ".", "msg", "(", ...
create and cache the handler object for this dialect
[ "create", "and", "cache", "the", "handler", "object", "for", "this", "dialect" ]
python
train
47.909091
androguard/androguard
androguard/core/bytecodes/axml/__init__.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/axml/__init__.py#L2684-L2692
def format_value(self): """ Return the formatted (interpreted) data according to `data_type`. """ return format_value( self.data_type, self.data, self.parent.stringpool_main.getString )
[ "def", "format_value", "(", "self", ")", ":", "return", "format_value", "(", "self", ".", "data_type", ",", "self", ".", "data", ",", "self", ".", "parent", ".", "stringpool_main", ".", "getString", ")" ]
Return the formatted (interpreted) data according to `data_type`.
[ "Return", "the", "formatted", "(", "interpreted", ")", "data", "according", "to", "data_type", "." ]
python
train
28.111111
python-diamond/Diamond
src/collectors/nagiosperfdata/nagiosperfdata.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L152-L172
def _normalize_to_unit(self, value, unit): """Normalize the value to the unit returned. We use base-1000 for second-based units, and base-1024 for byte-based units. Sadly, the Nagios-Plugins specification doesn't disambiguate base-1000 (KB) and base-1024 (KiB). """ if un...
[ "def", "_normalize_to_unit", "(", "self", ",", "value", ",", "unit", ")", ":", "if", "unit", "==", "'ms'", ":", "return", "value", "/", "1000.0", "if", "unit", "==", "'us'", ":", "return", "value", "/", "1000000.0", "if", "unit", "==", "'KB'", ":", "...
Normalize the value to the unit returned. We use base-1000 for second-based units, and base-1024 for byte-based units. Sadly, the Nagios-Plugins specification doesn't disambiguate base-1000 (KB) and base-1024 (KiB).
[ "Normalize", "the", "value", "to", "the", "unit", "returned", "." ]
python
train
33.285714
estnltk/estnltk
estnltk/wordnet/eurown.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L2037-L2045
def addInternalLink(self, link): '''Appends InternalLink ''' if isinstance(link, InternalLink): self.internalLinks.append(link) else: raise InternalLinkError( 'link Type should be InternalLink, not %s' % type(link))
[ "def", "addInternalLink", "(", "self", ",", "link", ")", ":", "if", "isinstance", "(", "link", ",", "InternalLink", ")", ":", "self", ".", "internalLinks", ".", "append", "(", "link", ")", "else", ":", "raise", "InternalLinkError", "(", "'link Type should be...
Appends InternalLink
[ "Appends", "InternalLink" ]
python
train
32.111111
mikedh/trimesh
trimesh/viewer/trackball.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/viewer/trackball.py#L220-L240
def rotate(self, azimuth, axis=None): """Rotate the trackball about the "Up" axis by azimuth radians. Parameters ---------- azimuth : float The number of radians to rotate. """ target = self._target y_axis = self._n_pose[:3, 1].flatten() if a...
[ "def", "rotate", "(", "self", ",", "azimuth", ",", "axis", "=", "None", ")", ":", "target", "=", "self", ".", "_target", "y_axis", "=", "self", ".", "_n_pose", "[", ":", "3", ",", "1", "]", ".", "flatten", "(", ")", "if", "axis", "is", "not", "...
Rotate the trackball about the "Up" axis by azimuth radians. Parameters ---------- azimuth : float The number of radians to rotate.
[ "Rotate", "the", "trackball", "about", "the", "Up", "axis", "by", "azimuth", "radians", "." ]
python
train
33.095238
daler/trackhub
trackhub/track.py
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L454-L472
def add_subgroups(self, subgroups): """ Add a list of SubGroupDefinition objects to this composite. Note that in contrast to :meth:`BaseTrack`, which takes a single dictionary indicating the particular subgroups for the track, this method takes a list of :class:`SubGroupDefiniti...
[ "def", "add_subgroups", "(", "self", ",", "subgroups", ")", ":", "if", "subgroups", "is", "None", ":", "subgroups", "=", "{", "}", "_subgroups", "=", "{", "}", "for", "sg", "in", "subgroups", ":", "assert", "isinstance", "(", "sg", ",", "SubGroupDefiniti...
Add a list of SubGroupDefinition objects to this composite. Note that in contrast to :meth:`BaseTrack`, which takes a single dictionary indicating the particular subgroups for the track, this method takes a list of :class:`SubGroupDefinition` objects representing the allowed subgroups f...
[ "Add", "a", "list", "of", "SubGroupDefinition", "objects", "to", "this", "composite", "." ]
python
train
36.789474
lk-geimfari/mimesis
mimesis/providers/numbers.py
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L20-L28
def floats(self, n: int = 2) -> List[float]: """Generate a list of random float numbers. :param n: Raise 10 to the 'n' power. :return: The list of floating-point numbers. """ nums = [self.random.random() for _ in range(10 ** int(n))] return nums
[ "def", "floats", "(", "self", ",", "n", ":", "int", "=", "2", ")", "->", "List", "[", "float", "]", ":", "nums", "=", "[", "self", ".", "random", ".", "random", "(", ")", "for", "_", "in", "range", "(", "10", "**", "int", "(", "n", ")", ")"...
Generate a list of random float numbers. :param n: Raise 10 to the 'n' power. :return: The list of floating-point numbers.
[ "Generate", "a", "list", "of", "random", "float", "numbers", "." ]
python
train
33.555556
cuihantao/andes
andes/variables/dae.py
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L582-L595
def add_jac(self, m, val, row, col): """Add tuples (val, row, col) to the Jacobian matrix ``m`` Implemented in numpy.arrays for temporary storage. """ assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx0', 'Fy0', 'Gx0', 'Gy0'), \ 'Wrong Jacobian matrix name <{0}>'.format(m) if...
[ "def", "add_jac", "(", "self", ",", "m", ",", "val", ",", "row", ",", "col", ")", ":", "assert", "m", "in", "(", "'Fx'", ",", "'Fy'", ",", "'Gx'", ",", "'Gy'", ",", "'Fx0'", ",", "'Fy0'", ",", "'Gx0'", ",", "'Gy0'", ")", ",", "'Wrong Jacobian mat...
Add tuples (val, row, col) to the Jacobian matrix ``m`` Implemented in numpy.arrays for temporary storage.
[ "Add", "tuples", "(", "val", "row", "col", ")", "to", "the", "Jacobian", "matrix", "m" ]
python
train
42.428571
zalando/patroni
patroni/utils.py
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L234-L238
def copy(self): """Return a clone of this retry manager""" return Retry(max_tries=self.max_tries, delay=self.delay, backoff=self.backoff, max_jitter=self.max_jitter / 100.0, max_delay=self.max_delay, sleep_func=self.sleep_func, deadline=self.deadline, retry_exce...
[ "def", "copy", "(", "self", ")", ":", "return", "Retry", "(", "max_tries", "=", "self", ".", "max_tries", ",", "delay", "=", "self", ".", "delay", ",", "backoff", "=", "self", ".", "backoff", ",", "max_jitter", "=", "self", ".", "max_jitter", "/", "1...
Return a clone of this retry manager
[ "Return", "a", "clone", "of", "this", "retry", "manager" ]
python
train
69
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L365-L380
def accel_fl(q: np.ndarray): """Accelaration in the earth-sun system using Fluxion potential energy""" # Infer number of dimensions from q dims: int = len(q) # Number of celestial bodies B: int = dims // 3 # The force given the positions q of the bodies f = force(q) # The accelerations...
[ "def", "accel_fl", "(", "q", ":", "np", ".", "ndarray", ")", ":", "# Infer number of dimensions from q", "dims", ":", "int", "=", "len", "(", "q", ")", "# Number of celestial bodies", "B", ":", "int", "=", "dims", "//", "3", "# The force given the positions q of...
Accelaration in the earth-sun system using Fluxion potential energy
[ "Accelaration", "in", "the", "earth", "-", "sun", "system", "using", "Fluxion", "potential", "energy" ]
python
train
26.9375
novopl/peltak
src/peltak/commands/lint.py
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/commands/lint.py#L54-L90
def lint_cli(ctx, exclude, skip_untracked, commit_only): # type: (click.Context, List[str], bool, bool) -> None """ Run pep8 and pylint on all project files. You can configure the linting paths using the lint.paths config variable. This should be a list of paths that will be linted. If a path to a dire...
[ "def", "lint_cli", "(", "ctx", ",", "exclude", ",", "skip_untracked", ",", "commit_only", ")", ":", "# type: (click.Context, List[str], bool, bool) -> None", "if", "ctx", ".", "invoked_subcommand", ":", "return", "from", "peltak", ".", "logic", "import", "lint", "li...
Run pep8 and pylint on all project files. You can configure the linting paths using the lint.paths config variable. This should be a list of paths that will be linted. If a path to a directory is given, all files in that directory and it's subdirectories will be used. The pep8 and pylint config pa...
[ "Run", "pep8", "and", "pylint", "on", "all", "project", "files", "." ]
python
train
35.513514
openstax/cnx-litezip
litezip/validate.py
https://github.com/openstax/cnx-litezip/blob/5e613f486f29fe350999d6b990d32847ac16a1b8/litezip/validate.py#L26-L33
def validate_content(*objs): """Runs the correct validator for given `obj`ects. Assumes all same type""" from .main import Collection, Module validator = { Collection: cnxml.validate_collxml, Module: cnxml.validate_cnxml, }[type(objs[0])] return validator(*[obj.file for obj in objs])
[ "def", "validate_content", "(", "*", "objs", ")", ":", "from", ".", "main", "import", "Collection", ",", "Module", "validator", "=", "{", "Collection", ":", "cnxml", ".", "validate_collxml", ",", "Module", ":", "cnxml", ".", "validate_cnxml", ",", "}", "["...
Runs the correct validator for given `obj`ects. Assumes all same type
[ "Runs", "the", "correct", "validator", "for", "given", "obj", "ects", ".", "Assumes", "all", "same", "type" ]
python
valid
39.125
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L276-L309
def is_best_response(self, own_action, opponents_actions, tol=None): """ Return True if `own_action` is a best response to `opponents_actions`. Parameters ---------- own_action : scalar(int) or array_like(float, ndim=1) An integer representing a pure action, ...
[ "def", "is_best_response", "(", "self", ",", "own_action", ",", "opponents_actions", ",", "tol", "=", "None", ")", ":", "if", "tol", "is", "None", ":", "tol", "=", "self", ".", "tol", "payoff_vector", "=", "self", ".", "payoff_vector", "(", "opponents_acti...
Return True if `own_action` is a best response to `opponents_actions`. Parameters ---------- own_action : scalar(int) or array_like(float, ndim=1) An integer representing a pure action, or an array of floats representing a mixed action. opponents_actions...
[ "Return", "True", "if", "own_action", "is", "a", "best", "response", "to", "opponents_actions", "." ]
python
train
32.529412
klahnakoski/mo-files
mo_files/__init__.py
https://github.com/klahnakoski/mo-files/blob/f6974a997cdc9fdabccb60c19edee13356a5787a/mo_files/__init__.py#L192-L202
def set_name(self, name): """ RETURN NEW FILE WITH GIVEN EXTENSION """ path = self._filename.split("/") parts = path[-1].split(".") if len(parts) == 1: path[-1] = name else: path[-1] = name + "." + parts[-1] return File("/".join(pat...
[ "def", "set_name", "(", "self", ",", "name", ")", ":", "path", "=", "self", ".", "_filename", ".", "split", "(", "\"/\"", ")", "parts", "=", "path", "[", "-", "1", "]", ".", "split", "(", "\".\"", ")", "if", "len", "(", "parts", ")", "==", "1",...
RETURN NEW FILE WITH GIVEN EXTENSION
[ "RETURN", "NEW", "FILE", "WITH", "GIVEN", "EXTENSION" ]
python
train
28.454545
rdireen/spherepy
spherepy/spherepy.py
https://github.com/rdireen/spherepy/blob/241521401d4d76851d4a1a564a365cfab8e98496/spherepy/spherepy.py#L1294-L1305
def _vector_pattern_uniform_op_right(func): """decorator for operator overloading when VectorPatternUniform is on the right""" @wraps(func) def verif(self, patt): if isinstance(patt, numbers.Number): return TransversePatternUniform(func(self, self._tdsph...
[ "def", "_vector_pattern_uniform_op_right", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "verif", "(", "self", ",", "patt", ")", ":", "if", "isinstance", "(", "patt", ",", "numbers", ".", "Number", ")", ":", "return", "TransversePatternUnif...
decorator for operator overloading when VectorPatternUniform is on the right
[ "decorator", "for", "operator", "overloading", "when", "VectorPatternUniform", "is", "on", "the", "right" ]
python
train
46.75
saltstack/salt
salt/modules/file.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L3675-L3699
def statvfs(path): ''' .. versionadded:: 2014.1.0 Perform a statvfs call against the filesystem that the file resides on CLI Example: .. code-block:: bash salt '*' file.statvfs /path/to/file ''' path = os.path.expanduser(path) if not os.path.isabs(path): raise SaltIn...
[ "def", "statvfs", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "path", ")", "if", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "raise", "SaltInvocationError", "(", "'File path must be absolute.'", ")", ...
.. versionadded:: 2014.1.0 Perform a statvfs call against the filesystem that the file resides on CLI Example: .. code-block:: bash salt '*' file.statvfs /path/to/file
[ "..", "versionadded", "::", "2014", ".", "1", ".", "0" ]
python
train
28.16
JensAstrup/pyOutlook
pyOutlook/core/main.py
https://github.com/JensAstrup/pyOutlook/blob/f4ca9d4a8629c0a41f78102ce84fab702a841167/pyOutlook/core/main.py#L243-L254
def get_folders(self): """ Returns a list of all folders for this account Returns: List[:class:`Folder <pyOutlook.core.folder.Folder>`] """ endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/' r = requests.get(endpoint, headers=self._headers) ...
[ "def", "get_folders", "(", "self", ")", ":", "endpoint", "=", "'https://outlook.office.com/api/v2.0/me/MailFolders/'", "r", "=", "requests", ".", "get", "(", "endpoint", ",", "headers", "=", "self", ".", "_headers", ")", "if", "check_response", "(", "r", ")", ...
Returns a list of all folders for this account Returns: List[:class:`Folder <pyOutlook.core.folder.Folder>`]
[ "Returns", "a", "list", "of", "all", "folders", "for", "this", "account" ]
python
train
32.916667
google/grr
grr/server/grr_response_server/artifact.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/artifact.py#L464-L514
def UploadArtifactYamlFile(file_content, overwrite=True, overwrite_system_artifacts=False): """Upload a yaml or json file as an artifact to the datastore.""" loaded_artifacts = [] registry_obj = artifact_registry.REGISTRY # Make sure all artifacts are loaded...
[ "def", "UploadArtifactYamlFile", "(", "file_content", ",", "overwrite", "=", "True", ",", "overwrite_system_artifacts", "=", "False", ")", ":", "loaded_artifacts", "=", "[", "]", "registry_obj", "=", "artifact_registry", ".", "REGISTRY", "# Make sure all artifacts are l...
Upload a yaml or json file as an artifact to the datastore.
[ "Upload", "a", "yaml", "or", "json", "file", "as", "an", "artifact", "to", "the", "datastore", "." ]
python
train
40.215686
pypa/pipenv
pipenv/vendor/jinja2/environment.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/environment.py#L100-L110
def _environment_sanity_check(environment): """Perform a sanity check on the environment.""" assert issubclass(environment.undefined, Undefined), 'undefined must ' \ 'be a subclass of undefined because filters depend on it.' assert environment.block_start_string != \ environment.variable_sta...
[ "def", "_environment_sanity_check", "(", "environment", ")", ":", "assert", "issubclass", "(", "environment", ".", "undefined", ",", "Undefined", ")", ",", "'undefined must '", "'be a subclass of undefined because filters depend on it.'", "assert", "environment", ".", "bloc...
Perform a sanity check on the environment.
[ "Perform", "a", "sanity", "check", "on", "the", "environment", "." ]
python
train
53.909091
geophysics-ubonn/reda
lib/reda/containers/ERT.py
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/ERT.py#L236-L259
def filter(self, query, inplace=True): """Use a query statement to filter data. Note that you specify the data to be removed! Parameters ---------- query : string The query string to be evaluated. Is directly provided to pandas.DataFrame.query inp...
[ "def", "filter", "(", "self", ",", "query", ",", "inplace", "=", "True", ")", ":", "with", "LogDataChanges", "(", "self", ",", "filter_action", "=", "'filter'", ",", "filter_query", "=", "query", ")", ":", "result", "=", "self", ".", "data", ".", "quer...
Use a query statement to filter data. Note that you specify the data to be removed! Parameters ---------- query : string The query string to be evaluated. Is directly provided to pandas.DataFrame.query inplace : bool if True, change the contai...
[ "Use", "a", "query", "statement", "to", "filter", "data", ".", "Note", "that", "you", "specify", "the", "data", "to", "be", "removed!" ]
python
train
32.583333
rackerlabs/simpl
simpl/config.py
https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/config.py#L958-L976
def main(): # pragma: no cover """Simple tests.""" opts = [ Option('--foo'), Option('--bar'), Option('--baz'), Option('--key', group='secret', mutually_exclusive=True), Option('--key-file', group='secret', mutually_exclusive=True), Option('--key-thing', group='se...
[ "def", "main", "(", ")", ":", "# pragma: no cover", "opts", "=", "[", "Option", "(", "'--foo'", ")", ",", "Option", "(", "'--bar'", ")", ",", "Option", "(", "'--baz'", ")", ",", "Option", "(", "'--key'", ",", "group", "=", "'secret'", ",", "mutually_ex...
Simple tests.
[ "Simple", "tests", "." ]
python
train
39.526316
saltstack/salt
salt/modules/libcloud_loadbalancer.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/libcloud_loadbalancer.py#L203-L228
def destroy_balancer(balancer_id, profile, **libcloud_kwargs): ''' Destroy a load balancer :param balancer_id: LoadBalancer ID which should be used :type balancer_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's ...
[ "def", "destroy_balancer", "(", "balancer_id", ",", "profile", ",", "*", "*", "libcloud_kwargs", ")", ":", "conn", "=", "_get_driver", "(", "profile", "=", "profile", ")", "libcloud_kwargs", "=", "salt", ".", "utils", ".", "args", ".", "clean_kwargs", "(", ...
Destroy a load balancer :param balancer_id: LoadBalancer ID which should be used :type balancer_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's destroy_balancer method :type libcloud_kwargs: ``dict`` :return: ...
[ "Destroy", "a", "load", "balancer" ]
python
train
30.692308
samuraisam/django-json-rpc
jsonrpc/__init__.py
https://github.com/samuraisam/django-json-rpc/blob/a88d744d960e828f3eb21265da0f10a694b8ebcf/jsonrpc/__init__.py#L141-L277
def jsonrpc_method(name, authenticated=False, authentication_arguments=['username', 'password'], safe=False, validate=False, site=default_site): """ Wraps a function turns it into a json-rpc method. Adds several attri...
[ "def", "jsonrpc_method", "(", "name", ",", "authenticated", "=", "False", ",", "authentication_arguments", "=", "[", "'username'", ",", "'password'", "]", ",", "safe", "=", "False", ",", "validate", "=", "False", ",", "site", "=", "default_site", ")", ":", ...
Wraps a function turns it into a json-rpc method. Adds several attributes to the function specific to the JSON-RPC machinery and adds it to the default jsonrpc_site if one isn't provided. You must import the module containing these functions in your urls.py. name The name of your metho...
[ "Wraps", "a", "function", "turns", "it", "into", "a", "json", "-", "rpc", "method", ".", "Adds", "several", "attributes", "to", "the", "function", "specific", "to", "the", "JSON", "-", "RPC", "machinery", "and", "adds", "it", "to", "the", "default", "jso...
python
train
42.817518
cgrok/clashroyale
clashroyale/official_api/client.py
https://github.com/cgrok/clashroyale/blob/2618f4da22a84ad3e36d2446e23436d87c423163/clashroyale/official_api/client.py#L589-L601
def get_rarity_info(self, rarity: str): """Returns card info from constants Parameters --------- rarity: str A rarity name Returns None or Constants """ for c in self.constants.rarities: if c.name == rarity: return c
[ "def", "get_rarity_info", "(", "self", ",", "rarity", ":", "str", ")", ":", "for", "c", "in", "self", ".", "constants", ".", "rarities", ":", "if", "c", ".", "name", "==", "rarity", ":", "return", "c" ]
Returns card info from constants Parameters --------- rarity: str A rarity name Returns None or Constants
[ "Returns", "card", "info", "from", "constants" ]
python
valid
23.230769
metakirby5/colorz
colorz.py
https://github.com/metakirby5/colorz/blob/11fd47a28d7a4af5b91d29978524335c8fef8cc9/colorz.py#L64-L71
def clamp(color, min_v, max_v): """ Clamps a color such that the value is between min_v and max_v. """ h, s, v = rgb_to_hsv(*map(down_scale, color)) min_v, max_v = map(down_scale, (min_v, max_v)) v = min(max(min_v, v), max_v) return tuple(map(up_scale, hsv_to_rgb(h, s, v)))
[ "def", "clamp", "(", "color", ",", "min_v", ",", "max_v", ")", ":", "h", ",", "s", ",", "v", "=", "rgb_to_hsv", "(", "*", "map", "(", "down_scale", ",", "color", ")", ")", "min_v", ",", "max_v", "=", "map", "(", "down_scale", ",", "(", "min_v", ...
Clamps a color such that the value is between min_v and max_v.
[ "Clamps", "a", "color", "such", "that", "the", "value", "is", "between", "min_v", "and", "max_v", "." ]
python
train
36.875
mitsei/dlkit
dlkit/json_/assessment/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1025-L1032
def _init_map(self, record_types=None, **kwargs): """Initialize form map""" osid_objects.OsidObjectForm._init_map(self, record_types=record_types) self._my_map['rubricId'] = self._rubric_default self._my_map['assignedBankIds'] = [str(kwargs['bank_id'])] self._my_map['levelId'] = ...
[ "def", "_init_map", "(", "self", ",", "record_types", "=", "None", ",", "*", "*", "kwargs", ")", ":", "osid_objects", ".", "OsidObjectForm", ".", "_init_map", "(", "self", ",", "record_types", "=", "record_types", ")", "self", ".", "_my_map", "[", "'rubric...
Initialize form map
[ "Initialize", "form", "map" ]
python
train
52.625
akfullfo/taskforce
taskforce/http.py
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/http.py#L281-L292
def getresponse(self): """ Pass-thru method to make this class behave a little like HTTPConnection """ resp = self.http.getresponse() self.log.info("resp is %s", str(resp)) if resp.status < 400: return resp else: errtext = resp.read() ...
[ "def", "getresponse", "(", "self", ")", ":", "resp", "=", "self", ".", "http", ".", "getresponse", "(", ")", "self", ".", "log", ".", "info", "(", "\"resp is %s\"", ",", "str", "(", "resp", ")", ")", "if", "resp", ".", "status", "<", "400", ":", ...
Pass-thru method to make this class behave a little like HTTPConnection
[ "Pass", "-", "thru", "method", "to", "make", "this", "class", "behave", "a", "little", "like", "HTTPConnection" ]
python
train
38.416667
sukujgrg/pptx-builder-from-yaml
pptx_builder/__init__.py
https://github.com/sukujgrg/pptx-builder-from-yaml/blob/2218290f2394a133f0937e432e588f687b2deb7b/pptx_builder/__init__.py#L176-L229
def cli(yaml_paths, pptx_template_path, font_size, master_slide_idx, slide_layout_idx, dst_dir, font_name, slide_txt_alignment, validate): """ A powerpoint builder https://github.com/sukujgrg/pptx-builder-from-yaml """ dst_dir = Path(dst_dir) pptx_template_path = Path(pptx_template_p...
[ "def", "cli", "(", "yaml_paths", ",", "pptx_template_path", ",", "font_size", ",", "master_slide_idx", ",", "slide_layout_idx", ",", "dst_dir", ",", "font_name", ",", "slide_txt_alignment", ",", "validate", ")", ":", "dst_dir", "=", "Path", "(", "dst_dir", ")", ...
A powerpoint builder https://github.com/sukujgrg/pptx-builder-from-yaml
[ "A", "powerpoint", "builder" ]
python
train
31.222222
fake-name/ChromeController
ChromeController/Generator/Generated.py
https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L66-L84
def Memory_setPressureNotificationsSuppressed(self, suppressed): """ Function path: Memory.setPressureNotificationsSuppressed Domain: Memory Method name: setPressureNotificationsSuppressed Parameters: Required arguments: 'suppressed' (type: boolean) -> If true, memory pressure notifications wil...
[ "def", "Memory_setPressureNotificationsSuppressed", "(", "self", ",", "suppressed", ")", ":", "assert", "isinstance", "(", "suppressed", ",", "(", "bool", ",", ")", ")", ",", "\"Argument 'suppressed' must be of type '['bool']'. Received type: '%s'\"", "%", "type", "(", ...
Function path: Memory.setPressureNotificationsSuppressed Domain: Memory Method name: setPressureNotificationsSuppressed Parameters: Required arguments: 'suppressed' (type: boolean) -> If true, memory pressure notifications will be suppressed. No return value. Description: Enable/disable su...
[ "Function", "path", ":", "Memory", ".", "setPressureNotificationsSuppressed", "Domain", ":", "Memory", "Method", "name", ":", "setPressureNotificationsSuppressed", "Parameters", ":", "Required", "arguments", ":", "suppressed", "(", "type", ":", "boolean", ")", "-", ...
python
train
38.105263
aloetesting/aloe_webdriver
aloe_webdriver/css.py
https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/css.py#L216-L224
def follow_link_by_selector(self, selector): """ Navigate to the href of the element matching the CSS selector. N.B. this does not click the link, but changes the browser's URL. """ elem = find_element_by_jquery(world.browser, selector) href = elem.get_attribute('href') world.browser.get(hr...
[ "def", "follow_link_by_selector", "(", "self", ",", "selector", ")", ":", "elem", "=", "find_element_by_jquery", "(", "world", ".", "browser", ",", "selector", ")", "href", "=", "elem", ".", "get_attribute", "(", "'href'", ")", "world", ".", "browser", ".", ...
Navigate to the href of the element matching the CSS selector. N.B. this does not click the link, but changes the browser's URL.
[ "Navigate", "to", "the", "href", "of", "the", "element", "matching", "the", "CSS", "selector", "." ]
python
train
35
saltstack/salt
salt/modules/boto_ec2.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_ec2.py#L1879-L1909
def get_all_tags(filters=None, region=None, key=None, keyid=None, profile=None): ''' Describe all tags matching the filter criteria, or all tags in the account otherwise. .. versionadded:: 2018.3.0 filters (dict) - Additional constraints on which volumes to return. Note that valid filters var...
[ "def", "get_all_tags", "(", "filters", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key...
Describe all tags matching the filter criteria, or all tags in the account otherwise. .. versionadded:: 2018.3.0 filters (dict) - Additional constraints on which volumes to return. Note that valid filters vary extensively depending on the resource type. When in doubt, search first without a ...
[ "Describe", "all", "tags", "matching", "the", "filter", "criteria", "or", "all", "tags", "in", "the", "account", "otherwise", "." ]
python
train
36.387097
SuperCowPowers/workbench
workbench/server/data_store.py
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L114-L122
def expire_data(self): """Expire data within the samples collection.""" # Do we need to start deleting stuff? while self.sample_storage_size() > self.samples_cap: # This should return the 'oldest' record in samples record = self.database[self.sample_collection].find().s...
[ "def", "expire_data", "(", "self", ")", ":", "# Do we need to start deleting stuff?", "while", "self", ".", "sample_storage_size", "(", ")", ">", "self", ".", "samples_cap", ":", "# This should return the 'oldest' record in samples", "record", "=", "self", ".", "databas...
Expire data within the samples collection.
[ "Expire", "data", "within", "the", "samples", "collection", "." ]
python
train
45.111111
saltstack/salt
salt/utils/gitfs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L764-L791
def fetch(self): ''' Fetch the repo. If the local copy was updated, return True. If the local copy was already up-to-date, return False. This function requires that a _fetch() function be implemented in a sub-class. ''' try: with self.gen_lock(lock_ty...
[ "def", "fetch", "(", "self", ")", ":", "try", ":", "with", "self", ".", "gen_lock", "(", "lock_type", "=", "'update'", ")", ":", "log", ".", "debug", "(", "'Fetching %s remote \\'%s\\''", ",", "self", ".", "role", ",", "self", ".", "id", ")", "# Run pr...
Fetch the repo. If the local copy was updated, return True. If the local copy was already up-to-date, return False. This function requires that a _fetch() function be implemented in a sub-class.
[ "Fetch", "the", "repo", ".", "If", "the", "local", "copy", "was", "updated", "return", "True", ".", "If", "the", "local", "copy", "was", "already", "up", "-", "to", "-", "date", "return", "False", "." ]
python
train
43.535714
osrg/ryu
ryu/services/protocols/bgp/core_managers/table_manager.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/core_managers/table_manager.py#L342-L355
def get_ipv4fs_table(self): """Returns global IPv4 Flow Specification table. Creates the table if it does not exist. """ ipv4fs_table = self._global_tables.get(RF_IPv4_FLOWSPEC) # Lazy initialization of the table. if not ipv4fs_table: ipv4fs_table = IPv4FlowS...
[ "def", "get_ipv4fs_table", "(", "self", ")", ":", "ipv4fs_table", "=", "self", ".", "_global_tables", ".", "get", "(", "RF_IPv4_FLOWSPEC", ")", "# Lazy initialization of the table.", "if", "not", "ipv4fs_table", ":", "ipv4fs_table", "=", "IPv4FlowSpecTable", "(", "s...
Returns global IPv4 Flow Specification table. Creates the table if it does not exist.
[ "Returns", "global", "IPv4", "Flow", "Specification", "table", "." ]
python
train
39.857143
h2oai/datatable
ci/make_fast.py
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/ci/make_fast.py#L15-L32
def get_files(): """ Return the list of all source/header files in `c/` directory. The files will have pathnames relative to the current folder, for example "c/csv/reader_utils.cc". """ sources = [] headers = ["datatable/include/datatable.h"] assert os.path.isfile(headers[0]) for di...
[ "def", "get_files", "(", ")", ":", "sources", "=", "[", "]", "headers", "=", "[", "\"datatable/include/datatable.h\"", "]", "assert", "os", ".", "path", ".", "isfile", "(", "headers", "[", "0", "]", ")", "for", "dirpath", ",", "_", ",", "filenames", "i...
Return the list of all source/header files in `c/` directory. The files will have pathnames relative to the current folder, for example "c/csv/reader_utils.cc".
[ "Return", "the", "list", "of", "all", "source", "/", "header", "files", "in", "c", "/", "directory", "." ]
python
train
35.444444
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L70-L76
def Pack(self, msg, type_url_prefix='type.googleapis.com/'): """Packs the specified message into current Any message.""" if len(type_url_prefix) < 1 or type_url_prefix[-1] != '/': self.type_url = '%s/%s' % (type_url_prefix, msg.DESCRIPTOR.full_name) else: self.type_url = '%s%s' % (type_url_prefi...
[ "def", "Pack", "(", "self", ",", "msg", ",", "type_url_prefix", "=", "'type.googleapis.com/'", ")", ":", "if", "len", "(", "type_url_prefix", ")", "<", "1", "or", "type_url_prefix", "[", "-", "1", "]", "!=", "'/'", ":", "self", ".", "type_url", "=", "'...
Packs the specified message into current Any message.
[ "Packs", "the", "specified", "message", "into", "current", "Any", "message", "." ]
python
train
54.714286
inspirehep/harvesting-kit
harvestingkit/inspire_cds_package/from_inspire.py
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/inspire_cds_package/from_inspire.py#L446-L457
def update_dois(self): """Remove duplicate BibMatch DOIs.""" dois = record_get_field_instances(self.record, '024', ind1="7") all_dois = {} for field in dois: subs = field_get_subfield_instances(field) subs_dict = dict(subs) if subs_dict.get('a'): ...
[ "def", "update_dois", "(", "self", ")", ":", "dois", "=", "record_get_field_instances", "(", "self", ".", "record", ",", "'024'", ",", "ind1", "=", "\"7\"", ")", "all_dois", "=", "{", "}", "for", "field", "in", "dois", ":", "subs", "=", "field_get_subfie...
Remove duplicate BibMatch DOIs.
[ "Remove", "duplicate", "BibMatch", "DOIs", "." ]
python
valid
44.5
matthiask/django-authlib
authlib/email.py
https://github.com/matthiask/django-authlib/blob/a142da7e27fe9d30f34a84b12f24f686f9d2c8e1/authlib/email.py#L90-L115
def send_registration_mail(email, *, request, **kwargs): """send_registration_mail(email, *, request, **kwargs) Sends the registration mail * ``email``: The email address where the registration link should be sent to. * ``request``: A HTTP request instance, used to construct the complete UR...
[ "def", "send_registration_mail", "(", "email", ",", "*", ",", "request", ",", "*", "*", "kwargs", ")", ":", "render_to_mail", "(", "\"registration/email_registration_email\"", ",", "{", "\"url\"", ":", "get_confirmation_url", "(", "email", ",", "request", ",", "...
send_registration_mail(email, *, request, **kwargs) Sends the registration mail * ``email``: The email address where the registration link should be sent to. * ``request``: A HTTP request instance, used to construct the complete URL (including protocol and domain) for the registration link. ...
[ "send_registration_mail", "(", "email", "*", "request", "**", "kwargs", ")", "Sends", "the", "registration", "mail" ]
python
train
40.5
orb-framework/orb
orb/core/column.py
https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/column.py#L452-L472
def store(self, value, context=None): """ Converts the value to one that is safe to store on a record within the record values dictionary :param value | <variant> :return <variant> """ if isinstance(value, (str, unicode)): value = self.value...
[ "def", "store", "(", "self", ",", "value", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "(", "str", ",", "unicode", ")", ")", ":", "value", "=", "self", ".", "valueFromString", "(", "value", ")", "# store the internatio...
Converts the value to one that is safe to store on a record within the record values dictionary :param value | <variant> :return <variant>
[ "Converts", "the", "value", "to", "one", "that", "is", "safe", "to", "store", "on", "a", "record", "within", "the", "record", "values", "dictionary" ]
python
train
30.285714
Jaymon/endpoints
endpoints/http.py
https://github.com/Jaymon/endpoints/blob/2f1c4ae2c69a168e69447d3d8395ada7becaa5fb/endpoints/http.py#L1144-L1153
def code(self): """the http status code to return to the client, by default, 200 if a body is present otherwise 204""" code = getattr(self, '_code', None) if not code: if self.has_body(): code = 200 else: code = 204 return code
[ "def", "code", "(", "self", ")", ":", "code", "=", "getattr", "(", "self", ",", "'_code'", ",", "None", ")", "if", "not", "code", ":", "if", "self", ".", "has_body", "(", ")", ":", "code", "=", "200", "else", ":", "code", "=", "204", "return", ...
the http status code to return to the client, by default, 200 if a body is present otherwise 204
[ "the", "http", "status", "code", "to", "return", "to", "the", "client", "by", "default", "200", "if", "a", "body", "is", "present", "otherwise", "204" ]
python
train
30.7
Kortemme-Lab/klab
klab/bio/pdb.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdb.py#L1755-L1766
def get_rosetta_sequence_to_atom_json_map(self): '''Returns the mapping from Rosetta residue IDs to PDB ATOM residue IDs in JSON format.''' import json if not self.rosetta_to_atom_sequence_maps and self.rosetta_sequences: raise Exception('The PDB to Rosetta mapping has not been deter...
[ "def", "get_rosetta_sequence_to_atom_json_map", "(", "self", ")", ":", "import", "json", "if", "not", "self", ".", "rosetta_to_atom_sequence_maps", "and", "self", ".", "rosetta_sequences", ":", "raise", "Exception", "(", "'The PDB to Rosetta mapping has not been determined....
Returns the mapping from Rosetta residue IDs to PDB ATOM residue IDs in JSON format.
[ "Returns", "the", "mapping", "from", "Rosetta", "residue", "IDs", "to", "PDB", "ATOM", "residue", "IDs", "in", "JSON", "format", "." ]
python
train
51.083333
timknip/pycsg
csg/core.py
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L454-L508
def cylinder(cls, **kwargs): """ Returns a cylinder. Kwargs: start (list): Start of cylinder, default [0, -1, 0]. end (list): End of cylinder, default [0, 1, 0]. radius (float): Radius of cylinder, default...
[ "def", "cylinder", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "s", "=", "kwargs", ".", "get", "(", "'start'", ",", "Vector", "(", "0.0", ",", "-", "1.0", ",", "0.0", ")", ")", "e", "=", "kwargs", ".", "get", "(", "'end'", ",", "Vector", "...
Returns a cylinder. Kwargs: start (list): Start of cylinder, default [0, -1, 0]. end (list): End of cylinder, default [0, 1, 0]. radius (float): Radius of cylinder, default 1.0. sl...
[ "Returns", "a", "cylinder", ".", "Kwargs", ":", "start", "(", "list", ")", ":", "Start", "of", "cylinder", "default", "[", "0", "-", "1", "0", "]", ".", "end", "(", "list", ")", ":", "End", "of", "cylinder", "default", "[", "0", "1", "0", "]", ...
python
train
38.781818
edx/edx-django-release-util
release_util/management/commands/__init__.py
https://github.com/edx/edx-django-release-util/blob/de0fde41d6a19885ab7dc309472b94fd0fccbc1d/release_util/management/commands/__init__.py#L247-L292
def __apply(self, migration=None, run_all=False): """ If a migration is supplied, runs that migration and appends to state. If run_all==True, runs all migrations. Raises a ValueError if neither "migration" nor "run_all" are provided. """ out = StringIO() trace = N...
[ "def", "__apply", "(", "self", ",", "migration", "=", "None", ",", "run_all", "=", "False", ")", ":", "out", "=", "StringIO", "(", ")", "trace", "=", "None", "migrate_kwargs", "=", "{", "'interactive'", ":", "False", ",", "'stdout'", ":", "out", ",", ...
If a migration is supplied, runs that migration and appends to state. If run_all==True, runs all migrations. Raises a ValueError if neither "migration" nor "run_all" are provided.
[ "If", "a", "migration", "is", "supplied", "runs", "that", "migration", "and", "appends", "to", "state", ".", "If", "run_all", "==", "True", "runs", "all", "migrations", ".", "Raises", "a", "ValueError", "if", "neither", "migration", "nor", "run_all", "are", ...
python
train
40.717391
sprockets/sprockets.mixins.amqp
sprockets/mixins/amqp/__init__.py
https://github.com/sprockets/sprockets.mixins.amqp/blob/de22b85aec1315bc01e47774637098c34525692b/sprockets/mixins/amqp/__init__.py#L428-L441
def on_connection_open(self, connection): """This method is called by pika once the connection to RabbitMQ has been established. :type connection: pika.TornadoConnection """ LOGGER.debug('Connection opened') connection.add_on_connection_blocked_callback( sel...
[ "def", "on_connection_open", "(", "self", ",", "connection", ")", ":", "LOGGER", ".", "debug", "(", "'Connection opened'", ")", "connection", ".", "add_on_connection_blocked_callback", "(", "self", ".", "on_connection_blocked", ")", "connection", ".", "add_on_connecti...
This method is called by pika once the connection to RabbitMQ has been established. :type connection: pika.TornadoConnection
[ "This", "method", "is", "called", "by", "pika", "once", "the", "connection", "to", "RabbitMQ", "has", "been", "established", "." ]
python
train
39.357143
ludeeus/pyruter
pyruter/api.py
https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/api.py#L21-L53
async def get_departures(self): """Get departure info from stopid.""" from .common import CommonFunctions common = CommonFunctions(self.loop, self.session) departures = [] endpoint = '{}/StopVisit/GetDepartures/{}'.format(BASE_URL, ...
[ "async", "def", "get_departures", "(", "self", ")", ":", "from", ".", "common", "import", "CommonFunctions", "common", "=", "CommonFunctions", "(", "self", ".", "loop", ",", "self", ".", "session", ")", "departures", "=", "[", "]", "endpoint", "=", "'{}/St...
Get departure info from stopid.
[ "Get", "departure", "info", "from", "stopid", "." ]
python
train
53.545455
ARMmbed/icetea
build_docs.py
https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/build_docs.py#L23-L60
def build_docs(location="doc-source", target=None, library="icetea_lib"): """ Build documentation for Icetea. Start by autogenerating module documentation and finish by building html. :param location: Documentation source :param target: Documentation target path :param library: Library location...
[ "def", "build_docs", "(", "location", "=", "\"doc-source\"", ",", "target", "=", "None", ",", "library", "=", "\"icetea_lib\"", ")", ":", "cmd_ar", "=", "[", "\"sphinx-apidoc\"", ",", "\"-o\"", ",", "location", ",", "library", "]", "try", ":", "print", "("...
Build documentation for Icetea. Start by autogenerating module documentation and finish by building html. :param location: Documentation source :param target: Documentation target path :param library: Library location for autodoc. :return: -1 if something fails. 0 if successfull.
[ "Build", "documentation", "for", "Icetea", ".", "Start", "by", "autogenerating", "module", "documentation", "and", "finish", "by", "building", "html", "." ]
python
train
38.473684
ManiacalLabs/BiblioPixel
bibliopixel/control/control.py
https://github.com/ManiacalLabs/BiblioPixel/blob/fd97e6c651a4bbcade64733847f4eec8f7704b7c/bibliopixel/control/control.py#L49-L69
def _receive(self, msg): """ Receive a message from the input source and perhaps raise an Exception. """ msg = self._convert(msg) if msg is None: return str_msg = self.verbose and self._msg_to_str(msg) if self.verbose and log.is_debug(): l...
[ "def", "_receive", "(", "self", ",", "msg", ")", ":", "msg", "=", "self", ".", "_convert", "(", "msg", ")", "if", "msg", "is", "None", ":", "return", "str_msg", "=", "self", ".", "verbose", "and", "self", ".", "_msg_to_str", "(", "msg", ")", "if", ...
Receive a message from the input source and perhaps raise an Exception.
[ "Receive", "a", "message", "from", "the", "input", "source", "and", "perhaps", "raise", "an", "Exception", "." ]
python
valid
31.238095
vimalkvn/riboplot
riboplot/ribocore.py
https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L260-L299
def get_ribo_counts(ribo_fileobj, transcript_name, read_lengths, read_offsets): """For each mapped read of the given transcript in the BAM file (pysam AlignmentFile object), return the position (+1) and the corresponding frame (1, 2 or 3) to which it aligns. Keyword arguments: ribo_fileobj -- file ...
[ "def", "get_ribo_counts", "(", "ribo_fileobj", ",", "transcript_name", ",", "read_lengths", ",", "read_offsets", ")", ":", "read_counts", "=", "{", "}", "total_reads", "=", "0", "for", "record", "in", "ribo_fileobj", ".", "fetch", "(", "transcript_name", ")", ...
For each mapped read of the given transcript in the BAM file (pysam AlignmentFile object), return the position (+1) and the corresponding frame (1, 2 or 3) to which it aligns. Keyword arguments: ribo_fileobj -- file object - BAM file opened using pysam AlignmentFile transcript_name -- Name of trans...
[ "For", "each", "mapped", "read", "of", "the", "given", "transcript", "in", "the", "BAM", "file", "(", "pysam", "AlignmentFile", "object", ")", "return", "the", "position", "(", "+", "1", ")", "and", "the", "corresponding", "frame", "(", "1", "2", "or", ...
python
train
41.275
mrstephenneal/mysql-toolkit
mysql/toolkit/components/operations/clone.py
https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/components/operations/clone.py#L22-L40
def _get_select_commands(self, source, tables): """ Create select queries for all of the tables from a source database. :param source: Source database name :param tables: Iterable of table names :return: Dictionary of table keys, command values """ # Create dicti...
[ "def", "_get_select_commands", "(", "self", ",", "source", ",", "tables", ")", ":", "# Create dictionary of select queries", "row_queries", "=", "{", "tbl", ":", "self", ".", "select_all", "(", "tbl", ",", "execute", "=", "False", ")", "for", "tbl", "in", "t...
Create select queries for all of the tables from a source database. :param source: Source database name :param tables: Iterable of table names :return: Dictionary of table keys, command values
[ "Create", "select", "queries", "for", "all", "of", "the", "tables", "from", "a", "source", "database", "." ]
python
train
43.421053
release-engineering/productmd
productmd/images.py
https://github.com/release-engineering/productmd/blob/49256bf2e8c84124f42346241140b986ad7bfc38/productmd/images.py#L207-L225
def identify_image(image): """Provides a tuple of image's UNIQUE_IMAGE_ATTRIBUTES. Note: this is not guaranteed to be unique (and will often not be) for pre-1.1 metadata, as subvariant did not exist. Provided as a function so consumers can use it on plain image dicts read from the metadata or PDC. ...
[ "def", "identify_image", "(", "image", ")", ":", "try", ":", "# Image instance case", "attrs", "=", "tuple", "(", "getattr", "(", "image", ",", "attr", ")", "for", "attr", "in", "UNIQUE_IMAGE_ATTRIBUTES", ")", "except", "AttributeError", ":", "# Plain dict case"...
Provides a tuple of image's UNIQUE_IMAGE_ATTRIBUTES. Note: this is not guaranteed to be unique (and will often not be) for pre-1.1 metadata, as subvariant did not exist. Provided as a function so consumers can use it on plain image dicts read from the metadata or PDC.
[ "Provides", "a", "tuple", "of", "image", "s", "UNIQUE_IMAGE_ATTRIBUTES", ".", "Note", ":", "this", "is", "not", "guaranteed", "to", "be", "unique", "(", "and", "will", "often", "not", "be", ")", "for", "pre", "-", "1", ".", "1", "metadata", "as", "subv...
python
train
45.210526
ungarj/mapchete
mapchete/io/vector.py
https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/io/vector.py#L34-L105
def reproject_geometry( geometry, src_crs=None, dst_crs=None, error_on_clip=False, validity_check=True, antimeridian_cutting=False ): """ Reproject a geometry to target CRS. Also, clips geometry if it lies outside the destination CRS boundary. Supported destination CRSes for clipping: 4326 (WGS...
[ "def", "reproject_geometry", "(", "geometry", ",", "src_crs", "=", "None", ",", "dst_crs", "=", "None", ",", "error_on_clip", "=", "False", ",", "validity_check", "=", "True", ",", "antimeridian_cutting", "=", "False", ")", ":", "src_crs", "=", "_validated_crs...
Reproject a geometry to target CRS. Also, clips geometry if it lies outside the destination CRS boundary. Supported destination CRSes for clipping: 4326 (WGS84), 3857 (Spherical Mercator) and 3035 (ETRS89 / ETRS-LAEA). Parameters ---------- geometry : ``shapely.geometry`` src_crs : ``raste...
[ "Reproject", "a", "geometry", "to", "target", "CRS", "." ]
python
valid
37.458333
saulpw/visidata
visidata/vdtui.py
https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/vdtui.py#L1651-L1697
def checkCursor(self): 'Keep cursor in bounds of data and screen.' # keep cursor within actual available rowset if self.nRows == 0 or self.cursorRowIndex <= 0: self.cursorRowIndex = 0 elif self.cursorRowIndex >= self.nRows: self.cursorRowIndex = self.nRows-1 ...
[ "def", "checkCursor", "(", "self", ")", ":", "# keep cursor within actual available rowset", "if", "self", ".", "nRows", "==", "0", "or", "self", ".", "cursorRowIndex", "<=", "0", ":", "self", ".", "cursorRowIndex", "=", "0", "elif", "self", ".", "cursorRowInd...
Keep cursor in bounds of data and screen.
[ "Keep", "cursor", "in", "bounds", "of", "data", "and", "screen", "." ]
python
train
44.042553
mcash/merchant-api-python-sdk
mcash/mapi_client/mapi_client.py
https://github.com/mcash/merchant-api-python-sdk/blob/ebe8734126790354b71077aca519ff263235944e/mcash/mapi_client/mapi_client.py#L372-L455
def update_payment_request(self, tid, currency=None, amount=None, action=None, ledger=None, callback_uri=None, display_message_uri=None, capture_id=None, additional_amount=None, text=None, refund_id=None, ...
[ "def", "update_payment_request", "(", "self", ",", "tid", ",", "currency", "=", "None", ",", "amount", "=", "None", ",", "action", "=", "None", ",", "ledger", "=", "None", ",", "callback_uri", "=", "None", ",", "display_message_uri", "=", "None", ",", "c...
Update payment request, reauthorize, capture, release or abort It is possible to update ledger and the callback URIs for a payment request. Changes are always appended to the open report of a ledger, and notifications are sent to the callback registered at the time of notification. ...
[ "Update", "payment", "request", "reauthorize", "capture", "release", "or", "abort" ]
python
train
45.5
swevm/scaleio-py
scaleiopy/api/scaleio/provisioning/volume.py
https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/provisioning/volume.py#L228-L240
def create_snapshot(self, systemId, snapshotSpecificationObject): """ Create snapshot for list of volumes :param systemID: Cluster ID :param snapshotSpecificationObject: Of class SnapshotSpecification :rtype: SnapshotGroupId """ self.conn.connection._check_login(...
[ "def", "create_snapshot", "(", "self", ",", "systemId", ",", "snapshotSpecificationObject", ")", ":", "self", ".", "conn", ".", "connection", ".", "_check_login", "(", ")", "#try:", "response", "=", "self", ".", "conn", ".", "connection", ".", "_do_post", "(...
Create snapshot for list of volumes :param systemID: Cluster ID :param snapshotSpecificationObject: Of class SnapshotSpecification :rtype: SnapshotGroupId
[ "Create", "snapshot", "for", "list", "of", "volumes", ":", "param", "systemID", ":", "Cluster", "ID", ":", "param", "snapshotSpecificationObject", ":", "Of", "class", "SnapshotSpecification", ":", "rtype", ":", "SnapshotGroupId" ]
python
train
52.307692
fulfilio/fulfil-python-api
fulfil_client/client.py
https://github.com/fulfilio/fulfil-python-api/blob/180ac969c427b1292439a0371866aa5f169ffa6b/fulfil_client/client.py#L173-L196
def login(self, login, password, set_auth=False): """ Attempts a login to the remote server and on success returns user id and session or None Warning: Do not depend on this. This will be deprecated with SSO. param set_auth: sets the authentication on the client...
[ "def", "login", "(", "self", ",", "login", ",", "password", ",", "set_auth", "=", "False", ")", ":", "rv", "=", "self", ".", "session", ".", "post", "(", "self", ".", "host", ",", "dumps", "(", "{", "\"method\"", ":", "\"common.db.login\"", ",", "\"p...
Attempts a login to the remote server and on success returns user id and session or None Warning: Do not depend on this. This will be deprecated with SSO. param set_auth: sets the authentication on the client
[ "Attempts", "a", "login", "to", "the", "remote", "server", "and", "on", "success", "returns", "user", "id", "and", "session", "or", "None" ]
python
train
27.5
danielperna84/pyhomematic
pyhomematic/devicetypes/generic.py
https://github.com/danielperna84/pyhomematic/blob/8b91f3e84c83f05d289c740d507293a0d6759d8e/pyhomematic/devicetypes/generic.py#L110-L128
def putParamset(self, paramset, data={}): """ Some devices act upon changes to paramsets. A "putted" paramset must not contain all keys available in the specified paramset, just the ones which are writable and should be changed. """ try: if paramset in self._P...
[ "def", "putParamset", "(", "self", ",", "paramset", ",", "data", "=", "{", "}", ")", ":", "try", ":", "if", "paramset", "in", "self", ".", "_PARAMSETS", "and", "data", ":", "self", ".", "_proxy", ".", "putParamset", "(", "self", ".", "_ADDRESS", ",",...
Some devices act upon changes to paramsets. A "putted" paramset must not contain all keys available in the specified paramset, just the ones which are writable and should be changed.
[ "Some", "devices", "act", "upon", "changes", "to", "paramsets", ".", "A", "putted", "paramset", "must", "not", "contain", "all", "keys", "available", "in", "the", "specified", "paramset", "just", "the", "ones", "which", "are", "writable", "and", "should", "b...
python
train
51.789474
wmayner/pyphi
pyphi/connectivity.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L26-L28
def get_outputs_from_cm(index, cm): """Return indices of the outputs of node with the given index.""" return tuple(i for i in range(cm.shape[0]) if cm[index][i])
[ "def", "get_outputs_from_cm", "(", "index", ",", "cm", ")", ":", "return", "tuple", "(", "i", "for", "i", "in", "range", "(", "cm", ".", "shape", "[", "0", "]", ")", "if", "cm", "[", "index", "]", "[", "i", "]", ")" ]
Return indices of the outputs of node with the given index.
[ "Return", "indices", "of", "the", "outputs", "of", "node", "with", "the", "given", "index", "." ]
python
train
55.666667
iotile/coretools
iotileemulate/iotile/emulate/virtual/emulation_mixin.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/emulation_mixin.py#L128-L149
def load_scenario(self, scenario_name, **kwargs): """Load a scenario into the emulated object. Scenarios are specific states of an an object that can be customized with keyword parameters. Typical examples are: - data logger with full storage - device with low battery indi...
[ "def", "load_scenario", "(", "self", ",", "scenario_name", ",", "*", "*", "kwargs", ")", ":", "scenario", "=", "self", ".", "_known_scenarios", ".", "get", "(", "scenario_name", ")", "if", "scenario", "is", "None", ":", "raise", "ArgumentError", "(", "\"Un...
Load a scenario into the emulated object. Scenarios are specific states of an an object that can be customized with keyword parameters. Typical examples are: - data logger with full storage - device with low battery indication on Args: scenario_name (str): The...
[ "Load", "a", "scenario", "into", "the", "emulated", "object", "." ]
python
train
38.545455
O365/python-o365
O365/excel.py
https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/excel.py#L615-L636
def to_api_data(self, restrict_keys=None): """ Returns a dict to communicate with the server :param restrict_keys: a set of keys to restrict the returned data to :rtype: dict """ cc = self._cc # alias data = { cc('column_hidden'): self._column_hidden, ...
[ "def", "to_api_data", "(", "self", ",", "restrict_keys", "=", "None", ")", ":", "cc", "=", "self", ".", "_cc", "# alias", "data", "=", "{", "cc", "(", "'column_hidden'", ")", ":", "self", ".", "_column_hidden", ",", "cc", "(", "'row_hidden'", ")", ":",...
Returns a dict to communicate with the server :param restrict_keys: a set of keys to restrict the returned data to :rtype: dict
[ "Returns", "a", "dict", "to", "communicate", "with", "the", "server" ]
python
train
34.909091
guaix-ucm/numina
numina/core/oresult.py
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/oresult.py#L75-L83
def get_sample_frame(self): """Return first available image in observation result""" for frame in self.frames: return frame.open() for res in self.results.values(): return res.open() return None
[ "def", "get_sample_frame", "(", "self", ")", ":", "for", "frame", "in", "self", ".", "frames", ":", "return", "frame", ".", "open", "(", ")", "for", "res", "in", "self", ".", "results", ".", "values", "(", ")", ":", "return", "res", ".", "open", "(...
Return first available image in observation result
[ "Return", "first", "available", "image", "in", "observation", "result" ]
python
train
27.111111
openvax/isovar
isovar/read_helpers.py
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/read_helpers.py#L25-L39
def get_single_allele_from_reads(allele_reads): """ Given a sequence of AlleleRead objects, which are expected to all have the same allele, return that allele. """ allele_reads = list(allele_reads) if len(allele_reads) == 0: raise ValueError("Expected non-empty list of AlleleRead object...
[ "def", "get_single_allele_from_reads", "(", "allele_reads", ")", ":", "allele_reads", "=", "list", "(", "allele_reads", ")", "if", "len", "(", "allele_reads", ")", "==", "0", ":", "raise", "ValueError", "(", "\"Expected non-empty list of AlleleRead objects\"", ")", ...
Given a sequence of AlleleRead objects, which are expected to all have the same allele, return that allele.
[ "Given", "a", "sequence", "of", "AlleleRead", "objects", "which", "are", "expected", "to", "all", "have", "the", "same", "allele", "return", "that", "allele", "." ]
python
train
36.2
gabstopper/smc-python
smc/core/sub_interfaces.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/sub_interfaces.py#L491-L509
def delete(self): """ Delete a loopback cluster virtual interface from this engine. Changes to the engine configuration are done immediately. You can find cluster virtual loopbacks by iterating at the engine level:: for loopbacks in engine.loopback_...
[ "def", "delete", "(", "self", ")", ":", "self", ".", "_engine", ".", "data", "[", "self", ".", "typeof", "]", "=", "[", "loopback", "for", "loopback", "in", "self", ".", "_engine", ".", "data", ".", "get", "(", "self", ".", "typeof", ",", "[", "]...
Delete a loopback cluster virtual interface from this engine. Changes to the engine configuration are done immediately. You can find cluster virtual loopbacks by iterating at the engine level:: for loopbacks in engine.loopback_interface: ... ...
[ "Delete", "a", "loopback", "cluster", "virtual", "interface", "from", "this", "engine", ".", "Changes", "to", "the", "engine", "configuration", "are", "done", "immediately", ".", "You", "can", "find", "cluster", "virtual", "loopbacks", "by", "iterating", "at", ...
python
train
35.210526
adafruit/Adafruit_Python_LED_Backpack
Adafruit_LED_Backpack/HT16K33.py
https://github.com/adafruit/Adafruit_Python_LED_Backpack/blob/7356b4dd8b4bb162d60987878c2cb752fdd017d5/Adafruit_LED_Backpack/HT16K33.py#L93-L96
def write_display(self): """Write display buffer to display hardware.""" for i, value in enumerate(self.buffer): self._device.write8(i, value)
[ "def", "write_display", "(", "self", ")", ":", "for", "i", ",", "value", "in", "enumerate", "(", "self", ".", "buffer", ")", ":", "self", ".", "_device", ".", "write8", "(", "i", ",", "value", ")" ]
Write display buffer to display hardware.
[ "Write", "display", "buffer", "to", "display", "hardware", "." ]
python
train
41.75
oasis-open/cti-stix-validator
stix2validator/v21/enums.py
https://github.com/oasis-open/cti-stix-validator/blob/a607014e3fa500a7678f8b61b278456ca581f9d0/stix2validator/v21/enums.py#L1659-L1683
def char_sets(): """Return a list of the IANA Character Sets, or an empty list if the IANA website is unreachable. Store it as a function attribute so that we only build the list once. """ if not hasattr(char_sets, 'setlist'): clist = [] try: data = requests.get('http://w...
[ "def", "char_sets", "(", ")", ":", "if", "not", "hasattr", "(", "char_sets", ",", "'setlist'", ")", ":", "clist", "=", "[", "]", "try", ":", "data", "=", "requests", ".", "get", "(", "'http://www.iana.org/assignments/character-'", "'sets/character-sets-1.csv'", ...
Return a list of the IANA Character Sets, or an empty list if the IANA website is unreachable. Store it as a function attribute so that we only build the list once.
[ "Return", "a", "list", "of", "the", "IANA", "Character", "Sets", "or", "an", "empty", "list", "if", "the", "IANA", "website", "is", "unreachable", ".", "Store", "it", "as", "a", "function", "attribute", "so", "that", "we", "only", "build", "the", "list",...
python
train
34.76
neuropsychology/NeuroKit.py
neurokit/miscellaneous/miscellaneous.py
https://github.com/neuropsychology/NeuroKit.py/blob/c9589348fbbde0fa7e986048c48f38e6b488adfe/neurokit/miscellaneous/miscellaneous.py#L84-L119
def get(self, reset=True): """ Get time since last initialisation / reset. Parameters ---------- reset = bool, optional Should the clock be reset after returning time? Returns ---------- float Time passed in milliseconds. ...
[ "def", "get", "(", "self", ",", "reset", "=", "True", ")", ":", "t", "=", "(", "builtin_time", ".", "clock", "(", ")", "-", "self", ".", "clock", ")", "*", "1000", "if", "reset", "is", "True", ":", "self", ".", "reset", "(", ")", "return", "(",...
Get time since last initialisation / reset. Parameters ---------- reset = bool, optional Should the clock be reset after returning time? Returns ---------- float Time passed in milliseconds. Example ---------- >>> import ...
[ "Get", "time", "since", "last", "initialisation", "/", "reset", "." ]
python
train
21.833333
lrq3000/pyFileFixity
pyFileFixity/lib/brownanrs/rs.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/brownanrs/rs.py#L225-L246
def check_fast(self, r, k=None): '''Fast check if there's any error in a message+ecc. Can be used before decoding, in addition to hashes to detect if the message was tampered, or after decoding to check that the message was fully recovered. returns True/False ''' n = self.n if no...
[ "def", "check_fast", "(", "self", ",", "r", ",", "k", "=", "None", ")", ":", "n", "=", "self", ".", "n", "if", "not", "k", ":", "k", "=", "self", ".", "k", "#h = self.h[k]", "g", "=", "self", ".", "g", "[", "k", "]", "# If we were given a string,...
Fast check if there's any error in a message+ecc. Can be used before decoding, in addition to hashes to detect if the message was tampered, or after decoding to check that the message was fully recovered. returns True/False
[ "Fast", "check", "if", "there", "s", "any", "error", "in", "a", "message", "+", "ecc", ".", "Can", "be", "used", "before", "decoding", "in", "addition", "to", "hashes", "to", "detect", "if", "the", "message", "was", "tampered", "or", "after", "decoding",...
python
train
41.181818
ranaroussi/pywallet
pywallet/utils/keys.py
https://github.com/ranaroussi/pywallet/blob/206ff224389c490d8798f660c9e79fe97ebb64cf/pywallet/utils/keys.py#L302-L313
def create_point(self, x, y): """Create an ECDSA point on the SECP256k1 curve with the given coords. :param x: The x coordinate on the curve :type x: long :param y: The y coodinate on the curve :type y: long """ if (not isinstance(x, six.integer_types) or ...
[ "def", "create_point", "(", "self", ",", "x", ",", "y", ")", ":", "if", "(", "not", "isinstance", "(", "x", ",", "six", ".", "integer_types", ")", "or", "not", "isinstance", "(", "y", ",", "six", ".", "integer_types", ")", ")", ":", "raise", "Value...
Create an ECDSA point on the SECP256k1 curve with the given coords. :param x: The x coordinate on the curve :type x: long :param y: The y coodinate on the curve :type y: long
[ "Create", "an", "ECDSA", "point", "on", "the", "SECP256k1", "curve", "with", "the", "given", "coords", "." ]
python
train
39.166667
mesowx/MesoPy
MesoPy.py
https://github.com/mesowx/MesoPy/blob/cd1e837e108ed7a110d81cf789f19afcdd52145b/MesoPy.py#L422-L495
def timeseries(self, start, end, **kwargs): r""" Returns a time series of observations at a user specified location for a specified time. Users must specify at least one geographic search parameter ('stid', 'state', 'country', 'county', 'radius', 'bbox', 'cwa', 'nwsfirezone', 'gacc', or 'subgacc...
[ "def", "timeseries", "(", "self", ",", "start", ",", "end", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_geo_param", "(", "kwargs", ")", "kwargs", "[", "'start'", "]", "=", "start", "kwargs", "[", "'end'", "]", "=", "end", "kwargs", "[", ...
r""" Returns a time series of observations at a user specified location for a specified time. Users must specify at least one geographic search parameter ('stid', 'state', 'country', 'county', 'radius', 'bbox', 'cwa', 'nwsfirezone', 'gacc', or 'subgacc') to obtain observation data. Other parameters may ...
[ "r", "Returns", "a", "time", "series", "of", "observations", "at", "a", "user", "specified", "location", "for", "a", "specified", "time", ".", "Users", "must", "specify", "at", "least", "one", "geographic", "search", "parameter", "(", "stid", "state", "count...
python
train
58.391892
log2timeline/dfvfs
dfvfs/vfs/sqlite_blob_file_system.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/sqlite_blob_file_system.py#L83-L102
def GetFileEntryByPathSpec(self, path_spec): """Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification. Returns: FileEntry: a file entry or None. """ row_index = getattr(path_spec, 'row_index', None) row_condition = getattr(path_spec, 'row_c...
[ "def", "GetFileEntryByPathSpec", "(", "self", ",", "path_spec", ")", ":", "row_index", "=", "getattr", "(", "path_spec", ",", "'row_index'", ",", "None", ")", "row_condition", "=", "getattr", "(", "path_spec", ",", "'row_condition'", ",", "None", ")", "# If no...
Retrieves a file entry for a path specification. Args: path_spec (PathSpec): path specification. Returns: FileEntry: a file entry or None.
[ "Retrieves", "a", "file", "entry", "for", "a", "path", "specification", "." ]
python
train
34.8
adewes/blitzdb
blitzdb/backends/mongo/backend.py
https://github.com/adewes/blitzdb/blob/4b459e0bcde9e1f6224dd4e3bea74194586864b0/blitzdb/backends/mongo/backend.py#L294-L334
def _canonicalize_query(self, query): """ Transform the query dictionary to replace e.g. documents with __ref__ fields. """ def transform_query(q): for encoder in self.query_encoders: q = encoder.encode(q,[]) if isinstance(q, dict): ...
[ "def", "_canonicalize_query", "(", "self", ",", "query", ")", ":", "def", "transform_query", "(", "q", ")", ":", "for", "encoder", "in", "self", ".", "query_encoders", ":", "q", "=", "encoder", ".", "encode", "(", "q", ",", "[", "]", ")", "if", "isin...
Transform the query dictionary to replace e.g. documents with __ref__ fields.
[ "Transform", "the", "query", "dictionary", "to", "replace", "e", ".", "g", ".", "documents", "with", "__ref__", "fields", "." ]
python
train
39.390244
bitesofcode/projexui
projexui/widgets/xcalendarwidget/xcalendarwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcalendarwidget/xcalendarwidget.py#L107-L119
def dragMoveEvent( self, event ): """ Processes the drag drop event using the filter set by the \ setDragDropFilter :param event | <QDragEvent> """ filt = self.dragDropFilter() if ( not filt ): super(XCalendarWidget, self).dragMo...
[ "def", "dragMoveEvent", "(", "self", ",", "event", ")", ":", "filt", "=", "self", ".", "dragDropFilter", "(", ")", "if", "(", "not", "filt", ")", ":", "super", "(", "XCalendarWidget", ",", "self", ")", ".", "dragMoveEvent", "(", "event", ")", "return",...
Processes the drag drop event using the filter set by the \ setDragDropFilter :param event | <QDragEvent>
[ "Processes", "the", "drag", "drop", "event", "using", "the", "filter", "set", "by", "the", "\\", "setDragDropFilter", ":", "param", "event", "|", "<QDragEvent", ">" ]
python
train
29.153846
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/__init__.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L136-L173
def cmd_map(self, args): '''map commands''' from MAVProxy.modules.mavproxy_map import mp_slipmap if len(args) < 1: print("usage: map <icon|set>") elif args[0] == "icon": if len(args) < 3: print("Usage: map icon <lat> <lon> <icon>") else...
[ "def", "cmd_map", "(", "self", ",", "args", ")", ":", "from", "MAVProxy", ".", "modules", ".", "mavproxy_map", "import", "mp_slipmap", "if", "len", "(", "args", ")", "<", "1", ":", "print", "(", "\"usage: map <icon|set>\"", ")", "elif", "args", "[", "0",...
map commands
[ "map", "commands" ]
python
train
40.789474
MrYsLab/pymata-aio
pymata_aio/pymata_iot.py
https://github.com/MrYsLab/pymata-aio/blob/015081a4628b9d47dfe3f8d6c698ff903f107810/pymata_aio/pymata_iot.py#L374-L411
async def i2c_read_request(self, command): """ This method sends an I2C read request to Firmata. It is qualified by a single shot, continuous read, or stop reading command. Special Note: for the read type supply one of the following string values: "0" = I2C_READ "1" =...
[ "async", "def", "i2c_read_request", "(", "self", ",", "command", ")", ":", "device_address", "=", "int", "(", "command", "[", "0", "]", ")", "register", "=", "int", "(", "command", "[", "1", "]", ")", "number_of_bytes", "=", "int", "(", "command", "[",...
This method sends an I2C read request to Firmata. It is qualified by a single shot, continuous read, or stop reading command. Special Note: for the read type supply one of the following string values: "0" = I2C_READ "1" = I2C_READ | I2C_END_TX_MASK" "2" = I2C_READ_CONTINUOU...
[ "This", "method", "sends", "an", "I2C", "read", "request", "to", "Firmata", ".", "It", "is", "qualified", "by", "a", "single", "shot", "continuous", "read", "or", "stop", "reading", "command", ".", "Special", "Note", ":", "for", "the", "read", "type", "s...
python
train
39.421053
tensorlayer/tensorlayer
tensorlayer/visualize.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/visualize.py#L34-L50
def read_image(image, path=''): """Read one image. Parameters ----------- image : str The image file name. path : str The image folder path. Returns ------- numpy.array The image. """ return imageio.imread(os.path.join(path, image))
[ "def", "read_image", "(", "image", ",", "path", "=", "''", ")", ":", "return", "imageio", ".", "imread", "(", "os", ".", "path", ".", "join", "(", "path", ",", "image", ")", ")" ]
Read one image. Parameters ----------- image : str The image file name. path : str The image folder path. Returns ------- numpy.array The image.
[ "Read", "one", "image", "." ]
python
valid
16.647059
quiltdata/quilt
compiler/quilt/util.py
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/util.py#L9-L22
def save(package, data, params={}, is_public=False): """Build and push data to Quilt registry at user/package/data_node, associating params as metadata for the data node. :param package: short package specifier string, i.e. 'team:user/pkg/subpath' :param data: data to save (np.ndarray or pd.DataFrame) ...
[ "def", "save", "(", "package", ",", "data", ",", "params", "=", "{", "}", ",", "is_public", "=", "False", ")", ":", "for", "key", ",", "value", "in", "params", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "np", ".", "ndarra...
Build and push data to Quilt registry at user/package/data_node, associating params as metadata for the data node. :param package: short package specifier string, i.e. 'team:user/pkg/subpath' :param data: data to save (np.ndarray or pd.DataFrame) :param params: metadata dictionary :param is_public: ...
[ "Build", "and", "push", "data", "to", "Quilt", "registry", "at", "user", "/", "package", "/", "data_node", "associating", "params", "as", "metadata", "for", "the", "data", "node", ".", ":", "param", "package", ":", "short", "package", "specifier", "string", ...
python
train
50.142857
wesm/feather
cpp/build-support/cpplint.py
https://github.com/wesm/feather/blob/99267b30461c46b9e437f95e1d9338a92a854270/cpp/build-support/cpplint.py#L4501-L4525
def _DropCommonSuffixes(filename): """Drops common suffixes like _test.cc or -inl.h from filename. For example: >>> _DropCommonSuffixes('foo/foo-inl.h') 'foo/foo' >>> _DropCommonSuffixes('foo/bar/foo.cc') 'foo/bar/foo' >>> _DropCommonSuffixes('foo/foo_internal.h') 'foo/foo' >>> _DropCom...
[ "def", "_DropCommonSuffixes", "(", "filename", ")", ":", "for", "suffix", "in", "(", "'test.cc'", ",", "'regtest.cc'", ",", "'unittest.cc'", ",", "'inl.h'", ",", "'impl.h'", ",", "'internal.h'", ")", ":", "if", "(", "filename", ".", "endswith", "(", "suffix"...
Drops common suffixes like _test.cc or -inl.h from filename. For example: >>> _DropCommonSuffixes('foo/foo-inl.h') 'foo/foo' >>> _DropCommonSuffixes('foo/bar/foo.cc') 'foo/bar/foo' >>> _DropCommonSuffixes('foo/foo_internal.h') 'foo/foo' >>> _DropCommonSuffixes('foo/foo_unusualinternal.h')...
[ "Drops", "common", "suffixes", "like", "_test", ".", "cc", "or", "-", "inl", ".", "h", "from", "filename", "." ]
python
train
31.4
gwastro/pycbc
pycbc/tmpltbank/option_utils.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/option_utils.py#L236-L245
def psd(self): """ A pyCBC FrequencySeries holding the appropriate PSD. Return the PSD used in the metric calculation. """ if not self._psd: errMsg = "The PSD has not been set in the metricParameters " errMsg += "instance." raise ValueError(err...
[ "def", "psd", "(", "self", ")", ":", "if", "not", "self", ".", "_psd", ":", "errMsg", "=", "\"The PSD has not been set in the metricParameters \"", "errMsg", "+=", "\"instance.\"", "raise", "ValueError", "(", "errMsg", ")", "return", "self", ".", "_psd" ]
A pyCBC FrequencySeries holding the appropriate PSD. Return the PSD used in the metric calculation.
[ "A", "pyCBC", "FrequencySeries", "holding", "the", "appropriate", "PSD", ".", "Return", "the", "PSD", "used", "in", "the", "metric", "calculation", "." ]
python
train
34
invenia/Arbiter
arbiter/scheduler.py
https://github.com/invenia/Arbiter/blob/51008393ae8797da85bcd67807259a157f941dfd/arbiter/scheduler.py#L145-L152
def fail_remaining(self): """ Mark all unfinished tasks (including currently running ones) as failed. """ self._failed.update(self._graph.nodes) self._graph = Graph() self._running = set()
[ "def", "fail_remaining", "(", "self", ")", ":", "self", ".", "_failed", ".", "update", "(", "self", ".", "_graph", ".", "nodes", ")", "self", ".", "_graph", "=", "Graph", "(", ")", "self", ".", "_running", "=", "set", "(", ")" ]
Mark all unfinished tasks (including currently running ones) as failed.
[ "Mark", "all", "unfinished", "tasks", "(", "including", "currently", "running", "ones", ")", "as", "failed", "." ]
python
train
29.625
abseil/abseil-py
absl/flags/_flagvalues.py
https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L888-L892
def _render_our_module_flags(self, module, output_lines, prefix=''): """Returns a help string for a given module.""" flags = self._get_flags_defined_by_module(module) if flags: self._render_module_flags(module, flags, output_lines, prefix)
[ "def", "_render_our_module_flags", "(", "self", ",", "module", ",", "output_lines", ",", "prefix", "=", "''", ")", ":", "flags", "=", "self", ".", "_get_flags_defined_by_module", "(", "module", ")", "if", "flags", ":", "self", ".", "_render_module_flags", "(",...
Returns a help string for a given module.
[ "Returns", "a", "help", "string", "for", "a", "given", "module", "." ]
python
train
50.6
joferkington/mplstereonet
mplstereonet/contouring.py
https://github.com/joferkington/mplstereonet/blob/f6d78ca49807915d4223e864e12bb24d497cc2d6/mplstereonet/contouring.py#L209-L214
def _kamb_count(cos_dist, sigma=3): """Original Kamb kernel function (raw count within radius).""" n = float(cos_dist.size) dist = _kamb_radius(n, sigma) count = (cos_dist >= dist).astype(float) return count, _kamb_units(n, dist)
[ "def", "_kamb_count", "(", "cos_dist", ",", "sigma", "=", "3", ")", ":", "n", "=", "float", "(", "cos_dist", ".", "size", ")", "dist", "=", "_kamb_radius", "(", "n", ",", "sigma", ")", "count", "=", "(", "cos_dist", ">=", "dist", ")", ".", "astype"...
Original Kamb kernel function (raw count within radius).
[ "Original", "Kamb", "kernel", "function", "(", "raw", "count", "within", "radius", ")", "." ]
python
train
40.666667
striglia/stockfighter
stockfighter/stockfighter.py
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L107-L118
def cancel_order(self, order_id, stock): """Cancel An Order https://starfighter.readme.io/docs/cancel-an-order """ url_fragment = 'venues/{venue}/stocks/{stock}/orders/{order_id}'.format( venue=self.venue, stock=stock, order_id=order_id, ) ...
[ "def", "cancel_order", "(", "self", ",", "order_id", ",", "stock", ")", ":", "url_fragment", "=", "'venues/{venue}/stocks/{stock}/orders/{order_id}'", ".", "format", "(", "venue", "=", "self", ".", "venue", ",", "stock", "=", "stock", ",", "order_id", "=", "or...
Cancel An Order https://starfighter.readme.io/docs/cancel-an-order
[ "Cancel", "An", "Order" ]
python
train
33.583333
LogicalDash/LiSE
allegedb/allegedb/query.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/query.py#L295-L314
def _flush_graph_val(self): """Send all new and changed graph values to the database.""" if not self._graphvals2set: return delafter = {} for graph, key, branch, turn, tick, value in self._graphvals2set: if (graph, key, branch) in delafter: delafte...
[ "def", "_flush_graph_val", "(", "self", ")", ":", "if", "not", "self", ".", "_graphvals2set", ":", "return", "delafter", "=", "{", "}", "for", "graph", ",", "key", ",", "branch", ",", "turn", ",", "tick", ",", "value", "in", "self", ".", "_graphvals2se...
Send all new and changed graph values to the database.
[ "Send", "all", "new", "and", "changed", "graph", "values", "to", "the", "database", "." ]
python
train
40.1
praekeltfoundation/seed-control-interface-service
services/tasks.py
https://github.com/praekeltfoundation/seed-control-interface-service/blob/0c8ec58ae61e72d4443e6c9a4d8b7dd12dd8a86e/services/tasks.py#L23-L37
def run(self, target, payload, instance_id=None, hook_id=None, **kwargs): """ target: the url to receive the payload. payload: a python primitive data structure instance_id: a possibly None "trigger" instance ID hook_id: the ID of defining Hook object """ ...
[ "def", "run", "(", "self", ",", "target", ",", "payload", ",", "instance_id", "=", "None", ",", "hook_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "requests", ".", "post", "(", "url", "=", "target", ",", "data", "=", "json", ".", "dumps", ...
target: the url to receive the payload. payload: a python primitive data structure instance_id: a possibly None "trigger" instance ID hook_id: the ID of defining Hook object
[ "target", ":", "the", "url", "to", "receive", "the", "payload", ".", "payload", ":", "a", "python", "primitive", "data", "structure", "instance_id", ":", "a", "possibly", "None", "trigger", "instance", "ID", "hook_id", ":", "the", "ID", "of", "defining", "...
python
train
37.2
MinchinWeb/colourettu
tasks.py
https://github.com/MinchinWeb/colourettu/blob/f0b2f6b1d44055f3ccee62ac2759829f1e16a252/tasks.py#L199-L246
def make_release(cts): '''Make and upload the release. Changelog: - v0.2.1 -- 2016-11-18 -- specify downloading of non-cached version of the package for multiple formats can be properly and individually tested. - 0.2.2 -- 2016-11028 -- mov...
[ "def", "make_release", "(", "cts", ")", ":", "make_release_version", "=", "__version__", "colorama", ".", "init", "(", ")", "text", ".", "title", "(", "\"Minchin 'Make Release' for Python v{}\"", ".", "format", "(", "make_release_version", ")", ")", "print", "(", ...
Make and upload the release. Changelog: - v0.2.1 -- 2016-11-18 -- specify downloading of non-cached version of the package for multiple formats can be properly and individually tested. - 0.2.2 -- 2016-11028 -- move configuration to top of file
[ "Make", "and", "upload", "the", "release", "." ]
python
train
36.6875
MrYsLab/pymata-aio
pymata_aio/pymata_core.py
https://github.com/MrYsLab/pymata-aio/blob/015081a4628b9d47dfe3f8d6c698ff903f107810/pymata_aio/pymata_core.py#L1945-L1975
async def _process_latching(self, key, latching_entry): """ This is a private utility method. This method process latching events and either returns them via callback or stores them in the latch map :param key: Encoded pin :param latching_entry: a latch table entry ...
[ "async", "def", "_process_latching", "(", "self", ",", "key", ",", "latching_entry", ")", ":", "if", "latching_entry", "[", "Constants", ".", "LATCH_CALLBACK", "]", ":", "# auto clear entry and execute the callback", "if", "latching_entry", "[", "Constants", ".", "L...
This is a private utility method. This method process latching events and either returns them via callback or stores them in the latch map :param key: Encoded pin :param latching_entry: a latch table entry :returns: Callback or store data in latch map
[ "This", "is", "a", "private", "utility", "method", ".", "This", "method", "process", "latching", "events", "and", "either", "returns", "them", "via", "callback", "or", "stores", "them", "in", "the", "latch", "map" ]
python
train
43.612903
edx/XBlock
xblock/fields.py
https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/fields.py#L874-L888
def _sanitize(self, value): """ Remove the control characters that are not allowed in XML: https://www.w3.org/TR/xml/#charsets Leave all other characters. """ if isinstance(value, six.binary_type): value = value.decode('utf-8') if isinstance(value, six...
[ "def", "_sanitize", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "binary_type", ")", ":", "value", "=", "value", ".", "decode", "(", "'utf-8'", ")", "if", "isinstance", "(", "value", ",", "six", ".", "text_t...
Remove the control characters that are not allowed in XML: https://www.w3.org/TR/xml/#charsets Leave all other characters.
[ "Remove", "the", "control", "characters", "that", "are", "not", "allowed", "in", "XML", ":", "https", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "xml", "/", "#charsets", "Leave", "all", "other", "characters", "." ]
python
train
47.666667
tensorlayer/tensorlayer
tensorlayer/files/utils.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/files/utils.py#L937-L974
def download_file_from_google_drive(ID, destination): """Download file from Google Drive. See ``tl.files.load_celebA_dataset`` for example. Parameters -------------- ID : str The driver ID. destination : str The destination for save file. """ def save_response_content...
[ "def", "download_file_from_google_drive", "(", "ID", ",", "destination", ")", ":", "def", "save_response_content", "(", "response", ",", "destination", ",", "chunk_size", "=", "32", "*", "1024", ")", ":", "total_size", "=", "int", "(", "response", ".", "header...
Download file from Google Drive. See ``tl.files.load_celebA_dataset`` for example. Parameters -------------- ID : str The driver ID. destination : str The destination for save file.
[ "Download", "file", "from", "Google", "Drive", "." ]
python
valid
33
openvax/pyensembl
pyensembl/locus.py
https://github.com/openvax/pyensembl/blob/4b995fb72e848206d6fbf11950cf30964cd9b3aa/pyensembl/locus.py#L136-L158
def offset_range(self, start, end): """ Database start/end entries are always ordered such that start < end. This makes computing a relative position (e.g. of a stop codon relative to its transcript) complicated since the "end" position of a backwards locus is actually earlir on ...
[ "def", "offset_range", "(", "self", ",", "start", ",", "end", ")", ":", "assert", "start", "<=", "end", ",", "\"Locations should always have start < end, got start=%d, end=%d\"", "%", "(", "start", ",", "end", ")", "if", "start", "<", "self", ".", "start", "or...
Database start/end entries are always ordered such that start < end. This makes computing a relative position (e.g. of a stop codon relative to its transcript) complicated since the "end" position of a backwards locus is actually earlir on the strand. This function correctly selects a st...
[ "Database", "start", "/", "end", "entries", "are", "always", "ordered", "such", "that", "start", "<", "end", ".", "This", "makes", "computing", "a", "relative", "position", "(", "e", ".", "g", ".", "of", "a", "stop", "codon", "relative", "to", "its", "...
python
train
42.130435
blockstack/blockstack-core
blockstack/lib/rpc.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L905-L921
def GET_user_profile( self, path_info, user_id ): """ Get a user profile. Reply the profile on success Return 404 on failure to load """ if not check_name(user_id) and not check_subdomain(user_id): return self._reply_json({'error': 'Invalid name or subdomain'}...
[ "def", "GET_user_profile", "(", "self", ",", "path_info", ",", "user_id", ")", ":", "if", "not", "check_name", "(", "user_id", ")", "and", "not", "check_subdomain", "(", "user_id", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", ...
Get a user profile. Reply the profile on success Return 404 on failure to load
[ "Get", "a", "user", "profile", ".", "Reply", "the", "profile", "on", "success", "Return", "404", "on", "failure", "to", "load" ]
python
train
37.470588
wummel/patool
patoolib/programs/xz.py
https://github.com/wummel/patool/blob/d7e64d9fd60faaa4b3f824bd97c43ce59b185c40/patoolib/programs/xz.py#L24-L31
def list_xz (archive, compression, cmd, verbosity, interactive): """List a XZ archive.""" cmdlist = [cmd] cmdlist.append('-l') if verbosity > 1: cmdlist.append('-v') cmdlist.append(archive) return cmdlist
[ "def", "list_xz", "(", "archive", ",", "compression", ",", "cmd", ",", "verbosity", ",", "interactive", ")", ":", "cmdlist", "=", "[", "cmd", "]", "cmdlist", ".", "append", "(", "'-l'", ")", "if", "verbosity", ">", "1", ":", "cmdlist", ".", "append", ...
List a XZ archive.
[ "List", "a", "XZ", "archive", "." ]
python
train
28.625
tensorflow/tensor2tensor
tensor2tensor/models/image_transformer_2d.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L501-L519
def imagetransformer_base_10l_8h_big_uncond_dr03_dan_64_2d(): """big 1d model for unconditional generation on imagenet.""" hparams = image_transformer2d_base() hparams.unconditional = True hparams.hidden_size = 512 hparams.batch_size = 1 hparams.img_len = 64 hparams.num_heads = 8 hparams.filter_size = 2...
[ "def", "imagetransformer_base_10l_8h_big_uncond_dr03_dan_64_2d", "(", ")", ":", "hparams", "=", "image_transformer2d_base", "(", ")", "hparams", ".", "unconditional", "=", "True", "hparams", ".", "hidden_size", "=", "512", "hparams", ".", "batch_size", "=", "1", "hp...
big 1d model for unconditional generation on imagenet.
[ "big", "1d", "model", "for", "unconditional", "generation", "on", "imagenet", "." ]
python
train
34.894737
pypa/setuptools
setuptools/dep_util.py
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/dep_util.py#L6-L23
def newer_pairwise_group(sources_groups, targets): """Walk both arguments in parallel, testing if each source group is newer than its corresponding target. Returns a pair of lists (sources_groups, targets) where sources is newer than target, according to the semantics of 'newer_group()'. """ if ...
[ "def", "newer_pairwise_group", "(", "sources_groups", ",", "targets", ")", ":", "if", "len", "(", "sources_groups", ")", "!=", "len", "(", "targets", ")", ":", "raise", "ValueError", "(", "\"'sources_group' and 'targets' must be the same length\"", ")", "# build a pai...
Walk both arguments in parallel, testing if each source group is newer than its corresponding target. Returns a pair of lists (sources_groups, targets) where sources is newer than target, according to the semantics of 'newer_group()'.
[ "Walk", "both", "arguments", "in", "parallel", "testing", "if", "each", "source", "group", "is", "newer", "than", "its", "corresponding", "target", ".", "Returns", "a", "pair", "of", "lists", "(", "sources_groups", "targets", ")", "where", "sources", "is", "...
python
train
41.888889
ninuxorg/nodeshot
nodeshot/community/notifications/views.py
https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/community/notifications/views.py#L48-L60
def get_unread(self, request, notifications, mark_as_read): """ return unread notifications and mark as read (unless read=false param is passed) """ notifications = notifications.filter(is_read=False) serializer = UnreadNotificationSerializer(list(notifications), # evalu...
[ "def", "get_unread", "(", "self", ",", "request", ",", "notifications", ",", "mark_as_read", ")", ":", "notifications", "=", "notifications", ".", "filter", "(", "is_read", "=", "False", ")", "serializer", "=", "UnreadNotificationSerializer", "(", "list", "(", ...
return unread notifications and mark as read (unless read=false param is passed)
[ "return", "unread", "notifications", "and", "mark", "as", "read", "(", "unless", "read", "=", "false", "param", "is", "passed", ")" ]
python
train
50.076923
elastic/elasticsearch-py
elasticsearch/client/xpack/ilm.py
https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ilm.py#L6-L14
def delete_lifecycle(self, policy=None, params=None): """ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_ :arg policy: The name of the index lifecycle policy """ return self.transport.perform_request( "DELETE", _make_pat...
[ "def", "delete_lifecycle", "(", "self", ",", "policy", "=", "None", ",", "params", "=", "None", ")", ":", "return", "self", ".", "transport", ".", "perform_request", "(", "\"DELETE\"", ",", "_make_path", "(", "\"_ilm\"", ",", "\"policy\"", ",", "policy", "...
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_ :arg policy: The name of the index lifecycle policy
[ "<https", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "ilm", "-", "delete", "-", "lifecycle", ".", "html", ">", "_" ]
python
train
40.444444
rstoneback/pysatMagVect
pysatMagVect/_core.py
https://github.com/rstoneback/pysatMagVect/blob/3fdc87ffbe05be58123f80f880d1237c2f34c7be/pysatMagVect/_core.py#L24-L48
def geocentric_to_ecef(latitude, longitude, altitude): """Convert geocentric coordinates into ECEF Parameters ---------- latitude : float or array_like Geocentric latitude (degrees) longitude : float or array_like Geocentric longitude (degrees) altitude : float or array_like...
[ "def", "geocentric_to_ecef", "(", "latitude", ",", "longitude", ",", "altitude", ")", ":", "r", "=", "earth_geo_radius", "+", "altitude", "x", "=", "r", "*", "np", ".", "cos", "(", "np", ".", "deg2rad", "(", "latitude", ")", ")", "*", "np", ".", "cos...
Convert geocentric coordinates into ECEF Parameters ---------- latitude : float or array_like Geocentric latitude (degrees) longitude : float or array_like Geocentric longitude (degrees) altitude : float or array_like Height (km) above presumed spherical Earth with radiu...
[ "Convert", "geocentric", "coordinates", "into", "ECEF", "Parameters", "----------", "latitude", ":", "float", "or", "array_like", "Geocentric", "latitude", "(", "degrees", ")", "longitude", ":", "float", "or", "array_like", "Geocentric", "longitude", "(", "degrees",...
python
train
28.88
saltstack/salt
salt/modules/layman.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/layman.py#L68-L98
def delete(overlay): ''' Remove the given overlay from the your locally installed overlays. Specify 'ALL' to remove all overlays. Return a list of the overlays(s) that were removed: CLI Example: .. code-block:: bash salt '*' layman.delete <overlay name> ''' ret = list() o...
[ "def", "delete", "(", "overlay", ")", ":", "ret", "=", "list", "(", ")", "old_overlays", "=", "list_local", "(", ")", "cmd", "=", "'layman --quietness=0 --delete {0}'", ".", "format", "(", "overlay", ")", "delete_attempt", "=", "__salt__", "[", "'cmd.run_all'"...
Remove the given overlay from the your locally installed overlays. Specify 'ALL' to remove all overlays. Return a list of the overlays(s) that were removed: CLI Example: .. code-block:: bash salt '*' layman.delete <overlay name>
[ "Remove", "the", "given", "overlay", "from", "the", "your", "locally", "installed", "overlays", ".", "Specify", "ALL", "to", "remove", "all", "overlays", "." ]
python
train
34.290323
andrenarchy/krypy
krypy/utils.py
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/utils.py#L98-L111
def shape_vecs(*args): '''Reshape all ndarrays with ``shape==(n,)`` to ``shape==(n,1)``. Recognizes ndarrays and ignores all others.''' ret_args = [] flat_vecs = True for arg in args: if type(arg) is numpy.ndarray: if len(arg.shape) == 1: arg = shape_vec(arg) ...
[ "def", "shape_vecs", "(", "*", "args", ")", ":", "ret_args", "=", "[", "]", "flat_vecs", "=", "True", "for", "arg", "in", "args", ":", "if", "type", "(", "arg", ")", "is", "numpy", ".", "ndarray", ":", "if", "len", "(", "arg", ".", "shape", ")", ...
Reshape all ndarrays with ``shape==(n,)`` to ``shape==(n,1)``. Recognizes ndarrays and ignores all others.
[ "Reshape", "all", "ndarrays", "with", "shape", "==", "(", "n", ")", "to", "shape", "==", "(", "n", "1", ")", "." ]
python
train
29.642857
sdispater/pendulum
pendulum/datetime.py
https://github.com/sdispater/pendulum/blob/94d28b0d3cb524ae02361bd1ed7ea03e2e655e4e/pendulum/datetime.py#L1187-L1212
def _first_of_month(self, day_of_week): """ Modify to the first occurrence of a given day of the week in the current month. If no day_of_week is provided, modify to the first day of the month. Use the supplied consts to indicate the desired day_of_week, ex. DateTime.MONDAY. ...
[ "def", "_first_of_month", "(", "self", ",", "day_of_week", ")", ":", "dt", "=", "self", ".", "start_of", "(", "\"day\"", ")", "if", "day_of_week", "is", "None", ":", "return", "dt", ".", "set", "(", "day", "=", "1", ")", "month", "=", "calendar", "."...
Modify to the first occurrence of a given day of the week in the current month. If no day_of_week is provided, modify to the first day of the month. Use the supplied consts to indicate the desired day_of_week, ex. DateTime.MONDAY. :type day_of_week: int :rtype: DateTime
[ "Modify", "to", "the", "first", "occurrence", "of", "a", "given", "day", "of", "the", "week", "in", "the", "current", "month", ".", "If", "no", "day_of_week", "is", "provided", "modify", "to", "the", "first", "day", "of", "the", "month", ".", "Use", "t...
python
train
29.192308
bfrog/whizzer
whizzer/server.py
https://github.com/bfrog/whizzer/blob/a1e43084b3ac8c1f3fb4ada081777cdbf791fd77/whizzer/server.py#L48-L55
def closed(self, reason): """Callback performed when the transport is closed.""" self.server.remove_connection(self) self.protocol.connection_lost(reason) if not isinstance(reason, ConnectionClosed): logger.warn("connection closed, reason: %s" % str(reason)) else: ...
[ "def", "closed", "(", "self", ",", "reason", ")", ":", "self", ".", "server", ".", "remove_connection", "(", "self", ")", "self", ".", "protocol", ".", "connection_lost", "(", "reason", ")", "if", "not", "isinstance", "(", "reason", ",", "ConnectionClosed"...
Callback performed when the transport is closed.
[ "Callback", "performed", "when", "the", "transport", "is", "closed", "." ]
python
train
44.25