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
census-instrumentation/opencensus-python
contrib/opencensus-ext-zipkin/opencensus/ext/zipkin/trace_exporter/__init__.py
https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/contrib/opencensus-ext-zipkin/opencensus/ext/zipkin/trace_exporter/__init__.py#L125-L182
def translate_to_zipkin(self, span_datas): """Translate the opencensus spans to zipkin spans. :type span_datas: list of :class: `~opencensus.trace.span_data.SpanData` :param span_datas: SpanData tuples to emit :rtype: list :returns: List of zipkin format...
[ "def", "translate_to_zipkin", "(", "self", ",", "span_datas", ")", ":", "local_endpoint", "=", "{", "'serviceName'", ":", "self", ".", "service_name", ",", "'port'", ":", "self", ".", "port", ",", "}", "if", "self", ".", "ipv4", "is", "not", "None", ":",...
Translate the opencensus spans to zipkin spans. :type span_datas: list of :class: `~opencensus.trace.span_data.SpanData` :param span_datas: SpanData tuples to emit :rtype: list :returns: List of zipkin format spans.
[ "Translate", "the", "opencensus", "spans", "to", "zipkin", "spans", "." ]
python
train
33.344828
crackinglandia/pype32
pype32/pype32.py
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L618-L625
def _fixPe(self): """ Fixes the necessary fields in the PE file instance in order to create a valid PE32. i.e. SizeOfImage. """ sizeOfImage = 0 for sh in self.sectionHeaders: sizeOfImage += sh.misc self.ntHeaders.optionaHeader.sizeoOfImage.value = self._sectio...
[ "def", "_fixPe", "(", "self", ")", ":", "sizeOfImage", "=", "0", "for", "sh", "in", "self", ".", "sectionHeaders", ":", "sizeOfImage", "+=", "sh", ".", "misc", "self", ".", "ntHeaders", ".", "optionaHeader", ".", "sizeoOfImage", ".", "value", "=", "self"...
Fixes the necessary fields in the PE file instance in order to create a valid PE32. i.e. SizeOfImage.
[ "Fixes", "the", "necessary", "fields", "in", "the", "PE", "file", "instance", "in", "order", "to", "create", "a", "valid", "PE32", ".", "i", ".", "e", ".", "SizeOfImage", "." ]
python
train
43.125
pandas-dev/pandas
pandas/io/formats/format.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/format.py#L720-L747
def to_html(self, classes=None, notebook=False, border=None): """ Render a DataFrame to a html table. Parameters ---------- classes : str or list-like classes to include in the `class` attribute of the opening ``<table>`` tag, in addition to the default "...
[ "def", "to_html", "(", "self", ",", "classes", "=", "None", ",", "notebook", "=", "False", ",", "border", "=", "None", ")", ":", "from", "pandas", ".", "io", ".", "formats", ".", "html", "import", "HTMLFormatter", ",", "NotebookFormatter", "Klass", "=", ...
Render a DataFrame to a html table. Parameters ---------- classes : str or list-like classes to include in the `class` attribute of the opening ``<table>`` tag, in addition to the default "dataframe". notebook : {True, False}, optional, default False ...
[ "Render", "a", "DataFrame", "to", "a", "html", "table", "." ]
python
train
42.035714
Kortemme-Lab/klab
klab/bio/fragments/generate_fragments.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fragments/generate_fragments.py#L547-L721
def parse_FASTA_files(options, fasta_file_contents): ''' This function iterates through each filepath in fasta_file_contents and returns a dict mapping (pdbid, chain, file_name) tuples to sequences: - options is the OptionParser member; - fasta_file_contents is a map from input filenames to the ...
[ "def", "parse_FASTA_files", "(", "options", ",", "fasta_file_contents", ")", ":", "records", "=", "{", "}", "reverse_mapping", "=", "{", "}", "original_segment_list", "=", "[", "]", "key_location", "=", "{", "}", "sequenceLine", "=", "re", ".", "compile", "(...
This function iterates through each filepath in fasta_file_contents and returns a dict mapping (pdbid, chain, file_name) tuples to sequences: - options is the OptionParser member; - fasta_file_contents is a map from input filenames to the associated FASTA file contents.
[ "This", "function", "iterates", "through", "each", "filepath", "in", "fasta_file_contents", "and", "returns", "a", "dict", "mapping", "(", "pdbid", "chain", "file_name", ")", "tuples", "to", "sequences", ":", "-", "options", "is", "the", "OptionParser", "member"...
python
train
65.6
azogue/esiosdata
esiosdata/importdemdata.py
https://github.com/azogue/esiosdata/blob/680c7918955bc6ceee5bded92b3a4485f5ea8151/esiosdata/importdemdata.py#L39-L50
def dem_url_dia(dt_day='2015-06-22'): """Obtiene las urls de descarga de los datos de demanda energética de un día concreto.""" def _url_tipo_dato(str_dia, k): url = SERVER + '/archives/{}/download_json?locale=es'.format(D_TIPOS_REQ_DEM[k]) if type(str_dia) is str: return url + '&da...
[ "def", "dem_url_dia", "(", "dt_day", "=", "'2015-06-22'", ")", ":", "def", "_url_tipo_dato", "(", "str_dia", ",", "k", ")", ":", "url", "=", "SERVER", "+", "'/archives/{}/download_json?locale=es'", ".", "format", "(", "D_TIPOS_REQ_DEM", "[", "k", "]", ")", "...
Obtiene las urls de descarga de los datos de demanda energética de un día concreto.
[ "Obtiene", "las", "urls", "de", "descarga", "de", "los", "datos", "de", "demanda", "energética", "de", "un", "día", "concreto", "." ]
python
valid
40.666667
Microsoft/nni
examples/trials/ga_squad/graph.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/ga_squad/graph.py#L133-L168
def is_topology(self, layers=None): ''' valid the topology ''' if layers is None: layers = self.layers layers_nodle = [] result = [] for i, layer in enumerate(layers): if layer.is_delete is False: layers_nodle.append(i) ...
[ "def", "is_topology", "(", "self", ",", "layers", "=", "None", ")", ":", "if", "layers", "is", "None", ":", "layers", "=", "self", ".", "layers", "layers_nodle", "=", "[", "]", "result", "=", "[", "]", "for", "i", ",", "layer", "in", "enumerate", "...
valid the topology
[ "valid", "the", "topology" ]
python
train
35.611111
cole/aiosmtplib
src/aiosmtplib/connection.py
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L342-L353
def close(self) -> None: """ Closes the connection. """ if self.transport is not None and not self.transport.is_closing(): self.transport.close() if self._connect_lock.locked(): self._connect_lock.release() self.protocol = None self.trans...
[ "def", "close", "(", "self", ")", "->", "None", ":", "if", "self", ".", "transport", "is", "not", "None", "and", "not", "self", ".", "transport", ".", "is_closing", "(", ")", ":", "self", ".", "transport", ".", "close", "(", ")", "if", "self", ".",...
Closes the connection.
[ "Closes", "the", "connection", "." ]
python
train
26.666667
bwohlberg/sporco
sporco/cupy/__init__.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cupy/__init__.py#L202-L211
def _complex_dtype(dtype): """Patched version of :func:`sporco.linalg.complex_dtype`.""" dt = cp.dtype(dtype) if dt == cp.dtype('float128'): return cp.dtype('complex256') elif dt == cp.dtype('float64'): return cp.dtype('complex128') else: return cp.dtype('complex64')
[ "def", "_complex_dtype", "(", "dtype", ")", ":", "dt", "=", "cp", ".", "dtype", "(", "dtype", ")", "if", "dt", "==", "cp", ".", "dtype", "(", "'float128'", ")", ":", "return", "cp", ".", "dtype", "(", "'complex256'", ")", "elif", "dt", "==", "cp", ...
Patched version of :func:`sporco.linalg.complex_dtype`.
[ "Patched", "version", "of", ":", "func", ":", "sporco", ".", "linalg", ".", "complex_dtype", "." ]
python
train
30.3
JarryShaw/PyPCAPKit
src/toolkit/scapy.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/scapy.py#L119-L144
def tcp_reassembly(packet, *, count=NotImplemented): """Store data for TCP reassembly.""" if 'TCP' in packet: ip = packet['IP'] if 'IP' in packet else packet['IPv6'] tcp = packet['TCP'] data = dict( bufid=( ipaddress.ip_address(ip.src), # source IP addre...
[ "def", "tcp_reassembly", "(", "packet", ",", "*", ",", "count", "=", "NotImplemented", ")", ":", "if", "'TCP'", "in", "packet", ":", "ip", "=", "packet", "[", "'IP'", "]", "if", "'IP'", "in", "packet", "else", "packet", "[", "'IPv6'", "]", "tcp", "="...
Store data for TCP reassembly.
[ "Store", "data", "for", "TCP", "reassembly", "." ]
python
train
55.307692
JamesPHoughton/pysd
pysd/py_backend/functions.py
https://github.com/JamesPHoughton/pysd/blob/bf1b1d03954e9ba5acac9ba4f1ada7cd93352eda/pysd/py_backend/functions.py#L803-L837
def ramp(time, slope, start, finish=0): """ Implements vensim's and xmile's RAMP function Parameters ---------- time: function The current time of modelling slope: float The slope of the ramp starting at zero at time start start: float Time at which the ramp begins ...
[ "def", "ramp", "(", "time", ",", "slope", ",", "start", ",", "finish", "=", "0", ")", ":", "t", "=", "time", "(", ")", "if", "t", "<", "start", ":", "return", "0", "else", ":", "if", "finish", "<=", "0", ":", "return", "slope", "*", "(", "t",...
Implements vensim's and xmile's RAMP function Parameters ---------- time: function The current time of modelling slope: float The slope of the ramp starting at zero at time start start: float Time at which the ramp begins finish: float Optional. Time at which the...
[ "Implements", "vensim", "s", "and", "xmile", "s", "RAMP", "function" ]
python
train
21.914286
rlisagor/pynetlinux
pynetlinux/brctl.py
https://github.com/rlisagor/pynetlinux/blob/e3f16978855c6649685f0c43d4c3fcf768427ae5/pynetlinux/brctl.py#L113-L116
def addbr(name): ''' Create new bridge with the given name ''' fcntl.ioctl(ifconfig.sockfd, SIOCBRADDBR, name) return Bridge(name)
[ "def", "addbr", "(", "name", ")", ":", "fcntl", ".", "ioctl", "(", "ifconfig", ".", "sockfd", ",", "SIOCBRADDBR", ",", "name", ")", "return", "Bridge", "(", "name", ")" ]
Create new bridge with the given name
[ "Create", "new", "bridge", "with", "the", "given", "name" ]
python
train
34.75
saltstack/salt
salt/modules/boto_ec2.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_ec2.py#L2079-L2107
def attach_volume(volume_id, instance_id, device, region=None, key=None, keyid=None, profile=None): ''' Attach an EBS volume to an EC2 instance. .. volume_id (string) – The ID of the EBS volume to be attached. instance_id (string) – The ID of the EC2 instance to at...
[ "def", "attach_volume", "(", "volume_id", ",", "instance_id", ",", "device", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ...
Attach an EBS volume to an EC2 instance. .. volume_id (string) – The ID of the EBS volume to be attached. instance_id (string) – The ID of the EC2 instance to attach the volume to. device (string) – The device on the instance through which the volume is exposed (e.g. /dev/sdh) ...
[ "Attach", "an", "EBS", "volume", "to", "an", "EC2", "instance", ".", ".." ]
python
train
29.689655
pandas-dev/pandas
pandas/io/html.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/html.py#L921-L1088
def read_html(io, match='.+', flavor=None, header=None, index_col=None, skiprows=None, attrs=None, parse_dates=False, tupleize_cols=None, thousands=',', encoding=None, decimal='.', converters=None, na_values=None, keep_default_na=True, displayed_only=True): r"...
[ "def", "read_html", "(", "io", ",", "match", "=", "'.+'", ",", "flavor", "=", "None", ",", "header", "=", "None", ",", "index_col", "=", "None", ",", "skiprows", "=", "None", ",", "attrs", "=", "None", ",", "parse_dates", "=", "False", ",", "tupleize...
r"""Read HTML tables into a ``list`` of ``DataFrame`` objects. Parameters ---------- io : str or file-like A URL, a file-like object, or a raw string containing HTML. Note that lxml only accepts the http, ftp and file url protocols. If you have a URL that starts with ``'https'`` you...
[ "r", "Read", "HTML", "tables", "into", "a", "list", "of", "DataFrame", "objects", "." ]
python
train
42.857143
PyGithub/PyGithub
github/Repository.py
https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/Repository.py#L1505-L1518
def get_top_referrers(self): """ :calls: `GET /repos/:owner/:repo/traffic/popular/referrers <https://developer.github.com/v3/repos/traffic/>`_ :rtype: :class:`list` of :class:`github.Referrer.Referrer` """ headers, data = self._requester.requestJsonAndCheck( "GET", ...
[ "def", "get_top_referrers", "(", "self", ")", ":", "headers", ",", "data", "=", "self", ".", "_requester", ".", "requestJsonAndCheck", "(", "\"GET\"", ",", "self", ".", "url", "+", "\"/traffic/popular/referrers\"", ")", "if", "isinstance", "(", "data", ",", ...
:calls: `GET /repos/:owner/:repo/traffic/popular/referrers <https://developer.github.com/v3/repos/traffic/>`_ :rtype: :class:`list` of :class:`github.Referrer.Referrer`
[ ":", "calls", ":", "GET", "/", "repos", "/", ":", "owner", "/", ":", "repo", "/", "traffic", "/", "popular", "/", "referrers", "<https", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "repos", "/", "traffic", "/", ">", "_", ":...
python
train
39.857143
consbio/parserutils
parserutils/elements.py
https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/elements.py#L981-L992
def strip_xml_declaration(file_or_xml): """ Removes XML declaration line from file or string passed in. If file_or_xml is not a file or string, it is returned as is. """ xml_content = _xml_content_to_string(file_or_xml) if not isinstance(xml_content, string_types): return xml_content ...
[ "def", "strip_xml_declaration", "(", "file_or_xml", ")", ":", "xml_content", "=", "_xml_content_to_string", "(", "file_or_xml", ")", "if", "not", "isinstance", "(", "xml_content", ",", "string_types", ")", ":", "return", "xml_content", "# For Python 2 compliance: replac...
Removes XML declaration line from file or string passed in. If file_or_xml is not a file or string, it is returned as is.
[ "Removes", "XML", "declaration", "line", "from", "file", "or", "string", "passed", "in", ".", "If", "file_or_xml", "is", "not", "a", "file", "or", "string", "it", "is", "returned", "as", "is", "." ]
python
train
37.083333
azavea/python-omgeo
omgeo/postprocessors.py
https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/postprocessors.py#L140-L150
def process(self, candidates): """ :arg list candidates: list of Candidates :returns: list of Candidates where score is at least min_score, if and only if one or more Candidates have at least min_score. Otherwise, returns original list of Candidates. "...
[ "def", "process", "(", "self", ",", "candidates", ")", ":", "high_score_candidates", "=", "[", "c", "for", "c", "in", "candidates", "if", "c", ".", "score", ">=", "self", ".", "min_score", "]", "if", "high_score_candidates", "!=", "[", "]", ":", "return"...
:arg list candidates: list of Candidates :returns: list of Candidates where score is at least min_score, if and only if one or more Candidates have at least min_score. Otherwise, returns original list of Candidates.
[ ":", "arg", "list", "candidates", ":", "list", "of", "Candidates", ":", "returns", ":", "list", "of", "Candidates", "where", "score", "is", "at", "least", "min_score", "if", "and", "only", "if", "one", "or", "more", "Candidates", "have", "at", "least", "...
python
train
45.818182
tensorlayer/tensorlayer
tensorlayer/files/utils.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/files/utils.py#L1722-L1750
def save_npz_dict(save_list=None, name='model.npz', sess=None): """Input parameters and the file name, save parameters as a dictionary into .npz file. Use ``tl.files.load_and_assign_npz_dict()`` to restore. Parameters ---------- save_list : list of parameters A list of parameters (tensor) ...
[ "def", "save_npz_dict", "(", "save_list", "=", "None", ",", "name", "=", "'model.npz'", ",", "sess", "=", "None", ")", ":", "if", "sess", "is", "None", ":", "raise", "ValueError", "(", "\"session is None.\"", ")", "if", "save_list", "is", "None", ":", "s...
Input parameters and the file name, save parameters as a dictionary into .npz file. Use ``tl.files.load_and_assign_npz_dict()`` to restore. Parameters ---------- save_list : list of parameters A list of parameters (tensor) to be saved. name : str The name of the `.npz` file. se...
[ "Input", "parameters", "and", "the", "file", "name", "save", "parameters", "as", "a", "dictionary", "into", ".", "npz", "file", "." ]
python
valid
31.206897
enkore/i3pystatus
i3pystatus/weather/wunderground.py
https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/weather/wunderground.py#L195-L289
def check_weather(self): ''' Query the configured/queried station and return the weather data ''' if self.station_id is None: # Failed to get the nearest station ID when first launched, so # retry it. self.get_station_id() self.data['update_er...
[ "def", "check_weather", "(", "self", ")", ":", "if", "self", ".", "station_id", "is", "None", ":", "# Failed to get the nearest station ID when first launched, so", "# retry it.", "self", ".", "get_station_id", "(", ")", "self", ".", "data", "[", "'update_error'", "...
Query the configured/queried station and return the weather data
[ "Query", "the", "configured", "/", "queried", "station", "and", "return", "the", "weather", "data" ]
python
train
45.557895
cloud9ers/gurumate
environment/lib/python2.7/site-packages/gurumate-2.8.6-py2.7.egg/gurumate/web.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/gurumate-2.8.6-py2.7.egg/gurumate/web.py#L5-L18
def check_url_accessibility(url, timeout=10): ''' Check whether the URL accessible and returns HTTP 200 OK or not if not raises ValidationError ''' if(url=='localhost'): url = 'http://127.0.0.1' try: req = urllib2.urlopen(url, timeout=timeout) if (req.getcode()==20...
[ "def", "check_url_accessibility", "(", "url", ",", "timeout", "=", "10", ")", ":", "if", "(", "url", "==", "'localhost'", ")", ":", "url", "=", "'http://127.0.0.1'", "try", ":", "req", "=", "urllib2", ".", "urlopen", "(", "url", ",", "timeout", "=", "t...
Check whether the URL accessible and returns HTTP 200 OK or not if not raises ValidationError
[ "Check", "whether", "the", "URL", "accessible", "and", "returns", "HTTP", "200", "OK", "or", "not", "if", "not", "raises", "ValidationError" ]
python
test
30.857143
cs01/gdbgui
gdbgui/SSLify.py
https://github.com/cs01/gdbgui/blob/5367f87554f8f7c671d1f4596c133bf1303154f0/gdbgui/SSLify.py#L90-L104
def get_ssl_context(private_key, certificate): """Get ssl context from private key and certificate paths. The return value is used when calling Flask. i.e. app.run(ssl_context=get_ssl_context(,,,)) """ if ( certificate and os.path.isfile(certificate) and private_key a...
[ "def", "get_ssl_context", "(", "private_key", ",", "certificate", ")", ":", "if", "(", "certificate", "and", "os", ".", "path", ".", "isfile", "(", "certificate", ")", "and", "private_key", "and", "os", ".", "path", ".", "isfile", "(", "private_key", ")", ...
Get ssl context from private key and certificate paths. The return value is used when calling Flask. i.e. app.run(ssl_context=get_ssl_context(,,,))
[ "Get", "ssl", "context", "from", "private", "key", "and", "certificate", "paths", ".", "The", "return", "value", "is", "used", "when", "calling", "Flask", ".", "i", ".", "e", ".", "app", ".", "run", "(", "ssl_context", "=", "get_ssl_context", "(", "))" ]
python
train
33
penguinmenac3/starttf
starttf/utils/misc.py
https://github.com/penguinmenac3/starttf/blob/f4086489d169757c0504e822165db2fea534b944/starttf/utils/misc.py#L32-L44
def mode_to_str(mode): """ Converts a tf.estimator.ModeKeys in a nice readable string. :param mode: The mdoe as a tf.estimator.ModeKeys :return: A human readable string representing the mode. """ if mode == tf.estimator.ModeKeys.TRAIN: return "train" if mode == tf.estimator.ModeKeys....
[ "def", "mode_to_str", "(", "mode", ")", ":", "if", "mode", "==", "tf", ".", "estimator", ".", "ModeKeys", ".", "TRAIN", ":", "return", "\"train\"", "if", "mode", "==", "tf", ".", "estimator", ".", "ModeKeys", ".", "EVAL", ":", "return", "\"eval\"", "if...
Converts a tf.estimator.ModeKeys in a nice readable string. :param mode: The mdoe as a tf.estimator.ModeKeys :return: A human readable string representing the mode.
[ "Converts", "a", "tf", ".", "estimator", ".", "ModeKeys", "in", "a", "nice", "readable", "string", ".", ":", "param", "mode", ":", "The", "mdoe", "as", "a", "tf", ".", "estimator", ".", "ModeKeys", ":", "return", ":", "A", "human", "readable", "string"...
python
train
32.846154
saltstack/salt
salt/utils/openstack/nova.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L721-L727
def suspend(self, instance_id): ''' Suspend a server ''' nt_ks = self.compute_conn response = nt_ks.servers.suspend(instance_id) return True
[ "def", "suspend", "(", "self", ",", "instance_id", ")", ":", "nt_ks", "=", "self", ".", "compute_conn", "response", "=", "nt_ks", ".", "servers", ".", "suspend", "(", "instance_id", ")", "return", "True" ]
Suspend a server
[ "Suspend", "a", "server" ]
python
train
26
ojarva/python-sshpubkeys
sshpubkeys/keys.py
https://github.com/ojarva/python-sshpubkeys/blob/86dc1ab27ce82dcc091ce127416cc3ee219e9bec/sshpubkeys/keys.py#L297-L322
def _process_ssh_rsa(self, data): """Parses ssh-rsa public keys.""" current_position, raw_e = self._unpack_by_int(data, 0) current_position, raw_n = self._unpack_by_int(data, current_position) unpacked_e = self._parse_long(raw_e) unpacked_n = self._parse_long(raw_n) sel...
[ "def", "_process_ssh_rsa", "(", "self", ",", "data", ")", ":", "current_position", ",", "raw_e", "=", "self", ".", "_unpack_by_int", "(", "data", ",", "0", ")", "current_position", ",", "raw_n", "=", "self", ".", "_unpack_by_int", "(", "data", ",", "curren...
Parses ssh-rsa public keys.
[ "Parses", "ssh", "-", "rsa", "public", "keys", "." ]
python
test
41.730769
huggingface/pytorch-pretrained-BERT
pytorch_pretrained_bert/tokenization.py
https://github.com/huggingface/pytorch-pretrained-BERT/blob/b832d5bb8a6dfc5965015b828e577677eace601e/pytorch_pretrained_bert/tokenization.py#L117-L128
def convert_tokens_to_ids(self, tokens): """Converts a sequence of tokens into ids using the vocab.""" ids = [] for token in tokens: ids.append(self.vocab[token]) if len(ids) > self.max_len: logger.warning( "Token indices sequence length is longer ...
[ "def", "convert_tokens_to_ids", "(", "self", ",", "tokens", ")", ":", "ids", "=", "[", "]", "for", "token", "in", "tokens", ":", "ids", ".", "append", "(", "self", ".", "vocab", "[", "token", "]", ")", "if", "len", "(", "ids", ")", ">", "self", "...
Converts a sequence of tokens into ids using the vocab.
[ "Converts", "a", "sequence", "of", "tokens", "into", "ids", "using", "the", "vocab", "." ]
python
train
46
pgxcentre/geneparse
geneparse/utils.py
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L45-L51
def flip_alleles(genotypes): """Flip the alleles of an Genotypes instance.""" warnings.warn("deprecated: use 'Genotypes.flip_coded'", DeprecationWarning) genotypes.reference, genotypes.coded = (genotypes.coded, genotypes.reference) genotypes.genotypes = 2 - ge...
[ "def", "flip_alleles", "(", "genotypes", ")", ":", "warnings", ".", "warn", "(", "\"deprecated: use 'Genotypes.flip_coded'\"", ",", "DeprecationWarning", ")", "genotypes", ".", "reference", ",", "genotypes", ".", "coded", "=", "(", "genotypes", ".", "coded", ",", ...
Flip the alleles of an Genotypes instance.
[ "Flip", "the", "alleles", "of", "an", "Genotypes", "instance", "." ]
python
train
50.285714
minus7/asif
asif/bot.py
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L450-L457
def _bg(self, coro: coroutine) -> asyncio.Task: """Run coro in background, log errors""" async def runner(): try: await coro except: self._log.exception("async: Coroutine raised exception") return asyncio.ensure_future(runner())
[ "def", "_bg", "(", "self", ",", "coro", ":", "coroutine", ")", "->", "asyncio", ".", "Task", ":", "async", "def", "runner", "(", ")", ":", "try", ":", "await", "coro", "except", ":", "self", ".", "_log", ".", "exception", "(", "\"async: Coroutine raise...
Run coro in background, log errors
[ "Run", "coro", "in", "background", "log", "errors" ]
python
train
37.625
OSSOS/MOP
src/ossos/core/ossos/match.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/match.py#L90-L266
def match_planted(fk_candidate_observations, match_filename, bright_limit=BRIGHT_LIMIT, object_planted=OBJECT_PLANTED, minimum_bright_detections=MINIMUM_BRIGHT_DETECTIONS, bright_fraction=MINIMUM_BRIGHT_FRACTION): """ Using the fk_candidate_observations as input get the Object.planted file fro...
[ "def", "match_planted", "(", "fk_candidate_observations", ",", "match_filename", ",", "bright_limit", "=", "BRIGHT_LIMIT", ",", "object_planted", "=", "OBJECT_PLANTED", ",", "minimum_bright_detections", "=", "MINIMUM_BRIGHT_DETECTIONS", ",", "bright_fraction", "=", "MINIMUM...
Using the fk_candidate_observations as input get the Object.planted file from VOSpace and match planted sources with found sources. The Object.planted list is pulled from VOSpace based on the standard file-layout and name of the first exposure as read from the .astrom file. :param fk_candidate_observa...
[ "Using", "the", "fk_candidate_observations", "as", "input", "get", "the", "Object", ".", "planted", "file", "from", "VOSpace", "and", "match", "planted", "sources", "with", "found", "sources", "." ]
python
train
53.231638
fastai/fastai
fastai/data_block.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/data_block.py#L532-L543
def databunch(self, path:PathOrStr=None, bs:int=64, val_bs:int=None, num_workers:int=defaults.cpus, dl_tfms:Optional[Collection[Callable]]=None, device:torch.device=None, collate_fn:Callable=data_collate, no_check:bool=False, **kwargs)->'DataBunch': "Create an `DataBunch` fro...
[ "def", "databunch", "(", "self", ",", "path", ":", "PathOrStr", "=", "None", ",", "bs", ":", "int", "=", "64", ",", "val_bs", ":", "int", "=", "None", ",", "num_workers", ":", "int", "=", "defaults", ".", "cpus", ",", "dl_tfms", ":", "Optional", "[...
Create an `DataBunch` from self, `path` will override `self.path`, `kwargs` are passed to `DataBunch.create`.
[ "Create", "an", "DataBunch", "from", "self", "path", "will", "override", "self", ".", "path", "kwargs", "are", "passed", "to", "DataBunch", ".", "create", "." ]
python
train
78.583333
RobotStudio/bors
bors/app/config.py
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/config.py#L84-L92
def get_api_service(self, name=None): """Returns the specific service config definition""" try: svc = self.services_by_name.get(name, None) if svc is None: raise ValueError(f"Couldn't find the API service configuration") return svc except: # N...
[ "def", "get_api_service", "(", "self", ",", "name", "=", "None", ")", ":", "try", ":", "svc", "=", "self", ".", "services_by_name", ".", "get", "(", "name", ",", "None", ")", "if", "svc", "is", "None", ":", "raise", "ValueError", "(", "f\"Couldn't find...
Returns the specific service config definition
[ "Returns", "the", "specific", "service", "config", "definition" ]
python
train
44
jbeluch/xbmcswift2
xbmcswift2/urls.py
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/urls.py#L100-L119
def _make_path(self, items): '''Returns a relative path for the given dictionary of items. Uses this url rule's url pattern and replaces instances of <var_name> with the appropriate value from the items dict. ''' for key, val in items.items(): if not isinstance(val, ...
[ "def", "_make_path", "(", "self", ",", "items", ")", ":", "for", "key", ",", "val", "in", "items", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "val", ",", "basestring", ")", ":", "raise", "TypeError", ",", "(", "'Value \"%s\" for key \...
Returns a relative path for the given dictionary of items. Uses this url rule's url pattern and replaces instances of <var_name> with the appropriate value from the items dict.
[ "Returns", "a", "relative", "path", "for", "the", "given", "dictionary", "of", "items", "." ]
python
train
39.3
instaloader/instaloader
instaloader/instaloadercontext.py
https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L398-L433
def graphql_query(self, query_hash: str, variables: Dict[str, Any], referer: Optional[str] = None, rhx_gis: Optional[str] = None) -> Dict[str, Any]: """ Do a GraphQL Query. :param query_hash: Query identifying hash. :param variables: Variables for the Query. ...
[ "def", "graphql_query", "(", "self", ",", "query_hash", ":", "str", ",", "variables", ":", "Dict", "[", "str", ",", "Any", "]", ",", "referer", ":", "Optional", "[", "str", "]", "=", "None", ",", "rhx_gis", ":", "Optional", "[", "str", "]", "=", "N...
Do a GraphQL Query. :param query_hash: Query identifying hash. :param variables: Variables for the Query. :param referer: HTTP Referer, or None. :param rhx_gis: 'rhx_gis' variable as somewhere returned by Instagram, needed to 'sign' request :return: The server's response diction...
[ "Do", "a", "GraphQL", "Query", "." ]
python
train
50.444444
spyder-ide/spyder
spyder/plugins/plots/widgets/figurebrowser.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/plots/widgets/figurebrowser.py#L597-L601
def save_current_figure_as(self): """Save the currently selected figure.""" if self.current_thumbnail is not None: self.save_figure_as(self.current_thumbnail.canvas.fig, self.current_thumbnail.canvas.fmt)
[ "def", "save_current_figure_as", "(", "self", ")", ":", "if", "self", ".", "current_thumbnail", "is", "not", "None", ":", "self", ".", "save_figure_as", "(", "self", ".", "current_thumbnail", ".", "canvas", ".", "fig", ",", "self", ".", "current_thumbnail", ...
Save the currently selected figure.
[ "Save", "the", "currently", "selected", "figure", "." ]
python
train
52
ThreatConnect-Inc/tcex
tcex/tcex_ti_indicator.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti_indicator.py#L150-L190
def attribute( self, attr_type, attr_value, displayed=False, source=None, unique=True, formatter=None ): """Return instance of Attribute unique: * False - Attribute type:value can be duplicated. * Type - Attribute type has to be unique (e.g., only 1 Description Attri...
[ "def", "attribute", "(", "self", ",", "attr_type", ",", "attr_value", ",", "displayed", "=", "False", ",", "source", "=", "None", ",", "unique", "=", "True", ",", "formatter", "=", "None", ")", ":", "attr", "=", "Attribute", "(", "attr_type", ",", "att...
Return instance of Attribute unique: * False - Attribute type:value can be duplicated. * Type - Attribute type has to be unique (e.g., only 1 Description Attribute). * True - Attribute type:value combo must be unique. Args: attr_type (str): The ThreatCon...
[ "Return", "instance", "of", "Attribute" ]
python
train
41.878049
tmr232/Sark
sark/enum.py
https://github.com/tmr232/Sark/blob/bee62879c2aea553a3924d887e2b30f2a6008581/sark/enum.py#L141-L149
def add(self, name, value, bitmask=DEFMASK): """Add an enum member Args: name: Name of the member value: value of the member bitmask: bitmask. Only use if enum is a bitfield. """ _add_enum_member(self._eid, name, value, bitmask)
[ "def", "add", "(", "self", ",", "name", ",", "value", ",", "bitmask", "=", "DEFMASK", ")", ":", "_add_enum_member", "(", "self", ".", "_eid", ",", "name", ",", "value", ",", "bitmask", ")" ]
Add an enum member Args: name: Name of the member value: value of the member bitmask: bitmask. Only use if enum is a bitfield.
[ "Add", "an", "enum", "member" ]
python
train
32.111111
inasafe/inasafe
safe/gui/tools/wizard/utilities.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/utilities.py#L60-L79
def layers_intersect(layer_a, layer_b): """Check if extents of two layers intersect. :param layer_a: One of the two layers to test overlapping :type layer_a: QgsMapLayer :param layer_b: The second of the two layers to test overlapping :type layer_b: QgsMapLayer :returns: true if the layers in...
[ "def", "layers_intersect", "(", "layer_a", ",", "layer_b", ")", ":", "extent_a", "=", "layer_a", ".", "extent", "(", ")", "extent_b", "=", "layer_b", ".", "extent", "(", ")", "if", "layer_a", ".", "crs", "(", ")", "!=", "layer_b", ".", "crs", "(", ")...
Check if extents of two layers intersect. :param layer_a: One of the two layers to test overlapping :type layer_a: QgsMapLayer :param layer_b: The second of the two layers to test overlapping :type layer_b: QgsMapLayer :returns: true if the layers intersect, false if they are disjoint :rtype:...
[ "Check", "if", "extents", "of", "two", "layers", "intersect", "." ]
python
train
36.7
crunchyroll/ef-open
efopen/ef_context.py
https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_context.py#L106-L114
def service_registry(self, sr): """ Sets service registry object in context, doesn't check it Args: sr: EFServiceRegistry object """ if type(sr) is not EFServiceRegistry: raise TypeError("sr value must be type 'EFServiceRegistry'") self._service_registry = sr
[ "def", "service_registry", "(", "self", ",", "sr", ")", ":", "if", "type", "(", "sr", ")", "is", "not", "EFServiceRegistry", ":", "raise", "TypeError", "(", "\"sr value must be type 'EFServiceRegistry'\"", ")", "self", ".", "_service_registry", "=", "sr" ]
Sets service registry object in context, doesn't check it Args: sr: EFServiceRegistry object
[ "Sets", "service", "registry", "object", "in", "context", "doesn", "t", "check", "it", "Args", ":", "sr", ":", "EFServiceRegistry", "object" ]
python
train
31.888889
pdkit/pdkit
pdkit/utils.py
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/utils.py#L464-L511
def butter_lowpass_filter(data, sample_rate, cutoff=10, order=4, plot=False): """ `Low-pass filter <http://stackoverflow.com/questions/25191620/ creating-lowpass-filter-in-scipy-understanding-methods-and-units>`_ data by the [order]th order zero lag Butterworth filter whose cut frequency is ...
[ "def", "butter_lowpass_filter", "(", "data", ",", "sample_rate", ",", "cutoff", "=", "10", ",", "order", "=", "4", ",", "plot", "=", "False", ")", ":", "nyquist", "=", "0.5", "*", "sample_rate", "normal_cutoff", "=", "cutoff", "/", "nyquist", "b", ",", ...
`Low-pass filter <http://stackoverflow.com/questions/25191620/ creating-lowpass-filter-in-scipy-understanding-methods-and-units>`_ data by the [order]th order zero lag Butterworth filter whose cut frequency is set to [cutoff] Hz. :param data: time-series data, :type data: numpy array of...
[ "Low", "-", "pass", "filter", "<http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "25191620", "/", "creating", "-", "lowpass", "-", "filter", "-", "in", "-", "scipy", "-", "understanding", "-", "methods", "-", "and", "-", "units", "...
python
train
31.75
trevisanj/f311
f311/hapi.py
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/hapi.py#L5245-L5273
def fetch(TableName,M,I,numin,numax,ParameterGroups=[],Parameters=[]): """ INPUT PARAMETERS: TableName: local table name to fetch in (required) M: HITRAN molecule number (required) I: HITRAN isotopologue number (required) numin: lower wavenumb...
[ "def", "fetch", "(", "TableName", ",", "M", ",", "I", ",", "numin", ",", "numax", ",", "ParameterGroups", "=", "[", "]", ",", "Parameters", "=", "[", "]", ")", ":", "queryHITRAN", "(", "TableName", ",", "[", "ISO", "[", "(", "M", ",", "I", ")", ...
INPUT PARAMETERS: TableName: local table name to fetch in (required) M: HITRAN molecule number (required) I: HITRAN isotopologue number (required) numin: lower wavenumber bound (required) numax: upper wavenumber bound (requir...
[ "INPUT", "PARAMETERS", ":", "TableName", ":", "local", "table", "name", "to", "fetch", "in", "(", "required", ")", "M", ":", "HITRAN", "molecule", "number", "(", "required", ")", "I", ":", "HITRAN", "isotopologue", "number", "(", "required", ")", "numin", ...
python
train
41.172414
pantsbuild/pants
src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py#L777-L791
def _create_context_jar(self, compile_context): """Jar up the compile_context to its output jar location. TODO(stuhood): In the medium term, we hope to add compiler support for this step, which would allow the jars to be used as compile _inputs_ as well. Currently using jar'd compile outputs as compile...
[ "def", "_create_context_jar", "(", "self", ",", "compile_context", ")", ":", "root", "=", "compile_context", ".", "classes_dir", ".", "path", "with", "compile_context", ".", "open_jar", "(", "mode", "=", "'w'", ")", "as", "jar", ":", "for", "abs_sub_dir", ",...
Jar up the compile_context to its output jar location. TODO(stuhood): In the medium term, we hope to add compiler support for this step, which would allow the jars to be used as compile _inputs_ as well. Currently using jar'd compile outputs as compile inputs would make the compiler's analysis useless. ...
[ "Jar", "up", "the", "compile_context", "to", "its", "output", "jar", "location", "." ]
python
train
52.733333
mapbox/mapbox-sdk-py
mapbox/services/maps.py
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L180-L192
def _validate_color(self, color): """Validates color, raising error if invalid.""" three_digit_pattern = compile("^[a-f0-9]{3}$") six_digit_pattern = compile("^[a-f0-9]{6}$") if not match(three_digit_pattern, color)\ and not match(six_digit_pattern, color): ...
[ "def", "_validate_color", "(", "self", ",", "color", ")", ":", "three_digit_pattern", "=", "compile", "(", "\"^[a-f0-9]{3}$\"", ")", "six_digit_pattern", "=", "compile", "(", "\"^[a-f0-9]{6}$\"", ")", "if", "not", "match", "(", "three_digit_pattern", ",", "color",...
Validates color, raising error if invalid.
[ "Validates", "color", "raising", "error", "if", "invalid", "." ]
python
train
33.230769
spyder-ide/spyder
spyder/utils/misc.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/misc.py#L96-L131
def count_lines(path, extensions=None, excluded_dirnames=None): """Return number of source code lines for all filenames in subdirectories of *path* with names ending with *extensions* Directory names *excluded_dirnames* will be ignored""" if extensions is None: extensions = ['.py', '.pyw', ...
[ "def", "count_lines", "(", "path", ",", "extensions", "=", "None", ",", "excluded_dirnames", "=", "None", ")", ":", "if", "extensions", "is", "None", ":", "extensions", "=", "[", "'.py'", ",", "'.pyw'", ",", "'.ipy'", ",", "'.enaml'", ",", "'.c'", ",", ...
Return number of source code lines for all filenames in subdirectories of *path* with names ending with *extensions* Directory names *excluded_dirnames* will be ignored
[ "Return", "number", "of", "source", "code", "lines", "for", "all", "filenames", "in", "subdirectories", "of", "*", "path", "*", "with", "names", "ending", "with", "*", "extensions", "*", "Directory", "names", "*", "excluded_dirnames", "*", "will", "be", "ign...
python
train
43.277778
keon/algorithms
algorithms/dp/longest_increasing.py
https://github.com/keon/algorithms/blob/4d6569464a62a75c1357acc97e2dd32ee2f9f4a3/algorithms/dp/longest_increasing.py#L13-L26
def longest_increasing_subsequence(sequence): """ Dynamic Programming Algorithm for counting the length of longest increasing subsequence type sequence: List[int] """ length = len(sequence) counts = [1 for _ in range(length)] for i in range(1, length): for j in range(0, i): ...
[ "def", "longest_increasing_subsequence", "(", "sequence", ")", ":", "length", "=", "len", "(", "sequence", ")", "counts", "=", "[", "1", "for", "_", "in", "range", "(", "length", ")", "]", "for", "i", "in", "range", "(", "1", ",", "length", ")", ":",...
Dynamic Programming Algorithm for counting the length of longest increasing subsequence type sequence: List[int]
[ "Dynamic", "Programming", "Algorithm", "for", "counting", "the", "length", "of", "longest", "increasing", "subsequence", "type", "sequence", ":", "List", "[", "int", "]" ]
python
train
32.428571
pmacosta/peng
peng/wave_functions.py
https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/wave_functions.py#L1473-L1507
def naverage(wave, indep_min=None, indep_max=None): r""" Return the numerical average of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param indep_min: Independent vector start point of computation :type indep_min: integer or float ...
[ "def", "naverage", "(", "wave", ",", "indep_min", "=", "None", ",", "indep_max", "=", "None", ")", ":", "ret", "=", "copy", ".", "copy", "(", "wave", ")", "_bound_waveform", "(", "ret", ",", "indep_min", ",", "indep_max", ")", "delta_x", "=", "ret", ...
r""" Return the numerical average of a waveform's dependent variable vector. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param indep_min: Independent vector start point of computation :type indep_min: integer or float :param indep_max: Independent vector stop point of c...
[ "r", "Return", "the", "numerical", "average", "of", "a", "waveform", "s", "dependent", "variable", "vector", "." ]
python
test
31.028571
DAI-Lab/Copulas
copulas/multivariate/tree.py
https://github.com/DAI-Lab/Copulas/blob/821df61c3d36a6b81ef2883935f935c2eaaa862c/copulas/multivariate/tree.py#L480-L500
def _identify_eds_ing(first, second): """Find nodes connecting adjacent edges. Args: first(Edge): Edge object representing the first edge. second(Edge): Edge object representing the second edge. Returns: tuple[int, int, set[int]]: The first two values repres...
[ "def", "_identify_eds_ing", "(", "first", ",", "second", ")", ":", "A", "=", "set", "(", "[", "first", ".", "L", ",", "first", ".", "R", "]", ")", "A", ".", "update", "(", "first", ".", "D", ")", "B", "=", "set", "(", "[", "second", ".", "L",...
Find nodes connecting adjacent edges. Args: first(Edge): Edge object representing the first edge. second(Edge): Edge object representing the second edge. Returns: tuple[int, int, set[int]]: The first two values represent left and right node indicies ...
[ "Find", "nodes", "connecting", "adjacent", "edges", "." ]
python
train
31.333333
brocade/pynos
pynos/versions/base/yang/brocade_ras.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/brocade_ras.py#L137-L148
def logging_auditlog_clss_clss(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") logging = ET.SubElement(config, "logging", xmlns="urn:brocade.com:mgmt:brocade-ras") auditlog = ET.SubElement(logging, "auditlog") clss = ET.SubElement(auditlog, "clas...
[ "def", "logging_auditlog_clss_clss", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "logging", "=", "ET", ".", "SubElement", "(", "config", ",", "\"logging\"", ",", "xmlns", "=", "\"urn:brocade....
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
40.5
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/injector.py
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/injector.py#L661-L704
def save(self, refreshing=None, next_action=None, json_last_refresh=None, data_blob=None): """ save or update the component on the Ariane server cache :param refreshing: the new refreshing value - default None and ignored :param next_action: the new next action - default None and ignored...
[ "def", "save", "(", "self", ",", "refreshing", "=", "None", ",", "next_action", "=", "None", ",", "json_last_refresh", "=", "None", ",", "data_blob", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "\"InjectorCachedComponent.save\"", ")", "ret", "=", "...
save or update the component on the Ariane server cache :param refreshing: the new refreshing value - default None and ignored :param next_action: the new next action - default None and ignored :param json_last_refresh: the new json last refresh - default the date of this call :param dat...
[ "save", "or", "update", "the", "component", "on", "the", "Ariane", "server", "cache", ":", "param", "refreshing", ":", "the", "new", "refreshing", "value", "-", "default", "None", "and", "ignored", ":", "param", "next_action", ":", "the", "new", "next", "a...
python
train
46.75
yyuu/botornado
boto/gs/key.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/gs/key.py#L112-L221
def set_contents_from_file(self, fp, headers=None, replace=True, cb=None, num_cb=10, policy=None, md5=None, res_upload_handler=None, size=None): """ Store an object in GS using the name of the Key object as the key in GS and the conte...
[ "def", "set_contents_from_file", "(", "self", ",", "fp", ",", "headers", "=", "None", ",", "replace", "=", "True", ",", "cb", "=", "None", ",", "num_cb", "=", "10", ",", "policy", "=", "None", ",", "md5", "=", "None", ",", "res_upload_handler", "=", ...
Store an object in GS using the name of the Key object as the key in GS and the contents of the file pointed to by 'fp' as the contents. :type fp: file :param fp: the file whose contents are to be uploaded :type headers: dict :param headers: additional HTTP headers to b...
[ "Store", "an", "object", "in", "GS", "using", "the", "name", "of", "the", "Key", "object", "as", "the", "key", "in", "GS", "and", "the", "contents", "of", "the", "file", "pointed", "to", "by", "fp", "as", "the", "contents", "." ]
python
train
45.754545
exhuma/python-cluster
cluster/linkage.py
https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/linkage.py#L28-L43
def single(a, b, distance_function): """ Given two collections ``a`` and ``b``, this will return the distance of the points which are closest together. ``distance_function`` is used to determine the distance between two elements. Example:: >>> single([1, 2], [3, 4], lambda x, y: abs(x-y))...
[ "def", "single", "(", "a", ",", "b", ",", "distance_function", ")", ":", "left_a", ",", "right_a", "=", "min", "(", "a", ")", ",", "max", "(", "a", ")", "left_b", ",", "right_b", "=", "min", "(", "b", ")", ",", "max", "(", "b", ")", "result", ...
Given two collections ``a`` and ``b``, this will return the distance of the points which are closest together. ``distance_function`` is used to determine the distance between two elements. Example:: >>> single([1, 2], [3, 4], lambda x, y: abs(x-y)) 1 # (distance between 2 and 3)
[ "Given", "two", "collections", "a", "and", "b", "this", "will", "return", "the", "distance", "of", "the", "points", "which", "are", "closest", "together", ".", "distance_function", "is", "used", "to", "determine", "the", "distance", "between", "two", "elements...
python
train
34.4375
mbr/simplekv
simplekv/__init__.py
https://github.com/mbr/simplekv/blob/fc46ee0b8ca9b071d6699f3f0f18a8e599a5a2d6/simplekv/__init__.py#L400-L416
def put_file(self, key, file, ttl_secs=None): """Like :meth:`~simplekv.KeyValueStore.put_file`, but with an additional parameter: :param ttl_secs: Number of seconds until the key expires. See above for valid values. :raises exceptions.ValueError: If ...
[ "def", "put_file", "(", "self", ",", "key", ",", "file", ",", "ttl_secs", "=", "None", ")", ":", "if", "ttl_secs", "is", "None", ":", "ttl_secs", "=", "self", ".", "default_ttl_secs", "self", ".", "_check_valid_key", "(", "key", ")", "if", "isinstance", ...
Like :meth:`~simplekv.KeyValueStore.put_file`, but with an additional parameter: :param ttl_secs: Number of seconds until the key expires. See above for valid values. :raises exceptions.ValueError: If ``ttl_secs`` is invalid.
[ "Like", ":", "meth", ":", "~simplekv", ".", "KeyValueStore", ".", "put_file", "but", "with", "an", "additional", "parameter", ":" ]
python
train
38.058824
pedrotgn/pyactor
pyactor/context.py
https://github.com/pedrotgn/pyactor/blob/24d98d134dd4228f2ba38e83611e9c3f50ec2fd4/pyactor/context.py#L442-L465
def loads(self, param): ''' Checks the return parameters generating new proxy instances to avoid query concurrences from shared proxies and creating proxies for actors from another host. ''' if isinstance(param, ProxyRef): try: return self.look...
[ "def", "loads", "(", "self", ",", "param", ")", ":", "if", "isinstance", "(", "param", ",", "ProxyRef", ")", ":", "try", ":", "return", "self", ".", "lookup_url", "(", "param", ".", "url", ",", "param", ".", "klass", ",", "param", ".", "module", ")...
Checks the return parameters generating new proxy instances to avoid query concurrences from shared proxies and creating proxies for actors from another host.
[ "Checks", "the", "return", "parameters", "generating", "new", "proxy", "instances", "to", "avoid", "query", "concurrences", "from", "shared", "proxies", "and", "creating", "proxies", "for", "actors", "from", "another", "host", "." ]
python
train
41.125
rcsb/mmtf-python
mmtf/api/mmtf_writer.py
https://github.com/rcsb/mmtf-python/blob/899bb877ca1b32a9396803d38c5bf38a2520754e/mmtf/api/mmtf_writer.py#L209-L250
def encode_data(self): """Encode the data back into a dict.""" output_data = {} output_data["groupTypeList"] = encode_array(self.group_type_list, 4, 0) output_data["xCoordList"] = encode_array(self.x_coord_list, 10, 1000) output_data["yCoordList"] = encode_array(self.y_coord_list...
[ "def", "encode_data", "(", "self", ")", ":", "output_data", "=", "{", "}", "output_data", "[", "\"groupTypeList\"", "]", "=", "encode_array", "(", "self", ".", "group_type_list", ",", "4", ",", "0", ")", "output_data", "[", "\"xCoordList\"", "]", "=", "enc...
Encode the data back into a dict.
[ "Encode", "the", "data", "back", "into", "a", "dict", "." ]
python
train
59.785714
open511/open511
open511/converter/o5xml.py
https://github.com/open511/open511/blob/3d573f59d7efa06ff1b5419ea5ff4d90a90b3cf8/open511/converter/o5xml.py#L18-L41
def json_doc_to_xml(json_obj, lang='en', custom_namespace=None): """Converts a Open511 JSON document to XML. lang: the appropriate language code Takes a dict deserialized from JSON, returns an lxml Element. Accepts only the full root-level JSON object from an Open511 response.""" if 'meta' not in...
[ "def", "json_doc_to_xml", "(", "json_obj", ",", "lang", "=", "'en'", ",", "custom_namespace", "=", "None", ")", ":", "if", "'meta'", "not", "in", "json_obj", ":", "raise", "Exception", "(", "\"This function requires a conforming Open511 JSON document with a 'meta' secti...
Converts a Open511 JSON document to XML. lang: the appropriate language code Takes a dict deserialized from JSON, returns an lxml Element. Accepts only the full root-level JSON object from an Open511 response.
[ "Converts", "a", "Open511", "JSON", "document", "to", "XML", "." ]
python
valid
35.541667
sorgerlab/indra
indra/databases/cbio_client.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/cbio_client.py#L312-L347
def get_ccle_mutations(gene_list, cell_lines, mutation_type=None): """Return a dict of mutations in given genes and cell lines from CCLE. This is a specialized call to get_mutations tailored to CCLE cell lines. Parameters ---------- gene_list : list[str] A list of HGNC gene symbols to get ...
[ "def", "get_ccle_mutations", "(", "gene_list", ",", "cell_lines", ",", "mutation_type", "=", "None", ")", ":", "mutations", "=", "{", "cl", ":", "{", "g", ":", "[", "]", "for", "g", "in", "gene_list", "}", "for", "cl", "in", "cell_lines", "}", "for", ...
Return a dict of mutations in given genes and cell lines from CCLE. This is a specialized call to get_mutations tailored to CCLE cell lines. Parameters ---------- gene_list : list[str] A list of HGNC gene symbols to get mutations in cell_lines : list[str] A list of CCLE cell line n...
[ "Return", "a", "dict", "of", "mutations", "in", "given", "genes", "and", "cell", "lines", "from", "CCLE", "." ]
python
train
39.166667
dls-controls/pymalcolm
malcolm/core/models.py
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L189-L200
def create_attribute_model(self, initial_value=None): # type: (Any) -> AttributeModel """Make an AttributeModel instance of the correct type for this Meta Args: initial_value: The initial value the Attribute should take Returns: AttributeModel: The created attri...
[ "def", "create_attribute_model", "(", "self", ",", "initial_value", "=", "None", ")", ":", "# type: (Any) -> AttributeModel", "attr", "=", "self", ".", "attribute_class", "(", "meta", "=", "self", ",", "value", "=", "initial_value", ")", "return", "attr" ]
Make an AttributeModel instance of the correct type for this Meta Args: initial_value: The initial value the Attribute should take Returns: AttributeModel: The created attribute model instance
[ "Make", "an", "AttributeModel", "instance", "of", "the", "correct", "type", "for", "this", "Meta" ]
python
train
35.666667
Kozea/pygal
pygal/colors.py
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/colors.py#L66-L89
def hsl_to_rgb(h, s, l): """Convert a color in h, s, l to a color in r, g, b""" h /= 360 s /= 100 l /= 100 m2 = l * (s + 1) if l <= .5 else l + s - l * s m1 = 2 * l - m2 def h_to_rgb(h): h = h % 1 if 6 * h < 1: return m1 + 6 * h * (m2 - m1) if 2 * h < 1:...
[ "def", "hsl_to_rgb", "(", "h", ",", "s", ",", "l", ")", ":", "h", "/=", "360", "s", "/=", "100", "l", "/=", "100", "m2", "=", "l", "*", "(", "s", "+", "1", ")", "if", "l", "<=", ".5", "else", "l", "+", "s", "-", "l", "*", "s", "m1", "...
Convert a color in h, s, l to a color in r, g, b
[ "Convert", "a", "color", "in", "h", "s", "l", "to", "a", "color", "in", "r", "g", "b" ]
python
train
22.166667
CI-WATER/gsshapy
gsshapy/orm/cif.py
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/cif.py#L666-L713
def _createReservoir(self, linkResult, replaceParamFile): """ Create GSSHAPY Reservoir Objects Method """ # Extract header variables from link result object header = linkResult['header'] # Cases if linkResult['type'] == 'LAKE': # Lake handler ...
[ "def", "_createReservoir", "(", "self", ",", "linkResult", ",", "replaceParamFile", ")", ":", "# Extract header variables from link result object", "header", "=", "linkResult", "[", "'header'", "]", "# Cases", "if", "linkResult", "[", "'type'", "]", "==", "'LAKE'", ...
Create GSSHAPY Reservoir Objects Method
[ "Create", "GSSHAPY", "Reservoir", "Objects", "Method" ]
python
train
35.791667
gboeing/osmnx
osmnx/plot.py
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L37-L97
def plot_shape(gdf, fc='#cbe0f0', ec='#999999', linewidth=1, alpha=1, figsize=(6,6), margin=0.02, axis_off=True): """ Plot a GeoDataFrame of place boundary geometries. Parameters ---------- gdf : GeoDataFrame the gdf containing the geometries to plot fc : string or list ...
[ "def", "plot_shape", "(", "gdf", ",", "fc", "=", "'#cbe0f0'", ",", "ec", "=", "'#999999'", ",", "linewidth", "=", "1", ",", "alpha", "=", "1", ",", "figsize", "=", "(", "6", ",", "6", ")", ",", "margin", "=", "0.02", ",", "axis_off", "=", "True",...
Plot a GeoDataFrame of place boundary geometries. Parameters ---------- gdf : GeoDataFrame the gdf containing the geometries to plot fc : string or list the facecolor (or list of facecolors) for the polygons ec : string or list the edgecolor (or list of edgecolors) for the p...
[ "Plot", "a", "GeoDataFrame", "of", "place", "boundary", "geometries", "." ]
python
train
33.95082
ashim888/awis
myawis/__init__.py
https://github.com/ashim888/awis/blob/b8ed3437dedd7a9646c748474bfabcf2d6e2700b/myawis/__init__.py#L34-L92
def create_v4_signature(self, request_params): ''' Create URI and signature headers based on AWS V4 signing process. Refer to https://docs.aws.amazon.com/AlexaWebInfoService/latest/ApiReferenceArticle.html for request params. :param request_params: dictionary of request parameters ...
[ "def", "create_v4_signature", "(", "self", ",", "request_params", ")", ":", "method", "=", "'GET'", "service", "=", "'awis'", "host", "=", "'awis.us-west-1.amazonaws.com'", "region", "=", "'us-west-1'", "endpoint", "=", "'https://awis.amazonaws.com/api'", "request_param...
Create URI and signature headers based on AWS V4 signing process. Refer to https://docs.aws.amazon.com/AlexaWebInfoService/latest/ApiReferenceArticle.html for request params. :param request_params: dictionary of request parameters :return: URL and header to be passed to requests.get
[ "Create", "URI", "and", "signature", "headers", "based", "on", "AWS", "V4", "signing", "process", ".", "Refer", "to", "https", ":", "//", "docs", ".", "aws", ".", "amazon", ".", "com", "/", "AlexaWebInfoService", "/", "latest", "/", "ApiReferenceArticle", ...
python
train
50.813559
DataBiosphere/toil
src/toil/fileStore.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/fileStore.py#L887-L927
def _setupCache(self): """ Setup the cache based on the provided values for localCacheDir. """ # we first check whether the cache directory exists. If it doesn't, create it. if not os.path.exists(self.localCacheDir): # Create a temporary directory as this worker's pri...
[ "def", "_setupCache", "(", "self", ")", ":", "# we first check whether the cache directory exists. If it doesn't, create it.", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "localCacheDir", ")", ":", "# Create a temporary directory as this worker's private ...
Setup the cache based on the provided values for localCacheDir.
[ "Setup", "the", "cache", "based", "on", "the", "provided", "values", "for", "localCacheDir", "." ]
python
train
57.682927
saltstack/salt
salt/utils/doc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/doc.py#L16-L46
def strip_rst(docs): ''' Strip/replace reStructuredText directives in docstrings ''' for func, docstring in six.iteritems(docs): log.debug('Stripping docstring for %s', func) if not docstring: continue docstring_new = docstring if six.PY3 else salt.utils.data.encode(d...
[ "def", "strip_rst", "(", "docs", ")", ":", "for", "func", ",", "docstring", "in", "six", ".", "iteritems", "(", "docs", ")", ":", "log", ".", "debug", "(", "'Stripping docstring for %s'", ",", "func", ")", "if", "not", "docstring", ":", "continue", "docs...
Strip/replace reStructuredText directives in docstrings
[ "Strip", "/", "replace", "reStructuredText", "directives", "in", "docstrings" ]
python
train
39.580645
minhhoit/yacms
yacms/template/__init__.py
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/template/__init__.py#L51-L63
def render_tag(self, tag_func): """ Creates a tag using the decorated func as the render function for the template tag node. The render function takes two arguments - the template context and the tag token. """ @wraps(tag_func) def tag_wrapper(parser, token): ...
[ "def", "render_tag", "(", "self", ",", "tag_func", ")", ":", "@", "wraps", "(", "tag_func", ")", "def", "tag_wrapper", "(", "parser", ",", "token", ")", ":", "class", "RenderTagNode", "(", "template", ".", "Node", ")", ":", "def", "render", "(", "self"...
Creates a tag using the decorated func as the render function for the template tag node. The render function takes two arguments - the template context and the tag token.
[ "Creates", "a", "tag", "using", "the", "decorated", "func", "as", "the", "render", "function", "for", "the", "template", "tag", "node", ".", "The", "render", "function", "takes", "two", "arguments", "-", "the", "template", "context", "and", "the", "tag", "...
python
train
39.846154
CenturyLinkCloud/clc-python-sdk
src/clc/APIv2/server.py
https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/server.py#L271-L277
def PublicIPs(self): """Returns PublicIPs object associated with the server. """ if not self.public_ips: self.public_ips = clc.v2.PublicIPs(server=self,public_ips_lst=self.ip_addresses,session=self.session) return(self.public_ips)
[ "def", "PublicIPs", "(", "self", ")", ":", "if", "not", "self", ".", "public_ips", ":", "self", ".", "public_ips", "=", "clc", ".", "v2", ".", "PublicIPs", "(", "server", "=", "self", ",", "public_ips_lst", "=", "self", ".", "ip_addresses", ",", "sessi...
Returns PublicIPs object associated with the server.
[ "Returns", "PublicIPs", "object", "associated", "with", "the", "server", "." ]
python
train
33.571429
alpacahq/pylivetrader
pylivetrader/backend/alpaca.py
https://github.com/alpacahq/pylivetrader/blob/fd328b6595428c0789d9f218df34623f83a02b8b/pylivetrader/backend/alpaca.py#L578-L592
def _symbol_trades(self, symbols): ''' Query last_trade in parallel for multiple symbols and return in dict. symbols: list[str] return: dict[str -> polygon.Trade] ''' @skip_http_error((404, 504)) def fetch(symbol): return self._api.polygon.l...
[ "def", "_symbol_trades", "(", "self", ",", "symbols", ")", ":", "@", "skip_http_error", "(", "(", "404", ",", "504", ")", ")", "def", "fetch", "(", "symbol", ")", ":", "return", "self", ".", "_api", ".", "polygon", ".", "last_trade", "(", "symbol", "...
Query last_trade in parallel for multiple symbols and return in dict. symbols: list[str] return: dict[str -> polygon.Trade]
[ "Query", "last_trade", "in", "parallel", "for", "multiple", "symbols", "and", "return", "in", "dict", "." ]
python
train
24.466667
pytroll/satpy
satpy/readers/seviri_l1b_native.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/seviri_l1b_native.py#L418-L465
def calibrate(self, data, dsid): """Calibrate the data.""" tic = datetime.now() data15hdr = self.header['15_DATA_HEADER'] calibration = dsid.calibration channel = dsid.name # even though all the channels may not be present in the file, # the header does have cal...
[ "def", "calibrate", "(", "self", ",", "data", ",", "dsid", ")", ":", "tic", "=", "datetime", ".", "now", "(", ")", "data15hdr", "=", "self", ".", "header", "[", "'15_DATA_HEADER'", "]", "calibration", "=", "dsid", ".", "calibration", "channel", "=", "d...
Calibrate the data.
[ "Calibrate", "the", "data", "." ]
python
train
43.25
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py#L248-L261
def show_vcs_output_vcs_nodes_vcs_node_info_node_hw_sync_state(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") show_vcs = ET.Element("show_vcs") config = show_vcs output = ET.SubElement(show_vcs, "output") vcs_nodes = ET.SubElement(output...
[ "def", "show_vcs_output_vcs_nodes_vcs_node_info_node_hw_sync_state", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "show_vcs", "=", "ET", ".", "Element", "(", "\"show_vcs\"", ")", "config", "=", "s...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
44.642857
tariqdaouda/pyGeno
pyGeno/SNP.py
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/SNP.py#L18-L25
def getSNPSetsList() : """Return the names of all imported snp sets""" import rabaDB.filters as rfilt f = rfilt.RabaQuery(SNPMaster) names = [] for g in f.iterRun() : names.append(g.setName) return names
[ "def", "getSNPSetsList", "(", ")", ":", "import", "rabaDB", ".", "filters", "as", "rfilt", "f", "=", "rfilt", ".", "RabaQuery", "(", "SNPMaster", ")", "names", "=", "[", "]", "for", "g", "in", "f", ".", "iterRun", "(", ")", ":", "names", ".", "appe...
Return the names of all imported snp sets
[ "Return", "the", "names", "of", "all", "imported", "snp", "sets" ]
python
train
25.5
dls-controls/pymalcolm
malcolm/modules/pva/controllers/pvaclientcomms.py
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pva/controllers/pvaclientcomms.py#L145-L165
def send_post(self, mri, method_name, **params): """Abstract method to dispatch a Post to the server Args: mri (str): The mri of the Block method_name (str): The name of the Method within the Block params: The parameters to send Returns: The retu...
[ "def", "send_post", "(", "self", ",", "mri", ",", "method_name", ",", "*", "*", "params", ")", ":", "typ", ",", "parameters", "=", "convert_to_type_tuple_value", "(", "serialize_object", "(", "params", ")", ")", "uri", "=", "NTURI", "(", "typ", "[", "2",...
Abstract method to dispatch a Post to the server Args: mri (str): The mri of the Block method_name (str): The name of the Method within the Block params: The parameters to send Returns: The return results from the server
[ "Abstract", "method", "to", "dispatch", "a", "Post", "to", "the", "server" ]
python
train
32.380952
facundobatista/yaswfp
yaswfp/swfparser.py
https://github.com/facundobatista/yaswfp/blob/2a2cc6ca4c0b4d52bd2e658fb5f80fdc0db4924c/yaswfp/swfparser.py#L1393-L1405
def _get_struct_glowfilter(self): """Get the values for the GLOWFILTER record.""" obj = _make_object("GlowFilter") obj.GlowColor = self._get_struct_rgba() obj.BlurX = unpack_fixed16(self._src) obj.BlurY = unpack_fixed16(self._src) obj.Strength = unpack_fixed8(self._src) ...
[ "def", "_get_struct_glowfilter", "(", "self", ")", ":", "obj", "=", "_make_object", "(", "\"GlowFilter\"", ")", "obj", ".", "GlowColor", "=", "self", ".", "_get_struct_rgba", "(", ")", "obj", ".", "BlurX", "=", "unpack_fixed16", "(", "self", ".", "_src", "...
Get the values for the GLOWFILTER record.
[ "Get", "the", "values", "for", "the", "GLOWFILTER", "record", "." ]
python
train
39
rfk/tnetstring
tnetstring/__init__.py
https://github.com/rfk/tnetstring/blob/146381498a07d6053e044375562be08ef16017c2/tnetstring/__init__.py#L248-L316
def load(file,encoding=None): """load(file,encoding=None) -> object This function reads a tnetstring from a file and parses it into a python object. The file must support the read() method, and this function promises not to read more data than necessary. """ # Read the length prefix one char ...
[ "def", "load", "(", "file", ",", "encoding", "=", "None", ")", ":", "# Read the length prefix one char at a time.", "# Note that the netstring spec explicitly forbids padding zeros.", "c", "=", "file", ".", "read", "(", "1", ")", "if", "not", "c", ".", "isdigit", ...
load(file,encoding=None) -> object This function reads a tnetstring from a file and parses it into a python object. The file must support the read() method, and this function promises not to read more data than necessary.
[ "load", "(", "file", "encoding", "=", "None", ")", "-", ">", "object" ]
python
train
34.115942
grycap/RADL
radl/radl_json.py
https://github.com/grycap/RADL/blob/03ccabb0313a48a5aa0e20c1f7983fddcb95e9cb/radl/radl_json.py#L52-L71
def parse_radl(data): """ Parse a RADL document in JSON. Args.: - data(str or list): document to parse. Return(RADL): RADL object. """ if not isinstance(data, list): if os.path.isfile(data): f = open(data) data = "".join(f.readlines()) f.close() ...
[ "def", "parse_radl", "(", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "list", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "data", ")", ":", "f", "=", "open", "(", "data", ")", "data", "=", "\"\"", ".", "join", "(",...
Parse a RADL document in JSON. Args.: - data(str or list): document to parse. Return(RADL): RADL object.
[ "Parse", "a", "RADL", "document", "in", "JSON", "." ]
python
train
23.3
lmcinnes/umap
umap/rp_tree.py
https://github.com/lmcinnes/umap/blob/bbb01c03ba49f7bff8f77fd662d00e50d6686c77/umap/rp_tree.py#L534-L577
def make_tree(data, rng_state, leaf_size=30, angular=False): """Construct a random projection tree based on ``data`` with leaves of size at most ``leaf_size``. Parameters ---------- data: array of shape (n_samples, n_features) The original data to be split rng_state: array of int64, shap...
[ "def", "make_tree", "(", "data", ",", "rng_state", ",", "leaf_size", "=", "30", ",", "angular", "=", "False", ")", ":", "is_sparse", "=", "scipy", ".", "sparse", ".", "isspmatrix_csr", "(", "data", ")", "indices", "=", "np", ".", "arange", "(", "data",...
Construct a random projection tree based on ``data`` with leaves of size at most ``leaf_size``. Parameters ---------- data: array of shape (n_samples, n_features) The original data to be split rng_state: array of int64, shape (3,) The internal state of the rng leaf_size: int (opt...
[ "Construct", "a", "random", "projection", "tree", "based", "on", "data", "with", "leaves", "of", "size", "at", "most", "leaf_size", ".", "Parameters", "----------", "data", ":", "array", "of", "shape", "(", "n_samples", "n_features", ")", "The", "original", ...
python
train
36.795455
pavoni/pyvera
pyvera/subscribe.py
https://github.com/pavoni/pyvera/blob/e05e3d13f76153444787d31948feb5419d77a8c8/pyvera/subscribe.py#L129-L134
def start(self): """Start a thread to handle Vera blocked polling.""" self._poll_thread = threading.Thread(target=self._run_poll_server, name='Vera Poll Thread') self._poll_thread.deamon = True self._poll_thread.start()
[ "def", "start", "(", "self", ")", ":", "self", ".", "_poll_thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_run_poll_server", ",", "name", "=", "'Vera Poll Thread'", ")", "self", ".", "_poll_thread", ".", "deamon", "=", "True", ...
Start a thread to handle Vera blocked polling.
[ "Start", "a", "thread", "to", "handle", "Vera", "blocked", "polling", "." ]
python
train
48.5
ossobv/exactonline
exactonline/http.py
https://github.com/ossobv/exactonline/blob/f6bee418a9cb1fcf3ef17347ea7ab0dd3b573fde/exactonline/http.py#L251-L256
def http_post(url, data=None, opt=opt_default): """ Shortcut for urlopen (POST) + read. We'll probably want to add a nice timeout here later too. """ return _http_request(url, method='POST', data=_marshalled(data), opt=opt)
[ "def", "http_post", "(", "url", ",", "data", "=", "None", ",", "opt", "=", "opt_default", ")", ":", "return", "_http_request", "(", "url", ",", "method", "=", "'POST'", ",", "data", "=", "_marshalled", "(", "data", ")", ",", "opt", "=", "opt", ")" ]
Shortcut for urlopen (POST) + read. We'll probably want to add a nice timeout here later too.
[ "Shortcut", "for", "urlopen", "(", "POST", ")", "+", "read", ".", "We", "ll", "probably", "want", "to", "add", "a", "nice", "timeout", "here", "later", "too", "." ]
python
test
39.666667
jxtech/wechatpy
wechatpy/client/api/device.py
https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/device.py#L116-L134
def unbind(self, ticket, device_id, user_id): """ 解绑设备 详情请参考 https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7 :param ticket: 绑定操作合法性的凭证(由微信后台生成,第三方H5通过客户端jsapi获得) :param device_id: 设备id :param user_id: 用户对应的openid :return: 返回的 JSON 数据包 """...
[ "def", "unbind", "(", "self", ",", "ticket", ",", "device_id", ",", "user_id", ")", ":", "return", "self", ".", "_post", "(", "'unbind'", ",", "data", "=", "{", "'ticket'", ":", "ticket", ",", "'device_id'", ":", "device_id", ",", "'openid'", ":", "use...
解绑设备 详情请参考 https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7 :param ticket: 绑定操作合法性的凭证(由微信后台生成,第三方H5通过客户端jsapi获得) :param device_id: 设备id :param user_id: 用户对应的openid :return: 返回的 JSON 数据包
[ "解绑设备", "详情请参考", "https", ":", "//", "iot", ".", "weixin", ".", "qq", ".", "com", "/", "wiki", "/", "new", "/", "index", ".", "html?page", "=", "3", "-", "4", "-", "7" ]
python
train
26.421053
hazelcast/hazelcast-python-client
hazelcast/proxy/map.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L646-L674
def replace(self, key, value): """ Replaces the entry for a key only if it is currently mapped to some value. This is equivalent to: >>> if map.contains_key(key): >>> return map.put(key,value) >>> else: >>> return None except that ...
[ "def", "replace", "(", "self", ",", "key", ",", "value", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be None\"", ")", "check_not_none", "(", "value", ",", "\"value can't be None\"", ")", "key_data", "=", "self", ".", "_to_data", "(", "key", ")"...
Replaces the entry for a key only if it is currently mapped to some value. This is equivalent to: >>> if map.contains_key(key): >>> return map.put(key,value) >>> else: >>> return None except that the action is performed atomically. **Warn...
[ "Replaces", "the", "entry", "for", "a", "key", "only", "if", "it", "is", "currently", "mapped", "to", "some", "value", "." ]
python
train
39.896552
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/utils/openpy.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/utils/openpy.py#L163-L191
def read_py_url(url, errors='replace', skip_encoding_cookie=True): """Read a Python file from a URL, using the encoding declared inside the file. Parameters ---------- url : str The URL from which to fetch the file. errors : str How to handle decoding errors in the file. Options are...
[ "def", "read_py_url", "(", "url", ",", "errors", "=", "'replace'", ",", "skip_encoding_cookie", "=", "True", ")", ":", "response", "=", "urllib", ".", "urlopen", "(", "url", ")", "buffer", "=", "io", ".", "BytesIO", "(", "response", ".", "read", "(", "...
Read a Python file from a URL, using the encoding declared inside the file. Parameters ---------- url : str The URL from which to fetch the file. errors : str How to handle decoding errors in the file. Options are the same as for bytes.decode(), but here 'replace' is the default. ...
[ "Read", "a", "Python", "file", "from", "a", "URL", "using", "the", "encoding", "declared", "inside", "the", "file", ".", "Parameters", "----------", "url", ":", "str", "The", "URL", "from", "which", "to", "fetch", "the", "file", ".", "errors", ":", "str"...
python
test
37.689655
rosenbrockc/fortpy
fortpy/interop/ftypes.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/interop/ftypes.py#L937-L948
def _ctypes_ex_assign(executable): """Return a list of code lines to allocate and assign the local parameter definitions that match those in the signature of the wrapped executable. """ result = [] for p in executable.ordered_parameters: _ctypes_code_parameter(result, p, "assign") if ty...
[ "def", "_ctypes_ex_assign", "(", "executable", ")", ":", "result", "=", "[", "]", "for", "p", "in", "executable", ".", "ordered_parameters", ":", "_ctypes_code_parameter", "(", "result", ",", "p", ",", "\"assign\"", ")", "if", "type", "(", "executable", ")",...
Return a list of code lines to allocate and assign the local parameter definitions that match those in the signature of the wrapped executable.
[ "Return", "a", "list", "of", "code", "lines", "to", "allocate", "and", "assign", "the", "local", "parameter", "definitions", "that", "match", "those", "in", "the", "signature", "of", "the", "wrapped", "executable", "." ]
python
train
35.583333
napalm-automation/napalm
napalm/junos/junos.py
https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/junos/junos.py#L118-L132
def open(self): """Open the connection with the device.""" try: self.device.open() except ConnectTimeoutError as cte: raise ConnectionException(cte.msg) self.device.timeout = self.timeout self.device._conn._session.transport.set_keepalive(self.keepalive) ...
[ "def", "open", "(", "self", ")", ":", "try", ":", "self", ".", "device", ".", "open", "(", ")", "except", "ConnectTimeoutError", "as", "cte", ":", "raise", "ConnectionException", "(", "cte", ".", "msg", ")", "self", ".", "device", ".", "timeout", "=", ...
Open the connection with the device.
[ "Open", "the", "connection", "with", "the", "device", "." ]
python
train
42.333333
boriel/zxbasic
arch/zx48k/backend/__32bit.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L703-L711
def _bnot32(ins): """ Negates top (Bitwise NOT) of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __BNOT32') output.append('push de') output.append('push hl') REQUIRES.add('bnot32.asm') return output
[ "def", "_bnot32", "(", "ins", ")", ":", "output", "=", "_32bit_oper", "(", "ins", ".", "quad", "[", "2", "]", ")", "output", ".", "append", "(", "'call __BNOT32'", ")", "output", ".", "append", "(", "'push de'", ")", "output", ".", "append", "(", "'p...
Negates top (Bitwise NOT) of the stack (32 bits in DEHL)
[ "Negates", "top", "(", "Bitwise", "NOT", ")", "of", "the", "stack", "(", "32", "bits", "in", "DEHL", ")" ]
python
train
29.111111
brainiak/brainiak
brainiak/reprsimil/brsa.py
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/reprsimil/brsa.py#L201-L220
def _zscore(a): """ Calculating z-score of data on the first axis. If the numbers in any column are all equal, scipy.stats.zscore will return NaN for this column. We shall correct them all to be zeros. Parameters ---------- a: numpy array Returns ------- zscore: num...
[ "def", "_zscore", "(", "a", ")", ":", "assert", "a", ".", "ndim", ">", "1", ",", "'a must have more than one dimensions'", "zscore", "=", "scipy", ".", "stats", ".", "zscore", "(", "a", ",", "axis", "=", "0", ")", "zscore", "[", ":", ",", "np", ".", ...
Calculating z-score of data on the first axis. If the numbers in any column are all equal, scipy.stats.zscore will return NaN for this column. We shall correct them all to be zeros. Parameters ---------- a: numpy array Returns ------- zscore: numpy array The z-s...
[ "Calculating", "z", "-", "score", "of", "data", "on", "the", "first", "axis", ".", "If", "the", "numbers", "in", "any", "column", "are", "all", "equal", "scipy", ".", "stats", ".", "zscore", "will", "return", "NaN", "for", "this", "column", ".", "We", ...
python
train
31.15
sendgrid/sendgrid-python
sendgrid/helpers/mail/mail.py
https://github.com/sendgrid/sendgrid-python/blob/266c2abde7a35dfcce263e06bedc6a0bbdebeac9/sendgrid/helpers/mail/mail.py#L211-L236
def to(self, to_emails, global_substitutions=None, is_multiple=False, p=0): """Adds To objects to the Personalization object :param to_emails: An To or list of To objects :type to_emails: To, list(To), str, tuple :param global_substitutions: A dict of substitutions for all recipients ...
[ "def", "to", "(", "self", ",", "to_emails", ",", "global_substitutions", "=", "None", ",", "is_multiple", "=", "False", ",", "p", "=", "0", ")", ":", "if", "isinstance", "(", "to_emails", ",", "list", ")", ":", "for", "email", "in", "to_emails", ":", ...
Adds To objects to the Personalization object :param to_emails: An To or list of To objects :type to_emails: To, list(To), str, tuple :param global_substitutions: A dict of substitutions for all recipients :type global_substitutions: dict :param is_multiple: Create a new personi...
[ "Adds", "To", "objects", "to", "the", "Personalization", "object" ]
python
train
46.884615
knipknap/exscript
Exscript/protocols/protocol.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/protocols/protocol.py#L652-L678
def login(self, account=None, app_account=None, flush=True): """ Log into the connected host using the best method available. If an account is not given, default to the account that was used during the last call to login(). If a previous call was not made, use the account that wa...
[ "def", "login", "(", "self", ",", "account", "=", "None", ",", "app_account", "=", "None", ",", "flush", "=", "True", ")", ":", "with", "self", ".", "_get_account", "(", "account", ")", "as", "account", ":", "if", "app_account", "is", "None", ":", "a...
Log into the connected host using the best method available. If an account is not given, default to the account that was used during the last call to login(). If a previous call was not made, use the account that was passed to the constructor. If that also fails, raise a TypeError. ...
[ "Log", "into", "the", "connected", "host", "using", "the", "best", "method", "available", ".", "If", "an", "account", "is", "not", "given", "default", "to", "the", "account", "that", "was", "used", "during", "the", "last", "call", "to", "login", "()", "....
python
train
45.259259
bpython/curtsies
curtsies/input.py
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/input.py#L164-L170
def send(self, timeout=None): """Returns an event or None if no events occur before timeout.""" if self.sigint_event and is_main_thread(): with ReplacedSigIntHandler(self.sigint_handler): return self._send(timeout) else: return self._send(timeout)
[ "def", "send", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "self", ".", "sigint_event", "and", "is_main_thread", "(", ")", ":", "with", "ReplacedSigIntHandler", "(", "self", ".", "sigint_handler", ")", ":", "return", "self", ".", "_send", "...
Returns an event or None if no events occur before timeout.
[ "Returns", "an", "event", "or", "None", "if", "no", "events", "occur", "before", "timeout", "." ]
python
train
43.571429
noahbenson/neuropythy
neuropythy/util/core.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/util/core.py#L1451-L1463
def tmpdir(prefix='npythy_tempdir_', delete=True): ''' tmpdir() creates a temporary directory and yields its path. At python exit, the directory and all of its contents are recursively deleted (so long as the the normal python exit process is allowed to call the atexit handlers). tmpdir(prefix) ...
[ "def", "tmpdir", "(", "prefix", "=", "'npythy_tempdir_'", ",", "delete", "=", "True", ")", ":", "path", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "prefix", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "raise", ...
tmpdir() creates a temporary directory and yields its path. At python exit, the directory and all of its contents are recursively deleted (so long as the the normal python exit process is allowed to call the atexit handlers). tmpdir(prefix) uses the given prefix in the tempfile.mkdtemp() call. ...
[ "tmpdir", "()", "creates", "a", "temporary", "directory", "and", "yields", "its", "path", ".", "At", "python", "exit", "the", "directory", "and", "all", "of", "its", "contents", "are", "recursively", "deleted", "(", "so", "long", "as", "the", "the", "norma...
python
train
52.153846
AirtestProject/Poco
poco/proxy.py
https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/proxy.py#L520-L548
def pinch(self, direction='in', percent=0.6, duration=2.0, dead_zone=0.1): """ Squeezing or expanding 2 fingers on this UI with given motion range and duration. Args: direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding ...
[ "def", "pinch", "(", "self", ",", "direction", "=", "'in'", ",", "percent", "=", "0.6", ",", "duration", "=", "2.0", ",", "dead_zone", "=", "0.1", ")", ":", "if", "direction", "not", "in", "(", "'in'", ",", "'out'", ")", ":", "raise", "ValueError", ...
Squeezing or expanding 2 fingers on this UI with given motion range and duration. Args: direction (:py:obj:`str`): pinching direction, only "in" or "out". "in" for squeezing, "out" for expanding percent (:py:obj:`float`): squeezing range from or expanding range to of the bounds of the U...
[ "Squeezing", "or", "expanding", "2", "fingers", "on", "this", "UI", "with", "given", "motion", "range", "and", "duration", "." ]
python
train
50.758621
SAP/PyHDB
pyhdb/protocol/parts.py
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/parts.py#L545-L573
def pack_lob_data(remaining_size, payload, row_header_start_pos, row_lobs): """ After parameter row has been written, append the lobs and update the corresponding lob headers with lob position and lob size: :param payload: payload object (io.BytesIO instance) :param row_header_st...
[ "def", "pack_lob_data", "(", "remaining_size", ",", "payload", ",", "row_header_start_pos", ",", "row_lobs", ")", ":", "unwritten_lobs", "=", "collections", ".", "deque", "(", ")", "for", "lob_buffer", "in", "row_lobs", ":", "# Calculate relative position of lob withi...
After parameter row has been written, append the lobs and update the corresponding lob headers with lob position and lob size: :param payload: payload object (io.BytesIO instance) :param row_header_start_pos: absolute position of start position of row within payload :param row_lobs: list...
[ "After", "parameter", "row", "has", "been", "written", "append", "the", "lobs", "and", "update", "the", "corresponding", "lob", "headers", "with", "lob", "position", "and", "lob", "size", ":", ":", "param", "payload", ":", "payload", "object", "(", "io", "...
python
train
60.206897
linnarsson-lab/loompy
loompy/loom_layer.py
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loom_layer.py#L146-L197
def map(self, f_list: List[Callable[[np.ndarray], int]], axis: int = 0, chunksize: int = 1000, selection: np.ndarray = None) -> List[np.ndarray]: """ Apply a function along an axis without loading the entire dataset in memory. Args: f_list (list of func): Function(s) that takes a numpy ndarray as argument ...
[ "def", "map", "(", "self", ",", "f_list", ":", "List", "[", "Callable", "[", "[", "np", ".", "ndarray", "]", ",", "int", "]", "]", ",", "axis", ":", "int", "=", "0", ",", "chunksize", ":", "int", "=", "1000", ",", "selection", ":", "np", ".", ...
Apply a function along an axis without loading the entire dataset in memory. Args: f_list (list of func): Function(s) that takes a numpy ndarray as argument axis (int): Axis along which to apply the function (0 = rows, 1 = columns) chunksize (int): Number of rows (columns) to load per chunk selectio...
[ "Apply", "a", "function", "along", "an", "axis", "without", "loading", "the", "entire", "dataset", "in", "memory", "." ]
python
train
35.788462
qiniu/python-sdk
qiniu/services/compute/app.py
https://github.com/qiniu/python-sdk/blob/a69fbef4e3e6ea1ebe09f4610a5b18bb2c17de59/qiniu/services/compute/app.py#L129-L146
def get_app_region_products(self, app_uri): """获得指定应用所在区域的产品信息 Args: - app_uri: 应用的完整标识 Returns: 返回产品信息列表,若失败则返回None """ apps, retInfo = self.list_apps() if apps is None: return None for app in apps: if (app.get('...
[ "def", "get_app_region_products", "(", "self", ",", "app_uri", ")", ":", "apps", ",", "retInfo", "=", "self", ".", "list_apps", "(", ")", "if", "apps", "is", "None", ":", "return", "None", "for", "app", "in", "apps", ":", "if", "(", "app", ".", "get"...
获得指定应用所在区域的产品信息 Args: - app_uri: 应用的完整标识 Returns: 返回产品信息列表,若失败则返回None
[ "获得指定应用所在区域的产品信息" ]
python
train
22.444444
saltstack/salt
salt/modules/xapi_virt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L131-L138
def _get_label_uuid(xapi, rectype, label): ''' Internal, returns label's uuid ''' try: return getattr(xapi, rectype).get_by_name_label(label)[0] except Exception: return False
[ "def", "_get_label_uuid", "(", "xapi", ",", "rectype", ",", "label", ")", ":", "try", ":", "return", "getattr", "(", "xapi", ",", "rectype", ")", ".", "get_by_name_label", "(", "label", ")", "[", "0", "]", "except", "Exception", ":", "return", "False" ]
Internal, returns label's uuid
[ "Internal", "returns", "label", "s", "uuid" ]
python
train
25.5
Erotemic/utool
utool/util_str.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L1350-L1494
def dict_str(dict_, **dictkw): r""" Makes a pretty printable / human-readable string representation of a dictionary. In most cases this string could be evaled. Args: dict_ (dict_): a dictionary Args: dict_ (dict_): a dictionary **dictkw: stritems, strkeys, strvals, nl, new...
[ "def", "dict_str", "(", "dict_", ",", "*", "*", "dictkw", ")", ":", "import", "utool", "as", "ut", "stritems", "=", "dictkw", ".", "pop", "(", "'si'", ",", "dictkw", ".", "pop", "(", "'stritems'", ",", "False", ")", ")", "if", "stritems", ":", "dic...
r""" Makes a pretty printable / human-readable string representation of a dictionary. In most cases this string could be evaled. Args: dict_ (dict_): a dictionary Args: dict_ (dict_): a dictionary **dictkw: stritems, strkeys, strvals, nl, newlines, truncate, nobr, ...
[ "r", "Makes", "a", "pretty", "printable", "/", "human", "-", "readable", "string", "representation", "of", "a", "dictionary", ".", "In", "most", "cases", "this", "string", "could", "be", "evaled", "." ]
python
train
37.324138
NarrativeScience/lsi
src/lsi/utils/hosts.py
https://github.com/NarrativeScience/lsi/blob/7d901b03fdb1a34ef795e5412bfe9685d948e32d/src/lsi/utils/hosts.py#L264-L294
def matches(self, _filter): """ Returns whether the instance matches the given filter text. :param _filter: A regex filter. If it starts with `<identifier>:`, then the part before the colon will be used as an attribute and the part after will be a...
[ "def", "matches", "(", "self", ",", "_filter", ")", ":", "within_attrib", "=", "re", ".", "match", "(", "r'^([a-z_.]+):(.*)'", ",", "_filter", ")", "having_attrib", "=", "re", ".", "match", "(", "r'^([a-z_.]+)\\?$'", ",", "_filter", ")", "if", "within_attrib...
Returns whether the instance matches the given filter text. :param _filter: A regex filter. If it starts with `<identifier>:`, then the part before the colon will be used as an attribute and the part after will be applied to that attribute. :type _filter:...
[ "Returns", "whether", "the", "instance", "matches", "the", "given", "filter", "text", "." ]
python
test
46.290323
pudo/jsongraph
jsongraph/common.py
https://github.com/pudo/jsongraph/blob/35e4f397dbe69cd5553cf9cb9ab98859c3620f03/jsongraph/common.py#L11-L15
def get_binding(self, schema, data): """ For a given schema, get a binding mediator providing links to the RDF terms matching that schema. """ schema = self.parent.get_schema(schema) return Binding(schema, self.parent.resolver, data=data)
[ "def", "get_binding", "(", "self", ",", "schema", ",", "data", ")", ":", "schema", "=", "self", ".", "parent", ".", "get_schema", "(", "schema", ")", "return", "Binding", "(", "schema", ",", "self", ".", "parent", ".", "resolver", ",", "data", "=", "...
For a given schema, get a binding mediator providing links to the RDF terms matching that schema.
[ "For", "a", "given", "schema", "get", "a", "binding", "mediator", "providing", "links", "to", "the", "RDF", "terms", "matching", "that", "schema", "." ]
python
train
53.2
RiotGames/cloud-inquisitor
plugins/public/cinq-auditor-cloudtrail/cinq_auditor_cloudtrail/__init__.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/plugins/public/cinq-auditor-cloudtrail/cinq_auditor_cloudtrail/__init__.py#L473-L500
def set_s3_bucket(self, region, name, bucketName): """Sets the S3 bucket location for logfile delivery Args: region (`str`): Name of the AWS region name (`str`): Name of the CloudTrail Trail bucketName (`str`): Name of the S3 bucket to deliver log files to R...
[ "def", "set_s3_bucket", "(", "self", ",", "region", ",", "name", ",", "bucketName", ")", ":", "ct", "=", "self", ".", "session", ".", "client", "(", "'cloudtrail'", ",", "region_name", "=", "region", ")", "ct", ".", "update_trail", "(", "Name", "=", "n...
Sets the S3 bucket location for logfile delivery Args: region (`str`): Name of the AWS region name (`str`): Name of the CloudTrail Trail bucketName (`str`): Name of the S3 bucket to deliver log files to Returns: `None`
[ "Sets", "the", "S3", "bucket", "location", "for", "logfile", "delivery" ]
python
train
30.928571
aalireza/SimpleAudioIndexer
SimpleAudioIndexer/__init__.py
https://github.com/aalireza/SimpleAudioIndexer/blob/73f9d75897d785bdaea9d28dde5fa48104428164/SimpleAudioIndexer/__init__.py#L841-L956
def _index_audio_ibm(self, basename=None, replace_already_indexed=False, continuous=True, model="en-US_BroadbandModel", word_confidence=True, word_alternatives_threshold=0.9, profanity_filter_for_US_results=False): """ Implements...
[ "def", "_index_audio_ibm", "(", "self", ",", "basename", "=", "None", ",", "replace_already_indexed", "=", "False", ",", "continuous", "=", "True", ",", "model", "=", "\"en-US_BroadbandModel\"", ",", "word_confidence", "=", "True", ",", "word_alternatives_threshold"...
Implements a search-suitable interface for Watson speech API. Some explaination of the parameters here have been taken from [1]_ Parameters ---------- basename : str, optional A specific basename to be indexed and is placed in src_dir e.g `audio.wav`. ...
[ "Implements", "a", "search", "-", "suitable", "interface", "for", "Watson", "speech", "API", "." ]
python
train
43.275862
jtwhite79/pyemu
pyemu/utils/gw_utils.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/utils/gw_utils.py#L1035-L1063
def last_kstp_from_kper(hds,kper): """ function to find the last time step (kstp) for a give stress period (kper) in a modflow head save file. Parameters ---------- hds : flopy.utils.HeadFile kper : int the zero-index stress period number Returns ------- kstp : int ...
[ "def", "last_kstp_from_kper", "(", "hds", ",", "kper", ")", ":", "#find the last kstp with this kper", "kstp", "=", "-", "1", "for", "kkstp", ",", "kkper", "in", "hds", ".", "kstpkper", ":", "if", "kkper", "==", "kper", "+", "1", "and", "kkstp", ">", "ks...
function to find the last time step (kstp) for a give stress period (kper) in a modflow head save file. Parameters ---------- hds : flopy.utils.HeadFile kper : int the zero-index stress period number Returns ------- kstp : int the zero-based last time step during stre...
[ "function", "to", "find", "the", "last", "time", "step", "(", "kstp", ")", "for", "a", "give", "stress", "period", "(", "kper", ")", "in", "a", "modflow", "head", "save", "file", "." ]
python
train
22.965517
RudolfCardinal/pythonlib
cardinal_pythonlib/sphinxtools.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sphinxtools.py#L100-L131
def write_if_allowed(filename: str, content: str, overwrite: bool = False, mock: bool = False) -> None: """ Writes the contents to a file, if permitted. Args: filename: filename to write content: contents to write overwr...
[ "def", "write_if_allowed", "(", "filename", ":", "str", ",", "content", ":", "str", ",", "overwrite", ":", "bool", "=", "False", ",", "mock", ":", "bool", "=", "False", ")", "->", "None", ":", "# Check we're allowed", "if", "not", "overwrite", "and", "ex...
Writes the contents to a file, if permitted. Args: filename: filename to write content: contents to write overwrite: permit overwrites? mock: pretend to write, but don't Raises: RuntimeError: if file exists but overwriting not permitted
[ "Writes", "the", "contents", "to", "a", "file", "if", "permitted", "." ]
python
train
28.75
robotools/fontParts
Lib/fontParts/base/font.py
https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/font.py#L1258-L1305
def appendGuideline(self, position=None, angle=None, name=None, color=None, guideline=None): """ Append a new guideline to the font. >>> guideline = font.appendGuideline((50, 0), 90) >>> guideline = font.appendGuideline((0, 540), 0, name="overshoot", >>> color=(0, 0,...
[ "def", "appendGuideline", "(", "self", ",", "position", "=", "None", ",", "angle", "=", "None", ",", "name", "=", "None", ",", "color", "=", "None", ",", "guideline", "=", "None", ")", ":", "identifier", "=", "None", "if", "guideline", "is", "not", "...
Append a new guideline to the font. >>> guideline = font.appendGuideline((50, 0), 90) >>> guideline = font.appendGuideline((0, 540), 0, name="overshoot", >>> color=(0, 0, 0, 0.2)) **position** must be a :ref:`type-coordinate` indicating the position of the guideline...
[ "Append", "a", "new", "guideline", "to", "the", "font", "." ]
python
train
46.895833
zabuldon/teslajsonpy
teslajsonpy/climate.py
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L100-L110
def set_temperature(self, temp): """Set both the driver and passenger temperature to temp.""" temp = round(temp, 1) self.__manual_update_time = time.time() data = self._controller.command(self._id, 'set_temps', {"driver_temp": temp, ...
[ "def", "set_temperature", "(", "self", ",", "temp", ")", ":", "temp", "=", "round", "(", "temp", ",", "1", ")", "self", ".", "__manual_update_time", "=", "time", ".", "time", "(", ")", "data", "=", "self", ".", "_controller", ".", "command", "(", "se...
Set both the driver and passenger temperature to temp.
[ "Set", "both", "the", "driver", "and", "passenger", "temperature", "to", "temp", "." ]
python
train
50.454545
sdispater/orator
orator/dbal/platforms/platform.py
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/platforms/platform.py#L209-L240
def get_foreign_key_base_declaration_sql(self, foreign_key): """ Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration to be used in statements like CREATE TABLE. :param foreign_key: The foreign key :type foreign_key: ForeignKeyCo...
[ "def", "get_foreign_key_base_declaration_sql", "(", "self", ",", "foreign_key", ")", ":", "sql", "=", "\"\"", "if", "foreign_key", ".", "get_name", "(", ")", ":", "sql", "+=", "\"CONSTRAINT %s \"", "%", "foreign_key", ".", "get_quoted_name", "(", "self", ")", ...
Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration to be used in statements like CREATE TABLE. :param foreign_key: The foreign key :type foreign_key: ForeignKeyConstraint :rtype: str
[ "Obtains", "DBMS", "specific", "SQL", "code", "portion", "needed", "to", "set", "the", "FOREIGN", "KEY", "constraint", "of", "a", "field", "declaration", "to", "be", "used", "in", "statements", "like", "CREATE", "TABLE", "." ]
python
train
35.9375
broadinstitute/fiss
firecloud/api.py
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/api.py#L1141-L1171
def create_workspace(namespace, name, authorizationDomain="", attributes=None): """Create a new FireCloud Workspace. Args: namespace (str): project to which workspace belongs name (str): Workspace name protected (bool): If True, this workspace is protected by dbGaP credentia...
[ "def", "create_workspace", "(", "namespace", ",", "name", ",", "authorizationDomain", "=", "\"\"", ",", "attributes", "=", "None", ")", ":", "if", "not", "attributes", ":", "attributes", "=", "dict", "(", ")", "body", "=", "{", "\"namespace\"", ":", "names...
Create a new FireCloud Workspace. Args: namespace (str): project to which workspace belongs name (str): Workspace name protected (bool): If True, this workspace is protected by dbGaP credentials. This option is only available if your FireCloud account is linked to yo...
[ "Create", "a", "new", "FireCloud", "Workspace", "." ]
python
train
29.709677