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
emory-libraries/eulfedora
eulfedora/api.py
https://github.com/emory-libraries/eulfedora/blob/161826f3fdcdab4007f6fa7dfd9f1ecabc4bcbe4/eulfedora/api.py#L293-L308
def listMethods(self, pid, sdefpid=None): '''List available service methods. :param pid: object pid :param sDefPid: service definition pid :rtype: :class:`requests.models.Response` ''' # /objects/{pid}/methods ? [format, datetime] # /objects/{pid}/methods/{sdefpi...
[ "def", "listMethods", "(", "self", ",", "pid", ",", "sdefpid", "=", "None", ")", ":", "# /objects/{pid}/methods ? [format, datetime]", "# /objects/{pid}/methods/{sdefpid} ? [format, datetime]", "## NOTE: getting an error when sdefpid is specified; fedora issue?", "uri", "=", "'obje...
List available service methods. :param pid: object pid :param sDefPid: service definition pid :rtype: :class:`requests.models.Response`
[ "List", "available", "service", "methods", "." ]
python
train
35.375
mgaitan/waliki
waliki/acl.py
https://github.com/mgaitan/waliki/blob/5baaf6f043275920a1174ff233726f7ff4bfb5cf/waliki/acl.py#L48-L87
def permission_required(perms, login_url=None, raise_exception=False, redirect_field_name=REDIRECT_FIELD_NAME): """ this is analog to django's builtin ``permission_required`` decorator, but improved to check per slug ACLRules and default permissions for anonymous and logged in users if there is a r...
[ "def", "permission_required", "(", "perms", ",", "login_url", "=", "None", ",", "raise_exception", "=", "False", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ")", ":", "def", "decorator", "(", "view_func", ")", ":", "@", "wraps", "(", "view_func", "...
this is analog to django's builtin ``permission_required`` decorator, but improved to check per slug ACLRules and default permissions for anonymous and logged in users if there is a rule affecting a slug, the user needs to be part of the rule's allowed users. If there isn't a matching rule, defaults pe...
[ "this", "is", "analog", "to", "django", "s", "builtin", "permission_required", "decorator", "but", "improved", "to", "check", "per", "slug", "ACLRules", "and", "default", "permissions", "for", "anonymous", "and", "logged", "in", "users" ]
python
train
46.825
daniellawrence/graphitesend
graphitesend/graphitesend.py
https://github.com/daniellawrence/graphitesend/blob/02281263e642f9b6e146886d4544e1d7aebd7753/graphitesend/graphitesend.py#L455-L490
def str2listtuple(self, string_message): "Covert a string that is ready to be sent to graphite into a tuple" if type(string_message).__name__ not in ('str', 'unicode'): raise TypeError("Must provide a string or unicode") if not string_message.endswith('\n'): string_mess...
[ "def", "str2listtuple", "(", "self", ",", "string_message", ")", ":", "if", "type", "(", "string_message", ")", ".", "__name__", "not", "in", "(", "'str'", ",", "'unicode'", ")", ":", "raise", "TypeError", "(", "\"Must provide a string or unicode\"", ")", "if"...
Covert a string that is ready to be sent to graphite into a tuple
[ "Covert", "a", "string", "that", "is", "ready", "to", "be", "sent", "to", "graphite", "into", "a", "tuple" ]
python
train
33.861111
jasonrbriggs/stomp.py
stomp/utils.py
https://github.com/jasonrbriggs/stomp.py/blob/643843c5fbf25fd24339dd0e69a9411c3d8b94c7/stomp/utils.py#L190-L208
def calculate_heartbeats(shb, chb): """ Given a heartbeat string from the server, and a heartbeat tuple from the client, calculate what the actual heartbeat settings should be. :param (str,str) shb: server heartbeat numbers :param (int,int) chb: client heartbeat numbers :rtype: (int,int) "...
[ "def", "calculate_heartbeats", "(", "shb", ",", "chb", ")", ":", "(", "sx", ",", "sy", ")", "=", "shb", "(", "cx", ",", "cy", ")", "=", "chb", "x", "=", "0", "y", "=", "0", "if", "cx", "!=", "0", "and", "sy", "!=", "'0'", ":", "x", "=", "...
Given a heartbeat string from the server, and a heartbeat tuple from the client, calculate what the actual heartbeat settings should be. :param (str,str) shb: server heartbeat numbers :param (int,int) chb: client heartbeat numbers :rtype: (int,int)
[ "Given", "a", "heartbeat", "string", "from", "the", "server", "and", "a", "heartbeat", "tuple", "from", "the", "client", "calculate", "what", "the", "actual", "heartbeat", "settings", "should", "be", "." ]
python
train
26.105263
spyder-ide/spyder
spyder/plugins/plots/widgets/figurebrowser.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/plots/widgets/figurebrowser.py#L52-L64
def get_unique_figname(dirname, root, ext): """ Append a number to "root" to form a filename that does not already exist in "dirname". """ i = 1 figname = root + '_%d' % i + ext while True: if osp.exists(osp.join(dirname, figname)): i += 1 figname = root + '_%...
[ "def", "get_unique_figname", "(", "dirname", ",", "root", ",", "ext", ")", ":", "i", "=", "1", "figname", "=", "root", "+", "'_%d'", "%", "i", "+", "ext", "while", "True", ":", "if", "osp", ".", "exists", "(", "osp", ".", "join", "(", "dirname", ...
Append a number to "root" to form a filename that does not already exist in "dirname".
[ "Append", "a", "number", "to", "root", "to", "form", "a", "filename", "that", "does", "not", "already", "exist", "in", "dirname", "." ]
python
train
29.230769
blockstack/virtualchain
virtualchain/virtualchain.py
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/virtualchain.py#L67-L85
def virtualchain_set_opfields( op, **fields ): """ Pass along virtualchain-reserved fields to a virtualchain operation. This layer of indirection is meant to help with future compatibility, so virtualchain implementations do not try to set operation fields directly. """ # warn about unsuppo...
[ "def", "virtualchain_set_opfields", "(", "op", ",", "*", "*", "fields", ")", ":", "# warn about unsupported fields", "for", "f", "in", "fields", ".", "keys", "(", ")", ":", "if", "f", "not", "in", "indexer", ".", "RESERVED_KEYS", ":", "log", ".", "warning"...
Pass along virtualchain-reserved fields to a virtualchain operation. This layer of indirection is meant to help with future compatibility, so virtualchain implementations do not try to set operation fields directly.
[ "Pass", "along", "virtualchain", "-", "reserved", "fields", "to", "a", "virtualchain", "operation", ".", "This", "layer", "of", "indirection", "is", "meant", "to", "help", "with", "future", "compatibility", "so", "virtualchain", "implementations", "do", "not", "...
python
train
31.368421
coderanger/depot
depot/storage.py
https://github.com/coderanger/depot/blob/d1a96f13204ad7028432096d25718e611d4d3d9d/depot/storage.py#L102-L119
def file(cls, uri_or_path): """ Given either a URI like s3://bucket/path.txt or a path like /path.txt, return a file object for it. """ uri = urlparse(uri_or_path) if not uri.scheme: # Just a normal path return open(uri_or_path, 'rb') else:...
[ "def", "file", "(", "cls", ",", "uri_or_path", ")", ":", "uri", "=", "urlparse", "(", "uri_or_path", ")", "if", "not", "uri", ".", "scheme", ":", "# Just a normal path", "return", "open", "(", "uri_or_path", ",", "'rb'", ")", "else", ":", "it", "=", "c...
Given either a URI like s3://bucket/path.txt or a path like /path.txt, return a file object for it.
[ "Given", "either", "a", "URI", "like", "s3", ":", "//", "bucket", "/", "path", ".", "txt", "or", "a", "path", "like", "/", "path", ".", "txt", "return", "a", "file", "object", "for", "it", "." ]
python
train
35.388889
DataBiosphere/toil
src/toil/common.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/common.py#L737-L775
def start(self, rootJob): """ Invoke a Toil workflow with the given job as the root for an initial run. This method must be called in the body of a ``with Toil(...) as toil:`` statement. This method should not be called more than once for a workflow that has not finished. :param...
[ "def", "start", "(", "self", ",", "rootJob", ")", ":", "self", ".", "_assertContextManagerUsed", "(", ")", "self", ".", "writePIDFile", "(", ")", "if", "self", ".", "config", ".", "restart", ":", "raise", "ToilRestartException", "(", "'A Toil workflow can only...
Invoke a Toil workflow with the given job as the root for an initial run. This method must be called in the body of a ``with Toil(...) as toil:`` statement. This method should not be called more than once for a workflow that has not finished. :param toil.job.Job rootJob: The root job of the wor...
[ "Invoke", "a", "Toil", "workflow", "with", "the", "given", "job", "as", "the", "root", "for", "an", "initial", "run", ".", "This", "method", "must", "be", "called", "in", "the", "body", "of", "a", "with", "Toil", "(", "...", ")", "as", "toil", ":", ...
python
train
45.666667
relekang/python-semantic-release
semantic_release/vcs_helpers.py
https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/vcs_helpers.py#L38-L59
def get_last_version(skip_tags=None) -> Optional[str]: """ Return last version from repo tags. :return: A string contains version number. """ debug('get_last_version skip_tags=', skip_tags) check_repo() skip_tags = skip_tags or [] def version_finder(tag): if isinstance(tag.com...
[ "def", "get_last_version", "(", "skip_tags", "=", "None", ")", "->", "Optional", "[", "str", "]", ":", "debug", "(", "'get_last_version skip_tags='", ",", "skip_tags", ")", "check_repo", "(", ")", "skip_tags", "=", "skip_tags", "or", "[", "]", "def", "versio...
Return last version from repo tags. :return: A string contains version number.
[ "Return", "last", "version", "from", "repo", "tags", "." ]
python
train
28.045455
EnigmaBridge/jbossply
jbossply/jbossparser.py
https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L185-L189
def t_escaped_CARRIAGE_RETURN_CHAR(self, t): r'\x72' # 'r' t.lexer.pop_state() t.value = unichr(0x000d) return t
[ "def", "t_escaped_CARRIAGE_RETURN_CHAR", "(", "self", ",", "t", ")", ":", "# 'r'", "t", ".", "lexer", ".", "pop_state", "(", ")", "t", ".", "value", "=", "unichr", "(", "0x000d", ")", "return", "t" ]
r'\x72
[ "r", "\\", "x72" ]
python
train
28.2
EnigmaBridge/client.py
ebclient/eb_request.py
https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_request.py#L68-L99
def call(self, request=None, *args, **kwargs): """ Calls multiple time - with retry. :param request: :return: response """ if request is not None: self.request = request retry = self.request.configuration.retry if not isinstance(retry, Simple...
[ "def", "call", "(", "self", ",", "request", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "request", "is", "not", "None", ":", "self", ".", "request", "=", "request", "retry", "=", "self", ".", "request", ".", "configurati...
Calls multiple time - with retry. :param request: :return: response
[ "Calls", "multiple", "time", "-", "with", "retry", "." ]
python
train
30.625
ThreatConnect-Inc/tcex
tcex/tcex_resources.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_resources.py#L2566-L2576
def read(self, domain, type_name, search_command, body=None): """Read entry in ThreatConnect Data Store Args: domain (string): One of 'local', 'organization', or 'system'. type_name (string): This is a free form index type name. The ThreatConnect API will use thi...
[ "def", "read", "(", "self", ",", "domain", ",", "type_name", ",", "search_command", ",", "body", "=", "None", ")", ":", "return", "self", ".", "_request", "(", "domain", ",", "type_name", ",", "search_command", ",", "'GET'", ",", "body", ")" ]
Read entry in ThreatConnect Data Store Args: domain (string): One of 'local', 'organization', or 'system'. type_name (string): This is a free form index type name. The ThreatConnect API will use this resource verbatim. search_command (string): Search command ...
[ "Read", "entry", "in", "ThreatConnect", "Data", "Store" ]
python
train
47.272727
consbio/gis-metadata-parser
gis_metadata/utils.py
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L592-L618
def validate_complex_list(prop, value, xpath_map=None): """ Default validation for Attribute Details data structure """ if value is not None: validate_type(prop, value, (dict, list)) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: ...
[ "def", "validate_complex_list", "(", "prop", ",", "value", ",", "xpath_map", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "(", "dict", ",", "list", ")", ")", "if", "prop", "in", "_co...
Default validation for Attribute Details data structure
[ "Default", "validation", "for", "Attribute", "Details", "data", "structure" ]
python
train
42.259259
juju-solutions/charms.reactive
charms/reactive/bus.py
https://github.com/juju-solutions/charms.reactive/blob/e37e781432e77c12b63d2c739bd6cd70d3230c3a/charms/reactive/bus.py#L142-L151
def add_predicate(self, predicate): """ Add a new predicate callback to this handler. """ _predicate = predicate if isinstance(predicate, partial): _predicate = 'partial(%s, %s, %s)' % (predicate.func, predicate.args, predicate.keywords) if LOG_OPTS['register'...
[ "def", "add_predicate", "(", "self", ",", "predicate", ")", ":", "_predicate", "=", "predicate", "if", "isinstance", "(", "predicate", ",", "partial", ")", ":", "_predicate", "=", "'partial(%s, %s, %s)'", "%", "(", "predicate", ".", "func", ",", "predicate", ...
Add a new predicate callback to this handler.
[ "Add", "a", "new", "predicate", "callback", "to", "this", "handler", "." ]
python
train
46
klmitch/turnstile
turnstile/control.py
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/control.py#L308-L340
def ping(daemon, channel, data=None): """ Process the 'ping' control message. :param daemon: The control daemon; used to get at the configuration and the database. :param channel: The publish channel to which to send the response. :param data: Optional extra d...
[ "def", "ping", "(", "daemon", ",", "channel", ",", "data", "=", "None", ")", ":", "if", "not", "channel", ":", "# No place to reply to", "return", "# Get our configured node name", "node_name", "=", "daemon", ".", "config", "[", "'control'", "]", ".", "get", ...
Process the 'ping' control message. :param daemon: The control daemon; used to get at the configuration and the database. :param channel: The publish channel to which to send the response. :param data: Optional extra data. Will be returned as the sec...
[ "Process", "the", "ping", "control", "message", "." ]
python
train
28.181818
pallets/werkzeug
src/werkzeug/http.py
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/http.py#L812-L843
def _dump_date(d, delim): """Used for `http_date` and `cookie_date`.""" if d is None: d = gmtime() elif isinstance(d, datetime): d = d.utctimetuple() elif isinstance(d, (integer_types, float)): d = gmtime(d) return "%s, %02d%s%s%s%s %02d:%02d:%02d GMT" % ( ("Mon", "Tu...
[ "def", "_dump_date", "(", "d", ",", "delim", ")", ":", "if", "d", "is", "None", ":", "d", "=", "gmtime", "(", ")", "elif", "isinstance", "(", "d", ",", "datetime", ")", ":", "d", "=", "d", ".", "utctimetuple", "(", ")", "elif", "isinstance", "(",...
Used for `http_date` and `cookie_date`.
[ "Used", "for", "http_date", "and", "cookie_date", "." ]
python
train
23
ytjia/utils-py
utils_py/time_seg_util.py
https://github.com/ytjia/utils-py/blob/68039b367e2e38fdecf234ecc625406b9e203ec0/utils_py/time_seg_util.py#L95-L103
def index_to_time_seg(time_seg_idx, slide_step): """ 将时间片索引值转换为时间片字符串 :param time_seg_idx: :param slide_step: :return: """ assert (time_seg_idx * slide_step < const.MINUTES_IN_A_DAY) return time_util.minutes_to_time_str(time_seg_idx * slide_step)
[ "def", "index_to_time_seg", "(", "time_seg_idx", ",", "slide_step", ")", ":", "assert", "(", "time_seg_idx", "*", "slide_step", "<", "const", ".", "MINUTES_IN_A_DAY", ")", "return", "time_util", ".", "minutes_to_time_str", "(", "time_seg_idx", "*", "slide_step", "...
将时间片索引值转换为时间片字符串 :param time_seg_idx: :param slide_step: :return:
[ "将时间片索引值转换为时间片字符串", ":", "param", "time_seg_idx", ":", ":", "param", "slide_step", ":", ":", "return", ":" ]
python
train
30
annoviko/pyclustering
pyclustering/cluster/clarans.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/clarans.py#L66-L93
def process(self): """! @brief Performs cluster analysis in line with rules of CLARANS algorithm. @see get_clusters() @see get_medoids() """ random.seed() for _ in range(0, self.__numlocal): # set (curren...
[ "def", "process", "(", "self", ")", ":", "random", ".", "seed", "(", ")", "for", "_", "in", "range", "(", "0", ",", "self", ".", "__numlocal", ")", ":", "# set (current) random medoids\r", "self", ".", "__current", "=", "random", ".", "sample", "(", "r...
! @brief Performs cluster analysis in line with rules of CLARANS algorithm. @see get_clusters() @see get_medoids()
[ "!" ]
python
valid
37.571429
skggm/skggm
inverse_covariance/inverse_covariance.py
https://github.com/skggm/skggm/blob/a0ed406586c4364ea3297a658f415e13b5cbdaf8/inverse_covariance/inverse_covariance.py#L315-L345
def ebic_select(self, gamma=0): """Uses Extended Bayesian Information Criteria for model selection. Can only be used in path mode (doesn't really make sense otherwise). See: Extended Bayesian Information Criteria for Gaussian Graphical Models R. Foygel and M. Drton NIPS...
[ "def", "ebic_select", "(", "self", ",", "gamma", "=", "0", ")", ":", "if", "not", "isinstance", "(", "self", ".", "precision_", ",", "list", ")", ":", "raise", "ValueError", "(", "\"EBIC requires multiple models to select from.\"", ")", "return", "if", "not", ...
Uses Extended Bayesian Information Criteria for model selection. Can only be used in path mode (doesn't really make sense otherwise). See: Extended Bayesian Information Criteria for Gaussian Graphical Models R. Foygel and M. Drton NIPS 2010 Parameters ---------...
[ "Uses", "Extended", "Bayesian", "Information", "Criteria", "for", "model", "selection", "." ]
python
train
34.129032
nchopin/particles
particles/smc_samplers.py
https://github.com/nchopin/particles/blob/3faa97a1073db45c5889eef3e015dd76ef350b52/particles/smc_samplers.py#L134-L155
def all_distinct(l, idx): """ Returns the list [l[i] for i in idx]  When needed, objects l[i] are replaced by a copy, to make sure that the elements of the list are all distinct Parameters --------- l: iterable idx: iterable that generates ints (e.g. ndarray of ints) Returns --...
[ "def", "all_distinct", "(", "l", ",", "idx", ")", ":", "out", "=", "[", "]", "deja_vu", "=", "[", "False", "for", "_", "in", "l", "]", "for", "i", "in", "idx", ":", "to_add", "=", "cp", ".", "deepcopy", "(", "l", "[", "i", "]", ")", "if", "...
Returns the list [l[i] for i in idx]  When needed, objects l[i] are replaced by a copy, to make sure that the elements of the list are all distinct Parameters --------- l: iterable idx: iterable that generates ints (e.g. ndarray of ints) Returns ------- a list
[ "Returns", "the", "list", "[", "l", "[", "i", "]", "for", "i", "in", "idx", "]", "When", "needed", "objects", "l", "[", "i", "]", "are", "replaced", "by", "a", "copy", "to", "make", "sure", "that", "the", "elements", "of", "the", "list", "are", "...
python
train
23.409091
Jajcus/pyxmpp2
pyxmpp2/cert.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/cert.py#L497-L534
def _decode_alt_names(self, alt_names): """Load SubjectAltName from a ASN.1 GeneralNames value. :Values: - `alt_names`: the SubjectAltNama extension value :Types: - `alt_name`: `GeneralNames` """ for alt_name in alt_names: tname = alt_name.get...
[ "def", "_decode_alt_names", "(", "self", ",", "alt_names", ")", ":", "for", "alt_name", "in", "alt_names", ":", "tname", "=", "alt_name", ".", "getName", "(", ")", "comp", "=", "alt_name", ".", "getComponent", "(", ")", "if", "tname", "==", "\"dNSName\"", ...
Load SubjectAltName from a ASN.1 GeneralNames value. :Values: - `alt_names`: the SubjectAltNama extension value :Types: - `alt_name`: `GeneralNames`
[ "Load", "SubjectAltName", "from", "a", "ASN", ".", "1", "GeneralNames", "value", "." ]
python
valid
41.868421
inveniosoftware/invenio-indexer
invenio_indexer/api.py
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L135-L146
def delete(self, record): """Delete a record. :param record: Record instance. """ index, doc_type = self.record_to_index(record) return self.client.delete( id=str(record.id), index=index, doc_type=doc_type, )
[ "def", "delete", "(", "self", ",", "record", ")", ":", "index", ",", "doc_type", "=", "self", ".", "record_to_index", "(", "record", ")", "return", "self", ".", "client", ".", "delete", "(", "id", "=", "str", "(", "record", ".", "id", ")", ",", "in...
Delete a record. :param record: Record instance.
[ "Delete", "a", "record", "." ]
python
train
23.583333
cstockton/py-gensend
gensend/providers/common.py
https://github.com/cstockton/py-gensend/blob/8c8e911f8e8c386bea42967350beb4636fc19240/gensend/providers/common.py#L161-L167
def types(self, *args): """Used for debugging, returns type of each arg. TYPES,ARG_1,...,ARG_N %{TYPES:A,...,10} -> 'str(A) str(B) ... int(10)' """ return ', '.join(['{0}({1})'.format(type(arg).__name__, arg) for arg in args])
[ "def", "types", "(", "self", ",", "*", "args", ")", ":", "return", "', '", ".", "join", "(", "[", "'{0}({1})'", ".", "format", "(", "type", "(", "arg", ")", ".", "__name__", ",", "arg", ")", "for", "arg", "in", "args", "]", ")" ]
Used for debugging, returns type of each arg. TYPES,ARG_1,...,ARG_N %{TYPES:A,...,10} -> 'str(A) str(B) ... int(10)'
[ "Used", "for", "debugging", "returns", "type", "of", "each", "arg", ".", "TYPES", "ARG_1", "...", "ARG_N" ]
python
train
37.857143
django-fluent/django-fluent-contents
fluent_contents/plugins/oembeditem/backend.py
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/plugins/oembeditem/backend.py#L47-L73
def _build_provider_list(): """ Construct the provider registry, using the app settings. """ registry = None if appsettings.FLUENT_OEMBED_SOURCE == 'basic': registry = bootstrap_basic() elif appsettings.FLUENT_OEMBED_SOURCE == 'embedly': params = {} if appsettings.MICAWBE...
[ "def", "_build_provider_list", "(", ")", ":", "registry", "=", "None", "if", "appsettings", ".", "FLUENT_OEMBED_SOURCE", "==", "'basic'", ":", "registry", "=", "bootstrap_basic", "(", ")", "elif", "appsettings", ".", "FLUENT_OEMBED_SOURCE", "==", "'embedly'", ":",...
Construct the provider registry, using the app settings.
[ "Construct", "the", "provider", "registry", "using", "the", "app", "settings", "." ]
python
train
43.925926
dbcli/cli_helpers
cli_helpers/config.py
https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/config.py#L119-L122
def system_config_files(self): """Get a list of absolute paths to the system config files.""" return [os.path.join(f, self.filename) for f in get_system_config_dirs( self.app_name, self.app_author)]
[ "def", "system_config_files", "(", "self", ")", ":", "return", "[", "os", ".", "path", ".", "join", "(", "f", ",", "self", ".", "filename", ")", "for", "f", "in", "get_system_config_dirs", "(", "self", ".", "app_name", ",", "self", ".", "app_author", "...
Get a list of absolute paths to the system config files.
[ "Get", "a", "list", "of", "absolute", "paths", "to", "the", "system", "config", "files", "." ]
python
test
55.75
ladybug-tools/ladybug
ladybug/designday.py
https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/designday.py#L925-L941
def dew_point(self, db): """Get the dew point (C), which is constant throughout the day (except at saturation). args: db: The maximum dry bulb temperature over the day. """ if self._hum_type == 'Dewpoint': return self._hum_value elif self._hum_type == 'We...
[ "def", "dew_point", "(", "self", ",", "db", ")", ":", "if", "self", ".", "_hum_type", "==", "'Dewpoint'", ":", "return", "self", ".", "_hum_value", "elif", "self", ".", "_hum_type", "==", "'Wetbulb'", ":", "return", "dew_point_from_db_wb", "(", "db", ",", ...
Get the dew point (C), which is constant throughout the day (except at saturation). args: db: The maximum dry bulb temperature over the day.
[ "Get", "the", "dew", "point", "(", "C", ")", "which", "is", "constant", "throughout", "the", "day", "(", "except", "at", "saturation", ")", "." ]
python
train
42.764706
CivicSpleen/ambry
ambry/orm/file.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/file.py#L80-L87
def update(self, of): """Update a file from another file, for copying""" # The other values should be set when the file object is created with dataset.bsfile() for p in ('mime_type', 'preference', 'state', 'hash', 'modified', 'size', 'contents', 'source_hash', 'data'): setattr(self,...
[ "def", "update", "(", "self", ",", "of", ")", ":", "# The other values should be set when the file object is created with dataset.bsfile()", "for", "p", "in", "(", "'mime_type'", ",", "'preference'", ",", "'state'", ",", "'hash'", ",", "'modified'", ",", "'size'", ","...
Update a file from another file, for copying
[ "Update", "a", "file", "from", "another", "file", "for", "copying" ]
python
train
44.125
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L94-L105
def aggregations(self): """ Override parent method. Obtain list of the terms and their corresponding values using "terms" aggregations for the previous time period. :returns: a data frame containing terms and their corresponding values """ prev_month_start = get_prev_mo...
[ "def", "aggregations", "(", "self", ")", ":", "prev_month_start", "=", "get_prev_month", "(", "self", ".", "end", ",", "self", ".", "query", ".", "interval_", ")", "self", ".", "query", ".", "since", "(", "prev_month_start", ")", "self", ".", "query", "....
Override parent method. Obtain list of the terms and their corresponding values using "terms" aggregations for the previous time period. :returns: a data frame containing terms and their corresponding values
[ "Override", "parent", "method", ".", "Obtain", "list", "of", "the", "terms", "and", "their", "corresponding", "values", "using", "terms", "aggregations", "for", "the", "previous", "time", "period", "." ]
python
train
40.166667
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/SConf.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/SConf.py#L623-L629
def TryLink( self, text, extension ): """Compiles the program given in text to an executable env.Program, using extension as file extension (e.g. '.c'). Returns 1, if compilation was successful, 0 otherwise. The target is saved in self.lastTarget (for further processing). """ ...
[ "def", "TryLink", "(", "self", ",", "text", ",", "extension", ")", ":", "return", "self", ".", "TryBuild", "(", "self", ".", "env", ".", "Program", ",", "text", ",", "extension", ")" ]
Compiles the program given in text to an executable env.Program, using extension as file extension (e.g. '.c'). Returns 1, if compilation was successful, 0 otherwise. The target is saved in self.lastTarget (for further processing).
[ "Compiles", "the", "program", "given", "in", "text", "to", "an", "executable", "env", ".", "Program", "using", "extension", "as", "file", "extension", "(", "e", ".", "g", ".", ".", "c", ")", ".", "Returns", "1", "if", "compilation", "was", "successful", ...
python
train
53.571429
weijia/djangoautoconf
djangoautoconf/class_based_views/detail_with_inline_view.py
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/class_based_views/detail_with_inline_view.py#L34-L40
def forms_valid(self, inlines): """ If the form and formsets are valid, save the associated models. """ for formset in inlines: formset.save() return HttpResponseRedirect(self.get_success_url())
[ "def", "forms_valid", "(", "self", ",", "inlines", ")", ":", "for", "formset", "in", "inlines", ":", "formset", ".", "save", "(", ")", "return", "HttpResponseRedirect", "(", "self", ".", "get_success_url", "(", ")", ")" ]
If the form and formsets are valid, save the associated models.
[ "If", "the", "form", "and", "formsets", "are", "valid", "save", "the", "associated", "models", "." ]
python
train
34.285714
facetoe/zenpy
zenpy/lib/api.py
https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L292-L303
def _build_url(self, endpoint): """ Build complete URL """ if not issubclass(type(self), ChatApiBase) and not self.subdomain: raise ZenpyException("subdomain is required when accessing the Zendesk API!") if self.subdomain: endpoint.netloc = '{}.{}'.format(self.subdomain,...
[ "def", "_build_url", "(", "self", ",", "endpoint", ")", ":", "if", "not", "issubclass", "(", "type", "(", "self", ")", ",", "ChatApiBase", ")", "and", "not", "self", ".", "subdomain", ":", "raise", "ZenpyException", "(", "\"subdomain is required when accessing...
Build complete URL
[ "Build", "complete", "URL" ]
python
train
38.083333
sdss/tree
bin/setup_tree.py
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/bin/setup_tree.py#L383-L404
def parse_args(): ''' Parse the arguments ''' parser = argparse.ArgumentParser(prog='setup_tree_modules', usage='%(prog)s [opts]') parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', help='Print extra information.', default=False) parser.add_argument('-r'...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'setup_tree_modules'", ",", "usage", "=", "'%(prog)s [opts]'", ")", "parser", ".", "add_argument", "(", "'-v'", ",", "'--verbose'", ",", "action", "=", "...
Parse the arguments
[ "Parse", "the", "arguments" ]
python
train
62.863636
dshean/pygeotools
pygeotools/lib/timelib.py
https://github.com/dshean/pygeotools/blob/5ac745717c0098d01eb293ff1fe32fd7358c76ab/pygeotools/lib/timelib.py#L68-L75
def strptime_fuzzy(s): """Fuzzy date string parsing Note: this returns current date if not found. If only year is provided, will return current month, day """ import dateutil.parser dt = dateutil.parser.parse(str(s), fuzzy=True) return dt
[ "def", "strptime_fuzzy", "(", "s", ")", ":", "import", "dateutil", ".", "parser", "dt", "=", "dateutil", ".", "parser", ".", "parse", "(", "str", "(", "s", ")", ",", "fuzzy", "=", "True", ")", "return", "dt" ]
Fuzzy date string parsing Note: this returns current date if not found. If only year is provided, will return current month, day
[ "Fuzzy", "date", "string", "parsing" ]
python
train
32.125
jjjake/giganews
giganews/giganews.py
https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/giganews.py#L434-L467
def compress_and_sort_index(self): """Sort index, add header, and compress. :rtype: bool :returns: True """ idx_fname = '{name}.{date}.mbox.csv'.format(**self.__dict__) try: reader = csv.reader(open(idx_fname), dialect='excel-tab') except IOError: ...
[ "def", "compress_and_sort_index", "(", "self", ")", ":", "idx_fname", "=", "'{name}.{date}.mbox.csv'", ".", "format", "(", "*", "*", "self", ".", "__dict__", ")", "try", ":", "reader", "=", "csv", ".", "reader", "(", "open", "(", "idx_fname", ")", ",", "...
Sort index, add header, and compress. :rtype: bool :returns: True
[ "Sort", "index", "add", "header", "and", "compress", "." ]
python
train
30.647059
happyleavesaoc/aoc-mgz
mgz/util.py
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/util.py#L138-L170
def _parse(self, stream, context, path): """Parse until the end of objects data.""" num_players = context._._._.replay.num_players start = stream.tell() # Have to read everything to be able to use find() read_bytes = stream.read() # Try to find the first marker, a portion...
[ "def", "_parse", "(", "self", ",", "stream", ",", "context", ",", "path", ")", ":", "num_players", "=", "context", ".", "_", ".", "_", ".", "_", ".", "replay", ".", "num_players", "start", "=", "stream", ".", "tell", "(", ")", "# Have to read everythin...
Parse until the end of objects data.
[ "Parse", "until", "the", "end", "of", "objects", "data", "." ]
python
train
44.181818
CalebBell/fluids
fluids/geometry.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1290-L1333
def a_torispherical(D, f, k): r'''Calculates depth of a torispherical head according to [1]_. .. math:: a = a_1 + a_2 .. math:: \alpha = \sin^{-1}\frac{1-2k}{2(f-k)} .. math:: a_1 = fD(1-\cos\alpha) .. math:: a_2 = kD\cos\alpha Parameters ---------- D...
[ "def", "a_torispherical", "(", "D", ",", "f", ",", "k", ")", ":", "alpha", "=", "asin", "(", "(", "1", "-", "2", "*", "k", ")", "/", "(", "2", "*", "(", "f", "-", "k", ")", ")", ")", "a1", "=", "f", "*", "D", "*", "(", "1", "-", "cos"...
r'''Calculates depth of a torispherical head according to [1]_. .. math:: a = a_1 + a_2 .. math:: \alpha = \sin^{-1}\frac{1-2k}{2(f-k)} .. math:: a_1 = fD(1-\cos\alpha) .. math:: a_2 = kD\cos\alpha Parameters ---------- D : float Diameter of the m...
[ "r", "Calculates", "depth", "of", "a", "torispherical", "head", "according", "to", "[", "1", "]", "_", "." ]
python
train
21.5
mitsei/dlkit
dlkit/records/osid/base_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/osid/base_records.py#L1783-L1930
def _update_object_map(self, obj_map): """loop through all the keys in self.my_osid_object._my_map, and see if any of them contain text like "AssetContent:<label>" If so, assume it is markup (?), replace the string with asset_content.get_url()""" # TODO: Look for <img> tags to add in alt...
[ "def", "_update_object_map", "(", "self", ",", "obj_map", ")", ":", "# TODO: Look for <img> tags to add in alt-text and description", "# TODO: Look for <video> and <audio> tags to add in description, transcripts and vtt files?", "try", ":", "super", "(", "FilesRecord", ",", "self", ...
loop through all the keys in self.my_osid_object._my_map, and see if any of them contain text like "AssetContent:<label>" If so, assume it is markup (?), replace the string with asset_content.get_url()
[ "loop", "through", "all", "the", "keys", "in", "self", ".", "my_osid_object", ".", "_my_map", "and", "see", "if", "any", "of", "them", "contain", "text", "like", "AssetContent", ":", "<label", ">", "If", "so", "assume", "it", "is", "markup", "(", "?", ...
python
train
54.587838
trustrachel/Flask-FeatureFlags
flask_featureflags/__init__.py
https://github.com/trustrachel/Flask-FeatureFlags/blob/bf32d07c8ce72adc009619ef04e666c51736f80c/flask_featureflags/__init__.py#L48-L76
def AppConfigFlagHandler(feature=None): """ This is the default handler. It checks for feature flags in the current app's configuration. For example, to have 'unfinished_feature' hidden in production but active in development: config.py class ProductionConfig(Config): FEATURE_FLAGS = { 'unfinished...
[ "def", "AppConfigFlagHandler", "(", "feature", "=", "None", ")", ":", "if", "not", "current_app", ":", "log", ".", "warn", "(", "u\"Got a request to check for {feature} but we're outside the request context. Returning False\"", ".", "format", "(", "feature", "=", "feature...
This is the default handler. It checks for feature flags in the current app's configuration. For example, to have 'unfinished_feature' hidden in production but active in development: config.py class ProductionConfig(Config): FEATURE_FLAGS = { 'unfinished_feature' : False, } class Development...
[ "This", "is", "the", "default", "handler", ".", "It", "checks", "for", "feature", "flags", "in", "the", "current", "app", "s", "configuration", "." ]
python
train
25.310345
JarryShaw/PyPCAPKit
src/protocols/internet/ipv4.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv4.py#L576-L658
def _read_mode_ts(self, size, kind): """Read Time Stamp option. Positional arguments: * size - int, length of option * kind - int, 68 (TS) Returns: * dict -- extracted Time Stamp (TS) option Structure of Timestamp (TS) option [RFC 791]: ...
[ "def", "_read_mode_ts", "(", "self", ",", "size", ",", "kind", ")", ":", "if", "size", ">", "40", "or", "size", "<", "4", ":", "raise", "ProtocolError", "(", "f'{self.alias}: [Optno {kind}] invalid format'", ")", "_tptr", "=", "self", ".", "_read_unpack", "(...
Read Time Stamp option. Positional arguments: * size - int, length of option * kind - int, 68 (TS) Returns: * dict -- extracted Time Stamp (TS) option Structure of Timestamp (TS) option [RFC 791]: +--------+--------+--------+--------+ ...
[ "Read", "Time", "Stamp", "option", "." ]
python
train
38.795181
deepmind/sonnet
sonnet/python/modules/basic.py
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic.py#L759-L777
def _infer_shape(self, dimensions): """Replaces the -1 wildcard in the output shape vector. This function infers the correct output shape given the input dimensions. Args: dimensions: List of input non-batch dimensions. Returns: Tuple of non-batch output dimensions. """ # Size of ...
[ "def", "_infer_shape", "(", "self", ",", "dimensions", ")", ":", "# Size of input", "n", "=", "np", ".", "prod", "(", "dimensions", ")", "# Size of output where defined", "m", "=", "np", ".", "prod", "(", "abs", "(", "np", ".", "array", "(", "self", ".",...
Replaces the -1 wildcard in the output shape vector. This function infers the correct output shape given the input dimensions. Args: dimensions: List of input non-batch dimensions. Returns: Tuple of non-batch output dimensions.
[ "Replaces", "the", "-", "1", "wildcard", "in", "the", "output", "shape", "vector", "." ]
python
train
26.894737
joferkington/mpldatacursor
mpldatacursor/datacursor.py
https://github.com/joferkington/mpldatacursor/blob/7dabc589ed02c35ac5d89de5931f91e0323aa795/mpldatacursor/datacursor.py#L256-L275
def _show_annotation_box(self, event): """Update an existing box or create an annotation box for an event.""" ax = event.artist.axes # Get the pre-created annotation box for the axes or create a new one. if self.display != 'multiple': annotation = self.annotations[ax] ...
[ "def", "_show_annotation_box", "(", "self", ",", "event", ")", ":", "ax", "=", "event", ".", "artist", ".", "axes", "# Get the pre-created annotation box for the axes or create a new one.", "if", "self", ".", "display", "!=", "'multiple'", ":", "annotation", "=", "s...
Update an existing box or create an annotation box for an event.
[ "Update", "an", "existing", "box", "or", "create", "an", "annotation", "box", "for", "an", "event", "." ]
python
train
44.4
jic-dtool/dtoolcore
dtoolcore/storagebroker.py
https://github.com/jic-dtool/dtoolcore/blob/eeb9a924dc8fcf543340653748a7877be1f98e0f/dtoolcore/storagebroker.py#L615-L625
def post_freeze_hook(self): """Post :meth:`dtoolcore.ProtoDataSet.freeze` cleanup actions. This method is called at the end of the :meth:`dtoolcore.ProtoDataSet.freeze` method. In the :class:`dtoolcore.storage_broker.DiskStorageBroker` it removes the temporary directory for sto...
[ "def", "post_freeze_hook", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "_metadata_fragments_abspath", ")", ":", "shutil", ".", "rmtree", "(", "self", ".", "_metadata_fragments_abspath", ")" ]
Post :meth:`dtoolcore.ProtoDataSet.freeze` cleanup actions. This method is called at the end of the :meth:`dtoolcore.ProtoDataSet.freeze` method. In the :class:`dtoolcore.storage_broker.DiskStorageBroker` it removes the temporary directory for storing item metadata fragment files.
[ "Post", ":", "meth", ":", "dtoolcore", ".", "ProtoDataSet", ".", "freeze", "cleanup", "actions", "." ]
python
train
43.272727
googlefonts/fontbakery
Lib/fontbakery/profiles/universal.py
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/universal.py#L652-L672
def com_google_fonts_check_whitespace_ink(ttFont): """Whitespace glyphs have ink?""" from fontbakery.utils import get_glyph_name, glyph_has_ink # code-points for all "whitespace" chars: WHITESPACE_CHARACTERS = [ 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x0020, 0x0085, 0x00A0, 0x1680, 0x2000, 0x2001,...
[ "def", "com_google_fonts_check_whitespace_ink", "(", "ttFont", ")", ":", "from", "fontbakery", ".", "utils", "import", "get_glyph_name", ",", "glyph_has_ink", "# code-points for all \"whitespace\" chars:", "WHITESPACE_CHARACTERS", "=", "[", "0x0009", ",", "0x000A", ",", "...
Whitespace glyphs have ink?
[ "Whitespace", "glyphs", "have", "ink?" ]
python
train
40.285714
jpscaletti/solution
solution/utils.py
https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/utils.py#L34-L76
def get_html_attrs(kwargs=None): """Generate HTML attributes from the provided keyword arguments. The output value is sorted by the passed keys, to provide consistent output. Because of the frequent use of the normally reserved keyword `class`, `classes` is used instead. Also, all underscores are tran...
[ "def", "get_html_attrs", "(", "kwargs", "=", "None", ")", ":", "kwargs", "=", "kwargs", "or", "{", "}", "attrs", "=", "[", "]", "props", "=", "[", "]", "classes", "=", "kwargs", ".", "get", "(", "'classes'", ",", "''", ")", ".", "strip", "(", ")"...
Generate HTML attributes from the provided keyword arguments. The output value is sorted by the passed keys, to provide consistent output. Because of the frequent use of the normally reserved keyword `class`, `classes` is used instead. Also, all underscores are translated to regular dashes. Set a...
[ "Generate", "HTML", "attributes", "from", "the", "provided", "keyword", "arguments", "." ]
python
train
29.302326
MartinThoma/hwrt
hwrt/segmentation/segmentation.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/segmentation/segmentation.py#L169-L217
def get_dataset(): """Create a dataset for machine learning of segmentations. Returns ------- tuple : (X, y) where X is a list of tuples. Each tuple is a feature. y is a list of labels (0 for 'not in one symbol' and 1 for 'in symbol') """ seg_data = "segmentation-X.npy" seg_...
[ "def", "get_dataset", "(", ")", ":", "seg_data", "=", "\"segmentation-X.npy\"", "seg_labels", "=", "\"segmentation-y.npy\"", "# seg_ids = \"segmentation-ids.npy\"", "if", "os", ".", "path", ".", "isfile", "(", "seg_data", ")", "and", "os", ".", "path", ".", "isfil...
Create a dataset for machine learning of segmentations. Returns ------- tuple : (X, y) where X is a list of tuples. Each tuple is a feature. y is a list of labels (0 for 'not in one symbol' and 1 for 'in symbol')
[ "Create", "a", "dataset", "for", "machine", "learning", "of", "segmentations", "." ]
python
train
40.693878
brocade/pynos
pynos/versions/base/ras.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/ras.py#L35-L72
def enable_support_autoupload(self, **kwargs): """Set Spanning Tree state. Args: enabled (bool): Is Autoupload enabled? (True, False). callback (function): A function executed upon completion of the method. The only parameter passed to `callback` will be the ...
[ "def", "enable_support_autoupload", "(", "self", ",", "*", "*", "kwargs", ")", ":", "enabled", "=", "kwargs", ".", "pop", "(", "'enabled'", ")", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "if", "not", ...
Set Spanning Tree state. Args: enabled (bool): Is Autoupload enabled? (True, False). callback (function): A function executed upon completion of the method. The only parameter passed to `callback` will be the ``ElementTree`` `config`. Returns: ...
[ "Set", "Spanning", "Tree", "state", "." ]
python
train
41.473684
DataBiosphere/toil
src/toil/lib/retry.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/lib/retry.py#L144-L157
def retryable_http_error( e ): """ Determine if an error encountered during an HTTP download is likely to go away if we try again. """ if isinstance( e, urllib.error.HTTPError ) and e.code in ('503', '408', '500'): # The server returned one of: # 503 Service Unavailable # 408 Req...
[ "def", "retryable_http_error", "(", "e", ")", ":", "if", "isinstance", "(", "e", ",", "urllib", ".", "error", ".", "HTTPError", ")", "and", "e", ".", "code", "in", "(", "'503'", ",", "'408'", ",", "'500'", ")", ":", "# The server returned one of:", "# 50...
Determine if an error encountered during an HTTP download is likely to go away if we try again.
[ "Determine", "if", "an", "error", "encountered", "during", "an", "HTTP", "download", "is", "likely", "to", "go", "away", "if", "we", "try", "again", "." ]
python
train
36.428571
armet/python-armet
armet/http/response.py
https://github.com/armet/python-armet/blob/d61eca9082256cb1e7f7f3c7f2fbc4b697157de7/armet/http/response.py#L104-L106
def insert(self, name, index, value): """Insert a value at the passed index in the named header.""" return self._sequence[name].insert(index, value)
[ "def", "insert", "(", "self", ",", "name", ",", "index", ",", "value", ")", ":", "return", "self", ".", "_sequence", "[", "name", "]", ".", "insert", "(", "index", ",", "value", ")" ]
Insert a value at the passed index in the named header.
[ "Insert", "a", "value", "at", "the", "passed", "index", "in", "the", "named", "header", "." ]
python
valid
54
Tanganelli/CoAPthon3
coapthon/client/coap.py
https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/client/coap.py#L69-L79
def close(self): """ Stop the client. """ self.stopped.set() for event in self.to_be_stopped: event.set() if self._receiver_thread is not None: self._receiver_thread.join() self._socket.close()
[ "def", "close", "(", "self", ")", ":", "self", ".", "stopped", ".", "set", "(", ")", "for", "event", "in", "self", ".", "to_be_stopped", ":", "event", ".", "set", "(", ")", "if", "self", ".", "_receiver_thread", "is", "not", "None", ":", "self", "....
Stop the client.
[ "Stop", "the", "client", "." ]
python
train
24
marrow/util
marrow/util/object.py
https://github.com/marrow/util/blob/abb8163dbd1fa0692d42a44d129b12ae2b39cdf2/marrow/util/object.py#L51-L65
def merge(s, t): """Merge dictionary t into s.""" for k, v in t.items(): if isinstance(v, dict): if k not in s: s[k] = v continue s[k] = merge(s[k], v) continue s[k] = v return s
[ "def", "merge", "(", "s", ",", "t", ")", ":", "for", "k", ",", "v", "in", "t", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "if", "k", "not", "in", "s", ":", "s", "[", "k", "]", "=", "v", "continue", ...
Merge dictionary t into s.
[ "Merge", "dictionary", "t", "into", "s", "." ]
python
train
17.6
saltstack/salt
salt/cloud/clouds/scaleway.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/scaleway.py#L171-L183
def create_node(args): ''' Create a node. ''' node = query(method='servers', args=args, http_method='POST') action = query( method='servers', server_id=node['server']['id'], command='action', args={'action': 'poweron'}, http_method='POST' ) return node
[ "def", "create_node", "(", "args", ")", ":", "node", "=", "query", "(", "method", "=", "'servers'", ",", "args", "=", "args", ",", "http_method", "=", "'POST'", ")", "action", "=", "query", "(", "method", "=", "'servers'", ",", "server_id", "=", "node"...
Create a node.
[ "Create", "a", "node", "." ]
python
train
23.461538
innolitics/dicom-numpy
dicom_numpy/combine_slices.py
https://github.com/innolitics/dicom-numpy/blob/c870f0302276e7eaa0b66e641bacee19fe090296/dicom_numpy/combine_slices.py#L156-L177
def _validate_image_orientation(image_orientation): ''' Ensure that the image orientation is supported - The direction cosines have magnitudes of 1 (just in case) - The direction cosines are perpendicular ''' row_cosine, column_cosine, slice_cosine = _extract_cosines(image_orientation) if n...
[ "def", "_validate_image_orientation", "(", "image_orientation", ")", ":", "row_cosine", ",", "column_cosine", ",", "slice_cosine", "=", "_extract_cosines", "(", "image_orientation", ")", "if", "not", "_almost_zero", "(", "np", ".", "dot", "(", "row_cosine", ",", "...
Ensure that the image orientation is supported - The direction cosines have magnitudes of 1 (just in case) - The direction cosines are perpendicular
[ "Ensure", "that", "the", "image", "orientation", "is", "supported", "-", "The", "direction", "cosines", "have", "magnitudes", "of", "1", "(", "just", "in", "case", ")", "-", "The", "direction", "cosines", "are", "perpendicular" ]
python
train
59.954545
PythonOptimizers/cygenja
cygenja/generator.py
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/generator.py#L178-L194
def register_filter(self, filter_name, filter_ref, force=False): """ Add/register one filter. Args: filter_name (str): Filter name used inside :program:`Jinja2` tags. filter_ref: Reference to the filter itself, i.e. the corresponding :program:`Python` function. ...
[ "def", "register_filter", "(", "self", ",", "filter_name", ",", "filter_ref", ",", "force", "=", "False", ")", ":", "if", "not", "force", "and", "(", "filter_name", "in", "self", ".", "filters_list", "(", ")", ")", ":", "self", ".", "log_warning", "(", ...
Add/register one filter. Args: filter_name (str): Filter name used inside :program:`Jinja2` tags. filter_ref: Reference to the filter itself, i.e. the corresponding :program:`Python` function. force (bool): If set to ``True``, forces the registration of a filter no matter if...
[ "Add", "/", "register", "one", "filter", "." ]
python
train
46.411765
bitlabstudio/django-rapid-prototyping
rapid_prototyping/context/utils.py
https://github.com/bitlabstudio/django-rapid-prototyping/blob/fd14ab5453bd7a0c2d5b973e8d96148963b03ab0/rapid_prototyping/context/utils.py#L84-L109
def append_overhead_costs(costs, new_id, overhead_percentage=0.15): """ Adds 15% overhead costs to the list of costs. Usage:: from rapid_prototyping.context.utils import append_overhead_costs costs = [ .... ] costs = append_overhead_costs(costs, MAIN_ID + get_co...
[ "def", "append_overhead_costs", "(", "costs", ",", "new_id", ",", "overhead_percentage", "=", "0.15", ")", ":", "total_time", "=", "0", "for", "item", "in", "costs", ":", "total_time", "+=", "item", "[", "'time'", "]", "costs", ".", "append", "(", "{", "...
Adds 15% overhead costs to the list of costs. Usage:: from rapid_prototyping.context.utils import append_overhead_costs costs = [ .... ] costs = append_overhead_costs(costs, MAIN_ID + get_counter(counter)[0]) :param costs: Your final list of costs. :param new_i...
[ "Adds", "15%", "overhead", "costs", "to", "the", "list", "of", "costs", "." ]
python
train
25.730769
uuazed/numerapi
numerapi/numerapi.py
https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L1409-L1426
def tournament_name2number(self, name): """Translate tournament name to tournament number. Args: name (str): tournament name to translate Returns: number (int): number of the tournament or `None` if unknown. Examples: >>> NumerAPI().tournament_name2...
[ "def", "tournament_name2number", "(", "self", ",", "name", ")", ":", "tournaments", "=", "self", ".", "get_tournaments", "(", ")", "d", "=", "{", "t", "[", "'name'", "]", ":", "t", "[", "'tournament'", "]", "for", "t", "in", "tournaments", "}", "return...
Translate tournament name to tournament number. Args: name (str): tournament name to translate Returns: number (int): number of the tournament or `None` if unknown. Examples: >>> NumerAPI().tournament_name2number('delta') 4 >>> Numer...
[ "Translate", "tournament", "name", "to", "tournament", "number", "." ]
python
train
31
sirfoga/pyhal
hal/meta/attributes.py
https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/meta/attributes.py#L34-L49
def _find_package(self, root_package): """Finds package name of file :param root_package: root package :return: package name """ package = self.path.replace(root_package, "") if package.endswith(".py"): package = package[:-3] package = package.repla...
[ "def", "_find_package", "(", "self", ",", "root_package", ")", ":", "package", "=", "self", ".", "path", ".", "replace", "(", "root_package", ",", "\"\"", ")", "if", "package", ".", "endswith", "(", "\".py\"", ")", ":", "package", "=", "package", "[", ...
Finds package name of file :param root_package: root package :return: package name
[ "Finds", "package", "name", "of", "file" ]
python
train
28.875
alan-turing-institute/topic-modelling-tools
topicmodels/preprocess.py
https://github.com/alan-turing-institute/topic-modelling-tools/blob/f0cf90cdd06f1072e824b446f201c7469b9de5df/topicmodels/preprocess.py#L108-L116
def stem(self): """ Stem tokens with Porter Stemmer. """ def s(tokens): return [PorterStemmer().stem(t) for t in tokens] self.stems = list(map(s, self.tokens))
[ "def", "stem", "(", "self", ")", ":", "def", "s", "(", "tokens", ")", ":", "return", "[", "PorterStemmer", "(", ")", ".", "stem", "(", "t", ")", "for", "t", "in", "tokens", "]", "self", ".", "stems", "=", "list", "(", "map", "(", "s", ",", "s...
Stem tokens with Porter Stemmer.
[ "Stem", "tokens", "with", "Porter", "Stemmer", "." ]
python
train
22.777778
lsbardel/python-stdnet
stdnet/odm/struct.py
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/struct.py#L708-L711
def rank(self, dte): '''The rank of a given *dte* in the timeseries''' timestamp = self.pickler.dumps(dte) return self.backend_structure().rank(timestamp)
[ "def", "rank", "(", "self", ",", "dte", ")", ":", "timestamp", "=", "self", ".", "pickler", ".", "dumps", "(", "dte", ")", "return", "self", ".", "backend_structure", "(", ")", ".", "rank", "(", "timestamp", ")" ]
The rank of a given *dte* in the timeseries
[ "The", "rank", "of", "a", "given", "*", "dte", "*", "in", "the", "timeseries" ]
python
train
44.5
misli/django-cms-articles
cms_articles/signals/title.py
https://github.com/misli/django-cms-articles/blob/d96ac77e049022deb4c70d268e4eab74d175145c/cms_articles/signals/title.py#L1-L12
def pre_save_title(instance, **kwargs): ''' Update article.languages ''' if instance.article.languages: languages = instance.article.languages.split(',') else: languages = [] if instance.language not in languages: languages.append(instance.language) instance.article.l...
[ "def", "pre_save_title", "(", "instance", ",", "*", "*", "kwargs", ")", ":", "if", "instance", ".", "article", ".", "languages", ":", "languages", "=", "instance", ".", "article", ".", "languages", ".", "split", "(", "','", ")", "else", ":", "languages",...
Update article.languages
[ "Update", "article", ".", "languages" ]
python
train
36.666667
FlorianRhiem/pyGLFW
glfw/__init__.py
https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L1099-L1118
def set_window_user_pointer(window, pointer): """ Sets the user pointer of the specified window. You may pass a normal python object into this function and it will be wrapped automatically. The object will be kept in existence until the pointer is set to something else or until the window is destroyed. ...
[ "def", "set_window_user_pointer", "(", "window", ",", "pointer", ")", ":", "data", "=", "(", "False", ",", "pointer", ")", "if", "not", "isinstance", "(", "pointer", ",", "ctypes", ".", "c_void_p", ")", ":", "data", "=", "(", "True", ",", "pointer", ")...
Sets the user pointer of the specified window. You may pass a normal python object into this function and it will be wrapped automatically. The object will be kept in existence until the pointer is set to something else or until the window is destroyed. Wrapper for: void glfwSetWindowUserPointer(GL...
[ "Sets", "the", "user", "pointer", "of", "the", "specified", "window", ".", "You", "may", "pass", "a", "normal", "python", "object", "into", "this", "function", "and", "it", "will", "be", "wrapped", "automatically", ".", "The", "object", "will", "be", "kept...
python
train
44.45
pybel/pybel
src/pybel/struct/filters/node_predicates.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/filters/node_predicates.py#L200-L205
def has_causal_out_edges(graph: BELGraph, node: BaseEntity) -> bool: """Return true if the node contains any out_edges that are causal.""" return any( data[RELATION] in CAUSAL_RELATIONS for _, _, data in graph.out_edges(node, data=True) )
[ "def", "has_causal_out_edges", "(", "graph", ":", "BELGraph", ",", "node", ":", "BaseEntity", ")", "->", "bool", ":", "return", "any", "(", "data", "[", "RELATION", "]", "in", "CAUSAL_RELATIONS", "for", "_", ",", "_", ",", "data", "in", "graph", ".", "...
Return true if the node contains any out_edges that are causal.
[ "Return", "true", "if", "the", "node", "contains", "any", "out_edges", "that", "are", "causal", "." ]
python
train
43.5
inbo/pyinaturalist
pyinaturalist/rest_api.py
https://github.com/inbo/pyinaturalist/blob/d380ede84bdf15eca8ccab9efefe08d2505fe6a8/pyinaturalist/rest_api.py#L146-L172
def create_observations(params: Dict[str, Dict[str, Any]], access_token: str) -> List[Dict[str, Any]]: """Create a single or several (if passed an array) observations). :param params: :param access_token: the access token, as returned by :func:`get_access_token()` :return: iNaturalist's JSON response,...
[ "def", "create_observations", "(", "params", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", "access_token", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "response", "=", "requests"...
Create a single or several (if passed an array) observations). :param params: :param access_token: the access token, as returned by :func:`get_access_token()` :return: iNaturalist's JSON response, as a Python object :raise: requests.HTTPError, if the call is not successful. iNaturalist returns an erro...
[ "Create", "a", "single", "or", "several", "(", "if", "passed", "an", "array", ")", "observations", ")", "." ]
python
train
49.777778
juicer/juicer
juicer/admin/JuicerAdmin.py
https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L47-L115
def create_repo(self, repo_name=None, feed=None, envs=[], checksum_type="sha256", query='/repositories/'): """ `repo_name` - Name of repository to create `feed` - Repo URL to feed from `checksum_type` - Used for generating meta-data Create repository in specified environments, a...
[ "def", "create_repo", "(", "self", ",", "repo_name", "=", "None", ",", "feed", "=", "None", ",", "envs", "=", "[", "]", ",", "checksum_type", "=", "\"sha256\"", ",", "query", "=", "'/repositories/'", ")", ":", "data", "=", "{", "'display_name'", ":", "...
`repo_name` - Name of repository to create `feed` - Repo URL to feed from `checksum_type` - Used for generating meta-data Create repository in specified environments, associate the yum_distributor with it and publish the repo
[ "repo_name", "-", "Name", "of", "repository", "to", "create", "feed", "-", "Repo", "URL", "to", "feed", "from", "checksum_type", "-", "Used", "for", "generating", "meta", "-", "data" ]
python
train
42.927536
merll/docker-fabric
dockerfabric/apiclient.py
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/apiclient.py#L294-L299
def start(self, container, **kwargs): """ Identical to :meth:`docker.api.container.ContainerApiMixin.start` with additional logging. """ self.push_log("Starting container '{0}'.".format(container)) super(DockerFabricClient, self).start(container, **kwargs)
[ "def", "start", "(", "self", ",", "container", ",", "*", "*", "kwargs", ")", ":", "self", ".", "push_log", "(", "\"Starting container '{0}'.\"", ".", "format", "(", "container", ")", ")", "super", "(", "DockerFabricClient", ",", "self", ")", ".", "start", ...
Identical to :meth:`docker.api.container.ContainerApiMixin.start` with additional logging.
[ "Identical", "to", ":", "meth", ":", "docker", ".", "api", ".", "container", ".", "ContainerApiMixin", ".", "start", "with", "additional", "logging", "." ]
python
train
48.5
inveniosoftware/invenio-communities
invenio_communities/views/ui.py
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/views/ui.py#L171-L209
def new(): """Create a new community.""" form = CommunityForm(formdata=request.values) ctx = mycommunities_ctx() ctx.update({ 'form': form, 'is_new': True, 'community': None, }) if form.validate_on_submit(): data = copy.deepcopy(form.data) community_id ...
[ "def", "new", "(", ")", ":", "form", "=", "CommunityForm", "(", "formdata", "=", "request", ".", "values", ")", "ctx", "=", "mycommunities_ctx", "(", ")", "ctx", ".", "update", "(", "{", "'form'", ":", "form", ",", "'is_new'", ":", "True", ",", "'com...
Create a new community.
[ "Create", "a", "new", "community", "." ]
python
train
29.538462
Diaoul/subliminal
subliminal/cli.py
https://github.com/Diaoul/subliminal/blob/a952dfb2032eb0fd6eb1eb89f04080923c11c4cf/subliminal/cli.py#L77-L80
def write(self): """Write the configuration to :attr:`path`""" with open(self.path, 'w') as f: self.config.write(f)
[ "def", "write", "(", "self", ")", ":", "with", "open", "(", "self", ".", "path", ",", "'w'", ")", "as", "f", ":", "self", ".", "config", ".", "write", "(", "f", ")" ]
Write the configuration to :attr:`path`
[ "Write", "the", "configuration", "to", ":", "attr", ":", "path" ]
python
train
35
log2timeline/plaso
plaso/multi_processing/engine.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/multi_processing/engine.py#L256-L274
def _RegisterProcess(self, process): """Registers a process with the engine. Args: process (MultiProcessBaseProcess): process. Raises: KeyError: if the process is already registered with the engine. ValueError: if the process is missing. """ if process is None: raise ValueE...
[ "def", "_RegisterProcess", "(", "self", ",", "process", ")", ":", "if", "process", "is", "None", ":", "raise", "ValueError", "(", "'Missing process.'", ")", "if", "process", ".", "pid", "in", "self", ".", "_processes_per_pid", ":", "raise", "KeyError", "(", ...
Registers a process with the engine. Args: process (MultiProcessBaseProcess): process. Raises: KeyError: if the process is already registered with the engine. ValueError: if the process is missing.
[ "Registers", "a", "process", "with", "the", "engine", "." ]
python
train
29.210526
knagra/farnsworth
legacy/views.py
https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/legacy/views.py#L93-L114
def legacy_events_view(request): """ View to see legacy events. """ events = TeacherEvent.objects.all() event_count = events.count() paginator = Paginator(events, 100) page = request.GET.get('page') try: events = paginator.page(page) except PageNotAnInteger: events =...
[ "def", "legacy_events_view", "(", "request", ")", ":", "events", "=", "TeacherEvent", ".", "objects", ".", "all", "(", ")", "event_count", "=", "events", ".", "count", "(", ")", "paginator", "=", "Paginator", "(", "events", ",", "100", ")", "page", "=", ...
View to see legacy events.
[ "View", "to", "see", "legacy", "events", "." ]
python
train
27.909091
thusoy/pwm
pwm/core.py
https://github.com/thusoy/pwm/blob/fff7d755c34f3a7235a8bf217ffa2ff5aed4926f/pwm/core.py#L112-L130
def _uses_db(func, self, *args, **kwargs): """ Use as a decorator for operations on the database, to ensure connection setup and teardown. Can only be used on methods on objects with a `self.session` attribute. """ if not self.session: _logger.debug('Creating new db session') self._init_...
[ "def", "_uses_db", "(", "func", ",", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "session", ":", "_logger", ".", "debug", "(", "'Creating new db session'", ")", "self", ".", "_init_db_session", "(", ")", "try"...
Use as a decorator for operations on the database, to ensure connection setup and teardown. Can only be used on methods on objects with a `self.session` attribute.
[ "Use", "as", "a", "decorator", "for", "operations", "on", "the", "database", "to", "ensure", "connection", "setup", "and", "teardown", ".", "Can", "only", "be", "used", "on", "methods", "on", "objects", "with", "a", "self", ".", "session", "attribute", "."...
python
test
32.421053
Diviyan-Kalainathan/CausalDiscoveryToolbox
cdt/causality/graph/CGNN.py
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/graph/CGNN.py#L315-L344
def orient_undirected_graph(self, data, umg, alg='HC'): """Orient the undirected graph using GNN and apply CGNN to improve the graph. Args: data (pandas.DataFrame): Observational data on which causal discovery has to be performed. umg (nx.Graph): Graph that provid...
[ "def", "orient_undirected_graph", "(", "self", ",", "data", ",", "umg", ",", "alg", "=", "'HC'", ")", ":", "warnings", ".", "warn", "(", "\"The pairwise GNN model is computed on each edge of the UMG \"", "\"to initialize the model and start CGNN with a DAG\"", ")", "gnn", ...
Orient the undirected graph using GNN and apply CGNN to improve the graph. Args: data (pandas.DataFrame): Observational data on which causal discovery has to be performed. umg (nx.Graph): Graph that provides the skeleton, on which the GNN then the CGNN algo...
[ "Orient", "the", "undirected", "graph", "using", "GNN", "and", "apply", "CGNN", "to", "improve", "the", "graph", "." ]
python
valid
48.633333
VIVelev/PyDojoML
dojo/losses.py
https://github.com/VIVelev/PyDojoML/blob/773fdce6866aa6decd306a5a85f94129fed816eb/dojo/losses.py#L75-L81
def gradient(self, P, Q, Y, i): """Computes the gradient of KL divergence with respect to the i'th example of Y""" return 4 * sum([ (P[i, j] - Q[i, j]) * (Y[i] - Y[j]) * (1 + np.linalg.norm(Y[i] - Y[j]) ** 2) ** -1 \ for j in range(Y.shape[0]) ])
[ "def", "gradient", "(", "self", ",", "P", ",", "Q", ",", "Y", ",", "i", ")", ":", "return", "4", "*", "sum", "(", "[", "(", "P", "[", "i", ",", "j", "]", "-", "Q", "[", "i", ",", "j", "]", ")", "*", "(", "Y", "[", "i", "]", "-", "Y"...
Computes the gradient of KL divergence with respect to the i'th example of Y
[ "Computes", "the", "gradient", "of", "KL", "divergence", "with", "respect", "to", "the", "i", "th", "example", "of", "Y" ]
python
train
41.285714
geronimp/graftM
graftm/greengenes_taxonomy.py
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/greengenes_taxonomy.py#L49-L53
def read_file(input_filename): '''Like read() except uses a file rather than an IO stream, for convenience''' with open(input_filename) as f: g = GreenGenesTaxonomy.read(f) return g
[ "def", "read_file", "(", "input_filename", ")", ":", "with", "open", "(", "input_filename", ")", "as", "f", ":", "g", "=", "GreenGenesTaxonomy", ".", "read", "(", "f", ")", "return", "g" ]
Like read() except uses a file rather than an IO stream, for convenience
[ "Like", "read", "()", "except", "uses", "a", "file", "rather", "than", "an", "IO", "stream", "for", "convenience" ]
python
train
42.6
samfoo/vt102
vt102/__init__.py
https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L836-L845
def _color_attr(self, ground, attr): """ Given a color attribute, set the current cursor appropriately. """ attr = colors[ground][attr] attrs = self.cursor_attributes if ground == "foreground": self.cursor_attributes = (attrs[0], attr, attrs[2]) elif ...
[ "def", "_color_attr", "(", "self", ",", "ground", ",", "attr", ")", ":", "attr", "=", "colors", "[", "ground", "]", "[", "attr", "]", "attrs", "=", "self", ".", "cursor_attributes", "if", "ground", "==", "\"foreground\"", ":", "self", ".", "cursor_attrib...
Given a color attribute, set the current cursor appropriately.
[ "Given", "a", "color", "attribute", "set", "the", "current", "cursor", "appropriately", "." ]
python
train
39.8
exxeleron/qPython
qpython/qconnection.py
https://github.com/exxeleron/qPython/blob/7e64a28b1e8814a8d6b9217ce79bb8de546e62f3/qpython/qconnection.py#L209-L245
def query(self, msg_type, query, *parameters, **options): '''Performs a query against a q service. In typical use case, `query` is the name of the function to call and `parameters` are its parameters. When `parameters` list is empty, the query can be an arbitrary q expression ...
[ "def", "query", "(", "self", ",", "msg_type", ",", "query", ",", "*", "parameters", ",", "*", "*", "options", ")", ":", "if", "not", "self", ".", "_connection", ":", "raise", "QConnectionException", "(", "'Connection is not established.'", ")", "if", "parame...
Performs a query against a q service. In typical use case, `query` is the name of the function to call and `parameters` are its parameters. When `parameters` list is empty, the query can be an arbitrary q expression (e.g. ``0 +/ til 100``). Calls a anonymous function ...
[ "Performs", "a", "query", "against", "a", "q", "service", ".", "In", "typical", "use", "case", "query", "is", "the", "name", "of", "the", "function", "to", "call", "and", "parameters", "are", "its", "parameters", ".", "When", "parameters", "list", "is", ...
python
train
43.540541
python-openxml/python-docx
docx/oxml/xmlchemy.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L296-L303
def _add_getter(self): """ Add a read-only ``{prop_name}`` property to the element class for this child element. """ property_ = property(self._getter, None, None) # assign unconditionally to overwrite element name definition setattr(self._element_cls, self._prop_...
[ "def", "_add_getter", "(", "self", ")", ":", "property_", "=", "property", "(", "self", ".", "_getter", ",", "None", ",", "None", ")", "# assign unconditionally to overwrite element name definition", "setattr", "(", "self", ".", "_element_cls", ",", "self", ".", ...
Add a read-only ``{prop_name}`` property to the element class for this child element.
[ "Add", "a", "read", "-", "only", "{", "prop_name", "}", "property", "to", "the", "element", "class", "for", "this", "child", "element", "." ]
python
train
41.125
WoLpH/python-statsd
statsd/timer.py
https://github.com/WoLpH/python-statsd/blob/a757da04375c48d03d322246405b33382d37f03f/statsd/timer.py#L127-L152
def decorate(self, function_or_name): '''Decorate a function to time the execution The method can be called with or without a name. If no name is given the function defaults to the name of the function. :keyword function_or_name: The name to post to or the function to wrap >>>...
[ "def", "decorate", "(", "self", ",", "function_or_name", ")", ":", "if", "callable", "(", "function_or_name", ")", ":", "return", "self", ".", "_decorate", "(", "function_or_name", ".", "__name__", ",", "function_or_name", ")", "else", ":", "return", "partial"...
Decorate a function to time the execution The method can be called with or without a name. If no name is given the function defaults to the name of the function. :keyword function_or_name: The name to post to or the function to wrap >>> from statsd import Timer >>> timer = Tim...
[ "Decorate", "a", "function", "to", "time", "the", "execution" ]
python
train
35.192308
etingof/pyasn1
pyasn1/type/univ.py
https://github.com/etingof/pyasn1/blob/25cf116ef8d11bb0e08454c0f3635c9f4002c2d6/pyasn1/type/univ.py#L2830-L2871
def setComponentByPosition(self, idx, value=noValue, verifyConstraints=True, matchTags=True, matchConstraints=True): """Assign |ASN.1| type component by position. Equivalent to Python sequence item assignment o...
[ "def", "setComponentByPosition", "(", "self", ",", "idx", ",", "value", "=", "noValue", ",", "verifyConstraints", "=", "True", ",", "matchTags", "=", "True", ",", "matchConstraints", "=", "True", ")", ":", "oldIdx", "=", "self", ".", "_currentIdx", "Set", ...
Assign |ASN.1| type component by position. Equivalent to Python sequence item assignment operation (e.g. `[]`). Parameters ---------- idx: :class:`int` Component index (zero-based). Must either refer to existing component or to N+1 component. In the latter case ...
[ "Assign", "|ASN", ".", "1|", "type", "component", "by", "position", "." ]
python
train
39.714286
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/account_management/account_management.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/account_management/account_management.py#L157-L174
def update_user(self, user_id, **kwargs): """Update user properties of specified user. :param str user_id: The ID of the user to update (Required) :param str username: The unique username of the user :param str email: The unique email of the user :param str full_name: The full n...
[ "def", "update_user", "(", "self", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "api", "=", "self", ".", "_get_api", "(", "iam", ".", "AccountAdminApi", ")", "user", "=", "User", ".", "_create_request_map", "(", "kwargs", ")", "body", "=", "iam",...
Update user properties of specified user. :param str user_id: The ID of the user to update (Required) :param str username: The unique username of the user :param str email: The unique email of the user :param str full_name: The full name of the user :param str password: The pass...
[ "Update", "user", "properties", "of", "specified", "user", "." ]
python
train
48.055556
sernst/cauldron
cauldron/cli/sync/sync_io.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/sync/sync_io.py#L95-L124
def write_file_chunk( file_path: str, packed_chunk: str, append: bool = True, offset: int = -1 ): """ Write or append the specified chunk data to the given file path, unpacking the chunk before writing. If the file does not yet exist, it will be created. Set the append ar...
[ "def", "write_file_chunk", "(", "file_path", ":", "str", ",", "packed_chunk", ":", "str", ",", "append", ":", "bool", "=", "True", ",", "offset", ":", "int", "=", "-", "1", ")", ":", "mode", "=", "'ab'", "if", "append", "else", "'wb'", "contents", "=...
Write or append the specified chunk data to the given file path, unpacking the chunk before writing. If the file does not yet exist, it will be created. Set the append argument to False if you do not want the chunk to be appended to an existing file. :param file_path: The file where the chunk w...
[ "Write", "or", "append", "the", "specified", "chunk", "data", "to", "the", "given", "file", "path", "unpacking", "the", "chunk", "before", "writing", ".", "If", "the", "file", "does", "not", "yet", "exist", "it", "will", "be", "created", ".", "Set", "the...
python
train
41.466667
CloudGenix/sdk-python
cloudgenix/__init__.py
https://github.com/CloudGenix/sdk-python/blob/1b2f92582b6a19769134914793bfd00e4caa074b/cloudgenix/__init__.py#L933-L997
def update_region_to_controller(self, region): """ Update the controller string with dynamic region info. Controller string should end up as `<name[-env]>.<region>.cloudgenix.com` **Parameters:** - **region:** region string. **Returns:** No return value, mutates the ...
[ "def", "update_region_to_controller", "(", "self", ",", "region", ")", ":", "# default region position in a list", "region_position", "=", "1", "# Check for a global \"ignore region\" flag", "if", "self", ".", "ignore_region", ":", "# bypass", "api_logger", ".", "debug", ...
Update the controller string with dynamic region info. Controller string should end up as `<name[-env]>.<region>.cloudgenix.com` **Parameters:** - **region:** region string. **Returns:** No return value, mutates the controller in the class namespace
[ "Update", "the", "controller", "string", "with", "dynamic", "region", "info", ".", "Controller", "string", "should", "end", "up", "as", "<name", "[", "-", "env", "]", ">", ".", "<region", ">", ".", "cloudgenix", ".", "com" ]
python
train
40.292308
ScottDuckworth/python-anyvcs
anyvcs/__init__.py
https://github.com/ScottDuckworth/python-anyvcs/blob/9eb09defbc6b7c99d373fad53cbf8fc81b637923/anyvcs/__init__.py#L32-L46
def clone(srcpath, destpath, vcs=None): """Clone an existing repository. :param str srcpath: Path to an existing repository :param str destpath: Desired path of new repository :param str vcs: Either ``git``, ``hg``, or ``svn`` :returns VCSRepo: The newly cloned repository If ``vcs`` is not giv...
[ "def", "clone", "(", "srcpath", ",", "destpath", ",", "vcs", "=", "None", ")", ":", "vcs", "=", "vcs", "or", "probe", "(", "srcpath", ")", "cls", "=", "_get_repo_class", "(", "vcs", ")", "return", "cls", ".", "clone", "(", "srcpath", ",", "destpath",...
Clone an existing repository. :param str srcpath: Path to an existing repository :param str destpath: Desired path of new repository :param str vcs: Either ``git``, ``hg``, or ``svn`` :returns VCSRepo: The newly cloned repository If ``vcs`` is not given, then the repository type is discovered from...
[ "Clone", "an", "existing", "repository", "." ]
python
train
33.333333
pmbarrett314/curses-menu
cursesmenu/curses_menu.py
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/curses_menu.py#L323-L335
def select(self): """ Select the current item and run it """ self.selected_option = self.current_option self.selected_item.set_up() self.selected_item.action() self.selected_item.clean_up() self.returned_value = self.selected_item.get_return() self...
[ "def", "select", "(", "self", ")", ":", "self", ".", "selected_option", "=", "self", ".", "current_option", "self", ".", "selected_item", ".", "set_up", "(", ")", "self", ".", "selected_item", ".", "action", "(", ")", "self", ".", "selected_item", ".", "...
Select the current item and run it
[ "Select", "the", "current", "item", "and", "run", "it" ]
python
test
31.615385
saltstack/salt
salt/modules/azurearm_dns.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/azurearm_dns.py#L81-L130
def record_set_create_or_update(name, zone_name, resource_group, record_type, **kwargs): ''' .. versionadded:: Fluorine Creates or updates a record set within a DNS zone. :param name: The name of the record set, relative to the name of the zone. :param zone_name: The name of the DNS zone (without...
[ "def", "record_set_create_or_update", "(", "name", ",", "zone_name", ",", "resource_group", ",", "record_type", ",", "*", "*", "kwargs", ")", ":", "dnsconn", "=", "__utils__", "[", "'azurearm.get_client'", "]", "(", "'dns'", ",", "*", "*", "kwargs", ")", "tr...
.. versionadded:: Fluorine Creates or updates a record set within a DNS zone. :param name: The name of the record set, relative to the name of the zone. :param zone_name: The name of the DNS zone (without a terminating dot). :param resource_group: The name of the resource group. :param record_t...
[ "..", "versionadded", "::", "Fluorine" ]
python
train
36.82
apache/airflow
airflow/_vendor/slugify/slugify.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/_vendor/slugify/slugify.py#L32-L71
def smart_truncate(string, max_length=0, word_boundary=False, separator=' ', save_order=False): """ Truncate a string. :param string (str): string for modification :param max_length (int): output string length :param word_boundary (bool): :param save_order (bool): if True then word order of outp...
[ "def", "smart_truncate", "(", "string", ",", "max_length", "=", "0", ",", "word_boundary", "=", "False", ",", "separator", "=", "' '", ",", "save_order", "=", "False", ")", ":", "string", "=", "string", ".", "strip", "(", "separator", ")", "if", "not", ...
Truncate a string. :param string (str): string for modification :param max_length (int): output string length :param word_boundary (bool): :param save_order (bool): if True then word order of output string is like input string :param separator (str): separator between words :return:
[ "Truncate", "a", "string", ".", ":", "param", "string", "(", "str", ")", ":", "string", "for", "modification", ":", "param", "max_length", "(", "int", ")", ":", "output", "string", "length", ":", "param", "word_boundary", "(", "bool", ")", ":", ":", "p...
python
test
30.1
saltstack/salt
salt/platform/win.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/platform/win.py#L1001-L1012
def grant_winsta_and_desktop(th): ''' Grant the token's user access to the current process's window station and desktop. ''' current_sid = win32security.GetTokenInformation(th, win32security.TokenUser)[0] # Add permissions for the sid to the current windows station and thread id. # This prev...
[ "def", "grant_winsta_and_desktop", "(", "th", ")", ":", "current_sid", "=", "win32security", ".", "GetTokenInformation", "(", "th", ",", "win32security", ".", "TokenUser", ")", "[", "0", "]", "# Add permissions for the sid to the current windows station and thread id.", "...
Grant the token's user access to the current process's window station and desktop.
[ "Grant", "the", "token", "s", "user", "access", "to", "the", "current", "process", "s", "window", "station", "and", "desktop", "." ]
python
train
47.5
saltstack/salt
salt/modules/defaults.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/defaults.py#L34-L71
def _load(formula): ''' Generates a list of salt://<formula>/defaults.(json|yaml) files and fetches them from the Salt master. Returns first defaults file as python dict. ''' # Compute possibilities _mk_client() paths = [] for ext in ('yaml', 'json'): source_url = salt.util...
[ "def", "_load", "(", "formula", ")", ":", "# Compute possibilities", "_mk_client", "(", ")", "paths", "=", "[", "]", "for", "ext", "in", "(", "'yaml'", ",", "'json'", ")", ":", "source_url", "=", "salt", ".", "utils", ".", "url", ".", "create", "(", ...
Generates a list of salt://<formula>/defaults.(json|yaml) files and fetches them from the Salt master. Returns first defaults file as python dict.
[ "Generates", "a", "list", "of", "salt", ":", "//", "<formula", ">", "/", "defaults", ".", "(", "json|yaml", ")", "files", "and", "fetches", "them", "from", "the", "Salt", "master", "." ]
python
train
30.921053
oscarbranson/latools
latools/filtering/filt_obj.py
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L409-L450
def grab_filt(self, filt, analyte=None): """ Flexible access to specific filter using any key format. Parameters ---------- f : str, dict or bool either logical filter expression, dict of expressions, or a boolean analyte : str name of...
[ "def", "grab_filt", "(", "self", ",", "filt", ",", "analyte", "=", "None", ")", ":", "if", "isinstance", "(", "filt", ",", "str", ")", ":", "if", "filt", "in", "self", ".", "components", ":", "if", "analyte", "is", "None", ":", "return", "self", "....
Flexible access to specific filter using any key format. Parameters ---------- f : str, dict or bool either logical filter expression, dict of expressions, or a boolean analyte : str name of analyte the filter is for. Returns ------- ...
[ "Flexible", "access", "to", "specific", "filter", "using", "any", "key", "format", "." ]
python
test
33.261905
skyfielders/python-skyfield
skyfield/iokit.py
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/iokit.py#L319-L335
def parse_deltat_data(fileobj): """Parse the United States Naval Observatory ``deltat.data`` file. Each line file gives the date and the value of Delta T:: 2016 2 1 68.1577 This function returns a 2xN array of raw Julian dates and matching Delta T values. """ array = np.loadtxt(fileob...
[ "def", "parse_deltat_data", "(", "fileobj", ")", ":", "array", "=", "np", ".", "loadtxt", "(", "fileobj", ")", "year", ",", "month", ",", "day", "=", "array", "[", "-", "1", ",", ":", "3", "]", ".", "astype", "(", "int", ")", "expiration_date", "="...
Parse the United States Naval Observatory ``deltat.data`` file. Each line file gives the date and the value of Delta T:: 2016 2 1 68.1577 This function returns a 2xN array of raw Julian dates and matching Delta T values.
[ "Parse", "the", "United", "States", "Naval", "Observatory", "deltat", ".", "data", "file", "." ]
python
train
31.647059
bwohlberg/sporco
sporco/linalg.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/linalg.py#L866-L901
def lu_solve_ATAI(A, rho, b, lu, piv, check_finite=True): r""" Solve the linear system :math:`(A^T A + \rho I)\mathbf{x} = \mathbf{b}` or :math:`(A^T A + \rho I)X = B` using :func:`scipy.linalg.lu_solve`. Parameters ---------- A : array_like Matrix :math:`A` rho : float Scalar :...
[ "def", "lu_solve_ATAI", "(", "A", ",", "rho", ",", "b", ",", "lu", ",", "piv", ",", "check_finite", "=", "True", ")", ":", "N", ",", "M", "=", "A", ".", "shape", "if", "N", ">=", "M", ":", "x", "=", "linalg", ".", "lu_solve", "(", "(", "lu", ...
r""" Solve the linear system :math:`(A^T A + \rho I)\mathbf{x} = \mathbf{b}` or :math:`(A^T A + \rho I)X = B` using :func:`scipy.linalg.lu_solve`. Parameters ---------- A : array_like Matrix :math:`A` rho : float Scalar :math:`\rho` b : array_like Vector :math:`\mathbf{b}`...
[ "r", "Solve", "the", "linear", "system", ":", "math", ":", "(", "A^T", "A", "+", "\\", "rho", "I", ")", "\\", "mathbf", "{", "x", "}", "=", "\\", "mathbf", "{", "b", "}", "or", ":", "math", ":", "(", "A^T", "A", "+", "\\", "rho", "I", ")", ...
python
train
31.805556
jaredLunde/redis_structures
redis_structures/__init__.py
https://github.com/jaredLunde/redis_structures/blob/b9cce5f5c85db5e12c292633ff8d04e3ae053294/redis_structures/__init__.py#L1472-L1474
def remove(self, item, count=0): """ Removes @item from the list for @count number of occurences """ self._client.lrem(self.key_prefix, count, self._dumps(item))
[ "def", "remove", "(", "self", ",", "item", ",", "count", "=", "0", ")", ":", "self", ".", "_client", ".", "lrem", "(", "self", ".", "key_prefix", ",", "count", ",", "self", ".", "_dumps", "(", "item", ")", ")" ]
Removes @item from the list for @count number of occurences
[ "Removes" ]
python
train
58.333333
facelessuser/backrefs
backrefs/bregex.py
https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/bregex.py#L387-L391
def expandf(m, format): # noqa A002 """Expand the string using the format replace pattern or function.""" _assert_expandable(format, True) return _apply_replace_backrefs(m, format, flags=FORMAT)
[ "def", "expandf", "(", "m", ",", "format", ")", ":", "# noqa A002", "_assert_expandable", "(", "format", ",", "True", ")", "return", "_apply_replace_backrefs", "(", "m", ",", "format", ",", "flags", "=", "FORMAT", ")" ]
Expand the string using the format replace pattern or function.
[ "Expand", "the", "string", "using", "the", "format", "replace", "pattern", "or", "function", "." ]
python
train
40.8
MacHu-GWU/uszipcode-project
uszipcode/pkg/sqlalchemy_mate/orm/extended_declarative_base.py
https://github.com/MacHu-GWU/uszipcode-project/blob/96282b779a3efb422802de83c48ca284598ba952/uszipcode/pkg/sqlalchemy_mate/orm/extended_declarative_base.py#L207-L266
def smart_insert(cls, engine_or_session, data, minimal_size=5, op_counter=0): """ An optimized Insert strategy. :return: number of insertion operation been executed. Usually it is greatly smaller than ``len(data)``. **中文文档** 在Insert中, 如果已经预知不会出现IntegrityError, 那么使用...
[ "def", "smart_insert", "(", "cls", ",", "engine_or_session", ",", "data", ",", "minimal_size", "=", "5", ",", "op_counter", "=", "0", ")", ":", "ses", ",", "auto_close", "=", "ensure_session", "(", "engine_or_session", ")", "if", "isinstance", "(", "data", ...
An optimized Insert strategy. :return: number of insertion operation been executed. Usually it is greatly smaller than ``len(data)``. **中文文档** 在Insert中, 如果已经预知不会出现IntegrityError, 那么使用Bulk Insert的速度要 远远快于逐条Insert。而如果无法预知, 那么我们采用如下策略: 1. 尝试Bulk Insert, Bulk Insert由于...
[ "An", "optimized", "Insert", "strategy", "." ]
python
train
31.983333
clusterpoint/python-client-api
pycps/response.py
https://github.com/clusterpoint/python-client-api/blob/fabf9bd8355aa54ba08fd6649e48f16e2c35eacd/pycps/response.py#L226-L266
def get_documents(self, doc_format='dict'): """ Get the documents returned from Storege in this response. Keyword args: doc_format -- Specifies the doc_format for the returned documents. Can be 'dict', 'etree' or 'string'. Default is 'dict'. Returns:...
[ "def", "get_documents", "(", "self", ",", "doc_format", "=", "'dict'", ")", ":", "def", "get_doc_id", "(", "root", ",", "rel_path", ")", ":", "if", "not", "rel_path", ":", "return", "root", ".", "text", "else", ":", "child", "=", "root", ".", "find", ...
Get the documents returned from Storege in this response. Keyword args: doc_format -- Specifies the doc_format for the returned documents. Can be 'dict', 'etree' or 'string'. Default is 'dict'. Returns: A dict where keys are document ids and ...
[ "Get", "the", "documents", "returned", "from", "Storege", "in", "this", "response", "." ]
python
train
44.902439
ArduPilot/MAVProxy
MAVProxy/modules/lib/mp_module.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_module.py#L150-L156
def dist_string(self, val_meters): '''return a distance as a string''' if self.settings.dist_unit == 'nm': return "%.1fnm" % (val_meters * 0.000539957) if self.settings.dist_unit == 'miles': return "%.1fmiles" % (val_meters * 0.000621371) return "%um" % val_meters
[ "def", "dist_string", "(", "self", ",", "val_meters", ")", ":", "if", "self", ".", "settings", ".", "dist_unit", "==", "'nm'", ":", "return", "\"%.1fnm\"", "%", "(", "val_meters", "*", "0.000539957", ")", "if", "self", ".", "settings", ".", "dist_unit", ...
return a distance as a string
[ "return", "a", "distance", "as", "a", "string" ]
python
train
44.857143
novopl/peltak
src/peltak/core/git.py
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L107-L119
def branches(self): # type: () -> List[str] """ List of all branches this commit is a part of. """ if self._branches is None: cmd = 'git branch --contains {}'.format(self.sha1) out = shell.run( cmd, capture=True, never_prete...
[ "def", "branches", "(", "self", ")", ":", "# type: () -> List[str]", "if", "self", ".", "_branches", "is", "None", ":", "cmd", "=", "'git branch --contains {}'", ".", "format", "(", "self", ".", "sha1", ")", "out", "=", "shell", ".", "run", "(", "cmd", "...
List of all branches this commit is a part of.
[ "List", "of", "all", "branches", "this", "commit", "is", "a", "part", "of", "." ]
python
train
34.615385
bennyrowland/suspect
suspect/io/philips.py
https://github.com/bennyrowland/suspect/blob/c09ab0a5013c5a199218214cdd791659243d7e41/suspect/io/philips.py#L69-L118
def _vax_to_ieee_single_float(data): """Converts a float in Vax format to IEEE format. data should be a single string of chars that have been read in from a binary file. These will be processed 4 at a time into float values. Thus the total number of byte/chars in the string should be divisible by 4...
[ "def", "_vax_to_ieee_single_float", "(", "data", ")", ":", "f", "=", "[", "]", "nfloat", "=", "int", "(", "len", "(", "data", ")", "/", "4", ")", "for", "i", "in", "range", "(", "nfloat", ")", ":", "byte2", "=", "data", "[", "0", "+", "i", "*",...
Converts a float in Vax format to IEEE format. data should be a single string of chars that have been read in from a binary file. These will be processed 4 at a time into float values. Thus the total number of byte/chars in the string should be divisible by 4. Based on VAX data organization in a b...
[ "Converts", "a", "float", "in", "Vax", "format", "to", "IEEE", "format", "." ]
python
train
32.16
madprime/cgivar2gvcf
cgivar2gvcf/__init__.py
https://github.com/madprime/cgivar2gvcf/blob/13b4cd8da08669f7e4b0ceed77a7a17082f91037/cgivar2gvcf/__init__.py#L65-L117
def process_full_position(data, header, var_only=False): """ Return genetic data when all alleles called on same line. Returns an array containing one item, a tuple of five items: (string) chromosome (string) start position (1-based) (array of strings) matching dbSNP entries ...
[ "def", "process_full_position", "(", "data", ",", "header", ",", "var_only", "=", "False", ")", ":", "feature_type", "=", "data", "[", "header", "[", "'varType'", "]", "]", "# Skip unmatchable, uncovered, or pseudoautosomal-in-X", "if", "(", "feature_type", "==", ...
Return genetic data when all alleles called on same line. Returns an array containing one item, a tuple of five items: (string) chromosome (string) start position (1-based) (array of strings) matching dbSNP entries (string) reference allele sequence (array of strings) the ge...
[ "Return", "genetic", "data", "when", "all", "alleles", "called", "on", "same", "line", "." ]
python
train
37.056604
ejeschke/ginga
ginga/util/wcs.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/wcs.py#L304-L318
def get_rotation_and_scale(header, skew_threshold=0.001): """Calculate rotation and CDELT.""" ((xrot, yrot), (cdelt1, cdelt2)) = get_xy_rotation_and_scale(header) if math.fabs(xrot) - math.fabs(yrot) > skew_threshold: raise ValueError("Skew detected: xrot=%.4f yrot=%.4f" % ( xrot, ...
[ "def", "get_rotation_and_scale", "(", "header", ",", "skew_threshold", "=", "0.001", ")", ":", "(", "(", "xrot", ",", "yrot", ")", ",", "(", "cdelt1", ",", "cdelt2", ")", ")", "=", "get_xy_rotation_and_scale", "(", "header", ")", "if", "math", ".", "fabs...
Calculate rotation and CDELT.
[ "Calculate", "rotation", "and", "CDELT", "." ]
python
train
31.2
greenelab/PathCORE-T
pathcore/network.py
https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L130-L153
def read_network_file(self, path_to_network_file): """ Parameters ----------- path_to_network_file : str Expects a network file with columns "pw0" and "pw1." A "features" column that specifies the features where the (pw0, pw1) edge is present will assign a w...
[ "def", "read_network_file", "(", "self", ",", "path_to_network_file", ")", ":", "network_df", "=", "pd", ".", "read_table", "(", "path_to_network_file", ")", "network_edges", "=", "{", "}", "for", "_", ",", "row", "in", "network_df", ".", "iterrows", "(", ")...
Parameters ----------- path_to_network_file : str Expects a network file with columns "pw0" and "pw1." A "features" column that specifies the features where the (pw0, pw1) edge is present will assign a weight to the edge, though it is not required (edge will have ...
[ "Parameters", "-----------", "path_to_network_file", ":", "str", "Expects", "a", "network", "file", "with", "columns", "pw0", "and", "pw1", ".", "A", "features", "column", "that", "specifies", "the", "features", "where", "the", "(", "pw0", "pw1", ")", "edge", ...
python
train
44.625
Microsoft/nni
src/sdk/pynni/nni/bohb_advisor/config_generator.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/config_generator.py#L114-L205
def sample_from_largest_budget(self, info_dict): """We opted for a single multidimensional KDE compared to the hierarchy of one-dimensional KDEs used in TPE. The dimensional is seperated by budget. This function sample a configuration from largest budget. Firstly we sample "num_samples" ...
[ "def", "sample_from_largest_budget", "(", "self", ",", "info_dict", ")", ":", "best", "=", "np", ".", "inf", "best_vector", "=", "None", "budget", "=", "max", "(", "self", ".", "kde_models", ".", "keys", "(", ")", ")", "l", "=", "self", ".", "kde_model...
We opted for a single multidimensional KDE compared to the hierarchy of one-dimensional KDEs used in TPE. The dimensional is seperated by budget. This function sample a configuration from largest budget. Firstly we sample "num_samples" configurations, then prefer one with the largest l(x...
[ "We", "opted", "for", "a", "single", "multidimensional", "KDE", "compared", "to", "the", "hierarchy", "of", "one", "-", "dimensional", "KDEs", "used", "in", "TPE", ".", "The", "dimensional", "is", "seperated", "by", "budget", ".", "This", "function", "sample...
python
train
41.5