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
jd/tenacity
tenacity/compat.py
https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L269-L286
def before_sleep_func_accept_retry_state(fn): """Wrap "before_sleep" function to accept "retry_state".""" if not six.callable(fn): return fn if func_takes_retry_state(fn): return fn @_utils.wraps(fn) def wrapped_before_sleep_func(retry_state): # retry_object, sleep, last_re...
[ "def", "before_sleep_func_accept_retry_state", "(", "fn", ")", ":", "if", "not", "six", ".", "callable", "(", "fn", ")", ":", "return", "fn", "if", "func_takes_retry_state", "(", "fn", ")", ":", "return", "fn", "@", "_utils", ".", "wraps", "(", "fn", ")"...
Wrap "before_sleep" function to accept "retry_state".
[ "Wrap", "before_sleep", "function", "to", "accept", "retry_state", "." ]
python
train
33.388889
uogbuji/versa
tools/py/driver/memory.py
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/driver/memory.py#L135-L166
def add(self, origin, rel, target, attrs=None, index=None): ''' Add one relationship to the extent origin - origin of the relationship (similar to an RDF subject) rel - type IRI of the relationship (similar to an RDF predicate) target - target of the relationship (similar to an ...
[ "def", "add", "(", "self", ",", "origin", ",", "rel", ",", "target", ",", "attrs", "=", "None", ",", "index", "=", "None", ")", ":", "#FIXME: return an ID (IRI) for the resulting relationship?", "if", "not", "origin", ":", "raise", "ValueError", "(", "'Relatio...
Add one relationship to the extent origin - origin of the relationship (similar to an RDF subject) rel - type IRI of the relationship (similar to an RDF predicate) target - target of the relationship (similar to an RDF object), a boolean, floating point or unicode object attrs - optiona...
[ "Add", "one", "relationship", "to", "the", "extent" ]
python
train
43.96875
dcos/shakedown
shakedown/dcos/__init__.py
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/__init__.py#L114-L130
def authenticate(username, password): """Authenticate with a DC/OS cluster and return an ACS token. return: ACS token """ url = _gen_url('acs/api/v1/auth/login') creds = { 'uid': username, 'password': password } response = dcos.http.request('post', url, json=creds) if ...
[ "def", "authenticate", "(", "username", ",", "password", ")", ":", "url", "=", "_gen_url", "(", "'acs/api/v1/auth/login'", ")", "creds", "=", "{", "'uid'", ":", "username", ",", "'password'", ":", "password", "}", "response", "=", "dcos", ".", "http", ".",...
Authenticate with a DC/OS cluster and return an ACS token. return: ACS token
[ "Authenticate", "with", "a", "DC", "/", "OS", "cluster", "and", "return", "an", "ACS", "token", ".", "return", ":", "ACS", "token" ]
python
train
23.647059
kdeldycke/maildir-deduplicate
maildir_deduplicate/cli.py
https://github.com/kdeldycke/maildir-deduplicate/blob/f1c6ff25b80c6c1a4dc2dc7a65b34d808b0b7733/maildir_deduplicate/cli.py#L140-L211
def deduplicate( ctx, strategy, time_source, regexp, dry_run, message_id, size_threshold, content_threshold, show_diff, maildirs): """ Deduplicate mails from a set of maildir folders. Run a first pass computing the canonical hash of each encountered mail from their headers, then a second pa...
[ "def", "deduplicate", "(", "ctx", ",", "strategy", ",", "time_source", ",", "regexp", ",", "dry_run", ",", "message_id", ",", "size_threshold", ",", "content_threshold", ",", "show_diff", ",", "maildirs", ")", ":", "# Print help screen and exit if no maildir folder pr...
Deduplicate mails from a set of maildir folders. Run a first pass computing the canonical hash of each encountered mail from their headers, then a second pass to apply the deletion strategy on each subset of duplicate mails. \b Removal strategies for each subsets of duplicate mails: - delete...
[ "Deduplicate", "mails", "from", "a", "set", "of", "maildir", "folders", "." ]
python
train
40.833333
googleapis/google-auth-library-python
google/auth/_default.py
https://github.com/googleapis/google-auth-library-python/blob/2c6ad78917e936f38f87c946209c8031166dc96e/google/auth/_default.py#L138-L155
def _get_gcloud_sdk_credentials(): """Gets the credentials and project ID from the Cloud SDK.""" from google.auth import _cloud_sdk # Check if application default credentials exist. credentials_filename = ( _cloud_sdk.get_application_default_credentials_path()) if not os.path.isfile(creden...
[ "def", "_get_gcloud_sdk_credentials", "(", ")", ":", "from", "google", ".", "auth", "import", "_cloud_sdk", "# Check if application default credentials exist.", "credentials_filename", "=", "(", "_cloud_sdk", ".", "get_application_default_credentials_path", "(", ")", ")", "...
Gets the credentials and project ID from the Cloud SDK.
[ "Gets", "the", "credentials", "and", "project", "ID", "from", "the", "Cloud", "SDK", "." ]
python
train
30.222222
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/core.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/core.py#L348-L355
def to_dict(self): """Return dictionary of object.""" dictionary = {} for key, value in iteritems(self.__dict__): property_name = key[1:] if hasattr(self, property_name): dictionary.update({property_name: getattr(self, property_name, None)}) return...
[ "def", "to_dict", "(", "self", ")", ":", "dictionary", "=", "{", "}", "for", "key", ",", "value", "in", "iteritems", "(", "self", ".", "__dict__", ")", ":", "property_name", "=", "key", "[", "1", ":", "]", "if", "hasattr", "(", "self", ",", "proper...
Return dictionary of object.
[ "Return", "dictionary", "of", "object", "." ]
python
train
40.5
jmgilman/Neolib
neolib/HTMLFilter.py
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/HTMLFilter.py#L31-L53
def handleHTML(self, record): """ Saves the given record's page content to a .html file Attributes record (Record) -- The log record """ # Create a unique file name to identify where this HTML source is coming from fileName = datetime.today().strftime("Neolib ...
[ "def", "handleHTML", "(", "self", ",", "record", ")", ":", "# Create a unique file name to identify where this HTML source is coming from", "fileName", "=", "datetime", ".", "today", "(", ")", ".", "strftime", "(", "\"Neolib %Y-%m-%d %H-%M-%S \"", ")", "+", "record", "....
Saves the given record's page content to a .html file Attributes record (Record) -- The log record
[ "Saves", "the", "given", "record", "s", "page", "content", "to", "a", ".", "html", "file", "Attributes", "record", "(", "Record", ")", "--", "The", "log", "record" ]
python
train
43.869565
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L8839-L8859
def ncposr(string, chars, start): """ Find the first occurrence in a string of a character NOT belonging to a collection of characters, starting at a specified location, searching in reverse. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ncposr_c.html :param string: Any character str...
[ "def", "ncposr", "(", "string", ",", "chars", ",", "start", ")", ":", "string", "=", "stypes", ".", "stringToCharP", "(", "string", ")", "chars", "=", "stypes", ".", "stringToCharP", "(", "chars", ")", "start", "=", "ctypes", ".", "c_int", "(", "start"...
Find the first occurrence in a string of a character NOT belonging to a collection of characters, starting at a specified location, searching in reverse. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ncposr_c.html :param string: Any character string. :type string: str :param chars: A...
[ "Find", "the", "first", "occurrence", "in", "a", "string", "of", "a", "character", "NOT", "belonging", "to", "a", "collection", "of", "characters", "starting", "at", "a", "specified", "location", "searching", "in", "reverse", "." ]
python
train
32.571429
google/grr
grr/core/grr_response_core/lib/util/compat/yaml.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/util/compat/yaml.py#L177-L185
def WriteManyToPath(objs, filepath): """Serializes and writes given Python objects to a multi-document YAML file. Args: objs: An iterable of Python objects to serialize. filepath: A path to the file into which the object is to be written. """ with io.open(filepath, mode="w", encoding="utf-8") as filede...
[ "def", "WriteManyToPath", "(", "objs", ",", "filepath", ")", ":", "with", "io", ".", "open", "(", "filepath", ",", "mode", "=", "\"w\"", ",", "encoding", "=", "\"utf-8\"", ")", "as", "filedesc", ":", "WriteManyToFile", "(", "objs", ",", "filedesc", ")" ]
Serializes and writes given Python objects to a multi-document YAML file. Args: objs: An iterable of Python objects to serialize. filepath: A path to the file into which the object is to be written.
[ "Serializes", "and", "writes", "given", "Python", "objects", "to", "a", "multi", "-", "document", "YAML", "file", "." ]
python
train
39
gwastro/pycbc-glue
pycbc_glue/segments.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/segments.py#L1154-L1164
def extend(self, other): """ Appends the segmentlists from other to the corresponding segmentlists in self, adding new segmentslists to self as needed. """ for key, value in other.iteritems(): if key not in self: self[key] = _shallowcopy(value) else: self[key].extend(value)
[ "def", "extend", "(", "self", ",", "other", ")", ":", "for", "key", ",", "value", "in", "other", ".", "iteritems", "(", ")", ":", "if", "key", "not", "in", "self", ":", "self", "[", "key", "]", "=", "_shallowcopy", "(", "value", ")", "else", ":",...
Appends the segmentlists from other to the corresponding segmentlists in self, adding new segmentslists to self as needed.
[ "Appends", "the", "segmentlists", "from", "other", "to", "the", "corresponding", "segmentlists", "in", "self", "adding", "new", "segmentslists", "to", "self", "as", "needed", "." ]
python
train
26.363636
vslutov/turingmarkov
turingmarkov/markov.py
https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/markov.py#L51-L59
def execute_once(self, string): """Execute only one rule.""" for rule in self.rules: if rule[0] in string: pos = string.find(rule[0]) self.last_rule = rule return string[:pos] + rule[1] + string[pos+len(rule[0]):] self.last_rule = None ...
[ "def", "execute_once", "(", "self", ",", "string", ")", ":", "for", "rule", "in", "self", ".", "rules", ":", "if", "rule", "[", "0", "]", "in", "string", ":", "pos", "=", "string", ".", "find", "(", "rule", "[", "0", "]", ")", "self", ".", "las...
Execute only one rule.
[ "Execute", "only", "one", "rule", "." ]
python
train
37
satellogic/telluric
telluric/georaster.py
https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L724-L726
def tags(cls, filename, namespace=None): """Extract tags from file.""" return cls._raster_opener(filename).tags(ns=namespace)
[ "def", "tags", "(", "cls", ",", "filename", ",", "namespace", "=", "None", ")", ":", "return", "cls", ".", "_raster_opener", "(", "filename", ")", ".", "tags", "(", "ns", "=", "namespace", ")" ]
Extract tags from file.
[ "Extract", "tags", "from", "file", "." ]
python
train
46.333333
mitsei/dlkit
dlkit/json_/repository/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L581-L619
def get_asset_contents_by_ids(self, asset_content_ids): """Gets an ``AssetList`` corresponding to the given ``IdList``. In plenary mode, the returned list contains all of the asset contents specified in the ``Id`` list, in the order of the list, including duplicates, or an error results...
[ "def", "get_asset_contents_by_ids", "(", "self", ",", "asset_content_ids", ")", ":", "collection", "=", "JSONClientValidated", "(", "'repository'", ",", "collection", "=", "'Asset'", ",", "runtime", "=", "self", ".", "_runtime", ")", "object_id_list", "=", "[", ...
Gets an ``AssetList`` corresponding to the given ``IdList``. In plenary mode, the returned list contains all of the asset contents specified in the ``Id`` list, in the order of the list, including duplicates, or an error results if an ``Id`` in the supplied list is not found or inaccess...
[ "Gets", "an", "AssetList", "corresponding", "to", "the", "given", "IdList", "." ]
python
train
51.307692
Jammy2211/PyAutoLens
autolens/lens/ray_tracing.py
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/ray_tracing.py#L46-L74
def check_tracer_for_mass_profile(func): """If none of the tracer's galaxies have a mass profile, it surface density, potential and deflections cannot \ be computed. This wrapper makes these properties return *None*. Parameters ---------- func : (self) -> Object A property function that req...
[ "def", "check_tracer_for_mass_profile", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ")", ":", "\"\"\"\n\n Parameters\n ----------\n self\n\n Returns\n -------\n A value or coordinate in the same...
If none of the tracer's galaxies have a mass profile, it surface density, potential and deflections cannot \ be computed. This wrapper makes these properties return *None*. Parameters ---------- func : (self) -> Object A property function that requires galaxies to have a mass profile.
[ "If", "none", "of", "the", "tracer", "s", "galaxies", "have", "a", "mass", "profile", "it", "surface", "density", "potential", "and", "deflections", "cannot", "\\", "be", "computed", ".", "This", "wrapper", "makes", "these", "properties", "return", "*", "Non...
python
valid
24.241379
jaraco/jaraco.compat
py31compat/cache.py
https://github.com/jaraco/jaraco.compat/blob/e61efd45d92e3c7db6d8fb28d47f38f43193a6f5/py31compat/cache.py#L35-L148
def lru_cache(maxsize=100, typed=False): """Least-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. If *typed* is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated as distinct ca...
[ "def", "lru_cache", "(", "maxsize", "=", "100", ",", "typed", "=", "False", ")", ":", "# Users should only access the lru_cache through its public API:", "# cache_info, cache_clear, and f.__wrapped__", "# The internals of the lru_cache are encapsulated for thread safety and", "# to...
Least-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. If *typed* is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated as distinct calls with distinct results. Arguments to th...
[ "Least", "-", "recently", "-", "used", "cache", "decorator", "." ]
python
train
29.473684
opencobra/cobrapy
cobra/io/sbml.py
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L105-L108
def _f_gene(sid, prefix="G_"): """Clips gene prefix from id.""" sid = sid.replace(SBML_DOT, ".") return _clip(sid, prefix)
[ "def", "_f_gene", "(", "sid", ",", "prefix", "=", "\"G_\"", ")", ":", "sid", "=", "sid", ".", "replace", "(", "SBML_DOT", ",", "\".\"", ")", "return", "_clip", "(", "sid", ",", "prefix", ")" ]
Clips gene prefix from id.
[ "Clips", "gene", "prefix", "from", "id", "." ]
python
valid
32.75
10gen/mongo-orchestration
mongo_orchestration/replica_sets.py
https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L323-L338
def member_del(self, member_id, reconfig=True): """remove member from replica set Args: member_id - member index reconfig - is need reconfig replica return True if operation success otherwise False """ server_id = self._servers.host_to_server_id( ...
[ "def", "member_del", "(", "self", ",", "member_id", ",", "reconfig", "=", "True", ")", ":", "server_id", "=", "self", ".", "_servers", ".", "host_to_server_id", "(", "self", ".", "member_id_to_host", "(", "member_id", ")", ")", "if", "reconfig", "and", "me...
remove member from replica set Args: member_id - member index reconfig - is need reconfig replica return True if operation success otherwise False
[ "remove", "member", "from", "replica", "set", "Args", ":", "member_id", "-", "member", "index", "reconfig", "-", "is", "need", "reconfig", "replica" ]
python
train
37.5625
saltstack/salt
salt/modules/kapacitor.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kapacitor.py#L55-L63
def _get_url(): ''' Get the kapacitor URL. ''' protocol = __salt__['config.option']('kapacitor.protocol', 'http') host = __salt__['config.option']('kapacitor.host', 'localhost') port = __salt__['config.option']('kapacitor.port', 9092) return '{0}://{1}:{2}'.format(protocol, host, port)
[ "def", "_get_url", "(", ")", ":", "protocol", "=", "__salt__", "[", "'config.option'", "]", "(", "'kapacitor.protocol'", ",", "'http'", ")", "host", "=", "__salt__", "[", "'config.option'", "]", "(", "'kapacitor.host'", ",", "'localhost'", ")", "port", "=", ...
Get the kapacitor URL.
[ "Get", "the", "kapacitor", "URL", "." ]
python
train
34.111111
Azure/azure-uamqp-python
uamqp/message.py
https://github.com/Azure/azure-uamqp-python/blob/b67e4fcaf2e8a337636947523570239c10a58ae2/uamqp/message.py#L134-L174
def _parse_message(self, message): """Parse a message received from an AMQP service. :param message: The received C message. :type message: uamqp.c_uamqp.cMessage """ _logger.debug("Parsing received message %r.", self.delivery_no) self._message = message body_typ...
[ "def", "_parse_message", "(", "self", ",", "message", ")", ":", "_logger", ".", "debug", "(", "\"Parsing received message %r.\"", ",", "self", ".", "delivery_no", ")", "self", ".", "_message", "=", "message", "body_type", "=", "message", ".", "body_type", "if"...
Parse a message received from an AMQP service. :param message: The received C message. :type message: uamqp.c_uamqp.cMessage
[ "Parse", "a", "message", "received", "from", "an", "AMQP", "service", "." ]
python
train
48.487805
pyblish/pyblish-qml
pyblish_qml/ipc/client.py
https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/ipc/client.py#L145-L187
def _dispatch(self, func, args=None): """Send message to parent process Arguments: func (str): Name of function for parent to call args (list, optional): Arguments passed to function when called """ data = json.dumps( { "header": "py...
[ "def", "_dispatch", "(", "self", ",", "func", ",", "args", "=", "None", ")", ":", "data", "=", "json", ".", "dumps", "(", "{", "\"header\"", ":", "\"pyblish-qml:popen.request\"", ",", "\"payload\"", ":", "{", "\"name\"", ":", "func", ",", "\"args\"", ":"...
Send message to parent process Arguments: func (str): Name of function for parent to call args (list, optional): Arguments passed to function when called
[ "Send", "message", "to", "parent", "process" ]
python
train
30.093023
3ll3d00d/vibe
backend/src/analyser/common/devicecontroller.py
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/devicecontroller.py#L118-L139
def scheduleMeasurement(self, measurementId, duration, start): """ Schedules the requested measurement session with all INITIALISED devices. :param measurementId: :param duration: :param start: :return: a dict of device vs status. """ # TODO subtract 1s fr...
[ "def", "scheduleMeasurement", "(", "self", ",", "measurementId", ",", "duration", ",", "start", ")", ":", "# TODO subtract 1s from start and format", "results", "=", "{", "}", "for", "device", "in", "self", ".", "getDevices", "(", "RecordingDeviceStatus", ".", "IN...
Schedules the requested measurement session with all INITIALISED devices. :param measurementId: :param duration: :param start: :return: a dict of device vs status.
[ "Schedules", "the", "requested", "measurement", "session", "with", "all", "INITIALISED", "devices", ".", ":", "param", "measurementId", ":", ":", "param", "duration", ":", ":", "param", "start", ":", ":", "return", ":", "a", "dict", "of", "device", "vs", "...
python
train
50.227273
markchil/gptools
gptools/kernel/matern.py
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L296-L312
def _compute_k(self, tau): r"""Evaluate the kernel directly at the given values of `tau`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. Returns ------- k : :py:class:`Array`, (`M`,) ...
[ "def", "_compute_k", "(", "self", ",", "tau", ")", ":", "y", ",", "r2l2", "=", "self", ".", "_compute_y", "(", "tau", ",", "return_r2l2", "=", "True", ")", "k", "=", "2.0", "**", "(", "1.0", "-", "self", ".", "nu", ")", "/", "scipy", ".", "spec...
r"""Evaluate the kernel directly at the given values of `tau`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. Returns ------- k : :py:class:`Array`, (`M`,) :math:`k(\tau)` (less the :math...
[ "r", "Evaluate", "the", "kernel", "directly", "at", "the", "given", "values", "of", "tau", ".", "Parameters", "----------", "tau", ":", ":", "py", ":", "class", ":", "Matrix", "(", "M", "D", ")", "M", "inputs", "with", "dimension", "D", ".", "Returns",...
python
train
35.470588
vadimk2016/v-vk-api
v_vk_api/session.py
https://github.com/vadimk2016/v-vk-api/blob/ef5656e09944b5319a1f573cfb7b022f3d31c0cf/v_vk_api/session.py#L93-L106
def login(self) -> bool: """ Authorizes a user and returns a bool value of the result """ response = self.get(self.LOGIN_URL) login_url = get_base_url(response.text) login_data = {'email': self._login, 'pass': self._password} login_response = self.post(login_url, ...
[ "def", "login", "(", "self", ")", "->", "bool", ":", "response", "=", "self", ".", "get", "(", "self", ".", "LOGIN_URL", ")", "login_url", "=", "get_base_url", "(", "response", ".", "text", ")", "login_data", "=", "{", "'email'", ":", "self", ".", "_...
Authorizes a user and returns a bool value of the result
[ "Authorizes", "a", "user", "and", "returns", "a", "bool", "value", "of", "the", "result" ]
python
train
45.642857
linkedin/naarad
src/naarad/metrics/top_metric.py
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L96-L120
def process_top_line(self, words): """ Process the line starting with "top" Example log: top - 00:00:02 up 32 days, 7:08, 19 users, load average: 0.00, 0.00, 0.00 """ self.ts_time = words[2] self.ts = self.ts_date + ' ' + self.ts_time self.ts = ts = naarad.utils.get_standardized_timestam...
[ "def", "process_top_line", "(", "self", ",", "words", ")", ":", "self", ".", "ts_time", "=", "words", "[", "2", "]", "self", ".", "ts", "=", "self", ".", "ts_date", "+", "' '", "+", "self", ".", "ts_time", "self", ".", "ts", "=", "ts", "=", "naar...
Process the line starting with "top" Example log: top - 00:00:02 up 32 days, 7:08, 19 users, load average: 0.00, 0.00, 0.00
[ "Process", "the", "line", "starting", "with", "top", "Example", "log", ":", "top", "-", "00", ":", "00", ":", "02", "up", "32", "days", "7", ":", "08", "19", "users", "load", "average", ":", "0", ".", "00", "0", ".", "00", "0", ".", "00" ]
python
valid
38.52
santoshphilip/eppy
eppy/bunch_subclass.py
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/bunch_subclass.py#L380-L399
def getrange(bch, fieldname): """get the ranges for this field""" keys = ['maximum', 'minimum', 'maximum<', 'minimum>', 'type'] index = bch.objls.index(fieldname) fielddct_orig = bch.objidd[index] fielddct = copy.deepcopy(fielddct_orig) therange = {} for key in keys: therange[key] = ...
[ "def", "getrange", "(", "bch", ",", "fieldname", ")", ":", "keys", "=", "[", "'maximum'", ",", "'minimum'", ",", "'maximum<'", ",", "'minimum>'", ",", "'type'", "]", "index", "=", "bch", ".", "objls", ".", "index", "(", "fieldname", ")", "fielddct_orig",...
get the ranges for this field
[ "get", "the", "ranges", "for", "this", "field" ]
python
train
36.3
ejhigson/nestcheck
nestcheck/estimators.py
https://github.com/ejhigson/nestcheck/blob/29151c314deb89746fd674f27f6ce54b77603189/nestcheck/estimators.py#L265-L316
def get_latex_name(func_in, **kwargs): """ Produce a latex formatted name for each function for use in labelling results. Parameters ---------- func_in: function kwargs: dict, optional Kwargs for function. Returns ------- latex_name: str Latex formatted name for...
[ "def", "get_latex_name", "(", "func_in", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "func_in", ",", "functools", ".", "partial", ")", ":", "func", "=", "func_in", ".", "func", "assert", "not", "set", "(", "func_in", ".", "keywords", ")...
Produce a latex formatted name for each function for use in labelling results. Parameters ---------- func_in: function kwargs: dict, optional Kwargs for function. Returns ------- latex_name: str Latex formatted name for the function.
[ "Produce", "a", "latex", "formatted", "name", "for", "each", "function", "for", "use", "in", "labelling", "results", "." ]
python
train
35.596154
vingd/encrypted-pickle-python
encryptedpickle/encryptedpickle.py
https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L623-L634
def _remove_header(self, data, options): '''Remove header from data''' version_info = self._get_version_info(options['version']) header_size = version_info['header_size'] if options['flags']['timestamp']: header_size += version_info['timestamp_size'] data = data[he...
[ "def", "_remove_header", "(", "self", ",", "data", ",", "options", ")", ":", "version_info", "=", "self", ".", "_get_version_info", "(", "options", "[", "'version'", "]", ")", "header_size", "=", "version_info", "[", "'header_size'", "]", "if", "options", "[...
Remove header from data
[ "Remove", "header", "from", "data" ]
python
valid
28.416667
dpkp/kafka-python
kafka/admin/client.py
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L266-L302
def _find_group_coordinator_id(self, group_id): """Find the broker node_id of the coordinator of the given group. Sends a FindCoordinatorRequest message to the cluster. Will block until the FindCoordinatorResponse is received. Any errors are immediately raised. :param group_id:...
[ "def", "_find_group_coordinator_id", "(", "self", ",", "group_id", ")", ":", "# Note: Java may change how this is implemented in KAFKA-6791.", "#", "# TODO add support for dynamically picking version of", "# GroupCoordinatorRequest which was renamed to FindCoordinatorRequest.", "# When I exp...
Find the broker node_id of the coordinator of the given group. Sends a FindCoordinatorRequest message to the cluster. Will block until the FindCoordinatorResponse is received. Any errors are immediately raised. :param group_id: The consumer group ID. This is typically the group ...
[ "Find", "the", "broker", "node_id", "of", "the", "coordinator", "of", "the", "given", "group", "." ]
python
train
55.405405
coldfix/udiskie
udiskie/locale.py
https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/locale.py#L11-L17
def _(text, *args, **kwargs): """Translate and then and format the text with ``str.format``.""" msg = _t.gettext(text) if args or kwargs: return msg.format(*args, **kwargs) else: return msg
[ "def", "_", "(", "text", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "_t", ".", "gettext", "(", "text", ")", "if", "args", "or", "kwargs", ":", "return", "msg", ".", "format", "(", "*", "args", ",", "*", "*", "kwargs", ")...
Translate and then and format the text with ``str.format``.
[ "Translate", "and", "then", "and", "format", "the", "text", "with", "str", ".", "format", "." ]
python
train
30.714286
qubole/qds-sdk-py
qds_sdk/commands.py
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/commands.py#L1306-L1359
def parse(cls, args): """ Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ...
[ "def", "parse", "(", "cls", ",", "args", ")", ":", "try", ":", "(", "options", ",", "args", ")", "=", "cls", ".", "optparser", ".", "parse_args", "(", "args", ")", "if", "options", ".", "db_tap_id", "is", "None", ":", "raise", "ParseError", "(", "\...
Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ParseError: when the arguments are no...
[ "Parse", "command", "line", "arguments", "to", "construct", "a", "dictionary", "of", "command", "parameters", "that", "can", "be", "used", "to", "create", "a", "command" ]
python
train
37.314815
tanghaibao/jcvi
jcvi/variation/deconvolute.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/variation/deconvolute.py#L39-L44
def unpack_ambiguous(s): """ List sequences with ambiguous characters in all possibilities. """ sd = [ambiguous_dna_values[x] for x in s] return ["".join(x) for x in list(product(*sd))]
[ "def", "unpack_ambiguous", "(", "s", ")", ":", "sd", "=", "[", "ambiguous_dna_values", "[", "x", "]", "for", "x", "in", "s", "]", "return", "[", "\"\"", ".", "join", "(", "x", ")", "for", "x", "in", "list", "(", "product", "(", "*", "sd", ")", ...
List sequences with ambiguous characters in all possibilities.
[ "List", "sequences", "with", "ambiguous", "characters", "in", "all", "possibilities", "." ]
python
train
33.333333
coghost/izen
izen/helper.py
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L1225-L1240
def _disp_width(self, pwcs, n=None): """ A wcswidth that never gives -1. Copying existing code is evil, but.. github.com/jquast/wcwidth/blob/07cea7f/wcwidth/wcwidth.py#L182-L204 """ # pylint: disable=C0103 # Invalid argument name "n" # TODO: Shall we consi...
[ "def", "_disp_width", "(", "self", ",", "pwcs", ",", "n", "=", "None", ")", ":", "# pylint: disable=C0103", "# Invalid argument name \"n\"", "# TODO: Shall we consider things like ANSI escape seqs here?", "# We can implement some ignore-me segment like those wrapped by", ...
A wcswidth that never gives -1. Copying existing code is evil, but.. github.com/jquast/wcwidth/blob/07cea7f/wcwidth/wcwidth.py#L182-L204
[ "A", "wcswidth", "that", "never", "gives", "-", "1", ".", "Copying", "existing", "code", "is", "evil", "but", "..", "github", ".", "com", "/", "jquast", "/", "wcwidth", "/", "blob", "/", "07cea7f", "/", "wcwidth", "/", "wcwidth", ".", "py#L182", "-", ...
python
train
40.5625
calmjs/calmjs.parse
src/calmjs/parse/handlers/obfuscation.py
https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/handlers/obfuscation.py#L505-L516
def finalize(self): """ Finalize the run - build the name generator and use it to build the remap symbol tables. """ self.global_scope.close() name_generator = NameGenerator(skip=self.reserved_keywords) self.global_scope.build_remap_symbols( name_gene...
[ "def", "finalize", "(", "self", ")", ":", "self", ".", "global_scope", ".", "close", "(", ")", "name_generator", "=", "NameGenerator", "(", "skip", "=", "self", ".", "reserved_keywords", ")", "self", ".", "global_scope", ".", "build_remap_symbols", "(", "nam...
Finalize the run - build the name generator and use it to build the remap symbol tables.
[ "Finalize", "the", "run", "-", "build", "the", "name", "generator", "and", "use", "it", "to", "build", "the", "remap", "symbol", "tables", "." ]
python
train
31.583333
xtrementl/focus
focus/plugin/modules/timer.py
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/timer.py#L55-L69
def parse_option(self, option, block_name, *values): """ Parse duration option for timer. """ try: if len(values) != 1: raise TypeError self.total_duration = int(values[0]) if self.total_duration <= 0: raise ValueError ...
[ "def", "parse_option", "(", "self", ",", "option", ",", "block_name", ",", "*", "values", ")", ":", "try", ":", "if", "len", "(", "values", ")", "!=", "1", ":", "raise", "TypeError", "self", ".", "total_duration", "=", "int", "(", "values", "[", "0",...
Parse duration option for timer.
[ "Parse", "duration", "option", "for", "timer", "." ]
python
train
29.133333
berkeley-cocosci/Wallace
wallace/networks.py
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/networks.py#L17-L27
def add_node(self, node): """Add an agent, connecting it to the previous node.""" other_nodes = [n for n in self.nodes() if n.id != node.id] if isinstance(node, Source) and other_nodes: raise(Exception("Chain network already has a nodes, " "can't add a so...
[ "def", "add_node", "(", "self", ",", "node", ")", ":", "other_nodes", "=", "[", "n", "for", "n", "in", "self", ".", "nodes", "(", ")", "if", "n", ".", "id", "!=", "node", ".", "id", "]", "if", "isinstance", "(", "node", ",", "Source", ")", "and...
Add an agent, connecting it to the previous node.
[ "Add", "an", "agent", "connecting", "it", "to", "the", "previous", "node", "." ]
python
train
41.090909
mozilla/build-mar
src/mardor/reader.py
https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L59-L76
def compression_type(self): """Return the latest compresion type used in this MAR. Returns: One of None, 'bz2', or 'xz' """ best_compression = None for e in self.mardata.index.entries: self.fileobj.seek(e.offset) magic = self.fileobj.read(10)...
[ "def", "compression_type", "(", "self", ")", ":", "best_compression", "=", "None", "for", "e", "in", "self", ".", "mardata", ".", "index", ".", "entries", ":", "self", ".", "fileobj", ".", "seek", "(", "e", ".", "offset", ")", "magic", "=", "self", "...
Return the latest compresion type used in this MAR. Returns: One of None, 'bz2', or 'xz'
[ "Return", "the", "latest", "compresion", "type", "used", "in", "this", "MAR", "." ]
python
train
32.944444
idlesign/django-sitetree
sitetree/sitetreeapp.py
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L1007-L1022
def update_has_children(self, tree_alias, tree_items, navigation_type): """Updates 'has_children' attribute for tree items inplace. :param str|unicode tree_alias: :param list tree_items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu """ get_children = s...
[ "def", "update_has_children", "(", "self", ",", "tree_alias", ",", "tree_items", ",", "navigation_type", ")", ":", "get_children", "=", "self", ".", "get_children", "filter_items", "=", "self", ".", "filter_items", "apply_hook", "=", "self", ".", "apply_hook", "...
Updates 'has_children' attribute for tree items inplace. :param str|unicode tree_alias: :param list tree_items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu
[ "Updates", "has_children", "attribute", "for", "tree", "items", "inplace", "." ]
python
test
43.4375
Godley/MuseParse
MuseParse/classes/Input/MxmlParser.py
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/Input/MxmlParser.py#L150-L167
def NewData(self, text): ''' Method which is called by the SAX parser upon encountering text inside a tag :param text: the text encountered :return: None, has side effects modifying the class itself ''' sint = ignore_exception(ValueError)(int) if len(self.tags) > ...
[ "def", "NewData", "(", "self", ",", "text", ")", ":", "sint", "=", "ignore_exception", "(", "ValueError", ")", "(", "int", ")", "if", "len", "(", "self", ".", "tags", ")", ">", "0", ":", "if", "self", ".", "tags", "[", "-", "1", "]", "==", "\"b...
Method which is called by the SAX parser upon encountering text inside a tag :param text: the text encountered :return: None, has side effects modifying the class itself
[ "Method", "which", "is", "called", "by", "the", "SAX", "parser", "upon", "encountering", "text", "inside", "a", "tag", ":", "param", "text", ":", "the", "text", "encountered", ":", "return", ":", "None", "has", "side", "effects", "modifying", "the", "class...
python
train
40.111111
pyvisa/pyvisa-py
pyvisa-py/usb.py
https://github.com/pyvisa/pyvisa-py/blob/dfbd509409675b59d71bb741cd72c5f256efd4cd/pyvisa-py/usb.py#L130-L145
def write(self, data): """Writes data to device or interface synchronously. Corresponds to viWrite function of the VISA library. :param data: data to be written. :type data: bytes :return: Number of bytes actually transferred, return value of the library call. :rtype: (...
[ "def", "write", "(", "self", ",", "data", ")", ":", "send_end", ",", "_", "=", "self", ".", "get_attribute", "(", "constants", ".", "VI_ATTR_SEND_END_EN", ")", "count", "=", "self", ".", "interface", ".", "write", "(", "data", ")", "return", "count", "...
Writes data to device or interface synchronously. Corresponds to viWrite function of the VISA library. :param data: data to be written. :type data: bytes :return: Number of bytes actually transferred, return value of the library call. :rtype: (int, VISAStatus)
[ "Writes", "data", "to", "device", "or", "interface", "synchronously", "." ]
python
train
30.75
TrafficSenseMSD/SumoTools
sumolib/miscutils.py
https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L153-L158
def relStdDev(self, limit=None): """return the relative standard deviation optionally limited to the last limit values""" moments = self.meanAndStdDev(limit) if moments is None: return None return moments[1] / moments[0]
[ "def", "relStdDev", "(", "self", ",", "limit", "=", "None", ")", ":", "moments", "=", "self", ".", "meanAndStdDev", "(", "limit", ")", "if", "moments", "is", "None", ":", "return", "None", "return", "moments", "[", "1", "]", "/", "moments", "[", "0",...
return the relative standard deviation optionally limited to the last limit values
[ "return", "the", "relative", "standard", "deviation", "optionally", "limited", "to", "the", "last", "limit", "values" ]
python
train
43.166667
xtuml/pyxtuml
bridgepoint/ooaofooa.py
https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/bridgepoint/ooaofooa.py#L124-L132
def get_attribute_type(o_attr): ''' Get the base data type (S_DT) associated with a BridgePoint attribute. ''' ref_o_attr = one(o_attr).O_RATTR[106].O_BATTR[113].O_ATTR[106]() if ref_o_attr: return get_attribute_type(ref_o_attr) else: return one(o_attr).S_DT[114]()
[ "def", "get_attribute_type", "(", "o_attr", ")", ":", "ref_o_attr", "=", "one", "(", "o_attr", ")", ".", "O_RATTR", "[", "106", "]", ".", "O_BATTR", "[", "113", "]", ".", "O_ATTR", "[", "106", "]", "(", ")", "if", "ref_o_attr", ":", "return", "get_at...
Get the base data type (S_DT) associated with a BridgePoint attribute.
[ "Get", "the", "base", "data", "type", "(", "S_DT", ")", "associated", "with", "a", "BridgePoint", "attribute", "." ]
python
test
33
ResidentMario/pysocrata
pysocrata/pysocrata.py
https://github.com/ResidentMario/pysocrata/blob/78d31ed24f9966284043eee45acebd62aa67e5b1/pysocrata/pysocrata.py#L51-L108
def get_endpoints_using_catalog_api(domain, token): """ Implements a raw HTTP GET against the entire Socrata portal for the domain in question. This method uses the second of the two ways of getting this information, the catalog API. Parameters ---------- domain: str A Socrata data port...
[ "def", "get_endpoints_using_catalog_api", "(", "domain", ",", "token", ")", ":", "# Token required for all requests. Providing login info instead is also possible but I didn't implement it.", "headers", "=", "{", "\"X-App-Token\"", ":", "token", "}", "# The API will return only 100 r...
Implements a raw HTTP GET against the entire Socrata portal for the domain in question. This method uses the second of the two ways of getting this information, the catalog API. Parameters ---------- domain: str A Socrata data portal domain. "data.seattle.gov" or "data.cityofnewyork.us" for exa...
[ "Implements", "a", "raw", "HTTP", "GET", "against", "the", "entire", "Socrata", "portal", "for", "the", "domain", "in", "question", ".", "This", "method", "uses", "the", "second", "of", "the", "two", "ways", "of", "getting", "this", "information", "the", "...
python
train
46.465517
zlobspb/txtarantool
txtarantool.py
https://github.com/zlobspb/txtarantool/blob/e8d451d53e1c99ccf1f23ce36a9c589fa2ed0350/txtarantool.py#L233-L253
def pack_field(self, value): """ Pack single field (string or integer value) <field> ::= <int32_varint><data> :param value: value to be packed :type value: bytes, str, int or long :return: packed value :rtype: bytes """ if isinstance(value, str):...
[ "def", "pack_field", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "return", "self", ".", "pack_str", "(", "value", ")", "elif", "isinstance", "(", "value", ",", "unicode", ")", ":", "return", "self", "....
Pack single field (string or integer value) <field> ::= <int32_varint><data> :param value: value to be packed :type value: bytes, str, int or long :return: packed value :rtype: bytes
[ "Pack", "single", "field", "(", "string", "or", "integer", "value", ")", "<field", ">", "::", "=", "<int32_varint", ">", "<data", ">" ]
python
train
35.285714
snowplow/snowplow-python-analytics-sdk
snowplow_analytics_sdk/run_manifests.py
https://github.com/snowplow/snowplow-python-analytics-sdk/blob/0ddca91e3f6d8bed88627fa557790aa4868bdace/snowplow_analytics_sdk/run_manifests.py#L38-L71
def create_manifest_table(dynamodb_client, table_name): """Create DynamoDB table for run manifests Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name """ try: dynamodb_client.create_table( AttributeDefinition...
[ "def", "create_manifest_table", "(", "dynamodb_client", ",", "table_name", ")", ":", "try", ":", "dynamodb_client", ".", "create_table", "(", "AttributeDefinitions", "=", "[", "{", "'AttributeName'", ":", "DYNAMODB_RUNID_ATTRIBUTE", ",", "'AttributeType'", ":", "'S'",...
Create DynamoDB table for run manifests Arguments: dynamodb_client - boto3 DynamoDB client (not service) table_name - string representing existing table name
[ "Create", "DynamoDB", "table", "for", "run", "manifests" ]
python
test
31
shoebot/shoebot
lib/graph/style.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L304-L381
def edges(s, edges, alpha=1.0, weighted=False, directed=False): """ Visualization of the edges in a network. """ p = s._ctx.BezierPath() if directed and s.stroke: pd = s._ctx.BezierPath() if weighted and s.fill: pw = [s._ctx.BezierPath() for i in range(11)...
[ "def", "edges", "(", "s", ",", "edges", ",", "alpha", "=", "1.0", ",", "weighted", "=", "False", ",", "directed", "=", "False", ")", ":", "p", "=", "s", ".", "_ctx", ".", "BezierPath", "(", ")", "if", "directed", "and", "s", ".", "stroke", ":", ...
Visualization of the edges in a network.
[ "Visualization", "of", "the", "edges", "in", "a", "network", "." ]
python
valid
25.820513
dourvaris/nano-python
src/nano/rpc.py
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L3124-L3169
def republish(self, hash, count=None, sources=None, destinations=None): """ Rebroadcast blocks starting at **hash** to the network :param hash: Hash of block to start rebroadcasting from :type hash: str :param count: Max number of blocks to rebroadcast :type count: int ...
[ "def", "republish", "(", "self", ",", "hash", ",", "count", "=", "None", ",", "sources", "=", "None", ",", "destinations", "=", "None", ")", ":", "hash", "=", "self", ".", "_process_value", "(", "hash", ",", "'block'", ")", "payload", "=", "{", "\"ha...
Rebroadcast blocks starting at **hash** to the network :param hash: Hash of block to start rebroadcasting from :type hash: str :param count: Max number of blocks to rebroadcast :type count: int :param sources: If set, additionally rebroadcasts source chain blocks ...
[ "Rebroadcast", "blocks", "starting", "at", "**", "hash", "**", "to", "the", "network" ]
python
train
32.652174
niklasf/python-chess
chess/pgn.py
https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/pgn.py#L432-L439
def board(self, *, _cache: bool = False) -> chess.Board: """ Gets the starting position of the game. Unless the ``FEN`` header tag is set, this is the default starting position (for the ``Variant``). """ return self.headers.board()
[ "def", "board", "(", "self", ",", "*", ",", "_cache", ":", "bool", "=", "False", ")", "->", "chess", ".", "Board", ":", "return", "self", ".", "headers", ".", "board", "(", ")" ]
Gets the starting position of the game. Unless the ``FEN`` header tag is set, this is the default starting position (for the ``Variant``).
[ "Gets", "the", "starting", "position", "of", "the", "game", "." ]
python
train
34.125
bxlab/bx-python
lib/bx_extras/stats.py
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/stats.py#L708-L721
def ltrimboth (l,proportiontocut): """ Slices off the passed proportion of items from BOTH ends of the passed list (i.e., with proportiontocut=0.1, slices 'leftmost' 10% AND 'rightmost' 10% of scores. Assumes list is sorted by magnitude. Slices off LESS if proportion results in a non-integer slice index (i.e., co...
[ "def", "ltrimboth", "(", "l", ",", "proportiontocut", ")", ":", "lowercut", "=", "int", "(", "proportiontocut", "*", "len", "(", "l", ")", ")", "uppercut", "=", "len", "(", "l", ")", "-", "lowercut", "return", "l", "[", "lowercut", ":", "uppercut", "...
Slices off the passed proportion of items from BOTH ends of the passed list (i.e., with proportiontocut=0.1, slices 'leftmost' 10% AND 'rightmost' 10% of scores. Assumes list is sorted by magnitude. Slices off LESS if proportion results in a non-integer slice index (i.e., conservatively slices off proportiontocut). ...
[ "Slices", "off", "the", "passed", "proportion", "of", "items", "from", "BOTH", "ends", "of", "the", "passed", "list", "(", "i", ".", "e", ".", "with", "proportiontocut", "=", "0", ".", "1", "slices", "leftmost", "10%", "AND", "rightmost", "10%", "of", ...
python
train
38.214286
aisthesis/pynance
pynance/opt/spread/vert.py
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/spread/vert.py#L52-L107
def call(self, lowstrike, highstrike, expiry): """ Metrics for evaluating a bull call spread. The metrics returned can easily be translated into bear spread metrics. The difference is only whether one buys the call at the lower strike and sells at the higher (bul...
[ "def", "call", "(", "self", ",", "lowstrike", ",", "highstrike", ",", "expiry", ")", ":", "assert", "lowstrike", "<", "highstrike", "_rows", "=", "{", "}", "_prices", "=", "{", "}", "_opttype", "=", "'call'", "for", "_strike", "in", "(", "lowstrike", "...
Metrics for evaluating a bull call spread. The metrics returned can easily be translated into bear spread metrics. The difference is only whether one buys the call at the lower strike and sells at the higher (bull call spread) or sells at the lower while buying at the hi...
[ "Metrics", "for", "evaluating", "a", "bull", "call", "spread", ".", "The", "metrics", "returned", "can", "easily", "be", "translated", "into", "bear", "spread", "metrics", ".", "The", "difference", "is", "only", "whether", "one", "buys", "the", "call", "at",...
python
train
39.053571
koordinates/python-client
koordinates/layers.py
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L208-L214
def get_draft_version(self, expand=[]): """ Get the current draft version of this layer. :raises NotFound: if there is no draft version. """ target_url = self._client.get_url('VERSION', 'GET', 'draft', {'layer_id': self.id}) return self._manager._get(target_url, expand=ex...
[ "def", "get_draft_version", "(", "self", ",", "expand", "=", "[", "]", ")", ":", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'draft'", ",", "{", "'layer_id'", ":", "self", ".", "id", "}", ")", "ret...
Get the current draft version of this layer. :raises NotFound: if there is no draft version.
[ "Get", "the", "current", "draft", "version", "of", "this", "layer", ".", ":", "raises", "NotFound", ":", "if", "there", "is", "no", "draft", "version", "." ]
python
train
45.571429
PyCQA/pylint
pylint/checkers/utils.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/utils.py#L430-L437
def check_messages(*messages: str) -> Callable: """decorator to store messages that are handled by a checker method""" def store_messages(func): func.checks_msgs = messages return func return store_messages
[ "def", "check_messages", "(", "*", "messages", ":", "str", ")", "->", "Callable", ":", "def", "store_messages", "(", "func", ")", ":", "func", ".", "checks_msgs", "=", "messages", "return", "func", "return", "store_messages" ]
decorator to store messages that are handled by a checker method
[ "decorator", "to", "store", "messages", "that", "are", "handled", "by", "a", "checker", "method" ]
python
test
28.625
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L939-L955
def _ReadPartitionKeyRanges(self, collection_link, feed_options=None): """Reads Partition Key Ranges. :param str collection_link: The link to the document collection. :param dict feed_options: :return: Query Iterable of PartitionKeyRanges. :rtype: ...
[ "def", "_ReadPartitionKeyRanges", "(", "self", ",", "collection_link", ",", "feed_options", "=", "None", ")", ":", "if", "feed_options", "is", "None", ":", "feed_options", "=", "{", "}", "return", "self", ".", "_QueryPartitionKeyRanges", "(", "collection_link", ...
Reads Partition Key Ranges. :param str collection_link: The link to the document collection. :param dict feed_options: :return: Query Iterable of PartitionKeyRanges. :rtype: query_iterable.QueryIterable
[ "Reads", "Partition", "Key", "Ranges", "." ]
python
train
29.235294
trailofbits/manticore
manticore/platforms/linux.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/linux.py#L1143-L1155
def _close(self, fd): """ Removes a file descriptor from the file descriptor list :rtype: int :param fd: the file descriptor to close. :return: C{0} on success. """ try: self.files[fd].close() self._closed_files.append(self.files[fd]) # Ke...
[ "def", "_close", "(", "self", ",", "fd", ")", ":", "try", ":", "self", ".", "files", "[", "fd", "]", ".", "close", "(", ")", "self", ".", "_closed_files", ".", "append", "(", "self", ".", "files", "[", "fd", "]", ")", "# Keep track for SymbolicFile t...
Removes a file descriptor from the file descriptor list :rtype: int :param fd: the file descriptor to close. :return: C{0} on success.
[ "Removes", "a", "file", "descriptor", "from", "the", "file", "descriptor", "list", ":", "rtype", ":", "int", ":", "param", "fd", ":", "the", "file", "descriptor", "to", "close", ".", ":", "return", ":", "C", "{", "0", "}", "on", "success", "." ]
python
valid
36.230769
viniciuschiele/flask-io
flask_io/io.py
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/io.py#L120-L131
def ok(self, data, schema=None, envelope=None): """ Gets a 200 response with the specified data. :param data: The content value. :param schema: The schema to serialize the data. :param envelope: The key used to envelope the data. :return: A Flask response object. ...
[ "def", "ok", "(", "self", ",", "data", ",", "schema", "=", "None", ",", "envelope", "=", "None", ")", ":", "data", "=", "marshal", "(", "data", ",", "schema", ",", "envelope", ")", "return", "self", ".", "__make_response", "(", "data", ")" ]
Gets a 200 response with the specified data. :param data: The content value. :param schema: The schema to serialize the data. :param envelope: The key used to envelope the data. :return: A Flask response object.
[ "Gets", "a", "200", "response", "with", "the", "specified", "data", "." ]
python
train
33.583333
spacetelescope/acstools
acstools/utils_calib.py
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/utils_calib.py#L203-L249
def extract_ref(scihdu, refhdu): """Extract section of the reference image that corresponds to the given science image. This only returns a view, not a copy of the reference image's array. Parameters ---------- scihdu, refhdu : obj Extension HDU's of the science and reference image...
[ "def", "extract_ref", "(", "scihdu", ",", "refhdu", ")", ":", "same_size", ",", "rx", ",", "ry", ",", "x0", ",", "y0", "=", "find_line", "(", "scihdu", ",", "refhdu", ")", "# Use the whole reference image", "if", "same_size", ":", "return", "refhdu", ".", ...
Extract section of the reference image that corresponds to the given science image. This only returns a view, not a copy of the reference image's array. Parameters ---------- scihdu, refhdu : obj Extension HDU's of the science and reference image, respectively. Returns ...
[ "Extract", "section", "of", "the", "reference", "image", "that", "corresponds", "to", "the", "given", "science", "image", "." ]
python
train
24.702128
wesyoung/pyzyre
czmq/_czmq_ctypes.py
https://github.com/wesyoung/pyzyre/blob/22d4c757acefcfdb700d3802adaf30b402bb9eea/czmq/_czmq_ctypes.py#L4924-L4929
def set_args(self, arguments): """ Setup the command line arguments, the first item must be an (absolute) filename to run. """ return lib.zproc_set_args(self._as_parameter_, byref(zlist_p.from_param(arguments)))
[ "def", "set_args", "(", "self", ",", "arguments", ")", ":", "return", "lib", ".", "zproc_set_args", "(", "self", ".", "_as_parameter_", ",", "byref", "(", "zlist_p", ".", "from_param", "(", "arguments", ")", ")", ")" ]
Setup the command line arguments, the first item must be an (absolute) filename to run.
[ "Setup", "the", "command", "line", "arguments", "the", "first", "item", "must", "be", "an", "(", "absolute", ")", "filename", "to", "run", "." ]
python
train
39.666667
openstack/horizon
horizon/base.py
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L793-L829
def get_user_home(self, user): """Returns the default URL for a particular user. This method can be used to customize where a user is sent when they log in, etc. By default it returns the value of :meth:`get_absolute_url`. An alternative function can be supplied to customize th...
[ "def", "get_user_home", "(", "self", ",", "user", ")", ":", "user_home", "=", "self", ".", "_conf", "[", "'user_home'", "]", "if", "user_home", ":", "if", "callable", "(", "user_home", ")", ":", "return", "user_home", "(", "user", ")", "elif", "isinstanc...
Returns the default URL for a particular user. This method can be used to customize where a user is sent when they log in, etc. By default it returns the value of :meth:`get_absolute_url`. An alternative function can be supplied to customize this behavior by specifying a either...
[ "Returns", "the", "default", "URL", "for", "a", "particular", "user", "." ]
python
train
46.297297
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L1334-L1381
def handle_offchain_secretreveal( mediator_state: MediatorTransferState, mediator_state_change: ReceiveSecretReveal, channelidentifiers_to_channels: ChannelMap, pseudo_random_generator: random.Random, block_number: BlockNumber, block_hash: BlockHash, ) -> TransitionResult...
[ "def", "handle_offchain_secretreveal", "(", "mediator_state", ":", "MediatorTransferState", ",", "mediator_state_change", ":", "ReceiveSecretReveal", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", ...
Handles the secret reveal and sends SendBalanceProof/RevealSecret if necessary.
[ "Handles", "the", "secret", "reveal", "and", "sends", "SendBalanceProof", "/", "RevealSecret", "if", "necessary", "." ]
python
train
40.208333
datasift/datasift-python
datasift/push.py
https://github.com/datasift/datasift-python/blob/bfaca1a47501a18e11065ecf630d9c31df818f65/datasift/push.py#L6-L20
def validate(self, output_type, output_params): """ Check that a subscription is defined correctly. Uses API documented at http://dev.datasift.com/docs/api/rest-api/endpoints/pushvalidate :param output_type: One of DataSift's supported output types, e.g. s3 :type output_t...
[ "def", "validate", "(", "self", ",", "output_type", ",", "output_params", ")", ":", "return", "self", ".", "request", ".", "post", "(", "'validate'", ",", "dict", "(", "output_type", "=", "output_type", ",", "output_params", "=", "output_params", ")", ")" ]
Check that a subscription is defined correctly. Uses API documented at http://dev.datasift.com/docs/api/rest-api/endpoints/pushvalidate :param output_type: One of DataSift's supported output types, e.g. s3 :type output_type: str :param output_params: The set of parame...
[ "Check", "that", "a", "subscription", "is", "defined", "correctly", "." ]
python
train
60.4
juju/python-libjuju
juju/client/_client3.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client3.py#L1415-L1430
async def AddCloud(self, cloud, name): ''' cloud : Cloud name : str Returns -> None ''' # map input types to rpc msg _params = dict() msg = dict(type='Cloud', request='AddCloud', version=3, params=_p...
[ "async", "def", "AddCloud", "(", "self", ",", "cloud", ",", "name", ")", ":", "# map input types to rpc msg", "_params", "=", "dict", "(", ")", "msg", "=", "dict", "(", "type", "=", "'Cloud'", ",", "request", "=", "'AddCloud'", ",", "version", "=", "3", ...
cloud : Cloud name : str Returns -> None
[ "cloud", ":", "Cloud", "name", ":", "str", "Returns", "-", ">", "None" ]
python
train
27
DataBiosphere/toil
src/toil/utils/toilStats.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/utils/toilStats.py#L358-L383
def sortJobs(jobTypes, options): """ Return a jobTypes all sorted. """ longforms = {"med": "median", "ave": "average", "min": "min", "total": "total", "max": "max",} sortField = longforms[options.sortField] if (options.sortCategory ...
[ "def", "sortJobs", "(", "jobTypes", ",", "options", ")", ":", "longforms", "=", "{", "\"med\"", ":", "\"median\"", ",", "\"ave\"", ":", "\"average\"", ",", "\"min\"", ":", "\"min\"", ",", "\"total\"", ":", "\"total\"", ",", "\"max\"", ":", "\"max\"", ",", ...
Return a jobTypes all sorted.
[ "Return", "a", "jobTypes", "all", "sorted", "." ]
python
train
37.153846
Hackerfleet/hfos
modules/enrol/hfos/enrol/enrolmanager.py
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L733-L738
def _send_invitation(self, enrollment, event): """Send an invitation mail to an open enrolment""" self.log('Sending enrollment status mail to user') self._send_mail(self.config.invitation_subject, self.config.invitation_mail, enrollment, event)
[ "def", "_send_invitation", "(", "self", ",", "enrollment", ",", "event", ")", ":", "self", ".", "log", "(", "'Sending enrollment status mail to user'", ")", "self", ".", "_send_mail", "(", "self", ".", "config", ".", "invitation_subject", ",", "self", ".", "co...
Send an invitation mail to an open enrolment
[ "Send", "an", "invitation", "mail", "to", "an", "open", "enrolment" ]
python
train
44.166667
mattjj/pylds
pylds/util.py
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/util.py#L141-L160
def sample_block_tridiag(H_diag, H_upper_diag): """ helper function for sampling block tridiag gaussians. this is only for speed comparison with the solve approach. """ T, D, _ = H_diag.shape assert H_diag.ndim == 3 and H_diag.shape[2] == D assert H_upper_diag.shape == (T - 1, D, D) J_i...
[ "def", "sample_block_tridiag", "(", "H_diag", ",", "H_upper_diag", ")", ":", "T", ",", "D", ",", "_", "=", "H_diag", ".", "shape", "assert", "H_diag", ".", "ndim", "==", "3", "and", "H_diag", ".", "shape", "[", "2", "]", "==", "D", "assert", "H_upper...
helper function for sampling block tridiag gaussians. this is only for speed comparison with the solve approach.
[ "helper", "function", "for", "sampling", "block", "tridiag", "gaussians", ".", "this", "is", "only", "for", "speed", "comparison", "with", "the", "solve", "approach", "." ]
python
train
31.95
willkg/socorro-siggen
siggen/utils.py
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/utils.py#L105-L138
def parse_source_file(source_file): """Parses a source file thing and returns the file name Example: >>> parse_file('hg:hg.mozilla.org/releases/mozilla-esr52:js/src/jit/MIR.h:755067c14b06') 'js/src/jit/MIR.h' :arg str source_file: the source file ("file") from a stack frame :returns: the fil...
[ "def", "parse_source_file", "(", "source_file", ")", ":", "if", "not", "source_file", ":", "return", "None", "vcsinfo", "=", "source_file", ".", "split", "(", "':'", ")", "if", "len", "(", "vcsinfo", ")", "==", "4", ":", "# These are repositories or cloud file...
Parses a source file thing and returns the file name Example: >>> parse_file('hg:hg.mozilla.org/releases/mozilla-esr52:js/src/jit/MIR.h:755067c14b06') 'js/src/jit/MIR.h' :arg str source_file: the source file ("file") from a stack frame :returns: the filename or ``None`` if it couldn't determine ...
[ "Parses", "a", "source", "file", "thing", "and", "returns", "the", "file", "name" ]
python
train
30
pybel/pybel-tools
src/pybel_tools/mutation/expansion.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L246-L264
def enrich_variants(graph: BELGraph, func: Union[None, str, Iterable[str]] = None): """Add the reference nodes for all variants of the given function. :param graph: The target BEL graph to enrich :param func: The function by which the subject of each triple is filtered. Defaults to the set of protein, rna,...
[ "def", "enrich_variants", "(", "graph", ":", "BELGraph", ",", "func", ":", "Union", "[", "None", ",", "str", ",", "Iterable", "[", "str", "]", "]", "=", "None", ")", ":", "if", "func", "is", "None", ":", "func", "=", "{", "PROTEIN", ",", "RNA", "...
Add the reference nodes for all variants of the given function. :param graph: The target BEL graph to enrich :param func: The function by which the subject of each triple is filtered. Defaults to the set of protein, rna, mirna, and gene.
[ "Add", "the", "reference", "nodes", "for", "all", "variants", "of", "the", "given", "function", "." ]
python
valid
33.105263
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#L75-L83
def get_api_key(self, api_key_id): """Get API key details for key registered in organisation. :param str api_key_id: The ID of the API key to be updated (Required) :returns: API key object :rtype: ApiKey """ api = self._get_api(iam.DeveloperApi) return ApiKey(api...
[ "def", "get_api_key", "(", "self", ",", "api_key_id", ")", ":", "api", "=", "self", ".", "_get_api", "(", "iam", ".", "DeveloperApi", ")", "return", "ApiKey", "(", "api", ".", "get_api_key", "(", "api_key_id", ")", ")" ]
Get API key details for key registered in organisation. :param str api_key_id: The ID of the API key to be updated (Required) :returns: API key object :rtype: ApiKey
[ "Get", "API", "key", "details", "for", "key", "registered", "in", "organisation", "." ]
python
train
37.444444
klmitch/bark
bark/handlers.py
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L119-L138
def address(addr): """ A special argument type that splits a string on ':' and transforms the result into a tuple of host and (integer) port. """ if ':' in addr: # Using rpartition here means we should be able to support # IPv6, but only with a strict syntax host, _sep, port...
[ "def", "address", "(", "addr", ")", ":", "if", "':'", "in", "addr", ":", "# Using rpartition here means we should be able to support", "# IPv6, but only with a strict syntax", "host", ",", "_sep", ",", "port", "=", "addr", ".", "rpartition", "(", "':'", ")", "# Conv...
A special argument type that splits a string on ':' and transforms the result into a tuple of host and (integer) port.
[ "A", "special", "argument", "type", "that", "splits", "a", "string", "on", ":", "and", "transforms", "the", "result", "into", "a", "tuple", "of", "host", "and", "(", "integer", ")", "port", "." ]
python
train
27.05
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L2187-L2199
def SetWindowPos(handle: int, hWndInsertAfter: int, x: int, y: int, width: int, height: int, flags: int) -> bool: """ SetWindowPos from Win32. handle: int, the handle of a native window. hWndInsertAfter: int, a value whose name starts with 'HWND' in class SWP. x: int. y: int. width: int. ...
[ "def", "SetWindowPos", "(", "handle", ":", "int", ",", "hWndInsertAfter", ":", "int", ",", "x", ":", "int", ",", "y", ":", "int", ",", "width", ":", "int", ",", "height", ":", "int", ",", "flags", ":", "int", ")", "->", "bool", ":", "return", "ct...
SetWindowPos from Win32. handle: int, the handle of a native window. hWndInsertAfter: int, a value whose name starts with 'HWND' in class SWP. x: int. y: int. width: int. height: int. flags: int, values whose name starts with 'SWP' in class `SWP`. Return bool, True if succeed otherwise F...
[ "SetWindowPos", "from", "Win32", ".", "handle", ":", "int", "the", "handle", "of", "a", "native", "window", ".", "hWndInsertAfter", ":", "int", "a", "value", "whose", "name", "starts", "with", "HWND", "in", "class", "SWP", ".", "x", ":", "int", ".", "y...
python
valid
44.538462
buzzfeed/caliendo
caliendo/facade.py
https://github.com/buzzfeed/caliendo/blob/1628a10f7782ad67c0422b5cbc9bf4979ac40abc/caliendo/facade.py#L23-L38
def should_exclude(type_or_instance, exclusion_list): """ Tests whether an object should be simply returned when being wrapped """ if type_or_instance in exclusion_list: # Check class definition return True if type(type_or_instance) in exclusion_list: # Check instance type return Tr...
[ "def", "should_exclude", "(", "type_or_instance", ",", "exclusion_list", ")", ":", "if", "type_or_instance", "in", "exclusion_list", ":", "# Check class definition", "return", "True", "if", "type", "(", "type_or_instance", ")", "in", "exclusion_list", ":", "# Check in...
Tests whether an object should be simply returned when being wrapped
[ "Tests", "whether", "an", "object", "should", "be", "simply", "returned", "when", "being", "wrapped" ]
python
train
28.9375
joke2k/faker
faker/providers/internet/__init__.py
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L363-L390
def ipv4_private(self, network=False, address_class=None): """ Returns a private IPv4. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :returns: Private IPv4 """ # compute private networks from given class supernet = ...
[ "def", "ipv4_private", "(", "self", ",", "network", "=", "False", ",", "address_class", "=", "None", ")", ":", "# compute private networks from given class", "supernet", "=", "_IPv4Constants", ".", "_network_classes", "[", "address_class", "or", "self", ".", "ipv4_n...
Returns a private IPv4. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :returns: Private IPv4
[ "Returns", "a", "private", "IPv4", "." ]
python
train
33
nwilming/ocupy
ocupy/spline_base.py
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/spline_base.py#L197-L257
def spline_base2d(width, height, nr_knots_x = 20.0, nr_knots_y = 20.0, spline_order = 5, marginal_x = None, marginal_y = None): """Computes a set of 2D spline basis functions. The basis functions cover the entire space in height*width and can for example be used to create fixation density ma...
[ "def", "spline_base2d", "(", "width", ",", "height", ",", "nr_knots_x", "=", "20.0", ",", "nr_knots_y", "=", "20.0", ",", "spline_order", "=", "5", ",", "marginal_x", "=", "None", ",", "marginal_y", "=", "None", ")", ":", "if", "not", "(", "nr_knots_x", ...
Computes a set of 2D spline basis functions. The basis functions cover the entire space in height*width and can for example be used to create fixation density maps. Input: width: int width of each basis height: int height of each basis nr_knots_x: i...
[ "Computes", "a", "set", "of", "2D", "spline", "basis", "functions", ".", "The", "basis", "functions", "cover", "the", "entire", "space", "in", "height", "*", "width", "and", "can", "for", "example", "be", "used", "to", "create", "fixation", "density", "map...
python
train
44.47541
alejandroautalan/pygubu
pygubudesigner/propertieseditor.py
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/propertieseditor.py#L46-L83
def _create_properties(self): """Populate a frame with a list of all editable properties""" self._frame = f = ttk.Labelframe(self._sframe.innerframe, text=_('Widget properties')) f.grid(sticky='nswe') label_tpl = "{0}:" row = 0 co...
[ "def", "_create_properties", "(", "self", ")", ":", "self", ".", "_frame", "=", "f", "=", "ttk", ".", "Labelframe", "(", "self", ".", "_sframe", ".", "innerframe", ",", "text", "=", "_", "(", "'Widget properties'", ")", ")", "f", ".", "grid", "(", "s...
Populate a frame with a list of all editable properties
[ "Populate", "a", "frame", "with", "a", "list", "of", "all", "editable", "properties" ]
python
train
45.526316
bitesofcode/projexui
projexui/xscheme.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xscheme.py#L64-L70
def reset( self ): """ Resets the values to the current application information. """ self.setValue('colorSet', XPaletteColorSet()) self.setValue('font', QApplication.font()) self.setValue('fontSize', QApplication.font().pointSize())
[ "def", "reset", "(", "self", ")", ":", "self", ".", "setValue", "(", "'colorSet'", ",", "XPaletteColorSet", "(", ")", ")", "self", ".", "setValue", "(", "'font'", ",", "QApplication", ".", "font", "(", ")", ")", "self", ".", "setValue", "(", "'fontSize...
Resets the values to the current application information.
[ "Resets", "the", "values", "to", "the", "current", "application", "information", "." ]
python
train
39.714286
mitsei/dlkit
dlkit/services/logging_.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/logging_.py#L944-L955
def _set_log_view(self, session): """Sets the underlying log view to match current view""" if self._log_view == FEDERATED: try: session.use_federated_log_view() except AttributeError: pass else: try: session.use_...
[ "def", "_set_log_view", "(", "self", ",", "session", ")", ":", "if", "self", ".", "_log_view", "==", "FEDERATED", ":", "try", ":", "session", ".", "use_federated_log_view", "(", ")", "except", "AttributeError", ":", "pass", "else", ":", "try", ":", "sessio...
Sets the underlying log view to match current view
[ "Sets", "the", "underlying", "log", "view", "to", "match", "current", "view" ]
python
train
32
rocky/python-xdis
xdis/opcodes/base.py
https://github.com/rocky/python-xdis/blob/46a2902ae8f5d8eee495eed67ac0690fd545453d/xdis/opcodes/base.py#L189-L196
def fix_opcode_names(opmap): """ Python stupidly named some OPCODES with a + which prevents using opcode name directly as an attribute, e.g. SLICE+3. So we turn that into SLICE_3 so we can then use opcode_23.SLICE_3. Later Python's fix this. """ return dict([(k.replace('+', '_'), v) ...
[ "def", "fix_opcode_names", "(", "opmap", ")", ":", "return", "dict", "(", "[", "(", "k", ".", "replace", "(", "'+'", ",", "'_'", ")", ",", "v", ")", "for", "(", "k", ",", "v", ")", "in", "opmap", ".", "items", "(", ")", "]", ")" ]
Python stupidly named some OPCODES with a + which prevents using opcode name directly as an attribute, e.g. SLICE+3. So we turn that into SLICE_3 so we can then use opcode_23.SLICE_3. Later Python's fix this.
[ "Python", "stupidly", "named", "some", "OPCODES", "with", "a", "+", "which", "prevents", "using", "opcode", "name", "directly", "as", "an", "attribute", "e", ".", "g", ".", "SLICE", "+", "3", ".", "So", "we", "turn", "that", "into", "SLICE_3", "so", "w...
python
train
43.625
nickjj/ansigenome
ansigenome/scan.py
https://github.com/nickjj/ansigenome/blob/70cd98d7a23d36c56f4e713ea820cfb4c485c81c/ansigenome/scan.py#L227-L234
def gather_readme(self): """ Return the readme file. """ if not os.path.exists(self.paths["readme"]): return "" return utils.file_to_string(self.paths["readme"])
[ "def", "gather_readme", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "paths", "[", "\"readme\"", "]", ")", ":", "return", "\"\"", "return", "utils", ".", "file_to_string", "(", "self", ".", "paths", "[", "\"...
Return the readme file.
[ "Return", "the", "readme", "file", "." ]
python
train
25.875
pearu/pyvtk
pyvtk/common.py
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L34-L36
def is_number(obj): """Check if obj is number.""" return isinstance(obj, (int, float, np.int_, np.float_))
[ "def", "is_number", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "(", "int", ",", "float", ",", "np", ".", "int_", ",", "np", ".", "float_", ")", ")" ]
Check if obj is number.
[ "Check", "if", "obj", "is", "number", "." ]
python
train
37.333333
gem/oq-engine
openquake/hazardlib/gsim/nga_east.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/nga_east.py#L192-L207
def get_tau_at_quantile(mean, stddev, quantile): """ Returns the value of tau at a given quantile in the form of a dictionary organised by intensity measure """ tau_model = {} for imt in mean: tau_model[imt] = {} for key in mean[imt]: if quantile is None: ...
[ "def", "get_tau_at_quantile", "(", "mean", ",", "stddev", ",", "quantile", ")", ":", "tau_model", "=", "{", "}", "for", "imt", "in", "mean", ":", "tau_model", "[", "imt", "]", "=", "{", "}", "for", "key", "in", "mean", "[", "imt", "]", ":", "if", ...
Returns the value of tau at a given quantile in the form of a dictionary organised by intensity measure
[ "Returns", "the", "value", "of", "tau", "at", "a", "given", "quantile", "in", "the", "form", "of", "a", "dictionary", "organised", "by", "intensity", "measure" ]
python
train
36.6875
FelixSchwarz/pymta
pymta/session.py
https://github.com/FelixSchwarz/pymta/blob/1884accc3311e6c2e89259784f9592314f6d34fc/pymta/session.py#L292-L296
def close_connection(self): "Request a connection close from the SMTP session handling instance." if self._is_connected: self._is_connected = False self._command_parser.close_when_done()
[ "def", "close_connection", "(", "self", ")", ":", "if", "self", ".", "_is_connected", ":", "self", ".", "_is_connected", "=", "False", "self", ".", "_command_parser", ".", "close_when_done", "(", ")" ]
Request a connection close from the SMTP session handling instance.
[ "Request", "a", "connection", "close", "from", "the", "SMTP", "session", "handling", "instance", "." ]
python
train
44.4
nimbusproject/dashi
dashi/__init__.py
https://github.com/nimbusproject/dashi/blob/368b3963ec8abd60aebe0f81915429b45cbf4b5a/dashi/__init__.py#L297-L305
def cancel(self, block=True): """Cancel a call to consume() happening in another thread This could take up to DashiConnection.consumer_timeout to complete. @param block: if True, waits until the consumer has returned """ if self._consumer: self._consumer.cancel(bloc...
[ "def", "cancel", "(", "self", ",", "block", "=", "True", ")", ":", "if", "self", ".", "_consumer", ":", "self", ".", "_consumer", ".", "cancel", "(", "block", "=", "block", ")" ]
Cancel a call to consume() happening in another thread This could take up to DashiConnection.consumer_timeout to complete. @param block: if True, waits until the consumer has returned
[ "Cancel", "a", "call", "to", "consume", "()", "happening", "in", "another", "thread" ]
python
train
35.555556
blockstack/pybitcoin
pybitcoin/transactions/scripts.py
https://github.com/blockstack/pybitcoin/blob/92c8da63c40f7418594b1ce395990c3f5a4787cc/pybitcoin/transactions/scripts.py#L17-L35
def script_to_hex(script): """ Parse the string representation of a script and return the hex version. Example: "OP_DUP OP_HASH160 c629...a6db OP_EQUALVERIFY OP_CHECKSIG" """ hex_script = '' parts = script.split(' ') for part in parts: if part[0:3] == 'OP_': try: ...
[ "def", "script_to_hex", "(", "script", ")", ":", "hex_script", "=", "''", "parts", "=", "script", ".", "split", "(", "' '", ")", "for", "part", "in", "parts", ":", "if", "part", "[", "0", ":", "3", "]", "==", "'OP_'", ":", "try", ":", "hex_script",...
Parse the string representation of a script and return the hex version. Example: "OP_DUP OP_HASH160 c629...a6db OP_EQUALVERIFY OP_CHECKSIG"
[ "Parse", "the", "string", "representation", "of", "a", "script", "and", "return", "the", "hex", "version", ".", "Example", ":", "OP_DUP", "OP_HASH160", "c629", "...", "a6db", "OP_EQUALVERIFY", "OP_CHECKSIG" ]
python
train
37.736842
tanghaibao/jcvi
jcvi/assembly/hic.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/hic.py#L307-L319
def flip_whole(self, tour): """ Test flipping all contigs at the same time to see if score improves. """ score, = self.evaluate_tour_Q(tour) self.signs = -self.signs score_flipped, = self.evaluate_tour_Q(tour) if score_flipped > score: tag = ACCEPT els...
[ "def", "flip_whole", "(", "self", ",", "tour", ")", ":", "score", ",", "=", "self", ".", "evaluate_tour_Q", "(", "tour", ")", "self", ".", "signs", "=", "-", "self", ".", "signs", "score_flipped", ",", "=", "self", ".", "evaluate_tour_Q", "(", "tour", ...
Test flipping all contigs at the same time to see if score improves.
[ "Test", "flipping", "all", "contigs", "at", "the", "same", "time", "to", "see", "if", "score", "improves", "." ]
python
train
34.846154
lucasmaystre/choix
choix/lsr.py
https://github.com/lucasmaystre/choix/blob/05a57a10bb707338113a9d91601ca528ead7a881/choix/lsr.py#L10-L17
def _init_lsr(n_items, alpha, initial_params): """Initialize the LSR Markov chain and the weights.""" if initial_params is None: weights = np.ones(n_items) else: weights = exp_transform(initial_params) chain = alpha * np.ones((n_items, n_items), dtype=float) return weights, chain
[ "def", "_init_lsr", "(", "n_items", ",", "alpha", ",", "initial_params", ")", ":", "if", "initial_params", "is", "None", ":", "weights", "=", "np", ".", "ones", "(", "n_items", ")", "else", ":", "weights", "=", "exp_transform", "(", "initial_params", ")", ...
Initialize the LSR Markov chain and the weights.
[ "Initialize", "the", "LSR", "Markov", "chain", "and", "the", "weights", "." ]
python
train
38.625
doloopwhile/pyjq
pyjq.py
https://github.com/doloopwhile/pyjq/blob/003144e636af20e20862d4a191f05ec9ed9017b7/pyjq.py#L52-L56
def apply(script, value=None, vars={}, url=None, opener=default_opener, library_paths=[]): """ Transform value by script, returning all results as list. """ return all(script, value, vars, url, opener, library_paths)
[ "def", "apply", "(", "script", ",", "value", "=", "None", ",", "vars", "=", "{", "}", ",", "url", "=", "None", ",", "opener", "=", "default_opener", ",", "library_paths", "=", "[", "]", ")", ":", "return", "all", "(", "script", ",", "value", ",", ...
Transform value by script, returning all results as list.
[ "Transform", "value", "by", "script", "returning", "all", "results", "as", "list", "." ]
python
train
45.6
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAData/base_datastruct.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAData/base_datastruct.py#L536-L542
def amplitude(self): '返回DataStruct.price的百分比变化' res = self.price.groupby( level=1 ).apply(lambda x: (x.max() - x.min()) / x.min()) res.name = 'amplitude' return res
[ "def", "amplitude", "(", "self", ")", ":", "res", "=", "self", ".", "price", ".", "groupby", "(", "level", "=", "1", ")", ".", "apply", "(", "lambda", "x", ":", "(", "x", ".", "max", "(", ")", "-", "x", ".", "min", "(", ")", ")", "/", "x", ...
返回DataStruct.price的百分比变化
[ "返回DataStruct", ".", "price的百分比变化" ]
python
train
30
pyslackers/slack-sansio
slack/sansio.py
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L252-L289
def prepare_iter_request( url: Union[methods, str], data: MutableMapping, *, iterkey: Optional[str] = None, itermode: Optional[str] = None, limit: int = 200, itervalue: Optional[Union[str, int]] = None, ) -> Tuple[MutableMapping, str, str]: """ Prepare outgoing iteration request ...
[ "def", "prepare_iter_request", "(", "url", ":", "Union", "[", "methods", ",", "str", "]", ",", "data", ":", "MutableMapping", ",", "*", ",", "iterkey", ":", "Optional", "[", "str", "]", "=", "None", ",", "itermode", ":", "Optional", "[", "str", "]", ...
Prepare outgoing iteration request Args: url: :class:`slack.methods` item or string of url data: Outgoing data limit: Maximum number of results to return per call. iterkey: Key in response data to iterate over (required for url string). itermode: Iteration mode (required for...
[ "Prepare", "outgoing", "iteration", "request" ]
python
train
33.078947
dmlc/gluon-nlp
src/gluonnlp/model/bert.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/model/bert.py#L630-L709
def get_bert_model(model_name=None, dataset_name=None, vocab=None, pretrained=True, ctx=mx.cpu(), use_pooler=True, use_decoder=True, use_classifier=True, output_attention=False, output_all_encodings=False, root=os.path.join(get_home_dir(), 'mod...
[ "def", "get_bert_model", "(", "model_name", "=", "None", ",", "dataset_name", "=", "None", ",", "vocab", "=", "None", ",", "pretrained", "=", "True", ",", "ctx", "=", "mx", ".", "cpu", "(", ")", ",", "use_pooler", "=", "True", ",", "use_decoder", "=", ...
Any BERT pretrained model. Parameters ---------- model_name : str or None, default None Options include 'bert_24_1024_16' and 'bert_12_768_12'. dataset_name : str or None, default None Options include 'book_corpus_wiki_en_cased', 'book_corpus_wiki_en_uncased' for both bert_24_10...
[ "Any", "BERT", "pretrained", "model", "." ]
python
train
52
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L284-L289
def flush(self): """Flush(apply) all changed to datastore.""" self.puts.flush() self.deletes.flush() self.ndb_puts.flush() self.ndb_deletes.flush()
[ "def", "flush", "(", "self", ")", ":", "self", ".", "puts", ".", "flush", "(", ")", "self", ".", "deletes", ".", "flush", "(", ")", "self", ".", "ndb_puts", ".", "flush", "(", ")", "self", ".", "ndb_deletes", ".", "flush", "(", ")" ]
Flush(apply) all changed to datastore.
[ "Flush", "(", "apply", ")", "all", "changed", "to", "datastore", "." ]
python
train
27
CyberReboot/vent
vent/menus/editor.py
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/menus/editor.py#L123-L228
def valid_input(val): """ Ensure the input the user gave is of a valid format """ # looks for 3 nums followed by a dot 3 times and then ending with # 3 nums, can be proceeded by any number of spaces ip_value = re.compile(r'(\d{1,3}\.){3}\d{1,3}$') # looks for only numbers and com...
[ "def", "valid_input", "(", "val", ")", ":", "# looks for 3 nums followed by a dot 3 times and then ending with", "# 3 nums, can be proceeded by any number of spaces", "ip_value", "=", "re", ".", "compile", "(", "r'(\\d{1,3}\\.){3}\\d{1,3}$'", ")", "# looks for only numbers and commas...
Ensure the input the user gave is of a valid format
[ "Ensure", "the", "input", "the", "user", "gave", "is", "of", "a", "valid", "format" ]
python
train
53.198113
belbio/bel
bel/nanopub/pubmed.py
https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/nanopub/pubmed.py#L138-L150
def process_pub_date(year, mon, day): """Create pub_date from what Pubmed provides in Journal PubDate entry """ pub_date = None if year and re.match("[a-zA-Z]+", mon): pub_date = datetime.datetime.strptime( f"{year}-{mon}-{day}", "%Y-%b-%d" ).strftime("%Y-%m-%d") elif ye...
[ "def", "process_pub_date", "(", "year", ",", "mon", ",", "day", ")", ":", "pub_date", "=", "None", "if", "year", "and", "re", ".", "match", "(", "\"[a-zA-Z]+\"", ",", "mon", ")", ":", "pub_date", "=", "datetime", ".", "datetime", ".", "strptime", "(", ...
Create pub_date from what Pubmed provides in Journal PubDate entry
[ "Create", "pub_date", "from", "what", "Pubmed", "provides", "in", "Journal", "PubDate", "entry" ]
python
train
28.692308
saltstack/salt
salt/cloud/clouds/msazure.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/msazure.py#L2399-L2433
def update_affinity_group(kwargs=None, conn=None, call=None): ''' .. versionadded:: 2015.8.0 Update an affinity group's properties CLI Example: .. code-block:: bash salt-cloud -f update_affinity_group my-azure name=my_group label=my_group ''' if call != 'function': raise ...
[ "def", "update_affinity_group", "(", "kwargs", "=", "None", ",", "conn", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The update_affinity_group function must be called with -f or --funct...
.. versionadded:: 2015.8.0 Update an affinity group's properties CLI Example: .. code-block:: bash salt-cloud -f update_affinity_group my-azure name=my_group label=my_group
[ "..", "versionadded", "::", "2015", ".", "8", ".", "0" ]
python
train
27.028571
ascribe/pyspool
spool/wallet.py
https://github.com/ascribe/pyspool/blob/f8b10df1e7d2ea7950dde433c1cb6d5225112f4f/spool/wallet.py#L55-L68
def _unique_hierarchical_string(self): """ Returns: str: a representation of time such as:: '2014/2/23/15/26/8/9877978' The last part (microsecond) is needed to avoid duplicates in rapid-fire transactions e.g. ``> 1`` edition. """ t = dateti...
[ "def", "_unique_hierarchical_string", "(", "self", ")", ":", "t", "=", "datetime", ".", "now", "(", ")", "return", "'%s/%s/%s/%s/%s/%s/%s'", "%", "(", "t", ".", "year", ",", "t", ".", "month", ",", "t", ".", "day", ",", "t", ".", "hour", ",", "t", ...
Returns: str: a representation of time such as:: '2014/2/23/15/26/8/9877978' The last part (microsecond) is needed to avoid duplicates in rapid-fire transactions e.g. ``> 1`` edition.
[ "Returns", ":", "str", ":", "a", "representation", "of", "time", "such", "as", "::" ]
python
train
33.142857
DataDog/integrations-core
datadog_checks_base/datadog_checks/base/stubs/aggregator.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/stubs/aggregator.py#L88-L105
def events(self): """ Return all events """ all_events = [{ensure_unicode(key): value for key, value in iteritems(ev)} for ev in self._events] for ev in all_events: to_decode = [] for key, value in iteritems(ev): if isinstance(value, binar...
[ "def", "events", "(", "self", ")", ":", "all_events", "=", "[", "{", "ensure_unicode", "(", "key", ")", ":", "value", "for", "key", ",", "value", "in", "iteritems", "(", "ev", ")", "}", "for", "ev", "in", "self", ".", "_events", "]", "for", "ev", ...
Return all events
[ "Return", "all", "events" ]
python
train
31.666667
Capitains/Nautilus
capitains_nautilus/apis/cts.py
https://github.com/Capitains/Nautilus/blob/6be453fe0cc0e2c1b89ff06e5af1409165fc1411/capitains_nautilus/apis/cts.py#L177-L197
def _get_prev_next(self, urn): """ Provisional route for GetPrevNext request :param urn: URN to filter the resource :param inv: Inventory Identifier :return: GetPrevNext response """ urn = URN(urn) subreference = None textId = urn.upTo(URN.NO_PASSAGE) ...
[ "def", "_get_prev_next", "(", "self", ",", "urn", ")", ":", "urn", "=", "URN", "(", "urn", ")", "subreference", "=", "None", "textId", "=", "urn", ".", "upTo", "(", "URN", ".", "NO_PASSAGE", ")", "if", "urn", ".", "reference", "is", "not", "None", ...
Provisional route for GetPrevNext request :param urn: URN to filter the resource :param inv: Inventory Identifier :return: GetPrevNext response
[ "Provisional", "route", "for", "GetPrevNext", "request" ]
python
train
34.714286
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/paulaxml/paula.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/paulaxml/paula.py#L137-L158
def __gen_primary_text_file(self): """ generate the PAULA file that contains the primary text of the document graph. (PAULA documents can have more than one primary text, but discoursegraphs only works with documents that are based on exactly one primary text.) Example ...
[ "def", "__gen_primary_text_file", "(", "self", ")", ":", "paula_id", "=", "'{0}.{1}.text'", ".", "format", "(", "self", ".", "corpus_name", ",", "self", ".", "name", ")", "E", ",", "tree", "=", "gen_paula_etree", "(", "paula_id", ")", "tree", ".", "append"...
generate the PAULA file that contains the primary text of the document graph. (PAULA documents can have more than one primary text, but discoursegraphs only works with documents that are based on exactly one primary text.) Example ------- <?xml version="1.0" standalone="...
[ "generate", "the", "PAULA", "file", "that", "contains", "the", "primary", "text", "of", "the", "document", "graph", ".", "(", "PAULA", "documents", "can", "have", "more", "than", "one", "primary", "text", "but", "discoursegraphs", "only", "works", "with", "d...
python
train
38.181818
maas/python-libmaas
maas/client/utils/__init__.py
https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/utils/__init__.py#L145-L163
def sign_request(self, url, method, body, headers): """Sign a request. :param url: The URL to which the request is to be sent. :param headers: The headers in the request. These will be updated with the signature. """ # The use of PLAINTEXT here was copied from MAAS, ...
[ "def", "sign_request", "(", "self", ",", "url", ",", "method", ",", "body", ",", "headers", ")", ":", "# The use of PLAINTEXT here was copied from MAAS, but we should switch", "# to HMAC once it works server-side.", "client", "=", "oauth1", ".", "Client", "(", "self", "...
Sign a request. :param url: The URL to which the request is to be sent. :param headers: The headers in the request. These will be updated with the signature.
[ "Sign", "a", "request", "." ]
python
train
50.578947
dnephin/PyStaticConfiguration
staticconf/getters.py
https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/getters.py#L84-L95
def build(self, validator, namespace, config_key, default, help): """Build or retrieve a ValueProxy from the attributes. Proxies are keyed using a repr because default values can be mutable types. """ proxy_attrs = validator, namespace, config_key, default proxy_key = repr(proxy_...
[ "def", "build", "(", "self", ",", "validator", ",", "namespace", ",", "config_key", ",", "default", ",", "help", ")", ":", "proxy_attrs", "=", "validator", ",", "namespace", ",", "config_key", ",", "default", "proxy_key", "=", "repr", "(", "proxy_attrs", "...
Build or retrieve a ValueProxy from the attributes. Proxies are keyed using a repr because default values can be mutable types.
[ "Build", "or", "retrieve", "a", "ValueProxy", "from", "the", "attributes", ".", "Proxies", "are", "keyed", "using", "a", "repr", "because", "default", "values", "can", "be", "mutable", "types", "." ]
python
train
47.666667
foxx/peewee-extras
old/old.py
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/old/old.py#L135-L139
def db_value(self, value): """Convert the python value for storage in the database.""" value = self.transform_value(value) return self.hhash.encrypt(value, salt_size=self.salt_size, rounds=self.rounds)
[ "def", "db_value", "(", "self", ",", "value", ")", ":", "value", "=", "self", ".", "transform_value", "(", "value", ")", "return", "self", ".", "hhash", ".", "encrypt", "(", "value", ",", "salt_size", "=", "self", ".", "salt_size", ",", "rounds", "=", ...
Convert the python value for storage in the database.
[ "Convert", "the", "python", "value", "for", "storage", "in", "the", "database", "." ]
python
valid
46.8
Azure/blobxfer
blobxfer/operations/upload.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/upload.py#L399-L449
def _put_data(self, ud, ase, offsets, data): # type: (Uploader, blobxfer.models.upload.Descriptor, # blobxfer.models.azure.StorageEntity, # blobxfer.models.upload.Offsets, bytes) -> None """Put data in Azure :param Uploader self: this :param blobxfer.models....
[ "def", "_put_data", "(", "self", ",", "ud", ",", "ase", ",", "offsets", ",", "data", ")", ":", "# type: (Uploader, blobxfer.models.upload.Descriptor,", "# blobxfer.models.azure.StorageEntity,", "# blobxfer.models.upload.Offsets, bytes) -> None", "if", "ase", ".", ...
Put data in Azure :param Uploader self: this :param blobxfer.models.upload.Descriptor ud: upload descriptor :param blobxfer.models.azure.StorageEntity ase: Storage entity :param blobxfer.models.upload.Offsets offsets: offsets :param bytes data: data to upload
[ "Put", "data", "in", "Azure", ":", "param", "Uploader", "self", ":", "this", ":", "param", "blobxfer", ".", "models", ".", "upload", ".", "Descriptor", "ud", ":", "upload", "descriptor", ":", "param", "blobxfer", ".", "models", ".", "azure", ".", "Storag...
python
train
45.254902
OSSOS/MOP
src/ossos/core/ossos/gui/config.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/gui/config.py#L10-L31
def read(keypath, configfile=None): """ Reads a value from the configuration file. Args: keypath: str Specifies the key for which the value is desired. It can be a hierarchical path. Example: "section1.subsection.key1" configfile: str Path to the config file to read. ...
[ "def", "read", "(", "keypath", ",", "configfile", "=", "None", ")", ":", "if", "configfile", "in", "_configs", ":", "appconfig", "=", "_configs", "[", "configfile", "]", "else", ":", "appconfig", "=", "AppConfig", "(", "configfile", "=", "configfile", ")",...
Reads a value from the configuration file. Args: keypath: str Specifies the key for which the value is desired. It can be a hierarchical path. Example: "section1.subsection.key1" configfile: str Path to the config file to read. Defaults to None, in which case the appl...
[ "Reads", "a", "value", "from", "the", "configuration", "file", "." ]
python
train
29.772727