repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
SKA-ScienceDataProcessor/integration-prototype
sip/execution_control/master_controller/master_controller_healthcheck.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/master_controller/master_controller_healthcheck.py#L41-L64
def get_services_health(self) -> dict: """Get the health of all services. Returns: dict, services id and health status """ # Initialise services_health = {} # Get Service IDs services_ids = self._get_services() for service_id in services_id...
[ "def", "get_services_health", "(", "self", ")", "->", "dict", ":", "# Initialise", "services_health", "=", "{", "}", "# Get Service IDs", "services_ids", "=", "self", ".", "_get_services", "(", ")", "for", "service_id", "in", "services_ids", ":", "service_name", ...
Get the health of all services. Returns: dict, services id and health status
[ "Get", "the", "health", "of", "all", "services", "." ]
python
train
29.333333
treyhunner/django-simple-history
simple_history/management/commands/populate_history.py
https://github.com/treyhunner/django-simple-history/blob/85758ecfe608279508a3fb5b71654d3e202eb63d/simple_history/management/commands/populate_history.py#L113-L158
def _bulk_history_create(self, model, batch_size): """Save a copy of all instances to the historical model. :param model: Model you want to bulk create :param batch_size: number of models to create at once. :return: """ instances = [] history = utils.get_history...
[ "def", "_bulk_history_create", "(", "self", ",", "model", ",", "batch_size", ")", ":", "instances", "=", "[", "]", "history", "=", "utils", ".", "get_history_manager_for_model", "(", "model", ")", "if", "self", ".", "verbosity", ">=", "1", ":", "self", "."...
Save a copy of all instances to the historical model. :param model: Model you want to bulk create :param batch_size: number of models to create at once. :return:
[ "Save", "a", "copy", "of", "all", "instances", "to", "the", "historical", "model", "." ]
python
train
37.869565
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L12112-L12126
def spkopa(filename): """ Open an existing SPK file for subsequent write. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkopa_c.html :param filename: The name of an existing SPK file. :type filename: str :return: A handle attached to the SPK file opened to append. :rtype: int ...
[ "def", "spkopa", "(", "filename", ")", ":", "filename", "=", "stypes", ".", "stringToCharP", "(", "filename", ")", "handle", "=", "ctypes", ".", "c_int", "(", ")", "libspice", ".", "spkopa_c", "(", "filename", ",", "ctypes", ".", "byref", "(", "handle", ...
Open an existing SPK file for subsequent write. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkopa_c.html :param filename: The name of an existing SPK file. :type filename: str :return: A handle attached to the SPK file opened to append. :rtype: int
[ "Open", "an", "existing", "SPK", "file", "for", "subsequent", "write", "." ]
python
train
30.866667
juju/charm-helpers
charmhelpers/contrib/network/ufw.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/network/ufw.py#L238-L287
def modify_access(src, dst='any', port=None, proto=None, action='allow', index=None): """ Grant access to an address or subnet :param src: address (e.g. 192.168.1.234) or subnet (e.g. 192.168.1.0/24). :param dst: destiny of the connection, if the machine has multiple I...
[ "def", "modify_access", "(", "src", ",", "dst", "=", "'any'", ",", "port", "=", "None", ",", "proto", "=", "None", ",", "action", "=", "'allow'", ",", "index", "=", "None", ")", ":", "if", "not", "is_enabled", "(", ")", ":", "hookenv", ".", "log", ...
Grant access to an address or subnet :param src: address (e.g. 192.168.1.234) or subnet (e.g. 192.168.1.0/24). :param dst: destiny of the connection, if the machine has multiple IPs and connections to only one of those have to accepted this is the field has to be...
[ "Grant", "access", "to", "an", "address", "or", "subnet" ]
python
train
32.24
kumar303/mohawk
mohawk/receiver.py
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/receiver.py#L123-L171
def respond(self, content=EmptyValue, content_type=EmptyValue, always_hash_content=True, ext=None): """ Respond to the request. This generates the :attr:`mohawk.Receiver.response_header` attribute. :param content=E...
[ "def", "respond", "(", "self", ",", "content", "=", "EmptyValue", ",", "content_type", "=", "EmptyValue", ",", "always_hash_content", "=", "True", ",", "ext", "=", "None", ")", ":", "log", ".", "debug", "(", "'generating response header'", ")", "resource", "...
Respond to the request. This generates the :attr:`mohawk.Receiver.response_header` attribute. :param content=EmptyValue: Byte string of response body that will be sent. :type content=EmptyValue: str :param content_type=EmptyValue: content-type header value for response. ...
[ "Respond", "to", "the", "request", "." ]
python
train
39.040816
nerdvegas/rez
src/rez/backport/zipfile.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/backport/zipfile.py#L801-L806
def printdir(self): """Print a table of contents for the zip file.""" print "%-46s %19s %12s" % ("File Name", "Modified ", "Size") for zinfo in self.filelist: date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time[:6] print "%-46s %s %12d" % (zinfo.filename, date, zinf...
[ "def", "printdir", "(", "self", ")", ":", "print", "\"%-46s %19s %12s\"", "%", "(", "\"File Name\"", ",", "\"Modified \"", ",", "\"Size\"", ")", "for", "zinfo", "in", "self", ".", "filelist", ":", "date", "=", "\"%d-%02d-%02d %02d:%02d:%02d\"", "%", "zinfo", ...
Print a table of contents for the zip file.
[ "Print", "a", "table", "of", "contents", "for", "the", "zip", "file", "." ]
python
train
54.5
Esri/ArcREST
src/arcrest/agol/services.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L2243-L2291
def addFeature(self, features, gdbVersion=None, rollbackOnFailure=True): """ Adds a single feature to the service Inputs: feature - list of common.Feature object or a single common.Feature Object, a FeatureSet object, or a ...
[ "def", "addFeature", "(", "self", ",", "features", ",", "gdbVersion", "=", "None", ",", "rollbackOnFailure", "=", "True", ")", ":", "url", "=", "self", ".", "_url", "+", "\"/addFeatures\"", "params", "=", "{", "\"f\"", ":", "\"json\"", "}", "if", "gdbVer...
Adds a single feature to the service Inputs: feature - list of common.Feature object or a single common.Feature Object, a FeatureSet object, or a list of dictionary objects gdbVersion - Geodatabase version to apply the edits ...
[ "Adds", "a", "single", "feature", "to", "the", "service", "Inputs", ":", "feature", "-", "list", "of", "common", ".", "Feature", "object", "or", "a", "single", "common", ".", "Feature", "Object", "a", "FeatureSet", "object", "or", "a", "list", "of", "dic...
python
train
50.387755
agoragames/leaderboard-python
leaderboard/leaderboard.py
https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L1024-L1033
def ranked_in_list(self, members, **options): ''' Retrieve a page of leaders from the leaderboard for a given list of members. @param members [Array] Member names. @param options [Hash] Options to be used when retrieving the page from the leaderboard. @return a page of leaders f...
[ "def", "ranked_in_list", "(", "self", ",", "members", ",", "*", "*", "options", ")", ":", "return", "self", ".", "ranked_in_list_in", "(", "self", ".", "leaderboard_name", ",", "members", ",", "*", "*", "options", ")" ]
Retrieve a page of leaders from the leaderboard for a given list of members. @param members [Array] Member names. @param options [Hash] Options to be used when retrieving the page from the leaderboard. @return a page of leaders from the leaderboard for a given list of members.
[ "Retrieve", "a", "page", "of", "leaders", "from", "the", "leaderboard", "for", "a", "given", "list", "of", "members", "." ]
python
train
46.5
Spinmob/spinmob
egg/_gui.py
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_gui.py#L2866-L2876
def _synchronize_controls(self): """ Updates the gui based on button configs. """ # whether the script is visible self.grid_script._widget.setVisible(self.button_script.get_value()) # whether we should be able to edit it. if not self.combo_autoscript.get_index()...
[ "def", "_synchronize_controls", "(", "self", ")", ":", "# whether the script is visible", "self", ".", "grid_script", ".", "_widget", ".", "setVisible", "(", "self", ".", "button_script", ".", "get_value", "(", ")", ")", "# whether we should be able to edit it.", "if"...
Updates the gui based on button configs.
[ "Updates", "the", "gui", "based", "on", "button", "configs", "." ]
python
train
37.272727
xapple/fasta
fasta/common.py
https://github.com/xapple/fasta/blob/a827c3138812d555203be45187ffae1277dd0d76/fasta/common.py#L6-L10
def add_dummy_scores(iteratable, score=0): """Add zero scores to all sequences""" for seq in iteratable: seq.letter_annotations["phred_quality"] = (score,)*len(seq) yield seq
[ "def", "add_dummy_scores", "(", "iteratable", ",", "score", "=", "0", ")", ":", "for", "seq", "in", "iteratable", ":", "seq", ".", "letter_annotations", "[", "\"phred_quality\"", "]", "=", "(", "score", ",", ")", "*", "len", "(", "seq", ")", "yield", "...
Add zero scores to all sequences
[ "Add", "zero", "scores", "to", "all", "sequences" ]
python
train
38.8
StackStorm/pybind
pybind/slxos/v17s_1_02/qos/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/qos/__init__.py#L168-L189
def _set_tx_queue(self, v, load=False): """ Setter method for tx_queue, mapped from YANG variable /qos/tx_queue (container) If this variable is read-only (config: false) in the source YANG file, then _set_tx_queue is considered as a private method. Backends looking to populate this variable should ...
[ "def", "_set_tx_queue", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base"...
Setter method for tx_queue, mapped from YANG variable /qos/tx_queue (container) If this variable is read-only (config: false) in the source YANG file, then _set_tx_queue is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_tx_queue() directl...
[ "Setter", "method", "for", "tx_queue", "mapped", "from", "YANG", "variable", "/", "qos", "/", "tx_queue", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "file",...
python
train
76.727273
iotile/coretools
scripts/release.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/scripts/release.py#L30-L40
def send_slack_message(message): """Send a message to the slack channel #coretools""" if 'SLACK_WEB_HOOK' not in os.environ: raise EnvironmentError("Could not find SLACK_WEB_HOOK environment variable") webhook = os.environ['SLACK_WEB_HOOK'] r = requests.post(webhook, json={'text':message, 'us...
[ "def", "send_slack_message", "(", "message", ")", ":", "if", "'SLACK_WEB_HOOK'", "not", "in", "os", ".", "environ", ":", "raise", "EnvironmentError", "(", "\"Could not find SLACK_WEB_HOOK environment variable\"", ")", "webhook", "=", "os", ".", "environ", "[", "'SLA...
Send a message to the slack channel #coretools
[ "Send", "a", "message", "to", "the", "slack", "channel", "#coretools" ]
python
train
39.363636
klen/pylama
pylama/main.py
https://github.com/klen/pylama/blob/f436ccc6b55b33381a295ded753e467953cf4379/pylama/main.py#L82-L101
def process_paths(options, candidates=None, error=True): """Process files and log errors.""" errors = check_path(options, rootdir=CURDIR, candidates=candidates) if options.format in ['pycodestyle', 'pep8']: pattern = "%(filename)s:%(lnum)s:%(col)s: %(text)s" elif options.format == 'pylint': ...
[ "def", "process_paths", "(", "options", ",", "candidates", "=", "None", ",", "error", "=", "True", ")", ":", "errors", "=", "check_path", "(", "options", ",", "rootdir", "=", "CURDIR", ",", "candidates", "=", "candidates", ")", "if", "options", ".", "for...
Process files and log errors.
[ "Process", "files", "and", "log", "errors", "." ]
python
train
33.85
pandas-dev/pandas
pandas/core/arrays/datetimelike.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/datetimelike.py#L986-L1007
def _add_delta_tdi(self, other): """ Add a delta of a TimedeltaIndex return the i8 result view """ if len(self) != len(other): raise ValueError("cannot add indices of unequal length") if isinstance(other, np.ndarray): # ndarray[timedelta64]; wrap ...
[ "def", "_add_delta_tdi", "(", "self", ",", "other", ")", ":", "if", "len", "(", "self", ")", "!=", "len", "(", "other", ")", ":", "raise", "ValueError", "(", "\"cannot add indices of unequal length\"", ")", "if", "isinstance", "(", "other", ",", "np", ".",...
Add a delta of a TimedeltaIndex return the i8 result view
[ "Add", "a", "delta", "of", "a", "TimedeltaIndex", "return", "the", "i8", "result", "view" ]
python
train
37.5
rwl/pylon
pylon/solver.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L726-L732
def _consfcn(self, x): """ Evaluates nonlinear constraints and their Jacobian for OPF. """ h, g = self._gh(x) dh, dg = self._dgh(x) return h, g, dh, dg
[ "def", "_consfcn", "(", "self", ",", "x", ")", ":", "h", ",", "g", "=", "self", ".", "_gh", "(", "x", ")", "dh", ",", "dg", "=", "self", ".", "_dgh", "(", "x", ")", "return", "h", ",", "g", ",", "dh", ",", "dg" ]
Evaluates nonlinear constraints and their Jacobian for OPF.
[ "Evaluates", "nonlinear", "constraints", "and", "their", "Jacobian", "for", "OPF", "." ]
python
train
26.571429
mbarakaja/braulio
braulio/cli.py
https://github.com/mbarakaja/braulio/blob/70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b/braulio/cli.py#L94-L107
def bump_option_validator(ctx, param, value): """In case a value is provided checks that it is a valid version string. If is not thrown :class:`click.UsageError`. Return a :class:`~braulio.version.Version` object or **None**. """ if value: try: value = Version(value) ex...
[ "def", "bump_option_validator", "(", "ctx", ",", "param", ",", "value", ")", ":", "if", "value", ":", "try", ":", "value", "=", "Version", "(", "value", ")", "except", "ValueError", ":", "ctx", ".", "fail", "(", "f\"{x_mark} {value} is not a valid version stri...
In case a value is provided checks that it is a valid version string. If is not thrown :class:`click.UsageError`. Return a :class:`~braulio.version.Version` object or **None**.
[ "In", "case", "a", "value", "is", "provided", "checks", "that", "it", "is", "a", "valid", "version", "string", ".", "If", "is", "not", "thrown", ":", "class", ":", "click", ".", "UsageError", "." ]
python
train
29.5
HumanCellAtlas/dcp-cli
hca/util/fs_helper.py
https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/util/fs_helper.py#L17-L24
def get_days_since_last_modified(filename): """ :param filename: Absolute file path :return: Number of days since filename's last modified time """ now = datetime.now() last_modified = datetime.fromtimestamp(os.path.getmtime(filename)) return (now - last_modified)...
[ "def", "get_days_since_last_modified", "(", "filename", ")", ":", "now", "=", "datetime", ".", "now", "(", ")", "last_modified", "=", "datetime", ".", "fromtimestamp", "(", "os", ".", "path", ".", "getmtime", "(", "filename", ")", ")", "return", "(", "now"...
:param filename: Absolute file path :return: Number of days since filename's last modified time
[ ":", "param", "filename", ":", "Absolute", "file", "path", ":", "return", ":", "Number", "of", "days", "since", "filename", "s", "last", "modified", "time" ]
python
train
39.75
jobovy/galpy
galpy/df/quasiisothermaldf.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/quasiisothermaldf.py#L577-L749
def _vmomentdensity(self,R,z,n,m,o,nsigma=None,mc=False,nmc=10000, _returnmc=False,_vrs=None,_vts=None,_vzs=None, _rawgausssamples=False, gl=False,ngl=_DEFAULTNGL,_returngl=False,_glqeval=None, _return_actions=False,_jr=None,_lz...
[ "def", "_vmomentdensity", "(", "self", ",", "R", ",", "z", ",", "n", ",", "m", ",", "o", ",", "nsigma", "=", "None", ",", "mc", "=", "False", ",", "nmc", "=", "10000", ",", "_returnmc", "=", "False", ",", "_vrs", "=", "None", ",", "_vts", "=", ...
Non-physical version of vmomentdensity, otherwise the same
[ "Non", "-", "physical", "version", "of", "vmomentdensity", "otherwise", "the", "same" ]
python
train
51.768786
cloudsmith-io/cloudsmith-cli
cloudsmith_cli/cli/commands/copy.py
https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/copy.py#L28-L94
def copy( ctx, opts, owner_repo_package, destination, skip_errors, wait_interval, no_wait_for_sync, sync_attempts, ): """ Copy a package to another repository. This requires appropriate permissions for both the source repository/package and the destination repository. ...
[ "def", "copy", "(", "ctx", ",", "opts", ",", "owner_repo_package", ",", "destination", ",", "skip_errors", ",", "wait_interval", ",", "no_wait_for_sync", ",", "sync_attempts", ",", ")", ":", "owner", ",", "source", ",", "slug", "=", "owner_repo_package", "clic...
Copy a package to another repository. This requires appropriate permissions for both the source repository/package and the destination repository. - OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), the REPO name where the package is stored, and the PACKAGE name (slug) of the pac...
[ "Copy", "a", "package", "to", "another", "repository", "." ]
python
train
26.38806
tbreitenfeldt/invisible_ui
invisible_ui/elements/element.py
https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/elements/element.py#L42-L44
def selected(self, interrupt=False): """This object has been selected.""" self.ao2.output(self.get_title(), interrupt=interrupt)
[ "def", "selected", "(", "self", ",", "interrupt", "=", "False", ")", ":", "self", ".", "ao2", ".", "output", "(", "self", ".", "get_title", "(", ")", ",", "interrupt", "=", "interrupt", ")" ]
This object has been selected.
[ "This", "object", "has", "been", "selected", "." ]
python
train
47.333333
ArchiveTeam/wpull
wpull/processor/base.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/processor/base.py#L55-L60
def _log_error(self, request, error): '''Log exceptions during a fetch.''' _logger.error( _('Fetching ‘{url}’ encountered an error: {error}'), url=request.url, error=error )
[ "def", "_log_error", "(", "self", ",", "request", ",", "error", ")", ":", "_logger", ".", "error", "(", "_", "(", "'Fetching ‘{url}’ encountered an error: {error}'),", "", "", "url", "=", "request", ".", "url", ",", "error", "=", "error", ")" ]
Log exceptions during a fetch.
[ "Log", "exceptions", "during", "a", "fetch", "." ]
python
train
36
wbond/certvalidator
certvalidator/validate.py
https://github.com/wbond/certvalidator/blob/c62233a713bcc36963e9d82323ec8d84f8e01485/certvalidator/validate.py#L1137-L1737
def verify_crl(cert, path, validation_context, use_deltas=True, cert_description=None, end_entity_name_override=None): """ Verifies a certificate against a list of CRLs, checking to make sure the certificate has not been revoked. Uses the algorithm from https://tools.ietf.org/html/rfc5280#section-6.3 as...
[ "def", "verify_crl", "(", "cert", ",", "path", ",", "validation_context", ",", "use_deltas", "=", "True", ",", "cert_description", "=", "None", ",", "end_entity_name_override", "=", "None", ")", ":", "if", "not", "isinstance", "(", "cert", ",", "x509", ".", ...
Verifies a certificate against a list of CRLs, checking to make sure the certificate has not been revoked. Uses the algorithm from https://tools.ietf.org/html/rfc5280#section-6.3 as a basis, but the implementation differs to allow CRLs from unrecorded locations. :param cert: An asn1cyrpto.x509....
[ "Verifies", "a", "certificate", "against", "a", "list", "of", "CRLs", "checking", "to", "make", "sure", "the", "certificate", "has", "not", "been", "revoked", ".", "Uses", "the", "algorithm", "from", "https", ":", "//", "tools", ".", "ietf", ".", "org", ...
python
train
38.34609
newville/wxmplot
wxmplot/basepanel.py
https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/basepanel.py#L458-L492
def zoom_motion(self, event=None): """motion event handler for zoom mode""" try: x, y = event.x, event.y except: return self.report_motion(event=event) if self.zoom_ini is None: return ini_x, ini_y, ini_xd, ini_yd = self.zoom_ini ...
[ "def", "zoom_motion", "(", "self", ",", "event", "=", "None", ")", ":", "try", ":", "x", ",", "y", "=", "event", ".", "x", ",", "event", ".", "y", "except", ":", "return", "self", ".", "report_motion", "(", "event", "=", "event", ")", "if", "self...
motion event handler for zoom mode
[ "motion", "event", "handler", "for", "zoom", "mode" ]
python
train
32.142857
derpferd/little-python
littlepython/parser.py
https://github.com/derpferd/little-python/blob/3f89c74cffb6532c12c5b40843bd8ff8605638ba/littlepython/parser.py#L208-L231
def variable(self): """ variable : variable Feature Type Array adds: variable : variable[expression] Feature Type Func adds: variable : variable(arg_list) """ var = Var(self.cur_token) self.eat(TokenTypes.VAR) if Features.TYPE_ARRA...
[ "def", "variable", "(", "self", ")", ":", "var", "=", "Var", "(", "self", ".", "cur_token", ")", "self", ".", "eat", "(", "TokenTypes", ".", "VAR", ")", "if", "Features", ".", "TYPE_ARRAY", "in", "self", ".", "features", ":", "while", "self", ".", ...
variable : variable Feature Type Array adds: variable : variable[expression] Feature Type Func adds: variable : variable(arg_list)
[ "variable", ":", "variable", "Feature", "Type", "Array", "adds", ":", "variable", ":", "variable", "[", "expression", "]", "Feature", "Type", "Func", "adds", ":", "variable", ":", "variable", "(", "arg_list", ")" ]
python
train
38.166667
klen/pylama
pylama/core.py
https://github.com/klen/pylama/blob/f436ccc6b55b33381a295ded753e467953cf4379/pylama/core.py#L186-L196
def merge_params(params, lparams): """Merge global ignore/select with linter local params.""" ignore = params.get('ignore', set()) if 'ignore' in lparams: ignore = ignore | set(lparams['ignore']) select = params.get('select', set()) if 'select' in lparams: select = select | set(lpar...
[ "def", "merge_params", "(", "params", ",", "lparams", ")", ":", "ignore", "=", "params", ".", "get", "(", "'ignore'", ",", "set", "(", ")", ")", "if", "'ignore'", "in", "lparams", ":", "ignore", "=", "ignore", "|", "set", "(", "lparams", "[", "'ignor...
Merge global ignore/select with linter local params.
[ "Merge", "global", "ignore", "/", "select", "with", "linter", "local", "params", "." ]
python
train
31.909091
kiwiz/gkeepapi
gkeepapi/__init__.py
https://github.com/kiwiz/gkeepapi/blob/78aaae8b988b1cf616e3973f7f15d4c6d5e996cc/gkeepapi/__init__.py#L663-L679
def createNote(self, title=None, text=None): """Create a new managed note. Any changes to the note will be uploaded when :py:meth:`sync` is called. Args: title (str): The title of the note. text (str): The text of the note. Returns: gkeepapi.node.List: The n...
[ "def", "createNote", "(", "self", ",", "title", "=", "None", ",", "text", "=", "None", ")", ":", "node", "=", "_node", ".", "Note", "(", ")", "if", "title", "is", "not", "None", ":", "node", ".", "title", "=", "title", "if", "text", "is", "not", ...
Create a new managed note. Any changes to the note will be uploaded when :py:meth:`sync` is called. Args: title (str): The title of the note. text (str): The text of the note. Returns: gkeepapi.node.List: The new note.
[ "Create", "a", "new", "managed", "note", ".", "Any", "changes", "to", "the", "note", "will", "be", "uploaded", "when", ":", "py", ":", "meth", ":", "sync", "is", "called", "." ]
python
train
30.235294
pvlib/pvlib-python
pvlib/modelchain.py
https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/modelchain.py#L714-L788
def complete_irradiance(self, times=None, weather=None): """ Determine the missing irradiation columns. Only two of the following data columns (dni, ghi, dhi) are needed to calculate the missing data. This function is not safe at the moment. Results can be too high or ne...
[ "def", "complete_irradiance", "(", "self", ",", "times", "=", "None", ",", "weather", "=", "None", ")", ":", "if", "weather", "is", "not", "None", ":", "self", ".", "weather", "=", "weather", "if", "times", "is", "not", "None", ":", "self", ".", "tim...
Determine the missing irradiation columns. Only two of the following data columns (dni, ghi, dhi) are needed to calculate the missing data. This function is not safe at the moment. Results can be too high or negative. Please contribute and help to improve this function on https:...
[ "Determine", "the", "missing", "irradiation", "columns", ".", "Only", "two", "of", "the", "following", "data", "columns", "(", "dni", "ghi", "dhi", ")", "are", "needed", "to", "calculate", "the", "missing", "data", "." ]
python
train
42.48
sbaechler/django-multilingual-search
multilingual/elasticsearch_backend.py
https://github.com/sbaechler/django-multilingual-search/blob/485c690d865da3267b19e073e28d3e2290f36611/multilingual/elasticsearch_backend.py#L108-L142
def update(self, index, iterable, commit=True): """ Updates the index with current data. :param index: The search_indexes.Index object :param iterable: The queryset :param commit: commit to the backend. """ parler = False # setup here because self.existing...
[ "def", "update", "(", "self", ",", "index", ",", "iterable", ",", "commit", "=", "True", ")", ":", "parler", "=", "False", "# setup here because self.existing_mappings are overridden.", "if", "not", "self", ".", "setup_complete", ":", "try", ":", "self", ".", ...
Updates the index with current data. :param index: The search_indexes.Index object :param iterable: The queryset :param commit: commit to the backend.
[ "Updates", "the", "index", "with", "current", "data", ".", ":", "param", "index", ":", "The", "search_indexes", ".", "Index", "object", ":", "param", "iterable", ":", "The", "queryset", ":", "param", "commit", ":", "commit", "to", "the", "backend", "." ]
python
train
40.542857
tmr232/Sark
sark/structure.py
https://github.com/tmr232/Sark/blob/bee62879c2aea553a3924d887e2b30f2a6008581/sark/structure.py#L84-L100
def get_struct(name): """Get a struct by it's name. Args: name: The name of the struct Returns: The struct's id Raises: exceptions.SarkStructNotFound: is the struct does not exist. """ sid = idc.GetStrucIdByName(name) if sid == idaapi.BADADDR: raise excepti...
[ "def", "get_struct", "(", "name", ")", ":", "sid", "=", "idc", ".", "GetStrucIdByName", "(", "name", ")", "if", "sid", "==", "idaapi", ".", "BADADDR", ":", "raise", "exceptions", ".", "SarkStructNotFound", "(", ")", "return", "sid" ]
Get a struct by it's name. Args: name: The name of the struct Returns: The struct's id Raises: exceptions.SarkStructNotFound: is the struct does not exist.
[ "Get", "a", "struct", "by", "it", "s", "name", "." ]
python
train
20.235294
rosenbrockc/fortpy
fortpy/code.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/code.py#L224-L231
def _add_current_codedir(self, path): """Adds the directory of the file at the specified path as a base path to find other files in. """ dirpath = self.tramp.dirname(path) if dirpath not in self.basepaths: self.basepaths.append(dirpath) self.rescan()
[ "def", "_add_current_codedir", "(", "self", ",", "path", ")", ":", "dirpath", "=", "self", ".", "tramp", ".", "dirname", "(", "path", ")", "if", "dirpath", "not", "in", "self", ".", "basepaths", ":", "self", ".", "basepaths", ".", "append", "(", "dirpa...
Adds the directory of the file at the specified path as a base path to find other files in.
[ "Adds", "the", "directory", "of", "the", "file", "at", "the", "specified", "path", "as", "a", "base", "path", "to", "find", "other", "files", "in", "." ]
python
train
38.375
codelv/enaml-native
src/enamlnative/android/app.py
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/app.py#L246-L257
def _on_permission_result(self, code, perms, results): """ Handles a permission request result by passing it to the handler with the given code. """ #: Get the handler for this request handler = self._permission_requests.get(code, None) if handler is not None: ...
[ "def", "_on_permission_result", "(", "self", ",", "code", ",", "perms", ",", "results", ")", ":", "#: Get the handler for this request", "handler", "=", "self", ".", "_permission_requests", ".", "get", "(", "code", ",", "None", ")", "if", "handler", "is", "not...
Handles a permission request result by passing it to the handler with the given code.
[ "Handles", "a", "permission", "request", "result", "by", "passing", "it", "to", "the", "handler", "with", "the", "given", "code", "." ]
python
train
39.25
jasonlaska/spherecluster
spherecluster/von_mises_fisher_mixture.py
https://github.com/jasonlaska/spherecluster/blob/701b0b1909088a56e353b363b2672580d4fe9d93/spherecluster/von_mises_fisher_mixture.py#L25-L33
def _inertia_from_labels(X, centers, labels): """Compute inertia with cosine distance using known labels. """ n_examples, n_features = X.shape inertia = np.zeros((n_examples,)) for ee in range(n_examples): inertia[ee] = 1 - X[ee, :].dot(centers[int(labels[ee]), :].T) return np.sum(inert...
[ "def", "_inertia_from_labels", "(", "X", ",", "centers", ",", "labels", ")", ":", "n_examples", ",", "n_features", "=", "X", ".", "shape", "inertia", "=", "np", ".", "zeros", "(", "(", "n_examples", ",", ")", ")", "for", "ee", "in", "range", "(", "n_...
Compute inertia with cosine distance using known labels.
[ "Compute", "inertia", "with", "cosine", "distance", "using", "known", "labels", "." ]
python
train
35
linode/linode_api4-python
linode_api4/linode_client.py
https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L67-L98
def stackscripts(self, *filters, **kwargs): """ Returns a list of :any:`StackScripts<StackScript>`, both public and private. You may filter this query to return only :any:`StackScripts<StackScript>` that match certain criteria. You may also request only your own private :any:`S...
[ "def", "stackscripts", "(", "self", ",", "*", "filters", ",", "*", "*", "kwargs", ")", ":", "# python2 can't handle *args and a single keyword argument, so this is a workaround", "if", "'mine_only'", "in", "kwargs", ":", "if", "kwargs", "[", "'mine_only'", "]", ":", ...
Returns a list of :any:`StackScripts<StackScript>`, both public and private. You may filter this query to return only :any:`StackScripts<StackScript>` that match certain criteria. You may also request only your own private :any:`StackScripts<StackScript>`:: my_stackscripts = client...
[ "Returns", "a", "list", "of", ":", "any", ":", "StackScripts<StackScript", ">", "both", "public", "and", "private", ".", "You", "may", "filter", "this", "query", "to", "return", "only", ":", "any", ":", "StackScripts<StackScript", ">", "that", "match", "cert...
python
train
41.53125
mattrobenolt/ec2
ec2/helpers.py
https://github.com/mattrobenolt/ec2/blob/fc1f8bce6cf76899165d9ac006371181d52439f8/ec2/helpers.py#L12-L22
def make_compare(key, value, obj): "Map a key name to a specific comparison function" if '__' not in key: # If no __ exists, default to doing an "exact" comparison key, comp = key, 'exact' else: key, comp = key.rsplit('__', 1) # Check if comp is valid if hasattr(Compare, comp...
[ "def", "make_compare", "(", "key", ",", "value", ",", "obj", ")", ":", "if", "'__'", "not", "in", "key", ":", "# If no __ exists, default to doing an \"exact\" comparison", "key", ",", "comp", "=", "key", ",", "'exact'", "else", ":", "key", ",", "comp", "=",...
Map a key name to a specific comparison function
[ "Map", "a", "key", "name", "to", "a", "specific", "comparison", "function" ]
python
train
38.272727
KrzyHonk/bpmn-python
bpmn_python/bpmn_diagram_rep.py
https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_rep.py#L416-L435
def add_gateway_to_diagram(self, process_id, gateway_type, gateway_name="", gateway_direction="Unspecified", node_id=None): """ Adds an exclusiveGateway element to BPMN diagram. :param process_id: string object. ID of parent process, :param gateway_type: s...
[ "def", "add_gateway_to_diagram", "(", "self", ",", "process_id", ",", "gateway_type", ",", "gateway_name", "=", "\"\"", ",", "gateway_direction", "=", "\"Unspecified\"", ",", "node_id", "=", "None", ")", ":", "gateway_id", ",", "gateway", "=", "self", ".", "ad...
Adds an exclusiveGateway element to BPMN diagram. :param process_id: string object. ID of parent process, :param gateway_type: string object. Type of gateway to be added. :param gateway_name: string object. Name of exclusive gateway, :param gateway_direction: string object. Accepted val...
[ "Adds", "an", "exclusiveGateway", "element", "to", "BPMN", "diagram", "." ]
python
train
63.9
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#L115-L124
def _to_operator(rep, data, input_dim, output_dim): """Transform a QuantumChannel to the Operator representation.""" if rep == 'Operator': return data if rep == 'Stinespring': return _stinespring_to_operator(data, input_dim, output_dim) # Convert via Kraus representation if rep != 'K...
[ "def", "_to_operator", "(", "rep", ",", "data", ",", "input_dim", ",", "output_dim", ")", ":", "if", "rep", "==", "'Operator'", ":", "return", "data", "if", "rep", "==", "'Stinespring'", ":", "return", "_stinespring_to_operator", "(", "data", ",", "input_dim...
Transform a QuantumChannel to the Operator representation.
[ "Transform", "a", "QuantumChannel", "to", "the", "Operator", "representation", "." ]
python
test
43.5
MolSSI-BSE/basis_set_exchange
basis_set_exchange/cli/check.py
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/cli/check.py#L71-L84
def _cli_check_basis(name, data_dir): '''Checks that a basis set exists and if not, raises a helpful exception''' if name is None: return None name = misc.transform_basis_name(name) metadata = api.get_metadata(data_dir) if not name in metadata: errstr = "Basis set '" + name + "' do...
[ "def", "_cli_check_basis", "(", "name", ",", "data_dir", ")", ":", "if", "name", "is", "None", ":", "return", "None", "name", "=", "misc", ".", "transform_basis_name", "(", "name", ")", "metadata", "=", "api", ".", "get_metadata", "(", "data_dir", ")", "...
Checks that a basis set exists and if not, raises a helpful exception
[ "Checks", "that", "a", "basis", "set", "exists", "and", "if", "not", "raises", "a", "helpful", "exception" ]
python
train
33.428571
ChristianTremblay/BAC0
BAC0/core/functions/discoverPoints.py
https://github.com/ChristianTremblay/BAC0/blob/8d95b065ea068524a08f5b0c34322ebeeba95d06/BAC0/core/functions/discoverPoints.py#L28-L139
def discoverPoints(bacnetapp, address, devID): """ Discover the BACnet points in a BACnet device. :param bacnetApp: The app itself so we can call read :param address: address of the device as a string (ex. '2:5') :param devID: device ID of the bacnet device as a string (ex. '1001') :returns: a...
[ "def", "discoverPoints", "(", "bacnetapp", ",", "address", ",", "devID", ")", ":", "pss", "=", "bacnetapp", ".", "read", "(", "\"{} device {} protocolServicesSupported\"", ".", "format", "(", "address", ",", "devID", ")", ")", "deviceName", "=", "bacnetapp", "...
Discover the BACnet points in a BACnet device. :param bacnetApp: The app itself so we can call read :param address: address of the device as a string (ex. '2:5') :param devID: device ID of the bacnet device as a string (ex. '1001') :returns: a tuple with deviceName, pss, objList, df * *device...
[ "Discover", "the", "BACnet", "points", "in", "a", "BACnet", "device", "." ]
python
train
31.428571
vkruoso/receita-tools
receita/tools/get.py
https://github.com/vkruoso/receita-tools/blob/fd62a252c76541c9feac6470b9048b31348ffe86/receita/tools/get.py#L88-L125
def valid(self, cnpj): """Check if a CNPJ is valid. We should avoid sending invalid CNPJ to the web service as we know it is going to be a waste of bandwidth. Assumes CNPJ is a string. """ if len(cnpj) != 14: return False tam = 12 nums = cnpj[:tam] ...
[ "def", "valid", "(", "self", ",", "cnpj", ")", ":", "if", "len", "(", "cnpj", ")", "!=", "14", ":", "return", "False", "tam", "=", "12", "nums", "=", "cnpj", "[", ":", "tam", "]", "digs", "=", "cnpj", "[", "tam", ":", "]", "tot", "=", "0", ...
Check if a CNPJ is valid. We should avoid sending invalid CNPJ to the web service as we know it is going to be a waste of bandwidth. Assumes CNPJ is a string.
[ "Check", "if", "a", "CNPJ", "is", "valid", "." ]
python
train
25.789474
MLAB-project/pymlab
src/pymlab/sensors/clkgen.py
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/clkgen.py#L102-L139
def set_freq(self, fout, freq): """ Sets new output frequency, required parameters are real current frequency at output and new required frequency. """ hsdiv_tuple = (4, 5, 6, 7, 9, 11) # possible dividers n1div_tuple = (1,) + tuple(range(2,129,2)) # fdco_min =...
[ "def", "set_freq", "(", "self", ",", "fout", ",", "freq", ")", ":", "hsdiv_tuple", "=", "(", "4", ",", "5", ",", "6", ",", "7", ",", "9", ",", "11", ")", "# possible dividers", "n1div_tuple", "=", "(", "1", ",", ")", "+", "tuple", "(", "range", ...
Sets new output frequency, required parameters are real current frequency at output and new required frequency.
[ "Sets", "new", "output", "frequency", "required", "parameters", "are", "real", "current", "frequency", "at", "output", "and", "new", "required", "frequency", "." ]
python
train
43.763158
iotile/coretools
iotilegateway/iotilegateway/main.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/main.py#L54-L107
def main(argv=None, loop=SharedLoop, max_time=None): """Main entry point for iotile-gateway.""" should_raise = argv is not None if argv is None: argv = sys.argv[1:] parser = build_parser() cmd_args = parser.parse_args(argv) configure_logging(cmd_args.verbose) logger = logging.getL...
[ "def", "main", "(", "argv", "=", "None", ",", "loop", "=", "SharedLoop", ",", "max_time", "=", "None", ")", ":", "should_raise", "=", "argv", "is", "not", "None", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]...
Main entry point for iotile-gateway.
[ "Main", "entry", "point", "for", "iotile", "-", "gateway", "." ]
python
train
31.611111
IdentityPython/pysaml2
src/saml2/cryptography/asymmetric.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/cryptography/asymmetric.py#L16-L20
def key_sign(rsakey, message, digest): """Sign the given message with the RSA key.""" padding = _asymmetric.padding.PKCS1v15() signature = rsakey.sign(message, padding, digest) return signature
[ "def", "key_sign", "(", "rsakey", ",", "message", ",", "digest", ")", ":", "padding", "=", "_asymmetric", ".", "padding", ".", "PKCS1v15", "(", ")", "signature", "=", "rsakey", ".", "sign", "(", "message", ",", "padding", ",", "digest", ")", "return", ...
Sign the given message with the RSA key.
[ "Sign", "the", "given", "message", "with", "the", "RSA", "key", "." ]
python
train
41
Alignak-monitoring/alignak
alignak/scheduler.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/scheduler.py#L600-L607
def hook_point(self, hook_name): """Generic function to call modules methods if such method is avalaible :param hook_name: function name to call :type hook_name: str :return:None """ self.my_daemon.hook_point(hook_name=hook_name, handle=self)
[ "def", "hook_point", "(", "self", ",", "hook_name", ")", ":", "self", ".", "my_daemon", ".", "hook_point", "(", "hook_name", "=", "hook_name", ",", "handle", "=", "self", ")" ]
Generic function to call modules methods if such method is avalaible :param hook_name: function name to call :type hook_name: str :return:None
[ "Generic", "function", "to", "call", "modules", "methods", "if", "such", "method", "is", "avalaible" ]
python
train
35.5
roclark/sportsreference
sportsreference/mlb/schedule.py
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/schedule.py#L172-L179
def datetime(self): """ Returns a datetime object of the month, day, year, and time the game was played. """ date_string = '%s %s' % (self._date, self._year) date_string = re.sub(r' \(\d+\)', '', date_string) return datetime.strptime(date_string, '%A, %b %d %Y')
[ "def", "datetime", "(", "self", ")", ":", "date_string", "=", "'%s %s'", "%", "(", "self", ".", "_date", ",", "self", ".", "_year", ")", "date_string", "=", "re", ".", "sub", "(", "r' \\(\\d+\\)'", ",", "''", ",", "date_string", ")", "return", "datetim...
Returns a datetime object of the month, day, year, and time the game was played.
[ "Returns", "a", "datetime", "object", "of", "the", "month", "day", "year", "and", "time", "the", "game", "was", "played", "." ]
python
train
38.875
paramiko/paramiko
paramiko/channel.py
https://github.com/paramiko/paramiko/blob/cf7d49d66f3b1fbc8b0853518a54050182b3b5eb/paramiko/channel.py#L233-L257
def exec_command(self, command): """ Execute a command on the server. If the server allows it, the channel will then be directly connected to the stdin, stdout, and stderr of the command being executed. When the command finishes executing, the channel will be closed and ...
[ "def", "exec_command", "(", "self", ",", "command", ")", ":", "m", "=", "Message", "(", ")", "m", ".", "add_byte", "(", "cMSG_CHANNEL_REQUEST", ")", "m", ".", "add_int", "(", "self", ".", "remote_chanid", ")", "m", ".", "add_string", "(", "\"exec\"", "...
Execute a command on the server. If the server allows it, the channel will then be directly connected to the stdin, stdout, and stderr of the command being executed. When the command finishes executing, the channel will be closed and can't be reused. You must open a new channel if you...
[ "Execute", "a", "command", "on", "the", "server", ".", "If", "the", "server", "allows", "it", "the", "channel", "will", "then", "be", "directly", "connected", "to", "the", "stdin", "stdout", "and", "stderr", "of", "the", "command", "being", "executed", "."...
python
train
34.72
jjgomera/iapws
iapws/iapws97.py
https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws97.py#L3854-L3925
def _Bound_Ph(P, h): """Region definition for input P y h Parameters ---------- P : float Pressure, [MPa] h : float Specific enthalpy, [kJ/kg] Returns ------- region : float IAPWS-97 region code References ---------- Wagner, W; Kretzschmar, H-J: Int...
[ "def", "_Bound_Ph", "(", "P", ",", "h", ")", ":", "region", "=", "None", "if", "Pmin", "<=", "P", "<=", "Ps_623", ":", "h14", "=", "_Region1", "(", "_TSat_P", "(", "P", ")", ",", "P", ")", "[", "\"h\"", "]", "h24", "=", "_Region2", "(", "_TSat_...
Region definition for input P y h Parameters ---------- P : float Pressure, [MPa] h : float Specific enthalpy, [kJ/kg] Returns ------- region : float IAPWS-97 region code References ---------- Wagner, W; Kretzschmar, H-J: International Steam Tables: Pro...
[ "Region", "definition", "for", "input", "P", "y", "h" ]
python
train
27.416667
xray7224/PyPump
pypump/models/feed.py
https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L537-L560
def create(self, display_name, content=None): """ Create a new user list :class:`collection <pypump.models.collection.Collection>`. :param display_name: List title. :param content: (optional) List description. Example: >>> pump.me.lists.create(display_name='Friends', conten...
[ "def", "create", "(", "self", ",", "display_name", ",", "content", "=", "None", ")", ":", "activity", "=", "{", "\"verb\"", ":", "\"create\"", ",", "\"object\"", ":", "{", "\"objectType\"", ":", "\"collection\"", ",", "\"objectTypes\"", ":", "[", "self", "...
Create a new user list :class:`collection <pypump.models.collection.Collection>`. :param display_name: List title. :param content: (optional) List description. Example: >>> pump.me.lists.create(display_name='Friends', content='List of friends') >>> myfriends = pump.me.l...
[ "Create", "a", "new", "user", "list", ":", "class", ":", "collection", "<pypump", ".", "models", ".", "collection", ".", "Collection", ">", "." ]
python
train
33.666667
pkkid/python-plexapi
plexapi/library.py
https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/library.py#L31-L44
def sections(self): """ Returns a list of all media sections in this library. Library sections may be any of :class:`~plexapi.library.MovieSection`, :class:`~plexapi.library.ShowSection`, :class:`~plexapi.library.MusicSection`, :class:`~plexapi.library.PhotoSection`. """ ...
[ "def", "sections", "(", "self", ")", ":", "key", "=", "'/library/sections'", "sections", "=", "[", "]", "for", "elem", "in", "self", ".", "_server", ".", "query", "(", "key", ")", ":", "for", "cls", "in", "(", "MovieSection", ",", "ShowSection", ",", ...
Returns a list of all media sections in this library. Library sections may be any of :class:`~plexapi.library.MovieSection`, :class:`~plexapi.library.ShowSection`, :class:`~plexapi.library.MusicSection`, :class:`~plexapi.library.PhotoSection`.
[ "Returns", "a", "list", "of", "all", "media", "sections", "in", "this", "library", ".", "Library", "sections", "may", "be", "any", "of", ":", "class", ":", "~plexapi", ".", "library", ".", "MovieSection", ":", "class", ":", "~plexapi", ".", "library", "....
python
train
51.785714
sdispater/poetry
poetry/utils/env.py
https://github.com/sdispater/poetry/blob/2d27acd76c165dd49f11934520a7973de7a3762a/poetry/utils/env.py#L391-L399
def _bin(self, bin): # type: (str) -> str """ Return path to the given executable. """ bin_path = (self._bin_dir / bin).with_suffix(".exe" if self._is_windows else "") if not bin_path.exists(): return bin return str(bin_path)
[ "def", "_bin", "(", "self", ",", "bin", ")", ":", "# type: (str) -> str", "bin_path", "=", "(", "self", ".", "_bin_dir", "/", "bin", ")", ".", "with_suffix", "(", "\".exe\"", "if", "self", ".", "_is_windows", "else", "\"\"", ")", "if", "not", "bin_path",...
Return path to the given executable.
[ "Return", "path", "to", "the", "given", "executable", "." ]
python
train
31
pydata/xarray
xarray/core/accessors.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/accessors.py#L87-L110
def _round_field(values, name, freq): """Indirectly access pandas rounding functions by wrapping data as a Series and calling through `.dt` attribute. Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : str (ceil, floor, round...
[ "def", "_round_field", "(", "values", ",", "name", ",", "freq", ")", ":", "if", "isinstance", "(", "values", ",", "dask_array_type", ")", ":", "from", "dask", ".", "array", "import", "map_blocks", "return", "map_blocks", "(", "_round_series", ",", "values", ...
Indirectly access pandas rounding functions by wrapping data as a Series and calling through `.dt` attribute. Parameters ---------- values : np.ndarray or dask.array-like Array-like container of datetime-like values name : str (ceil, floor, round) Name of rounding function freq ...
[ "Indirectly", "access", "pandas", "rounding", "functions", "by", "wrapping", "data", "as", "a", "Series", "and", "calling", "through", ".", "dt", "attribute", "." ]
python
train
33.458333
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/classtracker.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L334-L338
def _track_modify(self, cls, name, detail, keep, trace): """ Modify settings of a tracked class """ self._observers[cls].modify(name, detail, keep, trace)
[ "def", "_track_modify", "(", "self", ",", "cls", ",", "name", ",", "detail", ",", "keep", ",", "trace", ")", ":", "self", ".", "_observers", "[", "cls", "]", ".", "modify", "(", "name", ",", "detail", ",", "keep", ",", "trace", ")" ]
Modify settings of a tracked class
[ "Modify", "settings", "of", "a", "tracked", "class" ]
python
train
36.4
gwastro/pycbc
pycbc/tmpltbank/em_progenitors.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/em_progenitors.py#L199-L229
def pos_branch(incl, chi): """ Determines the effective [as defined in Stone, Loeb, Berger, PRD 87, 084053 (2013)] aligned dimensionless spin parameter of a NS-BH binary with tilted BH spin. This means finding the root chi_eff of ISCO_eq_chi_first(chi_eff, PG_ISSO_solver(chi,incl)). The resu...
[ "def", "pos_branch", "(", "incl", ",", "chi", ")", ":", "if", "incl", "==", "0", ":", "chi_eff", "=", "chi", "else", ":", "rISSO", "=", "PG_ISSO_solver", "(", "chi", ",", "incl", ")", "chi_eff", "=", "scipy", ".", "optimize", ".", "fsolve", "(", "I...
Determines the effective [as defined in Stone, Loeb, Berger, PRD 87, 084053 (2013)] aligned dimensionless spin parameter of a NS-BH binary with tilted BH spin. This means finding the root chi_eff of ISCO_eq_chi_first(chi_eff, PG_ISSO_solver(chi,incl)). The result returned by this function belongs to...
[ "Determines", "the", "effective", "[", "as", "defined", "in", "Stone", "Loeb", "Berger", "PRD", "87", "084053", "(", "2013", ")", "]", "aligned", "dimensionless", "spin", "parameter", "of", "a", "NS", "-", "BH", "binary", "with", "tilted", "BH", "spin", ...
python
train
30.870968
OSSOS/MOP
src/ossos/core/ossos/downloads/cutouts/source.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/downloads/cutouts/source.py#L298-L328
def get_observed_magnitude(self, centroid=True): # NOTE: this import is only here so that we don't load up IRAF # unnecessarily (ex: for candidates processing). """ Get the magnitude at the current pixel x/y location. :return: Table """ max_count = float(self.as...
[ "def", "get_observed_magnitude", "(", "self", ",", "centroid", "=", "True", ")", ":", "# NOTE: this import is only here so that we don't load up IRAF", "# unnecessarily (ex: for candidates processing).", "max_count", "=", "float", "(", "self", ".", "astrom_header", ".", "get"...
Get the magnitude at the current pixel x/y location. :return: Table
[ "Get", "the", "magnitude", "at", "the", "current", "pixel", "x", "/", "y", "location", "." ]
python
train
38.516129
nyergler/hieroglyph
src/hieroglyph/builder.py
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/builder.py#L145-L167
def post_process_images(self, doctree): """Pick the best candidate for all image URIs.""" super(AbstractSlideBuilder, self).post_process_images(doctree) # figure out where this doctree is in relation to the srcdir relative_base = ( ['..'] * doctree.attributes.ge...
[ "def", "post_process_images", "(", "self", ",", "doctree", ")", ":", "super", "(", "AbstractSlideBuilder", ",", "self", ")", ".", "post_process_images", "(", "doctree", ")", "# figure out where this doctree is in relation to the srcdir", "relative_base", "=", "(", "[", ...
Pick the best candidate for all image URIs.
[ "Pick", "the", "best", "candidate", "for", "all", "image", "URIs", "." ]
python
train
33.695652
NiklasRosenstein-Python/nr-deprecated
nr/stream.py
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/stream.py#L70-L85
def unique(cls, iterable, key=None): """ Yields unique items from *iterable* whilst preserving the original order. """ if key is None: key = lambda x: x def generator(): seen = set() seen_add = seen.add for item in iterable: key_val = key(item) if key_val not...
[ "def", "unique", "(", "cls", ",", "iterable", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "key", "=", "lambda", "x", ":", "x", "def", "generator", "(", ")", ":", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".",...
Yields unique items from *iterable* whilst preserving the original order.
[ "Yields", "unique", "items", "from", "*", "iterable", "*", "whilst", "preserving", "the", "original", "order", "." ]
python
train
24.4375
whiteclover/dbpy
db/query/insert.py
https://github.com/whiteclover/dbpy/blob/3d9ce85f55cfb39cced22081e525f79581b26b3a/db/query/insert.py#L36-L47
def values(self, values): """The values for insert , it can be a dict row or list tuple row. """ if isinstance(values, dict): l = [] for column in self._columns: l.append(values[column]) self._values.append(tuple(l)) else: ...
[ "def", "values", "(", "self", ",", "values", ")", ":", "if", "isinstance", "(", "values", ",", "dict", ")", ":", "l", "=", "[", "]", "for", "column", "in", "self", ".", "_columns", ":", "l", ".", "append", "(", "values", "[", "column", "]", ")", ...
The values for insert , it can be a dict row or list tuple row.
[ "The", "values", "for", "insert", "it", "can", "be", "a", "dict", "row", "or", "list", "tuple", "row", "." ]
python
train
30.666667
aquatix/python-utilkit
utilkit/fileutil.py
https://github.com/aquatix/python-utilkit/blob/1b4a4175381d2175592208619315f399610f915c/utilkit/fileutil.py#L72-L88
def list_files(dirname, extension=None): """ List all files in directory `dirname`, option to filter on file extension """ f = [] for (dirpath, dirnames, filenames) in os.walk(dirname): f.extend(filenames) break if extension is not None: # Filter on extension filt...
[ "def", "list_files", "(", "dirname", ",", "extension", "=", "None", ")", ":", "f", "=", "[", "]", "for", "(", "dirpath", ",", "dirnames", ",", "filenames", ")", "in", "os", ".", "walk", "(", "dirname", ")", ":", "f", ".", "extend", "(", "filenames"...
List all files in directory `dirname`, option to filter on file extension
[ "List", "all", "files", "in", "directory", "dirname", "option", "to", "filter", "on", "file", "extension" ]
python
train
30.588235
sanger-pathogens/circlator
circlator/merge.py
https://github.com/sanger-pathogens/circlator/blob/a4befb8c9dbbcd4b3ad1899a95aa3e689d58b638/circlator/merge.py#L158-L164
def _get_hit_nearest_ref_end(self, hits): '''Returns the hit nearest to the end of the ref sequence from the input list of hits''' nearest_to_end = hits[0] for hit in hits[1:]: if hit.ref_coords().end > nearest_to_end.ref_coords().end: nearest_to_end = hit ret...
[ "def", "_get_hit_nearest_ref_end", "(", "self", ",", "hits", ")", ":", "nearest_to_end", "=", "hits", "[", "0", "]", "for", "hit", "in", "hits", "[", "1", ":", "]", ":", "if", "hit", ".", "ref_coords", "(", ")", ".", "end", ">", "nearest_to_end", "."...
Returns the hit nearest to the end of the ref sequence from the input list of hits
[ "Returns", "the", "hit", "nearest", "to", "the", "end", "of", "the", "ref", "sequence", "from", "the", "input", "list", "of", "hits" ]
python
train
47.428571
jaredLunde/vital-tools
vital/debug/__init__.py
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L947-L951
def randset(self): """ -> a #set of random integers """ return { self._map_type(int) for x in range(self.random.randint(3, 10))}
[ "def", "randset", "(", "self", ")", ":", "return", "{", "self", ".", "_map_type", "(", "int", ")", "for", "x", "in", "range", "(", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", "}" ]
-> a #set of random integers
[ "-", ">", "a", "#set", "of", "random", "integers" ]
python
train
32.8
openpaperwork/paperwork-backend
paperwork_backend/shell.py
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/shell.py#L327-L401
def cmd_guess_labels(*args): """ Arguments: <document id> [-- [--apply]] Guess the labels that should be set on the document. Example: paperwork-shell guess_labels -- 20161207_1144_00_8 --apply Possible JSON replies: -- { "status": "error", "exception": "yyy", ...
[ "def", "cmd_guess_labels", "(", "*", "args", ")", ":", "args", "=", "list", "(", "args", ")", "apply_labels", "=", "False", "if", "\"--apply\"", "in", "args", ":", "apply_labels", "=", "True", "args", ".", "remove", "(", "\"--apply\"", ")", "docid", "=",...
Arguments: <document id> [-- [--apply]] Guess the labels that should be set on the document. Example: paperwork-shell guess_labels -- 20161207_1144_00_8 --apply Possible JSON replies: -- { "status": "error", "exception": "yyy", "reason": "xxxx", "args": "(xxxx, )" ...
[ "Arguments", ":", "<document", "id", ">", "[", "--", "[", "--", "apply", "]]" ]
python
train
27.2
poppy-project/pypot
pypot/vrep/remoteApiBindings/vrep.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L520-L527
def simxAuxiliaryConsolePrint(clientID, consoleHandle, txt, operationMode): ''' Please have a look at the function description/documentation in the V-REP user manual ''' if (sys.version_info[0] == 3) and (type(txt) is str): txt=txt.encode('utf-8') return c_AuxiliaryConsolePrint(clientID, co...
[ "def", "simxAuxiliaryConsolePrint", "(", "clientID", ",", "consoleHandle", ",", "txt", ",", "operationMode", ")", ":", "if", "(", "sys", ".", "version_info", "[", "0", "]", "==", "3", ")", "and", "(", "type", "(", "txt", ")", "is", "str", ")", ":", "...
Please have a look at the function description/documentation in the V-REP user manual
[ "Please", "have", "a", "look", "at", "the", "function", "description", "/", "documentation", "in", "the", "V", "-", "REP", "user", "manual" ]
python
train
43.125
LPgenerator/django-db-mailer
dbmail/providers/sendinblue/mail.py
https://github.com/LPgenerator/django-db-mailer/blob/217a73c21ba5c6b68738f74b2c55a6dd2c1afe35/dbmail/providers/sendinblue/mail.py#L26-L32
def email_address_to_list(email_address): """Convert an email address to a list.""" realname, address = email.utils.parseaddr(email_address) return ( [address, realname] if realname and address else [email_address, email_address] )
[ "def", "email_address_to_list", "(", "email_address", ")", ":", "realname", ",", "address", "=", "email", ".", "utils", ".", "parseaddr", "(", "email_address", ")", "return", "(", "[", "address", ",", "realname", "]", "if", "realname", "and", "address", "els...
Convert an email address to a list.
[ "Convert", "an", "email", "address", "to", "a", "list", "." ]
python
train
36.714286
stevearc/dql
dql/util.py
https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/util.py#L113-L147
def eval_interval(interval): """ Evaluate an interval expression """ kwargs = { "years": 0, "months": 0, "weeks": 0, "days": 0, "hours": 0, "minutes": 0, "seconds": 0, "microseconds": 0, } for section in interval[1:]: name = section...
[ "def", "eval_interval", "(", "interval", ")", ":", "kwargs", "=", "{", "\"years\"", ":", "0", ",", "\"months\"", ":", "0", ",", "\"weeks\"", ":", "0", ",", "\"days\"", ":", "0", ",", "\"hours\"", ":", "0", ",", "\"minutes\"", ":", "0", ",", "\"second...
Evaluate an interval expression
[ "Evaluate", "an", "interval", "expression" ]
python
train
33
tmr232/Sark
sark/qt.py
https://github.com/tmr232/Sark/blob/bee62879c2aea553a3924d887e2b30f2a6008581/sark/qt.py#L109-L118
def add_menu(self, name): """Add a top-level menu. The menu manager only allows one menu of the same name. However, it does not make sure that there are no pre-existing menus of that name. """ if name in self._menus: raise exceptions.MenuAlreadyExists("Menu name {!r}...
[ "def", "add_menu", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_menus", ":", "raise", "exceptions", ".", "MenuAlreadyExists", "(", "\"Menu name {!r} already exists.\"", ".", "format", "(", "name", ")", ")", "menu", "=", "self", "....
Add a top-level menu. The menu manager only allows one menu of the same name. However, it does not make sure that there are no pre-existing menus of that name.
[ "Add", "a", "top", "-", "level", "menu", "." ]
python
train
41.5
stefanfoulis/django-class-based-auth-views
class_based_auth_views/views.py
https://github.com/stefanfoulis/django-class-based-auth-views/blob/9998e2b8c1e5714c33a774a23c1a07d7a5928597/class_based_auth_views/views.py#L42-L49
def form_valid(self, form): """ The user has provided valid credentials (this was checked in AuthenticationForm.is_valid()). So now we can check the test cookie stuff and log him in. """ self.check_and_delete_test_cookie() login(self.request, form.get_user()) retu...
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "self", ".", "check_and_delete_test_cookie", "(", ")", "login", "(", "self", ".", "request", ",", "form", ".", "get_user", "(", ")", ")", "return", "super", "(", "LoginView", ",", "self", ")", "....
The user has provided valid credentials (this was checked in AuthenticationForm.is_valid()). So now we can check the test cookie stuff and log him in.
[ "The", "user", "has", "provided", "valid", "credentials", "(", "this", "was", "checked", "in", "AuthenticationForm", ".", "is_valid", "()", ")", ".", "So", "now", "we", "can", "check", "the", "test", "cookie", "stuff", "and", "log", "him", "in", "." ]
python
train
44.375
lappis-unb/salic-ml
src/salicml/metrics/finance/to_verify_funds.py
https://github.com/lappis-unb/salic-ml/blob/1b3ebc4f8067740999897ccffd9892dc94482a93/src/salicml/metrics/finance/to_verify_funds.py#L8-L19
def raised_funds_by_project(df): """ Raised funds organized by project. """ df['CaptacaoReal'] = df['CaptacaoReal'].apply( pd.to_numeric ) return ( df[['Pronac', 'CaptacaoReal']] .groupby(['Pronac']) .sum() )
[ "def", "raised_funds_by_project", "(", "df", ")", ":", "df", "[", "'CaptacaoReal'", "]", "=", "df", "[", "'CaptacaoReal'", "]", ".", "apply", "(", "pd", ".", "to_numeric", ")", "return", "(", "df", "[", "[", "'Pronac'", ",", "'CaptacaoReal'", "]", "]", ...
Raised funds organized by project.
[ "Raised", "funds", "organized", "by", "project", "." ]
python
train
21.416667
bpsmith/tia
tia/bbg/bbg_com.py
https://github.com/bpsmith/tia/blob/a7043b6383e557aeea8fc7112bbffd6e36a230e9/tia/bbg/bbg_com.py#L419-L428
def on_event(self, evt, is_final): """ this is invoked from in response to COM PumpWaitingMessages - different thread """ for msg in XmlHelper.message_iter(evt): # Single security element in historical request node = msg.GetElement('securityData') if node.HasElement('...
[ "def", "on_event", "(", "self", ",", "evt", ",", "is_final", ")", ":", "for", "msg", "in", "XmlHelper", ".", "message_iter", "(", "evt", ")", ":", "# Single security element in historical request", "node", "=", "msg", ".", "GetElement", "(", "'securityData'", ...
this is invoked from in response to COM PumpWaitingMessages - different thread
[ "this", "is", "invoked", "from", "in", "response", "to", "COM", "PumpWaitingMessages", "-", "different", "thread" ]
python
train
57.6
bhmm/bhmm
bhmm/hmm/generic_hmm.py
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L167-L172
def is_stationary(self): r""" Whether the MSM is stationary, i.e. whether the initial distribution is the stationary distribution of the hidden transition matrix. """ # for disconnected matrices, the stationary distribution depends on the estimator, so we can't compute # it directly. Th...
[ "def", "is_stationary", "(", "self", ")", ":", "# for disconnected matrices, the stationary distribution depends on the estimator, so we can't compute", "# it directly. Therefore we test whether the initial distribution is stationary.", "return", "np", ".", "allclose", "(", "np", ".", ...
r""" Whether the MSM is stationary, i.e. whether the initial distribution is the stationary distribution of the hidden transition matrix.
[ "r", "Whether", "the", "MSM", "is", "stationary", "i", ".", "e", ".", "whether", "the", "initial", "distribution", "is", "the", "stationary", "distribution", "of", "the", "hidden", "transition", "matrix", "." ]
python
train
74
saltstack/salt
salt/cli/api.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/api.py#L58-L71
def start(self): ''' Start the actual master. If sub-classed, don't **ever** forget to run: super(YourSubClass, self).start() NOTE: Run any required code before calling `super()`. ''' super(SaltAPI, self).start() if check_user(self.config['user']): ...
[ "def", "start", "(", "self", ")", ":", "super", "(", "SaltAPI", ",", "self", ")", ".", "start", "(", ")", "if", "check_user", "(", "self", ".", "config", "[", "'user'", "]", ")", ":", "log", ".", "info", "(", "'The salt-api is starting up'", ")", "se...
Start the actual master. If sub-classed, don't **ever** forget to run: super(YourSubClass, self).start() NOTE: Run any required code before calling `super()`.
[ "Start", "the", "actual", "master", "." ]
python
train
27.5
cokelaer/spectrum
src/spectrum/covar.py
https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/covar.py#L10-L257
def arcovar_marple(x, order): r"""Estimate AR model parameters using covariance method This implementation is based on [Marple]_. This code is far more complicated and slower than :func:`arcovar` function, which is now the official version. See :func:`arcovar` for a detailed description of Covariance m...
[ "def", "arcovar_marple", "(", "x", ",", "order", ")", ":", "assert", "len", "(", "x", ")", ">=", "order", ",", "\"X must be dimensioned >=N\"", "# ----------------------------------------------------- Initialization", "x", "=", "np", ".", "array", "(", "x", ")", ...
r"""Estimate AR model parameters using covariance method This implementation is based on [Marple]_. This code is far more complicated and slower than :func:`arcovar` function, which is now the official version. See :func:`arcovar` for a detailed description of Covariance method. This function should b...
[ "r", "Estimate", "AR", "model", "parameters", "using", "covariance", "method" ]
python
valid
32.987903
podio/podio-py
pypodio2/encode.py
https://github.com/podio/podio-py/blob/5ce956034a06c98b0ef18fcd940b36da0908ad6c/pypodio2/encode.py#L315-L319
def get_body_size(params, boundary): """Returns the number of bytes that the multipart/form-data encoding of ``params`` will be.""" size = sum(p.get_size(boundary) for p in MultipartParam.from_params(params)) return size + len(boundary) + 6
[ "def", "get_body_size", "(", "params", ",", "boundary", ")", ":", "size", "=", "sum", "(", "p", ".", "get_size", "(", "boundary", ")", "for", "p", "in", "MultipartParam", ".", "from_params", "(", "params", ")", ")", "return", "size", "+", "len", "(", ...
Returns the number of bytes that the multipart/form-data encoding of ``params`` will be.
[ "Returns", "the", "number", "of", "bytes", "that", "the", "multipart", "/", "form", "-", "data", "encoding", "of", "params", "will", "be", "." ]
python
train
50.4
log2timeline/plaso
plaso/cli/helpers/database_config.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/helpers/database_config.py#L49-L75
def ParseOptions(cls, options, output_module): """Parses and validates options. Args: options (argparse.Namespace): parser options. output_module (OutputModule): output module to configure. Raises: BadConfigObject: when the output module object does not have the SetCredentials ...
[ "def", "ParseOptions", "(", "cls", ",", "options", ",", "output_module", ")", ":", "if", "not", "hasattr", "(", "output_module", ",", "'SetCredentials'", ")", ":", "raise", "errors", ".", "BadConfigObject", "(", "'Unable to set username information.'", ")", "if", ...
Parses and validates options. Args: options (argparse.Namespace): parser options. output_module (OutputModule): output module to configure. Raises: BadConfigObject: when the output module object does not have the SetCredentials or SetDatabaseName methods.
[ "Parses", "and", "validates", "options", "." ]
python
train
40.037037
gem/oq-engine
openquake/hazardlib/gsim/skarlatoudis_2013.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/skarlatoudis_2013.py#L122-L130
def _compute_distance(self, rup, dists, C): """ equation 3 pag 1960: ``c31 * logR + c32 * (R-Rref)`` """ rref = 1.0 c31 = -1.7 return (c31 * np.log10(dists.rhypo) + C['c32'] * (dists.rhypo - rref))
[ "def", "_compute_distance", "(", "self", ",", "rup", ",", "dists", ",", "C", ")", ":", "rref", "=", "1.0", "c31", "=", "-", "1.7", "return", "(", "c31", "*", "np", ".", "log10", "(", "dists", ".", "rhypo", ")", "+", "C", "[", "'c32'", "]", "*",...
equation 3 pag 1960: ``c31 * logR + c32 * (R-Rref)``
[ "equation", "3", "pag", "1960", ":" ]
python
train
27.333333
jotacor/ComunioPy
ComunioPy/__init__.py
https://github.com/jotacor/ComunioPy/blob/2dd71e3e197b497980ea7b9cfbec1da64dca3ed0/ComunioPy/__init__.py#L172-L182
def info_player_id(self,name): '''Get id using name football player''' number = 0 name=name.title().replace(" ", "+") headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain",'Referer': 'http://'+self.domain+'/team_news.phtml',"User-Agent": user_agent} ...
[ "def", "info_player_id", "(", "self", ",", "name", ")", ":", "number", "=", "0", "name", "=", "name", ".", "title", "(", ")", ".", "replace", "(", "\" \"", ",", "\"+\"", ")", "headers", "=", "{", "\"Content-type\"", ":", "\"application/x-www-form-urlencode...
Get id using name football player
[ "Get", "id", "using", "name", "football", "player" ]
python
train
58
KKBOX/OpenAPI-Python
kkbox_developer_sdk/auth_flow.py
https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/auth_flow.py#L27-L60
def fetch_access_token_by_client_credentials(self): ''' There are three ways to let you start using KKBOX's Open/Partner API. The first way among them is to generate a client credential to fetch an access token to let KKBOX identify you. It allows you to access public data from K...
[ "def", "fetch_access_token_by_client_credentials", "(", "self", ")", ":", "client_credential_base", "=", "'%s:%s'", "%", "(", "self", ".", "client_id", ",", "self", ".", "client_secret", ")", "try", ":", "client_credentials", "=", "base64", ".", "b64encode", "(", ...
There are three ways to let you start using KKBOX's Open/Partner API. The first way among them is to generate a client credential to fetch an access token to let KKBOX identify you. It allows you to access public data from KKBOX such as public albums, playlists and so on. Howeve...
[ "There", "are", "three", "ways", "to", "let", "you", "start", "using", "KKBOX", "s", "Open", "/", "Partner", "API", ".", "The", "first", "way", "among", "them", "is", "to", "generate", "a", "client", "credential", "to", "fetch", "an", "access", "token", ...
python
train
48.705882
Hackerfleet/hfos
hfos/tool/installer.py
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L377-L380
def service(ctx): """Install systemd service configuration""" install_service(ctx.obj['instance'], ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'])
[ "def", "service", "(", "ctx", ")", ":", "install_service", "(", "ctx", ".", "obj", "[", "'instance'", "]", ",", "ctx", ".", "obj", "[", "'dbhost'", "]", ",", "ctx", ".", "obj", "[", "'dbname'", "]", ",", "ctx", ".", "obj", "[", "'port'", "]", ")"...
Install systemd service configuration
[ "Install", "systemd", "service", "configuration" ]
python
train
39.75
CodeReclaimers/neat-python
neat/distributed.py
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/distributed.py#L469-L473
def _reset_em(self): """Resets self.em and the shared instances.""" self.em = _ExtendedManager(self.addr, self.authkey, mode=self.mode, start=False) self.em.start() self._set_shared_instances()
[ "def", "_reset_em", "(", "self", ")", ":", "self", ".", "em", "=", "_ExtendedManager", "(", "self", ".", "addr", ",", "self", ".", "authkey", ",", "mode", "=", "self", ".", "mode", ",", "start", "=", "False", ")", "self", ".", "em", ".", "start", ...
Resets self.em and the shared instances.
[ "Resets", "self", ".", "em", "and", "the", "shared", "instances", "." ]
python
train
44.2
jleinonen/pytmatrix
pytmatrix/refractive.py
https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/refractive.py#L60-L74
def bruggeman_refractive(m, mix): """Bruggeman EMA for the refractive index. For instructions, see mg_refractive in this module, except this routine only works for two components. """ f1 = mix[0]/sum(mix) f2 = mix[1]/sum(mix) e1 = m[0]**2 e2 = m[1]**2 a = -2*(f1+f2) b = (2*f1*e1...
[ "def", "bruggeman_refractive", "(", "m", ",", "mix", ")", ":", "f1", "=", "mix", "[", "0", "]", "/", "sum", "(", "mix", ")", "f2", "=", "mix", "[", "1", "]", "/", "sum", "(", "mix", ")", "e1", "=", "m", "[", "0", "]", "**", "2", "e2", "="...
Bruggeman EMA for the refractive index. For instructions, see mg_refractive in this module, except this routine only works for two components.
[ "Bruggeman", "EMA", "for", "the", "refractive", "index", "." ]
python
train
28.4
Esri/ArcREST
src/arcrest/manageportal/administration.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageportal/administration.py#L678-L700
def refreshUserMembership(self, users): """ This operation iterates over every enterprise group configured in the portal and determines if the input user accounts belong to any of the configured enterprise groups. If there is any change in membership, the database and the indexes...
[ "def", "refreshUserMembership", "(", "self", ",", "users", ")", ":", "params", "=", "{", "\"f\"", ":", "\"json\"", ",", "\"users\"", ":", "users", "}", "url", "=", "self", ".", "_url", "+", "\"/users/refreshMembership\"", "return", "self", ".", "_post", "(...
This operation iterates over every enterprise group configured in the portal and determines if the input user accounts belong to any of the configured enterprise groups. If there is any change in membership, the database and the indexes are updated for each user account. While portal aut...
[ "This", "operation", "iterates", "over", "every", "enterprise", "group", "configured", "in", "the", "portal", "and", "determines", "if", "the", "input", "user", "accounts", "belong", "to", "any", "of", "the", "configured", "enterprise", "groups", ".", "If", "t...
python
train
43.26087
napalm-automation/napalm
napalm/junos/junos.py
https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/junos/junos.py#L149-L156
def _unlock(self): """Unlock the config DB.""" if self.locked: try: self.device.cu.unlock() self.locked = False except JnrpUnlockError as jue: raise UnlockError(jue.messsage)
[ "def", "_unlock", "(", "self", ")", ":", "if", "self", ".", "locked", ":", "try", ":", "self", ".", "device", ".", "cu", ".", "unlock", "(", ")", "self", ".", "locked", "=", "False", "except", "JnrpUnlockError", "as", "jue", ":", "raise", "UnlockErro...
Unlock the config DB.
[ "Unlock", "the", "config", "DB", "." ]
python
train
31.875
sbg/sevenbridges-python
sevenbridges/models/task.py
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/task.py#L367-L379
def get_execution_details(self): """ Retrieves execution details for a task. :return: Execution details instance. """ extra = { 'resource': self.__class__.__name__, 'query': {'id': self.id} } logger.info('Get execution details', extra=extra...
[ "def", "get_execution_details", "(", "self", ")", ":", "extra", "=", "{", "'resource'", ":", "self", ".", "__class__", ".", "__name__", ",", "'query'", ":", "{", "'id'", ":", "self", ".", "id", "}", "}", "logger", ".", "info", "(", "'Get execution detail...
Retrieves execution details for a task. :return: Execution details instance.
[ "Retrieves", "execution", "details", "for", "a", "task", ".", ":", "return", ":", "Execution", "details", "instance", "." ]
python
train
35.692308
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_attention.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_attention.py#L333-L400
def vqa_attention_base(): """VQA attention baseline hparams.""" hparams = common_hparams.basic_params1() hparams.batch_size = 128 hparams.use_fixed_batch_size = True, hparams.optimizer = "adam" hparams.optimizer_adam_beta1 = 0.9 hparams.optimizer_adam_beta2 = 0.999 hparams.optimizer_adam_epsilon = 1e-8 ...
[ "def", "vqa_attention_base", "(", ")", ":", "hparams", "=", "common_hparams", ".", "basic_params1", "(", ")", "hparams", ".", "batch_size", "=", "128", "hparams", ".", "use_fixed_batch_size", "=", "True", ",", "hparams", ".", "optimizer", "=", "\"adam\"", "hpa...
VQA attention baseline hparams.
[ "VQA", "attention", "baseline", "hparams", "." ]
python
train
31.75
wonambi-python/wonambi
wonambi/ioeeg/micromed.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/ioeeg/micromed.py#L67-L114
def return_dat(self, chan, begsam, endsam): """Return the data as 2D numpy.ndarray. Parameters ---------- chan : int or list index (indices) of the channels to read begsam : int index of the first sample endsam : int index of the last ...
[ "def", "return_dat", "(", "self", ",", "chan", ",", "begsam", ",", "endsam", ")", ":", "if", "type", "(", "chan", ")", "==", "int", ":", "# if single value is provided it needs to be transformed to list to generate a 2d matrix", "chan", "=", "[", "chan", ",", "]",...
Return the data as 2D numpy.ndarray. Parameters ---------- chan : int or list index (indices) of the channels to read begsam : int index of the first sample endsam : int index of the last sample Returns ------- numpy.n...
[ "Return", "the", "data", "as", "2D", "numpy", ".", "ndarray", "." ]
python
train
30.6875
has2k1/scikit-misc
setup.py
https://github.com/has2k1/scikit-misc/blob/1d599761e11f84233e59602330e22823efeee226/setup.py#L102-L120
def setup_requires(): """ Return required packages Plus any version tests and warnings """ from pkg_resources import parse_version required = ['cython>=0.24.0'] numpy_requirement = 'numpy>=1.7.1' try: import numpy except Exception: required.append(numpy_requirement)...
[ "def", "setup_requires", "(", ")", ":", "from", "pkg_resources", "import", "parse_version", "required", "=", "[", "'cython>=0.24.0'", "]", "numpy_requirement", "=", "'numpy>=1.7.1'", "try", ":", "import", "numpy", "except", "Exception", ":", "required", ".", "appe...
Return required packages Plus any version tests and warnings
[ "Return", "required", "packages" ]
python
train
23.684211
Leeps-Lab/otree-redwood
otree_redwood/models.py
https://github.com/Leeps-Lab/otree-redwood/blob/59212f61a256ef77e0a9ed392ff497ea83ee6245/otree_redwood/models.py#L213-L245
def when_all_players_ready(self): """Initializes decisions based on ``player.initial_decision()``. If :attr:`num_subperiods` is set, starts a timed task to run the sub-periods. """ self.group_decisions = {} self.subperiod_group_decisions = {} for player in self.ge...
[ "def", "when_all_players_ready", "(", "self", ")", ":", "self", ".", "group_decisions", "=", "{", "}", "self", ".", "subperiod_group_decisions", "=", "{", "}", "for", "player", "in", "self", ".", "get_players", "(", ")", ":", "self", ".", "group_decisions", ...
Initializes decisions based on ``player.initial_decision()``. If :attr:`num_subperiods` is set, starts a timed task to run the sub-periods.
[ "Initializes", "decisions", "based", "on", "player", ".", "initial_decision", "()", ".", "If", ":", "attr", ":", "num_subperiods", "is", "set", "starts", "a", "timed", "task", "to", "run", "the", "sub", "-", "periods", "." ]
python
train
41.787879
google/apitools
apitools/base/py/credentials_lib.py
https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/credentials_lib.py#L670-L680
def _EnsureFileExists(self): """Touches a file; returns False on error, True on success.""" if not os.path.exists(self._filename): old_umask = os.umask(0o177) try: open(self._filename, 'a+b').close() except OSError: return False ...
[ "def", "_EnsureFileExists", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "_filename", ")", ":", "old_umask", "=", "os", ".", "umask", "(", "0o177", ")", "try", ":", "open", "(", "self", ".", "_filename", "...
Touches a file; returns False on error, True on success.
[ "Touches", "a", "file", ";", "returns", "False", "on", "error", "True", "on", "success", "." ]
python
train
34.454545
jtwhite79/pyemu
pyemu/en.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/en.py#L407-L418
def nonzero(self): """ property decorated method to get a new ObservationEnsemble of only non-zero weighted observations Returns ------- ObservationEnsemble : ObservationEnsemble """ df = self.loc[:,self.pst.nnz_obs_names] return ObservationEnsemble.from...
[ "def", "nonzero", "(", "self", ")", ":", "df", "=", "self", ".", "loc", "[", ":", ",", "self", ".", "pst", ".", "nnz_obs_names", "]", "return", "ObservationEnsemble", ".", "from_dataframe", "(", "df", "=", "df", ",", "pst", "=", "self", ".", "pst", ...
property decorated method to get a new ObservationEnsemble of only non-zero weighted observations Returns ------- ObservationEnsemble : ObservationEnsemble
[ "property", "decorated", "method", "to", "get", "a", "new", "ObservationEnsemble", "of", "only", "non", "-", "zero", "weighted", "observations" ]
python
train
33.5
jantman/webhook2lambda2sqs
webhook2lambda2sqs/tf_generator.py
https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L380-L398
def _generate_api_gateway_deployment(self): """ Generate the API Gateway Deployment/Stage, and add to self.tf_conf """ # finally, the deployment # this resource MUST come last dep_on = [] for rtype in sorted(self.tf_conf['resource'].keys()): for rname ...
[ "def", "_generate_api_gateway_deployment", "(", "self", ")", ":", "# finally, the deployment", "# this resource MUST come last", "dep_on", "=", "[", "]", "for", "rtype", "in", "sorted", "(", "self", ".", "tf_conf", "[", "'resource'", "]", ".", "keys", "(", ")", ...
Generate the API Gateway Deployment/Stage, and add to self.tf_conf
[ "Generate", "the", "API", "Gateway", "Deployment", "/", "Stage", "and", "add", "to", "self", ".", "tf_conf" ]
python
train
42.842105
DaveMcEwan/ndim
ndim_base.py
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L212-L226
def pt_shift(pt=(0.0, 0.0), shift=[0.0, 0.0]): '''Return given point shifted in N dimensions. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i, float) assert isinstance(shift, list) l_sh = len(shift) assert l_sh == l_pt for ...
[ "def", "pt_shift", "(", "pt", "=", "(", "0.0", ",", "0.0", ")", ",", "shift", "=", "[", "0.0", ",", "0.0", "]", ")", ":", "assert", "isinstance", "(", "pt", ",", "tuple", ")", "l_pt", "=", "len", "(", "pt", ")", "assert", "l_pt", ">", "1", "f...
Return given point shifted in N dimensions.
[ "Return", "given", "point", "shifted", "in", "N", "dimensions", "." ]
python
train
27.466667
pypa/pipenv
pipenv/vendor/vistir/spin.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/spin.py#L318-L332
def _freeze(self, final_text, err=False): """Stop spinner, compose last frame and 'freeze' it.""" if not final_text: final_text = "" target = self.stderr if err else self.stdout if target.closed: target = sys.stderr if err else sys.stdout text = to_text(fi...
[ "def", "_freeze", "(", "self", ",", "final_text", ",", "err", "=", "False", ")", ":", "if", "not", "final_text", ":", "final_text", "=", "\"\"", "target", "=", "self", ".", "stderr", "if", "err", "else", "self", ".", "stdout", "if", "target", ".", "c...
Stop spinner, compose last frame and 'freeze' it.
[ "Stop", "spinner", "compose", "last", "frame", "and", "freeze", "it", "." ]
python
train
41.2
sykora/djournal
djournal/views.py
https://github.com/sykora/djournal/blob/c074e1f94e07e2630034a00c7dbd768e933f85e2/djournal/views.py#L10-L26
def entry_index(request, limit=0, template='djournal/entry_index.html'): '''Returns a reponse of a fixed number of entries; all of them, by default. ''' entries = Entry.public.all() if limit > 0: entries = entries[:limit] context = { 'entries': entries, } return render_to_res...
[ "def", "entry_index", "(", "request", ",", "limit", "=", "0", ",", "template", "=", "'djournal/entry_index.html'", ")", ":", "entries", "=", "Entry", ".", "public", ".", "all", "(", ")", "if", "limit", ">", "0", ":", "entries", "=", "entries", "[", ":"...
Returns a reponse of a fixed number of entries; all of them, by default.
[ "Returns", "a", "reponse", "of", "a", "fixed", "number", "of", "entries", ";", "all", "of", "them", "by", "default", "." ]
python
train
23.588235
watson-developer-cloud/python-sdk
ibm_watson/natural_language_understanding_v1.py
https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/natural_language_understanding_v1.py#L1015-L1020
def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'emotion') and self.emotion is not None: _dict['emotion'] = self.emotion._to_dict() return _dict
[ "def", "_to_dict", "(", "self", ")", ":", "_dict", "=", "{", "}", "if", "hasattr", "(", "self", ",", "'emotion'", ")", "and", "self", ".", "emotion", "is", "not", "None", ":", "_dict", "[", "'emotion'", "]", "=", "self", ".", "emotion", ".", "_to_d...
Return a json dictionary representing this model.
[ "Return", "a", "json", "dictionary", "representing", "this", "model", "." ]
python
train
39.833333
T-002/pycast
pycast/common/matrix.py
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L274-L290
def get_matrix_from_list(self, rows, columns, matrix_list, rowBased=True): """Create a new Matrix instance from a matrix_list. :note: This method is used to create a Matrix instance using cpython. :param integer rows: The height of the Matrix. :param integer columns: The widt...
[ "def", "get_matrix_from_list", "(", "self", ",", "rows", ",", "columns", ",", "matrix_list", ",", "rowBased", "=", "True", ")", ":", "resultMatrix", "=", "Matrix", "(", "columns", ",", "rows", ",", "matrix_list", ",", "rowBased", ")", "return", "resultMatrix...
Create a new Matrix instance from a matrix_list. :note: This method is used to create a Matrix instance using cpython. :param integer rows: The height of the Matrix. :param integer columns: The width of the Matrix. :param matrix_list: A one dimensional list containing...
[ "Create", "a", "new", "Matrix", "instance", "from", "a", "matrix_list", "." ]
python
train
58.882353
PMEAL/OpenPNM
openpnm/algorithms/MixedInvasionPercolation.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/algorithms/MixedInvasionPercolation.py#L272-L292
def _add_ps2q(self, throat, queue): """ Helper method to add pores to the cluster queue """ net = self.project.network elem_type = 'pore' # Find pores connected to newly invaded throat Ps = net['throat.conns'][throat] # Remove already invaded pores from Ps...
[ "def", "_add_ps2q", "(", "self", ",", "throat", ",", "queue", ")", ":", "net", "=", "self", ".", "project", ".", "network", "elem_type", "=", "'pore'", "# Find pores connected to newly invaded throat", "Ps", "=", "net", "[", "'throat.conns'", "]", "[", "throat...
Helper method to add pores to the cluster queue
[ "Helper", "method", "to", "add", "pores", "to", "the", "cluster", "queue" ]
python
train
35.52381
DataDog/integrations-core
kubelet/datadog_checks/kubelet/prometheus.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/prometheus.py#L453-L461
def container_fs_usage_bytes(self, metric, scraper_config): """ Number of bytes that are consumed by the container on this filesystem. """ metric_name = scraper_config['namespace'] + '.filesystem.usage' if metric.type not in METRIC_TYPES: self.log.error("Metric type %...
[ "def", "container_fs_usage_bytes", "(", "self", ",", "metric", ",", "scraper_config", ")", ":", "metric_name", "=", "scraper_config", "[", "'namespace'", "]", "+", "'.filesystem.usage'", "if", "metric", ".", "type", "not", "in", "METRIC_TYPES", ":", "self", ".",...
Number of bytes that are consumed by the container on this filesystem.
[ "Number", "of", "bytes", "that", "are", "consumed", "by", "the", "container", "on", "this", "filesystem", "." ]
python
train
53.555556
tensorflow/cleverhans
cleverhans/model_zoo/deep_k_nearest_neighbors/dknn.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/model_zoo/deep_k_nearest_neighbors/dknn.py#L134-L168
def find_train_knns(self, data_activations): """ Given a data_activation dictionary that contains a np array with activations for each layer, find the knns in the training data. """ knns_ind = {} knns_labels = {} for layer in self.layers: # Pre-process representations of data to norma...
[ "def", "find_train_knns", "(", "self", ",", "data_activations", ")", ":", "knns_ind", "=", "{", "}", "knns_labels", "=", "{", "}", "for", "layer", "in", "self", ".", "layers", ":", "# Pre-process representations of data to normalize and remove training data mean.", "d...
Given a data_activation dictionary that contains a np array with activations for each layer, find the knns in the training data.
[ "Given", "a", "data_activation", "dictionary", "that", "contains", "a", "np", "array", "with", "activations", "for", "each", "layer", "find", "the", "knns", "in", "the", "training", "data", "." ]
python
train
43
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/setup.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/setup.py#L50-L77
def generate_proto(source, require = True): """Invokes the Protocol Compiler to generate a _pb2.py from the given .proto file. Does nothing if the output already exists and is newer than the input.""" if not require and not os.path.exists(source): return output = source.replace(".proto", "_pb2.py").rep...
[ "def", "generate_proto", "(", "source", ",", "require", "=", "True", ")", ":", "if", "not", "require", "and", "not", "os", ".", "path", ".", "exists", "(", "source", ")", ":", "return", "output", "=", "source", ".", "replace", "(", "\".proto\"", ",", ...
Invokes the Protocol Compiler to generate a _pb2.py from the given .proto file. Does nothing if the output already exists and is newer than the input.
[ "Invokes", "the", "Protocol", "Compiler", "to", "generate", "a", "_pb2", ".", "py", "from", "the", "given", ".", "proto", "file", ".", "Does", "nothing", "if", "the", "output", "already", "exists", "and", "is", "newer", "than", "the", "input", "." ]
python
train
33.464286
pybel/pybel
src/pybel/manager/citation_utils.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/citation_utils.py#L100-L133
def enrich_citation_model(manager, citation, p) -> bool: """Enrich a citation model with the information from PubMed. :param pybel.manager.Manager manager: :param Citation citation: A citation model :param dict p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid] """ if 'err...
[ "def", "enrich_citation_model", "(", "manager", ",", "citation", ",", "p", ")", "->", "bool", ":", "if", "'error'", "in", "p", ":", "log", ".", "warning", "(", "'Error downloading PubMed'", ")", "return", "False", "citation", ".", "name", "=", "p", "[", ...
Enrich a citation model with the information from PubMed. :param pybel.manager.Manager manager: :param Citation citation: A citation model :param dict p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid]
[ "Enrich", "a", "citation", "model", "with", "the", "information", "from", "PubMed", "." ]
python
train
36.441176
timothyhahn/rui
rui/rui.py
https://github.com/timothyhahn/rui/blob/ac9f587fb486760d77332866c6e876f78a810f74/rui/rui.py#L99-L106
def remove_system(self, system): ''' Removes system from world and kills system ''' if system in self._systems: self._systems.remove(system) else: raise UnmanagedSystemError(system)
[ "def", "remove_system", "(", "self", ",", "system", ")", ":", "if", "system", "in", "self", ".", "_systems", ":", "self", ".", "_systems", ".", "remove", "(", "system", ")", "else", ":", "raise", "UnmanagedSystemError", "(", "system", ")" ]
Removes system from world and kills system
[ "Removes", "system", "from", "world", "and", "kills", "system" ]
python
train
29.75
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L619-L622
def _readline_echo(self, char, echo): """Echo a recieved character, move cursor etc...""" if self._readline_do_echo(echo): self.write(char)
[ "def", "_readline_echo", "(", "self", ",", "char", ",", "echo", ")", ":", "if", "self", ".", "_readline_do_echo", "(", "echo", ")", ":", "self", ".", "write", "(", "char", ")" ]
Echo a recieved character, move cursor etc...
[ "Echo", "a", "recieved", "character", "move", "cursor", "etc", "..." ]
python
train
41