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
ransford/sllurp
sllurp/epc/gtin.py
https://github.com/ransford/sllurp/blob/d744b7e17d7ba64a24d9a31bde6cba65d91ad9b1/sllurp/epc/gtin.py#L4-L18
def calculate_check_digit(gtin): '''Given a GTIN (8-14) or SSCC, calculate its appropriate check digit''' reverse_gtin = gtin[::-1] total = 0 count = 0 for char in reverse_gtin: digit = int(char) if count % 2 == 0: digit = digit * 3 total = total + digit c...
[ "def", "calculate_check_digit", "(", "gtin", ")", ":", "reverse_gtin", "=", "gtin", "[", ":", ":", "-", "1", "]", "total", "=", "0", "count", "=", "0", "for", "char", "in", "reverse_gtin", ":", "digit", "=", "int", "(", "char", ")", "if", "count", ...
Given a GTIN (8-14) or SSCC, calculate its appropriate check digit
[ "Given", "a", "GTIN", "(", "8", "-", "14", ")", "or", "SSCC", "calculate", "its", "appropriate", "check", "digit" ]
python
train
28.733333
scrapinghub/adblockparser
adblockparser/parser.py
https://github.com/scrapinghub/adblockparser/blob/4089612d65018d38dbb88dd7f697bcb07814014d/adblockparser/parser.py#L434-L453
def _combined_regex(regexes, flags=re.IGNORECASE, use_re2=False, max_mem=None): """ Return a compiled regex combined (using OR) from a list of ``regexes``. If there is nothing to combine, None is returned. re2 library (https://github.com/axiak/pyre2) often can match and compile large regexes much f...
[ "def", "_combined_regex", "(", "regexes", ",", "flags", "=", "re", ".", "IGNORECASE", ",", "use_re2", "=", "False", ",", "max_mem", "=", "None", ")", ":", "joined_regexes", "=", "\"|\"", ".", "join", "(", "r", "for", "r", "in", "regexes", "if", "r", ...
Return a compiled regex combined (using OR) from a list of ``regexes``. If there is nothing to combine, None is returned. re2 library (https://github.com/axiak/pyre2) often can match and compile large regexes much faster than stdlib re module (10x is not uncommon), but there are some gotchas: * in...
[ "Return", "a", "compiled", "regex", "combined", "(", "using", "OR", ")", "from", "a", "list", "of", "regexes", ".", "If", "there", "is", "nothing", "to", "combine", "None", "is", "returned", "." ]
python
train
39.25
NYUCCL/psiTurk
psiturk/amt_services.py
https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/amt_services.py#L228-L236
def validate_instance_size(self, size): ''' integer between 5-1024 (inclusive) ''' try: int(size) except ValueError: return '*** Error: size must be a whole number between 5 and 1024.' if int(size) < 5 or int(size) > 1024: return '*** Error: size must ...
[ "def", "validate_instance_size", "(", "self", ",", "size", ")", ":", "try", ":", "int", "(", "size", ")", "except", "ValueError", ":", "return", "'*** Error: size must be a whole number between 5 and 1024.'", "if", "int", "(", "size", ")", "<", "5", "or", "int",...
integer between 5-1024 (inclusive)
[ "integer", "between", "5", "-", "1024", "(", "inclusive", ")" ]
python
train
39.333333
cs01/pygdbmi
pygdbmi/gdbcontroller.py
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbcontroller.py#L248-L285
def get_gdb_response( self, timeout_sec=DEFAULT_GDB_TIMEOUT_SEC, raise_error_on_timeout=True ): """Get response from GDB, and block while doing so. If GDB does not have any response ready to be read by timeout_sec, an exception is raised. Args: timeout_sec (float): Maxim...
[ "def", "get_gdb_response", "(", "self", ",", "timeout_sec", "=", "DEFAULT_GDB_TIMEOUT_SEC", ",", "raise_error_on_timeout", "=", "True", ")", ":", "self", ".", "verify_valid_gdb_subprocess", "(", ")", "if", "timeout_sec", "<", "0", ":", "self", ".", "logger", "."...
Get response from GDB, and block while doing so. If GDB does not have any response ready to be read by timeout_sec, an exception is raised. Args: timeout_sec (float): Maximum time to wait for reponse. Must be >= 0. Will return after raise_error_on_timeout (bool): Whether an exce...
[ "Get", "response", "from", "GDB", "and", "block", "while", "doing", "so", ".", "If", "GDB", "does", "not", "have", "any", "response", "ready", "to", "be", "read", "by", "timeout_sec", "an", "exception", "is", "raised", "." ]
python
valid
38.421053
kcallin/mqtt-codec
mqtt_codec/packet.py
https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/packet.py#L82-L118
def are_flags_valid(packet_type, flags): """True when flags comply with [MQTT-2.2.2-1] requirements based on packet_type; False otherwise. Parameters ---------- packet_type: MqttControlPacketType flags: int Integer representation of 4-bit MQTT header flags field. Values outside ...
[ "def", "are_flags_valid", "(", "packet_type", ",", "flags", ")", ":", "if", "packet_type", "==", "MqttControlPacketType", ".", "publish", ":", "rv", "=", "0", "<=", "flags", "<=", "15", "elif", "packet_type", "in", "(", "MqttControlPacketType", ".", "pubrel", ...
True when flags comply with [MQTT-2.2.2-1] requirements based on packet_type; False otherwise. Parameters ---------- packet_type: MqttControlPacketType flags: int Integer representation of 4-bit MQTT header flags field. Values outside of the range [0, 15] will certainly cause the ...
[ "True", "when", "flags", "comply", "with", "[", "MQTT", "-", "2", ".", "2", ".", "2", "-", "1", "]", "requirements", "based", "on", "packet_type", ";", "False", "otherwise", "." ]
python
train
36.351351
DataBiosphere/toil
src/toil/wdl/wdl_analysis.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/wdl/wdl_analysis.py#L772-L797
def parse_declaration_expressn_memberaccess(self, lhsAST, rhsAST, es): """ Instead of "Class.variablename", use "Class.rv('variablename')". :param lhsAST: :param rhsAST: :param es: :return: """ if isinstance(lhsAST, wdl_parser.Terminal): es = ...
[ "def", "parse_declaration_expressn_memberaccess", "(", "self", ",", "lhsAST", ",", "rhsAST", ",", "es", ")", ":", "if", "isinstance", "(", "lhsAST", ",", "wdl_parser", ".", "Terminal", ")", ":", "es", "=", "es", "+", "lhsAST", ".", "source_string", "elif", ...
Instead of "Class.variablename", use "Class.rv('variablename')". :param lhsAST: :param rhsAST: :param es: :return:
[ "Instead", "of", "Class", ".", "variablename", "use", "Class", ".", "rv", "(", "variablename", ")", "." ]
python
train
31.307692
cogniteev/docido-python-sdk
docido_sdk/toolbox/yaml_ext.py
https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/yaml_ext.py#L7-L26
def envvar_constructor(loader, node): """Tag constructor to use environment variables in YAML files. Usage: - !TAG VARIABLE raise while loading the document if variable does not exists - !TAG VARIABLE:=DEFAULT_VALUE For instance: credentials: user: !env USER:=root ...
[ "def", "envvar_constructor", "(", "loader", ",", "node", ")", ":", "value", "=", "loader", ".", "construct_python_unicode", "(", "node", ")", "data", "=", "value", ".", "split", "(", "':='", ",", "1", ")", "if", "len", "(", "data", ")", "==", "2", ":...
Tag constructor to use environment variables in YAML files. Usage: - !TAG VARIABLE raise while loading the document if variable does not exists - !TAG VARIABLE:=DEFAULT_VALUE For instance: credentials: user: !env USER:=root group: !env GROUP:= root
[ "Tag", "constructor", "to", "use", "environment", "variables", "in", "YAML", "files", ".", "Usage", ":" ]
python
train
27.85
Exirel/pylint-json2html
pylint_json2html/__init__.py
https://github.com/Exirel/pylint-json2html/blob/7acdb4b7ea2f82a39a67d8ed3a43839c91cc423b/pylint_json2html/__init__.py#L188-L199
def on_close(self, stats, previous_stats): """Print the extended JSON report to reporter's output. :param dict stats: Metrics for the current pylint run :param dict previous_stats: Metrics for the previous pylint run """ reports = { 'messages': self._messages, ...
[ "def", "on_close", "(", "self", ",", "stats", ",", "previous_stats", ")", ":", "reports", "=", "{", "'messages'", ":", "self", ".", "_messages", ",", "'stats'", ":", "stats", ",", "'previous'", ":", "previous_stats", ",", "}", "print", "(", "json", ".", ...
Print the extended JSON report to reporter's output. :param dict stats: Metrics for the current pylint run :param dict previous_stats: Metrics for the previous pylint run
[ "Print", "the", "extended", "JSON", "report", "to", "reporter", "s", "output", "." ]
python
train
38.333333
btel/svg_utils
src/svgutils/transform.py
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L82-L92
def skew_y(self, y): """Skew element along the y-axis by the given angle. Parameters ---------- y : float y-axis skew angle in degrees """ self.root.set("transform", "%s skewY(%f)" % (self.root.get("transform") or '', y)) return ...
[ "def", "skew_y", "(", "self", ",", "y", ")", ":", "self", ".", "root", ".", "set", "(", "\"transform\"", ",", "\"%s skewY(%f)\"", "%", "(", "self", ".", "root", ".", "get", "(", "\"transform\"", ")", "or", "''", ",", "y", ")", ")", "return", "self"...
Skew element along the y-axis by the given angle. Parameters ---------- y : float y-axis skew angle in degrees
[ "Skew", "element", "along", "the", "y", "-", "axis", "by", "the", "given", "angle", "." ]
python
train
28.545455
project-ncl/pnc-cli
pnc_cli/swagger_client/apis/licenses_api.py
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/licenses_api.py#L472-L497
def update(self, id, **kwargs): """ Updates an existing License This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function...
[ "def", "update", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "update_with_http_info", "(", "id", ...
Updates an existing License This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response) ...
[ "Updates", "an", "existing", "License", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "define", "a", "callback", "function", "to", "be", "invoked", "when...
python
train
37.615385
caseyjlaw/rtpipe
rtpipe/RT.py
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L961-L969
def calc_nfalse(d): """ Calculate the number of thermal-noise false positives per segment. """ dtfactor = n.sum([1./i for i in d['dtarr']]) # assumes dedisperse-all algorithm ntrials = d['readints'] * dtfactor * len(d['dmarr']) * d['npixx'] * d['npixy'] qfrac = 1 - (erf(d['sigma_image1']/n.sqrt(...
[ "def", "calc_nfalse", "(", "d", ")", ":", "dtfactor", "=", "n", ".", "sum", "(", "[", "1.", "/", "i", "for", "i", "in", "d", "[", "'dtarr'", "]", "]", ")", "# assumes dedisperse-all algorithm", "ntrials", "=", "d", "[", "'readints'", "]", "*", "dtfac...
Calculate the number of thermal-noise false positives per segment.
[ "Calculate", "the", "number", "of", "thermal", "-", "noise", "false", "positives", "per", "segment", "." ]
python
train
41.444444
acorg/dark-matter
dark/titles.py
https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L38-L47
def toDict(self): """ Get information about a title alignment as a dictionary. @return: A C{dict} representation of the title aligment. """ return { 'hsps': [hsp.toDict() for hsp in self.hsps], 'read': self.read.toDict(), }
[ "def", "toDict", "(", "self", ")", ":", "return", "{", "'hsps'", ":", "[", "hsp", ".", "toDict", "(", ")", "for", "hsp", "in", "self", ".", "hsps", "]", ",", "'read'", ":", "self", ".", "read", ".", "toDict", "(", ")", ",", "}" ]
Get information about a title alignment as a dictionary. @return: A C{dict} representation of the title aligment.
[ "Get", "information", "about", "a", "title", "alignment", "as", "a", "dictionary", "." ]
python
train
28.7
googleapis/google-cloud-python
bigtable/google/cloud/bigtable_admin_v2/gapic/bigtable_instance_admin_client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable_admin_v2/gapic/bigtable_instance_admin_client.py#L112-L119
def cluster_path(cls, project, instance, cluster): """Return a fully-qualified cluster string.""" return google.api_core.path_template.expand( "projects/{project}/instances/{instance}/clusters/{cluster}", project=project, instance=instance, cluster=cluster...
[ "def", "cluster_path", "(", "cls", ",", "project", ",", "instance", ",", "cluster", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "\"projects/{project}/instances/{instance}/clusters/{cluster}\"", ",", "project", "=", "proje...
Return a fully-qualified cluster string.
[ "Return", "a", "fully", "-", "qualified", "cluster", "string", "." ]
python
train
40.5
sernst/cauldron
cauldron/session/display/__init__.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L403-L429
def listing( source: list, ordered: bool = False, expand_full: bool = False ): """ An unordered or ordered list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The iterable to display as a list. ...
[ "def", "listing", "(", "source", ":", "list", ",", "ordered", ":", "bool", "=", "False", ",", "expand_full", ":", "bool", "=", "False", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "listing", "(", "source"...
An unordered or ordered list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The iterable to display as a list. :param ordered: Whether or not the list should be ordered. If False, which is the default, an uno...
[ "An", "unordered", "or", "ordered", "list", "of", "the", "specified", "*", "source", "*", "iterable", "where", "each", "element", "is", "converted", "to", "a", "string", "representation", "for", "display", "." ]
python
train
35.148148
breuleux/hrepr
hrepr/__init__.py
https://github.com/breuleux/hrepr/blob/a411395d31ac7c8c071d174e63a093751aa5997b/hrepr/__init__.py#L342-L383
def titled_box(self, titles, contents, tdir='h', cdir='h'): """ Helper function to build a box containing a list of elements, with a title above and/or below, or left and/or right of the box. (e.g. a class name on top, or brackets on both sides.) The elements given must already ...
[ "def", "titled_box", "(", "self", ",", "titles", ",", "contents", ",", "tdir", "=", "'h'", ",", "cdir", "=", "'h'", ")", ":", "H", "=", "self", ".", "H", "def", "wrapt", "(", "x", ")", ":", "return", "H", ".", "div", "[", "'hrepr-title'", "]", ...
Helper function to build a box containing a list of elements, with a title above and/or below, or left and/or right of the box. (e.g. a class name on top, or brackets on both sides.) The elements given must already have been transformed into Tag instances. Arguments: ...
[ "Helper", "function", "to", "build", "a", "box", "containing", "a", "list", "of", "elements", "with", "a", "title", "above", "and", "/", "or", "below", "or", "left", "and", "/", "or", "right", "of", "the", "box", ".", "(", "e", ".", "g", ".", "a", ...
python
train
34.714286
mariano/pyfire
pyfire/room.py
https://github.com/mariano/pyfire/blob/42e3490c138abc8e10f2e9f8f8f3b40240a80412/pyfire/room.py#L143-L165
def speak(self, message): """ Post a message. Args: message (:class:`Message` or string): Message Returns: bool. Success """ campfire = self.get_campfire() if not isinstance(message, Message): message = Message(campfire, message) ...
[ "def", "speak", "(", "self", ",", "message", ")", ":", "campfire", "=", "self", ".", "get_campfire", "(", ")", "if", "not", "isinstance", "(", "message", ",", "Message", ")", ":", "message", "=", "Message", "(", "campfire", ",", "message", ")", "result...
Post a message. Args: message (:class:`Message` or string): Message Returns: bool. Success
[ "Post", "a", "message", "." ]
python
valid
26.086957
portfors-lab/sparkle
sparkle/gui/stim/auto_parameters_editor.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/auto_parameters_editor.py#L71-L91
def showEvent(self, event): """When this widget is shown it has an effect of putting other widgets in the parent widget into different editing modes, emits signal to notify other widgets. Restores the previous selection the last time this widget was visible""" selected = self.par...
[ "def", "showEvent", "(", "self", ",", "event", ")", ":", "selected", "=", "self", ".", "paramList", ".", "selectedIndexes", "(", ")", "model", "=", "self", ".", "paramList", ".", "model", "(", ")", "self", ".", "visibilityChanged", ".", "emit", "(", "1...
When this widget is shown it has an effect of putting other widgets in the parent widget into different editing modes, emits signal to notify other widgets. Restores the previous selection the last time this widget was visible
[ "When", "this", "widget", "is", "shown", "it", "has", "an", "effect", "of", "putting", "other", "widgets", "in", "the", "parent", "widget", "into", "different", "editing", "modes", "emits", "signal", "to", "notify", "other", "widgets", ".", "Restores", "the"...
python
train
56.714286
obulpathi/cdn-fastly-python
fastly/__init__.py
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L784-L787
def get_syslog(self, service_id, version_number, name): """Get the Syslog for a particular service and version.""" content = self._fetch("/service/%s/version/%d/syslog/%s" % (service_id, version_number, name)) return FastlySyslog(self, content)
[ "def", "get_syslog", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/syslog/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")", "return...
Get the Syslog for a particular service and version.
[ "Get", "the", "Syslog", "for", "a", "particular", "service", "and", "version", "." ]
python
train
61.75
google/grr
grr/server/grr_response_server/threadpool.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/threadpool.py#L458-L466
def Join(self): """Waits until all outstanding tasks are completed.""" for _ in range(self.JOIN_TIMEOUT_DECISECONDS): if self._queue.empty() and not self.busy_threads: return time.sleep(0.1) raise ValueError("Timeout during Join() for threadpool %s." % self.name)
[ "def", "Join", "(", "self", ")", ":", "for", "_", "in", "range", "(", "self", ".", "JOIN_TIMEOUT_DECISECONDS", ")", ":", "if", "self", ".", "_queue", ".", "empty", "(", ")", "and", "not", "self", ".", "busy_threads", ":", "return", "time", ".", "slee...
Waits until all outstanding tasks are completed.
[ "Waits", "until", "all", "outstanding", "tasks", "are", "completed", "." ]
python
train
32.111111
ihgazni2/elist
elist/elist.py
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L974-L988
def select_seqs(ol,seqs): ''' from elist.elist import * ol = ['a','b','c','d'] select_seqs(ol,[1,2]) ''' rslt =copy.deepcopy(ol) rslt = itemgetter(*seqs)(ol) if(seqs.__len__()==0): rslt = [] elif(seqs.__len__()==1): rslt = [rslt] else: rslt = l...
[ "def", "select_seqs", "(", "ol", ",", "seqs", ")", ":", "rslt", "=", "copy", ".", "deepcopy", "(", "ol", ")", "rslt", "=", "itemgetter", "(", "*", "seqs", ")", "(", "ol", ")", "if", "(", "seqs", ".", "__len__", "(", ")", "==", "0", ")", ":", ...
from elist.elist import * ol = ['a','b','c','d'] select_seqs(ol,[1,2])
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "a", "b", "c", "d", "]", "select_seqs", "(", "ol", "[", "1", "2", "]", ")" ]
python
valid
22.133333
umutbozkurt/django-rest-framework-mongoengine
rest_framework_mongoengine/serializers.py
https://github.com/umutbozkurt/django-rest-framework-mongoengine/blob/2fe6de53907b31a5e8b742e4c6b728942b5fa4f0/rest_framework_mongoengine/serializers.py#L542-L562
def apply_customization(self, serializer, customization): """ Applies fields customization to a nested or embedded DocumentSerializer. """ # apply fields or exclude if customization.fields is not None: if len(customization.fields) == 0: # customization...
[ "def", "apply_customization", "(", "self", ",", "serializer", ",", "customization", ")", ":", "# apply fields or exclude", "if", "customization", ".", "fields", "is", "not", "None", ":", "if", "len", "(", "customization", ".", "fields", ")", "==", "0", ":", ...
Applies fields customization to a nested or embedded DocumentSerializer.
[ "Applies", "fields", "customization", "to", "a", "nested", "or", "embedded", "DocumentSerializer", "." ]
python
train
42.761905
nickmckay/LiPD-utilities
Python/lipd/dataframes.py
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/dataframes.py#L240-L299
def _match_dfs_expr(lo_meta, expr, tt): """ Use the given expression to get all data frames that match the criteria (i.e. "paleo measurement tables") :param dict lo_meta: Lipd object metadata :param str expr: Search expression :param str tt: Table type (chron or paleo) :return list: All filename...
[ "def", "_match_dfs_expr", "(", "lo_meta", ",", "expr", ",", "tt", ")", ":", "logger_dataframes", ".", "info", "(", "\"enter match_dfs_expr\"", ")", "filenames", "=", "[", "]", "s", "=", "\"{}Data\"", ".", "format", "(", "tt", ")", "# Top table level. Going thr...
Use the given expression to get all data frames that match the criteria (i.e. "paleo measurement tables") :param dict lo_meta: Lipd object metadata :param str expr: Search expression :param str tt: Table type (chron or paleo) :return list: All filenames that match the expression
[ "Use", "the", "given", "expression", "to", "get", "all", "data", "frames", "that", "match", "the", "criteria", "(", "i", ".", "e", ".", "paleo", "measurement", "tables", ")", ":", "param", "dict", "lo_meta", ":", "Lipd", "object", "metadata", ":", "param...
python
train
44.35
delph-in/pydelphin
delphin/mrs/simplemrs.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L475-L492
def _serialize_lnk(lnk): """Serialize a predication lnk to surface form into the SimpleMRS encoding.""" s = "" if lnk is not None: s = '<' if lnk.type == Lnk.CHARSPAN: cfrom, cto = lnk.data s += ''.join([str(cfrom), ':', str(cto)]) elif lnk.type == Lnk....
[ "def", "_serialize_lnk", "(", "lnk", ")", ":", "s", "=", "\"\"", "if", "lnk", "is", "not", "None", ":", "s", "=", "'<'", "if", "lnk", ".", "type", "==", "Lnk", ".", "CHARSPAN", ":", "cfrom", ",", "cto", "=", "lnk", ".", "data", "s", "+=", "''",...
Serialize a predication lnk to surface form into the SimpleMRS encoding.
[ "Serialize", "a", "predication", "lnk", "to", "surface", "form", "into", "the", "SimpleMRS", "encoding", "." ]
python
train
33.555556
StackStorm/pybind
pybind/slxos/v17r_1_01a/isis_state/router_isis_config/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/isis_state/router_isis_config/__init__.py#L1330-L1353
def _set_pspf_timer(self, v, load=False): """ Setter method for pspf_timer, mapped from YANG variable /isis_state/router_isis_config/pspf_timer (container) If this variable is read-only (config: false) in the source YANG file, then _set_pspf_timer is considered as a private method. Backends looking ...
[ "def", "_set_pspf_timer", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "bas...
Setter method for pspf_timer, mapped from YANG variable /isis_state/router_isis_config/pspf_timer (container) If this variable is read-only (config: false) in the source YANG file, then _set_pspf_timer is considered as a private method. Backends looking to populate this variable should do so via calling...
[ "Setter", "method", "for", "pspf_timer", "mapped", "from", "YANG", "variable", "/", "isis_state", "/", "router_isis_config", "/", "pspf_timer", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in"...
python
train
74.25
tensorlayer/tensorlayer
tensorlayer/nlp.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L335-L375
def process_sentence(sentence, start_word="<S>", end_word="</S>"): """Seperate a sentence string into a list of string words, add start_word and end_word, see ``create_vocab()`` and ``tutorial_tfrecord3.py``. Parameters ---------- sentence : str A sentence. start_word : str or None ...
[ "def", "process_sentence", "(", "sentence", ",", "start_word", "=", "\"<S>\"", ",", "end_word", "=", "\"</S>\"", ")", ":", "if", "start_word", "is", "not", "None", ":", "process_sentence", "=", "[", "start_word", "]", "else", ":", "process_sentence", "=", "[...
Seperate a sentence string into a list of string words, add start_word and end_word, see ``create_vocab()`` and ``tutorial_tfrecord3.py``. Parameters ---------- sentence : str A sentence. start_word : str or None The start word. If None, no start word will be appended. end_word ...
[ "Seperate", "a", "sentence", "string", "into", "a", "list", "of", "string", "words", "add", "start_word", "and", "end_word", "see", "create_vocab", "()", "and", "tutorial_tfrecord3", ".", "py", "." ]
python
valid
28.634146
deepmind/sonnet
sonnet/python/modules/conv.py
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1159-L1183
def _recover_shape_information(self, inputs, outputs): """Recover output tensor shape value to enable shape inference. The batch size of `inputs` isn't preserved by the convolution op. Calculate what the proper output shape will be for `outputs`. Args: inputs: A Tensor of shape `data_format` and...
[ "def", "_recover_shape_information", "(", "self", ",", "inputs", ",", "outputs", ")", ":", "batch_size_value", "=", "inputs", ".", "get_shape", "(", ")", "[", "0", "]", "if", "self", ".", "_data_format", ".", "startswith", "(", "\"NC\"", ")", ":", "output_...
Recover output tensor shape value to enable shape inference. The batch size of `inputs` isn't preserved by the convolution op. Calculate what the proper output shape will be for `outputs`. Args: inputs: A Tensor of shape `data_format` and of type `tf.float16`, `tf.bfloat16` or `tf.float32`...
[ "Recover", "output", "tensor", "shape", "value", "to", "enable", "shape", "inference", "." ]
python
train
44.32
KnuVerse/knuverse-sdk-python
knuverse/knufactor.py
https://github.com/KnuVerse/knuverse-sdk-python/blob/00f1275a452a4dcf9bc92ef345f6985504226d8e/knuverse/knufactor.py#L639-L647
def status(self): """ Get server status. Uses GET to /status interface. :Returns: (dict) Server status as described `here <https://cloud.knuverse.com/docs/api/#api-General-Status>`_. """ response = self._get(url.status) self._check_response(response, 200) return...
[ "def", "status", "(", "self", ")", ":", "response", "=", "self", ".", "_get", "(", "url", ".", "status", ")", "self", ".", "_check_response", "(", "response", ",", "200", ")", "return", "self", ".", "_create_response", "(", "response", ")" ]
Get server status. Uses GET to /status interface. :Returns: (dict) Server status as described `here <https://cloud.knuverse.com/docs/api/#api-General-Status>`_.
[ "Get", "server", "status", ".", "Uses", "GET", "to", "/", "status", "interface", "." ]
python
train
38.222222
diamondman/proteusisc
proteusisc/promise.py
https://github.com/diamondman/proteusisc/blob/7622b7b04e63f9dc0f5a04429ff78d9a490c9c5c/proteusisc/promise.py#L151-L182
def _fulfill(self, bits, ignore_nonpromised_bits=False): """Supply the promise with the bits from its associated primitive's execution. The fulfillment process must walk the promise chain backwards until it reaches the original promise and can supply the final value. The data t...
[ "def", "_fulfill", "(", "self", ",", "bits", ",", "ignore_nonpromised_bits", "=", "False", ")", ":", "if", "self", ".", "_allsubsfulfilled", "(", ")", ":", "if", "not", "self", ".", "_components", ":", "if", "ignore_nonpromised_bits", ":", "self", ".", "_v...
Supply the promise with the bits from its associated primitive's execution. The fulfillment process must walk the promise chain backwards until it reaches the original promise and can supply the final value. The data that comes in can either be all a bit read for every bit writ...
[ "Supply", "the", "promise", "with", "the", "bits", "from", "its", "associated", "primitive", "s", "execution", "." ]
python
train
48.3125
mattja/nsim
nsim/nsim.py
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1113-L1132
def coupling(self, source_y, target_y, weight): """How to couple the output of one subsystem to the input of another. This is a fallback default coupling function that should usually be replaced with your own. This example coupling function takes the mean of all variables of the ...
[ "def", "coupling", "(", "self", ",", "source_y", ",", "target_y", ",", "weight", ")", ":", "return", "np", ".", "ones_like", "(", "target_y", ")", "*", "np", ".", "mean", "(", "source_y", ")", "*", "weight" ]
How to couple the output of one subsystem to the input of another. This is a fallback default coupling function that should usually be replaced with your own. This example coupling function takes the mean of all variables of the source subsystem and uses that value weighted by the conn...
[ "How", "to", "couple", "the", "output", "of", "one", "subsystem", "to", "the", "input", "of", "another", "." ]
python
train
43
vaexio/vaex
packages/vaex-core/vaex/dataframe.py
https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/dataframe.py#L3050-L3074
def add_virtual_columns_cartesian_velocities_to_polar(self, x="x", y="y", vx="vx", radius_polar=None, vy="vy", vr_out="vr_polar", vazimuth_out="vphi_polar", propagate_uncertainties=False,): """Convert cartesian to polar velocities. :param x: ...
[ "def", "add_virtual_columns_cartesian_velocities_to_polar", "(", "self", ",", "x", "=", "\"x\"", ",", "y", "=", "\"y\"", ",", "vx", "=", "\"vx\"", ",", "radius_polar", "=", "None", ",", "vy", "=", "\"vy\"", ",", "vr_out", "=", "\"vr_polar\"", ",", "vazimuth_...
Convert cartesian to polar velocities. :param x: :param y: :param vx: :param radius_polar: Optional expression for the radius, may lead to a better performance when given. :param vy: :param vr_out: :param vazimuth_out: :param propagate_uncertainties: {pro...
[ "Convert", "cartesian", "to", "polar", "velocities", "." ]
python
test
42.84
census-instrumentation/opencensus-python
nox.py
https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/nox.py#L82-L107
def system(session, py): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') # Run the system tests against late...
[ "def", "system", "(", "session", ",", "py", ")", ":", "# Sanity check: Only run system tests if the environment variable is set.", "if", "not", "os", ".", "environ", ".", "get", "(", "'GOOGLE_APPLICATION_CREDENTIALS'", ",", "''", ")", ":", "session", ".", "skip", "(...
Run the system test suite.
[ "Run", "the", "system", "test", "suite", "." ]
python
train
30.5
SKA-ScienceDataProcessor/integration-prototype
sip/platform/logging/sip_logging/sip_logging.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/platform/logging/sip_logging/sip_logging.py#L31-L43
def formatTime(self, record, datefmt=None): """Format the log timestamp.""" _seconds_fraction = record.created - int(record.created) _datetime_utc = time.mktime(time.gmtime(record.created)) _datetime_utc += _seconds_fraction _created = self.converter(_datetime_utc) if da...
[ "def", "formatTime", "(", "self", ",", "record", ",", "datefmt", "=", "None", ")", ":", "_seconds_fraction", "=", "record", ".", "created", "-", "int", "(", "record", ".", "created", ")", "_datetime_utc", "=", "time", ".", "mktime", "(", "time", ".", "...
Format the log timestamp.
[ "Format", "the", "log", "timestamp", "." ]
python
train
41.769231
loli/medpy
medpy/metric/histogram.py
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L1185-L1215
def quadratic_forms(h1, h2): r""" Quadrativ forms metric. Notes ----- UNDER DEVELOPMENT This distance measure shows very strange behaviour. The expression transpose(h1-h2) * A * (h1-h2) yields egative values that can not be processed by the square root. Some examples:: ...
[ "def", "quadratic_forms", "(", "h1", ",", "h2", ")", ":", "h1", ",", "h2", "=", "__prepare_histogram", "(", "h1", ",", "h2", ")", "A", "=", "__quadratic_forms_matrix_euclidean", "(", "h1", ",", "h2", ")", "return", "math", ".", "sqrt", "(", "(", "h1", ...
r""" Quadrativ forms metric. Notes ----- UNDER DEVELOPMENT This distance measure shows very strange behaviour. The expression transpose(h1-h2) * A * (h1-h2) yields egative values that can not be processed by the square root. Some examples:: h1 h2 ...
[ "r", "Quadrativ", "forms", "metric", ".", "Notes", "-----", "UNDER", "DEVELOPMENT", "This", "distance", "measure", "shows", "very", "strange", "behaviour", ".", "The", "expression", "transpose", "(", "h1", "-", "h2", ")", "*", "A", "*", "(", "h1", "-", "...
python
train
48.225806
google/mobly
mobly/controllers/android_device.py
https://github.com/google/mobly/blob/38ba2cf7d29a20e6a2fca1718eecb337df38db26/mobly/controllers/android_device.py#L274-L287
def get_all_instances(include_fastboot=False): """Create AndroidDevice instances for all attached android devices. Args: include_fastboot: Whether to include devices in bootloader mode or not. Returns: A list of AndroidDevice objects each representing an android device attached to ...
[ "def", "get_all_instances", "(", "include_fastboot", "=", "False", ")", ":", "if", "include_fastboot", ":", "serial_list", "=", "list_adb_devices", "(", ")", "+", "list_fastboot_devices", "(", ")", "return", "get_instances", "(", "serial_list", ")", "return", "get...
Create AndroidDevice instances for all attached android devices. Args: include_fastboot: Whether to include devices in bootloader mode or not. Returns: A list of AndroidDevice objects each representing an android device attached to the computer.
[ "Create", "AndroidDevice", "instances", "for", "all", "attached", "android", "devices", "." ]
python
train
36.214286
kislyuk/aegea
aegea/packages/github3/github.py
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L326-L334
def gist(self, id_num): """Gets the gist using the specified id number. :param int id_num: (required), unique id of the gist :returns: :class:`Gist <github3.gists.Gist>` """ url = self._build_url('gists', str(id_num)) json = self._json(self._get(url), 200) return...
[ "def", "gist", "(", "self", ",", "id_num", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'gists'", ",", "str", "(", "id_num", ")", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "ret...
Gets the gist using the specified id number. :param int id_num: (required), unique id of the gist :returns: :class:`Gist <github3.gists.Gist>`
[ "Gets", "the", "gist", "using", "the", "specified", "id", "number", "." ]
python
train
38.555556
openstack/networking-cisco
networking_cisco/apps/saf/server/dfa_server.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/dfa_server.py#L697-L701
def _get_segmentation_id(self, netid, segid, source): """Allocate segmentation id. """ return self.seg_drvr.allocate_segmentation_id(netid, seg_id=segid, source=source)
[ "def", "_get_segmentation_id", "(", "self", ",", "netid", ",", "segid", ",", "source", ")", ":", "return", "self", ".", "seg_drvr", ".", "allocate_segmentation_id", "(", "netid", ",", "seg_id", "=", "segid", ",", "source", "=", "source", ")" ]
Allocate segmentation id.
[ "Allocate", "segmentation", "id", "." ]
python
train
47
eandersson/amqpstorm
amqpstorm/message.py
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/message.py#L99-L113
def ack(self): """Acknowledge Message. :raises AMQPInvalidArgument: Invalid Parameters :raises AMQPChannelError: Raises if the channel encountered an error. :raises AMQPConnectionError: Raises if the connection encountered an error. :return:...
[ "def", "ack", "(", "self", ")", ":", "if", "not", "self", ".", "_method", ":", "raise", "AMQPMessageError", "(", "'Message.ack only available on incoming messages'", ")", "self", ".", "_channel", ".", "basic", ".", "ack", "(", "delivery_tag", "=", "self", ".",...
Acknowledge Message. :raises AMQPInvalidArgument: Invalid Parameters :raises AMQPChannelError: Raises if the channel encountered an error. :raises AMQPConnectionError: Raises if the connection encountered an error. :return:
[ "Acknowledge", "Message", "." ]
python
train
35.133333
lpantano/seqcluster
seqcluster/libs/read.py
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/read.py#L165-L184
def read_alignment(out_sam, loci, seqs, out_file): """read which seqs map to which loci and return a tab separated file""" hits = defaultdict(list) with open(out_file, "w") as out_handle: samfile = pysam.Samfile(out_sam, "r") for a in samfile.fetch(): if not a.is_unmapped: ...
[ "def", "read_alignment", "(", "out_sam", ",", "loci", ",", "seqs", ",", "out_file", ")", ":", "hits", "=", "defaultdict", "(", "list", ")", "with", "open", "(", "out_file", ",", "\"w\"", ")", "as", "out_handle", ":", "samfile", "=", "pysam", ".", "Samf...
read which seqs map to which loci and return a tab separated file
[ "read", "which", "seqs", "map", "to", "which", "loci", "and", "return", "a", "tab", "separated", "file" ]
python
train
41.85
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L25488-L25518
def take_screen_shot_to_array(self, screen_id, width, height, bitmap_format): """Takes a guest screen shot of the requested size and format and returns it as an array of bytes. in screen_id of type int The guest monitor to take screenshot from. in width of type int ...
[ "def", "take_screen_shot_to_array", "(", "self", ",", "screen_id", ",", "width", ",", "height", ",", "bitmap_format", ")", ":", "if", "not", "isinstance", "(", "screen_id", ",", "baseinteger", ")", ":", "raise", "TypeError", "(", "\"screen_id can only be an instan...
Takes a guest screen shot of the requested size and format and returns it as an array of bytes. in screen_id of type int The guest monitor to take screenshot from. in width of type int Desired image width. in height of type int Desired image height....
[ "Takes", "a", "guest", "screen", "shot", "of", "the", "requested", "size", "and", "format", "and", "returns", "it", "as", "an", "array", "of", "bytes", "." ]
python
train
40.709677
alejandrobll/py-sphviewer
sphviewer/Scene.py
https://github.com/alejandrobll/py-sphviewer/blob/f198bd9ed5adfb58ebdf66d169206e609fd46e42/sphviewer/Scene.py#L130-L137
def get_scene(self): """ - get_scene(): It return the x and y position, the smoothing length of the particles and the index of the particles that are active in the scene. In principle this is an internal function and you don't need this data. """ return self._...
[ "def", "get_scene", "(", "self", ")", ":", "return", "self", ".", "_x", ",", "self", ".", "_y", ",", "self", ".", "_hsml", ",", "self", ".", "_m", ",", "self", ".", "_kview" ]
- get_scene(): It return the x and y position, the smoothing length of the particles and the index of the particles that are active in the scene. In principle this is an internal function and you don't need this data.
[ "-", "get_scene", "()", ":", "It", "return", "the", "x", "and", "y", "position", "the", "smoothing", "length", "of", "the", "particles", "and", "the", "index", "of", "the", "particles", "that", "are", "active", "in", "the", "scene", ".", "In", "principle...
python
train
44.625
proycon/clam
clam/common/parameters.py
https://github.com/proycon/clam/blob/09d15cfc26d7cbe0f5976cdd5424dc446d10dbf3/clam/common/parameters.py#L212-L256
def fromxml(node): """Create a Parameter instance (of any class derived from AbstractParameter!) given its XML description. Node can be a string containing XML or an lxml _Element""" if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access node = ElementTree.parse(Stri...
[ "def", "fromxml", "(", "node", ")", ":", "if", "not", "isinstance", "(", "node", ",", "ElementTree", ".", "_Element", ")", ":", "#pylint: disable=protected-access", "node", "=", "ElementTree", ".", "parse", "(", "StringIO", "(", "node", ")", ")", ".", "get...
Create a Parameter instance (of any class derived from AbstractParameter!) given its XML description. Node can be a string containing XML or an lxml _Element
[ "Create", "a", "Parameter", "instance", "(", "of", "any", "class", "derived", "from", "AbstractParameter!", ")", "given", "its", "XML", "description", ".", "Node", "can", "be", "a", "string", "containing", "XML", "or", "an", "lxml", "_Element" ]
python
train
50.288889
pyviz/holoviews
holoviews/core/options.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/options.py#L515-L517
def cyclic(self): "Returns True if the options cycle, otherwise False" return any(isinstance(val, Cycle) for val in self.kwargs.values())
[ "def", "cyclic", "(", "self", ")", ":", "return", "any", "(", "isinstance", "(", "val", ",", "Cycle", ")", "for", "val", "in", "self", ".", "kwargs", ".", "values", "(", ")", ")" ]
Returns True if the options cycle, otherwise False
[ "Returns", "True", "if", "the", "options", "cycle", "otherwise", "False" ]
python
train
50.333333
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L1531-L1537
def nodePop(ctxt): """Pops the top element node from the node stack """ if ctxt is None: ctxt__o = None else: ctxt__o = ctxt._o ret = libxml2mod.nodePop(ctxt__o) if ret is None:raise treeError('nodePop() failed') return xmlNode(_obj=ret)
[ "def", "nodePop", "(", "ctxt", ")", ":", "if", "ctxt", "is", "None", ":", "ctxt__o", "=", "None", "else", ":", "ctxt__o", "=", "ctxt", ".", "_o", "ret", "=", "libxml2mod", ".", "nodePop", "(", "ctxt__o", ")", "if", "ret", "is", "None", ":", "raise"...
Pops the top element node from the node stack
[ "Pops", "the", "top", "element", "node", "from", "the", "node", "stack" ]
python
train
36.428571
dvdotsenko/jsonrpc.py
jsonrpcparts/serializers.py
https://github.com/dvdotsenko/jsonrpc.py/blob/19673edd77a9518ac5655bd407f6b93ffbb2cafc/jsonrpcparts/serializers.py#L57-L68
def json_loads(cls, s, **kwargs): """ A rewrap of json.loads done for one reason - to inject a custom `cls` kwarg :param s: :param kwargs: :return: :rtype: dict """ if 'cls' not in kwargs: kwargs['cls'] = cls.json_decoder return json.l...
[ "def", "json_loads", "(", "cls", ",", "s", ",", "*", "*", "kwargs", ")", ":", "if", "'cls'", "not", "in", "kwargs", ":", "kwargs", "[", "'cls'", "]", "=", "cls", ".", "json_decoder", "return", "json", ".", "loads", "(", "s", ",", "*", "*", "kwarg...
A rewrap of json.loads done for one reason - to inject a custom `cls` kwarg :param s: :param kwargs: :return: :rtype: dict
[ "A", "rewrap", "of", "json", ".", "loads", "done", "for", "one", "reason", "-", "to", "inject", "a", "custom", "cls", "kwarg" ]
python
train
27.166667
secynic/ipwhois
ipwhois/asn.py
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/asn.py#L772-L780
def _get_nets_radb(self, *args, **kwargs): """ Deprecated. This will be removed in a future release. """ from warnings import warn warn('ASNOrigin._get_nets_radb() has been deprecated and will be ' 'removed. You should now use ASNOrigin.get_nets_radb().') re...
[ "def", "_get_nets_radb", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "warnings", "import", "warn", "warn", "(", "'ASNOrigin._get_nets_radb() has been deprecated and will be '", "'removed. You should now use ASNOrigin.get_nets_radb().'", ")", ...
Deprecated. This will be removed in a future release.
[ "Deprecated", ".", "This", "will", "be", "removed", "in", "a", "future", "release", "." ]
python
train
39.111111
tyiannak/pyAudioAnalysis
pyAudioAnalysis/audioFeatureExtraction.py
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L74-L87
def stSpectralEntropy(X, n_short_blocks=10): """Computes the spectral entropy""" L = len(X) # number of frame samples Eol = numpy.sum(X ** 2) # total spectral energy sub_win_len = int(numpy.floor(L / n_short_blocks)) # length of sub-frame if L != sub_win_len * n...
[ "def", "stSpectralEntropy", "(", "X", ",", "n_short_blocks", "=", "10", ")", ":", "L", "=", "len", "(", "X", ")", "# number of frame samples", "Eol", "=", "numpy", ".", "sum", "(", "X", "**", "2", ")", "# total spectral energy", "sub_win_len", "=", "int", ...
Computes the spectral entropy
[ "Computes", "the", "spectral", "entropy" ]
python
train
50.857143
neithere/django-navigation
navigation/resolvers.py
https://github.com/neithere/django-navigation/blob/aff8d671a8431c84dde65cba6236ea8c16a08b4d/navigation/resolvers.py#L150-L184
def _resolve_by_callback(request, url, urlconf=None): """ Finds a view function by urlconf. If the function has attribute 'navigation', it is used as breadcrumb title. Such title can be either a callable or an object with `__unicode__` attribute. If it is callable, it must follow the views API (i.e....
[ "def", "_resolve_by_callback", "(", "request", ",", "url", ",", "urlconf", "=", "None", ")", ":", "try", ":", "callback", ",", "args", ",", "kwargs", "=", "_resolve_url", "(", "url", ",", "request", ",", "urlconf", "=", "urlconf", ")", "except", "urlreso...
Finds a view function by urlconf. If the function has attribute 'navigation', it is used as breadcrumb title. Such title can be either a callable or an object with `__unicode__` attribute. If it is callable, it must follow the views API (i.e. the only required argument is request object). It is also exp...
[ "Finds", "a", "view", "function", "by", "urlconf", ".", "If", "the", "function", "has", "attribute", "navigation", "it", "is", "used", "as", "breadcrumb", "title", ".", "Such", "title", "can", "be", "either", "a", "callable", "or", "an", "object", "with", ...
python
train
38.257143
abarker/pdfCropMargins
src/pdfCropMargins/calculate_bounding_boxes.py
https://github.com/abarker/pdfCropMargins/blob/55aca874613750ebf4ae69fd8851bdbb7696d6ac/src/pdfCropMargins/calculate_bounding_boxes.py#L99-L113
def correct_bounding_box_list_for_nonzero_origin(bbox_list, full_box_list): """The bounding box calculated from an image has coordinates relative to the lower-left point in the PDF being at zero. Similarly, Ghostscript reports a bounding box relative to a zero lower-left point. If the MediaBox (or full ...
[ "def", "correct_bounding_box_list_for_nonzero_origin", "(", "bbox_list", ",", "full_box_list", ")", ":", "corrected_box_list", "=", "[", "]", "for", "bbox", ",", "full_box", "in", "zip", "(", "bbox_list", ",", "full_box_list", ")", ":", "left_x", "=", "full_box", ...
The bounding box calculated from an image has coordinates relative to the lower-left point in the PDF being at zero. Similarly, Ghostscript reports a bounding box relative to a zero lower-left point. If the MediaBox (or full page box) has been shifted, like when cropping a previously cropped document,...
[ "The", "bounding", "box", "calculated", "from", "an", "image", "has", "coordinates", "relative", "to", "the", "lower", "-", "left", "point", "in", "the", "PDF", "being", "at", "zero", ".", "Similarly", "Ghostscript", "reports", "a", "bounding", "box", "relat...
python
train
52.866667
slarse/pdfebc-core
pdfebc_core/config_utils.py
https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L190-L203
def config_to_string(config): """Nice output string for the config, which is a nested defaultdict. Args: config (defaultdict(defaultdict)): The configuration information. Returns: str: A human-readable output string detailing the contents of the config. """ output = [] for secti...
[ "def", "config_to_string", "(", "config", ")", ":", "output", "=", "[", "]", "for", "section", ",", "section_content", "in", "config", ".", "items", "(", ")", ":", "output", ".", "append", "(", "\"[{}]\"", ".", "format", "(", "section", ")", ")", "for"...
Nice output string for the config, which is a nested defaultdict. Args: config (defaultdict(defaultdict)): The configuration information. Returns: str: A human-readable output string detailing the contents of the config.
[ "Nice", "output", "string", "for", "the", "config", "which", "is", "a", "nested", "defaultdict", "." ]
python
train
39.071429
csirtgadgets/bearded-avenger-sdk-py
cifsdk/utils/zhelper.py
https://github.com/csirtgadgets/bearded-avenger-sdk-py/blob/2b3e96cb2e7703ee0402811096da8265a740f378/cifsdk/utils/zhelper.py#L44-L70
def zthread_fork(ctx, func, *args, **kwargs): """ Create an attached thread. An attached thread gets a ctx and a PAIR pipe back to its parent. It must monitor its pipe, and exit if the pipe becomes unreadable. Returns pipe, or NULL if there was an error. """ a = ctx.socket(zmq.PAIR) a.setsoc...
[ "def", "zthread_fork", "(", "ctx", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "a", "=", "ctx", ".", "socket", "(", "zmq", ".", "PAIR", ")", "a", ".", "setsockopt", "(", "zmq", ".", "LINGER", ",", "0", ")", "a", ".", "se...
Create an attached thread. An attached thread gets a ctx and a PAIR pipe back to its parent. It must monitor its pipe, and exit if the pipe becomes unreadable. Returns pipe, or NULL if there was an error.
[ "Create", "an", "attached", "thread", ".", "An", "attached", "thread", "gets", "a", "ctx", "and", "a", "PAIR", "pipe", "back", "to", "its", "parent", ".", "It", "must", "monitor", "its", "pipe", "and", "exit", "if", "the", "pipe", "becomes", "unreadable"...
python
train
33.296296
cltl/KafNafParserPy
KafNafParserPy/KafNafParserMod.py
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/KafNafParserMod.py#L1133-L1140
def set_header(self,header): """ Sets the header of the object @type header: L{CHeader} @param header: the header object """ self.header = header self.root.insert(0,header.get_node())
[ "def", "set_header", "(", "self", ",", "header", ")", ":", "self", ".", "header", "=", "header", "self", ".", "root", ".", "insert", "(", "0", ",", "header", ".", "get_node", "(", ")", ")" ]
Sets the header of the object @type header: L{CHeader} @param header: the header object
[ "Sets", "the", "header", "of", "the", "object" ]
python
train
29
phoebe-project/phoebe2
phoebe/constraints/builtin.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/constraints/builtin.py#L145-L163
def requiv_to_pot_contact(requiv, q, sma, compno=1): """ :param requiv: user-provided equivalent radius :param q: mass ratio :param sma: semi-major axis (d = sma because we explicitly assume circular orbits for contacts) :param compno: 1 for primary, 2 for secondary :return: potential and fillou...
[ "def", "requiv_to_pot_contact", "(", "requiv", ",", "q", ",", "sma", ",", "compno", "=", "1", ")", ":", "logger", ".", "debug", "(", "\"requiv_to_pot_contact(requiv={}, q={}, sma={}, compno={})\"", ".", "format", "(", "requiv", ",", "q", ",", "sma", ",", "comp...
:param requiv: user-provided equivalent radius :param q: mass ratio :param sma: semi-major axis (d = sma because we explicitly assume circular orbits for contacts) :param compno: 1 for primary, 2 for secondary :return: potential and fillout factor
[ ":", "param", "requiv", ":", "user", "-", "provided", "equivalent", "radius", ":", "param", "q", ":", "mass", "ratio", ":", "param", "sma", ":", "semi", "-", "major", "axis", "(", "d", "=", "sma", "because", "we", "explicitly", "assume", "circular", "o...
python
train
48.368421
iwanbk/nyamuk
nyamuk/nyamuk.py
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L89-L95
def check_keepalive(self): """Send keepalive/PING if necessary.""" if self.sock != NC.INVALID_SOCKET and time.time() - self.last_msg_out >= self.keep_alive: if self.state == NC.CS_CONNECTED: self.send_pingreq() else: self.socket_close()
[ "def", "check_keepalive", "(", "self", ")", ":", "if", "self", ".", "sock", "!=", "NC", ".", "INVALID_SOCKET", "and", "time", ".", "time", "(", ")", "-", "self", ".", "last_msg_out", ">=", "self", ".", "keep_alive", ":", "if", "self", ".", "state", "...
Send keepalive/PING if necessary.
[ "Send", "keepalive", "/", "PING", "if", "necessary", "." ]
python
train
43.142857
bapakode/OmMongo
ommongo/query.py
https://github.com/bapakode/OmMongo/blob/52b5a5420516dc709f2d2eb065818c7973991ce3/ommongo/query.py#L381-L394
def query_bypass(self, query, raw_output=True): ''' Bypass query meaning that field check and validation is skipped, then query object directly executed by pymongo. :param raw_output: Skip OmMongo ORM layer (default: True) ''' if not isinstance(query, dict): rais...
[ "def", "query_bypass", "(", "self", ",", "query", ",", "raw_output", "=", "True", ")", ":", "if", "not", "isinstance", "(", "query", ",", "dict", ")", ":", "raise", "BadQueryException", "(", "'Query must be dict.'", ")", "self", ".", "__query", "=", "query...
Bypass query meaning that field check and validation is skipped, then query object directly executed by pymongo. :param raw_output: Skip OmMongo ORM layer (default: True)
[ "Bypass", "query", "meaning", "that", "field", "check", "and", "validation", "is", "skipped", "then", "query", "object", "directly", "executed", "by", "pymongo", ".", ":", "param", "raw_output", ":", "Skip", "OmMongo", "ORM", "layer", "(", "default", ":", "T...
python
train
37.714286
pytroll/pyspectral
rsr_convert_scripts/slstr_rsr.py
https://github.com/pytroll/pyspectral/blob/fd296c0e0bdf5364fa180134a1292665d6bc50a3/rsr_convert_scripts/slstr_rsr.py#L69-L79
def _load(self, scale=1.0): """Load the SLSTR relative spectral responses """ LOG.debug("File: %s", str(self.requested_band_filename)) ncf = Dataset(self.requested_band_filename, 'r') wvl = ncf.variables['wavelength'][:] * scale resp = ncf.variables['response'][:] ...
[ "def", "_load", "(", "self", ",", "scale", "=", "1.0", ")", ":", "LOG", ".", "debug", "(", "\"File: %s\"", ",", "str", "(", "self", ".", "requested_band_filename", ")", ")", "ncf", "=", "Dataset", "(", "self", ".", "requested_band_filename", ",", "'r'", ...
Load the SLSTR relative spectral responses
[ "Load", "the", "SLSTR", "relative", "spectral", "responses" ]
python
train
32.909091
deepmipt/DeepPavlov
deeppavlov/models/classifiers/utils.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/models/classifiers/utils.py#L77-L89
def proba2onehot(proba: [list, np.ndarray], confident_threshold: float, classes: [list, np.ndarray]) -> np.ndarray: """ Convert vectors of probabilities to one-hot representations using confident threshold Args: proba: samples where each sample is a vector of probabilities to belong with given cla...
[ "def", "proba2onehot", "(", "proba", ":", "[", "list", ",", "np", ".", "ndarray", "]", ",", "confident_threshold", ":", "float", ",", "classes", ":", "[", "list", ",", "np", ".", "ndarray", "]", ")", "->", "np", ".", "ndarray", ":", "return", "labels...
Convert vectors of probabilities to one-hot representations using confident threshold Args: proba: samples where each sample is a vector of probabilities to belong with given classes confident_threshold: boundary of probability to belong with a class classes: array of classes' names Re...
[ "Convert", "vectors", "of", "probabilities", "to", "one", "-", "hot", "representations", "using", "confident", "threshold" ]
python
test
46
ngmarchant/oasis
oasis/oasis.py
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/oasis.py#L115-L131
def update(self, ell, k): """Update the posterior and estimates after a label is sampled Parameters ---------- ell : int sampled label: 0 or 1 k : int index of stratum where label was sampled """ self.alpha_[k] += ell self.beta_[k...
[ "def", "update", "(", "self", ",", "ell", ",", "k", ")", ":", "self", ".", "alpha_", "[", "k", "]", "+=", "ell", "self", ".", "beta_", "[", "k", "]", "+=", "1", "-", "ell", "self", ".", "_calc_theta", "(", ")", "if", "self", ".", "store_varianc...
Update the posterior and estimates after a label is sampled Parameters ---------- ell : int sampled label: 0 or 1 k : int index of stratum where label was sampled
[ "Update", "the", "posterior", "and", "estimates", "after", "a", "label", "is", "sampled" ]
python
train
24.176471
zhmcclient/python-zhmcclient
zhmcclient_mock/_hmc.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient_mock/_hmc.py#L2995-L3020
def get_metric_group_definitions(self): """ Get the faked metric group definitions for this context object that are to be returned from its create operation. If a 'metric-groups' property had been specified for this context, only those faked metric group definitions of its manag...
[ "def", "get_metric_group_definitions", "(", "self", ")", ":", "group_names", "=", "self", ".", "properties", ".", "get", "(", "'metric-groups'", ",", "None", ")", "if", "not", "group_names", ":", "group_names", "=", "self", ".", "manager", ".", "get_metric_gro...
Get the faked metric group definitions for this context object that are to be returned from its create operation. If a 'metric-groups' property had been specified for this context, only those faked metric group definitions of its manager object that are in that list, are included in the...
[ "Get", "the", "faked", "metric", "group", "definitions", "for", "this", "context", "object", "that", "are", "to", "be", "returned", "from", "its", "create", "operation", "." ]
python
train
43.230769
noxdafox/clipspy
clips/classes.py
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L166-L185
def restore_instances(self, instances): """Restore a set of instances into the CLIPS data base. The Python equivalent of the CLIPS restore-instances command. Instances can be passed as a set of strings or as a file. """ instances = instances.encode() if os.path.exists...
[ "def", "restore_instances", "(", "self", ",", "instances", ")", ":", "instances", "=", "instances", ".", "encode", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "instances", ")", ":", "ret", "=", "lib", ".", "EnvRestoreInstances", "(", "self", ...
Restore a set of instances into the CLIPS data base. The Python equivalent of the CLIPS restore-instances command. Instances can be passed as a set of strings or as a file.
[ "Restore", "a", "set", "of", "instances", "into", "the", "CLIPS", "data", "base", "." ]
python
train
31.45
Opentrons/opentrons
api/src/opentrons/system/nmcli.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/system/nmcli.py#L595-L607
def sanitize_args(cmd: List[str]) -> List[str]: """ Filter the command so that it no longer contains passwords """ sanitized = [] for idx, fieldname in enumerate(cmd): def _is_password(cmdstr): return 'wifi-sec.psk' in cmdstr\ or 'password' in cmdstr.lower() i...
[ "def", "sanitize_args", "(", "cmd", ":", "List", "[", "str", "]", ")", "->", "List", "[", "str", "]", ":", "sanitized", "=", "[", "]", "for", "idx", ",", "fieldname", "in", "enumerate", "(", "cmd", ")", ":", "def", "_is_password", "(", "cmdstr", ")...
Filter the command so that it no longer contains passwords
[ "Filter", "the", "command", "so", "that", "it", "no", "longer", "contains", "passwords" ]
python
train
35.307692
geophysics-ubonn/reda
lib/reda/containers/sEIT.py
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/sEIT.py#L357-L419
def get_spectrum(self, nr_id=None, abmn=None, plot_filename=None): """Return a spectrum and its reciprocal counter part, if present in the dataset. Optimally, refer to the spectrum by its normal-reciprocal id. Returns ------- spectrum_nor : :py:class:`reda.eis.plots.sip_response...
[ "def", "get_spectrum", "(", "self", ",", "nr_id", "=", "None", ",", "abmn", "=", "None", ",", "plot_filename", "=", "None", ")", ":", "assert", "nr_id", "is", "None", "or", "abmn", "is", "None", "# determine nr_id for given abmn tuple", "if", "abmn", "is", ...
Return a spectrum and its reciprocal counter part, if present in the dataset. Optimally, refer to the spectrum by its normal-reciprocal id. Returns ------- spectrum_nor : :py:class:`reda.eis.plots.sip_response` Normal spectrum. None if no normal spectrum is available ...
[ "Return", "a", "spectrum", "and", "its", "reciprocal", "counter", "part", "if", "present", "in", "the", "dataset", ".", "Optimally", "refer", "to", "the", "spectrum", "by", "its", "normal", "-", "reciprocal", "id", "." ]
python
train
38.412698
krukas/Trionyx
trionyx/quickstart/__init__.py
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/quickstart/__init__.py#L30-L45
def create_project(self, project_path): """ Create Trionyx project in given path :param str path: path to create project in. :raises FileExistsError: """ shutil.copytree(self.project_path, project_path) self.update_file(project_path, 'requirements.txt', { ...
[ "def", "create_project", "(", "self", ",", "project_path", ")", ":", "shutil", ".", "copytree", "(", "self", ".", "project_path", ",", "project_path", ")", "self", ".", "update_file", "(", "project_path", ",", "'requirements.txt'", ",", "{", "'trionyx_version'",...
Create Trionyx project in given path :param str path: path to create project in. :raises FileExistsError:
[ "Create", "Trionyx", "project", "in", "given", "path" ]
python
train
30.6875
materialsproject/pymatgen-db
matgendb/query_engine.py
https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/query_engine.py#L451-L456
def query_one(self, *args, **kwargs): """Return first document from :meth:`query`, with same parameters. """ for r in self.query(*args, **kwargs): return r return None
[ "def", "query_one", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "r", "in", "self", ".", "query", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "r", "return", "None" ]
Return first document from :meth:`query`, with same parameters.
[ "Return", "first", "document", "from", ":", "meth", ":", "query", "with", "same", "parameters", "." ]
python
train
34.333333
PmagPy/PmagPy
programs/demag_gui.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/demag_gui.py#L3448-L3464
def recalculate_current_specimen_interpreatations(self): """ recalculates all interpretations on all specimens for all coordinate systems. Does not display recalcuated data. """ self.initialize_CART_rot(self.s) if str(self.s) in self.pmag_results_data['specimens']: ...
[ "def", "recalculate_current_specimen_interpreatations", "(", "self", ")", ":", "self", ".", "initialize_CART_rot", "(", "self", ".", "s", ")", "if", "str", "(", "self", ".", "s", ")", "in", "self", ".", "pmag_results_data", "[", "'specimens'", "]", ":", "for...
recalculates all interpretations on all specimens for all coordinate systems. Does not display recalcuated data.
[ "recalculates", "all", "interpretations", "on", "all", "specimens", "for", "all", "coordinate", "systems", ".", "Does", "not", "display", "recalcuated", "data", "." ]
python
train
80.294118
ambitioninc/django-entity
entity/sync.py
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L169-L176
def sync_entities_watching(instance): """ Syncs entities watching changes of a model instance. """ for entity_model, entity_model_getter in entity_registry.entity_watching[instance.__class__]: model_objs = list(entity_model_getter(instance)) if model_objs: sync_entities(*mode...
[ "def", "sync_entities_watching", "(", "instance", ")", ":", "for", "entity_model", ",", "entity_model_getter", "in", "entity_registry", ".", "entity_watching", "[", "instance", ".", "__class__", "]", ":", "model_objs", "=", "list", "(", "entity_model_getter", "(", ...
Syncs entities watching changes of a model instance.
[ "Syncs", "entities", "watching", "changes", "of", "a", "model", "instance", "." ]
python
train
40
StackStorm/pybind
pybind/nos/v6_0_2f/rbridge_id/interface/ve/ipv6/ipv6_local_anycast_gateway/ipv6_track/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/interface/ve/ipv6/ipv6_local_anycast_gateway/ipv6_track/__init__.py#L96-L117
def _set_ipv6_interface(self, v, load=False): """ Setter method for ipv6_interface, mapped from YANG variable /rbridge_id/interface/ve/ipv6/ipv6_local_anycast_gateway/ipv6_track/ipv6_interface (list) If this variable is read-only (config: false) in the source YANG file, then _set_ipv6_interface is consi...
[ "def", "_set_ipv6_interface", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", ...
Setter method for ipv6_interface, mapped from YANG variable /rbridge_id/interface/ve/ipv6/ipv6_local_anycast_gateway/ipv6_track/ipv6_interface (list) If this variable is read-only (config: false) in the source YANG file, then _set_ipv6_interface is considered as a private method. Backends looking to populat...
[ "Setter", "method", "for", "ipv6_interface", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "interface", "/", "ve", "/", "ipv6", "/", "ipv6_local_anycast_gateway", "/", "ipv6_track", "/", "ipv6_interface", "(", "list", ")", "If", "this", "variable...
python
train
140.636364
saltstack/salt
salt/modules/riak.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/riak.py#L52-L74
def stop(): ''' Stop Riak .. versionchanged:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' riak.stop ''' ret = {'comment': '', 'success': False} cmd = __execute_cmd('riak', 'stop') if cmd['retcode'] != 0: ret['comment'] = cmd['stderr'] else: r...
[ "def", "stop", "(", ")", ":", "ret", "=", "{", "'comment'", ":", "''", ",", "'success'", ":", "False", "}", "cmd", "=", "__execute_cmd", "(", "'riak'", ",", "'stop'", ")", "if", "cmd", "[", "'retcode'", "]", "!=", "0", ":", "ret", "[", "'comment'",...
Stop Riak .. versionchanged:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' riak.stop
[ "Stop", "Riak" ]
python
train
16.217391
mardix/pylot
pylot/component/views.py
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/component/views.py#L1080-L1254
def user_admin_view(model, login_view="Login", template_dir=None): """ :param UserStruct: The User model structure containing other classes :param login_view: The login view interface :param template_dir: The directory containing the view pages :return: UserAdmin Doc: User Admin is a view t...
[ "def", "user_admin_view", "(", "model", ",", "login_view", "=", "\"Login\"", ",", "template_dir", "=", "None", ")", ":", "Pylot", ".", "context_", "(", "COMPONENT_USER_ADMIN", "=", "True", ")", "User", "=", "model", ".", "UserStruct", ".", "User", "LoginView...
:param UserStruct: The User model structure containing other classes :param login_view: The login view interface :param template_dir: The directory containing the view pages :return: UserAdmin Doc: User Admin is a view that allows you to admin users. You must create a Pylot view called `UserAdm...
[ ":", "param", "UserStruct", ":", "The", "User", "model", "structure", "containing", "other", "classes", ":", "param", "login_view", ":", "The", "login", "view", "interface", ":", "param", "template_dir", ":", "The", "directory", "containing", "the", "view", "p...
python
train
36.251429
CellProfiler/centrosome
centrosome/cpmorphology.py
https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L1381-L1706
def minimum_enclosing_circle(labels, indexes = None, hull_and_point_count = None): """Find the location of the minimum enclosing circle and its radius labels - a labels matrix indexes - an array giving the label indexes to be processed hull_and_point_count - convex_hul...
[ "def", "minimum_enclosing_circle", "(", "labels", ",", "indexes", "=", "None", ",", "hull_and_point_count", "=", "None", ")", ":", "if", "indexes", "is", "None", ":", "if", "hull_and_point_count", "is", "not", "None", ":", "indexes", "=", "np", ".", "array",...
Find the location of the minimum enclosing circle and its radius labels - a labels matrix indexes - an array giving the label indexes to be processed hull_and_point_count - convex_hull output if already done. None = calculate returns an Nx3 array organized as i,j of the center and radius A...
[ "Find", "the", "location", "of", "the", "minimum", "enclosing", "circle", "and", "its", "radius", "labels", "-", "a", "labels", "matrix", "indexes", "-", "an", "array", "giving", "the", "label", "indexes", "to", "be", "processed", "hull_and_point_count", "-", ...
python
train
43.98773
quasipedia/simpleactors
simpleactors.py
https://github.com/quasipedia/simpleactors/blob/4253da2d10b3df080b5e7b3fbee03aa6dd10db07/simpleactors.py#L84-L92
def unplug(self): '''Remove the actor's methods from the callback registry.''' if not self.__plugged: return members = set([method for _, method in inspect.getmembers(self, predicate=inspect.ismethod)]) for message in global_callbacks: global...
[ "def", "unplug", "(", "self", ")", ":", "if", "not", "self", ".", "__plugged", ":", "return", "members", "=", "set", "(", "[", "method", "for", "_", ",", "method", "in", "inspect", ".", "getmembers", "(", "self", ",", "predicate", "=", "inspect", "."...
Remove the actor's methods from the callback registry.
[ "Remove", "the", "actor", "s", "methods", "from", "the", "callback", "registry", "." ]
python
train
41.444444
maciejkula/glove-python
glove/metrics/accuracy.py
https://github.com/maciejkula/glove-python/blob/749494290fdfd24379dcc2e244c583ee61808634/glove/metrics/accuracy.py#L10-L25
def read_analogy_file(filename): """ Read the analogy task test set from a file. """ section = None with open(filename, 'r') as questions_file: for line in questions_file: if line.startswith(':'): section = line[2:].replace('\n', '') continue...
[ "def", "read_analogy_file", "(", "filename", ")", ":", "section", "=", "None", "with", "open", "(", "filename", ",", "'r'", ")", "as", "questions_file", ":", "for", "line", "in", "questions_file", ":", "if", "line", ".", "startswith", "(", "':'", ")", ":...
Read the analogy task test set from a file.
[ "Read", "the", "analogy", "task", "test", "set", "from", "a", "file", "." ]
python
train
25.9375
vtkiorg/vtki
vtki/export.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/export.py#L217-L225
def dump_t_coords(dataset_dir, data_dir, dataset, root=None, compress=True): """dump vtkjs texture coordinates""" if root is None: root = {} tcoords = dataset.GetPointData().GetTCoords() if tcoords: dumped_array = dump_data_array(dataset_dir, data_dir, tcoords, {}, compress) root...
[ "def", "dump_t_coords", "(", "dataset_dir", ",", "data_dir", ",", "dataset", ",", "root", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "root", "is", "None", ":", "root", "=", "{", "}", "tcoords", "=", "dataset", ".", "GetPointData", "(", ...
dump vtkjs texture coordinates
[ "dump", "vtkjs", "texture", "coordinates" ]
python
train
49.333333
rueckstiess/mtools
mtools/util/logfile.py
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logfile.py#L166-L172
def versions(self): """Return all version changes.""" versions = [] for v, _ in self.restarts: if len(versions) == 0 or v != versions[-1]: versions.append(v) return versions
[ "def", "versions", "(", "self", ")", ":", "versions", "=", "[", "]", "for", "v", ",", "_", "in", "self", ".", "restarts", ":", "if", "len", "(", "versions", ")", "==", "0", "or", "v", "!=", "versions", "[", "-", "1", "]", ":", "versions", ".", ...
Return all version changes.
[ "Return", "all", "version", "changes", "." ]
python
train
32.428571
tonyfischetti/sake
sakelib/acts.py
https://github.com/tonyfischetti/sake/blob/b7ad20fe8e7137db99a20ac06b8da26492601b00/sakelib/acts.py#L409-L431
def get_ties(G): """ If you specify a target that shares a dependency with another target, both targets need to be updated. This is because running one will resolve the sha mismatch and sake will think that the other one doesn't have to run. This is called a "tie". This function will find such ties....
[ "def", "get_ties", "(", "G", ")", ":", "# we are going to make a dictionary whose keys are every dependency", "# and whose values are a list of all targets that use that dependency.", "# after making the dictionary, values whose length is above one will", "# be called \"ties\"", "ties", "=", ...
If you specify a target that shares a dependency with another target, both targets need to be updated. This is because running one will resolve the sha mismatch and sake will think that the other one doesn't have to run. This is called a "tie". This function will find such ties.
[ "If", "you", "specify", "a", "target", "that", "shares", "a", "dependency", "with", "another", "target", "both", "targets", "need", "to", "be", "updated", ".", "This", "is", "because", "running", "one", "will", "resolve", "the", "sha", "mismatch", "and", "...
python
valid
42.26087
Deisss/python-sockjsroom
sockjsroom/socketHandler.py
https://github.com/Deisss/python-sockjsroom/blob/7c20187571d39e7fede848dc98f954235ca77241/sockjsroom/socketHandler.py#L61-L65
def join(self, _id): """ Join a room """ if not SockJSRoomHandler._room.has_key(self._gcls() + _id): SockJSRoomHandler._room[self._gcls() + _id] = set() SockJSRoomHandler._room[self._gcls() + _id].add(self)
[ "def", "join", "(", "self", ",", "_id", ")", ":", "if", "not", "SockJSRoomHandler", ".", "_room", ".", "has_key", "(", "self", ".", "_gcls", "(", ")", "+", "_id", ")", ":", "SockJSRoomHandler", ".", "_room", "[", "self", ".", "_gcls", "(", ")", "+"...
Join a room
[ "Join", "a", "room" ]
python
train
47.6
androguard/androguard
androguard/session.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/session.py#L208-L246
def addDEX(self, filename, data, dx=None): """ Add a DEX file to the Session and run analysis. :param filename: the (file)name of the DEX file :param data: binary data of the dex file :param dx: an existing Analysis Object (optional) :return: A tuple of SHA256 Hash, Dalv...
[ "def", "addDEX", "(", "self", ",", "filename", ",", "data", ",", "dx", "=", "None", ")", ":", "digest", "=", "hashlib", ".", "sha256", "(", "data", ")", ".", "hexdigest", "(", ")", "log", ".", "debug", "(", "\"add DEX:%s\"", "%", "digest", ")", "lo...
Add a DEX file to the Session and run analysis. :param filename: the (file)name of the DEX file :param data: binary data of the dex file :param dx: an existing Analysis Object (optional) :return: A tuple of SHA256 Hash, DalvikVMFormat Object and Analysis object
[ "Add", "a", "DEX", "file", "to", "the", "Session", "and", "run", "analysis", "." ]
python
train
31.025641
saltstack/salt
salt/modules/ipset.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipset.py#L320-L378
def add(setname=None, entry=None, family='ipv4', **kwargs): ''' Append an entry to the specified set. CLI Example: .. code-block:: bash salt '*' ipset.add setname 192.168.1.26 salt '*' ipset.add setname 192.168.0.3,AA:BB:CC:DD:EE:FF ''' if not setname: return 'Error:...
[ "def", "add", "(", "setname", "=", "None", ",", "entry", "=", "None", ",", "family", "=", "'ipv4'", ",", "*", "*", "kwargs", ")", ":", "if", "not", "setname", ":", "return", "'Error: Set needs to be specified'", "if", "not", "entry", ":", "return", "'Err...
Append an entry to the specified set. CLI Example: .. code-block:: bash salt '*' ipset.add setname 192.168.1.26 salt '*' ipset.add setname 192.168.0.3,AA:BB:CC:DD:EE:FF
[ "Append", "an", "entry", "to", "the", "specified", "set", "." ]
python
train
32.474576
iotile/coretools
iotilesensorgraph/iotile/sg/node_descriptor.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/node_descriptor.py#L241-L266
def _create_binary_trigger(trigger): """Create an 8-bit binary trigger from an InputTrigger, TrueTrigger, FalseTrigger.""" ops = { 0: ">", 1: "<", 2: ">=", 3: "<=", 4: "==", 5: 'always' } op_codes = {y: x for x, y in ops.items()} source = 0 if i...
[ "def", "_create_binary_trigger", "(", "trigger", ")", ":", "ops", "=", "{", "0", ":", "\">\"", ",", "1", ":", "\"<\"", ",", "2", ":", "\">=\"", ",", "3", ":", "\"<=\"", ",", "4", ":", "\"==\"", ",", "5", ":", "'always'", "}", "op_codes", "=", "{"...
Create an 8-bit binary trigger from an InputTrigger, TrueTrigger, FalseTrigger.
[ "Create", "an", "8", "-", "bit", "binary", "trigger", "from", "an", "InputTrigger", "TrueTrigger", "FalseTrigger", "." ]
python
train
25.230769
neon-jungle/wagtailnews
wagtailnews/views/editor.py
https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/views/editor.py#L225-L268
def build_dummy_request(newsitem): """ Construct a HttpRequest object that is, as far as possible, representative of ones that would receive this page as a response. Used for previewing / moderation and any other place where we want to display a view of this page in the admin interface without going...
[ "def", "build_dummy_request", "(", "newsitem", ")", ":", "url", "=", "newsitem", ".", "full_url", "if", "url", ":", "url_info", "=", "urlparse", "(", "url", ")", "hostname", "=", "url_info", ".", "hostname", "path", "=", "url_info", ".", "path", "port", ...
Construct a HttpRequest object that is, as far as possible, representative of ones that would receive this page as a response. Used for previewing / moderation and any other place where we want to display a view of this page in the admin interface without going through the regular page routing logic.
[ "Construct", "a", "HttpRequest", "object", "that", "is", "as", "far", "as", "possible", "representative", "of", "ones", "that", "would", "receive", "this", "page", "as", "a", "response", ".", "Used", "for", "previewing", "/", "moderation", "and", "any", "oth...
python
train
34.045455
eventable/vobject
docs/build/lib/vobject/icalendar.py
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/icalendar.py#L1929-L1951
def tzinfo_eq(tzinfo1, tzinfo2, startYear = 2000, endYear=2020): """ Compare offsets and DST transitions from startYear to endYear. """ if tzinfo1 == tzinfo2: return True elif tzinfo1 is None or tzinfo2 is None: return False def dt_test(dt): if dt is None: re...
[ "def", "tzinfo_eq", "(", "tzinfo1", ",", "tzinfo2", ",", "startYear", "=", "2000", ",", "endYear", "=", "2020", ")", ":", "if", "tzinfo1", "==", "tzinfo2", ":", "return", "True", "elif", "tzinfo1", "is", "None", "or", "tzinfo2", "is", "None", ":", "ret...
Compare offsets and DST transitions from startYear to endYear.
[ "Compare", "offsets", "and", "DST", "transitions", "from", "startYear", "to", "endYear", "." ]
python
train
32.478261
tonybaloney/wily
wily/operators/__init__.py
https://github.com/tonybaloney/wily/blob/bae259354a91b57d56603f0ca7403186f086a84c/wily/operators/__init__.py#L170-L188
def resolve_metric_as_tuple(metric): """ Resolve metric key to a given target. :param metric: the metric name. :type metric: ``str`` :rtype: :class:`Metric` """ if "." in metric: _, metric = metric.split(".") r = [ (operator, match) for operator, match in ALL_METRICS ...
[ "def", "resolve_metric_as_tuple", "(", "metric", ")", ":", "if", "\".\"", "in", "metric", ":", "_", ",", "metric", "=", "metric", ".", "split", "(", "\".\"", ")", "r", "=", "[", "(", "operator", ",", "match", ")", "for", "operator", ",", "match", "in...
Resolve metric key to a given target. :param metric: the metric name. :type metric: ``str`` :rtype: :class:`Metric`
[ "Resolve", "metric", "key", "to", "a", "given", "target", "." ]
python
train
23.631579
saltstack/salt
salt/version.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/version.py#L707-L717
def versions_information(include_salt_cloud=False): ''' Report the versions of dependent software. ''' salt_info = list(salt_information()) lib_info = list(dependency_information(include_salt_cloud)) sys_info = list(system_information()) return {'Salt Version': dict(salt_info), ...
[ "def", "versions_information", "(", "include_salt_cloud", "=", "False", ")", ":", "salt_info", "=", "list", "(", "salt_information", "(", ")", ")", "lib_info", "=", "list", "(", "dependency_information", "(", "include_salt_cloud", ")", ")", "sys_info", "=", "lis...
Report the versions of dependent software.
[ "Report", "the", "versions", "of", "dependent", "software", "." ]
python
train
35.909091
Rapptz/discord.py
discord/colour.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/colour.py#L110-L113
def from_hsv(cls, h, s, v): """Constructs a :class:`Colour` from an HSV tuple.""" rgb = colorsys.hsv_to_rgb(h, s, v) return cls.from_rgb(*(int(x * 255) for x in rgb))
[ "def", "from_hsv", "(", "cls", ",", "h", ",", "s", ",", "v", ")", ":", "rgb", "=", "colorsys", ".", "hsv_to_rgb", "(", "h", ",", "s", ",", "v", ")", "return", "cls", ".", "from_rgb", "(", "*", "(", "int", "(", "x", "*", "255", ")", "for", "...
Constructs a :class:`Colour` from an HSV tuple.
[ "Constructs", "a", ":", "class", ":", "Colour", "from", "an", "HSV", "tuple", "." ]
python
train
46.75
ynop/audiomate
audiomate/utils/naming.py
https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/naming.py#L33-L49
def generate_name(length=15, not_in=None): """ Generates a random string of lowercase letters with the given length. Parameters: length (int): Length of the string to output. not_in (list): Only return a string not in the given iterator. Returns: str: A new name thats not in th...
[ "def", "generate_name", "(", "length", "=", "15", ",", "not_in", "=", "None", ")", ":", "value", "=", "''", ".", "join", "(", "random", ".", "choice", "(", "string", ".", "ascii_lowercase", ")", "for", "i", "in", "range", "(", "length", ")", ")", "...
Generates a random string of lowercase letters with the given length. Parameters: length (int): Length of the string to output. not_in (list): Only return a string not in the given iterator. Returns: str: A new name thats not in the given list.
[ "Generates", "a", "random", "string", "of", "lowercase", "letters", "with", "the", "given", "length", "." ]
python
train
33.294118
Microsoft/botbuilder-python
libraries/botbuilder-dialogs/botbuilder/dialogs/dialog.py
https://github.com/Microsoft/botbuilder-python/blob/274663dd91c811bae6ac4488915ba5880771b0a7/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog.py#L33-L40
def telemetry_client(self, value: BotTelemetryClient) -> None: """ Sets the telemetry client for logging events. """ if value is None: self._telemetry_client = NullTelemetryClient() else: self._telemetry_client = value
[ "def", "telemetry_client", "(", "self", ",", "value", ":", "BotTelemetryClient", ")", "->", "None", ":", "if", "value", "is", "None", ":", "self", ".", "_telemetry_client", "=", "NullTelemetryClient", "(", ")", "else", ":", "self", ".", "_telemetry_client", ...
Sets the telemetry client for logging events.
[ "Sets", "the", "telemetry", "client", "for", "logging", "events", "." ]
python
test
34.375
agile4you/bottle-neck
bottle_neck/routing.py
https://github.com/agile4you/bottle-neck/blob/ebc670a4b178255473d68e9b4122ba04e38f4810/bottle_neck/routing.py#L38-L61
def wrap_callable(cls, uri, methods, callable_obj): """Wraps function-based callable_obj into a `Route` instance, else proxies a `bottle_neck.handlers.BaseHandler` subclass instance. Args: uri (str): The uri relative path. methods (tuple): A tuple of valid method string...
[ "def", "wrap_callable", "(", "cls", ",", "uri", ",", "methods", ",", "callable_obj", ")", ":", "if", "isinstance", "(", "callable_obj", ",", "HandlerMeta", ")", ":", "callable_obj", ".", "base_endpoint", "=", "uri", "callable_obj", ".", "is_valid", "=", "Tru...
Wraps function-based callable_obj into a `Route` instance, else proxies a `bottle_neck.handlers.BaseHandler` subclass instance. Args: uri (str): The uri relative path. methods (tuple): A tuple of valid method strings. callable_obj (instance): The callable object. ...
[ "Wraps", "function", "-", "based", "callable_obj", "into", "a", "Route", "instance", "else", "proxies", "a", "bottle_neck", ".", "handlers", ".", "BaseHandler", "subclass", "instance", "." ]
python
train
35.166667
ultrabug/py3status
py3status/docstrings.py
https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/docstrings.py#L10-L14
def modules_directory(): """ Get the core modules directory. """ return os.path.join(os.path.dirname(os.path.abspath(__file__)), "modules")
[ "def", "modules_directory", "(", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "\"modules\"", ")" ]
Get the core modules directory.
[ "Get", "the", "core", "modules", "directory", "." ]
python
train
30.2
iotile/coretools
iotilebuild/iotile/build/utilities/bundled_data.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/utilities/bundled_data.py#L22-L65
def resource_path(relative_path=None, expect=None): """Return the absolute path to a resource in iotile-build. This method finds the path to the `config` folder inside iotile-build, appends `relative_path` to it and then checks to make sure the desired file or directory exists. You can specify exp...
[ "def", "resource_path", "(", "relative_path", "=", "None", ",", "expect", "=", "None", ")", ":", "if", "expect", "not", "in", "(", "None", ",", "'file'", ",", "'folder'", ")", ":", "raise", "ArgumentError", "(", "\"Invalid expect parameter, must be None, 'file' ...
Return the absolute path to a resource in iotile-build. This method finds the path to the `config` folder inside iotile-build, appends `relative_path` to it and then checks to make sure the desired file or directory exists. You can specify expect=(None, 'file', or 'folder') for what you expect to ...
[ "Return", "the", "absolute", "path", "to", "a", "resource", "in", "iotile", "-", "build", "." ]
python
train
42.659091
clchiou/startup
startup.py
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L224-L236
def _get_not_annotated(func, annotations=None): """Return non-optional parameters that are not annotated.""" argspec = inspect.getfullargspec(func) args = argspec.args if argspec.defaults is not None: args = args[:-len(argspec.defaults)] if inspect.isclass(func) or inspect.ismethod(func): ...
[ "def", "_get_not_annotated", "(", "func", ",", "annotations", "=", "None", ")", ":", "argspec", "=", "inspect", ".", "getfullargspec", "(", "func", ")", "args", "=", "argspec", ".", "args", "if", "argspec", ".", "defaults", "is", "not", "None", ":", "arg...
Return non-optional parameters that are not annotated.
[ "Return", "non", "-", "optional", "parameters", "that", "are", "not", "annotated", "." ]
python
train
48.461538
citruz/beacontools
beacontools/packet_types/estimote.py
https://github.com/citruz/beacontools/blob/15a83e9750d0a4393f8a36868e07f6d9458253fe/beacontools/packet_types/estimote.py#L46-L59
def parse_motion_state(val): """Convert motion state byte to seconds.""" number = val & 0b00111111 unit = (val & 0b11000000) >> 6 if unit == 1: number *= 60 # minutes elif unit == 2: number *= 60 * 60 # hours elif unit == 3 and number < 32: ...
[ "def", "parse_motion_state", "(", "val", ")", ":", "number", "=", "val", "&", "0b00111111", "unit", "=", "(", "val", "&", "0b11000000", ")", ">>", "6", "if", "unit", "==", "1", ":", "number", "*=", "60", "# minutes", "elif", "unit", "==", "2", ":", ...
Convert motion state byte to seconds.
[ "Convert", "motion", "state", "byte", "to", "seconds", "." ]
python
train
32.785714
hydpy-dev/hydpy
hydpy/core/sequencetools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/sequencetools.py#L1523-L1538
def old(self): """Assess to the state value(s) at beginning of the time step, which has been processed most recently. When using *HydPy* in the normal manner. But it can be helpful for demonstration and debugging purposes. """ value = getattr(self.fastaccess_old, self.n...
[ "def", "old", "(", "self", ")", ":", "value", "=", "getattr", "(", "self", ".", "fastaccess_old", ",", "self", ".", "name", ",", "None", ")", "if", "value", "is", "None", ":", "raise", "RuntimeError", "(", "'No value/values of sequence %s has/have '", "'not ...
Assess to the state value(s) at beginning of the time step, which has been processed most recently. When using *HydPy* in the normal manner. But it can be helpful for demonstration and debugging purposes.
[ "Assess", "to", "the", "state", "value", "(", "s", ")", "at", "beginning", "of", "the", "time", "step", "which", "has", "been", "processed", "most", "recently", ".", "When", "using", "*", "HydPy", "*", "in", "the", "normal", "manner", ".", "But", "it",...
python
train
39.75
bram85/topydo
topydo/lib/ListFormat.py
https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/ListFormat.py#L268-L307
def parse(self, p_todo): """ Returns fully parsed string from 'format_string' attribute with all placeholders properly substituted by content obtained from p_todo. It uses preprocessed form of 'format_string' (result of ListFormatParser._preprocess_format) stored in 'format_list...
[ "def", "parse", "(", "self", ",", "p_todo", ")", ":", "parsed_list", "=", "[", "]", "repl_trunc", "=", "None", "for", "substr", ",", "placeholder", ",", "getter", "in", "self", ".", "format_list", ":", "repl", "=", "getter", "(", "p_todo", ")", "if", ...
Returns fully parsed string from 'format_string' attribute with all placeholders properly substituted by content obtained from p_todo. It uses preprocessed form of 'format_string' (result of ListFormatParser._preprocess_format) stored in 'format_list' attribute.
[ "Returns", "fully", "parsed", "string", "from", "format_string", "attribute", "with", "all", "placeholders", "properly", "substituted", "by", "content", "obtained", "from", "p_todo", "." ]
python
train
35.225
saltstack/salt
salt/modules/consul.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/consul.py#L1364-L1403
def session_info(consul_url=None, token=None, session=None, **kwargs): ''' Information about a session :param consul_url: The Consul server URL. :param session: The ID of the session to return information about. :param dc: By default, the datacenter of the agent is queried; however, ...
[ "def", "session_info", "(", "consul_url", "=", "None", ",", "token", "=", "None", ",", "session", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "}", "if", "not", "consul_url", ":", "consul_url", "=", "_get_config", "(", ")", "if", ...
Information about a session :param consul_url: The Consul server URL. :param session: The ID of the session to return information about. :param dc: By default, the datacenter of the agent is queried; however, the dc can be provided using the "dc" parameter. :return: Boolean & message of ...
[ "Information", "about", "a", "session" ]
python
train
29.35
hazelcast/hazelcast-python-client
hazelcast/proxy/pn_counter.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/pn_counter.py#L91-L103
def add_and_get(self, delta): """ Adds the given value to the current value and returns the updated value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises C...
[ "def", "add_and_get", "(", "self", ",", "delta", ")", ":", "return", "self", ".", "_invoke_internal", "(", "pn_counter_add_codec", ",", "delta", "=", "delta", ",", "get_before_update", "=", "False", ")" ]
Adds the given value to the current value and returns the updated value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises ConsistencyLostError: if the session guarantees hav...
[ "Adds", "the", "given", "value", "to", "the", "current", "value", "and", "returns", "the", "updated", "value", "." ]
python
train
43.923077
lexich/yandex-disk-webdav
yandexwebdav.py
https://github.com/lexich/yandex-disk-webdav/blob/669f51f999ed14e137454b90e7d035e2ca171c75/yandexwebdav.py#L192-L202
def getHeaders(self): """ Get common headers :return: """ basicauth = base64.encodestring(b(self.user + ':' + self.password)).strip() return { "Depth": "1", "Authorization": 'Basic ' + _decode_utf8(basicauth), "Accept": "*/*" }
[ "def", "getHeaders", "(", "self", ")", ":", "basicauth", "=", "base64", ".", "encodestring", "(", "b", "(", "self", ".", "user", "+", "':'", "+", "self", ".", "password", ")", ")", ".", "strip", "(", ")", "return", "{", "\"Depth\"", ":", "\"1\"", "...
Get common headers :return:
[ "Get", "common", "headers", ":", "return", ":" ]
python
train
28.090909
liampauling/betfair
betfairlightweight/filters.py
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/filters.py#L163-L185
def place_instruction(order_type, selection_id, side, handicap=None, limit_order=None, limit_on_close_order=None, market_on_close_order=None, customer_order_ref=None): """ Create order instructions to place an order at exchange. :param str order_type: define type of order to place. ...
[ "def", "place_instruction", "(", "order_type", ",", "selection_id", ",", "side", ",", "handicap", "=", "None", ",", "limit_order", "=", "None", ",", "limit_on_close_order", "=", "None", ",", "market_on_close_order", "=", "None", ",", "customer_order_ref", "=", "...
Create order instructions to place an order at exchange. :param str order_type: define type of order to place. :param int selection_id: selection on which to place order :param float handicap: handicap if placing order on asianhandicap type market :param str side: side of order :param resources.Limi...
[ "Create", "order", "instructions", "to", "place", "an", "order", "at", "exchange", ".", ":", "param", "str", "order_type", ":", "define", "type", "of", "order", "to", "place", ".", ":", "param", "int", "selection_id", ":", "selection", "on", "which", "to",...
python
train
48.565217
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/apiextensions_v1beta1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/apiextensions_v1beta1_api.py#L715-L738
def patch_custom_resource_definition_status(self, name, body, **kwargs): # noqa: E501 """patch_custom_resource_definition_status # noqa: E501 partially update status of the specified CustomResourceDefinition # noqa: E501 This method makes a synchronous HTTP request by default. To make an ...
[ "def", "patch_custom_resource_definition_status", "(", "self", ",", "name", ",", "body", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", ...
patch_custom_resource_definition_status # noqa: E501 partially update status of the specified CustomResourceDefinition # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.patch_custom_r...
[ "patch_custom_resource_definition_status", "#", "noqa", ":", "E501" ]
python
train
62.625
ewels/MultiQC
multiqc/modules/bismark/bismark.py
https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/bismark/bismark.py#L186-L232
def parse_bismark_mbias(self, f): """ Parse the Bismark M-Bias plot data """ s = f['s_name'] self.bismark_mbias_data['meth']['CpG_R1'][s] = {} self.bismark_mbias_data['meth']['CHG_R1'][s] = {} self.bismark_mbias_data['meth']['CHH_R1'][s] = {} self.bismark_mbias_data['cov'...
[ "def", "parse_bismark_mbias", "(", "self", ",", "f", ")", ":", "s", "=", "f", "[", "'s_name'", "]", "self", ".", "bismark_mbias_data", "[", "'meth'", "]", "[", "'CpG_R1'", "]", "[", "s", "]", "=", "{", "}", "self", ".", "bismark_mbias_data", "[", "'m...
Parse the Bismark M-Bias plot data
[ "Parse", "the", "Bismark", "M", "-", "Bias", "plot", "data" ]
python
train
42.489362
googleapis/oauth2client
oauth2client/transport.py
https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/transport.py#L204-L251
def wrap_http_for_jwt_access(credentials, http): """Prepares an HTTP object's request method for JWT access. Wraps HTTP requests with logic to catch auth failures (typically identified via a 401 status code). In the event of failure, tries to refresh the token used and then retry the original request. ...
[ "def", "wrap_http_for_jwt_access", "(", "credentials", ",", "http", ")", ":", "orig_request_method", "=", "http", ".", "request", "wrap_http_for_auth", "(", "credentials", ",", "http", ")", "# The new value of ``http.request`` set by ``wrap_http_for_auth``.", "authenticated_r...
Prepares an HTTP object's request method for JWT access. Wraps HTTP requests with logic to catch auth failures (typically identified via a 401 status code). In the event of failure, tries to refresh the token used and then retry the original request. Args: credentials: _JWTAccessCredentials, t...
[ "Prepares", "an", "HTTP", "object", "s", "request", "method", "for", "JWT", "access", "." ]
python
valid
45.75
vnmabus/dcor
dcor/distances.py
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L92-L149
def pairwise_distances(x, y=None, **kwargs): r""" pairwise_distances(x, y=None, *, exponent=1) Pairwise distance between points. Return the pairwise distance between points in two sets, or in the same set if only one set is passed. Parameters ---------- x: array_like An :math:...
[ "def", "pairwise_distances", "(", "x", ",", "y", "=", "None", ",", "*", "*", "kwargs", ")", ":", "x", "=", "_transform_to_2d", "(", "x", ")", "if", "y", "is", "None", "or", "y", "is", "x", ":", "return", "_pdist", "(", "x", ",", "*", "*", "kwar...
r""" pairwise_distances(x, y=None, *, exponent=1) Pairwise distance between points. Return the pairwise distance between points in two sets, or in the same set if only one set is passed. Parameters ---------- x: array_like An :math:`n \times m` array of :math:`n` observations in ...
[ "r", "pairwise_distances", "(", "x", "y", "=", "None", "*", "exponent", "=", "1", ")" ]
python
train
31.689655