repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
uw-it-aca/uw-restclients-sws
uw_sws/term.py
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/term.py#L74-L88
def get_term_after(aterm): """ Returns a uw_sws.models.Term object, for the term after the term given. """ next_year = aterm.year if aterm.quarter == "autumn": next_quarter = QUARTER_SEQ[0] else: next_quarter = QUARTER_SEQ[QUARTER_SEQ.index(aterm.quarter) + 1] if next_qu...
[ "def", "get_term_after", "(", "aterm", ")", ":", "next_year", "=", "aterm", ".", "year", "if", "aterm", ".", "quarter", "==", "\"autumn\"", ":", "next_quarter", "=", "QUARTER_SEQ", "[", "0", "]", "else", ":", "next_quarter", "=", "QUARTER_SEQ", "[", "QUART...
Returns a uw_sws.models.Term object, for the term after the term given.
[ "Returns", "a", "uw_sws", ".", "models", ".", "Term", "object", "for", "the", "term", "after", "the", "term", "given", "." ]
python
train
psd-tools/psd-tools
src/psd_tools/api/layers.py
https://github.com/psd-tools/psd-tools/blob/4952b57bcf1cf2c1f16fd9d6d51d4fa0b53bce4e/src/psd_tools/api/layers.py#L635-L643
def smart_object(self): """ Associated smart object. :return: :py:class:`~psd_tools.api.smart_object.SmartObject`. """ if not hasattr(self, '_smart_object'): self._smart_object = SmartObject(self) return self._smart_object
[ "def", "smart_object", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_smart_object'", ")", ":", "self", ".", "_smart_object", "=", "SmartObject", "(", "self", ")", "return", "self", ".", "_smart_object" ]
Associated smart object. :return: :py:class:`~psd_tools.api.smart_object.SmartObject`.
[ "Associated", "smart", "object", "." ]
python
train
openstack/horizon
openstack_dashboard/api/neutron.py
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L740-L769
def list_targets_by_instance(self, instance_id, target_list=None): """Returns a list of FloatingIpTarget objects of FIP association. :param instance_id: ID of target VM instance :param target_list: (optional) a list returned by list_targets(). If specified, looking up is done agains...
[ "def", "list_targets_by_instance", "(", "self", ",", "instance_id", ",", "target_list", "=", "None", ")", ":", "if", "target_list", "is", "not", "None", ":", "# We assume that target_list was returned by list_targets()", "# so we can assume checks for subnet reachability and IP...
Returns a list of FloatingIpTarget objects of FIP association. :param instance_id: ID of target VM instance :param target_list: (optional) a list returned by list_targets(). If specified, looking up is done against the specified list to save extra API calls to a back-end. Otherw...
[ "Returns", "a", "list", "of", "FloatingIpTarget", "objects", "of", "FIP", "association", "." ]
python
train
PmagPy/PmagPy
pmagpy/builder2.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/builder2.py#L924-L954
def write_files(self): """ write all data out into er_* and pmag_* files as appropriate """ warnings = self.validate_data() print('-I- Writing all saved data to files') if self.measurements: self.write_measurements_file() for dtype in ['specimen', 'sa...
[ "def", "write_files", "(", "self", ")", ":", "warnings", "=", "self", ".", "validate_data", "(", ")", "print", "(", "'-I- Writing all saved data to files'", ")", "if", "self", ".", "measurements", ":", "self", ".", "write_measurements_file", "(", ")", "for", "...
write all data out into er_* and pmag_* files as appropriate
[ "write", "all", "data", "out", "into", "er_", "*", "and", "pmag_", "*", "files", "as", "appropriate" ]
python
train
pypa/pipenv
pipenv/vendor/requests/cookies.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/cookies.py#L348-L354
def update(self, other): """Updates this jar with cookies from another CookieJar or dict-like""" if isinstance(other, cookielib.CookieJar): for cookie in other: self.set_cookie(copy.copy(cookie)) else: super(RequestsCookieJar, self).update(other)
[ "def", "update", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "cookielib", ".", "CookieJar", ")", ":", "for", "cookie", "in", "other", ":", "self", ".", "set_cookie", "(", "copy", ".", "copy", "(", "cookie", ")", ")", ...
Updates this jar with cookies from another CookieJar or dict-like
[ "Updates", "this", "jar", "with", "cookies", "from", "another", "CookieJar", "or", "dict", "-", "like" ]
python
train
elastic/elasticsearch-py
elasticsearch/client/xpack/ml.py
https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/xpack/ml.py#L350-L369
def get_categories(self, job_id, category_id=None, body=None, params=None): """ `<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html>`_ :arg job_id: The name of the job :arg category_id: The identifier of the category definition of interest :arg ...
[ "def", "get_categories", "(", "self", ",", "job_id", ",", "category_id", "=", "None", ",", "body", "=", "None", ",", "params", "=", "None", ")", ":", "if", "job_id", "in", "SKIP_IN_PATH", ":", "raise", "ValueError", "(", "\"Empty value passed for a required ar...
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html>`_ :arg job_id: The name of the job :arg category_id: The identifier of the category definition of interest :arg body: Category selection details if not provided in URI :arg from_: skips a number of ca...
[ "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "ml", "-", "get", "-", "category", ".", "html", ">", "_" ]
python
train
biosustain/optlang
optlang/scipy_interface.py
https://github.com/biosustain/optlang/blob/13673ac26f6b3ba37a2ef392489722c52e3c5ff1/optlang/scipy_interface.py#L154-L164
def remove_variable(self, name): """Remove a variable from the problem.""" index = self._get_var_index(name) # Remove from matrix self._A = np.delete(self.A, index, 1) # Remove from bounds del self.bounds[name] # Remove from var list del self._variables[na...
[ "def", "remove_variable", "(", "self", ",", "name", ")", ":", "index", "=", "self", ".", "_get_var_index", "(", "name", ")", "# Remove from matrix", "self", ".", "_A", "=", "np", ".", "delete", "(", "self", ".", "A", ",", "index", ",", "1", ")", "# R...
Remove a variable from the problem.
[ "Remove", "a", "variable", "from", "the", "problem", "." ]
python
train
SatelliteQE/nailgun
docs/create_organization_nailgun_v2.py
https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/docs/create_organization_nailgun_v2.py#L8-L12
def main(): """Create an organization, print out its attributes and delete it.""" org = Organization(name='junk org').create() pprint(org.get_values()) # e.g. {'name': 'junk org', …} org.delete()
[ "def", "main", "(", ")", ":", "org", "=", "Organization", "(", "name", "=", "'junk org'", ")", ".", "create", "(", ")", "pprint", "(", "org", ".", "get_values", "(", ")", ")", "# e.g. {'name': 'junk org', …}", "org", ".", "delete", "(", ")" ]
Create an organization, print out its attributes and delete it.
[ "Create", "an", "organization", "print", "out", "its", "attributes", "and", "delete", "it", "." ]
python
train
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/subscribe/subscribe.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/subscribe/subscribe.py#L191-L206
def notify(self, data): """Notify subscribers that data was received""" triggered_channels = [] for channel_name, items in data.items(): for item in items or []: LOG.debug('notify received: %s', item) try: # some channels return str...
[ "def", "notify", "(", "self", ",", "data", ")", ":", "triggered_channels", "=", "[", "]", "for", "channel_name", ",", "items", "in", "data", ".", "items", "(", ")", ":", "for", "item", "in", "items", "or", "[", "]", ":", "LOG", ".", "debug", "(", ...
Notify subscribers that data was received
[ "Notify", "subscribers", "that", "data", "was", "received" ]
python
train
cackharot/suds-py3
suds/builder.py
https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/builder.py#L96-L101
def add_attributes(self, data, type): """ add required attributes """ for attr, ancestry in type.attributes(): name = '_%s' % attr.name value = attr.get_default() setattr(data, name, value)
[ "def", "add_attributes", "(", "self", ",", "data", ",", "type", ")", ":", "for", "attr", ",", "ancestry", "in", "type", ".", "attributes", "(", ")", ":", "name", "=", "'_%s'", "%", "attr", ".", "name", "value", "=", "attr", ".", "get_default", "(", ...
add required attributes
[ "add", "required", "attributes" ]
python
train
tnkteja/myhelp
virtualEnvironment/lib/python2.7/site-packages/coverage/parser.py
https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/parser.py#L69-L74
def _get_byte_parser(self): """Create a ByteParser on demand.""" if not self._byte_parser: self._byte_parser = \ ByteParser(text=self.text, filename=self.filename) return self._byte_parser
[ "def", "_get_byte_parser", "(", "self", ")", ":", "if", "not", "self", ".", "_byte_parser", ":", "self", ".", "_byte_parser", "=", "ByteParser", "(", "text", "=", "self", ".", "text", ",", "filename", "=", "self", ".", "filename", ")", "return", "self", ...
Create a ByteParser on demand.
[ "Create", "a", "ByteParser", "on", "demand", "." ]
python
test
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_firmware.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_firmware.py#L484-L498
def firmware_download_input_protocol_type_sftp_protocol_sftp_port(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") firmware_download = ET.Element("firmware_download") config = firmware_download input = ET.SubElement(firmware_download, "input") ...
[ "def", "firmware_download_input_protocol_type_sftp_protocol_sftp_port", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "firmware_download", "=", "ET", ".", "Element", "(", "\"firmware_download\"", ")", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
amzn/ion-python
amazon/ion/writer.py
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/writer.py#L117-L131
def _drain(writer, ion_event): """Drain the writer of its pending write events. Args: writer (Coroutine): A writer co-routine. ion_event (amazon.ion.core.IonEvent): The first event to apply to the writer. Yields: DataEvent: Yields each pending data event. """ result_event =...
[ "def", "_drain", "(", "writer", ",", "ion_event", ")", ":", "result_event", "=", "_WRITE_EVENT_HAS_PENDING_EMPTY", "while", "result_event", ".", "type", "is", "WriteEventType", ".", "HAS_PENDING", ":", "result_event", "=", "writer", ".", "send", "(", "ion_event", ...
Drain the writer of its pending write events. Args: writer (Coroutine): A writer co-routine. ion_event (amazon.ion.core.IonEvent): The first event to apply to the writer. Yields: DataEvent: Yields each pending data event.
[ "Drain", "the", "writer", "of", "its", "pending", "write", "events", "." ]
python
train
fastai/fastai
fastai/vision/gan.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/gan.py#L90-L104
def on_train_begin(self, **kwargs): "Create the optimizers for the generator and critic if necessary, initialize smootheners." if not getattr(self,'opt_gen',None): self.opt_gen = self.opt.new([nn.Sequential(*flatten_model(self.generator))]) else: self.opt_gen.lr,self.opt_gen.wd = sel...
[ "def", "on_train_begin", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "getattr", "(", "self", ",", "'opt_gen'", ",", "None", ")", ":", "self", ".", "opt_gen", "=", "self", ".", "opt", ".", "new", "(", "[", "nn", ".", "Sequential", ...
Create the optimizers for the generator and critic if necessary, initialize smootheners.
[ "Create", "the", "optimizers", "for", "the", "generator", "and", "critic", "if", "necessary", "initialize", "smootheners", "." ]
python
train
getsentry/sentry-python
sentry_sdk/hub.py
https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/hub.py#L393-L410
def configure_scope(self, callback=None): # noqa """Reconfigures the scope.""" client, scope = self._stack[-1] if callback is not None: if client is not None: callback(scope) return None @contextmanager def inner(): if clien...
[ "def", "configure_scope", "(", "self", ",", "callback", "=", "None", ")", ":", "# noqa", "client", ",", "scope", "=", "self", ".", "_stack", "[", "-", "1", "]", "if", "callback", "is", "not", "None", ":", "if", "client", "is", "not", "None", ":", "...
Reconfigures the scope.
[ "Reconfigures", "the", "scope", "." ]
python
train
seperman/deepdiff
deepdiff/diff.py
https://github.com/seperman/deepdiff/blob/a66879190fadc671632f154c1fcb82f5c3cef800/deepdiff/diff.py#L564-L591
def __diff_numbers(self, level): """Diff Numbers""" t1_type = "number" if self.ignore_numeric_type_changes else level.t1.__class__.__name__ t2_type = "number" if self.ignore_numeric_type_changes else level.t2.__class__.__name__ if self.significant_digits is None: if level.t1...
[ "def", "__diff_numbers", "(", "self", ",", "level", ")", ":", "t1_type", "=", "\"number\"", "if", "self", ".", "ignore_numeric_type_changes", "else", "level", ".", "t1", ".", "__class__", ".", "__name__", "t2_type", "=", "\"number\"", "if", "self", ".", "ign...
Diff Numbers
[ "Diff", "Numbers" ]
python
train
pipermerriam/flex
flex/core.py
https://github.com/pipermerriam/flex/blob/233f8149fb851a6255753bcec948cb6fefb2723b/flex/core.py#L141-L168
def validate_api_call(schema, raw_request, raw_response): """ Validate the request/response cycle of an api call against a swagger schema. Request/Response objects from the `requests` and `urllib` library are supported. """ request = normalize_request(raw_request) with ErrorDict() as error...
[ "def", "validate_api_call", "(", "schema", ",", "raw_request", ",", "raw_response", ")", ":", "request", "=", "normalize_request", "(", "raw_request", ")", "with", "ErrorDict", "(", ")", "as", "errors", ":", "try", ":", "validate_request", "(", "request", "=",...
Validate the request/response cycle of an api call against a swagger schema. Request/Response objects from the `requests` and `urllib` library are supported.
[ "Validate", "the", "request", "/", "response", "cycle", "of", "an", "api", "call", "against", "a", "swagger", "schema", ".", "Request", "/", "Response", "objects", "from", "the", "requests", "and", "urllib", "library", "are", "supported", "." ]
python
train
cgarciae/phi
phi/dsl.py
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L640-L644
def Then0(self, f, *args, **kwargs): """ `Then0(f, ...)` is equivalent to `ThenAt(0, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information. """ return self.ThenAt(0, f, *args, **kwargs)
[ "def", "Then0", "(", "self", ",", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "ThenAt", "(", "0", ",", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
`Then0(f, ...)` is equivalent to `ThenAt(0, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information.
[ "Then0", "(", "f", "...", ")", "is", "equivalent", "to", "ThenAt", "(", "0", "f", "...", ")", ".", "Checkout", "phi", ".", "builder", ".", "Builder", ".", "ThenAt", "for", "more", "information", "." ]
python
train
EventTeam/beliefs
src/beliefs/cells/bools.py
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/bools.py#L44-L49
def is_entailed_by(self, other): """ If the other is as or more specific than self""" other = BoolCell.coerce(other) if self.value == U or other.value == self.value: return True return False
[ "def", "is_entailed_by", "(", "self", ",", "other", ")", ":", "other", "=", "BoolCell", ".", "coerce", "(", "other", ")", "if", "self", ".", "value", "==", "U", "or", "other", ".", "value", "==", "self", ".", "value", ":", "return", "True", "return",...
If the other is as or more specific than self
[ "If", "the", "other", "is", "as", "or", "more", "specific", "than", "self" ]
python
train
mrstephenneal/mysql-toolkit
mysql/toolkit/components/operations/compare.py
https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/components/operations/compare.py#L110-L122
def _schema_getter(self, db): """Retrieve a dictionary representing a database's data schema.""" # Change DB connection if needed if self.database != db: self.change_db(db) schema_dict = {tbl: self.get_schema(tbl) for tbl in self.tables} schema_lst = [] for t...
[ "def", "_schema_getter", "(", "self", ",", "db", ")", ":", "# Change DB connection if needed", "if", "self", ".", "database", "!=", "db", ":", "self", ".", "change_db", "(", "db", ")", "schema_dict", "=", "{", "tbl", ":", "self", ".", "get_schema", "(", ...
Retrieve a dictionary representing a database's data schema.
[ "Retrieve", "a", "dictionary", "representing", "a", "database", "s", "data", "schema", "." ]
python
train
Fizzadar/pyinfra
pyinfra/facts/util/files.py
https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/facts/util/files.py#L57-L71
def _parse_mode(mode): ''' Converts ls mode output (rwxrwxrwx) -> integer (755). ''' result = '' # owner, group, world for group in [mode[0:3], mode[3:6], mode[6:9]]: if group in SYMBOL_TO_OCTAL_PERMISSIONS: result = '{0}{1}'.format(result, SYMBOL_TO_OCTAL_PERMISSIONS[group]...
[ "def", "_parse_mode", "(", "mode", ")", ":", "result", "=", "''", "# owner, group, world", "for", "group", "in", "[", "mode", "[", "0", ":", "3", "]", ",", "mode", "[", "3", ":", "6", "]", ",", "mode", "[", "6", ":", "9", "]", "]", ":", "if", ...
Converts ls mode output (rwxrwxrwx) -> integer (755).
[ "Converts", "ls", "mode", "output", "(", "rwxrwxrwx", ")", "-", ">", "integer", "(", "755", ")", "." ]
python
train
Erotemic/ubelt
ubelt/util_hash.py
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/util_hash.py#L181-L223
def _rectify_hasher(hasher): """ Convert a string-based key into a hasher class Notes: In terms of speed on 64bit systems, sha1 is the fastest followed by md5 and sha512. The slowest algorithm is sha256. If xxhash is installed the fastest algorithm is xxh64. Example: >>...
[ "def", "_rectify_hasher", "(", "hasher", ")", ":", "if", "xxhash", "is", "not", "None", ":", "# pragma: nobranch", "if", "hasher", "in", "{", "'xxh32'", ",", "'xx32'", ",", "'xxhash'", "}", ":", "return", "xxhash", ".", "xxh32", "if", "hasher", "in", "{"...
Convert a string-based key into a hasher class Notes: In terms of speed on 64bit systems, sha1 is the fastest followed by md5 and sha512. The slowest algorithm is sha256. If xxhash is installed the fastest algorithm is xxh64. Example: >>> assert _rectify_hasher(NoParam) is DEFA...
[ "Convert", "a", "string", "-", "based", "key", "into", "a", "hasher", "class" ]
python
valid
aws/sagemaker-containers
src/sagemaker_containers/_mapping.py
https://github.com/aws/sagemaker-containers/blob/0030f07abbaf22a55d986d97274d7a8d1aa1f10c/src/sagemaker_containers/_mapping.py#L144-L151
def properties(self): # type: () -> list """ Returns: (list[str]) List of public properties """ _type = type(self) return [_property for _property in dir(_type) if self._is_property(_property)]
[ "def", "properties", "(", "self", ")", ":", "# type: () -> list", "_type", "=", "type", "(", "self", ")", "return", "[", "_property", "for", "_property", "in", "dir", "(", "_type", ")", "if", "self", ".", "_is_property", "(", "_property", ")", "]" ]
Returns: (list[str]) List of public properties
[ "Returns", ":", "(", "list", "[", "str", "]", ")", "List", "of", "public", "properties" ]
python
train
ababic/django-cogwheels
cogwheels/helpers/settings.py
https://github.com/ababic/django-cogwheels/blob/f185245f6ea1d6a2c23b94ff7304c1594049ca56/cogwheels/helpers/settings.py#L133-L155
def _load_defaults(self): """ Called by ``__init__()`` to create a dictionary of the relevant values from the associated defaults module, and save it to the object's ``_defaults`` attribute to improve lookup performance. Only variables with upper-case names are included. ...
[ "def", "_load_defaults", "(", "self", ")", ":", "self", ".", "_defaults_module_path", "=", "self", ".", "defaults_path", "or", "'.'", ".", "join", "(", "self", ".", "__module_path_split", "[", ":", "-", "1", "]", ")", "+", "\".defaults\"", "module", "=", ...
Called by ``__init__()`` to create a dictionary of the relevant values from the associated defaults module, and save it to the object's ``_defaults`` attribute to improve lookup performance. Only variables with upper-case names are included. :raises: ImportError It is assumed t...
[ "Called", "by", "__init__", "()", "to", "create", "a", "dictionary", "of", "the", "relevant", "values", "from", "the", "associated", "defaults", "module", "and", "save", "it", "to", "the", "object", "s", "_defaults", "attribute", "to", "improve", "lookup", "...
python
train
googledatalab/pydatalab
solutionbox/image_classification/mltoolbox/image/classification/_model.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/image_classification/mltoolbox/image/classification/_model.py#L348-L360
def format_metric_values(self, metric_values): """Formats metric values - used for logging purpose.""" # Early in training, metric_values may actually be None. loss_str = 'N/A' accuracy_str = 'N/A' try: loss_str = 'loss: %.3f' % metric_values[0] accuracy_str = 'accuracy: %.3f' % metric_...
[ "def", "format_metric_values", "(", "self", ",", "metric_values", ")", ":", "# Early in training, metric_values may actually be None.", "loss_str", "=", "'N/A'", "accuracy_str", "=", "'N/A'", "try", ":", "loss_str", "=", "'loss: %.3f'", "%", "metric_values", "[", "0", ...
Formats metric values - used for logging purpose.
[ "Formats", "metric", "values", "-", "used", "for", "logging", "purpose", "." ]
python
train
OCHA-DAP/hdx-python-country
src/hdx/location/country.py
https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L45-L104
def _add_countriesdata(cls, iso3, country): # type: (str, hxl.Row) -> None """ Set up countries data from data in form provided by UNStats and World Bank Args: iso3 (str): ISO3 code for country country (hxl.Row): Country information Returns: ...
[ "def", "_add_countriesdata", "(", "cls", ",", "iso3", ",", "country", ")", ":", "# type: (str, hxl.Row) -> None", "countryname", "=", "country", ".", "get", "(", "'#country+name+preferred'", ")", "cls", ".", "_countriesdata", "[", "'countrynames2iso3'", "]", "[", ...
Set up countries data from data in form provided by UNStats and World Bank Args: iso3 (str): ISO3 code for country country (hxl.Row): Country information Returns: None
[ "Set", "up", "countries", "data", "from", "data", "in", "form", "provided", "by", "UNStats", "and", "World", "Bank" ]
python
train
saltstack/salt
salt/proxy/esxcluster.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/esxcluster.py#L281-L302
def find_credentials(): ''' Cycle through all the possible credentials and return the first one that works. ''' # if the username and password were already found don't fo though the # connection process again if 'username' in DETAILS and 'password' in DETAILS: return DETAILS['userna...
[ "def", "find_credentials", "(", ")", ":", "# if the username and password were already found don't fo though the", "# connection process again", "if", "'username'", "in", "DETAILS", "and", "'password'", "in", "DETAILS", ":", "return", "DETAILS", "[", "'username'", "]", ",",...
Cycle through all the possible credentials and return the first one that works.
[ "Cycle", "through", "all", "the", "possible", "credentials", "and", "return", "the", "first", "one", "that", "works", "." ]
python
train
wonambi-python/wonambi
wonambi/ioeeg/wonambi.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/ioeeg/wonambi.py#L120-L168
def write_wonambi(data, filename, subj_id='', dtype='float64'): """Write file in simple Wonambi format. Parameters ---------- data : instance of ChanTime data with only one trial filename : path to file file to export to (the extensions .won and .dat will be added) subj_id : str...
[ "def", "write_wonambi", "(", "data", ",", "filename", ",", "subj_id", "=", "''", ",", "dtype", "=", "'float64'", ")", ":", "filename", "=", "Path", "(", "filename", ")", "json_file", "=", "filename", ".", "with_suffix", "(", "'.won'", ")", "memmap_file", ...
Write file in simple Wonambi format. Parameters ---------- data : instance of ChanTime data with only one trial filename : path to file file to export to (the extensions .won and .dat will be added) subj_id : str subject id dtype : str numpy dtype in which you wa...
[ "Write", "file", "in", "simple", "Wonambi", "format", "." ]
python
train
gnosis/gnosis-py
gnosis/eth/ethereum_client.py
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L518-L543
def send_eth_to(self, private_key: str, to: str, gas_price: int, value: int, gas: int=22000, retry: bool = False, block_identifier=None, max_eth_to_send: int = 0) -> bytes: """ Send ether using configured account :param to: to :param gas_price: gas_price :para...
[ "def", "send_eth_to", "(", "self", ",", "private_key", ":", "str", ",", "to", ":", "str", ",", "gas_price", ":", "int", ",", "value", ":", "int", ",", "gas", ":", "int", "=", "22000", ",", "retry", ":", "bool", "=", "False", ",", "block_identifier", ...
Send ether using configured account :param to: to :param gas_price: gas_price :param value: value(wei) :param gas: gas, defaults to 22000 :param retry: Retry if a problem is found :param block_identifier: None default, 'pending' not confirmed txs :return: tx_hash
[ "Send", "ether", "using", "configured", "account", ":", "param", "to", ":", "to", ":", "param", "gas_price", ":", "gas_price", ":", "param", "value", ":", "value", "(", "wei", ")", ":", "param", "gas", ":", "gas", "defaults", "to", "22000", ":", "param...
python
test
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/color/color_space.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/color/color_space.py#L25-L36
def _hex_to_rgba(hexs): """Convert hex to rgba, permitting alpha values in hex""" hexs = np.atleast_1d(np.array(hexs, '|U9')) out = np.ones((len(hexs), 4), np.float32) for hi, h in enumerate(hexs): assert isinstance(h, string_types) off = 1 if h[0] == '#' else 0 assert len(h) in ...
[ "def", "_hex_to_rgba", "(", "hexs", ")", ":", "hexs", "=", "np", ".", "atleast_1d", "(", "np", ".", "array", "(", "hexs", ",", "'|U9'", ")", ")", "out", "=", "np", ".", "ones", "(", "(", "len", "(", "hexs", ")", ",", "4", ")", ",", "np", ".",...
Convert hex to rgba, permitting alpha values in hex
[ "Convert", "hex", "to", "rgba", "permitting", "alpha", "values", "in", "hex" ]
python
train
spyder-ide/spyder
spyder/plugins/console/plugin.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/plugin.py#L252-L276
def run_script(self, filename=None, silent=False, set_focus=False, args=None): """Run a Python script""" if filename is None: self.shell.interpreter.restore_stds() filename, _selfilter = getopenfilename( self, _("Run Python script"), g...
[ "def", "run_script", "(", "self", ",", "filename", "=", "None", ",", "silent", "=", "False", ",", "set_focus", "=", "False", ",", "args", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "self", ".", "shell", ".", "interpreter", ".", "rest...
Run a Python script
[ "Run", "a", "Python", "script" ]
python
train
click-contrib/click-configfile
tasks/_vendor/pathlib.py
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1222-L1233
def is_block_device(self): """ Whether this path is a block device. """ try: return S_ISBLK(self.stat().st_mode) except OSError as e: if e.errno != ENOENT: raise # Path doesn't exist or is a broken symlink # (see htt...
[ "def", "is_block_device", "(", "self", ")", ":", "try", ":", "return", "S_ISBLK", "(", "self", ".", "stat", "(", ")", ".", "st_mode", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "!=", "ENOENT", ":", "raise", "# Path doesn't exist...
Whether this path is a block device.
[ "Whether", "this", "path", "is", "a", "block", "device", "." ]
python
train
metagriffin/fso
fso/filesystemoverlay.py
https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L465-L472
def fso_rmdir(self, path): 'overlays os.rmdir()' st = self.fso_lstat(path) if not stat.S_ISDIR(st.st_mode): raise OSError(20, 'Not a directory', path) if len(self.fso_listdir(path)) > 0: raise OSError(39, 'Directory not empty', path) self._addentry(OverlayEntry(self, path, None))
[ "def", "fso_rmdir", "(", "self", ",", "path", ")", ":", "st", "=", "self", ".", "fso_lstat", "(", "path", ")", "if", "not", "stat", ".", "S_ISDIR", "(", "st", ".", "st_mode", ")", ":", "raise", "OSError", "(", "20", ",", "'Not a directory'", ",", "...
overlays os.rmdir()
[ "overlays", "os", ".", "rmdir", "()" ]
python
valid
theonion/django-bulbs
bulbs/content/custom_search.py
https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/content/custom_search.py#L162-L203
def groups_filter_from_query(query, field_map={}): """Creates an F object for the groups of a search query.""" f = None # filter groups for group in query.get("groups", []): group_f = MatchAll() for condition in group.get("conditions", []): field_name = condition["field"] ...
[ "def", "groups_filter_from_query", "(", "query", ",", "field_map", "=", "{", "}", ")", ":", "f", "=", "None", "# filter groups", "for", "group", "in", "query", ".", "get", "(", "\"groups\"", ",", "[", "]", ")", ":", "group_f", "=", "MatchAll", "(", ")"...
Creates an F object for the groups of a search query.
[ "Creates", "an", "F", "object", "for", "the", "groups", "of", "a", "search", "query", "." ]
python
train
Jaymon/prom
prom/cli/generate.py
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/generate.py#L12-L28
def get_table_info(*table_names): """Returns a dict with table_name keys mapped to the Interface that table exists in :param *table_names: the tables you are searching for """ ret = {} if table_names: for table_name in table_names: for name, inter in get_interfaces().items(): ...
[ "def", "get_table_info", "(", "*", "table_names", ")", ":", "ret", "=", "{", "}", "if", "table_names", ":", "for", "table_name", "in", "table_names", ":", "for", "name", ",", "inter", "in", "get_interfaces", "(", ")", ".", "items", "(", ")", ":", "if",...
Returns a dict with table_name keys mapped to the Interface that table exists in :param *table_names: the tables you are searching for
[ "Returns", "a", "dict", "with", "table_name", "keys", "mapped", "to", "the", "Interface", "that", "table", "exists", "in" ]
python
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L5739-L5826
def initialize(self, modulo=None): """reset logger, overwrite original files, `modulo`: log only every modulo call""" if modulo is not None: self.modulo = modulo try: es = self.es # must have been registered except AttributeError: pass # TODO: revise...
[ "def", "initialize", "(", "self", ",", "modulo", "=", "None", ")", ":", "if", "modulo", "is", "not", "None", ":", "self", ".", "modulo", "=", "modulo", "try", ":", "es", "=", "self", ".", "es", "# must have been registered", "except", "AttributeError", "...
reset logger, overwrite original files, `modulo`: log only every modulo call
[ "reset", "logger", "overwrite", "original", "files", "modulo", ":", "log", "only", "every", "modulo", "call" ]
python
train
fhcrc/nestly
nestly/scripts/nestrun.py
https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scripts/nestrun.py#L186-L192
def complete(self, return_code): """ Mark the process as complete with provided return_code """ self.return_code = return_code self.status = 'COMPLETE' if not return_code else 'FAILED' self.end_time = datetime.datetime.now()
[ "def", "complete", "(", "self", ",", "return_code", ")", ":", "self", ".", "return_code", "=", "return_code", "self", ".", "status", "=", "'COMPLETE'", "if", "not", "return_code", "else", "'FAILED'", "self", ".", "end_time", "=", "datetime", ".", "datetime",...
Mark the process as complete with provided return_code
[ "Mark", "the", "process", "as", "complete", "with", "provided", "return_code" ]
python
train
SatelliteQE/nailgun
nailgun/entities.py
https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entities.py#L1659-L1665
def update_payload(self, fields=None): """Wrap submitted data within an extra dict.""" payload = super(JobTemplate, self).update_payload(fields) effective_user = payload.pop(u'effective_user', None) if effective_user: payload[u'ssh'] = {u'effective_user': effective_user} ...
[ "def", "update_payload", "(", "self", ",", "fields", "=", "None", ")", ":", "payload", "=", "super", "(", "JobTemplate", ",", "self", ")", ".", "update_payload", "(", "fields", ")", "effective_user", "=", "payload", ".", "pop", "(", "u'effective_user'", ",...
Wrap submitted data within an extra dict.
[ "Wrap", "submitted", "data", "within", "an", "extra", "dict", "." ]
python
train
pyQode/pyqode.core
pyqode/core/api/code_edit.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/api/code_edit.py#L890-L898
def copy(self): """ Copy the selected text to the clipboard. If no text was selected, the entire line is copied (this feature can be turned off by setting :attr:`select_line_on_copy_empty` to False. """ if self.select_line_on_copy_empty and not self.textCursor().hasSelect...
[ "def", "copy", "(", "self", ")", ":", "if", "self", ".", "select_line_on_copy_empty", "and", "not", "self", ".", "textCursor", "(", ")", ".", "hasSelection", "(", ")", ":", "TextHelper", "(", "self", ")", ".", "select_whole_line", "(", ")", "super", "(",...
Copy the selected text to the clipboard. If no text was selected, the entire line is copied (this feature can be turned off by setting :attr:`select_line_on_copy_empty` to False.
[ "Copy", "the", "selected", "text", "to", "the", "clipboard", ".", "If", "no", "text", "was", "selected", "the", "entire", "line", "is", "copied", "(", "this", "feature", "can", "be", "turned", "off", "by", "setting", ":", "attr", ":", "select_line_on_copy_...
python
train
summa-tx/riemann
riemann/encoding/base58.py
https://github.com/summa-tx/riemann/blob/04ae336dfd4007ceaed748daadc91cc32fa278ec/riemann/encoding/base58.py#L32-L39
def encode(data, checksum=True): """Convert binary to base58 using BASE58_ALPHABET.""" if checksum: data = data + utils.hash256(data)[:4] v, prefix = to_long(256, lambda x: x, iter(data)) data = from_long(v, prefix, BASE58_BASE, lambda v: BASE58_ALPHABET[v]) return data.decode("utf8")
[ "def", "encode", "(", "data", ",", "checksum", "=", "True", ")", ":", "if", "checksum", ":", "data", "=", "data", "+", "utils", ".", "hash256", "(", "data", ")", "[", ":", "4", "]", "v", ",", "prefix", "=", "to_long", "(", "256", ",", "lambda", ...
Convert binary to base58 using BASE58_ALPHABET.
[ "Convert", "binary", "to", "base58", "using", "BASE58_ALPHABET", "." ]
python
train
pgmpy/pgmpy
pgmpy/models/BayesianModel.py
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L511-L567
def predict(self, data): """ Predicts states of all the missing variables. Parameters ---------- data : pandas DataFrame object A DataFrame object with column names same as the variables in the model. Examples -------- >>> import numpy as np ...
[ "def", "predict", "(", "self", ",", "data", ")", ":", "from", "pgmpy", ".", "inference", "import", "VariableElimination", "if", "set", "(", "data", ".", "columns", ")", "==", "set", "(", "self", ".", "nodes", "(", ")", ")", ":", "raise", "ValueError", ...
Predicts states of all the missing variables. Parameters ---------- data : pandas DataFrame object A DataFrame object with column names same as the variables in the model. Examples -------- >>> import numpy as np >>> import pandas as pd >>> f...
[ "Predicts", "states", "of", "all", "the", "missing", "variables", "." ]
python
train
tumblr/pytumblr
pytumblr/__init__.py
https://github.com/tumblr/pytumblr/blob/4a5cd7c4b8ae78d12811d9fd52620afa1692a415/pytumblr/__init__.py#L114-L134
def posts(self, blogname, type=None, **kwargs): """ Gets a list of posts from a particular blog :param blogname: a string, the blogname you want to look up posts for. eg: codingjester.tumblr.com :param id: an int, the id of the post you are looking for on the bl...
[ "def", "posts", "(", "self", ",", "blogname", ",", "type", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "type", "is", "None", ":", "url", "=", "'/v2/blog/{}/posts'", ".", "format", "(", "blogname", ")", "else", ":", "url", "=", "'/v2/blog/{}...
Gets a list of posts from a particular blog :param blogname: a string, the blogname you want to look up posts for. eg: codingjester.tumblr.com :param id: an int, the id of the post you are looking for on the blog :param tag: a string, the tag you are looking for on post...
[ "Gets", "a", "list", "of", "posts", "from", "a", "particular", "blog" ]
python
train
RedisJSON/rejson-py
rejson/client.py
https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L106-L123
def jsonget(self, name, *args): """ Get the object stored as a JSON value at key ``name`` ``args`` is zero or more paths, and defaults to root path """ pieces = [name] if len(args) == 0: pieces.append(Path.rootPath()) else: for p in args: ...
[ "def", "jsonget", "(", "self", ",", "name", ",", "*", "args", ")", ":", "pieces", "=", "[", "name", "]", "if", "len", "(", "args", ")", "==", "0", ":", "pieces", ".", "append", "(", "Path", ".", "rootPath", "(", ")", ")", "else", ":", "for", ...
Get the object stored as a JSON value at key ``name`` ``args`` is zero or more paths, and defaults to root path
[ "Get", "the", "object", "stored", "as", "a", "JSON", "value", "at", "key", "name", "args", "is", "zero", "or", "more", "paths", "and", "defaults", "to", "root", "path" ]
python
train
hawkular/hawkular-client-python
hawkular/alerts/triggers.py
https://github.com/hawkular/hawkular-client-python/blob/52371f9ebabbe310efee2a8ff8eb735ccc0654bb/hawkular/alerts/triggers.py#L212-L222
def group_members(self, group_id, include_orphans=False): """ Find all group member trigger definitions :param group_id: group trigger id :param include_orphans: If True, include orphan members :return: list of asociated group members as trigger objects """ param...
[ "def", "group_members", "(", "self", ",", "group_id", ",", "include_orphans", "=", "False", ")", ":", "params", "=", "{", "'includeOrphans'", ":", "str", "(", "include_orphans", ")", ".", "lower", "(", ")", "}", "url", "=", "self", ".", "_service_url", "...
Find all group member trigger definitions :param group_id: group trigger id :param include_orphans: If True, include orphan members :return: list of asociated group members as trigger objects
[ "Find", "all", "group", "member", "trigger", "definitions" ]
python
train
spdx/tools-python
spdx/parsers/tagvaluebuilders.py
https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/tagvaluebuilders.py#L907-L924
def set_concluded_license(self, doc, lic): """ Raises OrderError if no package or file defined. Raises CardinalityError if already set. Raises SPDXValueError if malformed. """ if self.has_package(doc) and self.has_file(doc): if not self.file_conc_lics_set: ...
[ "def", "set_concluded_license", "(", "self", ",", "doc", ",", "lic", ")", ":", "if", "self", ".", "has_package", "(", "doc", ")", "and", "self", ".", "has_file", "(", "doc", ")", ":", "if", "not", "self", ".", "file_conc_lics_set", ":", "self", ".", ...
Raises OrderError if no package or file defined. Raises CardinalityError if already set. Raises SPDXValueError if malformed.
[ "Raises", "OrderError", "if", "no", "package", "or", "file", "defined", ".", "Raises", "CardinalityError", "if", "already", "set", ".", "Raises", "SPDXValueError", "if", "malformed", "." ]
python
valid
totalgood/nlpia
src/nlpia/web.py
https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/web.py#L224-L252
def download_file_from_google_drive(driveid, filename=None, destination=os.path.curdir): """ Download script for google drive shared links Thank you @turdus-merula and Andrew Hundt! https://stackoverflow.com/a/39225039/623735 """ if '&id=' in driveid: # https://drive.google.com/uc?export=...
[ "def", "download_file_from_google_drive", "(", "driveid", ",", "filename", "=", "None", ",", "destination", "=", "os", ".", "path", ".", "curdir", ")", ":", "if", "'&id='", "in", "driveid", ":", "# https://drive.google.com/uc?export=download&id=0BwmD_VLjROrfM1BxdkxVaTY2...
Download script for google drive shared links Thank you @turdus-merula and Andrew Hundt! https://stackoverflow.com/a/39225039/623735
[ "Download", "script", "for", "google", "drive", "shared", "links" ]
python
train
tensorpack/tensorpack
examples/FasterRCNN/model_frcnn.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/FasterRCNN/model_frcnn.py#L20-L38
def proposal_metrics(iou): """ Add summaries for RPN proposals. Args: iou: nxm, #proposal x #gt """ # find best roi for each gt, for summary only best_iou = tf.reduce_max(iou, axis=0) mean_best_iou = tf.reduce_mean(best_iou, name='best_iou_per_gt') summaries = [mean_best_iou] ...
[ "def", "proposal_metrics", "(", "iou", ")", ":", "# find best roi for each gt, for summary only", "best_iou", "=", "tf", ".", "reduce_max", "(", "iou", ",", "axis", "=", "0", ")", "mean_best_iou", "=", "tf", ".", "reduce_mean", "(", "best_iou", ",", "name", "=...
Add summaries for RPN proposals. Args: iou: nxm, #proposal x #gt
[ "Add", "summaries", "for", "RPN", "proposals", "." ]
python
train
sdispater/orator
orator/schema/blueprint.py
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/blueprint.py#L61-L71
def _add_implied_commands(self): """ Add the commands that are implied by the blueprint. """ if len(self.get_added_columns()) and not self._creating(): self._commands.insert(0, self._create_command("add")) if len(self.get_changed_columns()) and not self._creating(): ...
[ "def", "_add_implied_commands", "(", "self", ")", ":", "if", "len", "(", "self", ".", "get_added_columns", "(", ")", ")", "and", "not", "self", ".", "_creating", "(", ")", ":", "self", ".", "_commands", ".", "insert", "(", "0", ",", "self", ".", "_cr...
Add the commands that are implied by the blueprint.
[ "Add", "the", "commands", "that", "are", "implied", "by", "the", "blueprint", "." ]
python
train
bokeh/bokeh
bokeh/embed/standalone.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/embed/standalone.py#L111-L248
def components(models, wrap_script=True, wrap_plot_info=True, theme=FromCurdoc): ''' Return HTML components to embed a Bokeh plot. The data for the plot is stored directly in the returned HTML. An example can be found in examples/embed/embed_multiple.py The returned components assume that BokehJS reso...
[ "def", "components", "(", "models", ",", "wrap_script", "=", "True", ",", "wrap_plot_info", "=", "True", ",", "theme", "=", "FromCurdoc", ")", ":", "# 1) Convert single items and dicts into list", "was_single_object", "=", "isinstance", "(", "models", ",", "Model", ...
Return HTML components to embed a Bokeh plot. The data for the plot is stored directly in the returned HTML. An example can be found in examples/embed/embed_multiple.py The returned components assume that BokehJS resources are **already loaded**. The html template in which they will be embedded needs ...
[ "Return", "HTML", "components", "to", "embed", "a", "Bokeh", "plot", ".", "The", "data", "for", "the", "plot", "is", "stored", "directly", "in", "the", "returned", "HTML", "." ]
python
train
mvcisback/py-aiger
aiger/common.py
https://github.com/mvcisback/py-aiger/blob/475ae75bd19a54ac5a71aa4dadb8369a009a1627/aiger/common.py#L126-L133
def _ite(test: str, in1: str, in0: str, output: str = None): r"test -> in1 /\ ~test -> in0" assert len({test, in0, in1}) == 3 true_out = bit_flipper([test]) >> or_gate([test, in1], 'true_out') false_out = or_gate([test, in0], 'false_out') return (true_out | false_out) >> and_gate(['true_out', 'fals...
[ "def", "_ite", "(", "test", ":", "str", ",", "in1", ":", "str", ",", "in0", ":", "str", ",", "output", ":", "str", "=", "None", ")", ":", "assert", "len", "(", "{", "test", ",", "in0", ",", "in1", "}", ")", "==", "3", "true_out", "=", "bit_fl...
r"test -> in1 /\ ~test -> in0
[ "r", "test", "-", ">", "in1", "/", "\\", "~test", "-", ">", "in0" ]
python
train
shopkick/flawless
flawless/client/client.py
https://github.com/shopkick/flawless/blob/c54b63ca1991c153e6f75080536f6df445aacc64/flawless/client/client.py#L173-L228
def record_error(hostname, exc_info, preceding_stack=None, error_threshold=None, additional_info=None): ''' Helper function to record errors to the flawless backend ''' stack = [] exc_type, exc_value, sys_traceback = exc_info while sys_traceback is not None: stack.append(sys_traceback) ...
[ "def", "record_error", "(", "hostname", ",", "exc_info", ",", "preceding_stack", "=", "None", ",", "error_threshold", "=", "None", ",", "additional_info", "=", "None", ")", ":", "stack", "=", "[", "]", "exc_type", ",", "exc_value", ",", "sys_traceback", "=",...
Helper function to record errors to the flawless backend
[ "Helper", "function", "to", "record", "errors", "to", "the", "flawless", "backend" ]
python
test
inveniosoftware-attic/invenio-comments
invenio_comments/api.py
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L954-L1121
def query_add_comment_or_remark(reviews=0, recID=0, uid=-1, msg="", note="", score=0, priority=0, client_ip_address='', editor_type='textarea', req=None, reply_to=None, attached_files=None): """ Private function ...
[ "def", "query_add_comment_or_remark", "(", "reviews", "=", "0", ",", "recID", "=", "0", ",", "uid", "=", "-", "1", ",", "msg", "=", "\"\"", ",", "note", "=", "\"\"", ",", "score", "=", "0", ",", "priority", "=", "0", ",", "client_ip_address", "=", ...
Private function Insert a comment/review or remarkinto the database :param recID: record id :param uid: user id :param msg: comment body :param note: comment title :param score: review star score :param priority: remark priority #!FIXME :param editor_type: the kind of editor used to subm...
[ "Private", "function", "Insert", "a", "comment", "/", "review", "or", "remarkinto", "the", "database", ":", "param", "recID", ":", "record", "id", ":", "param", "uid", ":", "user", "id", ":", "param", "msg", ":", "comment", "body", ":", "param", "note", ...
python
train
rodluger/everest
everest/basecamp.py
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L57-L70
def show(self): """Show the overfitting PDF summary.""" try: if platform.system().lower().startswith('darwin'): subprocess.call(['open', self.pdf]) elif os.name == 'nt': os.startfile(self.pdf) elif os.name == 'posix': su...
[ "def", "show", "(", "self", ")", ":", "try", ":", "if", "platform", ".", "system", "(", ")", ".", "lower", "(", ")", ".", "startswith", "(", "'darwin'", ")", ":", "subprocess", ".", "call", "(", "[", "'open'", ",", "self", ".", "pdf", "]", ")", ...
Show the overfitting PDF summary.
[ "Show", "the", "overfitting", "PDF", "summary", "." ]
python
train
openvax/varcode
varcode/effects/effect_collection.py
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_collection.py#L272-L301
def to_dataframe(self): """Build a dataframe from the effect collection""" # list of properties to extract from Variant objects if they're # not None variant_properties = [ "contig", "start", "ref", "alt", "is_snv", ...
[ "def", "to_dataframe", "(", "self", ")", ":", "# list of properties to extract from Variant objects if they're", "# not None", "variant_properties", "=", "[", "\"contig\"", ",", "\"start\"", ",", "\"ref\"", ",", "\"alt\"", ",", "\"is_snv\"", ",", "\"is_transversion\"", ",...
Build a dataframe from the effect collection
[ "Build", "a", "dataframe", "from", "the", "effect", "collection" ]
python
train
tcalmant/ipopo
samples/rsa/helloimpl.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/samples/rsa/helloimpl.py#L58-L71
def sayHelloPromise(self, name="Not given", message="nothing"): """ Implementation of IHello.sayHelloPromise. This method will be executed via some thread, and the remote caller will not block. """ print( "Python.sayHelloPromise called by: {0} " "w...
[ "def", "sayHelloPromise", "(", "self", ",", "name", "=", "\"Not given\"", ",", "message", "=", "\"nothing\"", ")", ":", "print", "(", "\"Python.sayHelloPromise called by: {0} \"", "\"with message: '{1}'\"", ".", "format", "(", "name", ",", "message", ")", ")", "re...
Implementation of IHello.sayHelloPromise. This method will be executed via some thread, and the remote caller will not block.
[ "Implementation", "of", "IHello", ".", "sayHelloPromise", ".", "This", "method", "will", "be", "executed", "via", "some", "thread", "and", "the", "remote", "caller", "will", "not", "block", "." ]
python
train
geophysics-ubonn/crtomo_tools
lib/crtomo/grid.py
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L417-L427
def get_electrode_node(self, electrode): """ For a given electrode (e.g. from a config.dat file), return the true node number as in self.nodes['sorted'] """ elec_node_raw = int(self.electrodes[electrode - 1][0]) if(self.header['cutmck']): elec_node = self.node...
[ "def", "get_electrode_node", "(", "self", ",", "electrode", ")", ":", "elec_node_raw", "=", "int", "(", "self", ".", "electrodes", "[", "electrode", "-", "1", "]", "[", "0", "]", ")", "if", "(", "self", ".", "header", "[", "'cutmck'", "]", ")", ":", ...
For a given electrode (e.g. from a config.dat file), return the true node number as in self.nodes['sorted']
[ "For", "a", "given", "electrode", "(", "e", ".", "g", ".", "from", "a", "config", ".", "dat", "file", ")", "return", "the", "true", "node", "number", "as", "in", "self", ".", "nodes", "[", "sorted", "]" ]
python
train
arkottke/pysra
pysra/propagation.py
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/propagation.py#L284-L338
def _calc_waves(self, angular_freqs, profile): """Compute the wave numbers and amplitudes (up- and down-going). Parameters ---------- angular_freqs: :class:`numpy.ndarray` Angular frequency at which the waves are computed. profile: :class:`~.base.site.Profile` ...
[ "def", "_calc_waves", "(", "self", ",", "angular_freqs", ",", "profile", ")", ":", "# Compute the complex wave numbers of the system", "wave_nums", "=", "np", ".", "empty", "(", "(", "len", "(", "profile", ")", ",", "len", "(", "angular_freqs", ")", ")", ",", ...
Compute the wave numbers and amplitudes (up- and down-going). Parameters ---------- angular_freqs: :class:`numpy.ndarray` Angular frequency at which the waves are computed. profile: :class:`~.base.site.Profile` Site profile.
[ "Compute", "the", "wave", "numbers", "and", "amplitudes", "(", "up", "-", "and", "down", "-", "going", ")", "." ]
python
train
evhub/coconut
coconut/compiler/matching.py
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/matching.py#L223-L226
def match_all_in(self, matches, item): """Matches all matches to elements of item.""" for i, match in enumerate(matches): self.match(match, item + "[" + str(i) + "]")
[ "def", "match_all_in", "(", "self", ",", "matches", ",", "item", ")", ":", "for", "i", ",", "match", "in", "enumerate", "(", "matches", ")", ":", "self", ".", "match", "(", "match", ",", "item", "+", "\"[\"", "+", "str", "(", "i", ")", "+", "\"]\...
Matches all matches to elements of item.
[ "Matches", "all", "matches", "to", "elements", "of", "item", "." ]
python
train
PyGithub/PyGithub
github/MainClass.py
https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/MainClass.py#L206-L219
def get_licenses(self): """ :calls: `GET /licenses <https://developer.github.com/v3/licenses/#list-all-licenses>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.License.License` """ url_parameters = dict() return github.PaginatedList.PaginatedLis...
[ "def", "get_licenses", "(", "self", ")", ":", "url_parameters", "=", "dict", "(", ")", "return", "github", ".", "PaginatedList", ".", "PaginatedList", "(", "github", ".", "License", ".", "License", ",", "self", ".", "__requester", ",", "\"/licenses\"", ",", ...
:calls: `GET /licenses <https://developer.github.com/v3/licenses/#list-all-licenses>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.License.License`
[ ":", "calls", ":", "GET", "/", "licenses", "<https", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "licenses", "/", "#list", "-", "all", "-", "licenses", ">", "_", ":", "rtype", ":", ":", "class", ":", "github", ".", "Paginated...
python
train
tensorpack/tensorpack
tensorpack/tfutils/common.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/tfutils/common.py#L167-L245
def collect_env_info(): """ Returns: str - a table contains important information about the environment """ data = [] data.append(("sys.platform", sys.platform)) data.append(("Python", sys.version.replace("\n", ""))) data.append(("Tensorpack", __git_version__)) data.append(("Nump...
[ "def", "collect_env_info", "(", ")", ":", "data", "=", "[", "]", "data", ".", "append", "(", "(", "\"sys.platform\"", ",", "sys", ".", "platform", ")", ")", "data", ".", "append", "(", "(", "\"Python\"", ",", "sys", ".", "version", ".", "replace", "(...
Returns: str - a table contains important information about the environment
[ "Returns", ":", "str", "-", "a", "table", "contains", "important", "information", "about", "the", "environment" ]
python
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/inverse.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/inverse.py#L81-L93
def _guess_x_kmeans(self, y_desired, **kwargs): """Provide an initial guesses for a probable x from y""" k = kwargs.get('k', self.k) _, indexes = self.fmodel.dataset.nn_y(y_desired, k=k) X = np.array([self.fmodel.get_x(i) for i in indexes]) if np.sum(X) == 0.: centroi...
[ "def", "_guess_x_kmeans", "(", "self", ",", "y_desired", ",", "*", "*", "kwargs", ")", ":", "k", "=", "kwargs", ".", "get", "(", "'k'", ",", "self", ".", "k", ")", "_", ",", "indexes", "=", "self", ".", "fmodel", ".", "dataset", ".", "nn_y", "(",...
Provide an initial guesses for a probable x from y
[ "Provide", "an", "initial", "guesses", "for", "a", "probable", "x", "from", "y" ]
python
train
merll/docker-map
dockermap/map/runner/image.py
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/runner/image.py#L51-L71
def pull(self, action, image_name, **kwargs): """ Pulls an image for a container configuration :param action: Action configuration. :type action: dockermap.map.runner.ActionConfig :param image_name: Image name. :type image_name: unicode | str :param kwargs: Addit...
[ "def", "pull", "(", "self", ",", "action", ",", "image_name", ",", "*", "*", "kwargs", ")", ":", "config_id", "=", "action", ".", "config_id", "registry", ",", "__", ",", "image", "=", "config_id", ".", "config_name", ".", "rpartition", "(", "'/'", ")"...
Pulls an image for a container configuration :param action: Action configuration. :type action: dockermap.map.runner.ActionConfig :param image_name: Image name. :type image_name: unicode | str :param kwargs: Additional keyword arguments to complement or override the configuratio...
[ "Pulls", "an", "image", "for", "a", "container", "configuration" ]
python
train
jut-io/jut-python-tools
jut/api/accounts.py
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/accounts.py#L130-L147
def user_exists(username, token_manager=None, app_url=defaults.APP_URL): """ check if the user exists with the specified username """ headers = token_manager.get_access_token_headers() auth_url = environment.get_auth_url(app_url=app_url) url = "%s/api/v1/accounts...
[ "def", "user_exists", "(", "username", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "headers", "=", "token_manager", ".", "get_access_token_headers", "(", ")", "auth_url", "=", "environment", ".", "get_auth_url", ...
check if the user exists with the specified username
[ "check", "if", "the", "user", "exists", "with", "the", "specified", "username" ]
python
train
The-Politico/politico-civic-election
election/models/candidate.py
https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/candidate.py#L71-L77
def get_election_electoral_votes(self, election): """Get all electoral votes for this candidate in an election.""" candidate_election = CandidateElection.objects.get( candidate=self, election=election ) return candidate_election.electoral_votes.all()
[ "def", "get_election_electoral_votes", "(", "self", ",", "election", ")", ":", "candidate_election", "=", "CandidateElection", ".", "objects", ".", "get", "(", "candidate", "=", "self", ",", "election", "=", "election", ")", "return", "candidate_election", ".", ...
Get all electoral votes for this candidate in an election.
[ "Get", "all", "electoral", "votes", "for", "this", "candidate", "in", "an", "election", "." ]
python
train
prthkms/alex
alex/duckduckgo.py
https://github.com/prthkms/alex/blob/79d3167c877e94cc07db0aab55a35857fac67ef7/alex/duckduckgo.py#L30-L42
def query(string): """query(user string) -- make http request to duckduckgo api, to get result in json format, then call parse_result. """ url = "https://api.duckduckgo.com/?q=" formating = "&format=json" query_string = url+'+'.join(string)+formating try: result = json.loads(requests.get(query_string).text) e...
[ "def", "query", "(", "string", ")", ":", "url", "=", "\"https://api.duckduckgo.com/?q=\"", "formating", "=", "\"&format=json\"", "query_string", "=", "url", "+", "'+'", ".", "join", "(", "string", ")", "+", "formating", "try", ":", "result", "=", "json", "."...
query(user string) -- make http request to duckduckgo api, to get result in json format, then call parse_result.
[ "query", "(", "user", "string", ")", "--", "make", "http", "request", "to", "duckduckgo", "api", "to", "get", "result", "in", "json", "format", "then", "call", "parse_result", "." ]
python
train
pysam-developers/pysam
pysam/Pileup.py
https://github.com/pysam-developers/pysam/blob/9961bebd4cd1f2bf5e42817df25699a6e6344b5a/pysam/Pileup.py#L198-L253
def vcf2pileup(vcf, sample): '''convert vcf record to pileup record.''' chromosome = vcf.contig pos = vcf.pos reference = vcf.ref allelles = [reference] + vcf.alt data = vcf[sample] # get genotype genotypes = data["GT"] if len(genotypes) > 1: raise ValueError("only single ...
[ "def", "vcf2pileup", "(", "vcf", ",", "sample", ")", ":", "chromosome", "=", "vcf", ".", "contig", "pos", "=", "vcf", ".", "pos", "reference", "=", "vcf", ".", "ref", "allelles", "=", "[", "reference", "]", "+", "vcf", ".", "alt", "data", "=", "vcf...
convert vcf record to pileup record.
[ "convert", "vcf", "record", "to", "pileup", "record", "." ]
python
train
fracpete/python-weka-wrapper3
python/weka/core/classes.py
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L398-L407
def logger(self): """ Returns the logger object. :return: the logger :rtype: logger """ if self._logger is None: self._logger = self.new_logger() return self._logger
[ "def", "logger", "(", "self", ")", ":", "if", "self", ".", "_logger", "is", "None", ":", "self", ".", "_logger", "=", "self", ".", "new_logger", "(", ")", "return", "self", ".", "_logger" ]
Returns the logger object. :return: the logger :rtype: logger
[ "Returns", "the", "logger", "object", "." ]
python
train
kislyuk/aegea
aegea/packages/github3/github.py
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L76-L86
def authorization(self, id_num): """Get information about authorization ``id``. :param int id_num: (required), unique id of the authorization :returns: :class:`Authorization <Authorization>` """ json = None if int(id_num) > 0: url = self._build_url('authoriza...
[ "def", "authorization", "(", "self", ",", "id_num", ")", ":", "json", "=", "None", "if", "int", "(", "id_num", ")", ">", "0", ":", "url", "=", "self", ".", "_build_url", "(", "'authorizations'", ",", "str", "(", "id_num", ")", ")", "json", "=", "se...
Get information about authorization ``id``. :param int id_num: (required), unique id of the authorization :returns: :class:`Authorization <Authorization>`
[ "Get", "information", "about", "authorization", "id", "." ]
python
train
Genida/django-meerkat
src/meerkat/utils/list.py
https://github.com/Genida/django-meerkat/blob/486502a75bb0800266db785fd32717d8c0eb8deb/src/meerkat/utils/list.py#L6-L18
def distinct(l): """ Return a list where the duplicates have been removed. Args: l (list): the list to filter. Returns: list: the same list without duplicates. """ seen = set() seen_add = seen.add return (_ for _ in l if not (_ in seen or seen_add(_)))
[ "def", "distinct", "(", "l", ")", ":", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".", "add", "return", "(", "_", "for", "_", "in", "l", "if", "not", "(", "_", "in", "seen", "or", "seen_add", "(", "_", ")", ")", ")" ]
Return a list where the duplicates have been removed. Args: l (list): the list to filter. Returns: list: the same list without duplicates.
[ "Return", "a", "list", "where", "the", "duplicates", "have", "been", "removed", "." ]
python
train
chrisspen/dtree
dtree.py
https://github.com/chrisspen/dtree/blob/9e9c9992b22ad9a7e296af7e6837666b05db43ef/dtree.py#L429-L473
def get_gain(data, attr, class_attr, method=DEFAULT_DISCRETE_METRIC, only_sub=0, prefer_fewer_values=False, entropy_func=None): """ Calculates the information gain (reduction in entropy) that would result by splitting the data on the chosen attribute (attr). Parameters: prefer_fewe...
[ "def", "get_gain", "(", "data", ",", "attr", ",", "class_attr", ",", "method", "=", "DEFAULT_DISCRETE_METRIC", ",", "only_sub", "=", "0", ",", "prefer_fewer_values", "=", "False", ",", "entropy_func", "=", "None", ")", ":", "entropy_func", "=", "entropy_func",...
Calculates the information gain (reduction in entropy) that would result by splitting the data on the chosen attribute (attr). Parameters: prefer_fewer_values := Weights the gain by the count of the attribute's unique values. If multiple attributes have the same gain, but one has s...
[ "Calculates", "the", "information", "gain", "(", "reduction", "in", "entropy", ")", "that", "would", "result", "by", "splitting", "the", "data", "on", "the", "chosen", "attribute", "(", "attr", ")", ".", "Parameters", ":", "prefer_fewer_values", ":", "=", "W...
python
train
spdx/tools-python
spdx/parsers/tagvaluebuilders.py
https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/tagvaluebuilders.py#L248-L262
def build_person(self, doc, entity): """Builds an organization object of of a string representation. Returns built organization. Raises SPDXValueError if failed to extract name. """ match = self.person_re.match(entity) if match and validations.validate_person_name(match.g...
[ "def", "build_person", "(", "self", ",", "doc", ",", "entity", ")", ":", "match", "=", "self", ".", "person_re", ".", "match", "(", "entity", ")", "if", "match", "and", "validations", ".", "validate_person_name", "(", "match", ".", "group", "(", "self", ...
Builds an organization object of of a string representation. Returns built organization. Raises SPDXValueError if failed to extract name.
[ "Builds", "an", "organization", "object", "of", "of", "a", "string", "representation", ".", "Returns", "built", "organization", ".", "Raises", "SPDXValueError", "if", "failed", "to", "extract", "name", "." ]
python
valid
kytos/kytos-utils
kytos/cli/commands/napps/api.py
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L284-L300
def reload(cls, args): """Reload NApps code.""" LOG.info('Reloading NApps...') mgr = NAppsManager() try: if args['all']: mgr.reload(None) else: napps = args['<napp>'] mgr.reload(napps) LOG.info('\tReloa...
[ "def", "reload", "(", "cls", ",", "args", ")", ":", "LOG", ".", "info", "(", "'Reloading NApps...'", ")", "mgr", "=", "NAppsManager", "(", ")", "try", ":", "if", "args", "[", "'all'", "]", ":", "mgr", ".", "reload", "(", "None", ")", "else", ":", ...
Reload NApps code.
[ "Reload", "NApps", "code", "." ]
python
train
akissa/spamc
examples/example1.py
https://github.com/akissa/spamc/blob/da50732e276f7ed3d67cb75c31cb017d6a62f066/examples/example1.py#L32-L109
def runit(): """run things""" parser = OptionParser() parser.add_option('-s', '--server', help='The spamassassin spamd server to connect to', dest='server', type='str', default='standalone.home.topdog-software.com') ...
[ "def", "runit", "(", ")", ":", "parser", "=", "OptionParser", "(", ")", "parser", ".", "add_option", "(", "'-s'", ",", "'--server'", ",", "help", "=", "'The spamassassin spamd server to connect to'", ",", "dest", "=", "'server'", ",", "type", "=", "'str'", "...
run things
[ "run", "things" ]
python
train
nilp0inter/cpe
cpe/cpelang2_3.py
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L172-L277
def language_match(self, cpeset, cpel_dom=None): """ Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applic...
[ "def", "language_match", "(", "self", ",", "cpeset", ",", "cpel_dom", "=", "None", ")", ":", "# Root element tag", "TAG_ROOT", "=", "'#document'", "# A container for child platform definitions", "TAG_PLATSPEC", "=", "'cpe:platform-specification'", "# Information about a platf...
Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applicability Language, represented as the XML infoset for the ...
[ "Accepts", "a", "set", "of", "known", "CPE", "Names", "and", "an", "expression", "in", "the", "CPE", "language", "and", "delivers", "the", "answer", "True", "if", "the", "expression", "matches", "with", "the", "set", ".", "Otherwise", "it", "returns", "Fal...
python
train
omtinez/pddb
pddb/pddb.py
https://github.com/omtinez/pddb/blob/a24cee0702c8286c5c466c51ca65cf8dbc2c183c/pddb/pddb.py#L142-L147
def get_table_schema(self, tname): ''' Returns a list of column names of the provided table name ''' tname = self._check_tname(tname, noload=True) if tname not in self._schemas: raise ValueError('Table "%s" not found in schema store' % tname) return list(self._schemas[tname])
[ "def", "get_table_schema", "(", "self", ",", "tname", ")", ":", "tname", "=", "self", ".", "_check_tname", "(", "tname", ",", "noload", "=", "True", ")", "if", "tname", "not", "in", "self", ".", "_schemas", ":", "raise", "ValueError", "(", "'Table \"%s\"...
Returns a list of column names of the provided table name
[ "Returns", "a", "list", "of", "column", "names", "of", "the", "provided", "table", "name" ]
python
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L233-L241
def autoscroll(self, autoscroll): """Autoscroll will 'right justify' text from the cursor if set True, otherwise it will 'left justify' the text. """ if autoscroll: self.displaymode |= LCD_ENTRYSHIFTINCREMENT else: self.displaymode &= ~LCD_ENTRYSHIFTINCREM...
[ "def", "autoscroll", "(", "self", ",", "autoscroll", ")", ":", "if", "autoscroll", ":", "self", ".", "displaymode", "|=", "LCD_ENTRYSHIFTINCREMENT", "else", ":", "self", ".", "displaymode", "&=", "~", "LCD_ENTRYSHIFTINCREMENT", "self", ".", "write8", "(", "LCD...
Autoscroll will 'right justify' text from the cursor if set True, otherwise it will 'left justify' the text.
[ "Autoscroll", "will", "right", "justify", "text", "from", "the", "cursor", "if", "set", "True", "otherwise", "it", "will", "left", "justify", "the", "text", "." ]
python
train
mattjj/pylds
pylds/util.py
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/util.py#L163-L196
def logdet_symm_block_tridiag(H_diag, H_upper_diag): """ compute the log determinant of a positive definite, symmetric block tridiag matrix. Use the Kalman info filter to do so. Specifically, the KF computes the normalizer: log Z = 1/2 h^T J^{-1} h -1/2 log |J| +n/2 log 2 \pi We set ...
[ "def", "logdet_symm_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_...
compute the log determinant of a positive definite, symmetric block tridiag matrix. Use the Kalman info filter to do so. Specifically, the KF computes the normalizer: log Z = 1/2 h^T J^{-1} h -1/2 log |J| +n/2 log 2 \pi We set h=0 to get -1/2 log |J| + n/2 log 2 \pi and from this we solv...
[ "compute", "the", "log", "determinant", "of", "a", "positive", "definite", "symmetric", "block", "tridiag", "matrix", ".", "Use", "the", "Kalman", "info", "filter", "to", "do", "so", ".", "Specifically", "the", "KF", "computes", "the", "normalizer", ":" ]
python
train
saulpw/visidata
visidata/canvas.py
https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/canvas.py#L417-L426
def qcurve(self, vertexes, attr=0, row=None): 'quadratic curve from vertexes[0] to vertexes[2] with control point at vertexes[1]' assert len(vertexes) == 3, len(vertexes) x1, y1 = vertexes[0] x2, y2 = vertexes[1] x3, y3 = vertexes[2] self.point(x1, y1, attr, row) ...
[ "def", "qcurve", "(", "self", ",", "vertexes", ",", "attr", "=", "0", ",", "row", "=", "None", ")", ":", "assert", "len", "(", "vertexes", ")", "==", "3", ",", "len", "(", "vertexes", ")", "x1", ",", "y1", "=", "vertexes", "[", "0", "]", "x2", ...
quadratic curve from vertexes[0] to vertexes[2] with control point at vertexes[1]
[ "quadratic", "curve", "from", "vertexes", "[", "0", "]", "to", "vertexes", "[", "2", "]", "with", "control", "point", "at", "vertexes", "[", "1", "]" ]
python
train
readbeyond/aeneas
aeneas/ttswrappers/basettswrapper.py
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ttswrappers/basettswrapper.py#L670-L767
def _synthesize_multiple_generic(self, helper_function, text_file, output_file_path, quit_after=None, backwards=False): """ Synthesize multiple fragments, generic function. The ``helper_function`` is a function that takes parameters ``(text, voice_code, output_file_path)`` and r...
[ "def", "_synthesize_multiple_generic", "(", "self", ",", "helper_function", ",", "text_file", ",", "output_file_path", ",", "quit_after", "=", "None", ",", "backwards", "=", "False", ")", ":", "self", ".", "log", "(", "u\"Calling TTS engine using multiple generic func...
Synthesize multiple fragments, generic function. The ``helper_function`` is a function that takes parameters ``(text, voice_code, output_file_path)`` and returns a tuple ``(result, (audio_length, audio_sample_rate, audio_format, audio_samples))``. :rtype: tuple (result, (anchor...
[ "Synthesize", "multiple", "fragments", "generic", "function", "." ]
python
train
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L353-L359
def select_row(self, steps): """Move selected row a number of steps. Iterates in a cyclic behaviour. """ row = (self.currentRow() + steps) % self.count() self.setCurrentRow(row)
[ "def", "select_row", "(", "self", ",", "steps", ")", ":", "row", "=", "(", "self", ".", "currentRow", "(", ")", "+", "steps", ")", "%", "self", ".", "count", "(", ")", "self", ".", "setCurrentRow", "(", "row", ")" ]
Move selected row a number of steps. Iterates in a cyclic behaviour.
[ "Move", "selected", "row", "a", "number", "of", "steps", ".", "Iterates", "in", "a", "cyclic", "behaviour", "." ]
python
train
vslutov/turingmarkov
turingmarkov/__main__.py
https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/__main__.py#L29-L35
def load_turing(argv, stdin): """Load and return turing machine.""" if len(argv) > 3: with open(argv[3]) as input_file: return build_machine(input_file.readlines()) else: return build_machine(stdin.readlines())
[ "def", "load_turing", "(", "argv", ",", "stdin", ")", ":", "if", "len", "(", "argv", ")", ">", "3", ":", "with", "open", "(", "argv", "[", "3", "]", ")", "as", "input_file", ":", "return", "build_machine", "(", "input_file", ".", "readlines", "(", ...
Load and return turing machine.
[ "Load", "and", "return", "turing", "machine", "." ]
python
train
pettarin/ipapy
ipapy/__init__.py
https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__init__.py#L26-L70
def split_using_dictionary(string, dictionary, max_key_length, single_char_parsing=False): """ Return a list of (non-empty) substrings of the given string, where each substring is either: 1. the longest string starting at the current index that is a key in the dictionary, or 2. a single ...
[ "def", "split_using_dictionary", "(", "string", ",", "dictionary", ",", "max_key_length", ",", "single_char_parsing", "=", "False", ")", ":", "def", "substring", "(", "string", ",", "i", ",", "j", ")", ":", "if", "isinstance", "(", "string", "[", "i", "]",...
Return a list of (non-empty) substrings of the given string, where each substring is either: 1. the longest string starting at the current index that is a key in the dictionary, or 2. a single character that is not a key in the dictionary. If ``single_char_parsing`` is ``False``, parse ...
[ "Return", "a", "list", "of", "(", "non", "-", "empty", ")", "substrings", "of", "the", "given", "string", "where", "each", "substring", "is", "either", ":", "1", ".", "the", "longest", "string", "starting", "at", "the", "current", "index", "that", "is", ...
python
train
ModisWorks/modis
modis/discord_modis/modules/music/api_music.py
https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/api_music.py#L48-L64
def build_sc_api(): """Build the SoundCloud API for future use""" data = datatools.get_data() if "soundcloud_client_id" not in data["discord"]["keys"]: logger.warning("No API key found with name 'soundcloud_client_id'") logger.info("Please add your SoundCloud client id with name 'soundcloud_...
[ "def", "build_sc_api", "(", ")", ":", "data", "=", "datatools", ".", "get_data", "(", ")", "if", "\"soundcloud_client_id\"", "not", "in", "data", "[", "\"discord\"", "]", "[", "\"keys\"", "]", ":", "logger", ".", "warning", "(", "\"No API key found with name '...
Build the SoundCloud API for future use
[ "Build", "the", "SoundCloud", "API", "for", "future", "use" ]
python
train
foutaise/texttable
texttable.py
https://github.com/foutaise/texttable/blob/8eea49c20458ec40478e2f26b4b260ad47550838/texttable.py#L686-L714
def _splitit(self, line, isheader): """Split each element of line to fit the column width Each element is turned into a list, result of the wrapping of the string to the desired width """ line_wrapped = [] for cell, width in zip(line, self._width): array = [...
[ "def", "_splitit", "(", "self", ",", "line", ",", "isheader", ")", ":", "line_wrapped", "=", "[", "]", "for", "cell", ",", "width", "in", "zip", "(", "line", ",", "self", ".", "_width", ")", ":", "array", "=", "[", "]", "for", "c", "in", "cell", ...
Split each element of line to fit the column width Each element is turned into a list, result of the wrapping of the string to the desired width
[ "Split", "each", "element", "of", "line", "to", "fit", "the", "column", "width" ]
python
train
PredixDev/predixpy
predix/admin/cf/services.py
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/services.py#L134-L142
def get_service_plan_for_service(self, service_name): """ Return the service plans available for a given service. """ services = self.get_services() for service in services['resources']: if service['entity']['label'] == service_name: response = self.ap...
[ "def", "get_service_plan_for_service", "(", "self", ",", "service_name", ")", ":", "services", "=", "self", ".", "get_services", "(", ")", "for", "service", "in", "services", "[", "'resources'", "]", ":", "if", "service", "[", "'entity'", "]", "[", "'label'"...
Return the service plans available for a given service.
[ "Return", "the", "service", "plans", "available", "for", "a", "given", "service", "." ]
python
train
tcalmant/ipopo
pelix/threadpool.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/threadpool.py#L402-L429
def enqueue(self, method, *args, **kwargs): """ Queues a task in the pool :param method: Method to call :return: A FutureResult object, to get the result of the task :raise ValueError: Invalid method :raise Full: The task queue is full """ if not hasattr(...
[ "def", "enqueue", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "method", ",", "\"__call__\"", ")", ":", "raise", "ValueError", "(", "\"{0} has no __call__ member.\"", ".", "format", "(", "m...
Queues a task in the pool :param method: Method to call :return: A FutureResult object, to get the result of the task :raise ValueError: Invalid method :raise Full: The task queue is full
[ "Queues", "a", "task", "in", "the", "pool" ]
python
train
saltstack/salt
salt/states/host.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/host.py#L206-L254
def only(name, hostnames): ''' Ensure that only the given hostnames are associated with the given IP address. .. versionadded:: 2016.3.0 name The IP address to associate with the given hostnames. hostnames Either a single hostname or a list of hostnames to associate wi...
[ "def", "only", "(", "name", ",", "hostnames", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "None", ",", "'comment'", ":", "''", "}", "if", "isinstance", "(", "hostnames", ",", "six", ".", ...
Ensure that only the given hostnames are associated with the given IP address. .. versionadded:: 2016.3.0 name The IP address to associate with the given hostnames. hostnames Either a single hostname or a list of hostnames to associate with the given IP address in the given or...
[ "Ensure", "that", "only", "the", "given", "hostnames", "are", "associated", "with", "the", "given", "IP", "address", "." ]
python
train
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAARP/QAAccount.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAARP/QAAccount.py#L558-L577
def start_date(self): """账户的起始交易日期(只在回测中使用) Raises: RuntimeWarning -- [description] Returns: [type] -- [description] """ if self.start_==None: if len(self.time_index_max) > 0: return str(min(self.time_index_max))[0:10] ...
[ "def", "start_date", "(", "self", ")", ":", "if", "self", ".", "start_", "==", "None", ":", "if", "len", "(", "self", ".", "time_index_max", ")", ">", "0", ":", "return", "str", "(", "min", "(", "self", ".", "time_index_max", ")", ")", "[", "0", ...
账户的起始交易日期(只在回测中使用) Raises: RuntimeWarning -- [description] Returns: [type] -- [description]
[ "账户的起始交易日期", "(", "只在回测中使用", ")" ]
python
train
saltstack/salt
salt/grains/core.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/core.py#L465-L485
def _osx_memdata(): ''' Return the memory information for BSD-like systems ''' grains = {'mem_total': 0, 'swap_total': 0} sysctl = salt.utils.path.which('sysctl') if sysctl: mem = __salt__['cmd.run']('{0} -n hw.memsize'.format(sysctl)) swap_total = __salt__['cmd.run']('{0} -n vm...
[ "def", "_osx_memdata", "(", ")", ":", "grains", "=", "{", "'mem_total'", ":", "0", ",", "'swap_total'", ":", "0", "}", "sysctl", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "'sysctl'", ")", "if", "sysctl", ":", "mem", "=", "__salt__", ...
Return the memory information for BSD-like systems
[ "Return", "the", "memory", "information", "for", "BSD", "-", "like", "systems" ]
python
train
openstack/monasca-common
monasca_common/kafka_lib/partitioner/hashed.py
https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/partitioner/hashed.py#L54-L122
def murmur2(key): """Pure-python Murmur2 implementation. Based on java client, see org.apache.kafka.common.utils.Utils.murmur2 Args: key: if not a bytes type, encoded using default encoding Returns: MurmurHash2 of key bytearray """ # Convert key to bytes or bytearray if isinstanc...
[ "def", "murmur2", "(", "key", ")", ":", "# Convert key to bytes or bytearray", "if", "isinstance", "(", "key", ",", "bytearray", ")", "or", "(", "six", ".", "PY3", "and", "isinstance", "(", "key", ",", "bytes", ")", ")", ":", "data", "=", "key", "else", ...
Pure-python Murmur2 implementation. Based on java client, see org.apache.kafka.common.utils.Utils.murmur2 Args: key: if not a bytes type, encoded using default encoding Returns: MurmurHash2 of key bytearray
[ "Pure", "-", "python", "Murmur2", "implementation", "." ]
python
train
crytic/slither
examples/scripts/possible_paths.py
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/examples/scripts/possible_paths.py#L65-L73
def all_function_definitions(function): """ Obtains a list of representing this function and any base definitions :param function: The function to obtain all definitions at and beneath. :return: Returns a list composed of the provided function definition and any base definitions. """ return [fun...
[ "def", "all_function_definitions", "(", "function", ")", ":", "return", "[", "function", "]", "+", "[", "f", "for", "c", "in", "function", ".", "contract", ".", "inheritance", "for", "f", "in", "c", ".", "functions_and_modifiers_not_inherited", "if", "f", "....
Obtains a list of representing this function and any base definitions :param function: The function to obtain all definitions at and beneath. :return: Returns a list composed of the provided function definition and any base definitions.
[ "Obtains", "a", "list", "of", "representing", "this", "function", "and", "any", "base", "definitions", ":", "param", "function", ":", "The", "function", "to", "obtain", "all", "definitions", "at", "and", "beneath", ".", ":", "return", ":", "Returns", "a", ...
python
train
yyuu/botornado
boto/dynamodb/layer2.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/dynamodb/layer2.py#L75-L89
def dynamize_attribute_updates(self, pending_updates): """ Convert a set of pending item updates into the structure required by Layer1. """ d = {} for attr_name in pending_updates: action, value = pending_updates[attr_name] if value is None: ...
[ "def", "dynamize_attribute_updates", "(", "self", ",", "pending_updates", ")", ":", "d", "=", "{", "}", "for", "attr_name", "in", "pending_updates", ":", "action", ",", "value", "=", "pending_updates", "[", "attr_name", "]", "if", "value", "is", "None", ":",...
Convert a set of pending item updates into the structure required by Layer1.
[ "Convert", "a", "set", "of", "pending", "item", "updates", "into", "the", "structure", "required", "by", "Layer1", "." ]
python
train
cs50/lib50
lib50/_api.py
https://github.com/cs50/lib50/blob/941767f6c0a3b81af0cdea48c25c8d5a761086eb/lib50/_api.py#L700-L710
def _prompt_username(prompt="Username: ", prefill=None): """Prompt the user for username.""" if prefill: readline.set_startup_hook(lambda: readline.insert_text(prefill)) try: return input(prompt).strip() except EOFError: print() finally: readline.set_startup_hook()
[ "def", "_prompt_username", "(", "prompt", "=", "\"Username: \"", ",", "prefill", "=", "None", ")", ":", "if", "prefill", ":", "readline", ".", "set_startup_hook", "(", "lambda", ":", "readline", ".", "insert_text", "(", "prefill", ")", ")", "try", ":", "re...
Prompt the user for username.
[ "Prompt", "the", "user", "for", "username", "." ]
python
train
sloria/sphinx-issues
sphinx_issues.py
https://github.com/sloria/sphinx-issues/blob/0a9597472645dc728c2aef12e0653aabfdb68ab2/sphinx_issues.py#L13-L43
def user_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Sphinx role for linking to a user profile. Defaults to linking to Github profiles, but the profile URIS can be configured via the ``issues_user_uri`` config value. Examples: :: :user:`sloria` Anchor text a...
[ "def", "user_role", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "None", ",", "content", "=", "None", ")", ":", "options", "=", "options", "or", "{", "}", "content", "=", "content", "or", "[", "]", "...
Sphinx role for linking to a user profile. Defaults to linking to Github profiles, but the profile URIS can be configured via the ``issues_user_uri`` config value. Examples: :: :user:`sloria` Anchor text also works: :: :user:`Steven Loria <sloria>`
[ "Sphinx", "role", "for", "linking", "to", "a", "user", "profile", ".", "Defaults", "to", "linking", "to", "Github", "profiles", "but", "the", "profile", "URIS", "can", "be", "configured", "via", "the", "issues_user_uri", "config", "value", "." ]
python
train
ray-project/ray
python/ray/tune/automl/genetic_searcher.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/genetic_searcher.py#L181-L220
def _crossover(candidate): """Perform crossover action to candidates. For example, new gene = 60% sample_1 + 40% sample_2. Args: candidate: List of candidate genes (encodings). Examples: >>> # Genes that represent 3 parameters >>> gene1 = np.array([...
[ "def", "_crossover", "(", "candidate", ")", ":", "sample_index1", "=", "np", ".", "random", ".", "choice", "(", "len", "(", "candidate", ")", ")", "sample_index2", "=", "np", ".", "random", ".", "choice", "(", "len", "(", "candidate", ")", ")", "sample...
Perform crossover action to candidates. For example, new gene = 60% sample_1 + 40% sample_2. Args: candidate: List of candidate genes (encodings). Examples: >>> # Genes that represent 3 parameters >>> gene1 = np.array([[0, 0, 1], [0, 1], [1, 0]]) ...
[ "Perform", "crossover", "action", "to", "candidates", "." ]
python
train
LISE-B26/pylabcontrol
build/lib/pylabcontrol/src/gui/qt_b26_gui.py
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_gui.py#L413-L452
def plot_clicked(self, mouse_event): """ gets activated when the user clicks on a plot Args: mouse_event: """ if isinstance(self.current_script, SelectPoints) and self.current_script.is_running: if (not (mouse_event.xdata == None)): if (mou...
[ "def", "plot_clicked", "(", "self", ",", "mouse_event", ")", ":", "if", "isinstance", "(", "self", ".", "current_script", ",", "SelectPoints", ")", "and", "self", ".", "current_script", ".", "is_running", ":", "if", "(", "not", "(", "mouse_event", ".", "xd...
gets activated when the user clicks on a plot Args: mouse_event:
[ "gets", "activated", "when", "the", "user", "clicks", "on", "a", "plot", "Args", ":", "mouse_event", ":" ]
python
train
deepmind/sonnet
sonnet/python/modules/relational_memory.py
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/relational_memory.py#L120-L161
def _multihead_attention(self, memory): """Perform multi-head attention from 'Attention is All You Need'. Implementation of the attention mechanism from https://arxiv.org/abs/1706.03762. Args: memory: Memory tensor to perform attention on. Returns: new_memory: New memory tensor. "...
[ "def", "_multihead_attention", "(", "self", ",", "memory", ")", ":", "key_size", "=", "self", ".", "_key_size", "value_size", "=", "self", ".", "_head_size", "qkv_size", "=", "2", "*", "key_size", "+", "value_size", "total_size", "=", "qkv_size", "*", "self"...
Perform multi-head attention from 'Attention is All You Need'. Implementation of the attention mechanism from https://arxiv.org/abs/1706.03762. Args: memory: Memory tensor to perform attention on. Returns: new_memory: New memory tensor.
[ "Perform", "multi", "-", "head", "attention", "from", "Attention", "is", "All", "You", "Need", "." ]
python
train
sorgerlab/indra
indra/belief/__init__.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L434-L462
def sample_statements(stmts, seed=None): """Return statements sampled according to belief. Statements are sampled independently according to their belief scores. For instance, a Staement with a belief score of 0.7 will end up in the returned Statement list with probability 0.7. Parameters ...
[ "def", "sample_statements", "(", "stmts", ",", "seed", "=", "None", ")", ":", "if", "seed", ":", "numpy", ".", "random", ".", "seed", "(", "seed", ")", "new_stmts", "=", "[", "]", "r", "=", "numpy", ".", "random", ".", "rand", "(", "len", "(", "s...
Return statements sampled according to belief. Statements are sampled independently according to their belief scores. For instance, a Staement with a belief score of 0.7 will end up in the returned Statement list with probability 0.7. Parameters ---------- stmts : list[indra.statements.Sta...
[ "Return", "statements", "sampled", "according", "to", "belief", "." ]
python
train
zhmcclient/python-zhmcclient
zhmcclient/_adapter.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_adapter.py#L321-L334
def port_uris_prop(self): """ :term:`string`: Name of adapter property that specifies the adapter port URIs, or the empty string ('') for adapters without ports. For example, 'network-port-uris' for a network adapter. """ if self._port_uris_prop is None: fami...
[ "def", "port_uris_prop", "(", "self", ")", ":", "if", "self", ".", "_port_uris_prop", "is", "None", ":", "family", "=", "self", ".", "get_property", "(", "'adapter-family'", ")", "try", ":", "self", ".", "_port_uris_prop", "=", "self", ".", "port_uris_prop_b...
:term:`string`: Name of adapter property that specifies the adapter port URIs, or the empty string ('') for adapters without ports. For example, 'network-port-uris' for a network adapter.
[ ":", "term", ":", "string", ":", "Name", "of", "adapter", "property", "that", "specifies", "the", "adapter", "port", "URIs", "or", "the", "empty", "string", "(", ")", "for", "adapters", "without", "ports", "." ]
python
train
erdewit/ib_insync
ib_insync/util.py
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/util.py#L171-L197
def formatSI(n) -> str: """ Format the integer or float n to 3 significant digits + SI prefix. """ s = '' if n < 0: n = -n s += '-' if type(n) is int and n < 1000: s = str(n) + ' ' elif n < 1e-22: s = '0.00 ' else: assert n < 9.99e26 log = ...
[ "def", "formatSI", "(", "n", ")", "->", "str", ":", "s", "=", "''", "if", "n", "<", "0", ":", "n", "=", "-", "n", "s", "+=", "'-'", "if", "type", "(", "n", ")", "is", "int", "and", "n", "<", "1000", ":", "s", "=", "str", "(", "n", ")", ...
Format the integer or float n to 3 significant digits + SI prefix.
[ "Format", "the", "integer", "or", "float", "n", "to", "3", "significant", "digits", "+", "SI", "prefix", "." ]
python
train