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 |
|---|---|---|---|---|---|---|---|---|
Becksteinlab/GromacsWrapper | gromacs/fileformats/xvg.py | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/fileformats/xvg.py#L1044-L1070 | def decimate_error(self, a, maxpoints, **kwargs):
"""Return data *a* error-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates an
error estimate in each bin as the decimated data, using
:func:`numkit.timeseries.error_histogrammed_function`. The
... | [
"def",
"decimate_error",
"(",
"self",
",",
"a",
",",
"maxpoints",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Using undocumented decimate_error() is highly EXPERIMENTAL\"",
",",
"category",
"=",
"gromacs",
".",
"exceptions",
".",
"LowAccura... | Return data *a* error-decimated on *maxpoints*.
Histograms each column into *maxpoints* bins and calculates an
error estimate in each bin as the decimated data, using
:func:`numkit.timeseries.error_histogrammed_function`. The
coarse grained time in the first column contains the centers
... | [
"Return",
"data",
"*",
"a",
"*",
"error",
"-",
"decimated",
"on",
"*",
"maxpoints",
"*",
"."
] | python | valid |
quantopian/zipline | zipline/algorithm.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1457-L1466 | def on_dt_changed(self, dt):
"""
Callback triggered by the simulation loop whenever the current dt
changes.
Any logic that should happen exactly once at the start of each datetime
group should happen here.
"""
self.datetime = dt
self.blotter.set_date(dt) | [
"def",
"on_dt_changed",
"(",
"self",
",",
"dt",
")",
":",
"self",
".",
"datetime",
"=",
"dt",
"self",
".",
"blotter",
".",
"set_date",
"(",
"dt",
")"
] | Callback triggered by the simulation loop whenever the current dt
changes.
Any logic that should happen exactly once at the start of each datetime
group should happen here. | [
"Callback",
"triggered",
"by",
"the",
"simulation",
"loop",
"whenever",
"the",
"current",
"dt",
"changes",
"."
] | python | train |
dw/mitogen | ansible_mitogen/mixins.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/ansible_mitogen/mixins.py#L240-L250 | def _fixup_perms2(self, remote_paths, remote_user=None, execute=True):
"""
Mitogen always executes ActionBase helper methods in the context of the
target user account, so it is never necessary to modify permissions
except to ensure the execute bit is set if requested.
"""
... | [
"def",
"_fixup_perms2",
"(",
"self",
",",
"remote_paths",
",",
"remote_user",
"=",
"None",
",",
"execute",
"=",
"True",
")",
":",
"LOG",
".",
"debug",
"(",
"'_fixup_perms2(%r, remote_user=%r, execute=%r)'",
",",
"remote_paths",
",",
"remote_user",
",",
"execute",
... | Mitogen always executes ActionBase helper methods in the context of the
target user account, so it is never necessary to modify permissions
except to ensure the execute bit is set if requested. | [
"Mitogen",
"always",
"executes",
"ActionBase",
"helper",
"methods",
"in",
"the",
"context",
"of",
"the",
"target",
"user",
"account",
"so",
"it",
"is",
"never",
"necessary",
"to",
"modify",
"permissions",
"except",
"to",
"ensure",
"the",
"execute",
"bit",
"is"... | python | train |
bjmorgan/lattice_mc | lattice_mc/jump.py | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L79-L90 | def nearest_neighbour_delta_E( self ):
"""
Nearest-neighbour interaction contribution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (nearest-neighbour)
"""
delta_nn = self.final_site.nn_occupation... | [
"def",
"nearest_neighbour_delta_E",
"(",
"self",
")",
":",
"delta_nn",
"=",
"self",
".",
"final_site",
".",
"nn_occupation",
"(",
")",
"-",
"self",
".",
"initial_site",
".",
"nn_occupation",
"(",
")",
"-",
"1",
"# -1 because the hopping ion is not counted in the fin... | Nearest-neighbour interaction contribution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (nearest-neighbour) | [
"Nearest",
"-",
"neighbour",
"interaction",
"contribution",
"to",
"the",
"change",
"in",
"system",
"energy",
"if",
"this",
"jump",
"were",
"accepted",
"."
] | python | train |
OSSOS/MOP | src/ossos/core/scripts/mk_mopheader.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/scripts/mk_mopheader.py#L36-L67 | def mk_mopheader(expnum, ccd, version, dry_run=False, prefix=""):
"""Run the OSSOS mopheader script.
"""
## confirm destination directory exists.
destdir = os.path.dirname(
storage.dbimages_uri(expnum, ccd, prefix=prefix, version=version, ext='fits'))
if not dry_run:
storage.mkdir(d... | [
"def",
"mk_mopheader",
"(",
"expnum",
",",
"ccd",
",",
"version",
",",
"dry_run",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
":",
"## confirm destination directory exists.",
"destdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"storage",
".",
"dbimage... | Run the OSSOS mopheader script. | [
"Run",
"the",
"OSSOS",
"mopheader",
"script",
"."
] | python | train |
belbio/bel | bel/nanopub/pubmed.py | https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/nanopub/pubmed.py#L62-L135 | def get_pubtator(pmid):
"""Get Pubtator Bioconcepts from Pubmed Abstract
Re-configure the denotations into an annotation dictionary format
and collapse duplicate terms so that their spans are in a list.
"""
r = get_url(PUBTATOR_TMPL.replace("PMID", pmid), timeout=10)
if r and r.status_code == 2... | [
"def",
"get_pubtator",
"(",
"pmid",
")",
":",
"r",
"=",
"get_url",
"(",
"PUBTATOR_TMPL",
".",
"replace",
"(",
"\"PMID\"",
",",
"pmid",
")",
",",
"timeout",
"=",
"10",
")",
"if",
"r",
"and",
"r",
".",
"status_code",
"==",
"200",
":",
"pubtator",
"=",
... | Get Pubtator Bioconcepts from Pubmed Abstract
Re-configure the denotations into an annotation dictionary format
and collapse duplicate terms so that their spans are in a list. | [
"Get",
"Pubtator",
"Bioconcepts",
"from",
"Pubmed",
"Abstract"
] | python | train |
krischer/mtspec | mtspec/util.py | https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/util.py#L43-L54 | def _load_mtdata(gzfile):
"""
Simple helper function that finds the test data in the directory tree
and loads it using :func:`gzip.open` and :func:`numpy.loadtxt`.
:param gzfile: Filename
:type gzfile: str
:returns: data
:rtype: numpy.ndarray
"""
path = os.path.join(os.path.dirname(... | [
"def",
"_load_mtdata",
"(",
"gzfile",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'tests'",
",",
"'data'",
",",
"gzfile",
")",
"return",
"np",
".",
"loadtxt",
"(",
"gzip... | Simple helper function that finds the test data in the directory tree
and loads it using :func:`gzip.open` and :func:`numpy.loadtxt`.
:param gzfile: Filename
:type gzfile: str
:returns: data
:rtype: numpy.ndarray | [
"Simple",
"helper",
"function",
"that",
"finds",
"the",
"test",
"data",
"in",
"the",
"directory",
"tree",
"and",
"loads",
"it",
"using",
":",
"func",
":",
"gzip",
".",
"open",
"and",
":",
"func",
":",
"numpy",
".",
"loadtxt",
"."
] | python | train |
oauthlib/oauthlib | oauthlib/oauth2/rfc6749/request_validator.py | https://github.com/oauthlib/oauthlib/blob/30321dd3c0ca784d3508a1970cf90d9f76835c79/oauthlib/oauth2/rfc6749/request_validator.py#L294-L303 | def save_token(self, token, request, *args, **kwargs):
"""Persist the token with a token type specific method.
Currently, only save_bearer_token is supported.
:param token: A (Bearer) token dict.
:param request: OAuthlib request.
:type request: oauthlib.common.Request
"... | [
"def",
"save_token",
"(",
"self",
",",
"token",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"save_bearer_token",
"(",
"token",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Persist the token with a token type specific method.
Currently, only save_bearer_token is supported.
:param token: A (Bearer) token dict.
:param request: OAuthlib request.
:type request: oauthlib.common.Request | [
"Persist",
"the",
"token",
"with",
"a",
"token",
"type",
"specific",
"method",
"."
] | python | train |
projectshift/shift-boiler | boiler/user/user_service.py | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/user_service.py#L358-L385 | def register(self, user_data, base_confirm_url='', send_welcome=True):
"""
Register user
Accepts user data, validates it and performs registration. Will send
a welcome message with a confirmation link on success.
:param user_data: dic, populate user with data
:param send... | [
"def",
"register",
"(",
"self",
",",
"user_data",
",",
"base_confirm_url",
"=",
"''",
",",
"send_welcome",
"=",
"True",
")",
":",
"user",
"=",
"self",
".",
"__model__",
"(",
"*",
"*",
"user_data",
")",
"schema",
"=",
"RegisterSchema",
"(",
")",
"valid",
... | Register user
Accepts user data, validates it and performs registration. Will send
a welcome message with a confirmation link on success.
:param user_data: dic, populate user with data
:param send_welcome: bool, whether to send welcome or skip it (testing)
:param base_confirm_ur... | [
"Register",
"user",
"Accepts",
"user",
"data",
"validates",
"it",
"and",
"performs",
"registration",
".",
"Will",
"send",
"a",
"welcome",
"message",
"with",
"a",
"confirmation",
"link",
"on",
"success",
"."
] | python | train |
Qiskit/qiskit-terra | qiskit/quantum_info/operators/channel/transformations.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L305-L308 | def _choi_to_chi(data, input_dim, output_dim):
"""Transform Choi representation to the Chi representation."""
num_qubits = int(np.log2(input_dim))
return _transform_to_pauli(data, num_qubits) | [
"def",
"_choi_to_chi",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"num_qubits",
"=",
"int",
"(",
"np",
".",
"log2",
"(",
"input_dim",
")",
")",
"return",
"_transform_to_pauli",
"(",
"data",
",",
"num_qubits",
")"
] | Transform Choi representation to the Chi representation. | [
"Transform",
"Choi",
"representation",
"to",
"the",
"Chi",
"representation",
"."
] | python | test |
divio/django-filer | filer/server/backends/base.py | https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/server/backends/base.py#L24-L40 | def save_as_header(self, response, **kwargs):
"""
* if save_as is False the header will not be added
* if save_as is a filename, it will be used in the header
* if save_as is True or None the filename will be determined from the
file path
"""
save_as = kwargs.ge... | [
"def",
"save_as_header",
"(",
"self",
",",
"response",
",",
"*",
"*",
"kwargs",
")",
":",
"save_as",
"=",
"kwargs",
".",
"get",
"(",
"'save_as'",
",",
"None",
")",
"if",
"save_as",
"is",
"False",
":",
"return",
"file_obj",
"=",
"kwargs",
".",
"get",
... | * if save_as is False the header will not be added
* if save_as is a filename, it will be used in the header
* if save_as is True or None the filename will be determined from the
file path | [
"*",
"if",
"save_as",
"is",
"False",
"the",
"header",
"will",
"not",
"be",
"added",
"*",
"if",
"save_as",
"is",
"a",
"filename",
"it",
"will",
"be",
"used",
"in",
"the",
"header",
"*",
"if",
"save_as",
"is",
"True",
"or",
"None",
"the",
"filename",
"... | python | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L4609-L4629 | def get_overlay_data_start_offset(self):
"""Get the offset of data appended to the file and not contained within the area described in the headers."""
highest_PointerToRawData = 0
highest_SizeOfRawData = 0
for section in self.sections:
# If a section seems to fa... | [
"def",
"get_overlay_data_start_offset",
"(",
"self",
")",
":",
"highest_PointerToRawData",
"=",
"0",
"highest_SizeOfRawData",
"=",
"0",
"for",
"section",
"in",
"self",
".",
"sections",
":",
"# If a section seems to fall outside the boundaries of the file we assume it's either",... | Get the offset of data appended to the file and not contained within the area described in the headers. | [
"Get",
"the",
"offset",
"of",
"data",
"appended",
"to",
"the",
"file",
"and",
"not",
"contained",
"within",
"the",
"area",
"described",
"in",
"the",
"headers",
"."
] | python | train |
mathandy/svgpathtools | svgpathtools/path.py | https://github.com/mathandy/svgpathtools/blob/fd7348a1dfd88b65ea61da02325c6605aedf8c4f/svgpathtools/path.py#L866-L873 | def poly(self, return_coeffs=False):
"""returns the quadratic as a Polynomial object."""
p = self.bpoints()
coeffs = (p[0] - 2*p[1] + p[2], 2*(p[1] - p[0]), p[0])
if return_coeffs:
return coeffs
else:
return np.poly1d(coeffs) | [
"def",
"poly",
"(",
"self",
",",
"return_coeffs",
"=",
"False",
")",
":",
"p",
"=",
"self",
".",
"bpoints",
"(",
")",
"coeffs",
"=",
"(",
"p",
"[",
"0",
"]",
"-",
"2",
"*",
"p",
"[",
"1",
"]",
"+",
"p",
"[",
"2",
"]",
",",
"2",
"*",
"(",
... | returns the quadratic as a Polynomial object. | [
"returns",
"the",
"quadratic",
"as",
"a",
"Polynomial",
"object",
"."
] | python | train |
groveco/django-sql-explorer | explorer/forms.py | https://github.com/groveco/django-sql-explorer/blob/622b96354e1d7ae7f7105ae90b8da3247e028623/explorer/forms.py#L11-L28 | def validate(self, value):
"""
Ensure that the SQL passes the blacklist.
:param value: The SQL for this Query model.
"""
query = Query(sql=value)
passes_blacklist, failing_words = query.passes_blacklist()
error = MSG_FAILED_BLACKLIST % ', '.join(failing_words)... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"query",
"=",
"Query",
"(",
"sql",
"=",
"value",
")",
"passes_blacklist",
",",
"failing_words",
"=",
"query",
".",
"passes_blacklist",
"(",
")",
"error",
"=",
"MSG_FAILED_BLACKLIST",
"%",
"', '",
".",... | Ensure that the SQL passes the blacklist.
:param value: The SQL for this Query model. | [
"Ensure",
"that",
"the",
"SQL",
"passes",
"the",
"blacklist",
"."
] | python | train |
pkgw/pwkit | pwkit/dulk_models.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/dulk_models.py#L251-L284 | def calc_synch_eta(b, ne, delta, sinth, nu, E0=1.):
"""Calculate the relativistic synchrotron emission coefficient η_ν.
This is Dulk (1985) equation 40, which is an approximation assuming a
power-law electron population. Arguments are:
b
Magnetic field strength in Gauss
ne
The density ... | [
"def",
"calc_synch_eta",
"(",
"b",
",",
"ne",
",",
"delta",
",",
"sinth",
",",
"nu",
",",
"E0",
"=",
"1.",
")",
":",
"s",
"=",
"nu",
"/",
"calc_nu_b",
"(",
"b",
")",
"return",
"(",
"b",
"*",
"ne",
"*",
"8.6e-24",
"*",
"(",
"delta",
"-",
"1",
... | Calculate the relativistic synchrotron emission coefficient η_ν.
This is Dulk (1985) equation 40, which is an approximation assuming a
power-law electron population. Arguments are:
b
Magnetic field strength in Gauss
ne
The density of electrons per cubic centimeter with energies greater tha... | [
"Calculate",
"the",
"relativistic",
"synchrotron",
"emission",
"coefficient",
"η_ν",
"."
] | python | train |
brainiak/brainiak | examples/factoranalysis/htfa_cv_example.py | https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/examples/factoranalysis/htfa_cv_example.py#L26-L54 | def recon_err(data, F, W):
"""Calcuate reconstruction error
Parameters
----------
data : 2D array
True data to recover.
F : 2D array
HTFA factor matrix.
W : 2D array
HTFA weight matrix.
Returns
-------
float
Returns root mean squared recon... | [
"def",
"recon_err",
"(",
"data",
",",
"F",
",",
"W",
")",
":",
"recon",
"=",
"F",
".",
"dot",
"(",
"W",
")",
".",
"ravel",
"(",
")",
"err",
"=",
"mean_squared_error",
"(",
"data",
".",
"ravel",
"(",
")",
",",
"recon",
",",
"multioutput",
"=",
"... | Calcuate reconstruction error
Parameters
----------
data : 2D array
True data to recover.
F : 2D array
HTFA factor matrix.
W : 2D array
HTFA weight matrix.
Returns
-------
float
Returns root mean squared reconstruction error. | [
"Calcuate",
"reconstruction",
"error"
] | python | train |
portantier/habu | habu/lib/ip.py | https://github.com/portantier/habu/blob/87091e389dc6332fe1b82830c22b2eefc55816f2/habu/lib/ip.py#L14-L28 | def get_internal_ip():
"""Get the local IP addresses."""
nics = {}
for interface_name in interfaces():
addresses = ifaddresses(interface_name)
try:
nics[interface_name] = {
'ipv4': addresses[AF_INET],
'link_layer': addresses[AF_LINK],
... | [
"def",
"get_internal_ip",
"(",
")",
":",
"nics",
"=",
"{",
"}",
"for",
"interface_name",
"in",
"interfaces",
"(",
")",
":",
"addresses",
"=",
"ifaddresses",
"(",
"interface_name",
")",
"try",
":",
"nics",
"[",
"interface_name",
"]",
"=",
"{",
"'ipv4'",
"... | Get the local IP addresses. | [
"Get",
"the",
"local",
"IP",
"addresses",
"."
] | python | train |
tinybike/coinbridge | coinbridge/__init__.py | https://github.com/tinybike/coinbridge/blob/c9bde6f4196fecc09e8119f51dff8a26cfc1aee6/coinbridge/__init__.py#L384-L398 | def listtransactions(self, user_id="", count=10, start_at=0):
"""List all transactions associated with this account.
Args:
user_id (str): this user's unique identifier
count (int): number of transactions to return (default=10)
start_at (int): start the list at this transac... | [
"def",
"listtransactions",
"(",
"self",
",",
"user_id",
"=",
"\"\"",
",",
"count",
"=",
"10",
",",
"start_at",
"=",
"0",
")",
":",
"txlist",
"=",
"self",
".",
"rpc",
".",
"call",
"(",
"\"listtransactions\"",
",",
"user_id",
",",
"count",
",",
"start_at... | List all transactions associated with this account.
Args:
user_id (str): this user's unique identifier
count (int): number of transactions to return (default=10)
start_at (int): start the list at this transaction (default=0)
Returns:
list [dict]: transactions as... | [
"List",
"all",
"transactions",
"associated",
"with",
"this",
"account",
"."
] | python | train |
cloud9ers/gurumate | environment/share/doc/ipython/examples/parallel/iopubwatcher.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/share/doc/ipython/examples/parallel/iopubwatcher.py#L27-L75 | def main(connection_file):
"""watch iopub channel, and print messages"""
ctx = zmq.Context.instance()
with open(connection_file) as f:
cfg = json.loads(f.read())
location = cfg['location']
reg_url = cfg['url']
session = Session(key=str_to_bytes(cfg['exec_key']))
q... | [
"def",
"main",
"(",
"connection_file",
")",
":",
"ctx",
"=",
"zmq",
".",
"Context",
".",
"instance",
"(",
")",
"with",
"open",
"(",
"connection_file",
")",
"as",
"f",
":",
"cfg",
"=",
"json",
".",
"loads",
"(",
"f",
".",
"read",
"(",
")",
")",
"l... | watch iopub channel, and print messages | [
"watch",
"iopub",
"channel",
"and",
"print",
"messages"
] | python | test |
wtsi-hgi/python-baton-wrapper | baton/_baton/api.py | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/api.py#L21-L29 | def connect_to_irods_with_baton(baton_binaries_directory: str, skip_baton_binaries_validation: bool=False) \
-> Connection:
"""
Convenience method to create a pseudo connection to iRODS.
:param baton_binaries_directory: see `Connection.__init__`
:param skip_baton_binaries_validation: see `Connec... | [
"def",
"connect_to_irods_with_baton",
"(",
"baton_binaries_directory",
":",
"str",
",",
"skip_baton_binaries_validation",
":",
"bool",
"=",
"False",
")",
"->",
"Connection",
":",
"return",
"Connection",
"(",
"baton_binaries_directory",
",",
"skip_baton_binaries_validation",... | Convenience method to create a pseudo connection to iRODS.
:param baton_binaries_directory: see `Connection.__init__`
:param skip_baton_binaries_validation: see `Connection.__init__`
:return: pseudo connection to iRODS | [
"Convenience",
"method",
"to",
"create",
"a",
"pseudo",
"connection",
"to",
"iRODS",
".",
":",
"param",
"baton_binaries_directory",
":",
"see",
"Connection",
".",
"__init__",
":",
"param",
"skip_baton_binaries_validation",
":",
"see",
"Connection",
".",
"__init__",
... | python | train |
smartfile/python-librsync | librsync/__init__.py | https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L118-L152 | def _execute(job, f, o=None):
"""
Executes a librsync "job" by reading bytes from `f` and writing results to
`o` if provided. If `o` is omitted, the output is ignored.
"""
# Re-use the same buffer for output, we will read from it after each
# iteration.
out = ctypes.create_string_buffer(RS_J... | [
"def",
"_execute",
"(",
"job",
",",
"f",
",",
"o",
"=",
"None",
")",
":",
"# Re-use the same buffer for output, we will read from it after each",
"# iteration.",
"out",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"RS_JOB_BLOCKSIZE",
")",
"while",
"True",
":",
"... | Executes a librsync "job" by reading bytes from `f` and writing results to
`o` if provided. If `o` is omitted, the output is ignored. | [
"Executes",
"a",
"librsync",
"job",
"by",
"reading",
"bytes",
"from",
"f",
"and",
"writing",
"results",
"to",
"o",
"if",
"provided",
".",
"If",
"o",
"is",
"omitted",
"the",
"output",
"is",
"ignored",
"."
] | python | train |
ev3dev/ev3dev-lang-python | ev3dev2/sound.py | https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/sound.py#L224-L249 | def play_note(self, note, duration, volume=100, play_type=PLAY_WAIT_FOR_COMPLETE):
""" Plays a note, given by its name as defined in ``_NOTE_FREQUENCIES``.
:param string note: The note symbol with its octave number
:param float duration: Tone duration, in seconds
:param int volume: The ... | [
"def",
"play_note",
"(",
"self",
",",
"note",
",",
"duration",
",",
"volume",
"=",
"100",
",",
"play_type",
"=",
"PLAY_WAIT_FOR_COMPLETE",
")",
":",
"self",
".",
"_validate_play_type",
"(",
"play_type",
")",
"try",
":",
"freq",
"=",
"self",
".",
"_NOTE_FRE... | Plays a note, given by its name as defined in ``_NOTE_FREQUENCIES``.
:param string note: The note symbol with its octave number
:param float duration: Tone duration, in seconds
:param int volume: The play volume, in percent of maximum volume
:param play_type: The behavior of ``play_not... | [
"Plays",
"a",
"note",
"given",
"by",
"its",
"name",
"as",
"defined",
"in",
"_NOTE_FREQUENCIES",
"."
] | python | train |
testingrequired/vom | vom/__init__.py | https://github.com/testingrequired/vom/blob/9e4da7d90c6ae6a01af3c7ec5c40ee4b08327188/vom/__init__.py#L269-L294 | def find_elements(self, by, value, view_cls=None):
# type: (By, Any, Value) -> List[View]
"""
Find one or more elements matching condition
:param by: Type of condition
:param value: Condition value
:param view_cls: Optional custom class to wrap returned elements
:... | [
"def",
"find_elements",
"(",
"self",
",",
"by",
",",
"value",
",",
"view_cls",
"=",
"None",
")",
":",
"# type: (By, Any, Value) -> List[View]",
"if",
"view_cls",
"is",
"None",
":",
"view_cls",
"=",
"View",
"def",
"get_elements",
"(",
")",
":",
"results",
"="... | Find one or more elements matching condition
:param by: Type of condition
:param value: Condition value
:param view_cls: Optional custom class to wrap returned elements
:return: List of matching web elements wrapped in a view | [
"Find",
"one",
"or",
"more",
"elements",
"matching",
"condition",
":",
"param",
"by",
":",
"Type",
"of",
"condition",
":",
"param",
"value",
":",
"Condition",
"value",
":",
"param",
"view_cls",
":",
"Optional",
"custom",
"class",
"to",
"wrap",
"returned",
... | python | train |
drdoctr/doctr | doctr/travis.py | https://github.com/drdoctr/doctr/blob/0f19ff78c8239efcc98d417f36b0a31d9be01ba5/doctr/travis.py#L479-L534 | def commit_docs(*, added, removed):
"""
Commit the docs to the current branch
Assumes that :func:`setup_GitHub_push`, which sets up the ``doctr_remote``
remote, has been run.
Returns True if changes were committed and False if no changes were
committed.
"""
TRAVIS_BUILD_NUMBER = os.env... | [
"def",
"commit_docs",
"(",
"*",
",",
"added",
",",
"removed",
")",
":",
"TRAVIS_BUILD_NUMBER",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"TRAVIS_BUILD_NUMBER\"",
",",
"\"<unknown>\"",
")",
"TRAVIS_BRANCH",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\... | Commit the docs to the current branch
Assumes that :func:`setup_GitHub_push`, which sets up the ``doctr_remote``
remote, has been run.
Returns True if changes were committed and False if no changes were
committed. | [
"Commit",
"the",
"docs",
"to",
"the",
"current",
"branch"
] | python | train |
ucsb-cs/submit | submit/helpers.py | https://github.com/ucsb-cs/submit/blob/92810c81255a4fc6bbebac1ac8aae856fd576ffe/submit/helpers.py#L329-L342 | def get_queue_func(request):
"""Establish the connection to rabbitmq."""
def cleanup(request):
conn.close()
def queue_func(**kwargs):
return conn.channel().basic_publish(
exchange='', body=json.dumps(kwargs), routing_key=queue,
properties=pika.BasicProperties(deliver... | [
"def",
"get_queue_func",
"(",
"request",
")",
":",
"def",
"cleanup",
"(",
"request",
")",
":",
"conn",
".",
"close",
"(",
")",
"def",
"queue_func",
"(",
"*",
"*",
"kwargs",
")",
":",
"return",
"conn",
".",
"channel",
"(",
")",
".",
"basic_publish",
"... | Establish the connection to rabbitmq. | [
"Establish",
"the",
"connection",
"to",
"rabbitmq",
"."
] | python | train |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TC.py | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1636-L1647 | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data. items in
list are space separated.
'''
v = []
items = text.split()
for item in items:
v.append(self.itemTypeCode.text_to_data(item, elt, ps))
if self.pyclass is not N... | [
"def",
"text_to_data",
"(",
"self",
",",
"text",
",",
"elt",
",",
"ps",
")",
":",
"v",
"=",
"[",
"]",
"items",
"=",
"text",
".",
"split",
"(",
")",
"for",
"item",
"in",
"items",
":",
"v",
".",
"append",
"(",
"self",
".",
"itemTypeCode",
".",
"t... | convert text into typecode specific data. items in
list are space separated. | [
"convert",
"text",
"into",
"typecode",
"specific",
"data",
".",
"items",
"in",
"list",
"are",
"space",
"separated",
"."
] | python | train |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L3299-L3311 | def getVideoStreamFrameBuffer(self, hTrackedCamera, eFrameType, pFrameBuffer, nFrameBufferSize, nFrameHeaderSize):
"""
Copies the image frame into a caller's provided buffer. The image data is currently provided as RGBA data, 4 bytes per pixel.
A caller can provide null for the framebuffer or fr... | [
"def",
"getVideoStreamFrameBuffer",
"(",
"self",
",",
"hTrackedCamera",
",",
"eFrameType",
",",
"pFrameBuffer",
",",
"nFrameBufferSize",
",",
"nFrameHeaderSize",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getVideoStreamFrameBuffer",
"pFrameHeader",
"=",... | Copies the image frame into a caller's provided buffer. The image data is currently provided as RGBA data, 4 bytes per pixel.
A caller can provide null for the framebuffer or frameheader if not desired. Requesting the frame header first, followed by the frame buffer allows
the caller to determine if the... | [
"Copies",
"the",
"image",
"frame",
"into",
"a",
"caller",
"s",
"provided",
"buffer",
".",
"The",
"image",
"data",
"is",
"currently",
"provided",
"as",
"RGBA",
"data",
"4",
"bytes",
"per",
"pixel",
".",
"A",
"caller",
"can",
"provide",
"null",
"for",
"the... | python | train |
agoragames/kairos | kairos/mongo_backend.py | https://github.com/agoragames/kairos/blob/0b062d543b0f4a46df460fa0eb6ec281232ab179/kairos/mongo_backend.py#L152-L160 | def _insert(self, name, value, timestamp, intervals, **kwargs):
'''
Insert the new value.
'''
# TODO: confirm that this is in fact using the indices correctly.
for interval,config in self._intervals.items():
timestamps = self._normalize_timestamps(timestamp, intervals, config)
for tstamp... | [
"def",
"_insert",
"(",
"self",
",",
"name",
",",
"value",
",",
"timestamp",
",",
"intervals",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: confirm that this is in fact using the indices correctly.",
"for",
"interval",
",",
"config",
"in",
"self",
".",
"_intervals",... | Insert the new value. | [
"Insert",
"the",
"new",
"value",
"."
] | python | train |
thomasdelaet/python-velbus | velbus/messages/start_relay_blinking_timer.py | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/start_relay_blinking_timer.py#L40-L47 | def data_to_binary(self):
"""
:return: bytes
"""
return bytes([
COMMAND_CODE,
self.channels_to_byte(self.relay_channels)]) + \
struct.pack('>L', self.delay_time)[-3:] | [
"def",
"data_to_binary",
"(",
"self",
")",
":",
"return",
"bytes",
"(",
"[",
"COMMAND_CODE",
",",
"self",
".",
"channels_to_byte",
"(",
"self",
".",
"relay_channels",
")",
"]",
")",
"+",
"struct",
".",
"pack",
"(",
"'>L'",
",",
"self",
".",
"delay_time",... | :return: bytes | [
":",
"return",
":",
"bytes"
] | python | train |
milesrichardson/ParsePy | parse_rest/user.py | https://github.com/milesrichardson/ParsePy/blob/7c52d8a5dc63bb7c3b0b8c0c09d032b4bc7299ea/parse_rest/user.py#L21-L28 | def login_required(func):
'''decorator describing User methods that need to be logged in'''
def ret(obj, *args, **kw):
if not hasattr(obj, 'sessionToken'):
message = '%s requires a logged-in session' % func.__name__
raise ResourceRequestLoginRequired(message)
return func(... | [
"def",
"login_required",
"(",
"func",
")",
":",
"def",
"ret",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'sessionToken'",
")",
":",
"message",
"=",
"'%s requires a logged-in session'",
"%",
"f... | decorator describing User methods that need to be logged in | [
"decorator",
"describing",
"User",
"methods",
"that",
"need",
"to",
"be",
"logged",
"in"
] | python | train |
SeabornGames/RequestClient | seaborn/request_client/repr_wrapper.py | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/repr_wrapper.py#L153-L165 | def repr_setup(self, name=None, col_names=None, col_types=None):
"""
This wasn't safe to pass into init because of the inheritance
:param name: name of the api return type (ex. CAMERA_DATA_LIST)
:param col_names:
:param col_types:
:return None:
"""
self._n... | [
"def",
"repr_setup",
"(",
"self",
",",
"name",
"=",
"None",
",",
"col_names",
"=",
"None",
",",
"col_types",
"=",
"None",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"self",
".",
"_name",
"self",
".",
"_col_names",
"=",
"col_names",
"or",
"sel... | This wasn't safe to pass into init because of the inheritance
:param name: name of the api return type (ex. CAMERA_DATA_LIST)
:param col_names:
:param col_types:
:return None: | [
"This",
"wasn",
"t",
"safe",
"to",
"pass",
"into",
"init",
"because",
"of",
"the",
"inheritance",
":",
"param",
"name",
":",
"name",
"of",
"the",
"api",
"return",
"type",
"(",
"ex",
".",
"CAMERA_DATA_LIST",
")",
":",
"param",
"col_names",
":",
":",
"pa... | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/build/build_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/build/build_client.py#L1195-L1215 | def update_build_properties(self, document, project, build_id):
"""UpdateBuildProperties.
[Preview API] Updates properties for a build.
:param :class:`<[JsonPatchOperation]> <azure.devops.v5_0.build.models.[JsonPatchOperation]>` document: A json-patch document describing the properties to update... | [
"def",
"update_build_properties",
"(",
"self",
",",
"document",
",",
"project",
",",
"build_id",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"project",
"is",
"not",
"None",
":",
"route_values",
"[",
"'project'",
"]",
"=",
"self",
".",
"_serialize",
".",... | UpdateBuildProperties.
[Preview API] Updates properties for a build.
:param :class:`<[JsonPatchOperation]> <azure.devops.v5_0.build.models.[JsonPatchOperation]>` document: A json-patch document describing the properties to update.
:param str project: Project ID or project name
:param int... | [
"UpdateBuildProperties",
".",
"[",
"Preview",
"API",
"]",
"Updates",
"properties",
"for",
"a",
"build",
".",
":",
"param",
":",
"class",
":",
"<",
"[",
"JsonPatchOperation",
"]",
">",
"<azure",
".",
"devops",
".",
"v5_0",
".",
"build",
".",
"models",
"."... | python | train |
DataDog/integrations-core | mapreduce/datadog_checks/mapreduce/mapreduce.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mapreduce/datadog_checks/mapreduce/mapreduce.py#L456-L465 | def _set_metric(self, metric_name, metric_type, value, tags=None, device_name=None):
"""
Set a metric
"""
if metric_type == self.HISTOGRAM:
self.histogram(metric_name, value, tags=tags, device_name=device_name)
elif metric_type == self.INCREMENT:
self.incr... | [
"def",
"_set_metric",
"(",
"self",
",",
"metric_name",
",",
"metric_type",
",",
"value",
",",
"tags",
"=",
"None",
",",
"device_name",
"=",
"None",
")",
":",
"if",
"metric_type",
"==",
"self",
".",
"HISTOGRAM",
":",
"self",
".",
"histogram",
"(",
"metric... | Set a metric | [
"Set",
"a",
"metric"
] | python | train |
pybel/pybel-tools | src/pybel_tools/analysis/stability.py | https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L179-L185 | def get_mutually_unstable_correlation_triples(graph: BELGraph) -> Iterable[NodeTriple]:
"""Yield triples of nodes (A, B, C) such that ``A neg B``, ``B neg C``, and ``C neg A``."""
cg = get_correlation_graph(graph)
for a, b, c in get_correlation_triangles(cg):
if all(NEGATIVE_CORRELATION in x for x ... | [
"def",
"get_mutually_unstable_correlation_triples",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"Iterable",
"[",
"NodeTriple",
"]",
":",
"cg",
"=",
"get_correlation_graph",
"(",
"graph",
")",
"for",
"a",
",",
"b",
",",
"c",
"in",
"get_correlation_triangles",
"(",
... | Yield triples of nodes (A, B, C) such that ``A neg B``, ``B neg C``, and ``C neg A``. | [
"Yield",
"triples",
"of",
"nodes",
"(",
"A",
"B",
"C",
")",
"such",
"that",
"A",
"neg",
"B",
"B",
"neg",
"C",
"and",
"C",
"neg",
"A",
"."
] | python | valid |
xapple/plumbing | plumbing/slurm/__init__.py | https://github.com/xapple/plumbing/blob/4a7706c7722f5996d0ca366f191aff9ac145880a/plumbing/slurm/__init__.py#L10-L19 | def count_processors():
"""How many cores does the current computer have ?"""
if 'SLURM_NTASKS' in os.environ: return int(os.environ['SLURM_NTASKS'])
elif 'SLURM_JOB_CPUS_PER_NODE' in os.environ:
text = os.environ['SLURM_JOB_CPUS_PER_NODE']
if is_integer(text): return int(text)
el... | [
"def",
"count_processors",
"(",
")",
":",
"if",
"'SLURM_NTASKS'",
"in",
"os",
".",
"environ",
":",
"return",
"int",
"(",
"os",
".",
"environ",
"[",
"'SLURM_NTASKS'",
"]",
")",
"elif",
"'SLURM_JOB_CPUS_PER_NODE'",
"in",
"os",
".",
"environ",
":",
"text",
"=... | How many cores does the current computer have ? | [
"How",
"many",
"cores",
"does",
"the",
"current",
"computer",
"have",
"?"
] | python | train |
honmaple/flask-maple | example/manager.py | https://github.com/honmaple/flask-maple/blob/8124de55e5e531a5cb43477944168f98608dc08f/example/manager.py#L24-L31 | def init_db():
"""
Drops and re-creates the SQL schema
"""
db.drop_all()
db.configure_mappers()
db.create_all()
db.session.commit() | [
"def",
"init_db",
"(",
")",
":",
"db",
".",
"drop_all",
"(",
")",
"db",
".",
"configure_mappers",
"(",
")",
"db",
".",
"create_all",
"(",
")",
"db",
".",
"session",
".",
"commit",
"(",
")"
] | Drops and re-creates the SQL schema | [
"Drops",
"and",
"re",
"-",
"creates",
"the",
"SQL",
"schema"
] | python | train |
splunk/splunk-sdk-python | examples/analytics/bottle.py | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L944-L950 | def params(self):
""" A combined :class:`MultiDict` with values from :attr:`forms` and
:attr:`GET`. File-uploads are not included. """
params = MultiDict(self.GET)
for key, value in self.forms.iterallitems():
params[key] = value
return params | [
"def",
"params",
"(",
"self",
")",
":",
"params",
"=",
"MultiDict",
"(",
"self",
".",
"GET",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"forms",
".",
"iterallitems",
"(",
")",
":",
"params",
"[",
"key",
"]",
"=",
"value",
"return",
"params... | A combined :class:`MultiDict` with values from :attr:`forms` and
:attr:`GET`. File-uploads are not included. | [
"A",
"combined",
":",
"class",
":",
"MultiDict",
"with",
"values",
"from",
":",
"attr",
":",
"forms",
"and",
":",
"attr",
":",
"GET",
".",
"File",
"-",
"uploads",
"are",
"not",
"included",
"."
] | python | train |
matousc89/padasip | padasip/filters/__init__.py | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/__init__.py#L179-L228 | def filter_data(d, x, model="lms", **kwargs):
"""
Function that filter data with selected adaptive filter.
**Args:**
* `d` : desired value (1 dimensional array)
* `x` : input matrix (2-dimensional array). Rows are samples, columns are
input arrays.
**Kwargs:**
* An... | [
"def",
"filter_data",
"(",
"d",
",",
"x",
",",
"model",
"=",
"\"lms\"",
",",
"*",
"*",
"kwargs",
")",
":",
"# overwrite n with correct size",
"kwargs",
"[",
"\"n\"",
"]",
"=",
"x",
".",
"shape",
"[",
"1",
"]",
"# create filter according model",
"if",
"mode... | Function that filter data with selected adaptive filter.
**Args:**
* `d` : desired value (1 dimensional array)
* `x` : input matrix (2-dimensional array). Rows are samples, columns are
input arrays.
**Kwargs:**
* Any key argument that can be accepted with selected filter m... | [
"Function",
"that",
"filter",
"data",
"with",
"selected",
"adaptive",
"filter",
".",
"**",
"Args",
":",
"**"
] | python | train |
crazy-canux/arguspy | arguspy/ssh_paramiko.py | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/arguspy/ssh_paramiko.py#L51-L82 | def execute(self, command, timeout=None):
"""Execute a shell command."""
try:
self.channel = self.ssh.get_transport().open_session()
except paramiko.SSHException as e:
self.unknown("Create channel error: %s" % e)
try:
self.channel.settimeout(self.args.... | [
"def",
"execute",
"(",
"self",
",",
"command",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"channel",
"=",
"self",
".",
"ssh",
".",
"get_transport",
"(",
")",
".",
"open_session",
"(",
")",
"except",
"paramiko",
".",
"SSHException",... | Execute a shell command. | [
"Execute",
"a",
"shell",
"command",
"."
] | python | valid |
mlperf/training | reinforcement/tensorflow/minigo/rl_loop/example_buffer.py | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/rl_loop/example_buffer.py#L100-L117 | def update(self, new_games):
""" new_games is a list of .tfrecord.zz new game records. """
new_games.sort(key=os.path.basename)
first_new_game = None
for idx, game in enumerate(new_games):
timestamp = file_timestamp(game)
if timestamp <= self.examples[-1][0]:
... | [
"def",
"update",
"(",
"self",
",",
"new_games",
")",
":",
"new_games",
".",
"sort",
"(",
"key",
"=",
"os",
".",
"path",
".",
"basename",
")",
"first_new_game",
"=",
"None",
"for",
"idx",
",",
"game",
"in",
"enumerate",
"(",
"new_games",
")",
":",
"ti... | new_games is a list of .tfrecord.zz new game records. | [
"new_games",
"is",
"a",
"list",
"of",
".",
"tfrecord",
".",
"zz",
"new",
"game",
"records",
"."
] | python | train |
libyal/dtfabric | dtfabric/runtime/data_maps.py | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L909-L1031 | def _CompositeMapByteStream(
self, byte_stream, byte_offset=0, context=None, **unused_kwargs):
"""Maps a sequence of composite data types on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[... | [
"def",
"_CompositeMapByteStream",
"(",
"self",
",",
"byte_stream",
",",
"byte_offset",
"=",
"0",
",",
"context",
"=",
"None",
",",
"*",
"*",
"unused_kwargs",
")",
":",
"elements_data_size",
"=",
"None",
"elements_terminator",
"=",
"None",
"number_of_elements",
"... | Maps a sequence of composite data types on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[DataTypeMapContext]): data type map context.
Returns:
tuple[object, ...]: mapped values.
Rai... | [
"Maps",
"a",
"sequence",
"of",
"composite",
"data",
"types",
"on",
"a",
"byte",
"stream",
"."
] | python | train |
PyGithub/PyGithub | github/Team.py | https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/Team.py#L235-L262 | def edit(self, name, description=github.GithubObject.NotSet, permission=github.GithubObject.NotSet, privacy=github.GithubObject.NotSet):
"""
:calls: `PATCH /teams/:id <http://developer.github.com/v3/orgs/teams>`_
:param name: string
:param description: string
:param permission: s... | [
"def",
"edit",
"(",
"self",
",",
"name",
",",
"description",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
",",
"permission",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
",",
"privacy",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
")",
... | :calls: `PATCH /teams/:id <http://developer.github.com/v3/orgs/teams>`_
:param name: string
:param description: string
:param permission: string
:param privacy: string
:rtype: None | [
":",
"calls",
":",
"PATCH",
"/",
"teams",
"/",
":",
"id",
"<http",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"orgs",
"/",
"teams",
">",
"_",
":",
"param",
"name",
":",
"string",
":",
"param",
"description",
":",
"string",
... | python | train |
inasafe/inasafe | safe/gui/widgets/field_mapping_tab.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/field_mapping_tab.py#L311-L329 | def get_parameter_value(self):
"""Get parameter of the tab.
:returns: Dictionary of parameters by type in this format:
{'fields': {}, 'values': {}}.
:rtype: dict
"""
parameters = self.parameter_container.get_parameters(True)
field_parameters = {}
valu... | [
"def",
"get_parameter_value",
"(",
"self",
")",
":",
"parameters",
"=",
"self",
".",
"parameter_container",
".",
"get_parameters",
"(",
"True",
")",
"field_parameters",
"=",
"{",
"}",
"value_parameters",
"=",
"{",
"}",
"for",
"parameter",
"in",
"parameters",
"... | Get parameter of the tab.
:returns: Dictionary of parameters by type in this format:
{'fields': {}, 'values': {}}.
:rtype: dict | [
"Get",
"parameter",
"of",
"the",
"tab",
"."
] | python | train |
nutechsoftware/alarmdecoder | alarmdecoder/devices/usb_device.py | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/devices/usb_device.py#L303-L314 | def close(self):
"""
Closes the device.
"""
try:
Device.close(self)
# HACK: Probably should fork pyftdi and make this call in .close()
self._device.usb_dev.attach_kernel_driver(self._device_number)
except Exception:
pass | [
"def",
"close",
"(",
"self",
")",
":",
"try",
":",
"Device",
".",
"close",
"(",
"self",
")",
"# HACK: Probably should fork pyftdi and make this call in .close()",
"self",
".",
"_device",
".",
"usb_dev",
".",
"attach_kernel_driver",
"(",
"self",
".",
"_device_number"... | Closes the device. | [
"Closes",
"the",
"device",
"."
] | python | train |
myint/autoflake | autoflake.py | https://github.com/myint/autoflake/blob/68fea68646922b920d55975f9f2adaeafd84df4f/autoflake.py#L488-L510 | def dict_entry_has_key(line, key):
"""Return True if `line` is a dict entry that uses `key`.
Return False for multiline cases where the line should not be removed by
itself.
"""
if '#' in line:
return False
result = re.match(r'\s*(.*)\s*:\s*(.*),\s*$', line)
if not result:
... | [
"def",
"dict_entry_has_key",
"(",
"line",
",",
"key",
")",
":",
"if",
"'#'",
"in",
"line",
":",
"return",
"False",
"result",
"=",
"re",
".",
"match",
"(",
"r'\\s*(.*)\\s*:\\s*(.*),\\s*$'",
",",
"line",
")",
"if",
"not",
"result",
":",
"return",
"False",
... | Return True if `line` is a dict entry that uses `key`.
Return False for multiline cases where the line should not be removed by
itself. | [
"Return",
"True",
"if",
"line",
"is",
"a",
"dict",
"entry",
"that",
"uses",
"key",
"."
] | python | test |
idlesign/django-sitetree | sitetree/utils.py | https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/utils.py#L189-L206 | def get_model_class(settings_entry_name):
"""Returns a certain sitetree model as defined in the project settings.
:param str|unicode settings_entry_name:
:rtype: TreeItemBase|TreeBase
"""
app_name, model_name = get_app_n_model(settings_entry_name)
try:
model = apps_get_model(app_name, ... | [
"def",
"get_model_class",
"(",
"settings_entry_name",
")",
":",
"app_name",
",",
"model_name",
"=",
"get_app_n_model",
"(",
"settings_entry_name",
")",
"try",
":",
"model",
"=",
"apps_get_model",
"(",
"app_name",
",",
"model_name",
")",
"except",
"(",
"LookupError... | Returns a certain sitetree model as defined in the project settings.
:param str|unicode settings_entry_name:
:rtype: TreeItemBase|TreeBase | [
"Returns",
"a",
"certain",
"sitetree",
"model",
"as",
"defined",
"in",
"the",
"project",
"settings",
"."
] | python | test |
mitsei/dlkit | dlkit/json_/assessment_authoring/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment_authoring/sessions.py#L968-L1011 | def get_assessment_part_form_for_update(self, assessment_part_id):
"""Gets the assessment part form for updating an existing assessment part.
A new assessment part form should be requested for each update
transaction.
arg: assessment_part_id (osid.id.Id): the ``Id`` of the
... | [
"def",
"get_assessment_part_form_for_update",
"(",
"self",
",",
"assessment_part_id",
")",
":",
"collection",
"=",
"JSONClientValidated",
"(",
"'assessment_authoring'",
",",
"collection",
"=",
"'AssessmentPart'",
",",
"runtime",
"=",
"self",
".",
"_runtime",
")",
"if"... | Gets the assessment part form for updating an existing assessment part.
A new assessment part form should be requested for each update
transaction.
arg: assessment_part_id (osid.id.Id): the ``Id`` of the
``AssessmentPart``
return: (osid.assessment.authoring.Assessmen... | [
"Gets",
"the",
"assessment",
"part",
"form",
"for",
"updating",
"an",
"existing",
"assessment",
"part",
"."
] | python | train |
brian-rose/climlab | climlab/convection/akmaev_adjustment.py | https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/convection/akmaev_adjustment.py#L58-L129 | def Akmaev_adjustment(theta, q, beta, n_k, theta_k, s_k, t_k):
'''Single column only.'''
L = q.size # number of vertical levels
# Akmaev step 1
k = 1
n_k[k-1] = 1
theta_k[k-1] = theta[k-1]
l = 2
while True:
# Akmaev step 2
n = 1
thistheta = theta[l-1]
whi... | [
"def",
"Akmaev_adjustment",
"(",
"theta",
",",
"q",
",",
"beta",
",",
"n_k",
",",
"theta_k",
",",
"s_k",
",",
"t_k",
")",
":",
"L",
"=",
"q",
".",
"size",
"# number of vertical levels",
"# Akmaev step 1",
"k",
"=",
"1",
"n_k",
"[",
"k",
"-",
"1",
"]"... | Single column only. | [
"Single",
"column",
"only",
"."
] | python | train |
poppy-project/pypot | pypot/vrep/io.py | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L162-L167 | def set_motor_force(self, motor_name, force):
""" Sets the maximum force or torque that a joint can exert. """
self.call_remote_api('simxSetJointForce',
self.get_object_handle(motor_name),
force,
sending=True) | [
"def",
"set_motor_force",
"(",
"self",
",",
"motor_name",
",",
"force",
")",
":",
"self",
".",
"call_remote_api",
"(",
"'simxSetJointForce'",
",",
"self",
".",
"get_object_handle",
"(",
"motor_name",
")",
",",
"force",
",",
"sending",
"=",
"True",
")"
] | Sets the maximum force or torque that a joint can exert. | [
"Sets",
"the",
"maximum",
"force",
"or",
"torque",
"that",
"a",
"joint",
"can",
"exert",
"."
] | python | train |
Mxit/python-mxit | mxit/services.py | https://github.com/Mxit/python-mxit/blob/6b18a54ef6fbfe1f9d94755ba3d4ad77743c8b0c/mxit/services.py#L403-L417 | def get_gallery_file(self, file_id, output_file_path=None, scope='content/read'):
"""
Get a file in the Mxit user's gallery
User authentication required with the following scope: 'content/read'
"""
data = _get(
token=self.oauth.get_user_token(scope),
uri='... | [
"def",
"get_gallery_file",
"(",
"self",
",",
"file_id",
",",
"output_file_path",
"=",
"None",
",",
"scope",
"=",
"'content/read'",
")",
":",
"data",
"=",
"_get",
"(",
"token",
"=",
"self",
".",
"oauth",
".",
"get_user_token",
"(",
"scope",
")",
",",
"uri... | Get a file in the Mxit user's gallery
User authentication required with the following scope: 'content/read' | [
"Get",
"a",
"file",
"in",
"the",
"Mxit",
"user",
"s",
"gallery",
"User",
"authentication",
"required",
"with",
"the",
"following",
"scope",
":",
"content",
"/",
"read"
] | python | train |
ska-sa/montblanc | montblanc/impl/rime/tensorflow/sources/cached_source_provider.py | https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/cached_source_provider.py#L140-L146 | def stop(self, stop_context):
""" Perform any logic on solution stop """
for p in self._providers:
p.stop(stop_context)
if self._clear_stop:
self.clear_cache() | [
"def",
"stop",
"(",
"self",
",",
"stop_context",
")",
":",
"for",
"p",
"in",
"self",
".",
"_providers",
":",
"p",
".",
"stop",
"(",
"stop_context",
")",
"if",
"self",
".",
"_clear_stop",
":",
"self",
".",
"clear_cache",
"(",
")"
] | Perform any logic on solution stop | [
"Perform",
"any",
"logic",
"on",
"solution",
"stop"
] | python | train |
gabstopper/smc-python | smc/vpn/elements.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L396-L407 | def enable_disable_force_nat_t(self):
"""
Enable or disable NAT-T on this endpoint. If enabled, it will be
disabled and vice versa.
:return: None
"""
if self.force_nat_t:
self.data['force_nat_t'] = False
else:
self.data['force_nat_t'] = Tr... | [
"def",
"enable_disable_force_nat_t",
"(",
"self",
")",
":",
"if",
"self",
".",
"force_nat_t",
":",
"self",
".",
"data",
"[",
"'force_nat_t'",
"]",
"=",
"False",
"else",
":",
"self",
".",
"data",
"[",
"'force_nat_t'",
"]",
"=",
"True",
"self",
".",
"updat... | Enable or disable NAT-T on this endpoint. If enabled, it will be
disabled and vice versa.
:return: None | [
"Enable",
"or",
"disable",
"NAT",
"-",
"T",
"on",
"this",
"endpoint",
".",
"If",
"enabled",
"it",
"will",
"be",
"disabled",
"and",
"vice",
"versa",
"."
] | python | train |
hotdogee/gff3-py | gff3/gff3.py | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L785-L803 | def descendants(self, line_data):
"""
BFS graph algorithm
:param line_data: line_data(dict) with line_data['line_index'] or line_index(int)
:return: list of line_data(dict)
"""
# get start node
try:
start = line_data['line_index']
except TypeEr... | [
"def",
"descendants",
"(",
"self",
",",
"line_data",
")",
":",
"# get start node",
"try",
":",
"start",
"=",
"line_data",
"[",
"'line_index'",
"]",
"except",
"TypeError",
":",
"start",
"=",
"self",
".",
"lines",
"[",
"line_data",
"]",
"[",
"'line_index'",
... | BFS graph algorithm
:param line_data: line_data(dict) with line_data['line_index'] or line_index(int)
:return: list of line_data(dict) | [
"BFS",
"graph",
"algorithm",
":",
"param",
"line_data",
":",
"line_data",
"(",
"dict",
")",
"with",
"line_data",
"[",
"line_index",
"]",
"or",
"line_index",
"(",
"int",
")",
":",
"return",
":",
"list",
"of",
"line_data",
"(",
"dict",
")"
] | python | valid |
cs50/style50 | style50/_api.py | https://github.com/cs50/style50/blob/2dfe5957f7b727ee5163499e7b8191275aee914c/style50/_api.py#L159-L179 | def run_score(self):
"""
Run checks on self.files, printing raw percentage to stdout.
"""
diffs = 0
lines = 0
for file in self.files:
try:
results = self._check(file)
except Error as e:
termcolor.cprint(e.msg, "yell... | [
"def",
"run_score",
"(",
"self",
")",
":",
"diffs",
"=",
"0",
"lines",
"=",
"0",
"for",
"file",
"in",
"self",
".",
"files",
":",
"try",
":",
"results",
"=",
"self",
".",
"_check",
"(",
"file",
")",
"except",
"Error",
"as",
"e",
":",
"termcolor",
... | Run checks on self.files, printing raw percentage to stdout. | [
"Run",
"checks",
"on",
"self",
".",
"files",
"printing",
"raw",
"percentage",
"to",
"stdout",
"."
] | python | train |
senaite/senaite.core | bika/lims/content/analysisservice.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/analysisservice.py#L51-L118 | def getContainers(instance,
minvol=None,
allow_blank=True,
show_container_types=True,
show_containers=True):
""" Containers vocabulary
This is a separate class so that it can be called from ajax to filter
the container list, as well as... | [
"def",
"getContainers",
"(",
"instance",
",",
"minvol",
"=",
"None",
",",
"allow_blank",
"=",
"True",
",",
"show_container_types",
"=",
"True",
",",
"show_containers",
"=",
"True",
")",
":",
"bsc",
"=",
"getToolByName",
"(",
"instance",
",",
"'bika_setup_catal... | Containers vocabulary
This is a separate class so that it can be called from ajax to filter
the container list, as well as being used as the AT field vocabulary.
Returns a tuple of tuples: ((object_uid, object_title), ())
If the partition is flagged 'Separate', only containers are displayed.
If t... | [
"Containers",
"vocabulary"
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/distribute-0.6.31-py2.7.egg/setuptools/command/easy_install.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/distribute-0.6.31-py2.7.egg/setuptools/command/easy_install.py#L1306-L1314 | def create_home_path(self):
"""Create directories under ~."""
if not self.user:
return
home = convert_path(os.path.expanduser("~"))
for name, path in self.config_vars.iteritems():
if path.startswith(home) and not os.path.isdir(path):
self.debug_pri... | [
"def",
"create_home_path",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"user",
":",
"return",
"home",
"=",
"convert_path",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~\"",
")",
")",
"for",
"name",
",",
"path",
"in",
"self",
".",
"config_... | Create directories under ~. | [
"Create",
"directories",
"under",
"~",
"."
] | python | test |
chrislit/abydos | abydos/compression/_arithmetic.py | https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/compression/_arithmetic.py#L86-L148 | def train(self, text):
r"""Generate a probability dict from the provided text.
Text to 0-order probability statistics as a dict
Parameters
----------
text : str
The text data over which to calculate probability statistics. This
must not contain the NUL (... | [
"def",
"train",
"(",
"self",
",",
"text",
")",
":",
"text",
"=",
"text_type",
"(",
"text",
")",
"if",
"'\\x00'",
"in",
"text",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"'\\x00'",
",",
"' '",
")",
"counts",
"=",
"Counter",
"(",
"text",
")",
... | r"""Generate a probability dict from the provided text.
Text to 0-order probability statistics as a dict
Parameters
----------
text : str
The text data over which to calculate probability statistics. This
must not contain the NUL (0x00) character because that is... | [
"r",
"Generate",
"a",
"probability",
"dict",
"from",
"the",
"provided",
"text",
"."
] | python | valid |
matthewdeanmartin/jiggle_version | build.py | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build.py#L294-L303 | def docs():
"""
Docs
"""
with safe_cd(SRC):
with safe_cd("docs"):
my_env = config_pythonpath()
command = "{0} make html".format(PIPENV).strip()
print(command)
execute_with_environment(command, env=my_env) | [
"def",
"docs",
"(",
")",
":",
"with",
"safe_cd",
"(",
"SRC",
")",
":",
"with",
"safe_cd",
"(",
"\"docs\"",
")",
":",
"my_env",
"=",
"config_pythonpath",
"(",
")",
"command",
"=",
"\"{0} make html\"",
".",
"format",
"(",
"PIPENV",
")",
".",
"strip",
"("... | Docs | [
"Docs"
] | python | train |
kytos/kytos-utils | kytos/utils/napps.py | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/napps.py#L565-L575 | def reload(self, napps=None):
"""Reload a NApp or all NApps.
Args:
napps (list): NApp list to be reloaded.
Raises:
requests.HTTPError: When there's a server error.
"""
client = NAppsClient(self._config)
client.reload_napps(napps) | [
"def",
"reload",
"(",
"self",
",",
"napps",
"=",
"None",
")",
":",
"client",
"=",
"NAppsClient",
"(",
"self",
".",
"_config",
")",
"client",
".",
"reload_napps",
"(",
"napps",
")"
] | Reload a NApp or all NApps.
Args:
napps (list): NApp list to be reloaded.
Raises:
requests.HTTPError: When there's a server error. | [
"Reload",
"a",
"NApp",
"or",
"all",
"NApps",
"."
] | python | train |
riga/scinum | scinum.py | https://github.com/riga/scinum/blob/55eb6d8aa77beacee5a07443392954b8a0aad8cb/scinum.py#L1629-L1644 | def infer_si_prefix(f):
"""
Infers the SI prefix of a value *f* and returns the string label and decimal magnitude in a
2-tuple. Example:
.. code-block:: python
infer_si_prefix(1) # -> ("", 0)
infer_si_prefix(25) # -> ("", 0)
infer_si_prefix(4320) # -> ("k", 3)
"""
... | [
"def",
"infer_si_prefix",
"(",
"f",
")",
":",
"if",
"f",
"==",
"0",
":",
"return",
"\"\"",
",",
"0",
"else",
":",
"mag",
"=",
"3",
"*",
"int",
"(",
"math",
".",
"log10",
"(",
"abs",
"(",
"float",
"(",
"f",
")",
")",
")",
"//",
"3",
")",
"re... | Infers the SI prefix of a value *f* and returns the string label and decimal magnitude in a
2-tuple. Example:
.. code-block:: python
infer_si_prefix(1) # -> ("", 0)
infer_si_prefix(25) # -> ("", 0)
infer_si_prefix(4320) # -> ("k", 3) | [
"Infers",
"the",
"SI",
"prefix",
"of",
"a",
"value",
"*",
"f",
"*",
"and",
"returns",
"the",
"string",
"label",
"and",
"decimal",
"magnitude",
"in",
"a",
"2",
"-",
"tuple",
".",
"Example",
":"
] | python | train |
bookieio/breadability | breadability/readable.py | https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L55-L64 | def ok_embedded_video(node):
"""Check if this embed/video is an ok one to count."""
good_keywords = ('youtube', 'blip.tv', 'vimeo')
node_str = tounicode(node)
for key in good_keywords:
if key in node_str:
return True
return False | [
"def",
"ok_embedded_video",
"(",
"node",
")",
":",
"good_keywords",
"=",
"(",
"'youtube'",
",",
"'blip.tv'",
",",
"'vimeo'",
")",
"node_str",
"=",
"tounicode",
"(",
"node",
")",
"for",
"key",
"in",
"good_keywords",
":",
"if",
"key",
"in",
"node_str",
":",
... | Check if this embed/video is an ok one to count. | [
"Check",
"if",
"this",
"embed",
"/",
"video",
"is",
"an",
"ok",
"one",
"to",
"count",
"."
] | python | train |
icgood/pymap | pymap/config.py | https://github.com/icgood/pymap/blob/e77d9a54d760e3cbe044a548883bb4299ed61dc2/pymap/config.py#L110-L122 | def from_args(cls: Type[ConfigT], args: Namespace) -> ConfigT:
"""Build and return a new :class:`IMAPConfig` using command-line
arguments.
Args:
args: The arguments parsed from the command-line.
"""
parsed_args = cls.parse_args(args)
return cls(args, host=ar... | [
"def",
"from_args",
"(",
"cls",
":",
"Type",
"[",
"ConfigT",
"]",
",",
"args",
":",
"Namespace",
")",
"->",
"ConfigT",
":",
"parsed_args",
"=",
"cls",
".",
"parse_args",
"(",
"args",
")",
"return",
"cls",
"(",
"args",
",",
"host",
"=",
"args",
".",
... | Build and return a new :class:`IMAPConfig` using command-line
arguments.
Args:
args: The arguments parsed from the command-line. | [
"Build",
"and",
"return",
"a",
"new",
":",
"class",
":",
"IMAPConfig",
"using",
"command",
"-",
"line",
"arguments",
"."
] | python | train |
pricingassistant/mrq | mrq/queue_raw.py | https://github.com/pricingassistant/mrq/blob/d0a5a34de9cba38afa94fb7c9e17f9b570b79a50/mrq/queue_raw.py#L147-L159 | def count_jobs_to_dequeue(self):
""" Returns the number of jobs that can be dequeued right now from the queue. """
# timed ZSET
if self.is_timed:
return context.connections.redis.zcount(
self.redis_key,
"-inf",
time.time())
# ... | [
"def",
"count_jobs_to_dequeue",
"(",
"self",
")",
":",
"# timed ZSET",
"if",
"self",
".",
"is_timed",
":",
"return",
"context",
".",
"connections",
".",
"redis",
".",
"zcount",
"(",
"self",
".",
"redis_key",
",",
"\"-inf\"",
",",
"time",
".",
"time",
"(",
... | Returns the number of jobs that can be dequeued right now from the queue. | [
"Returns",
"the",
"number",
"of",
"jobs",
"that",
"can",
"be",
"dequeued",
"right",
"now",
"from",
"the",
"queue",
"."
] | python | train |
portfors-lab/sparkle | sparkle/run/calibration_runner.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/run/calibration_runner.py#L103-L109 | def set_duration(self, dur):
"""See :meth:`AbstractCalibrationRunner<sparkle.run.calibration_runner.AbstractCalibrationRunner.set_duration>`"""
# this may be set at any time, and is not checked before run, so set
# all stim components
for comp in self.stim_components:
comp.se... | [
"def",
"set_duration",
"(",
"self",
",",
"dur",
")",
":",
"# this may be set at any time, and is not checked before run, so set",
"# all stim components",
"for",
"comp",
"in",
"self",
".",
"stim_components",
":",
"comp",
".",
"setDuration",
"(",
"dur",
")",
"self",
".... | See :meth:`AbstractCalibrationRunner<sparkle.run.calibration_runner.AbstractCalibrationRunner.set_duration>` | [
"See",
":",
"meth",
":",
"AbstractCalibrationRunner<sparkle",
".",
"run",
".",
"calibration_runner",
".",
"AbstractCalibrationRunner",
".",
"set_duration",
">"
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/units.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/units.py#L363-L376 | def delete_dimension(dimension_id,**kwargs):
"""
Delete a dimension from the DB. Raises and exception if the dimension does not exist
"""
try:
dimension = db.DBSession.query(Dimension).filter(Dimension.id==dimension_id).one()
db.DBSession.query(Unit).filter(Unit.dimension_id==dimens... | [
"def",
"delete_dimension",
"(",
"dimension_id",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"dimension",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Dimension",
")",
".",
"filter",
"(",
"Dimension",
".",
"id",
"==",
"dimension_id",
")",
".",
"o... | Delete a dimension from the DB. Raises and exception if the dimension does not exist | [
"Delete",
"a",
"dimension",
"from",
"the",
"DB",
".",
"Raises",
"and",
"exception",
"if",
"the",
"dimension",
"does",
"not",
"exist"
] | python | train |
googlefonts/ufo2ft | Lib/ufo2ft/util.py | https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/util.py#L221-L229 | def closeGlyphsOverGSUB(gsub, glyphs):
""" Use the FontTools subsetter to perform a closure over the GSUB table
given the initial `glyphs` (set of glyph names, str). Update the set
in-place adding all the glyph names that can be reached via GSUB
substitutions from this initial set.
"""
subsetter... | [
"def",
"closeGlyphsOverGSUB",
"(",
"gsub",
",",
"glyphs",
")",
":",
"subsetter",
"=",
"subset",
".",
"Subsetter",
"(",
")",
"subsetter",
".",
"glyphs",
"=",
"glyphs",
"gsub",
".",
"closure_glyphs",
"(",
"subsetter",
")"
] | Use the FontTools subsetter to perform a closure over the GSUB table
given the initial `glyphs` (set of glyph names, str). Update the set
in-place adding all the glyph names that can be reached via GSUB
substitutions from this initial set. | [
"Use",
"the",
"FontTools",
"subsetter",
"to",
"perform",
"a",
"closure",
"over",
"the",
"GSUB",
"table",
"given",
"the",
"initial",
"glyphs",
"(",
"set",
"of",
"glyph",
"names",
"str",
")",
".",
"Update",
"the",
"set",
"in",
"-",
"place",
"adding",
"all"... | python | train |
django-fluent/django-fluent-blogs | fluent_blogs/sitemaps.py | https://github.com/django-fluent/django-fluent-blogs/blob/86b148549a010eaca9a2ea987fe43be250e06c50/fluent_blogs/sitemaps.py#L86-L89 | def lastmod(self, tag):
"""Return the last modification of the entry."""
lastitems = EntryModel.objects.published().order_by('-modification_date').filter(tags=tag).only('modification_date')
return lastitems[0].modification_date | [
"def",
"lastmod",
"(",
"self",
",",
"tag",
")",
":",
"lastitems",
"=",
"EntryModel",
".",
"objects",
".",
"published",
"(",
")",
".",
"order_by",
"(",
"'-modification_date'",
")",
".",
"filter",
"(",
"tags",
"=",
"tag",
")",
".",
"only",
"(",
"'modific... | Return the last modification of the entry. | [
"Return",
"the",
"last",
"modification",
"of",
"the",
"entry",
"."
] | python | train |
acsone/git-aggregator | git_aggregator/repo.py | https://github.com/acsone/git-aggregator/blob/8631b0e64f9e8ce1857b21adeddb890ebd8469a6/git_aggregator/repo.py#L153-L162 | def log_call(self, cmd, callwith=subprocess.check_call,
log_level=logging.DEBUG, **kw):
"""Wrap a subprocess call with logging
:param meth: the calling method to use.
"""
logger.log(log_level, "%s> call %r", self.cwd, cmd)
ret = callwith(cmd, **kw)
if cal... | [
"def",
"log_call",
"(",
"self",
",",
"cmd",
",",
"callwith",
"=",
"subprocess",
".",
"check_call",
",",
"log_level",
"=",
"logging",
".",
"DEBUG",
",",
"*",
"*",
"kw",
")",
":",
"logger",
".",
"log",
"(",
"log_level",
",",
"\"%s> call %r\"",
",",
"self... | Wrap a subprocess call with logging
:param meth: the calling method to use. | [
"Wrap",
"a",
"subprocess",
"call",
"with",
"logging",
":",
"param",
"meth",
":",
"the",
"calling",
"method",
"to",
"use",
"."
] | python | train |
JonathanRaiman/pytreebank | pytreebank/parse.py | https://github.com/JonathanRaiman/pytreebank/blob/7b4c671d3dff661cc3677e54db817e50c5a1c666/pytreebank/parse.py#L163-L187 | def load_sst(path=None,
url='http://nlp.stanford.edu/sentiment/trainDevTestTrees_PTB.zip'):
"""
Download and read in the Stanford Sentiment Treebank dataset
into a dictionary with a 'train', 'dev', and 'test' keys. The
dictionary keys point to lists of LabeledTrees.
Arguments:
----... | [
"def",
"load_sst",
"(",
"path",
"=",
"None",
",",
"url",
"=",
"'http://nlp.stanford.edu/sentiment/trainDevTestTrees_PTB.zip'",
")",
":",
"if",
"path",
"is",
"None",
":",
"# find a good temporary path",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/s... | Download and read in the Stanford Sentiment Treebank dataset
into a dictionary with a 'train', 'dev', and 'test' keys. The
dictionary keys point to lists of LabeledTrees.
Arguments:
----------
path : str, (optional defaults to ~/stanford_sentiment_treebank),
directory where the corp... | [
"Download",
"and",
"read",
"in",
"the",
"Stanford",
"Sentiment",
"Treebank",
"dataset",
"into",
"a",
"dictionary",
"with",
"a",
"train",
"dev",
"and",
"test",
"keys",
".",
"The",
"dictionary",
"keys",
"point",
"to",
"lists",
"of",
"LabeledTrees",
"."
] | python | train |
ClericPy/torequests | torequests/utils.py | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L347-L401 | def timeago(seconds=0, accuracy=4, format=0, lang="en"):
"""Translate seconds into human-readable.
:param seconds: seconds (float/int).
:param accuracy: 4 by default (units[:accuracy]), determine the length of elements.
:param format: index of [led, literal, dict].
:param lang: en o... | [
"def",
"timeago",
"(",
"seconds",
"=",
"0",
",",
"accuracy",
"=",
"4",
",",
"format",
"=",
"0",
",",
"lang",
"=",
"\"en\"",
")",
":",
"assert",
"format",
"in",
"[",
"0",
",",
"1",
",",
"2",
"]",
",",
"ValueError",
"(",
"\"format arg should be one of ... | Translate seconds into human-readable.
:param seconds: seconds (float/int).
:param accuracy: 4 by default (units[:accuracy]), determine the length of elements.
:param format: index of [led, literal, dict].
:param lang: en or cn.
:param units: day, hour, minute, second, ms.
... | [
"Translate",
"seconds",
"into",
"human",
"-",
"readable",
"."
] | python | train |
PyAr/fades | fades/cache.py | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/cache.py#L200-L208 | def _read_cache(self):
"""Read virtualenv metadata from cache."""
if os.path.exists(self.filepath):
with open(self.filepath, 'rt', encoding='utf8') as fh:
lines = [x.strip() for x in fh]
else:
logger.debug("Index not found, starting empty")
lin... | [
"def",
"_read_cache",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"filepath",
")",
":",
"with",
"open",
"(",
"self",
".",
"filepath",
",",
"'rt'",
",",
"encoding",
"=",
"'utf8'",
")",
"as",
"fh",
":",
"lines",
... | Read virtualenv metadata from cache. | [
"Read",
"virtualenv",
"metadata",
"from",
"cache",
"."
] | python | train |
dw/mitogen | ansible_mitogen/connection.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/ansible_mitogen/connection.py#L860-L869 | def spawn_isolated_child(self):
"""
Fork or launch a new child off the target context.
:returns:
mitogen.core.Context of the new child.
"""
return self.get_chain(use_fork=True).call(
ansible_mitogen.target.spawn_isolated_child
) | [
"def",
"spawn_isolated_child",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_chain",
"(",
"use_fork",
"=",
"True",
")",
".",
"call",
"(",
"ansible_mitogen",
".",
"target",
".",
"spawn_isolated_child",
")"
] | Fork or launch a new child off the target context.
:returns:
mitogen.core.Context of the new child. | [
"Fork",
"or",
"launch",
"a",
"new",
"child",
"off",
"the",
"target",
"context",
"."
] | python | train |
ucsb-cs/submit | submit/models.py | https://github.com/ucsb-cs/submit/blob/92810c81255a4fc6bbebac1ac8aae856fd576ffe/submit/models.py#L723-L725 | def verify(self, base_path, update=False):
"""Verify the submission and return testables that can be executed."""
return self.project.verify_submission(base_path, self, update=update) | [
"def",
"verify",
"(",
"self",
",",
"base_path",
",",
"update",
"=",
"False",
")",
":",
"return",
"self",
".",
"project",
".",
"verify_submission",
"(",
"base_path",
",",
"self",
",",
"update",
"=",
"update",
")"
] | Verify the submission and return testables that can be executed. | [
"Verify",
"the",
"submission",
"and",
"return",
"testables",
"that",
"can",
"be",
"executed",
"."
] | python | train |
pystorm/pystorm | pystorm/component.py | https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L544-L550 | def _exit(self, status_code):
"""Properly kill Python process including zombie threads."""
# If there are active threads still running infinite loops, sys.exit
# won't kill them but os._exit will. os._exit skips calling cleanup
# handlers, flushing stdio buffers, etc.
exit_func =... | [
"def",
"_exit",
"(",
"self",
",",
"status_code",
")",
":",
"# If there are active threads still running infinite loops, sys.exit",
"# won't kill them but os._exit will. os._exit skips calling cleanup",
"# handlers, flushing stdio buffers, etc.",
"exit_func",
"=",
"os",
".",
"_exit",
... | Properly kill Python process including zombie threads. | [
"Properly",
"kill",
"Python",
"process",
"including",
"zombie",
"threads",
"."
] | python | train |
bitlabstudio/django-development-fabfile | development_fabfile/fabfile/local.py | https://github.com/bitlabstudio/django-development-fabfile/blob/a135c6eb5bdd0b496a7eccfd271aca558dd99243/development_fabfile/fabfile/local.py#L42-L61 | def check_coverage():
"""Checks if the coverage is 100%."""
with lcd(settings.LOCAL_COVERAGE_PATH):
total_line = local('grep -n Total index.html', capture=True)
match = re.search(r'^(\d+):', total_line)
total_line_number = int(match.groups()[0])
percentage_line_number = total_lin... | [
"def",
"check_coverage",
"(",
")",
":",
"with",
"lcd",
"(",
"settings",
".",
"LOCAL_COVERAGE_PATH",
")",
":",
"total_line",
"=",
"local",
"(",
"'grep -n Total index.html'",
",",
"capture",
"=",
"True",
")",
"match",
"=",
"re",
".",
"search",
"(",
"r'^(\\d+):... | Checks if the coverage is 100%. | [
"Checks",
"if",
"the",
"coverage",
"is",
"100%",
"."
] | python | train |
pyvisa/pyvisa | pyvisa/resources/resource.py | https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L176-L183 | def resource_info(self):
"""Get the extended information of this resource.
:param resource_name: Unique symbolic name of a resource.
:rtype: :class:`pyvisa.highlevel.ResourceInfo`
"""
return self.visalib.parse_resource_extended(self._resource_manager.session, self.resource_name... | [
"def",
"resource_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"visalib",
".",
"parse_resource_extended",
"(",
"self",
".",
"_resource_manager",
".",
"session",
",",
"self",
".",
"resource_name",
")"
] | Get the extended information of this resource.
:param resource_name: Unique symbolic name of a resource.
:rtype: :class:`pyvisa.highlevel.ResourceInfo` | [
"Get",
"the",
"extended",
"information",
"of",
"this",
"resource",
"."
] | python | train |
kcallin/mqtt-codec | mqtt_codec/io.py | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/io.py#L317-L339 | def unpack_utf8(self):
"""Decode a utf-8 string encoded as described in MQTT Version
3.1.1 section 1.5.3 line 177. This is a 16-bit unsigned length
followed by a utf-8 encoded string.
Raises
------
UnderflowDecodeError
Raised when a read failed to extract en... | [
"def",
"unpack_utf8",
"(",
"self",
")",
":",
"num_bytes_consumed",
",",
"s",
"=",
"decode_utf8",
"(",
"self",
".",
"__f",
")",
"self",
".",
"__num_bytes_consumed",
"+=",
"num_bytes_consumed",
"return",
"num_bytes_consumed",
",",
"s"
] | Decode a utf-8 string encoded as described in MQTT Version
3.1.1 section 1.5.3 line 177. This is a 16-bit unsigned length
followed by a utf-8 encoded string.
Raises
------
UnderflowDecodeError
Raised when a read failed to extract enough bytes from the
un... | [
"Decode",
"a",
"utf",
"-",
"8",
"string",
"encoded",
"as",
"described",
"in",
"MQTT",
"Version",
"3",
".",
"1",
".",
"1",
"section",
"1",
".",
"5",
".",
"3",
"line",
"177",
".",
"This",
"is",
"a",
"16",
"-",
"bit",
"unsigned",
"length",
"followed",... | python | train |
OSSOS/MOP | src/jjk/preproc/MOPplot.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPplot.py#L758-L762 | def set_pointing_label(self):
"""Let the label of the current pointing to the value in the plabel box"""
self.pointings[self.current]['label']['text']=w.plabel.get()
self.reset() | [
"def",
"set_pointing_label",
"(",
"self",
")",
":",
"self",
".",
"pointings",
"[",
"self",
".",
"current",
"]",
"[",
"'label'",
"]",
"[",
"'text'",
"]",
"=",
"w",
".",
"plabel",
".",
"get",
"(",
")",
"self",
".",
"reset",
"(",
")"
] | Let the label of the current pointing to the value in the plabel box | [
"Let",
"the",
"label",
"of",
"the",
"current",
"pointing",
"to",
"the",
"value",
"in",
"the",
"plabel",
"box"
] | python | train |
Metatab/metapack | metapack/html.py | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/html.py#L477-L619 | def display_context(doc):
"""Create a Jinja context for display"""
from rowgenerators.exceptions import DownloadError
context = {s.name.lower(): s.as_dict() for s in doc if s.name.lower() != 'schema'}
#import json
#print(json.dumps(context, indent=4))
mandatory_sections = ['documentation', 'c... | [
"def",
"display_context",
"(",
"doc",
")",
":",
"from",
"rowgenerators",
".",
"exceptions",
"import",
"DownloadError",
"context",
"=",
"{",
"s",
".",
"name",
".",
"lower",
"(",
")",
":",
"s",
".",
"as_dict",
"(",
")",
"for",
"s",
"in",
"doc",
"if",
"... | Create a Jinja context for display | [
"Create",
"a",
"Jinja",
"context",
"for",
"display"
] | python | train |
tanghaibao/goatools | goatools/pvalcalc.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/pvalcalc.py#L90-L101 | def _init_pval_obj(self):
"""Returns a Fisher object based on user-input."""
if self.pval_fnc_name in self.options.keys():
try:
fisher_obj = self.options[self.pval_fnc_name](self.pval_fnc_name, self.log)
except ImportError:
print("fisher module not... | [
"def",
"_init_pval_obj",
"(",
"self",
")",
":",
"if",
"self",
".",
"pval_fnc_name",
"in",
"self",
".",
"options",
".",
"keys",
"(",
")",
":",
"try",
":",
"fisher_obj",
"=",
"self",
".",
"options",
"[",
"self",
".",
"pval_fnc_name",
"]",
"(",
"self",
... | Returns a Fisher object based on user-input. | [
"Returns",
"a",
"Fisher",
"object",
"based",
"on",
"user",
"-",
"input",
"."
] | python | train |
santoshphilip/eppy | eppy/EPlusInterfaceFunctions/mylib2.py | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/EPlusInterfaceFunctions/mylib2.py#L102-L121 | def makedoedict(str1):
"""makedoedict"""
blocklist = str1.split('..')
blocklist = blocklist[:-1]#remove empty item after last '..'
blockdict = {}
belongsdict = {}
for num in range(0, len(blocklist)):
blocklist[num] = blocklist[num].strip()
linelist = blocklist[num].split(os.lines... | [
"def",
"makedoedict",
"(",
"str1",
")",
":",
"blocklist",
"=",
"str1",
".",
"split",
"(",
"'..'",
")",
"blocklist",
"=",
"blocklist",
"[",
":",
"-",
"1",
"]",
"#remove empty item after last '..'",
"blockdict",
"=",
"{",
"}",
"belongsdict",
"=",
"{",
"}",
... | makedoedict | [
"makedoedict"
] | python | train |
coinbase/coinbase-python | coinbase/wallet/client.py | https://github.com/coinbase/coinbase-python/blob/497c28158f529e8c7d0228521b4386a890baf088/coinbase/wallet/client.py#L469-L477 | def sell(self, account_id, **params):
"""https://developers.coinbase.com/api/v2#sell-bitcoin"""
if 'amount' not in params and 'total' not in params:
raise ValueError("Missing required parameter: 'amount' or 'total'")
for required in ['currency']:
if required not in params... | [
"def",
"sell",
"(",
"self",
",",
"account_id",
",",
"*",
"*",
"params",
")",
":",
"if",
"'amount'",
"not",
"in",
"params",
"and",
"'total'",
"not",
"in",
"params",
":",
"raise",
"ValueError",
"(",
"\"Missing required parameter: 'amount' or 'total'\"",
")",
"fo... | https://developers.coinbase.com/api/v2#sell-bitcoin | [
"https",
":",
"//",
"developers",
".",
"coinbase",
".",
"com",
"/",
"api",
"/",
"v2#sell",
"-",
"bitcoin"
] | python | train |
theislab/scanpy | scanpy/tools/_dpt.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/tools/_dpt.py#L182-L262 | def detect_branchings(self):
"""Detect all branchings up to `n_branchings`.
Writes Attributes
-----------------
segs : np.ndarray
List of integer index arrays.
segs_tips : np.ndarray
List of indices of the tips of segments.
"""
logg.m(' ... | [
"def",
"detect_branchings",
"(",
"self",
")",
":",
"logg",
".",
"m",
"(",
"' detect'",
",",
"self",
".",
"n_branchings",
",",
"'branching'",
"+",
"(",
"''",
"if",
"self",
".",
"n_branchings",
"==",
"1",
"else",
"'s'",
")",
")",
"# a segment is a subset ... | Detect all branchings up to `n_branchings`.
Writes Attributes
-----------------
segs : np.ndarray
List of integer index arrays.
segs_tips : np.ndarray
List of indices of the tips of segments. | [
"Detect",
"all",
"branchings",
"up",
"to",
"n_branchings",
"."
] | python | train |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/client.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/client.py#L95-L108 | def get_processing_block_ids(self):
"""Get list of processing block ids using the processing block id"""
# Initialise empty list
_processing_block_ids = []
# Pattern used to search processing block ids
pattern = '*:processing_block:*'
block_ids = self._db.get_ids(patter... | [
"def",
"get_processing_block_ids",
"(",
"self",
")",
":",
"# Initialise empty list",
"_processing_block_ids",
"=",
"[",
"]",
"# Pattern used to search processing block ids",
"pattern",
"=",
"'*:processing_block:*'",
"block_ids",
"=",
"self",
".",
"_db",
".",
"get_ids",
"(... | Get list of processing block ids using the processing block id | [
"Get",
"list",
"of",
"processing",
"block",
"ids",
"using",
"the",
"processing",
"block",
"id"
] | python | train |
sparklingpandas/sparklingpandas | sparklingpandas/prdd.py | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/prdd.py#L49-L53 | def applymap(self, func, **kwargs):
"""Return a new PRDD by applying a function to each element of each
pandas DataFrame."""
return self.from_rdd(
self._rdd.map(lambda data: data.applymap(func), **kwargs)) | [
"def",
"applymap",
"(",
"self",
",",
"func",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"from_rdd",
"(",
"self",
".",
"_rdd",
".",
"map",
"(",
"lambda",
"data",
":",
"data",
".",
"applymap",
"(",
"func",
")",
",",
"*",
"*",
"kwargs... | Return a new PRDD by applying a function to each element of each
pandas DataFrame. | [
"Return",
"a",
"new",
"PRDD",
"by",
"applying",
"a",
"function",
"to",
"each",
"element",
"of",
"each",
"pandas",
"DataFrame",
"."
] | python | train |
automl/HpBandSter | hpbandster/core/base_iteration.py | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/base_iteration.py#L141-L176 | def get_next_run(self):
"""
function to return the next configuration and budget to run.
This function is called from HB_master, don't call this from
your script.
It returns None if this run of SH is finished or there are
pending jobs that need to finish to progress to the next stage.
If there are empt... | [
"def",
"get_next_run",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_finished",
":",
"return",
"(",
"None",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"data",
".",
"items",
"(",
")",
":",
"if",
"v",
".",
"status",
"==",
"'QUEUED'",
":",
"asser... | function to return the next configuration and budget to run.
This function is called from HB_master, don't call this from
your script.
It returns None if this run of SH is finished or there are
pending jobs that need to finish to progress to the next stage.
If there are empty slots to be filled in the curr... | [
"function",
"to",
"return",
"the",
"next",
"configuration",
"and",
"budget",
"to",
"run",
"."
] | python | train |
aliyun/aliyun-odps-python-sdk | odps/models/function.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/models/function.py#L97-L107 | def update(self):
"""
Update this function.
:return: None
"""
if self._owner_changed:
self.update_owner(self.owner)
self._resources = [res.name for res in self.resources]
return self.parent.update(self) | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_owner_changed",
":",
"self",
".",
"update_owner",
"(",
"self",
".",
"owner",
")",
"self",
".",
"_resources",
"=",
"[",
"res",
".",
"name",
"for",
"res",
"in",
"self",
".",
"resources",
"]",... | Update this function.
:return: None | [
"Update",
"this",
"function",
"."
] | python | train |
guykisel/inline-plz | inlineplz/main.py | https://github.com/guykisel/inline-plz/blob/b5b1744e9156e31f68b519c0d8022feff79888ae/inlineplz/main.py#L102-L143 | def load_config(args, config_path=".inlineplz.yml"):
"""Load inline-plz config from yaml config file with reasonable defaults."""
config = {}
try:
with open(config_path) as configfile:
config = yaml.safe_load(configfile) or {}
if config:
print("Loaded config f... | [
"def",
"load_config",
"(",
"args",
",",
"config_path",
"=",
"\".inlineplz.yml\"",
")",
":",
"config",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"config_path",
")",
"as",
"configfile",
":",
"config",
"=",
"yaml",
".",
"safe_load",
"(",
"configfile",
... | Load inline-plz config from yaml config file with reasonable defaults. | [
"Load",
"inline",
"-",
"plz",
"config",
"from",
"yaml",
"config",
"file",
"with",
"reasonable",
"defaults",
"."
] | python | train |
talkincode/toughlib | toughlib/permit.py | https://github.com/talkincode/toughlib/blob/1c2f7dde3a7f101248f1b5f5d428cc85466995cf/toughlib/permit.py#L105-L112 | def check_opr_category(self, opr, category):
""" 检查权限是否在指定目录下
"""
for path in self.routes:
route = self.routes[path]
if opr in route['oprs'] and route['category'] == category:
return True
return False | [
"def",
"check_opr_category",
"(",
"self",
",",
"opr",
",",
"category",
")",
":",
"for",
"path",
"in",
"self",
".",
"routes",
":",
"route",
"=",
"self",
".",
"routes",
"[",
"path",
"]",
"if",
"opr",
"in",
"route",
"[",
"'oprs'",
"]",
"and",
"route",
... | 检查权限是否在指定目录下 | [
"检查权限是否在指定目录下"
] | python | train |
couchbase/couchbase-python-client | couchbase/connstr.py | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/connstr.py#L173-L181 | def convert_1x_args(bucket, **kwargs):
"""
Converts arguments for 1.x constructors to their 2.x forms
"""
host = kwargs.pop('host', 'localhost')
port = kwargs.pop('port', None)
if not 'connstr' in kwargs and 'connection_string' not in kwargs:
kwargs['connection_string'] = _build_connstr(... | [
"def",
"convert_1x_args",
"(",
"bucket",
",",
"*",
"*",
"kwargs",
")",
":",
"host",
"=",
"kwargs",
".",
"pop",
"(",
"'host'",
",",
"'localhost'",
")",
"port",
"=",
"kwargs",
".",
"pop",
"(",
"'port'",
",",
"None",
")",
"if",
"not",
"'connstr'",
"in",... | Converts arguments for 1.x constructors to their 2.x forms | [
"Converts",
"arguments",
"for",
"1",
".",
"x",
"constructors",
"to",
"their",
"2",
".",
"x",
"forms"
] | python | train |
sassoftware/saspy | saspy/sasets.py | https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasets.py#L393-L441 | def varmax(self, data: ['SASdata', str] = None,
bound: str = None,
by: [str, list] = None,
causal: str = None,
cointeg: str = None,
condfore: str = None,
garch: str = None,
id: [str, list] = None,
ini... | [
"def",
"varmax",
"(",
"self",
",",
"data",
":",
"[",
"'SASdata'",
",",
"str",
"]",
"=",
"None",
",",
"bound",
":",
"str",
"=",
"None",
",",
"by",
":",
"[",
"str",
",",
"list",
"]",
"=",
"None",
",",
"causal",
":",
"str",
"=",
"None",
",",
"co... | Python method to call the VARMAX procedure
Documentation link:
https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=etsug&docsetTarget=etsug_varmax_syntax.htm&locale=en
:param data: SASdata object or string. This parameter is required.
:parm adjust: The adjust ... | [
"Python",
"method",
"to",
"call",
"the",
"VARMAX",
"procedure"
] | python | train |
Microsoft/ApplicationInsights-Python | applicationinsights/channel/contracts/DataPoint.py | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/channel/contracts/DataPoint.py#L193-L202 | def std_dev(self, value):
"""The std_dev property.
Args:
value (float). the property value.
"""
if value == self._defaults['stdDev'] and 'stdDev' in self._values:
del self._values['stdDev']
else:
self._values['stdDev'] = value | [
"def",
"std_dev",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"==",
"self",
".",
"_defaults",
"[",
"'stdDev'",
"]",
"and",
"'stdDev'",
"in",
"self",
".",
"_values",
":",
"del",
"self",
".",
"_values",
"[",
"'stdDev'",
"]",
"else",
":",
"self"... | The std_dev property.
Args:
value (float). the property value. | [
"The",
"std_dev",
"property",
".",
"Args",
":",
"value",
"(",
"float",
")",
".",
"the",
"property",
"value",
"."
] | python | train |
ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_mode.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_mode.py#L50-L79 | def cmd_guided(self, args):
'''set GUIDED target'''
if len(args) != 1 and len(args) != 3:
print("Usage: guided ALTITUDE | guided LAT LON ALTITUDE")
return
if len(args) == 3:
latitude = float(args[0])
longitude = float(args[1])
altitude... | [
"def",
"cmd_guided",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"and",
"len",
"(",
"args",
")",
"!=",
"3",
":",
"print",
"(",
"\"Usage: guided ALTITUDE | guided LAT LON ALTITUDE\"",
")",
"return",
"if",
"len",
"(",
"arg... | set GUIDED target | [
"set",
"GUIDED",
"target"
] | python | train |
morpframework/morpfw | morpfw/interfaces.py | https://github.com/morpframework/morpfw/blob/803fbf29714e6f29456482f1cfbdbd4922b020b0/morpfw/interfaces.py#L168-L172 | def aggregate(self, query: Optional[dict] = None,
group: Optional[dict] = None,
order_by: Union[None, list, tuple] = None) -> list:
"""return aggregation result based on specified rulez query and group"""
raise NotImplementedError | [
"def",
"aggregate",
"(",
"self",
",",
"query",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
",",
"group",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
",",
"order_by",
":",
"Union",
"[",
"None",
",",
"list",
",",
"tuple",
"]",
"=",
"None",
... | return aggregation result based on specified rulez query and group | [
"return",
"aggregation",
"result",
"based",
"on",
"specified",
"rulez",
"query",
"and",
"group"
] | python | train |
cloud9ers/gurumate | environment/share/doc/ipython/examples/parallel/options/mckernel.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/share/doc/ipython/examples/parallel/options/mckernel.py#L1-L43 | def price_options(S=100.0, K=100.0, sigma=0.25, r=0.05, days=260, paths=10000):
"""
Price European and Asian options using a Monte Carlo method.
Parameters
----------
S : float
The initial price of the stock.
K : float
The strike price of the option.
sigma : float
Th... | [
"def",
"price_options",
"(",
"S",
"=",
"100.0",
",",
"K",
"=",
"100.0",
",",
"sigma",
"=",
"0.25",
",",
"r",
"=",
"0.05",
",",
"days",
"=",
"260",
",",
"paths",
"=",
"10000",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
"math",
"import",
"exp... | Price European and Asian options using a Monte Carlo method.
Parameters
----------
S : float
The initial price of the stock.
K : float
The strike price of the option.
sigma : float
The volatility of the stock.
r : float
The risk free interest rate.
days : int... | [
"Price",
"European",
"and",
"Asian",
"options",
"using",
"a",
"Monte",
"Carlo",
"method",
"."
] | python | test |
ralphje/imagemounter | imagemounter/disk.py | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L89-L120 | def _get_mount_methods(self, disk_type):
"""Finds which mount methods are suitable for the specified disk type. Returns a list of all suitable mount
methods.
"""
if self.disk_mounter == 'auto':
methods = []
def add_method_if_exists(method):
if (me... | [
"def",
"_get_mount_methods",
"(",
"self",
",",
"disk_type",
")",
":",
"if",
"self",
".",
"disk_mounter",
"==",
"'auto'",
":",
"methods",
"=",
"[",
"]",
"def",
"add_method_if_exists",
"(",
"method",
")",
":",
"if",
"(",
"method",
"==",
"'avfs'",
"and",
"_... | Finds which mount methods are suitable for the specified disk type. Returns a list of all suitable mount
methods. | [
"Finds",
"which",
"mount",
"methods",
"are",
"suitable",
"for",
"the",
"specified",
"disk",
"type",
".",
"Returns",
"a",
"list",
"of",
"all",
"suitable",
"mount",
"methods",
"."
] | python | train |
jantman/pypi-download-stats | pypi_download_stats/dataquery.py | https://github.com/jantman/pypi-download-stats/blob/44a7a6bbcd61a9e7f02bd02c52584a98183f80c5/pypi_download_stats/dataquery.py#L529-L543 | def _have_cache_for_date(self, dt):
"""
Return True if we have cached data for all projects for the specified
datetime. Return False otherwise.
:param dt: datetime to find cache for
:type dt: datetime.datetime
:return: True if we have cache for all projects for this date... | [
"def",
"_have_cache_for_date",
"(",
"self",
",",
"dt",
")",
":",
"for",
"p",
"in",
"self",
".",
"projects",
":",
"if",
"self",
".",
"cache",
".",
"get",
"(",
"p",
",",
"dt",
")",
"is",
"None",
":",
"return",
"False",
"return",
"True"
] | Return True if we have cached data for all projects for the specified
datetime. Return False otherwise.
:param dt: datetime to find cache for
:type dt: datetime.datetime
:return: True if we have cache for all projects for this date, False
otherwise
:rtype: bool | [
"Return",
"True",
"if",
"we",
"have",
"cached",
"data",
"for",
"all",
"projects",
"for",
"the",
"specified",
"datetime",
".",
"Return",
"False",
"otherwise",
"."
] | python | train |
wright-group/WrightTools | WrightTools/_group.py | https://github.com/wright-group/WrightTools/blob/80d3ddd5074d8d5c1bc03fd5a0e0f10d4b424aeb/WrightTools/_group.py#L365-L409 | def save(self, filepath=None, overwrite=False, verbose=True):
"""Save as root of a new file.
Parameters
----------
filepath : Path-like object (optional)
Filepath to write. If None, file is created using natural_name.
overwrite : boolean (optional)
Toggle... | [
"def",
"save",
"(",
"self",
",",
"filepath",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"filepath",
"is",
"None",
":",
"filepath",
"=",
"pathlib",
".",
"Path",
"(",
"\".\"",
")",
"/",
"self",
".",
"nat... | Save as root of a new file.
Parameters
----------
filepath : Path-like object (optional)
Filepath to write. If None, file is created using natural_name.
overwrite : boolean (optional)
Toggle overwrite behavior. Default is False.
verbose : boolean (optiona... | [
"Save",
"as",
"root",
"of",
"a",
"new",
"file",
"."
] | python | train |
dossier/dossier.models | dossier/models/features/basic.py | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/basic.py#L41-L44 | def phones(text):
'''Returns list of phone numbers without punctuation.'''
return imap(lambda m: m.group(0).replace('-', ''),
REGEX_PHONE.finditer(text)) | [
"def",
"phones",
"(",
"text",
")",
":",
"return",
"imap",
"(",
"lambda",
"m",
":",
"m",
".",
"group",
"(",
"0",
")",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
",",
"REGEX_PHONE",
".",
"finditer",
"(",
"text",
")",
")"
] | Returns list of phone numbers without punctuation. | [
"Returns",
"list",
"of",
"phone",
"numbers",
"without",
"punctuation",
"."
] | python | train |
thiagopbueno/pyrddl | pyrddl/parser.py | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L450-L457 | def p_state_cons_list(self, p):
'''state_cons_list : state_cons_list state_cons_def
| state_cons_def'''
if len(p) == 3:
p[1].append(p[2])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | [
"def",
"p_state_cons_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"3",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"elif",
"len",
"(",
"... | state_cons_list : state_cons_list state_cons_def
| state_cons_def | [
"state_cons_list",
":",
"state_cons_list",
"state_cons_def",
"|",
"state_cons_def"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.