repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
kislyuk/aegea | aegea/packages/github3/repos/repo.py | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/repo.py#L1587-L1600 | def iter_statuses(self, sha, number=-1, etag=None):
"""Iterates over the statuses for a specific SHA.
:param str sha: SHA of the commit to list the statuses of
:param int number: (optional), return up to number statuses. Default:
-1 returns all available statuses.
:param str... | [
"def",
"iter_statuses",
"(",
"self",
",",
"sha",
",",
"number",
"=",
"-",
"1",
",",
"etag",
"=",
"None",
")",
":",
"url",
"=",
"''",
"if",
"sha",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'statuses'",
",",
"sha",
",",
"base_url",
"=",
"se... | Iterates over the statuses for a specific SHA.
:param str sha: SHA of the commit to list the statuses of
:param int number: (optional), return up to number statuses. Default:
-1 returns all available statuses.
:param str etag: (optional), ETag from a previous request to the same
... | [
"Iterates",
"over",
"the",
"statuses",
"for",
"a",
"specific",
"SHA",
"."
] | python | train |
pymc-devs/pymc | pymc/database/hdf5.py | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/database/hdf5.py#L86-L117 | def gettrace(self, burn=0, thin=1, chain=-1, slicing=None):
"""Return the trace (last by default).
:Parameters:
burn : integer
The number of transient steps to skip.
thin : integer
Keep one in thin.
chain : integer
The index of the chain to fetch. I... | [
"def",
"gettrace",
"(",
"self",
",",
"burn",
"=",
"0",
",",
"thin",
"=",
"1",
",",
"chain",
"=",
"-",
"1",
",",
"slicing",
"=",
"None",
")",
":",
"if",
"chain",
"is",
"not",
"None",
":",
"vlarrays",
"=",
"[",
"self",
".",
"_vlarrays",
"[",
"cha... | Return the trace (last by default).
:Parameters:
burn : integer
The number of transient steps to skip.
thin : integer
Keep one in thin.
chain : integer
The index of the chain to fetch. If None, return all chains. The
default is to return the last ... | [
"Return",
"the",
"trace",
"(",
"last",
"by",
"default",
")",
"."
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/git/git_client_base.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/git/git_client_base.py#L730-L751 | def query_import_requests(self, project, repository_id, include_abandoned=None):
"""QueryImportRequests.
[Preview API] Retrieve import requests for a repository.
:param str project: Project ID or project name
:param str repository_id: The name or ID of the repository.
:param bool... | [
"def",
"query_import_requests",
"(",
"self",
",",
"project",
",",
"repository_id",
",",
"include_abandoned",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'",
"]",
"=",
"self",
... | QueryImportRequests.
[Preview API] Retrieve import requests for a repository.
:param str project: Project ID or project name
:param str repository_id: The name or ID of the repository.
:param bool include_abandoned: True to include abandoned import requests in the results.
:rtype... | [
"QueryImportRequests",
".",
"[",
"Preview",
"API",
"]",
"Retrieve",
"import",
"requests",
"for",
"a",
"repository",
".",
":",
"param",
"str",
"project",
":",
"Project",
"ID",
"or",
"project",
"name",
":",
"param",
"str",
"repository_id",
":",
"The",
"name",
... | python | train |
resync/resync | resync/client.py | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L241-L326 | def baseline_or_audit(self, allow_deletion=False, audit_only=False):
"""Baseline synchonization or audit.
Both functions implemented in this routine because audit is a prerequisite
for a baseline sync. In the case of baseline sync the last timestamp seen
is recorded as client state.
... | [
"def",
"baseline_or_audit",
"(",
"self",
",",
"allow_deletion",
"=",
"False",
",",
"audit_only",
"=",
"False",
")",
":",
"action",
"=",
"(",
"'audit'",
"if",
"(",
"audit_only",
")",
"else",
"'baseline sync'",
")",
"self",
".",
"logger",
".",
"debug",
"(",
... | Baseline synchonization or audit.
Both functions implemented in this routine because audit is a prerequisite
for a baseline sync. In the case of baseline sync the last timestamp seen
is recorded as client state. | [
"Baseline",
"synchonization",
"or",
"audit",
"."
] | python | train |
CivicSpleen/ckcache | ckcache/__init__.py | https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/__init__.py#L327-L348 | def store_list(self, cb=None):
"""List the cache and store it as metadata. This allows for getting the list from HTTP caches
and other types where it is not possible to traverse the tree"""
from StringIO import StringIO
import json
d = {}
for k, v in self.list().items(... | [
"def",
"store_list",
"(",
"self",
",",
"cb",
"=",
"None",
")",
":",
"from",
"StringIO",
"import",
"StringIO",
"import",
"json",
"d",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"list",
"(",
")",
".",
"items",
"(",
")",
":",
"if",
"'... | List the cache and store it as metadata. This allows for getting the list from HTTP caches
and other types where it is not possible to traverse the tree | [
"List",
"the",
"cache",
"and",
"store",
"it",
"as",
"metadata",
".",
"This",
"allows",
"for",
"getting",
"the",
"list",
"from",
"HTTP",
"caches",
"and",
"other",
"types",
"where",
"it",
"is",
"not",
"possible",
"to",
"traverse",
"the",
"tree"
] | python | train |
thespacedoctor/polyglot | polyglot/htmlCleaner.py | https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/htmlCleaner.py#L97-L225 | def clean(
self):
"""*parse and clean the html document with Mercury Parser*
**Return:**
- ``filePath`` -- path to the cleaned HTML document
**Usage:**
See class usage
"""
self.log.debug('starting the ``clean`` method')
url = self.... | [
"def",
"clean",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``clean`` method'",
")",
"url",
"=",
"self",
".",
"url",
"# PARSE THE CONTENT OF THE WEBPAGE AT THE URL",
"parser_response",
"=",
"self",
".",
"_request_parsed_article_from_me... | *parse and clean the html document with Mercury Parser*
**Return:**
- ``filePath`` -- path to the cleaned HTML document
**Usage:**
See class usage | [
"*",
"parse",
"and",
"clean",
"the",
"html",
"document",
"with",
"Mercury",
"Parser",
"*"
] | python | train |
sorgerlab/indra | indra/explanation/model_checker.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/explanation/model_checker.py#L352-L423 | def check_statement(self, stmt, max_paths=1, max_path_length=5):
"""Check a single Statement against the model.
Parameters
----------
stmt : indra.statements.Statement
The Statement to check.
max_paths : Optional[int]
The maximum number of specific paths ... | [
"def",
"check_statement",
"(",
"self",
",",
"stmt",
",",
"max_paths",
"=",
"1",
",",
"max_path_length",
"=",
"5",
")",
":",
"# Make sure the influence map is initialized",
"self",
".",
"get_im",
"(",
")",
"# Check if this is one of the statement types that we can check",
... | Check a single Statement against the model.
Parameters
----------
stmt : indra.statements.Statement
The Statement to check.
max_paths : Optional[int]
The maximum number of specific paths to return for each Statement
to be explained. Default: 1
... | [
"Check",
"a",
"single",
"Statement",
"against",
"the",
"model",
"."
] | python | train |
ska-sa/montblanc | montblanc/impl/rime/tensorflow/config.py | https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/config.py#L134-L141 | def identity_on_pols(self, context):
"""
Returns [[1, 0], tiled up to other dimensions
[0, 1]]
"""
A = np.empty(context.shape, context.dtype)
A[:,:,:] = [[[1,0,0,1]]]
return A | [
"def",
"identity_on_pols",
"(",
"self",
",",
"context",
")",
":",
"A",
"=",
"np",
".",
"empty",
"(",
"context",
".",
"shape",
",",
"context",
".",
"dtype",
")",
"A",
"[",
":",
",",
":",
",",
":",
"]",
"=",
"[",
"[",
"[",
"1",
",",
"0",
",",
... | Returns [[1, 0], tiled up to other dimensions
[0, 1]] | [
"Returns",
"[[",
"1",
"0",
"]",
"tiled",
"up",
"to",
"other",
"dimensions",
"[",
"0",
"1",
"]]"
] | python | train |
numenta/nupic | src/nupic/algorithms/sdr_classifier.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/sdr_classifier.py#L319-L362 | def infer(self, patternNZ, actValueList):
"""
Return the inference value from one input sample. The actual
learning happens in compute().
:param patternNZ: list of the active indices from the output below
:param classification: dict of the classification information:
bucketIdx: ... | [
"def",
"infer",
"(",
"self",
",",
"patternNZ",
",",
"actValueList",
")",
":",
"# Return value dict. For buckets which we don't have an actual value",
"# for yet, just plug in any valid actual value. It doesn't matter what",
"# we use because that bucket won't have non-zero likelihood anyways... | Return the inference value from one input sample. The actual
learning happens in compute().
:param patternNZ: list of the active indices from the output below
:param classification: dict of the classification information:
bucketIdx: index of the encoder bucket
actVal... | [
"Return",
"the",
"inference",
"value",
"from",
"one",
"input",
"sample",
".",
"The",
"actual",
"learning",
"happens",
"in",
"compute",
"()",
"."
] | python | valid |
joke2k/django-environ | environ/environ.py | https://github.com/joke2k/django-environ/blob/c2620021614557abe197578f99deeef42af3e082/environ/environ.py#L687-L694 | def path(self, *paths, **kwargs):
"""Create new Path based on self.root and provided paths.
:param paths: List of sub paths
:param kwargs: required=False
:rtype: Path
"""
return self.__class__(self.__root__, *paths, **kwargs) | [
"def",
"path",
"(",
"self",
",",
"*",
"paths",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"__root__",
",",
"*",
"paths",
",",
"*",
"*",
"kwargs",
")"
] | Create new Path based on self.root and provided paths.
:param paths: List of sub paths
:param kwargs: required=False
:rtype: Path | [
"Create",
"new",
"Path",
"based",
"on",
"self",
".",
"root",
"and",
"provided",
"paths",
"."
] | python | train |
tsileo/globster | lazy_regex.py | https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/lazy_regex.py#L60-L65 | def _compile_and_collapse(self):
"""Actually compile the requested regex"""
self._real_regex = self._real_re_compile(*self._regex_args,
**self._regex_kwargs)
for attr in self._regex_attributes_to_copy:
setattr(self, attr, getattr(self.... | [
"def",
"_compile_and_collapse",
"(",
"self",
")",
":",
"self",
".",
"_real_regex",
"=",
"self",
".",
"_real_re_compile",
"(",
"*",
"self",
".",
"_regex_args",
",",
"*",
"*",
"self",
".",
"_regex_kwargs",
")",
"for",
"attr",
"in",
"self",
".",
"_regex_attri... | Actually compile the requested regex | [
"Actually",
"compile",
"the",
"requested",
"regex"
] | python | train |
ellmetha/django-machina | machina/apps/forum_conversation/abstract_models.py | https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_conversation/abstract_models.py#L284-L287 | def position(self):
""" Returns an integer corresponding to the position of the post in the topic. """
position = self.topic.posts.filter(Q(created__lt=self.created) | Q(id=self.id)).count()
return position | [
"def",
"position",
"(",
"self",
")",
":",
"position",
"=",
"self",
".",
"topic",
".",
"posts",
".",
"filter",
"(",
"Q",
"(",
"created__lt",
"=",
"self",
".",
"created",
")",
"|",
"Q",
"(",
"id",
"=",
"self",
".",
"id",
")",
")",
".",
"count",
"... | Returns an integer corresponding to the position of the post in the topic. | [
"Returns",
"an",
"integer",
"corresponding",
"to",
"the",
"position",
"of",
"the",
"post",
"in",
"the",
"topic",
"."
] | python | train |
edx/edx-django-utils | edx_django_utils/monitoring/utils.py | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/utils.py#L103-L113 | def function_trace(function_name):
"""
Wraps a chunk of code that we want to appear as a separate, explicit,
segment in our monitoring tools.
"""
if newrelic:
nr_transaction = newrelic.agent.current_transaction()
with newrelic.agent.FunctionTrace(nr_transaction, function_name):
... | [
"def",
"function_trace",
"(",
"function_name",
")",
":",
"if",
"newrelic",
":",
"nr_transaction",
"=",
"newrelic",
".",
"agent",
".",
"current_transaction",
"(",
")",
"with",
"newrelic",
".",
"agent",
".",
"FunctionTrace",
"(",
"nr_transaction",
",",
"function_n... | Wraps a chunk of code that we want to appear as a separate, explicit,
segment in our monitoring tools. | [
"Wraps",
"a",
"chunk",
"of",
"code",
"that",
"we",
"want",
"to",
"appear",
"as",
"a",
"separate",
"explicit",
"segment",
"in",
"our",
"monitoring",
"tools",
"."
] | python | train |
ierror/django-js-reverse | django_js_reverse/rjsmin.py | https://github.com/ierror/django-js-reverse/blob/58320a8acec040636e8ad718754c2d472d0d504d/django_js_reverse/rjsmin.py#L312-L427 | def jsmin_for_posers(script, keep_bang_comments=False):
r"""
Minify javascript based on `jsmin.c by Douglas Crockford`_\.
Instead of parsing the stream char by char, it uses a regular
expression approach which minifies the whole script with one big
substitution regex.
.. _jsmin.c by Douglas Cr... | [
"def",
"jsmin_for_posers",
"(",
"script",
",",
"keep_bang_comments",
"=",
"False",
")",
":",
"if",
"not",
"keep_bang_comments",
":",
"rex",
"=",
"(",
"r'([^\\047\"/\\000-\\040]+)|((?:(?:\\047[^\\047\\\\\\r\\n]*(?:\\\\(?:[^\\r\\n]'",
"r'|\\r?\\n|\\r)[^\\047\\\\\\r\\n]*)*\\047)|(?:... | r"""
Minify javascript based on `jsmin.c by Douglas Crockford`_\.
Instead of parsing the stream char by char, it uses a regular
expression approach which minifies the whole script with one big
substitution regex.
.. _jsmin.c by Douglas Crockford:
http://www.crockford.com/javascript/jsmin.c
... | [
"r",
"Minify",
"javascript",
"based",
"on",
"jsmin",
".",
"c",
"by",
"Douglas",
"Crockford",
"_",
"\\",
"."
] | python | train |
SmokinCaterpillar/pypet | pypet/storageservice.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/storageservice.py#L4035-L4057 | def _prm_select_shared_pandas_data(self, pd_node, full_name, **kwargs):
"""Reads a DataFrame from dis.
:param pd_node:
hdf5 node storing the pandas DataFrame
:param full_name:
Full name of the parameter or result whose data is to be loaded
:param kwargs:
... | [
"def",
"_prm_select_shared_pandas_data",
"(",
"self",
",",
"pd_node",
",",
"full_name",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"pathname",
"=",
"pd_node",
".",
"_v_pathname",
"pandas_store",
"=",
"self",
".",
"_hdf5store",
"return",
"pandas_store",
"."... | Reads a DataFrame from dis.
:param pd_node:
hdf5 node storing the pandas DataFrame
:param full_name:
Full name of the parameter or result whose data is to be loaded
:param kwargs:
Arguments passed to pandas' select method | [
"Reads",
"a",
"DataFrame",
"from",
"dis",
"."
] | python | test |
yinkaisheng/Python-UIAutomation-for-Windows | uiautomation/uiautomation.py | https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L5094-L5103 | def WaitForInputIdle(self, milliseconds: int) -> bool:
'''
Call IUIAutomationWindowPattern::WaitForInputIdle.
Cause the calling code to block for the specified time or
until the associated process enters an idle state, whichever completes first.
milliseconds: int.
Ret... | [
"def",
"WaitForInputIdle",
"(",
"self",
",",
"milliseconds",
":",
"int",
")",
"->",
"bool",
":",
"return",
"self",
".",
"pattern",
".",
"WaitForInputIdle",
"(",
"milliseconds",
")",
"==",
"S_OK"
] | Call IUIAutomationWindowPattern::WaitForInputIdle.
Cause the calling code to block for the specified time or
until the associated process enters an idle state, whichever completes first.
milliseconds: int.
Return bool, True if succeed otherwise False.
Refer https://docs.micro... | [
"Call",
"IUIAutomationWindowPattern",
"::",
"WaitForInputIdle",
".",
"Cause",
"the",
"calling",
"code",
"to",
"block",
"for",
"the",
"specified",
"time",
"or",
"until",
"the",
"associated",
"process",
"enters",
"an",
"idle",
"state",
"whichever",
"completes",
"fir... | python | valid |
eandersson/amqpstorm | amqpstorm/rpc.py | https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/rpc.py#L124-L136 | def _wait_for_request(self, uuid, connection_adapter=None):
"""Wait for RPC request to arrive.
:param str uuid: Rpc Identifier.
:param obj connection_adapter: Provide custom connection adapter.
:return:
"""
start_time = time.time()
while not self._response[uuid]:... | [
"def",
"_wait_for_request",
"(",
"self",
",",
"uuid",
",",
"connection_adapter",
"=",
"None",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"while",
"not",
"self",
".",
"_response",
"[",
"uuid",
"]",
":",
"connection_adapter",
".",
"check_for... | Wait for RPC request to arrive.
:param str uuid: Rpc Identifier.
:param obj connection_adapter: Provide custom connection adapter.
:return: | [
"Wait",
"for",
"RPC",
"request",
"to",
"arrive",
"."
] | python | train |
icometrix/dicom2nifti | dicom2nifti/convert_philips.py | https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L190-L202 | def _is_bval_type_b(grouped_dicoms):
"""
Check if the bvals are stored in the second of 2 currently known ways for single frame dti
"""
bval_tag = Tag(0x0018, 0x9087)
bvec_tag = Tag(0x0018, 0x9089)
for group in grouped_dicoms:
if bvec_tag in group[0] and bval_tag in group[0]:
... | [
"def",
"_is_bval_type_b",
"(",
"grouped_dicoms",
")",
":",
"bval_tag",
"=",
"Tag",
"(",
"0x0018",
",",
"0x9087",
")",
"bvec_tag",
"=",
"Tag",
"(",
"0x0018",
",",
"0x9089",
")",
"for",
"group",
"in",
"grouped_dicoms",
":",
"if",
"bvec_tag",
"in",
"group",
... | Check if the bvals are stored in the second of 2 currently known ways for single frame dti | [
"Check",
"if",
"the",
"bvals",
"are",
"stored",
"in",
"the",
"second",
"of",
"2",
"currently",
"known",
"ways",
"for",
"single",
"frame",
"dti"
] | python | train |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/guerilla/guerillamgmt.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/guerilla/guerillamgmt.py#L1202-L1216 | def prj_add_atype(self, *args, **kwargs):
"""Add more assettypes to the project.
:returns: None
:rtype: None
:raises: None
"""
if not self.cur_prj:
return
dialog = AtypeAdderDialog(project=self.cur_prj)
dialog.exec_()
atypes = dialog.a... | [
"def",
"prj_add_atype",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"cur_prj",
":",
"return",
"dialog",
"=",
"AtypeAdderDialog",
"(",
"project",
"=",
"self",
".",
"cur_prj",
")",
"dialog",
".",
"exec_",
... | Add more assettypes to the project.
:returns: None
:rtype: None
:raises: None | [
"Add",
"more",
"assettypes",
"to",
"the",
"project",
"."
] | python | train |
tornadoweb/tornado | tornado/web.py | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1007-L1028 | def get_template_namespace(self) -> Dict[str, Any]:
"""Returns a dictionary to be used as the default template namespace.
May be overridden by subclasses to add or modify values.
The results of this method will be combined with additional
defaults in the `tornado.template` module and k... | [
"def",
"get_template_namespace",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"namespace",
"=",
"dict",
"(",
"handler",
"=",
"self",
",",
"request",
"=",
"self",
".",
"request",
",",
"current_user",
"=",
"self",
".",
"current_user",
... | Returns a dictionary to be used as the default template namespace.
May be overridden by subclasses to add or modify values.
The results of this method will be combined with additional
defaults in the `tornado.template` module and keyword arguments
to `render` or `render_string`. | [
"Returns",
"a",
"dictionary",
"to",
"be",
"used",
"as",
"the",
"default",
"template",
"namespace",
"."
] | python | train |
davidmogar/cucco | cucco/config.py | https://github.com/davidmogar/cucco/blob/e2a0ff3342e4a9f25a65c486206a5a2ae1a4dbd4/cucco/config.py#L53-L76 | def _load_from_file(path):
"""Load a config file from the given path.
Load all normalizations from the config file received as
argument. It expects to find a YAML file with a list of
normalizations and arguments under the key 'normalizations'.
Args:
path: Path to YA... | [
"def",
"_load_from_file",
"(",
"path",
")",
":",
"config",
"=",
"[",
"]",
"try",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"config_file",
":",
"config",
"=",
"yaml",
".",
"load",
"(",
"config_file",
")",
"[",
"'normalizations'",
"]",
"... | Load a config file from the given path.
Load all normalizations from the config file received as
argument. It expects to find a YAML file with a list of
normalizations and arguments under the key 'normalizations'.
Args:
path: Path to YAML file. | [
"Load",
"a",
"config",
"file",
"from",
"the",
"given",
"path",
"."
] | python | train |
boriel/zxbasic | arch/zx48k/optimizer.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L641-L653 | def rl(self, r):
""" Like the above, bus uses carry
"""
if self.C is None or not is_number(self.regs[r]):
self.set(r, None)
self.set_flag(None)
return
self.rlc(r)
tmp = self.C
v_ = self.getv(self.regs[r])
self.C = v_ & 1
... | [
"def",
"rl",
"(",
"self",
",",
"r",
")",
":",
"if",
"self",
".",
"C",
"is",
"None",
"or",
"not",
"is_number",
"(",
"self",
".",
"regs",
"[",
"r",
"]",
")",
":",
"self",
".",
"set",
"(",
"r",
",",
"None",
")",
"self",
".",
"set_flag",
"(",
"... | Like the above, bus uses carry | [
"Like",
"the",
"above",
"bus",
"uses",
"carry"
] | python | train |
gitpython-developers/GitPython | git/index/base.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/index/base.py#L929-L953 | def commit(self, message, parent_commits=None, head=True, author=None,
committer=None, author_date=None, commit_date=None,
skip_hooks=False):
"""Commit the current default index file, creating a commit object.
For more information on the arguments, see tree.commit.
... | [
"def",
"commit",
"(",
"self",
",",
"message",
",",
"parent_commits",
"=",
"None",
",",
"head",
"=",
"True",
",",
"author",
"=",
"None",
",",
"committer",
"=",
"None",
",",
"author_date",
"=",
"None",
",",
"commit_date",
"=",
"None",
",",
"skip_hooks",
... | Commit the current default index file, creating a commit object.
For more information on the arguments, see tree.commit.
:note: If you have manually altered the .entries member of this instance,
don't forget to write() your changes to disk beforehand.
Passing skip_hooks=Tr... | [
"Commit",
"the",
"current",
"default",
"index",
"file",
"creating",
"a",
"commit",
"object",
".",
"For",
"more",
"information",
"on",
"the",
"arguments",
"see",
"tree",
".",
"commit",
"."
] | python | train |
wgnet/webium | webium/plugins/browser_closer.py | https://github.com/wgnet/webium/blob/ccb09876a201e75f5c5810392d4db7a8708b90cb/webium/plugins/browser_closer.py#L25-L29 | def configure(self, options, conf):
"""Configure plugin. Plugin is enabled by default.
"""
self.conf = conf
self.when = options.browser_closer_when | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"conf",
")",
":",
"self",
".",
"conf",
"=",
"conf",
"self",
".",
"when",
"=",
"options",
".",
"browser_closer_when"
] | Configure plugin. Plugin is enabled by default. | [
"Configure",
"plugin",
".",
"Plugin",
"is",
"enabled",
"by",
"default",
"."
] | python | train |
juju/charm-helpers | charmhelpers/core/hookenv.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/hookenv.py#L1160-L1165 | def juju_version():
"""Full version string (eg. '1.23.3.1-trusty-amd64')"""
# Per https://bugs.launchpad.net/juju-core/+bug/1455368/comments/1
jujud = glob.glob('/var/lib/juju/tools/machine-*/jujud')[0]
return subprocess.check_output([jujud, 'version'],
universal_newli... | [
"def",
"juju_version",
"(",
")",
":",
"# Per https://bugs.launchpad.net/juju-core/+bug/1455368/comments/1",
"jujud",
"=",
"glob",
".",
"glob",
"(",
"'/var/lib/juju/tools/machine-*/jujud'",
")",
"[",
"0",
"]",
"return",
"subprocess",
".",
"check_output",
"(",
"[",
"jujud... | Full version string (eg. '1.23.3.1-trusty-amd64') | [
"Full",
"version",
"string",
"(",
"eg",
".",
"1",
".",
"23",
".",
"3",
".",
"1",
"-",
"trusty",
"-",
"amd64",
")"
] | python | train |
pyvisa/pyvisa | pyvisa/ctwrapper/functions.py | https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L916-L940 | def move_asynchronously(library, session, source_space, source_offset, source_width,
destination_space, destination_offset,
destination_width, length):
"""Moves a block of data asynchronously.
Corresponds to viMoveAsync function of the VISA library.
:param l... | [
"def",
"move_asynchronously",
"(",
"library",
",",
"session",
",",
"source_space",
",",
"source_offset",
",",
"source_width",
",",
"destination_space",
",",
"destination_offset",
",",
"destination_width",
",",
"length",
")",
":",
"job_id",
"=",
"ViJobId",
"(",
")"... | Moves a block of data asynchronously.
Corresponds to viMoveAsync function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param source_space: Specifies the address space of the source.
:param source_offset: Offset of... | [
"Moves",
"a",
"block",
"of",
"data",
"asynchronously",
"."
] | python | train |
tjcsl/cslbot | cslbot/helpers/modutils.py | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/helpers/modutils.py#L169-L180 | def scan_and_reimport(mod_type: str) -> List[Tuple[str, str]]:
"""Scans folder for modules."""
mod_enabled, mod_disabled = get_modules(mod_type)
errors = []
for mod in mod_enabled + mod_disabled:
if mod in sys.modules:
msg = safe_reload(sys.modules[mod])
else:
msg... | [
"def",
"scan_and_reimport",
"(",
"mod_type",
":",
"str",
")",
"->",
"List",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
":",
"mod_enabled",
",",
"mod_disabled",
"=",
"get_modules",
"(",
"mod_type",
")",
"errors",
"=",
"[",
"]",
"for",
"mod",
"in",
... | Scans folder for modules. | [
"Scans",
"folder",
"for",
"modules",
"."
] | python | train |
not-na/peng3d | peng3d/model.py | https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/model.py#L73-L133 | def calcSphereCoordinates(pos,radius,rot):
"""
Calculates the Cartesian coordinates from spherical coordinates.
``pos`` is a simple offset to offset the result with.
``radius`` is the radius of the input.
``rot`` is a 2-tuple of ``(azimuth,polar)`` angles.
Angles are given in... | [
"def",
"calcSphereCoordinates",
"(",
"pos",
",",
"radius",
",",
"rot",
")",
":",
"# Input angles should be in degrees, as in the rest of the game",
"# E.g. phi=inclination and theta=azimuth",
"# phi is yrad",
"# Look from above ",
"#(Z goes positive towards you) ",
"# ... | Calculates the Cartesian coordinates from spherical coordinates.
``pos`` is a simple offset to offset the result with.
``radius`` is the radius of the input.
``rot`` is a 2-tuple of ``(azimuth,polar)`` angles.
Angles are given in degrees. Most directions in this game use the same con... | [
"Calculates",
"the",
"Cartesian",
"coordinates",
"from",
"spherical",
"coordinates",
".",
"pos",
"is",
"a",
"simple",
"offset",
"to",
"offset",
"the",
"result",
"with",
".",
"radius",
"is",
"the",
"radius",
"of",
"the",
"input",
".",
"rot",
"is",
"a",
"2",... | python | test |
python-rope/rope | rope/refactor/sourceutils.py | https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/refactor/sourceutils.py#L35-L38 | def fix_indentation(code, new_indents):
"""Change the indentation of `code` to `new_indents`"""
min_indents = find_minimum_indents(code)
return indent_lines(code, new_indents - min_indents) | [
"def",
"fix_indentation",
"(",
"code",
",",
"new_indents",
")",
":",
"min_indents",
"=",
"find_minimum_indents",
"(",
"code",
")",
"return",
"indent_lines",
"(",
"code",
",",
"new_indents",
"-",
"min_indents",
")"
] | Change the indentation of `code` to `new_indents` | [
"Change",
"the",
"indentation",
"of",
"code",
"to",
"new_indents"
] | python | train |
googleapis/google-cloud-python | bigquery/google/cloud/bigquery/job.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/job.py#L2593-L2606 | def total_bytes_billed(self):
"""Return total bytes billed from job statistics, if present.
See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.totalBytesBilled
:rtype: int or None
:returns: total bytes processed by the job, or None if job is not... | [
"def",
"total_bytes_billed",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"_job_statistics",
"(",
")",
".",
"get",
"(",
"\"totalBytesBilled\"",
")",
"if",
"result",
"is",
"not",
"None",
":",
"result",
"=",
"int",
"(",
"result",
")",
"return",
"resu... | Return total bytes billed from job statistics, if present.
See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.totalBytesBilled
:rtype: int or None
:returns: total bytes processed by the job, or None if job is not
yet complete. | [
"Return",
"total",
"bytes",
"billed",
"from",
"job",
"statistics",
"if",
"present",
"."
] | python | train |
tdryer/hangups | hangups/conversation_event.py | https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/conversation_event.py#L88-L101 | def from_str(text):
"""Construct :class:`ChatMessageSegment` list parsed from a string.
Args:
text (str): Text to parse. May contain line breaks, URLs and
formatting markup (simplified Markdown and HTML) to be
converted into equivalent segments.
Retu... | [
"def",
"from_str",
"(",
"text",
")",
":",
"segment_list",
"=",
"chat_message_parser",
".",
"parse",
"(",
"text",
")",
"return",
"[",
"ChatMessageSegment",
"(",
"segment",
".",
"text",
",",
"*",
"*",
"segment",
".",
"params",
")",
"for",
"segment",
"in",
... | Construct :class:`ChatMessageSegment` list parsed from a string.
Args:
text (str): Text to parse. May contain line breaks, URLs and
formatting markup (simplified Markdown and HTML) to be
converted into equivalent segments.
Returns:
List of :class... | [
"Construct",
":",
"class",
":",
"ChatMessageSegment",
"list",
"parsed",
"from",
"a",
"string",
"."
] | python | valid |
Jammy2211/PyAutoLens | autolens/model/inversion/util/regularization_util.py | https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/inversion/util/regularization_util.py#L97-L127 | def weighted_regularization_matrix_from_pixel_neighbors(regularization_weights, pixel_neighbors,
pixel_neighbors_size):
"""From the pixel-neighbors, setup the regularization matrix using the weighted regularization scheme.
Parameters
----------
re... | [
"def",
"weighted_regularization_matrix_from_pixel_neighbors",
"(",
"regularization_weights",
",",
"pixel_neighbors",
",",
"pixel_neighbors_size",
")",
":",
"pixels",
"=",
"len",
"(",
"regularization_weights",
")",
"regularization_matrix",
"=",
"np",
".",
"zeros",
"(",
"sh... | From the pixel-neighbors, setup the regularization matrix using the weighted regularization scheme.
Parameters
----------
regularization_weights : ndarray
The regularization_ weight of each pixel, which governs how much smoothing is applied to that individual pixel.
pixel_neighbors : ndarray
... | [
"From",
"the",
"pixel",
"-",
"neighbors",
"setup",
"the",
"regularization",
"matrix",
"using",
"the",
"weighted",
"regularization",
"scheme",
"."
] | python | valid |
urschrei/pyzotero | pyzotero/zotero.py | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1192-L1222 | def create_collections(self, payload, last_modified=None):
"""
Create new Zotero collections
Accepts one argument, a list of dicts containing the following keys:
'name': the name of the collection
'parentCollection': OPTIONAL, the parent collection to which you wish to add this
... | [
"def",
"create_collections",
"(",
"self",
",",
"payload",
",",
"last_modified",
"=",
"None",
")",
":",
"# no point in proceeding if there's no 'name' key",
"for",
"item",
"in",
"payload",
":",
"if",
"\"name\"",
"not",
"in",
"item",
":",
"raise",
"ze",
".",
"Para... | Create new Zotero collections
Accepts one argument, a list of dicts containing the following keys:
'name': the name of the collection
'parentCollection': OPTIONAL, the parent collection to which you wish to add this | [
"Create",
"new",
"Zotero",
"collections",
"Accepts",
"one",
"argument",
"a",
"list",
"of",
"dicts",
"containing",
"the",
"following",
"keys",
":"
] | python | valid |
apache/airflow | airflow/contrib/hooks/azure_data_lake_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_data_lake_hook.py#L55-L68 | def check_for_file(self, file_path):
"""
Check if a file exists on Azure Data Lake.
:param file_path: Path and name of the file.
:type file_path: str
:return: True if the file exists, False otherwise.
:rtype: bool
"""
try:
files = self.connect... | [
"def",
"check_for_file",
"(",
"self",
",",
"file_path",
")",
":",
"try",
":",
"files",
"=",
"self",
".",
"connection",
".",
"glob",
"(",
"file_path",
",",
"details",
"=",
"False",
",",
"invalidate_cache",
"=",
"True",
")",
"return",
"len",
"(",
"files",
... | Check if a file exists on Azure Data Lake.
:param file_path: Path and name of the file.
:type file_path: str
:return: True if the file exists, False otherwise.
:rtype: bool | [
"Check",
"if",
"a",
"file",
"exists",
"on",
"Azure",
"Data",
"Lake",
"."
] | python | test |
MillionIntegrals/vel | vel/rl/models/deterministic_policy_model.py | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/models/deterministic_policy_model.py#L29-L33 | def model_actions(self):
""" Estimate state-value of the transition next state """
observations = self.get('rollout:observations')
model_action = self.model.action(observations)
return model_action | [
"def",
"model_actions",
"(",
"self",
")",
":",
"observations",
"=",
"self",
".",
"get",
"(",
"'rollout:observations'",
")",
"model_action",
"=",
"self",
".",
"model",
".",
"action",
"(",
"observations",
")",
"return",
"model_action"
] | Estimate state-value of the transition next state | [
"Estimate",
"state",
"-",
"value",
"of",
"the",
"transition",
"next",
"state"
] | python | train |
jmcgeheeiv/pyfakefs | pyfakefs/fake_filesystem.py | https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_filesystem.py#L2800-L2843 | def makedirs(self, dir_name, mode=PERM_DEF, exist_ok=False):
"""Create a leaf Fake directory and create any non-existent
parent dirs.
Args:
dir_name: (str) Name of directory to create.
mode: (int) Mode to create directory (and any necessary parent
directo... | [
"def",
"makedirs",
"(",
"self",
",",
"dir_name",
",",
"mode",
"=",
"PERM_DEF",
",",
"exist_ok",
"=",
"False",
")",
":",
"ends_with_sep",
"=",
"self",
".",
"ends_with_path_separator",
"(",
"dir_name",
")",
"dir_name",
"=",
"self",
".",
"absnormpath",
"(",
"... | Create a leaf Fake directory and create any non-existent
parent dirs.
Args:
dir_name: (str) Name of directory to create.
mode: (int) Mode to create directory (and any necessary parent
directories) with. This argument defaults to 0o777.
The umask i... | [
"Create",
"a",
"leaf",
"Fake",
"directory",
"and",
"create",
"any",
"non",
"-",
"existent",
"parent",
"dirs",
"."
] | python | train |
Synerty/peek-plugin-base | peek_plugin_base/storage/DbConnection.py | https://github.com/Synerty/peek-plugin-base/blob/276101d028e1ee0678af514c761b74cce5a5cda9/peek_plugin_base/storage/DbConnection.py#L82-L100 | def ormSessionCreator(self) -> DbSessionCreator:
""" Get Orm Session
:return: A SQLAlchemy session scoped for the callers thread..
"""
assert self._dbConnectString
if self._ScopedSession:
return self._ScopedSession
self._dbEngine = create_engine(
... | [
"def",
"ormSessionCreator",
"(",
"self",
")",
"->",
"DbSessionCreator",
":",
"assert",
"self",
".",
"_dbConnectString",
"if",
"self",
".",
"_ScopedSession",
":",
"return",
"self",
".",
"_ScopedSession",
"self",
".",
"_dbEngine",
"=",
"create_engine",
"(",
"self"... | Get Orm Session
:return: A SQLAlchemy session scoped for the callers thread.. | [
"Get",
"Orm",
"Session"
] | python | train |
ensime/ensime-vim | ensime_shared/client.py | https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/client.py#L154-L184 | def setup(self, quiet=False, bootstrap_server=False):
"""Check the classpath and connect to the server if necessary."""
def lazy_initialize_ensime():
if not self.ensime:
called_by = inspect.stack()[4][3]
self.log.debug(str(inspect.stack()))
sel... | [
"def",
"setup",
"(",
"self",
",",
"quiet",
"=",
"False",
",",
"bootstrap_server",
"=",
"False",
")",
":",
"def",
"lazy_initialize_ensime",
"(",
")",
":",
"if",
"not",
"self",
".",
"ensime",
":",
"called_by",
"=",
"inspect",
".",
"stack",
"(",
")",
"[",... | Check the classpath and connect to the server if necessary. | [
"Check",
"the",
"classpath",
"and",
"connect",
"to",
"the",
"server",
"if",
"necessary",
"."
] | python | train |
pybel/pybel | src/pybel/struct/graph.py | https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L356-L369 | def add_warning(self,
exception: BELParserWarning,
context: Optional[Mapping[str, Any]] = None,
) -> None:
"""Add a warning to the internal warning log in the graph, with optional context information.
:param exception: The exception that occur... | [
"def",
"add_warning",
"(",
"self",
",",
"exception",
":",
"BELParserWarning",
",",
"context",
":",
"Optional",
"[",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"self",
".",
"warnings",
".",
"append",
"(",
"(... | Add a warning to the internal warning log in the graph, with optional context information.
:param exception: The exception that occurred
:param context: The context from the parser when the exception occurred | [
"Add",
"a",
"warning",
"to",
"the",
"internal",
"warning",
"log",
"in",
"the",
"graph",
"with",
"optional",
"context",
"information",
"."
] | python | train |
jorgenkg/python-neural-network | nimblenet/preprocessing.py | https://github.com/jorgenkg/python-neural-network/blob/617b9940fa157d54d7831c42c0f7ba6857239b9a/nimblenet/preprocessing.py#L47-L69 | def replace_nan( trainingset, replace_with = None ): # if replace_with = None, replaces with mean value
"""
Replace instanced of "not a number" with either the mean of the signal feature
or a specific value assigned by `replace_nan_with`
"""
training_data = np.array( [instance.features for instance ... | [
"def",
"replace_nan",
"(",
"trainingset",
",",
"replace_with",
"=",
"None",
")",
":",
"# if replace_with = None, replaces with mean value",
"training_data",
"=",
"np",
".",
"array",
"(",
"[",
"instance",
".",
"features",
"for",
"instance",
"in",
"trainingset",
"]",
... | Replace instanced of "not a number" with either the mean of the signal feature
or a specific value assigned by `replace_nan_with` | [
"Replace",
"instanced",
"of",
"not",
"a",
"number",
"with",
"either",
"the",
"mean",
"of",
"the",
"signal",
"feature",
"or",
"a",
"specific",
"value",
"assigned",
"by",
"replace_nan_with"
] | python | train |
adafruit/Adafruit_Python_PlatformDetect | adafruit_platformdetect/chip.py | https://github.com/adafruit/Adafruit_Python_PlatformDetect/blob/cddd4d47e530026778dc4e3c3ccabad14e6eac46/adafruit_platformdetect/chip.py#L26-L70 | def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-statements
"""Return a unique id for the detected chip, if any."""
# There are some times we want to trick the platform detection
# say if a raspberry pi doesn't have the right ID, or for testing
try:
... | [
"def",
"id",
"(",
"self",
")",
":",
"# pylint: disable=invalid-name,too-many-branches,too-many-return-statements",
"# There are some times we want to trick the platform detection",
"# say if a raspberry pi doesn't have the right ID, or for testing",
"try",
":",
"return",
"os",
".",
"envi... | Return a unique id for the detected chip, if any. | [
"Return",
"a",
"unique",
"id",
"for",
"the",
"detected",
"chip",
"if",
"any",
"."
] | python | train |
joshspeagle/dynesty | dynesty/dynamicsampler.py | https://github.com/joshspeagle/dynesty/blob/9e482aafeb5cf84bedb896fa6f07a761d917983e/dynesty/dynamicsampler.py#L452-L511 | def reset(self):
"""Re-initialize the sampler."""
# sampling
self.it = 1
self.batch = 0
self.ncall = 0
self.bound = []
self.eff = 1.
self.base = False
# results
self.saved_id = []
self.saved_u = []
self.saved_v = []
... | [
"def",
"reset",
"(",
"self",
")",
":",
"# sampling",
"self",
".",
"it",
"=",
"1",
"self",
".",
"batch",
"=",
"0",
"self",
".",
"ncall",
"=",
"0",
"self",
".",
"bound",
"=",
"[",
"]",
"self",
".",
"eff",
"=",
"1.",
"self",
".",
"base",
"=",
"F... | Re-initialize the sampler. | [
"Re",
"-",
"initialize",
"the",
"sampler",
"."
] | python | train |
fronzbot/blinkpy | blinkpy/api.py | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L156-L159 | def request_video_count(blink):
"""Request total video count."""
url = "{}/api/v2/videos/count".format(blink.urls.base_url)
return http_get(blink, url) | [
"def",
"request_video_count",
"(",
"blink",
")",
":",
"url",
"=",
"\"{}/api/v2/videos/count\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request total video count. | [
"Request",
"total",
"video",
"count",
"."
] | python | train |
persandstrom/python-verisure | verisure/session.py | https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L331-L347 | def get_lock_state_transaction(self, transaction_id):
""" Get lock state transaction status
Args:
transaction_id: Transaction ID received from set_lock_state
"""
response = None
try:
response = requests.get(
urls.get_lockstate_transaction(... | [
"def",
"get_lock_state_transaction",
"(",
"self",
",",
"transaction_id",
")",
":",
"response",
"=",
"None",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"urls",
".",
"get_lockstate_transaction",
"(",
"self",
".",
"_giid",
",",
"transaction_id",
")... | Get lock state transaction status
Args:
transaction_id: Transaction ID received from set_lock_state | [
"Get",
"lock",
"state",
"transaction",
"status"
] | python | train |
PmagPy/PmagPy | programs/plot_geomagia.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/plot_geomagia.py#L15-L124 | def main():
"""
NAME
plot_geomagia.py
DESCRIPTION
makes a map and VADM plot of geomagia download file
SYNTAX
plot_geomagia.py [command line options]
OPTIONS
-h prints help message and quits
-f FILE, specify geomagia download file
-res [c,l,i,h] s... | [
"def",
"main",
"(",
")",
":",
"dir_path",
"=",
"'.'",
"names",
",",
"res",
",",
"proj",
",",
"locs",
",",
"padlon",
",",
"padlat",
",",
"fancy",
",",
"gridspace",
",",
"details",
"=",
"[",
"]",
",",
"'l'",
",",
"'lcc'",
",",
"''",
",",
"0",
","... | NAME
plot_geomagia.py
DESCRIPTION
makes a map and VADM plot of geomagia download file
SYNTAX
plot_geomagia.py [command line options]
OPTIONS
-h prints help message and quits
-f FILE, specify geomagia download file
-res [c,l,i,h] specify resolution (crude... | [
"NAME",
"plot_geomagia",
".",
"py"
] | python | train |
mdsol/rwslib | rwslib/builders/metadata.py | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/builders/metadata.py#L1367-L1371 | def soft_hard(self, value):
"""sets the Soft or Hard range setting (with validation of input)"""
if not isinstance(value, RangeCheckType):
raise AttributeError("%s soft_hard invalid in RangeCheck." % (value,))
self._soft_hard = value | [
"def",
"soft_hard",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"RangeCheckType",
")",
":",
"raise",
"AttributeError",
"(",
"\"%s soft_hard invalid in RangeCheck.\"",
"%",
"(",
"value",
",",
")",
")",
"self",
".",
"_sof... | sets the Soft or Hard range setting (with validation of input) | [
"sets",
"the",
"Soft",
"or",
"Hard",
"range",
"setting",
"(",
"with",
"validation",
"of",
"input",
")"
] | python | train |
Karaage-Cluster/karaage | karaage/datastores/mam.py | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/mam.py#L468-L490 | def save_institute(self, institute):
""" Called when institute is created/updated. """
name = institute.name
logger.debug("save_institute '%s'" % name)
# institute created
# institute updated
if institute.is_active:
# date_deleted is not set, user should exi... | [
"def",
"save_institute",
"(",
"self",
",",
"institute",
")",
":",
"name",
"=",
"institute",
".",
"name",
"logger",
".",
"debug",
"(",
"\"save_institute '%s'\"",
"%",
"name",
")",
"# institute created",
"# institute updated",
"if",
"institute",
".",
"is_active",
... | Called when institute is created/updated. | [
"Called",
"when",
"institute",
"is",
"created",
"/",
"updated",
"."
] | python | train |
rosenbrockc/fortpy | fortpy/isense/rtupdate.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/isense/rtupdate.py#L76-L81 | def absolute_charindex(self, string, start, end):
"""Finds the absolute character index of the specified regex match
start and end indices in the *buffer* refstring."""
search = string[start:end]
abs_start = self.refstring.index(search)
return abs_start, (end - start) + abs_start | [
"def",
"absolute_charindex",
"(",
"self",
",",
"string",
",",
"start",
",",
"end",
")",
":",
"search",
"=",
"string",
"[",
"start",
":",
"end",
"]",
"abs_start",
"=",
"self",
".",
"refstring",
".",
"index",
"(",
"search",
")",
"return",
"abs_start",
",... | Finds the absolute character index of the specified regex match
start and end indices in the *buffer* refstring. | [
"Finds",
"the",
"absolute",
"character",
"index",
"of",
"the",
"specified",
"regex",
"match",
"start",
"and",
"end",
"indices",
"in",
"the",
"*",
"buffer",
"*",
"refstring",
"."
] | python | train |
amaas-fintech/amaas-core-sdk-python | amaascore/assets/synthetic_multi_leg.py | https://github.com/amaas-fintech/amaas-core-sdk-python/blob/347b71f8e776b2dde582b015e31b4802d91e8040/amaascore/assets/synthetic_multi_leg.py#L32-L44 | def legs(self, legs):
"""
A list of dictionaries of the legs that make up the multi-legged asset.
Format is {'asset_id': XYZ, 'quantity': ABC_Decimal}
:param legs:
:return:
"""
if legs is not None:
if not isinstance(legs, list):
raise V... | [
"def",
"legs",
"(",
"self",
",",
"legs",
")",
":",
"if",
"legs",
"is",
"not",
"None",
":",
"if",
"not",
"isinstance",
"(",
"legs",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid type for asset legs: %s\"",
"%",
"type",
"(",
"legs",
")",
... | A list of dictionaries of the legs that make up the multi-legged asset.
Format is {'asset_id': XYZ, 'quantity': ABC_Decimal}
:param legs:
:return: | [
"A",
"list",
"of",
"dictionaries",
"of",
"the",
"legs",
"that",
"make",
"up",
"the",
"multi",
"-",
"legged",
"asset",
".",
"Format",
"is",
"{",
"asset_id",
":",
"XYZ",
"quantity",
":",
"ABC_Decimal",
"}",
":",
"param",
"legs",
":",
":",
"return",
":"
] | python | train |
Gandi/gandi.cli | gandi/cli/modules/record.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/record.py#L47-L58 | def create(cls, zone_id, record):
"""Create a new zone version for record."""
cls.echo('Creating new zone version')
new_version_id = Zone.new(zone_id)
cls.echo('Updating zone version')
cls.add(zone_id, new_version_id, record)
cls.echo('Activation of new zone version')
... | [
"def",
"create",
"(",
"cls",
",",
"zone_id",
",",
"record",
")",
":",
"cls",
".",
"echo",
"(",
"'Creating new zone version'",
")",
"new_version_id",
"=",
"Zone",
".",
"new",
"(",
"zone_id",
")",
"cls",
".",
"echo",
"(",
"'Updating zone version'",
")",
"cls... | Create a new zone version for record. | [
"Create",
"a",
"new",
"zone",
"version",
"for",
"record",
"."
] | python | train |
divio/django-filer | filer/management/commands/import_files.py | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/management/commands/import_files.py#L28-L56 | def import_file(self, file_obj, folder):
"""
Create a File or an Image into the given folder
"""
try:
iext = os.path.splitext(file_obj.name)[1].lower()
except: # noqa
iext = ''
if iext in ['.jpg', '.jpeg', '.png', '.gif']:
obj, created... | [
"def",
"import_file",
"(",
"self",
",",
"file_obj",
",",
"folder",
")",
":",
"try",
":",
"iext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file_obj",
".",
"name",
")",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"except",
":",
"# noqa",
"iext",
"... | Create a File or an Image into the given folder | [
"Create",
"a",
"File",
"or",
"an",
"Image",
"into",
"the",
"given",
"folder"
] | python | train |
theonion/django-bulbs | bulbs/reading_list/mixins.py | https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/reading_list/mixins.py#L85-L99 | def augment_reading_list(self, primary_query, augment_query=None, reverse_negate=False):
"""Apply injected logic for slicing reading lists with additional content."""
primary_query = self.validate_query(primary_query)
augment_query = self.get_validated_augment_query(augment_query=augment_query)
... | [
"def",
"augment_reading_list",
"(",
"self",
",",
"primary_query",
",",
"augment_query",
"=",
"None",
",",
"reverse_negate",
"=",
"False",
")",
":",
"primary_query",
"=",
"self",
".",
"validate_query",
"(",
"primary_query",
")",
"augment_query",
"=",
"self",
".",... | Apply injected logic for slicing reading lists with additional content. | [
"Apply",
"injected",
"logic",
"for",
"slicing",
"reading",
"lists",
"with",
"additional",
"content",
"."
] | python | train |
funkybob/knights-templater | knights/tags.py | https://github.com/funkybob/knights-templater/blob/b15cdbaae7d824d02f7f03ca04599ae94bb759dd/knights/tags.py#L106-L168 | def do_for(parser, token):
'''
{% for a, b, c in iterable %}
{% endfor %}
We create the structure:
with ContextWrapper(context) as context:
for a, b, c in iterable:
context.update(a=a, b=b, c=c)
...
If there is a {% empty %} clause, we create:
if iterable... | [
"def",
"do_for",
"(",
"parser",
",",
"token",
")",
":",
"code",
"=",
"ast",
".",
"parse",
"(",
"'for %s: pass'",
"%",
"token",
",",
"mode",
"=",
"'exec'",
")",
"# Grab the ast.For node",
"loop",
"=",
"code",
".",
"body",
"[",
"0",
"]",
"# Wrap its source... | {% for a, b, c in iterable %}
{% endfor %}
We create the structure:
with ContextWrapper(context) as context:
for a, b, c in iterable:
context.update(a=a, b=b, c=c)
...
If there is a {% empty %} clause, we create:
if iterable:
{ above code }
else:
... | [
"{",
"%",
"for",
"a",
"b",
"c",
"in",
"iterable",
"%",
"}"
] | python | train |
saltstack/salt | salt/utils/zfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/zfs.py#L477-L492 | def from_size(value):
'''
Convert zfs size (human readble) to python int (bytes)
'''
match_size = re_zfs_size.match(str(value))
if match_size:
v_unit = match_size.group(2).upper()[0]
v_size = float(match_size.group(1))
v_multiplier = math.pow(1024, zfs_size.index(v_unit) + 1)... | [
"def",
"from_size",
"(",
"value",
")",
":",
"match_size",
"=",
"re_zfs_size",
".",
"match",
"(",
"str",
"(",
"value",
")",
")",
"if",
"match_size",
":",
"v_unit",
"=",
"match_size",
".",
"group",
"(",
"2",
")",
".",
"upper",
"(",
")",
"[",
"0",
"]"... | Convert zfs size (human readble) to python int (bytes) | [
"Convert",
"zfs",
"size",
"(",
"human",
"readble",
")",
"to",
"python",
"int",
"(",
"bytes",
")"
] | python | train |
glut23/webvtt-py | webvtt/cli.py | https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/cli.py#L35-L47 | def segment(f, output, target_duration, mpegts):
"""Segment command."""
try:
target_duration = int(target_duration)
except ValueError:
exit('Error: Invalid target duration.')
try:
mpegts = int(mpegts)
except ValueError:
exit('Error: Invalid MPEGTS value.')
WebVT... | [
"def",
"segment",
"(",
"f",
",",
"output",
",",
"target_duration",
",",
"mpegts",
")",
":",
"try",
":",
"target_duration",
"=",
"int",
"(",
"target_duration",
")",
"except",
"ValueError",
":",
"exit",
"(",
"'Error: Invalid target duration.'",
")",
"try",
":",
... | Segment command. | [
"Segment",
"command",
"."
] | python | train |
guaix-ucm/numina | numina/array/ccd_line.py | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/ccd_line.py#L229-L232 | def linspace_pix(self, start=None, stop=None, pixel_step=1, y_vs_x=False):
"""Return x,y values evaluated with a given pixel step."""
return CCDLine.linspace_pix(self, start=start, stop=stop,
pixel_step=pixel_step, y_vs_x=y_vs_x) | [
"def",
"linspace_pix",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"pixel_step",
"=",
"1",
",",
"y_vs_x",
"=",
"False",
")",
":",
"return",
"CCDLine",
".",
"linspace_pix",
"(",
"self",
",",
"start",
"=",
"start",
",",
"stop... | Return x,y values evaluated with a given pixel step. | [
"Return",
"x",
"y",
"values",
"evaluated",
"with",
"a",
"given",
"pixel",
"step",
"."
] | python | train |
pyviz/holoviews | holoviews/plotting/bokeh/element.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/bokeh/element.py#L1997-L2019 | def _merge_tools(self, subplot):
"""
Merges tools on the overlay with those on the subplots.
"""
if self.batched and 'hover' in subplot.handles:
self.handles['hover'] = subplot.handles['hover']
elif 'hover' in subplot.handles and 'hover_tools' in self.handles:
... | [
"def",
"_merge_tools",
"(",
"self",
",",
"subplot",
")",
":",
"if",
"self",
".",
"batched",
"and",
"'hover'",
"in",
"subplot",
".",
"handles",
":",
"self",
".",
"handles",
"[",
"'hover'",
"]",
"=",
"subplot",
".",
"handles",
"[",
"'hover'",
"]",
"elif"... | Merges tools on the overlay with those on the subplots. | [
"Merges",
"tools",
"on",
"the",
"overlay",
"with",
"those",
"on",
"the",
"subplots",
"."
] | python | train |
tensorflow/tensorboard | tensorboard/plugins/image/summary_v2.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/image/summary_v2.py#L29-L88 | def image(name,
data,
step=None,
max_outputs=3,
description=None):
"""Write an image summary.
Arguments:
name: A name for this summary. The summary tag used for TensorBoard will
be this name prefixed by any active name scopes.
data: A `Tensor` representing pixe... | [
"def",
"image",
"(",
"name",
",",
"data",
",",
"step",
"=",
"None",
",",
"max_outputs",
"=",
"3",
",",
"description",
"=",
"None",
")",
":",
"summary_metadata",
"=",
"metadata",
".",
"create_summary_metadata",
"(",
"display_name",
"=",
"None",
",",
"descri... | Write an image summary.
Arguments:
name: A name for this summary. The summary tag used for TensorBoard will
be this name prefixed by any active name scopes.
data: A `Tensor` representing pixel data with shape `[k, h, w, c]`,
where `k` is the number of images, `h` and `w` are the height and
... | [
"Write",
"an",
"image",
"summary",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_dai.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_dai.py#L46-L66 | def arp_access_list_permit_permit_list_host_ip(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
arp = ET.SubElement(config, "arp", xmlns="urn:brocade.com:mgmt:brocade-dai")
access_list = ET.SubElement(arp, "access-list")
acl_name_key = ET.SubEleme... | [
"def",
"arp_access_list_permit_permit_list_host_ip",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"arp",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"arp\"",
",",
"xmlns",
"=",
"\"urn:... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
andersinno/python-database-sanitizer | database_sanitizer/config.py | https://github.com/andersinno/python-database-sanitizer/blob/742bc1f43526b60f322a48f18c900f94fd446ed4/database_sanitizer/config.py#L29-L48 | def from_file(cls, filename):
"""
Reads configuration from given path to a file in local file system and
returns parsed version of it.
:param filename: Path to the YAML file in local file system where the
configuration will be read from.
:type filename: ... | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
")",
":",
"instance",
"=",
"cls",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"file_stream",
":",
"config_data",
"=",
"yaml",
".",
"load",
"(",
"file_stream",
")",
"instance",
".... | Reads configuration from given path to a file in local file system and
returns parsed version of it.
:param filename: Path to the YAML file in local file system where the
configuration will be read from.
:type filename: str
:return: Configuration instance parse... | [
"Reads",
"configuration",
"from",
"given",
"path",
"to",
"a",
"file",
"in",
"local",
"file",
"system",
"and",
"returns",
"parsed",
"version",
"of",
"it",
"."
] | python | train |
bokeh/bokeh | bokeh/plotting/helpers.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/plotting/helpers.py#L544-L561 | def _tool_from_string(name):
""" Takes a string and returns a corresponding `Tool` instance. """
known_tools = sorted(_known_tools.keys())
if name in known_tools:
tool_fn = _known_tools[name]
if isinstance(tool_fn, string_types):
tool_fn = _known_tools[tool_fn]
return ... | [
"def",
"_tool_from_string",
"(",
"name",
")",
":",
"known_tools",
"=",
"sorted",
"(",
"_known_tools",
".",
"keys",
"(",
")",
")",
"if",
"name",
"in",
"known_tools",
":",
"tool_fn",
"=",
"_known_tools",
"[",
"name",
"]",
"if",
"isinstance",
"(",
"tool_fn",
... | Takes a string and returns a corresponding `Tool` instance. | [
"Takes",
"a",
"string",
"and",
"returns",
"a",
"corresponding",
"Tool",
"instance",
"."
] | python | train |
juju-solutions/charms.reactive | charms/reactive/relations.py | https://github.com/juju-solutions/charms.reactive/blob/e37e781432e77c12b63d2c739bd6cd70d3230c3a/charms/reactive/relations.py#L159-L192 | def _find_relation_factory(module):
"""
Attempt to find a RelationFactory subclass in the module.
Note: RelationFactory and RelationBase are ignored so they may
be imported to be used as base classes without fear.
"""
if not module:
return None
# All the RelationFactory subclasses
... | [
"def",
"_find_relation_factory",
"(",
"module",
")",
":",
"if",
"not",
"module",
":",
"return",
"None",
"# All the RelationFactory subclasses",
"candidates",
"=",
"[",
"o",
"for",
"o",
"in",
"(",
"getattr",
"(",
"module",
",",
"attr",
")",
"for",
"attr",
"in... | Attempt to find a RelationFactory subclass in the module.
Note: RelationFactory and RelationBase are ignored so they may
be imported to be used as base classes without fear. | [
"Attempt",
"to",
"find",
"a",
"RelationFactory",
"subclass",
"in",
"the",
"module",
"."
] | python | train |
Esri/ArcREST | src/arcrest/webmap/symbols.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/webmap/symbols.py#L448-L454 | def base64ToImage(imgData, out_path, out_file):
""" converts a base64 string to a file """
fh = open(os.path.join(out_path, out_file), "wb")
fh.write(imgData.decode('base64'))
fh.close()
del fh
return os.path.join(out_path, out_file) | [
"def",
"base64ToImage",
"(",
"imgData",
",",
"out_path",
",",
"out_file",
")",
":",
"fh",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"out_path",
",",
"out_file",
")",
",",
"\"wb\"",
")",
"fh",
".",
"write",
"(",
"imgData",
".",
"decode",
... | converts a base64 string to a file | [
"converts",
"a",
"base64",
"string",
"to",
"a",
"file"
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/controllers/state_machine_tree.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/state_machine_tree.py#L134-L142 | def _add_new_state(self, *event, **kwargs):
"""Triggered when shortcut keys for adding a new state are pressed, or Menu Bar "Edit, Add State" is clicked.
Adds a new state only if the the state machine tree is in focus.
"""
if react_to_event(self.view, self.view['state_machine_tree_view'... | [
"def",
"_add_new_state",
"(",
"self",
",",
"*",
"event",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"react_to_event",
"(",
"self",
".",
"view",
",",
"self",
".",
"view",
"[",
"'state_machine_tree_view'",
"]",
",",
"event",
")",
":",
"state_type",
"=",
"S... | Triggered when shortcut keys for adding a new state are pressed, or Menu Bar "Edit, Add State" is clicked.
Adds a new state only if the the state machine tree is in focus. | [
"Triggered",
"when",
"shortcut",
"keys",
"for",
"adding",
"a",
"new",
"state",
"are",
"pressed",
"or",
"Menu",
"Bar",
"Edit",
"Add",
"State",
"is",
"clicked",
"."
] | python | train |
ClericPy/torequests | torequests/dummy.py | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/dummy.py#L504-L512 | def set_frequency(self, host, sem=None, interval=None):
"""Set frequency for host with sem and interval."""
# single sem or global sem
sem = sem or self.sem
interval = self.interval if interval is None else interval
frequency = Frequency(sem, interval, host)
frequencies =... | [
"def",
"set_frequency",
"(",
"self",
",",
"host",
",",
"sem",
"=",
"None",
",",
"interval",
"=",
"None",
")",
":",
"# single sem or global sem",
"sem",
"=",
"sem",
"or",
"self",
".",
"sem",
"interval",
"=",
"self",
".",
"interval",
"if",
"interval",
"is"... | Set frequency for host with sem and interval. | [
"Set",
"frequency",
"for",
"host",
"with",
"sem",
"and",
"interval",
"."
] | python | train |
awacha/sastool | sastool/misc/easylsq.py | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/easylsq.py#L182-L215 | def simultaneous_nonlinear_leastsquares(xs, ys, dys, func, params_inits, verbose=False, **kwargs):
"""Do a simultaneous nonlinear least-squares fit and return the fitted
parameters as instances of ErrorValue.
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordin... | [
"def",
"simultaneous_nonlinear_leastsquares",
"(",
"xs",
",",
"ys",
",",
"dys",
",",
"func",
",",
"params_inits",
",",
"verbose",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"p",
",",
"dp",
",",
"statdict",
"=",
"simultaneous_nlsq_fit",
"(",
"xs",
"... | Do a simultaneous nonlinear least-squares fit and return the fitted
parameters as instances of ErrorValue.
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordinate vectors (1d numpy ndarrays)
`dys`: tuple of the errors of ordinate vectors (1d numpy ndarrays or N... | [
"Do",
"a",
"simultaneous",
"nonlinear",
"least",
"-",
"squares",
"fit",
"and",
"return",
"the",
"fitted",
"parameters",
"as",
"instances",
"of",
"ErrorValue",
"."
] | python | train |
PyCQA/pydocstyle | src/pydocstyle/parser.py | https://github.com/PyCQA/pydocstyle/blob/2549847f9efad225789f931e83dfe782418ca13e/src/pydocstyle/parser.py#L85-L93 | def source(self):
"""Return the source code for the definition."""
full_src = self._source[self._slice]
def is_empty_or_comment(line):
return line.strip() == '' or line.strip().startswith('#')
filtered_src = dropwhile(is_empty_or_comment, reversed(full_src))
return ... | [
"def",
"source",
"(",
"self",
")",
":",
"full_src",
"=",
"self",
".",
"_source",
"[",
"self",
".",
"_slice",
"]",
"def",
"is_empty_or_comment",
"(",
"line",
")",
":",
"return",
"line",
".",
"strip",
"(",
")",
"==",
"''",
"or",
"line",
".",
"strip",
... | Return the source code for the definition. | [
"Return",
"the",
"source",
"code",
"for",
"the",
"definition",
"."
] | python | train |
LonamiWebs/Telethon | telethon/network/mtprotostate.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/mtprotostate.py#L95-L114 | def encrypt_message_data(self, data):
"""
Encrypts the given message data using the current authorization key
following MTProto 2.0 guidelines core.telegram.org/mtproto/description.
"""
data = struct.pack('<qq', self.salt, self.id) + data
padding = os.urandom(-(len(data) ... | [
"def",
"encrypt_message_data",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"struct",
".",
"pack",
"(",
"'<qq'",
",",
"self",
".",
"salt",
",",
"self",
".",
"id",
")",
"+",
"data",
"padding",
"=",
"os",
".",
"urandom",
"(",
"-",
"(",
"len",
"... | Encrypts the given message data using the current authorization key
following MTProto 2.0 guidelines core.telegram.org/mtproto/description. | [
"Encrypts",
"the",
"given",
"message",
"data",
"using",
"the",
"current",
"authorization",
"key",
"following",
"MTProto",
"2",
".",
"0",
"guidelines",
"core",
".",
"telegram",
".",
"org",
"/",
"mtproto",
"/",
"description",
"."
] | python | train |
SpriteLink/NIPAP | nipap/nipap/backend.py | https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/nipap/nipap/backend.py#L1358-L1396 | def list_vrf(self, auth, spec=None):
""" Return a list of VRFs matching `spec`.
* `auth` [BaseAuth]
AAA options.
* `spec` [vrf_spec]
A VRF specification. If omitted, all VRFs are returned.
Returns a list of dicts.
This is the doc... | [
"def",
"list_vrf",
"(",
"self",
",",
"auth",
",",
"spec",
"=",
"None",
")",
":",
"if",
"spec",
"is",
"None",
":",
"spec",
"=",
"{",
"}",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"list_vrf called; spec: %s\"",
"%",
"unicode",
"(",
"spec",
")",
")"... | Return a list of VRFs matching `spec`.
* `auth` [BaseAuth]
AAA options.
* `spec` [vrf_spec]
A VRF specification. If omitted, all VRFs are returned.
Returns a list of dicts.
This is the documentation of the internal backend function. It's... | [
"Return",
"a",
"list",
"of",
"VRFs",
"matching",
"spec",
"."
] | python | train |
angr/claripy | claripy/vsa/strided_interval.py | https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/vsa/strided_interval.py#L654-L695 | def _rshift_arithmetic(self, shift_amount):
"""
Arithmetic shift right with a concrete shift amount
:param int shift_amount: Number of bits to shift right.
:return: The new StridedInterval after right shifting
:rtype: StridedInterval
"""
if self.is_empty:
... | [
"def",
"_rshift_arithmetic",
"(",
"self",
",",
"shift_amount",
")",
":",
"if",
"self",
".",
"is_empty",
":",
"return",
"self",
"# If straddling the north pole, we'll have to split it into two, perform arithmetic right shift on them",
"# individually, then union the result back togeth... | Arithmetic shift right with a concrete shift amount
:param int shift_amount: Number of bits to shift right.
:return: The new StridedInterval after right shifting
:rtype: StridedInterval | [
"Arithmetic",
"shift",
"right",
"with",
"a",
"concrete",
"shift",
"amount"
] | python | train |
andy-esch/sqterritory | sqterritory/territory.py | https://github.com/andy-esch/sqterritory/blob/53bcf7c8946f5d216d1ceccf55f9f339125b8205/sqterritory/territory.py#L139-L278 | def calc(self, maxiter=100, fixedprec=1e9):
"""Min Cost Flow"""
source_data_holder = []
N = self.targets.shape[0]
K = self.origins.shape[0]
# dict of labels for each target node
M, demand = self._get_demand_graph()
max_dist_trip = 400 # kilometers
cost_... | [
"def",
"calc",
"(",
"self",
",",
"maxiter",
"=",
"100",
",",
"fixedprec",
"=",
"1e9",
")",
":",
"source_data_holder",
"=",
"[",
"]",
"N",
"=",
"self",
".",
"targets",
".",
"shape",
"[",
"0",
"]",
"K",
"=",
"self",
".",
"origins",
".",
"shape",
"[... | Min Cost Flow | [
"Min",
"Cost",
"Flow"
] | python | train |
jhuapl-boss/intern | intern/service/boss/volume.py | https://github.com/jhuapl-boss/intern/blob/d8fc6df011d8f212c87e6a1fd4cc21cfb5d103ed/intern/service/boss/volume.py#L113-L126 | def reserve_ids(self, resource, num_ids):
"""Reserve a block of unique, sequential ids for annotations.
Args:
resource (intern.resource.Resource): Resource should be an annotation channel.
num_ids (int): Number of ids to reserve.
Returns:
(int): First id res... | [
"def",
"reserve_ids",
"(",
"self",
",",
"resource",
",",
"num_ids",
")",
":",
"return",
"self",
".",
"service",
".",
"reserve_ids",
"(",
"resource",
",",
"num_ids",
",",
"self",
".",
"url_prefix",
",",
"self",
".",
"auth",
",",
"self",
".",
"session",
... | Reserve a block of unique, sequential ids for annotations.
Args:
resource (intern.resource.Resource): Resource should be an annotation channel.
num_ids (int): Number of ids to reserve.
Returns:
(int): First id reserved. | [
"Reserve",
"a",
"block",
"of",
"unique",
"sequential",
"ids",
"for",
"annotations",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/jinja2/compiler.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/jinja2/compiler.py#L409-L460 | def signature(self, node, frame, extra_kwargs=None):
"""Writes a function call to the stream for the current node.
A leading comma is added automatically. The extra keyword
arguments may not include python keywords otherwise a syntax
error could occour. The extra keyword arguments shou... | [
"def",
"signature",
"(",
"self",
",",
"node",
",",
"frame",
",",
"extra_kwargs",
"=",
"None",
")",
":",
"# if any of the given keyword arguments is a python keyword",
"# we have to make sure that no invalid call is created.",
"kwarg_workaround",
"=",
"False",
"for",
"kwarg",
... | Writes a function call to the stream for the current node.
A leading comma is added automatically. The extra keyword
arguments may not include python keywords otherwise a syntax
error could occour. The extra keyword arguments should be given
as python dict. | [
"Writes",
"a",
"function",
"call",
"to",
"the",
"stream",
"for",
"the",
"current",
"node",
".",
"A",
"leading",
"comma",
"is",
"added",
"automatically",
".",
"The",
"extra",
"keyword",
"arguments",
"may",
"not",
"include",
"python",
"keywords",
"otherwise",
... | python | train |
PyCQA/pylint | pylint/pyreverse/diagrams.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/diagrams.py#L114-L120 | def add_object(self, title, node):
"""create a diagram object
"""
assert node not in self._nodes
ent = DiagramEntity(title, node)
self._nodes[node] = ent
self.objects.append(ent) | [
"def",
"add_object",
"(",
"self",
",",
"title",
",",
"node",
")",
":",
"assert",
"node",
"not",
"in",
"self",
".",
"_nodes",
"ent",
"=",
"DiagramEntity",
"(",
"title",
",",
"node",
")",
"self",
".",
"_nodes",
"[",
"node",
"]",
"=",
"ent",
"self",
"... | create a diagram object | [
"create",
"a",
"diagram",
"object"
] | python | test |
PmagPy/PmagPy | pmagpy/pmag.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L9233-L9261 | def getvec(gh, lat, lon):
"""
Evaluates the vector at a given latitude and longitude for a specified
set of coefficients
Parameters
----------
gh : a list of gauss coefficients
lat : latitude of location
long : longitude of location
Returns
-------
vec : direction in [dec, ... | [
"def",
"getvec",
"(",
"gh",
",",
"lat",
",",
"lon",
")",
":",
"sv",
"=",
"[",
"]",
"pad",
"=",
"120",
"-",
"len",
"(",
"gh",
")",
"for",
"x",
"in",
"range",
"(",
"pad",
")",
":",
"gh",
".",
"append",
"(",
"0.",
")",
"for",
"x",
"in",
"ran... | Evaluates the vector at a given latitude and longitude for a specified
set of coefficients
Parameters
----------
gh : a list of gauss coefficients
lat : latitude of location
long : longitude of location
Returns
-------
vec : direction in [dec, inc, intensity] | [
"Evaluates",
"the",
"vector",
"at",
"a",
"given",
"latitude",
"and",
"longitude",
"for",
"a",
"specified",
"set",
"of",
"coefficients"
] | python | train |
nicferrier/md | src/mdlib/client.py | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/client.py#L143-L169 | def lisp(self, foldername="INBOX", reverse=False, since=None, stream=sys.stdout):
"""Do JSON list of the folder to the stream.
'since' allows the listing to be date filtered since that
date. It should be a float, a time since epoch.
"""
def fromval(hdr):
if hdr:
... | [
"def",
"lisp",
"(",
"self",
",",
"foldername",
"=",
"\"INBOX\"",
",",
"reverse",
"=",
"False",
",",
"since",
"=",
"None",
",",
"stream",
"=",
"sys",
".",
"stdout",
")",
":",
"def",
"fromval",
"(",
"hdr",
")",
":",
"if",
"hdr",
":",
"return",
"parse... | Do JSON list of the folder to the stream.
'since' allows the listing to be date filtered since that
date. It should be a float, a time since epoch. | [
"Do",
"JSON",
"list",
"of",
"the",
"folder",
"to",
"the",
"stream",
"."
] | python | train |
rochacbruno/dynaconf | dynaconf/base.py | https://github.com/rochacbruno/dynaconf/blob/5a7cc8f8252251cbdf4f4112965801f9dfe2831d/dynaconf/base.py#L534-L537 | def clean(self, *args, **kwargs):
"""Clean all loaded values to reload when switching envs"""
for key in list(self.store.keys()):
self.unset(key) | [
"def",
"clean",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"store",
".",
"keys",
"(",
")",
")",
":",
"self",
".",
"unset",
"(",
"key",
")"
] | Clean all loaded values to reload when switching envs | [
"Clean",
"all",
"loaded",
"values",
"to",
"reload",
"when",
"switching",
"envs"
] | python | train |
adafruit/Adafruit_Python_BluefruitLE | Adafruit_BluefruitLE/bluez_dbus/gatt.py | https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/bluez_dbus/gatt.py#L111-L117 | def list_descriptors(self):
"""Return list of GATT descriptors that have been discovered for this
characteristic.
"""
paths = self._props.Get(_CHARACTERISTIC_INTERFACE, 'Descriptors')
return map(BluezGattDescriptor,
get_provider()._get_objects_by_path(paths)) | [
"def",
"list_descriptors",
"(",
"self",
")",
":",
"paths",
"=",
"self",
".",
"_props",
".",
"Get",
"(",
"_CHARACTERISTIC_INTERFACE",
",",
"'Descriptors'",
")",
"return",
"map",
"(",
"BluezGattDescriptor",
",",
"get_provider",
"(",
")",
".",
"_get_objects_by_path... | Return list of GATT descriptors that have been discovered for this
characteristic. | [
"Return",
"list",
"of",
"GATT",
"descriptors",
"that",
"have",
"been",
"discovered",
"for",
"this",
"characteristic",
"."
] | python | valid |
GoogleCloudPlatform/appengine-pipelines | python/src/pipeline/__init__.py | https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/python/src/pipeline/__init__.py#L22-L37 | def _fix_path():
"""Finds the google_appengine directory and fixes Python imports to use it."""
import os
import sys
all_paths = os.environ.get('PYTHONPATH').split(os.pathsep)
for path_dir in all_paths:
dev_appserver_path = os.path.join(path_dir, 'dev_appserver.py')
if os.path.exists(dev_appserver_pat... | [
"def",
"_fix_path",
"(",
")",
":",
"import",
"os",
"import",
"sys",
"all_paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PYTHONPATH'",
")",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"for",
"path_dir",
"in",
"all_paths",
":",
"dev_appserver_path... | Finds the google_appengine directory and fixes Python imports to use it. | [
"Finds",
"the",
"google_appengine",
"directory",
"and",
"fixes",
"Python",
"imports",
"to",
"use",
"it",
"."
] | python | train |
pywbem/pywbem | pywbem/cim_obj.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L2877-L2953 | def tocimxml(self, ignore_path=False):
"""
Return the CIM-XML representation of this CIM instance,
as an object of an appropriate subclass of :term:`Element`.
If the instance has no instance path specified or if `ignore_path` is
`True`, the returned CIM-XML representation is an ... | [
"def",
"tocimxml",
"(",
"self",
",",
"ignore_path",
"=",
"False",
")",
":",
"# The items in the self.properties dictionary are required to be",
"# CIMProperty objects and that is ensured when initializing a",
"# CIMInstance object and when setting the entire self.properties",
"# attribute.... | Return the CIM-XML representation of this CIM instance,
as an object of an appropriate subclass of :term:`Element`.
If the instance has no instance path specified or if `ignore_path` is
`True`, the returned CIM-XML representation is an `INSTANCE` element
consistent with :term:`DSP0201`.... | [
"Return",
"the",
"CIM",
"-",
"XML",
"representation",
"of",
"this",
"CIM",
"instance",
"as",
"an",
"object",
"of",
"an",
"appropriate",
"subclass",
"of",
":",
"term",
":",
"Element",
"."
] | python | train |
lekhakpadmanabh/Summarizer | smrzr/core.py | https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L32-L37 | def _tokenize(sentence):
'''Tokenizer and Stemmer'''
_tokens = nltk.word_tokenize(sentence)
tokens = [stemmer.stem(tk) for tk in _tokens]
return tokens | [
"def",
"_tokenize",
"(",
"sentence",
")",
":",
"_tokens",
"=",
"nltk",
".",
"word_tokenize",
"(",
"sentence",
")",
"tokens",
"=",
"[",
"stemmer",
".",
"stem",
"(",
"tk",
")",
"for",
"tk",
"in",
"_tokens",
"]",
"return",
"tokens"
] | Tokenizer and Stemmer | [
"Tokenizer",
"and",
"Stemmer"
] | python | train |
aio-libs/aiohttp-cors | aiohttp_cors/__init__.py | https://github.com/aio-libs/aiohttp-cors/blob/14affbd95c88c675eb513c1d295ede1897930f94/aiohttp_cors/__init__.py#L40-L67 | def setup(app: web.Application, *,
defaults: Mapping[str, Union[ResourceOptions,
Mapping[str, Any]]]=None) -> CorsConfig:
"""Setup CORS processing for the application.
To enable CORS for a resource you need to explicitly add route for
that resource using `Co... | [
"def",
"setup",
"(",
"app",
":",
"web",
".",
"Application",
",",
"*",
",",
"defaults",
":",
"Mapping",
"[",
"str",
",",
"Union",
"[",
"ResourceOptions",
",",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
"]",
"=",
"None",
")",
"->",
"CorsConfig",
":... | Setup CORS processing for the application.
To enable CORS for a resource you need to explicitly add route for
that resource using `CorsConfig.add()` method::
app = aiohttp.web.Application()
cors = aiohttp_cors.setup(app)
cors.add(
app.router.add_route("GET", "/resource", ha... | [
"Setup",
"CORS",
"processing",
"for",
"the",
"application",
"."
] | python | train |
radjkarl/imgProcessor | imgProcessor/camera/LensDistortion.py | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L186-L212 | def drawChessboard(self, img=None):
'''
draw a grid fitting to the last added image
on this one or an extra image
img == None
==False -> draw chessbord on empty image
==img
'''
assert self.findCount > 0, 'cannot draw chessboard if nothing f... | [
"def",
"drawChessboard",
"(",
"self",
",",
"img",
"=",
"None",
")",
":",
"assert",
"self",
".",
"findCount",
">",
"0",
",",
"'cannot draw chessboard if nothing found'",
"if",
"img",
"is",
"None",
":",
"img",
"=",
"self",
".",
"img",
"elif",
"isinstance",
"... | draw a grid fitting to the last added image
on this one or an extra image
img == None
==False -> draw chessbord on empty image
==img | [
"draw",
"a",
"grid",
"fitting",
"to",
"the",
"last",
"added",
"image",
"on",
"this",
"one",
"or",
"an",
"extra",
"image",
"img",
"==",
"None",
"==",
"False",
"-",
">",
"draw",
"chessbord",
"on",
"empty",
"image",
"==",
"img"
] | python | train |
google/prettytensor | prettytensor/pretty_tensor_class.py | https://github.com/google/prettytensor/blob/75daa0b11252590f548da5647addc0ea610c4c45/prettytensor/pretty_tensor_class.py#L732-L750 | def attach_template(self, _template, _key, **unbound_var_values):
"""Attaches the template to this such that _key=this layer.
Note: names were chosen to avoid conflicts with any likely unbound_var keys.
Args:
_template: The template to construct.
_key: The key that this layer should replace.
... | [
"def",
"attach_template",
"(",
"self",
",",
"_template",
",",
"_key",
",",
"*",
"*",
"unbound_var_values",
")",
":",
"if",
"_key",
"in",
"unbound_var_values",
":",
"raise",
"ValueError",
"(",
"'%s specified twice.'",
"%",
"_key",
")",
"unbound_var_values",
"[",
... | Attaches the template to this such that _key=this layer.
Note: names were chosen to avoid conflicts with any likely unbound_var keys.
Args:
_template: The template to construct.
_key: The key that this layer should replace.
**unbound_var_values: The values for the unbound_vars.
Returns:
... | [
"Attaches",
"the",
"template",
"to",
"this",
"such",
"that",
"_key",
"=",
"this",
"layer",
"."
] | python | train |
scanny/python-pptx | pptx/opc/oxml.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/opc/oxml.py#L135-L142 | def add_override(self, partname, content_type):
"""
Add a child ``<Override>`` element with attributes set to parameter
values.
"""
return self._add_override(
partName=partname, contentType=content_type
) | [
"def",
"add_override",
"(",
"self",
",",
"partname",
",",
"content_type",
")",
":",
"return",
"self",
".",
"_add_override",
"(",
"partName",
"=",
"partname",
",",
"contentType",
"=",
"content_type",
")"
] | Add a child ``<Override>`` element with attributes set to parameter
values. | [
"Add",
"a",
"child",
"<Override",
">",
"element",
"with",
"attributes",
"set",
"to",
"parameter",
"values",
"."
] | python | train |
spacetelescope/stsci.tools | lib/stsci/tools/basicpar.py | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L656-L661 | def _getPFilename(self,native,prompt):
"""Get p_filename field for this parameter
Same as get for non-list params
"""
return self.get(native=native,prompt=prompt) | [
"def",
"_getPFilename",
"(",
"self",
",",
"native",
",",
"prompt",
")",
":",
"return",
"self",
".",
"get",
"(",
"native",
"=",
"native",
",",
"prompt",
"=",
"prompt",
")"
] | Get p_filename field for this parameter
Same as get for non-list params | [
"Get",
"p_filename",
"field",
"for",
"this",
"parameter"
] | python | train |
mitsei/dlkit | dlkit/services/authorization.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/authorization.py#L594-L602 | def get_vaults(self):
"""Pass through to provider VaultLookupSession.get_vaults"""
# Implemented from kitosid template for -
# osid.resource.BinLookupSession.get_bins_template
catalogs = self._get_provider_session('vault_lookup_session').get_vaults()
cat_list = []
for cat... | [
"def",
"get_vaults",
"(",
"self",
")",
":",
"# Implemented from kitosid template for -",
"# osid.resource.BinLookupSession.get_bins_template",
"catalogs",
"=",
"self",
".",
"_get_provider_session",
"(",
"'vault_lookup_session'",
")",
".",
"get_vaults",
"(",
")",
"cat_list",
... | Pass through to provider VaultLookupSession.get_vaults | [
"Pass",
"through",
"to",
"provider",
"VaultLookupSession",
".",
"get_vaults"
] | python | train |
spyder-ide/spyder-notebook | spyder_notebook/notebookplugin.py | https://github.com/spyder-ide/spyder-notebook/blob/54e626b9d2a3fccd3e4625b0f97fe06e5bb1a6db/spyder_notebook/notebookplugin.py#L404-L410 | def create_welcome_client(self):
"""Create a welcome client with some instructions."""
if self.tabwidget.count() == 0:
welcome = open(WELCOME).read()
client = NotebookClient(self, WELCOME, ini_message=welcome)
self.add_tab(client)
return client | [
"def",
"create_welcome_client",
"(",
"self",
")",
":",
"if",
"self",
".",
"tabwidget",
".",
"count",
"(",
")",
"==",
"0",
":",
"welcome",
"=",
"open",
"(",
"WELCOME",
")",
".",
"read",
"(",
")",
"client",
"=",
"NotebookClient",
"(",
"self",
",",
"WEL... | Create a welcome client with some instructions. | [
"Create",
"a",
"welcome",
"client",
"with",
"some",
"instructions",
"."
] | python | train |
praekeltfoundation/seed-message-sender | message_sender/tasks.py | https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/tasks.py#L498-L505 | def create_archived_outbound(self, date, filename):
"""
Creates the required ArchivedOutbound entry with the file specified
at `filename`
"""
with open(filename, "rb") as f:
f = File(f)
ArchivedOutbounds.objects.create(date=date, archive=f) | [
"def",
"create_archived_outbound",
"(",
"self",
",",
"date",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"f",
":",
"f",
"=",
"File",
"(",
"f",
")",
"ArchivedOutbounds",
".",
"objects",
".",
"create",
"(",
"date... | Creates the required ArchivedOutbound entry with the file specified
at `filename` | [
"Creates",
"the",
"required",
"ArchivedOutbound",
"entry",
"with",
"the",
"file",
"specified",
"at",
"filename"
] | python | train |
shaypal5/strct | strct/dicts/_dict.py | https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/dicts/_dict.py#L96-L128 | def safe_nested_val(key_tuple, dict_obj, default_value=None):
"""Return a value from nested dicts by the order of the given keys tuple.
Parameters
----------
key_tuple : tuple
The keys to use for extraction, in order.
dict_obj : dict
The outer-most dict to extract from.
default_... | [
"def",
"safe_nested_val",
"(",
"key_tuple",
",",
"dict_obj",
",",
"default_value",
"=",
"None",
")",
":",
"try",
":",
"return",
"get_nested_val",
"(",
"key_tuple",
",",
"dict_obj",
")",
"except",
"(",
"KeyError",
",",
"IndexError",
",",
"TypeError",
")",
":"... | Return a value from nested dicts by the order of the given keys tuple.
Parameters
----------
key_tuple : tuple
The keys to use for extraction, in order.
dict_obj : dict
The outer-most dict to extract from.
default_value : object, default None
The value to return when no matc... | [
"Return",
"a",
"value",
"from",
"nested",
"dicts",
"by",
"the",
"order",
"of",
"the",
"given",
"keys",
"tuple",
"."
] | python | train |
UCL-INGI/INGInious | inginious/frontend/pages/course_admin/settings.py | https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/settings.py#L22-L103 | def POST_AUTH(self, courseid): # pylint: disable=arguments-differ
""" POST request """
course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False)
errors = []
course_content = {}
try:
data = web.input()
course_content = self.course_fac... | [
"def",
"POST_AUTH",
"(",
"self",
",",
"courseid",
")",
":",
"# pylint: disable=arguments-differ",
"course",
",",
"__",
"=",
"self",
".",
"get_course_and_check_rights",
"(",
"courseid",
",",
"allow_all_staff",
"=",
"False",
")",
"errors",
"=",
"[",
"]",
"course_c... | POST request | [
"POST",
"request"
] | python | train |
se-esss-litterbox/Pynac | Pynac/Core.py | https://github.com/se-esss-litterbox/Pynac/blob/97e20aa85d20112cd114faa54a8197c5d0f61209/Pynac/Core.py#L666-L674 | def get_number_of_particles():
"""
Queries the ``dynac.short`` file for the number of particles used in the
simulation.
"""
with open('dynac.short') as f:
data_str = ''.join(line for line in f.readlines())
num_of_parts = int(data_str.split('Simulation with')[1].strip().split()[0])
... | [
"def",
"get_number_of_particles",
"(",
")",
":",
"with",
"open",
"(",
"'dynac.short'",
")",
"as",
"f",
":",
"data_str",
"=",
"''",
".",
"join",
"(",
"line",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
")",
"num_of_parts",
"=",
"int",
"(",
"... | Queries the ``dynac.short`` file for the number of particles used in the
simulation. | [
"Queries",
"the",
"dynac",
".",
"short",
"file",
"for",
"the",
"number",
"of",
"particles",
"used",
"in",
"the",
"simulation",
"."
] | python | train |
geographika/mappyfile | mappyfile/pprint.py | https://github.com/geographika/mappyfile/blob/aecbc5e66ec06896bc4c5db41313503468829d00/mappyfile/pprint.py#L46-L56 | def escape_quotes(self, val):
"""
Escape any quotes in a value
"""
if self.is_string(val) and self._in_quotes(val, self.quote):
# make sure any previously escaped quotes are not re-escaped
middle = self.remove_quotes(val).replace("\\" + self.quote, self.quote)
... | [
"def",
"escape_quotes",
"(",
"self",
",",
"val",
")",
":",
"if",
"self",
".",
"is_string",
"(",
"val",
")",
"and",
"self",
".",
"_in_quotes",
"(",
"val",
",",
"self",
".",
"quote",
")",
":",
"# make sure any previously escaped quotes are not re-escaped",
"midd... | Escape any quotes in a value | [
"Escape",
"any",
"quotes",
"in",
"a",
"value"
] | python | train |
encode/uvicorn | uvicorn/middleware/message_logger.py | https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/middleware/message_logger.py#L11-L22 | def message_with_placeholders(message):
"""
Return an ASGI message, with any body-type content omitted and replaced
with a placeholder.
"""
new_message = message.copy()
for attr in PLACEHOLDER_FORMAT.keys():
if message.get(attr) is not None:
content = message[attr]
... | [
"def",
"message_with_placeholders",
"(",
"message",
")",
":",
"new_message",
"=",
"message",
".",
"copy",
"(",
")",
"for",
"attr",
"in",
"PLACEHOLDER_FORMAT",
".",
"keys",
"(",
")",
":",
"if",
"message",
".",
"get",
"(",
"attr",
")",
"is",
"not",
"None",... | Return an ASGI message, with any body-type content omitted and replaced
with a placeholder. | [
"Return",
"an",
"ASGI",
"message",
"with",
"any",
"body",
"-",
"type",
"content",
"omitted",
"and",
"replaced",
"with",
"a",
"placeholder",
"."
] | python | train |
frasertweedale/ledgertools | ltlib/score.py | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/score.py#L34-L43 | def append(self, item):
"""Append an item to the score set.
item is a pair tuple, the first element of which is a valid dict
key and the second of which is a numeric value.
"""
if item in self:
self.items[item[0]].append(item[1])
else:
self.items[... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
"in",
"self",
":",
"self",
".",
"items",
"[",
"item",
"[",
"0",
"]",
"]",
".",
"append",
"(",
"item",
"[",
"1",
"]",
")",
"else",
":",
"self",
".",
"items",
"[",
"item",
"[",
... | Append an item to the score set.
item is a pair tuple, the first element of which is a valid dict
key and the second of which is a numeric value. | [
"Append",
"an",
"item",
"to",
"the",
"score",
"set",
"."
] | python | train |
bapakode/OmMongo | ommongo/document.py | https://github.com/bapakode/OmMongo/blob/52b5a5420516dc709f2d2eb065818c7973991ce3/ommongo/document.py#L633-L644 | def geo2d(self, name, min=None, max=None):
""" Create a 2d index. See:
http://www.mongodb.org/display/DOCS/Geospatial+Indexing
:param name: Name of the indexed column
:param min: minimum value for the index
:param max: minimum value for the index
"""
... | [
"def",
"geo2d",
"(",
"self",
",",
"name",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"self",
".",
"components",
".",
"append",
"(",
"(",
"name",
",",
"GEO2D",
")",
")",
"self",
".",
"__min",
"=",
"min",
"self",
".",
"__max",
"=... | Create a 2d index. See:
http://www.mongodb.org/display/DOCS/Geospatial+Indexing
:param name: Name of the indexed column
:param min: minimum value for the index
:param max: minimum value for the index | [
"Create",
"a",
"2d",
"index",
".",
"See",
":",
"http",
":",
"//",
"www",
".",
"mongodb",
".",
"org",
"/",
"display",
"/",
"DOCS",
"/",
"Geospatial",
"+",
"Indexing"
] | python | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L409-L430 | def _send_long(self,value):
"""
Convert a numerical value into an integer, then to a bytes object. Check
bounds for signed long.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
new_... | [
"def",
"_send_long",
"(",
"self",
",",
"value",
")",
":",
"# Coerce to int. This will throw a ValueError if the value can't ",
"# actually be converted.",
"if",
"type",
"(",
"value",
")",
"!=",
"int",
":",
"new_value",
"=",
"int",
"(",
"value",
")",
"if",
"self",
... | Convert a numerical value into an integer, then to a bytes object. Check
bounds for signed long. | [
"Convert",
"a",
"numerical",
"value",
"into",
"an",
"integer",
"then",
"to",
"a",
"bytes",
"object",
".",
"Check",
"bounds",
"for",
"signed",
"long",
"."
] | python | train |
mjirik/imcut | imcut/pycut.py | https://github.com/mjirik/imcut/blob/1b38e7cd18a7a38fe683c1cabe1222fe5fa03aa3/imcut/pycut.py#L203-L221 | def __ms_npenalty_fcn(self, axis, mask, orig_shape):
"""
:param axis: direction of edge
:param mask: 3d ndarray with ones where is fine resolution
Neighboorhood penalty between small pixels should be smaller then in
bigger tiles. This is the way how to set it.
"""
... | [
"def",
"__ms_npenalty_fcn",
"(",
"self",
",",
"axis",
",",
"mask",
",",
"orig_shape",
")",
":",
"maskz",
"=",
"zoom_to_shape",
"(",
"mask",
",",
"orig_shape",
")",
"maskz_new",
"=",
"np",
".",
"zeros",
"(",
"orig_shape",
",",
"dtype",
"=",
"np",
".",
"... | :param axis: direction of edge
:param mask: 3d ndarray with ones where is fine resolution
Neighboorhood penalty between small pixels should be smaller then in
bigger tiles. This is the way how to set it. | [
":",
"param",
"axis",
":",
"direction",
"of",
"edge",
":",
"param",
"mask",
":",
"3d",
"ndarray",
"with",
"ones",
"where",
"is",
"fine",
"resolution"
] | python | train |
LionelR/pyair | pyair/xair.py | https://github.com/LionelR/pyair/blob/467e8a843ca9f882f8bb2958805b7293591996ad/pyair/xair.py#L160-L175 | def liste_parametres(self, parametre=None):
"""
Liste des paramètres
Paramètres:
parametre: si fourni, retourne l'entrée pour ce parametre uniquement
"""
condition = ""
if parametre:
condition = "WHERE CCHIM='%s'" % parametre
_sql = """SELECT... | [
"def",
"liste_parametres",
"(",
"self",
",",
"parametre",
"=",
"None",
")",
":",
"condition",
"=",
"\"\"",
"if",
"parametre",
":",
"condition",
"=",
"\"WHERE CCHIM='%s'\"",
"%",
"parametre",
"_sql",
"=",
"\"\"\"SELECT CCHIM AS PARAMETRE,\n NCON AS LIBELLE,\n ... | Liste des paramètres
Paramètres:
parametre: si fourni, retourne l'entrée pour ce parametre uniquement | [
"Liste",
"des",
"paramètres"
] | python | valid |
joeferraro/mm | mm/sforce/base.py | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L570-L576 | def describeSObjects(self, sObjectTypes):
'''
An array-based version of describeSObject; describes metadata (field list
and object properties) for the specified object or array of objects.
'''
self._setHeaders('describeSObjects')
return self._handleResultTyping(self._sforce.service.describeSObje... | [
"def",
"describeSObjects",
"(",
"self",
",",
"sObjectTypes",
")",
":",
"self",
".",
"_setHeaders",
"(",
"'describeSObjects'",
")",
"return",
"self",
".",
"_handleResultTyping",
"(",
"self",
".",
"_sforce",
".",
"service",
".",
"describeSObjects",
"(",
"sObjectTy... | An array-based version of describeSObject; describes metadata (field list
and object properties) for the specified object or array of objects. | [
"An",
"array",
"-",
"based",
"version",
"of",
"describeSObject",
";",
"describes",
"metadata",
"(",
"field",
"list",
"and",
"object",
"properties",
")",
"for",
"the",
"specified",
"object",
"or",
"array",
"of",
"objects",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.