repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
Microsoft/LightGBM
python-package/lightgbm/basic.py
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1358-L1375
def set_group(self, group): """Set group size of Dataset (used for ranking). Parameters ---------- group : list, numpy 1-D array, pandas Series or None Group size of each group. Returns ------- self : Dataset Dataset with set group. ...
[ "def", "set_group", "(", "self", ",", "group", ")", ":", "self", ".", "group", "=", "group", "if", "self", ".", "handle", "is", "not", "None", "and", "group", "is", "not", "None", ":", "group", "=", "list_to_1d_numpy", "(", "group", ",", "np", ".", ...
Set group size of Dataset (used for ranking). Parameters ---------- group : list, numpy 1-D array, pandas Series or None Group size of each group. Returns ------- self : Dataset Dataset with set group.
[ "Set", "group", "size", "of", "Dataset", "(", "used", "for", "ranking", ")", "." ]
python
train
29.166667
berkerpeksag/astor
astor/source_repr.py
https://github.com/berkerpeksag/astor/blob/d9e893eb49d9eb2e30779680f90cd632c30e0ba1/astor/source_repr.py#L177-L210
def delimiter_groups(line, begin_delim=begin_delim, end_delim=end_delim): """Split a line into alternating groups. The first group cannot have a line feed inserted, the next one can, etc. """ text = [] line = iter(line) while True: # First build and yield a...
[ "def", "delimiter_groups", "(", "line", ",", "begin_delim", "=", "begin_delim", ",", "end_delim", "=", "end_delim", ")", ":", "text", "=", "[", "]", "line", "=", "iter", "(", "line", ")", "while", "True", ":", "# First build and yield an unsplittable group", "...
Split a line into alternating groups. The first group cannot have a line feed inserted, the next one can, etc.
[ "Split", "a", "line", "into", "alternating", "groups", ".", "The", "first", "group", "cannot", "have", "a", "line", "feed", "inserted", "the", "next", "one", "can", "etc", "." ]
python
train
27.470588
google/flatbuffers
python/flatbuffers/builder.py
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L156-L164
def StartObject(self, numfields): """StartObject initializes bookkeeping for writing a new object.""" self.assertNotNested() # use 32-bit offsets so that arithmetic doesn't overflow. self.current_vtable = [0 for _ in range_func(numfields)] self.objectEnd = self.Offset() ...
[ "def", "StartObject", "(", "self", ",", "numfields", ")", ":", "self", ".", "assertNotNested", "(", ")", "# use 32-bit offsets so that arithmetic doesn't overflow.", "self", ".", "current_vtable", "=", "[", "0", "for", "_", "in", "range_func", "(", "numfields", ")...
StartObject initializes bookkeeping for writing a new object.
[ "StartObject", "initializes", "bookkeeping", "for", "writing", "a", "new", "object", "." ]
python
train
36.777778
brocade/pynos
pynos/versions/base/yang/ietf_netconf.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/ietf_netconf.py#L313-L323
def copy_config_input_with_inactive(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") copy_config = ET.Element("copy_config") config = copy_config input = ET.SubElement(copy_config, "input") with_inactive = ET.SubElement(input, "with-inacti...
[ "def", "copy_config_input_with_inactive", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "copy_config", "=", "ET", ".", "Element", "(", "\"copy_config\"", ")", "config", "=", "copy_config", "input...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
41.454545
saltstack/salt
salt/modules/boto3_route53.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto3_route53.py#L287-L412
def create_hosted_zone(Name, VPCId=None, VPCName=None, VPCRegion=None, CallerReference=None, Comment='', PrivateZone=False, DelegationSetId=None, region=None, key=None, keyid=None, profile=None): ''' Create a new Route53 Hosted Zone. Returns a Python data structure ...
[ "def", "create_hosted_zone", "(", "Name", ",", "VPCId", "=", "None", ",", "VPCName", "=", "None", ",", "VPCRegion", "=", "None", ",", "CallerReference", "=", "None", ",", "Comment", "=", "''", ",", "PrivateZone", "=", "False", ",", "DelegationSetId", "=", ...
Create a new Route53 Hosted Zone. Returns a Python data structure with information about the newly created Hosted Zone. Name The name of the domain. This should be a fully-specified domain, and should terminate with a period. This is the name you have registered with your DNS registrar. It is a...
[ "Create", "a", "new", "Route53", "Hosted", "Zone", ".", "Returns", "a", "Python", "data", "structure", "with", "information", "about", "the", "newly", "created", "Hosted", "Zone", "." ]
python
train
41.079365
google/grumpy
third_party/stdlib/optparse.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/optparse.py#L1024-L1052
def add_option(self, *args, **kwargs): """add_option(Option) add_option(opt_str, ..., kwarg=val, ...) """ if type(args[0]) in types.StringTypes: option = self.option_class(*args, **kwargs) elif len(args) == 1 and not kwargs: option = args[0] ...
[ "def", "add_option", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "type", "(", "args", "[", "0", "]", ")", "in", "types", ".", "StringTypes", ":", "option", "=", "self", ".", "option_class", "(", "*", "args", ",", "*", ...
add_option(Option) add_option(opt_str, ..., kwarg=val, ...)
[ "add_option", "(", "Option", ")", "add_option", "(", "opt_str", "...", "kwarg", "=", "val", "...", ")" ]
python
valid
36.034483
ArchiveTeam/wpull
wpull/application/tasks/log.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/application/tasks/log.py#L86-L114
def _setup_file_logger(cls, session: AppSession, args): '''Set up the file message logger. A file log handler and with a formatter is added to the root logger. ''' if not (args.output_file or args.append_output): return logger = logging.getLogger() formatte...
[ "def", "_setup_file_logger", "(", "cls", ",", "session", ":", "AppSession", ",", "args", ")", ":", "if", "not", "(", "args", ".", "output_file", "or", "args", ".", "append_output", ")", ":", "return", "logger", "=", "logging", ".", "getLogger", "(", ")",...
Set up the file message logger. A file log handler and with a formatter is added to the root logger.
[ "Set", "up", "the", "file", "message", "logger", "." ]
python
train
30.62069
b3j0f/task
b3j0f/task/condition.py
https://github.com/b3j0f/task/blob/3e3e48633b1c9a52911c19df3a44fba4b744f60e/b3j0f/task/condition.py#L43-L84
def during(rrule, duration=None, timestamp=None, **kwargs): """ Check if input timestamp is in rrule+duration period :param rrule: rrule to check :type rrule: str or dict (freq, dtstart, interval, count, wkst, until, bymonth, byminute, etc.) :param dict duration: time duration from rrule st...
[ "def", "during", "(", "rrule", ",", "duration", "=", "None", ",", "timestamp", "=", "None", ",", "*", "*", "kwargs", ")", ":", "result", "=", "False", "# if rrule is a string expression", "if", "isinstance", "(", "rrule", ",", "string_types", ")", ":", "rr...
Check if input timestamp is in rrule+duration period :param rrule: rrule to check :type rrule: str or dict (freq, dtstart, interval, count, wkst, until, bymonth, byminute, etc.) :param dict duration: time duration from rrule step. Ex:{'minutes': 60} :param float timestamp: timestamp to check be...
[ "Check", "if", "input", "timestamp", "is", "in", "rrule", "+", "duration", "period" ]
python
train
27.928571
Alignak-monitoring/alignak
alignak/external_command.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L1925-L1936
def disable_contactgroup_svc_notifications(self, contactgroup): """Disable service notifications for a contactgroup Format of the line that triggers function call:: DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name> :param contactgroup: contactgroup to disable :type con...
[ "def", "disable_contactgroup_svc_notifications", "(", "self", ",", "contactgroup", ")", ":", "for", "contact_id", "in", "contactgroup", ".", "get_contacts", "(", ")", ":", "self", ".", "disable_contact_svc_notifications", "(", "self", ".", "daemon", ".", "contacts",...
Disable service notifications for a contactgroup Format of the line that triggers function call:: DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name> :param contactgroup: contactgroup to disable :type contactgroup: alignak.objects.contactgroup.Contactgroup :return: None
[ "Disable", "service", "notifications", "for", "a", "contactgroup", "Format", "of", "the", "line", "that", "triggers", "function", "call", "::" ]
python
train
44.583333
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L148-L157
def _fix_bias(op_name, attrs, num_inputs): """A workaround for 'use_bias' attribute since onnx don't provide this attribute, we have to check the number of inputs to decide it.""" if num_inputs == 3: attrs['no_bias'] = False elif num_inputs == 2: attrs['no_bias'] = True else: ...
[ "def", "_fix_bias", "(", "op_name", ",", "attrs", ",", "num_inputs", ")", ":", "if", "num_inputs", "==", "3", ":", "attrs", "[", "'no_bias'", "]", "=", "False", "elif", "num_inputs", "==", "2", ":", "attrs", "[", "'no_bias'", "]", "=", "True", "else", ...
A workaround for 'use_bias' attribute since onnx don't provide this attribute, we have to check the number of inputs to decide it.
[ "A", "workaround", "for", "use_bias", "attribute", "since", "onnx", "don", "t", "provide", "this", "attribute", "we", "have", "to", "check", "the", "number", "of", "inputs", "to", "decide", "it", "." ]
python
train
40
pyecore/pyecoregen
pyecoregen/ecore.py
https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L59-L71
def imported_classifiers_package(p: ecore.EPackage): """Determines which classifiers have to be imported into given package.""" classes = {c for c in p.eClassifiers if isinstance(c, ecore.EClass)} references = itertools.chain(*(c.eAllReferences() for c in classes)) references_types = (r...
[ "def", "imported_classifiers_package", "(", "p", ":", "ecore", ".", "EPackage", ")", ":", "classes", "=", "{", "c", "for", "c", "in", "p", ".", "eClassifiers", "if", "isinstance", "(", "c", ",", "ecore", ".", "EClass", ")", "}", "references", "=", "ite...
Determines which classifiers have to be imported into given package.
[ "Determines", "which", "classifiers", "have", "to", "be", "imported", "into", "given", "package", "." ]
python
train
45.923077
KelSolaar/Foundations
foundations/ui/common.py
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/ui/common.py#L42-L58
def center_widget_on_screen(widget, screen=None): """ Centers given Widget on the screen. :param widget: Current Widget. :type widget: QWidget :param screen: Screen used for centering. :type screen: int :return: Definition success. :rtype: bool """ screen = screen and screen or...
[ "def", "center_widget_on_screen", "(", "widget", ",", "screen", "=", "None", ")", ":", "screen", "=", "screen", "and", "screen", "or", "QApplication", ".", "desktop", "(", ")", ".", "primaryScreen", "(", ")", "desktop_width", "=", "QApplication", ".", "deskt...
Centers given Widget on the screen. :param widget: Current Widget. :type widget: QWidget :param screen: Screen used for centering. :type screen: int :return: Definition success. :rtype: bool
[ "Centers", "given", "Widget", "on", "the", "screen", "." ]
python
train
37
snare/scruffy
scruffy/file.py
https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L162-L189
def configure(self): """ Configure the Python logging module for this file. """ # build a file handler for this file handler = logging.FileHandler(self.path, delay=True) # if we got a format string, create a formatter with it if self._format: handler....
[ "def", "configure", "(", "self", ")", ":", "# build a file handler for this file", "handler", "=", "logging", ".", "FileHandler", "(", "self", ".", "path", ",", "delay", "=", "True", ")", "# if we got a format string, create a formatter with it", "if", "self", ".", ...
Configure the Python logging module for this file.
[ "Configure", "the", "Python", "logging", "module", "for", "this", "file", "." ]
python
test
45
Jaymon/endpoints
endpoints/http.py
https://github.com/Jaymon/endpoints/blob/2f1c4ae2c69a168e69447d3d8395ada7becaa5fb/endpoints/http.py#L562-L586
def base(self, *paths, **query_kwargs): """create a new url object using the current base path as a base if you had requested /foo/bar, then this would append *paths and **query_kwargs to /foo/bar :example: # current path: /foo/bar print url # http://host.com/f...
[ "def", "base", "(", "self", ",", "*", "paths", ",", "*", "*", "query_kwargs", ")", ":", "kwargs", "=", "self", ".", "_normalize_params", "(", "*", "paths", ",", "*", "*", "query_kwargs", ")", "if", "self", ".", "path", ":", "if", "\"path\"", "in", ...
create a new url object using the current base path as a base if you had requested /foo/bar, then this would append *paths and **query_kwargs to /foo/bar :example: # current path: /foo/bar print url # http://host.com/foo/bar print url.base() # http://host....
[ "create", "a", "new", "url", "object", "using", "the", "current", "base", "path", "as", "a", "base" ]
python
train
38.36
openshift/openshift-restclient-python
openshift/dynamic/client.py
https://github.com/openshift/openshift-restclient-python/blob/5d86bf5ba4e723bcc4d33ad47077aca01edca0f6/openshift/dynamic/client.py#L698-L733
def get_resources_for_api_version(self, prefix, group, version, preferred): """ returns a dictionary of resources associated with provided (prefix, group, version)""" resources = defaultdict(list) subresources = {} path = '/'.join(filter(None, [prefix, group, version])) resourc...
[ "def", "get_resources_for_api_version", "(", "self", ",", "prefix", ",", "group", ",", "version", ",", "preferred", ")", ":", "resources", "=", "defaultdict", "(", "list", ")", "subresources", "=", "{", "}", "path", "=", "'/'", ".", "join", "(", "filter", ...
returns a dictionary of resources associated with provided (prefix, group, version)
[ "returns", "a", "dictionary", "of", "resources", "associated", "with", "provided", "(", "prefix", "group", "version", ")" ]
python
train
44.166667
secdev/scapy
scapy/layers/lltd.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/lltd.py#L809-L836
def parse(self, plist): """Update the builder using the provided `plist`. `plist` can be either a Packet() or a PacketList(). """ if not isinstance(plist, PacketList): plist = PacketList(plist) for pkt in plist[LLTD]: if LLTDQueryLargeTlv in pkt: ...
[ "def", "parse", "(", "self", ",", "plist", ")", ":", "if", "not", "isinstance", "(", "plist", ",", "PacketList", ")", ":", "plist", "=", "PacketList", "(", "plist", ")", "for", "pkt", "in", "plist", "[", "LLTD", "]", ":", "if", "LLTDQueryLargeTlv", "...
Update the builder using the provided `plist`. `plist` can be either a Packet() or a PacketList().
[ "Update", "the", "builder", "using", "the", "provided", "plist", ".", "plist", "can", "be", "either", "a", "Packet", "()", "or", "a", "PacketList", "()", "." ]
python
train
47.178571
SKA-ScienceDataProcessor/integration-prototype
sip/execution_control/docker_api/sip_docker_swarm/docker_swarm_client.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/docker_api/sip_docker_swarm/docker_swarm_client.py#L668-L679
def _parse_logging(log_values: dict, service_config: dict): """Parse log key. Args: log_values (dict): logging configuration values service_config (dict): Service specification """ for log_key, log_value in log_values.items(): if 'driver' in log_key: ...
[ "def", "_parse_logging", "(", "log_values", ":", "dict", ",", "service_config", ":", "dict", ")", ":", "for", "log_key", ",", "log_value", "in", "log_values", ".", "items", "(", ")", ":", "if", "'driver'", "in", "log_key", ":", "service_config", "[", "'log...
Parse log key. Args: log_values (dict): logging configuration values service_config (dict): Service specification
[ "Parse", "log", "key", "." ]
python
train
38.916667
OCA/openupgradelib
openupgradelib/openupgrade_90.py
https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade_90.py#L16-L81
def convert_binary_field_to_attachment(env, field_spec): """This method converts the 8.0 binary fields to attachments like Odoo 9.0 makes with the new attachment=True attribute. It has to be called on post-migration script, as there's a call to get the res_name of the target model, which is not yet load...
[ "def", "convert_binary_field_to_attachment", "(", "env", ",", "field_spec", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "'OpenUpgrade'", ")", "attachment_model", "=", "env", "[", "'ir.attachment'", "]", "for", "model_name", "in", "field_spec", ":", ...
This method converts the 8.0 binary fields to attachments like Odoo 9.0 makes with the new attachment=True attribute. It has to be called on post-migration script, as there's a call to get the res_name of the target model, which is not yet loaded on pre-migration. You need to rename the involved column...
[ "This", "method", "converts", "the", "8", ".", "0", "binary", "fields", "to", "attachments", "like", "Odoo", "9", ".", "0", "makes", "with", "the", "new", "attachment", "=", "True", "attribute", ".", "It", "has", "to", "be", "called", "on", "post", "-"...
python
train
43.863636
Azure/azure-multiapi-storage-python
azure/multiapi/storage/v2015_04_05/file/fileservice.py
https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2015_04_05/file/fileservice.py#L1084-L1123
def _list_directories_and_files(self, share_name, directory_name=None, marker=None, max_results=None, timeout=None): ''' Returns a list of the directories and files under the specified share. :param str share_name: Name of existing share. ...
[ "def", "_list_directories_and_files", "(", "self", ",", "share_name", ",", "directory_name", "=", "None", ",", "marker", "=", "None", ",", "max_results", "=", "None", ",", "timeout", "=", "None", ")", ":", "_validate_not_none", "(", "'share_name'", ",", "share...
Returns a list of the directories and files under the specified share. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str marker: A string value that identifies the portion of the list t...
[ "Returns", "a", "list", "of", "the", "directories", "and", "files", "under", "the", "specified", "share", "." ]
python
train
46.825
ricequant/rqalpha
rqalpha/model/instrument.py
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L188-L198
def status(self): """ [str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市, ‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用) """ try: return self.__dict__["status"] except (KeyError, ValueError): raise AttributeError( ...
[ "def", "status", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "\"status\"", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "raise", "AttributeError", "(", "\"Instrument(order_book_id={}) has no attribute 'status' \"", "....
[str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市, ‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用)
[ "[", "str", "]", "合约状态。’Active’", "-", "正常上市", "‘Delisted’", "-", "终止上市", "‘TemporarySuspended’", "-", "暂停上市", "‘PreIPO’", "-", "发行配售期间", "‘FailIPO’", "-", "发行失败(股票专用)" ]
python
train
37.181818
markovmodel/PyEMMA
pyemma/coordinates/data/_base/datasource.py
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/data/_base/datasource.py#L519-L608
def write_to_csv(self, filename=None, extension='.dat', overwrite=False, stride=1, chunksize=None, **kw): """ write all data to csv with numpy.savetxt Parameters ---------- filename : str, optional filename string, which may contain placeholders {itraj} ...
[ "def", "write_to_csv", "(", "self", ",", "filename", "=", "None", ",", "extension", "=", "'.dat'", ",", "overwrite", "=", "False", ",", "stride", "=", "1", ",", "chunksize", "=", "None", ",", "*", "*", "kw", ")", ":", "import", "os", "if", "not", "...
write all data to csv with numpy.savetxt Parameters ---------- filename : str, optional filename string, which may contain placeholders {itraj} and {stride}: * itraj will be replaced by trajetory index * stride is stride argument of this method ...
[ "write", "all", "data", "to", "csv", "with", "numpy", ".", "savetxt" ]
python
train
40.933333
marshmallow-code/marshmallow
src/marshmallow/utils.py
https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L167-L178
def rfcformat(dt, localtime=False): """Return the RFC822-formatted representation of a datetime object. :param datetime dt: The datetime. :param bool localtime: If ``True``, return the date relative to the local timezone instead of UTC, displaying the proper offset, e.g. "Sun, 10 Nov 2013 0...
[ "def", "rfcformat", "(", "dt", ",", "localtime", "=", "False", ")", ":", "if", "not", "localtime", ":", "return", "formatdate", "(", "timegm", "(", "dt", ".", "utctimetuple", "(", ")", ")", ")", "else", ":", "return", "local_rfcformat", "(", "dt", ")" ...
Return the RFC822-formatted representation of a datetime object. :param datetime dt: The datetime. :param bool localtime: If ``True``, return the date relative to the local timezone instead of UTC, displaying the proper offset, e.g. "Sun, 10 Nov 2013 08:23:45 -0600"
[ "Return", "the", "RFC822", "-", "formatted", "representation", "of", "a", "datetime", "object", "." ]
python
train
37.583333
samuel-phan/mssh-copy-id
msshcopyid/utils.py
https://github.com/samuel-phan/mssh-copy-id/blob/59c50eabb74c4e0eeb729266df57c285e6661b0b/msshcopyid/utils.py#L42-L84
def parse_hosts(hosts, ssh_port=None, ssh_config=None): """ Parse a list of hosts (string) and return a list of `msshcopyid.Host` objects. The information about the host are taken in this order of priority: - host: - from the host (string) itself. - user: - from the host (string) i...
[ "def", "parse_hosts", "(", "hosts", ",", "ssh_port", "=", "None", ",", "ssh_config", "=", "None", ")", ":", "host_list", "=", "[", "]", "# list of Host objects", "current_user", "=", "getpass", ".", "getuser", "(", ")", "for", "host", "in", "hosts", ":", ...
Parse a list of hosts (string) and return a list of `msshcopyid.Host` objects. The information about the host are taken in this order of priority: - host: - from the host (string) itself. - user: - from the host (string) itself. - from the `paramiko.config.SSHConfig` object. ...
[ "Parse", "a", "list", "of", "hosts", "(", "string", ")", "and", "return", "a", "list", "of", "msshcopyid", ".", "Host", "objects", "." ]
python
train
32.72093
ToucanToco/toucan-data-sdk
toucan_data_sdk/utils/postprocess/text.py
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/text.py#L544-L575
def replace_pattern( df, column: str, *, pat: str, repl: str, new_column: str = None, case: bool = True, regex: bool = True ): """ Replace occurrences of pattern/regex in `column` with some other string See [pandas doc]( https://pandas.pyda...
[ "def", "replace_pattern", "(", "df", ",", "column", ":", "str", ",", "*", ",", "pat", ":", "str", ",", "repl", ":", "str", ",", "new_column", ":", "str", "=", "None", ",", "case", ":", "bool", "=", "True", ",", "regex", ":", "bool", "=", "True", ...
Replace occurrences of pattern/regex in `column` with some other string See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.replace.html) for more information --- ### Parameters *mandatory :* - `column` (*str*): the column - `pat` (*str*): charac...
[ "Replace", "occurrences", "of", "pattern", "/", "regex", "in", "column", "with", "some", "other", "string", "See", "[", "pandas", "doc", "]", "(", "https", ":", "//", "pandas", ".", "pydata", ".", "org", "/", "pandas", "-", "docs", "/", "stable", "/", ...
python
test
28.40625
geophysics-ubonn/reda
lib/reda/configs/configManager.py
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/configs/configManager.py#L675-L753
def gen_configs_permutate(self, injections_raw, only_same_dipole_length=False, ignore_crossed_dipoles=False, silent=False): """ Create measurement configurations out of a pool of current ...
[ "def", "gen_configs_permutate", "(", "self", ",", "injections_raw", ",", "only_same_dipole_length", "=", "False", ",", "ignore_crossed_dipoles", "=", "False", ",", "silent", "=", "False", ")", ":", "injections", "=", "np", ".", "atleast_2d", "(", "injections_raw",...
Create measurement configurations out of a pool of current injections. Use only the provided dipoles for potential dipole selection. This means that we have always reciprocal measurements. Remove quadpoles where electrodes are used both as current and voltage dipoles. Paramete...
[ "Create", "measurement", "configurations", "out", "of", "a", "pool", "of", "current", "injections", ".", "Use", "only", "the", "provided", "dipoles", "for", "potential", "dipole", "selection", ".", "This", "means", "that", "we", "have", "always", "reciprocal", ...
python
train
41.949367
xtuml/pyxtuml
bridgepoint/oal.py
https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/bridgepoint/oal.py#L1523-L1529
def p_unrelate_statement_using_1(self, p): '''statement : UNRELATE instance_name FROM instance_name ACROSS rel_id USING instance_name''' p[0] = UnrelateUsingNode(from_variable_name=p[2], to_variable_name=p[4], rel_id=p[6], ...
[ "def", "p_unrelate_statement_using_1", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "UnrelateUsingNode", "(", "from_variable_name", "=", "p", "[", "2", "]", ",", "to_variable_name", "=", "p", "[", "4", "]", ",", "rel_id", "=", "p", "[", ...
statement : UNRELATE instance_name FROM instance_name ACROSS rel_id USING instance_name
[ "statement", ":", "UNRELATE", "instance_name", "FROM", "instance_name", "ACROSS", "rel_id", "USING", "instance_name" ]
python
test
57.571429
475Cumulus/TBone
tbone/db/models.py
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/db/models.py#L245-L285
async def update(self, db=None, data=None): ''' Update the entire document by replacing its content with new data, retaining its primary key ''' db = db or self.db if data: # update model explicitely with a new data structure # merge the current model's data with the...
[ "async", "def", "update", "(", "self", ",", "db", "=", "None", ",", "data", "=", "None", ")", ":", "db", "=", "db", "or", "self", ".", "db", "if", "data", ":", "# update model explicitely with a new data structure", "# merge the current model's data with the new d...
Update the entire document by replacing its content with new data, retaining its primary key
[ "Update", "the", "entire", "document", "by", "replacing", "its", "content", "with", "new", "data", "retaining", "its", "primary", "key" ]
python
train
41.146341
wandb/client
wandb/apis/public.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/apis/public.py#L115-L141
def _parse_path(self, path): """Parses paths in the following formats: url: username/project/runs/run_id path: username/project/run_id docker: username/project:run_id username is optional and will fallback to the current logged in user. """ run = self.settings['...
[ "def", "_parse_path", "(", "self", ",", "path", ")", ":", "run", "=", "self", ".", "settings", "[", "'run'", "]", "project", "=", "self", ".", "settings", "[", "'project'", "]", "username", "=", "self", ".", "settings", "[", "'username'", "]", "parts",...
Parses paths in the following formats: url: username/project/runs/run_id path: username/project/run_id docker: username/project:run_id username is optional and will fallback to the current logged in user.
[ "Parses", "paths", "in", "the", "following", "formats", ":" ]
python
train
32.962963
apache/airflow
airflow/hooks/S3_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/S3_hook.py#L233-L277
def select_key(self, key, bucket_name=None, expression='SELECT * FROM S3Object', expression_type='SQL', input_serialization=None, output_serialization=None): """ Reads a key with S3 Select. :param key: S3 key that will ...
[ "def", "select_key", "(", "self", ",", "key", ",", "bucket_name", "=", "None", ",", "expression", "=", "'SELECT * FROM S3Object'", ",", "expression_type", "=", "'SQL'", ",", "input_serialization", "=", "None", ",", "output_serialization", "=", "None", ")", ":", ...
Reads a key with S3 Select. :param key: S3 key that will point to the file :type key: str :param bucket_name: Name of the bucket in which the file is stored :type bucket_name: str :param expression: S3 Select expression :type expression: str :param expression_typ...
[ "Reads", "a", "key", "with", "S3", "Select", "." ]
python
test
40.911111
csparpa/pyowm
pyowm/stationsapi30/station_parser.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/stationsapi30/station_parser.py#L34-L63
def parse_JSON(self, JSON_string): """ Parses a *pyowm.stationsapi30.station.Station* instance out of raw JSON data. :param JSON_string: a raw JSON string :type JSON_string: str :return: a *pyowm.stationsapi30.station.Station** instance or ``None`` if no data...
[ "def", "parse_JSON", "(", "self", ",", "JSON_string", ")", ":", "if", "JSON_string", "is", "None", ":", "raise", "parse_response_error", ".", "ParseResponseError", "(", "'JSON data is None'", ")", "d", "=", "json", ".", "loads", "(", "JSON_string", ")", "try",...
Parses a *pyowm.stationsapi30.station.Station* instance out of raw JSON data. :param JSON_string: a raw JSON string :type JSON_string: str :return: a *pyowm.stationsapi30.station.Station** instance or ``None`` if no data is available :raises: *ParseResponseError* if ...
[ "Parses", "a", "*", "pyowm", ".", "stationsapi30", ".", "station", ".", "Station", "*", "instance", "out", "of", "raw", "JSON", "data", "." ]
python
train
41.266667
midasplatform/pydas
pydas/api.py
https://github.com/midasplatform/pydas/blob/e5f9e96e754fb2dc5da187b05e4abc77a9b2affd/pydas/api.py#L331-L346
def _create_folder(local_folder, parent_folder_id): """ Function for creating a remote folder and returning the id. This should be a building block for user-level functions. :param local_folder: full path to a local folder :type local_folder: string :param parent_folder_id: id of parent folder ...
[ "def", "_create_folder", "(", "local_folder", ",", "parent_folder_id", ")", ":", "new_folder", "=", "session", ".", "communicator", ".", "create_folder", "(", "session", ".", "token", ",", "os", ".", "path", ".", "basename", "(", "local_folder", ")", ",", "p...
Function for creating a remote folder and returning the id. This should be a building block for user-level functions. :param local_folder: full path to a local folder :type local_folder: string :param parent_folder_id: id of parent folder on the Midas Server instance, where the new folder will ...
[ "Function", "for", "creating", "a", "remote", "folder", "and", "returning", "the", "id", ".", "This", "should", "be", "a", "building", "block", "for", "user", "-", "level", "functions", "." ]
python
valid
41.4375
ebroecker/canmatrix
src/canmatrix/formats/arxml.py
https://github.com/ebroecker/canmatrix/blob/d6150b7a648350f051a11c431e9628308c8d5593/src/canmatrix/formats/arxml.py#L942-L1171
def get_signals(signal_array, frame, root_or_cache, ns, multiplex_id, float_factory): # type: (typing.Sequence[_Element], canmatrix.Frame, _DocRoot, str, _MultiplexId, typing.Callable) -> None """Add signals from xml to the Frame.""" global signal_rxs group_id = 1 if signal_array is None: # Empty s...
[ "def", "get_signals", "(", "signal_array", ",", "frame", ",", "root_or_cache", ",", "ns", ",", "multiplex_id", ",", "float_factory", ")", ":", "# type: (typing.Sequence[_Element], canmatrix.Frame, _DocRoot, str, _MultiplexId, typing.Callable) -> None", "global", "signal_rxs", "...
Add signals from xml to the Frame.
[ "Add", "signals", "from", "xml", "to", "the", "Frame", "." ]
python
train
46.004348
poppy-project/pypot
pypot/vrep/remoteApiBindings/vrep.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L169-L174
def simxSetJointPosition(clientID, jointHandle, position, operationMode): ''' Please have a look at the function description/documentation in the V-REP user manual ''' return c_SetJointPosition(clientID, jointHandle, position, operationMode)
[ "def", "simxSetJointPosition", "(", "clientID", ",", "jointHandle", ",", "position", ",", "operationMode", ")", ":", "return", "c_SetJointPosition", "(", "clientID", ",", "jointHandle", ",", "position", ",", "operationMode", ")" ]
Please have a look at the function description/documentation in the V-REP user manual
[ "Please", "have", "a", "look", "at", "the", "function", "description", "/", "documentation", "in", "the", "V", "-", "REP", "user", "manual" ]
python
train
42.166667
pyvisa/pyvisa
pyvisa/resources/resource.py
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L281-L291
def install_handler(self, event_type, handler, user_handle=None): """Installs handlers for event callbacks in this resource. :param event_type: Logical event identifier. :param handler: Interpreted as a valid reference to a handler to be installed by a client application. :param user_ha...
[ "def", "install_handler", "(", "self", ",", "event_type", ",", "handler", ",", "user_handle", "=", "None", ")", ":", "return", "self", ".", "visalib", ".", "install_visa_handler", "(", "self", ".", "session", ",", "event_type", ",", "handler", ",", "user_han...
Installs handlers for event callbacks in this resource. :param event_type: Logical event identifier. :param handler: Interpreted as a valid reference to a handler to be installed by a client application. :param user_handle: A value specified by an application that can be used for identifying ha...
[ "Installs", "handlers", "for", "event", "callbacks", "in", "this", "resource", "." ]
python
train
55.181818
peri-source/peri
peri/comp/exactpsf.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/comp/exactpsf.py#L344-L363
def characterize_psf(self): """ Get support size and drift polynomial for current set of params """ # there may be an issue with the support and characterization-- # it might be best to do the characterization with the same support # as the calculated psf. l,u = max(self.zrange[0...
[ "def", "characterize_psf", "(", "self", ")", ":", "# there may be an issue with the support and characterization--", "# it might be best to do the characterization with the same support", "# as the calculated psf.", "l", ",", "u", "=", "max", "(", "self", ".", "zrange", "[", "0...
Get support size and drift polynomial for current set of params
[ "Get", "support", "size", "and", "drift", "polynomial", "for", "current", "set", "of", "params" ]
python
valid
51.35
kbr/fritzconnection
fritzconnection/fritzmonitor.py
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzmonitor.py#L58-L70
def set_fraction(self, value): """Set the meter indicator. Value should be between 0 and 1.""" if value < 0: value *= -1 value = min(value, 1) if self.horizontal: width = int(self.width * value) height = self.height else: width = se...
[ "def", "set_fraction", "(", "self", ",", "value", ")", ":", "if", "value", "<", "0", ":", "value", "*=", "-", "1", "value", "=", "min", "(", "value", ",", "1", ")", "if", "self", ".", "horizontal", ":", "width", "=", "int", "(", "self", ".", "w...
Set the meter indicator. Value should be between 0 and 1.
[ "Set", "the", "meter", "indicator", ".", "Value", "should", "be", "between", "0", "and", "1", "." ]
python
train
37.615385
deepmind/pysc2
pysc2/lib/renderer_human.py
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L172-L186
def write_screen(self, font, color, screen_pos, text, align="left", valign="top"): """Write to the screen in font.size relative coordinates.""" pos = point.Point(*screen_pos) * point.Point(0.75, 1) * font.get_linesize() text_surf = font.render(str(text), True, color) rect = text_surf....
[ "def", "write_screen", "(", "self", ",", "font", ",", "color", ",", "screen_pos", ",", "text", ",", "align", "=", "\"left\"", ",", "valign", "=", "\"top\"", ")", ":", "pos", "=", "point", ".", "Point", "(", "*", "screen_pos", ")", "*", "point", ".", ...
Write to the screen in font.size relative coordinates.
[ "Write", "to", "the", "screen", "in", "font", ".", "size", "relative", "coordinates", "." ]
python
train
39.8
ttu/ruuvitag-sensor
ruuvitag_sensor/ruuvi.py
https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvi.py#L115-L130
def get_datas(callback, macs=[], run_flag=RunFlag(), bt_device=''): """ Get data for all ruuvitag sensors or sensors in the MAC's list. Args: callback (func): callback funcion to be called when new data is received macs (list): MAC addresses run_flag (object)...
[ "def", "get_datas", "(", "callback", ",", "macs", "=", "[", "]", ",", "run_flag", "=", "RunFlag", "(", ")", ",", "bt_device", "=", "''", ")", ":", "log", ".", "info", "(", "'Get latest data for sensors. Stop with Ctrl+C.'", ")", "log", ".", "info", "(", ...
Get data for all ruuvitag sensors or sensors in the MAC's list. Args: callback (func): callback funcion to be called when new data is received macs (list): MAC addresses run_flag (object): RunFlag object. Function executes while run_flag.running bt_device (string...
[ "Get", "data", "for", "all", "ruuvitag", "sensors", "or", "sensors", "in", "the", "MAC", "s", "list", "." ]
python
train
40.9375
lacava/DistanceClassifier
DistanceClassifier/DistanceClassifier.py
https://github.com/lacava/DistanceClassifier/blob/cbb8a38a82b453c5821d2a2c3328b581f62e47bc/DistanceClassifier/DistanceClassifier.py#L165-L170
def is_invertible(self,X): """checks if Z is invertible""" if len(X.shape) == 2: return X.shape[0] == X.shape[1] and np.linalg.matrix_rank(X) == X.shape[0] else: return False
[ "def", "is_invertible", "(", "self", ",", "X", ")", ":", "if", "len", "(", "X", ".", "shape", ")", "==", "2", ":", "return", "X", ".", "shape", "[", "0", "]", "==", "X", ".", "shape", "[", "1", "]", "and", "np", ".", "linalg", ".", "matrix_ra...
checks if Z is invertible
[ "checks", "if", "Z", "is", "invertible" ]
python
train
36.166667
jaraco/irc
irc/server.py
https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L381-L399
def handle_part(self, params): """ Handle a client parting from channel(s). """ for pchannel in params.split(','): if pchannel.strip() in self.server.channels: # Send message to all clients in all channels user is in, and # remove the user from...
[ "def", "handle_part", "(", "self", ",", "params", ")", ":", "for", "pchannel", "in", "params", ".", "split", "(", "','", ")", ":", "if", "pchannel", ".", "strip", "(", ")", "in", "self", ".", "server", ".", "channels", ":", "# Send message to all clients...
Handle a client parting from channel(s).
[ "Handle", "a", "client", "parting", "from", "channel", "(", "s", ")", "." ]
python
train
46
niemasd/TreeSwift
treeswift/Tree.py
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L591-L605
def labels(self, leaves=True, internal=True): '''Generator over the (non-``None``) ``Node`` labels of this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False`` ...
[ "def", "labels", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "if", "not", "isinstance", "(", "leaves", ",", "bool", ")", ":", "raise", "TypeError", "(", "\"leaves must be a bool\"", ")", "if", "not", "isinstance", "("...
Generator over the (non-``None``) ``Node`` labels of this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
[ "Generator", "over", "the", "(", "non", "-", "None", ")", "Node", "labels", "of", "this", "Tree" ]
python
train
46.266667
DataBiosphere/toil
src/toil/fileStore.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/fileStore.py#L130-L140
def getLocalTempDir(self): """ Get a new local temporary directory in which to write files that persist for the duration of the job. :return: The absolute path to a new local temporary directory. This directory will exist for the duration of the job only, and is guarant...
[ "def", "getLocalTempDir", "(", "self", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "\"t\"", ",", "dir", "=", "self", ".", "localTempDir", ")", ")" ]
Get a new local temporary directory in which to write files that persist for the duration of the job. :return: The absolute path to a new local temporary directory. This directory will exist for the duration of the job only, and is guaranteed to be deleted once the job ...
[ "Get", "a", "new", "local", "temporary", "directory", "in", "which", "to", "write", "files", "that", "persist", "for", "the", "duration", "of", "the", "job", "." ]
python
train
48.090909
quora/qcore
qcore/inspection.py
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/inspection.py#L215-L222
def get_subclass_tree(cls, ensure_unique=True): """Returns all subclasses (direct and recursive) of cls.""" subclasses = [] # cls.__subclasses__() fails on classes inheriting from type for subcls in type.__subclasses__(cls): subclasses.append(subcls) subclasses.extend(get_subclass_tree(s...
[ "def", "get_subclass_tree", "(", "cls", ",", "ensure_unique", "=", "True", ")", ":", "subclasses", "=", "[", "]", "# cls.__subclasses__() fails on classes inheriting from type", "for", "subcls", "in", "type", ".", "__subclasses__", "(", "cls", ")", ":", "subclasses"...
Returns all subclasses (direct and recursive) of cls.
[ "Returns", "all", "subclasses", "(", "direct", "and", "recursive", ")", "of", "cls", "." ]
python
train
50.125
PedalPi/PluginsManager
pluginsmanager/util/restriction_list.py
https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/util/restriction_list.py#L68-L73
def remove(self, item): """ See :meth:`~pluginsmanager.observer.observable_list.ObservableList.remove()` method """ self.real_list.remove(item) self._items.remove(item)
[ "def", "remove", "(", "self", ",", "item", ")", ":", "self", ".", "real_list", ".", "remove", "(", "item", ")", "self", ".", "_items", ".", "remove", "(", "item", ")" ]
See :meth:`~pluginsmanager.observer.observable_list.ObservableList.remove()` method
[ "See", ":", "meth", ":", "~pluginsmanager", ".", "observer", ".", "observable_list", ".", "ObservableList", ".", "remove", "()", "method" ]
python
train
33.833333
Gbps/fastlog
fastlog/term.py
https://github.com/Gbps/fastlog/blob/8edb2327d72191510302c4654ffaa1691fe31277/fastlog/term.py#L117-L131
def typeseq(types): """ Returns an escape for a terminal text formatting type, or a list of types. Valid types are: * 'i' for 'italic' * 'b' for 'bold' * 'u' for 'underline' * 'r' for 'reverse' """ ret = "" for t in types: ret += termcap.get(fmttypes[t]) ...
[ "def", "typeseq", "(", "types", ")", ":", "ret", "=", "\"\"", "for", "t", "in", "types", ":", "ret", "+=", "termcap", ".", "get", "(", "fmttypes", "[", "t", "]", ")", "return", "ret" ]
Returns an escape for a terminal text formatting type, or a list of types. Valid types are: * 'i' for 'italic' * 'b' for 'bold' * 'u' for 'underline' * 'r' for 'reverse'
[ "Returns", "an", "escape", "for", "a", "terminal", "text", "formatting", "type", "or", "a", "list", "of", "types", "." ]
python
train
21.666667
pydata/xarray
xarray/core/combine.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/combine.py#L215-L316
def _dataset_concat(datasets, dim, data_vars, coords, compat, positions): """ Concatenate a sequence of datasets along a new or existing dimension """ from .dataset import Dataset if compat not in ['equals', 'identical']: raise ValueError("compat=%r invalid: must be 'equals' " ...
[ "def", "_dataset_concat", "(", "datasets", ",", "dim", ",", "data_vars", ",", "coords", ",", "compat", ",", "positions", ")", ":", "from", ".", "dataset", "import", "Dataset", "if", "compat", "not", "in", "[", "'equals'", ",", "'identical'", "]", ":", "r...
Concatenate a sequence of datasets along a new or existing dimension
[ "Concatenate", "a", "sequence", "of", "datasets", "along", "a", "new", "or", "existing", "dimension" ]
python
train
41.45098
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L259-L274
def make_set(value): ''' Takes a value and turns it into a set !!!! This is important because set(string) will parse a string to individual characters vs. adding the string as an element of the set i.e. x = 'setvalue' set(x) = {'t', 'a', 'e', 'v', 'u', 's', 'l'} make_set(x) = {'...
[ "def", "make_set", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "set", "(", "value", ")", "elif", "not", "isinstance", "(", "value", ",", "set", ")", ":", "value", "=", "set", "(", "[", "value", "...
Takes a value and turns it into a set !!!! This is important because set(string) will parse a string to individual characters vs. adding the string as an element of the set i.e. x = 'setvalue' set(x) = {'t', 'a', 'e', 'v', 'u', 's', 'l'} make_set(x) = {'setvalue'} or use set...
[ "Takes", "a", "value", "and", "turns", "it", "into", "a", "set" ]
python
train
33.1875
hyperledger/indy-plenum
plenum/server/replica.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L2577-L2587
def _request_pre_prepare(self, three_pc_key: Tuple[int, int], stash_data: Optional[Tuple[str, str, str]] = None) -> bool: """ Request preprepare """ recipients = self.primaryName return self._request_three_phase_msg(three_pc_key, ...
[ "def", "_request_pre_prepare", "(", "self", ",", "three_pc_key", ":", "Tuple", "[", "int", ",", "int", "]", ",", "stash_data", ":", "Optional", "[", "Tuple", "[", "str", ",", "str", ",", "str", "]", "]", "=", "None", ")", "->", "bool", ":", "recipien...
Request preprepare
[ "Request", "preprepare" ]
python
train
48.454545
razorpay/razorpay-python
razorpay/utility/utility.py
https://github.com/razorpay/razorpay-python/blob/5bc63fd8452165a4b54556888492e555222c8afe/razorpay/utility/utility.py#L50-L63
def compare_string(self, expected_str, actual_str): """ Returns True if the two strings are equal, False otherwise The time taken is independent of the number of characters that match For the sake of simplicity, this function executes in constant time only when the two strings ha...
[ "def", "compare_string", "(", "self", ",", "expected_str", ",", "actual_str", ")", ":", "if", "len", "(", "expected_str", ")", "!=", "len", "(", "actual_str", ")", ":", "return", "False", "result", "=", "0", "for", "x", ",", "y", "in", "zip", "(", "e...
Returns True if the two strings are equal, False otherwise The time taken is independent of the number of characters that match For the sake of simplicity, this function executes in constant time only when the two strings have the same length. It short-circuits when they have different l...
[ "Returns", "True", "if", "the", "two", "strings", "are", "equal", "False", "otherwise", "The", "time", "taken", "is", "independent", "of", "the", "number", "of", "characters", "that", "match", "For", "the", "sake", "of", "simplicity", "this", "function", "ex...
python
train
43.285714
MSchnei/pyprf_feature
pyprf_feature/simulation/pRF_functions.py
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L359-L485
def funcNrlTcMotPred(idxPrc, varPixX, varPixY, NrlMdlChunk, varNumTP, aryBoxCar, # aryCond path, varNumNrlMdls, varNumMtDrctn, var...
[ "def", "funcNrlTcMotPred", "(", "idxPrc", ",", "varPixX", ",", "varPixY", ",", "NrlMdlChunk", ",", "varNumTP", ",", "aryBoxCar", ",", "# aryCond", "path", ",", "varNumNrlMdls", ",", "varNumMtDrctn", ",", "varPar", ",", "queOut", ")", ":", "# # if hd5 method i...
Function for creating neural time course models. This function should be used to create neural models if different predictors for every motion direction are included.
[ "Function", "for", "creating", "neural", "time", "course", "models", ".", "This", "function", "should", "be", "used", "to", "create", "neural", "models", "if", "different", "predictors", "for", "every", "motion", "direction", "are", "included", "." ]
python
train
36.307087
gregoil/ipdbugger
ipdbugger/__init__.py
https://github.com/gregoil/ipdbugger/blob/9575734ec26f6be86ae263496d50eb60bb988b21/ipdbugger/__init__.py#L134-L175
def wrap_with_try(self, node): """Wrap an ast node in a 'try' node to enter debug on exception.""" handlers = [] if self.ignore_exceptions is None: handlers.append(ast.ExceptHandler(type=None, name=None, ...
[ "def", "wrap_with_try", "(", "self", ",", "node", ")", ":", "handlers", "=", "[", "]", "if", "self", ".", "ignore_exceptions", "is", "None", ":", "handlers", ".", "append", "(", "ast", ".", "ExceptHandler", "(", "type", "=", "None", ",", "name", "=", ...
Wrap an ast node in a 'try' node to enter debug on exception.
[ "Wrap", "an", "ast", "node", "in", "a", "try", "node", "to", "enter", "debug", "on", "exception", "." ]
python
train
43.619048
mdsol/rwslib
rwslib/builders/metadata.py
https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/builders/metadata.py#L1408-L1412
def build(self, builder): """Build XML by appending to builder""" builder.start("CheckValue", {}) builder.data(str(self.value)) builder.end("CheckValue")
[ "def", "build", "(", "self", ",", "builder", ")", ":", "builder", ".", "start", "(", "\"CheckValue\"", ",", "{", "}", ")", "builder", ".", "data", "(", "str", "(", "self", ".", "value", ")", ")", "builder", ".", "end", "(", "\"CheckValue\"", ")" ]
Build XML by appending to builder
[ "Build", "XML", "by", "appending", "to", "builder" ]
python
train
36.2
bwohlberg/sporco
sporco/cupy/__init__.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cupy/__init__.py#L254-L257
def _inner(x, y, axis=-1): """Patched version of :func:`sporco.linalg.inner`.""" return cp.sum(x * y, axis=axis, keepdims=True)
[ "def", "_inner", "(", "x", ",", "y", ",", "axis", "=", "-", "1", ")", ":", "return", "cp", ".", "sum", "(", "x", "*", "y", ",", "axis", "=", "axis", ",", "keepdims", "=", "True", ")" ]
Patched version of :func:`sporco.linalg.inner`.
[ "Patched", "version", "of", ":", "func", ":", "sporco", ".", "linalg", ".", "inner", "." ]
python
train
33.25
learningequality/ricecooker
examples/sample_program.py
https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/examples/sample_program.py#L306-L314
def construct_channel(self, *args, **kwargs): """ Create ChannelNode and build topic tree. """ channel = self.get_channel(*args, **kwargs) # creates ChannelNode from data in self.channel_info _build_tree(channel, SAMPLE_TREE) raise_for_invalid_channel(channel) ...
[ "def", "construct_channel", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "channel", "=", "self", ".", "get_channel", "(", "*", "args", ",", "*", "*", "kwargs", ")", "# creates ChannelNode from data in self.channel_info", "_build_tree", "("...
Create ChannelNode and build topic tree.
[ "Create", "ChannelNode", "and", "build", "topic", "tree", "." ]
python
train
36.222222
openwisp/netdiff
netdiff/parsers/batman.py
https://github.com/openwisp/netdiff/blob/f7fda2ed78ad815b8c56eae27dfd193172fb23f5/netdiff/parsers/batman.py#L108-L118
def _parse_txtinfo(self, data): """ Converts the python list returned by self._txtinfo_to_python() to a NetworkX Graph object, which is then returned. """ graph = self._init_graph() for link in data: graph.add_edge(link['source'], li...
[ "def", "_parse_txtinfo", "(", "self", ",", "data", ")", ":", "graph", "=", "self", ".", "_init_graph", "(", ")", "for", "link", "in", "data", ":", "graph", ".", "add_edge", "(", "link", "[", "'source'", "]", ",", "link", "[", "'target'", "]", ",", ...
Converts the python list returned by self._txtinfo_to_python() to a NetworkX Graph object, which is then returned.
[ "Converts", "the", "python", "list", "returned", "by", "self", ".", "_txtinfo_to_python", "()", "to", "a", "NetworkX", "Graph", "object", "which", "is", "then", "returned", "." ]
python
train
35.636364
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L10593-L10617
def set_position_target_local_ned_send(self, time_boot_ms, target_system, target_component, coordinate_frame, type_mask, x, y, z, vx, vy, vz, afx, afy, afz, yaw, yaw_rate, force_mavlink1=False): ''' Sets a desired vehicle position in a local north-east-down coordinate fra...
[ "def", "set_position_target_local_ned_send", "(", "self", ",", "time_boot_ms", ",", "target_system", ",", "target_component", ",", "coordinate_frame", ",", "type_mask", ",", "x", ",", "y", ",", "z", ",", "vx", ",", "vy", ",", "vz", ",", "afx", ",", "afy", ...
Sets a desired vehicle position in a local north-east-down coordinate frame. Used by an external controller to command the vehicle (manual controller or other system). time_boot_ms : Timestamp in milliseconds since system boot (uint32_t) targ...
[ "Sets", "a", "desired", "vehicle", "position", "in", "a", "local", "north", "-", "east", "-", "down", "coordinate", "frame", ".", "Used", "by", "an", "external", "controller", "to", "command", "the", "vehicle", "(", "manual", "controller", "or", "other", "...
python
train
108.52
non-Jedi/gyr
gyr/matrix_objects.py
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/matrix_objects.py#L49-L55
def user(self): """Creates a User object when requested.""" try: return self._user except AttributeError: self._user = MatrixUser(self.mxid, self.Api(identity=self.mxid)) return self._user
[ "def", "user", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_user", "except", "AttributeError", ":", "self", ".", "_user", "=", "MatrixUser", "(", "self", ".", "mxid", ",", "self", ".", "Api", "(", "identity", "=", "self", ".", "mxid", ...
Creates a User object when requested.
[ "Creates", "a", "User", "object", "when", "requested", "." ]
python
train
34.571429
zeromake/aiko
aiko/request.py
https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/request.py#L321-L326
def set(self, name: str, value: str) -> None: """ 重写请求中的 header, 不推荐使用 """ name = name.casefold() self._headers[name] = value
[ "def", "set", "(", "self", ",", "name", ":", "str", ",", "value", ":", "str", ")", "->", "None", ":", "name", "=", "name", ".", "casefold", "(", ")", "self", ".", "_headers", "[", "name", "]", "=", "value" ]
重写请求中的 header, 不推荐使用
[ "重写请求中的", "header", "不推荐使用" ]
python
train
26.666667
numenta/nupic
src/nupic/regions/tm_region.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/tm_region.py#L65-L114
def _buildArgs(f, self=None, kwargs={}): """ Get the default arguments from the function and assign as instance vars. Return a list of 3-tuples with (name, description, defaultValue) for each argument to the function. Assigns all arguments to the function as instance variables of TMRegion. If the argume...
[ "def", "_buildArgs", "(", "f", ",", "self", "=", "None", ",", "kwargs", "=", "{", "}", ")", ":", "# Get the name, description, and default value for each argument", "argTuples", "=", "getArgumentDescriptions", "(", "f", ")", "argTuples", "=", "argTuples", "[", "1"...
Get the default arguments from the function and assign as instance vars. Return a list of 3-tuples with (name, description, defaultValue) for each argument to the function. Assigns all arguments to the function as instance variables of TMRegion. If the argument was not provided, uses the default value. P...
[ "Get", "the", "default", "arguments", "from", "the", "function", "and", "assign", "as", "instance", "vars", "." ]
python
valid
36.84
TorkamaniLab/metapipe
metapipe/models/pbs_job.py
https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/pbs_job.py#L60-L80
def _grep_qstat(self, status_type='complete'): """ Greps qstat -e <job_id> for information from the queue. :paramsstatus_type: complete, queued, running, error, gone """ args = "qstat -e {}".format(self.id).split() res, _ = call(args) if res == '': return False re...
[ "def", "_grep_qstat", "(", "self", ",", "status_type", "=", "'complete'", ")", ":", "args", "=", "\"qstat -e {}\"", ".", "format", "(", "self", ".", "id", ")", ".", "split", "(", ")", "res", ",", "_", "=", "call", "(", "args", ")", "if", "res", "==...
Greps qstat -e <job_id> for information from the queue. :paramsstatus_type: complete, queued, running, error, gone
[ "Greps", "qstat", "-", "e", "<job_id", ">", "for", "information", "from", "the", "queue", ".", ":", "paramsstatus_type", ":", "complete", "queued", "running", "error", "gone" ]
python
train
38
dereneaton/ipyrad
ipyrad/plotting/baba_panel_plot.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/plotting/baba_panel_plot.py#L26-L66
def baba_panel_plot( ttree, tests, boots, show_tip_labels=True, show_test_labels=True, use_edge_lengths=False, collapse_outgroup=False, pct_tree_x=0.4, pct_tree_y=0.2, alpha=3.0, *args, **kwargs): """ signature... """ ## create Panel plot object an...
[ "def", "baba_panel_plot", "(", "ttree", ",", "tests", ",", "boots", ",", "show_tip_labels", "=", "True", ",", "show_test_labels", "=", "True", ",", "use_edge_lengths", "=", "False", ",", "collapse_outgroup", "=", "False", ",", "pct_tree_x", "=", "0.4", ",", ...
signature...
[ "signature", "..." ]
python
valid
29.390244
RockFeng0/rtsf-web
webuidriver/actions.py
https://github.com/RockFeng0/rtsf-web/blob/ceabcf62ddf1c969a97b5c7a4a4c547198b6ea71/webuidriver/actions.py#L199-L218
def _element(cls): ''' find the element with controls ''' if not cls.__is_selector(): raise Exception("Invalid selector[%s]." %cls.__control["by"]) driver = Web.driver try: elements = WebDriverWait(driver, cls.__control["timeout"]).un...
[ "def", "_element", "(", "cls", ")", ":", "if", "not", "cls", ".", "__is_selector", "(", ")", ":", "raise", "Exception", "(", "\"Invalid selector[%s].\"", "%", "cls", ".", "__control", "[", "\"by\"", "]", ")", "driver", "=", "Web", ".", "driver", "try", ...
find the element with controls
[ "find", "the", "element", "with", "controls" ]
python
train
55.8
TheOneHyer/arandomness
build/lib.linux-x86_64-3.6/arandomness/files/copen.py
https://github.com/TheOneHyer/arandomness/blob/ae9f630e9a1d67b0eb6d61644a49756de8a5268c/build/lib.linux-x86_64-3.6/arandomness/files/copen.py#L41-L147
def copen(fileobj, mode='rb', **kwargs): """Detects and opens compressed file for reading and writing. Args: fileobj (File): any File-like object supported by an underlying compression algorithm mode (unicode): mode to open fileobj with **kwargs: keyword-argume...
[ "def", "copen", "(", "fileobj", ",", "mode", "=", "'rb'", ",", "*", "*", "kwargs", ")", ":", "algo", "=", "io", ".", "open", "# Only used as io.open in write mode", "mode", "=", "mode", ".", "lower", "(", ")", ".", "strip", "(", ")", "modules", "=", ...
Detects and opens compressed file for reading and writing. Args: fileobj (File): any File-like object supported by an underlying compression algorithm mode (unicode): mode to open fileobj with **kwargs: keyword-arguments to pass to the compression algorithm Re...
[ "Detects", "and", "opens", "compressed", "file", "for", "reading", "and", "writing", "." ]
python
train
34.364486
edaniszewski/colorutils
colorutils/convert.py
https://github.com/edaniszewski/colorutils/blob/bdff54091cb5d62aa8628ce39bc09abd40fb8dd0/colorutils/convert.py#L69-L104
def rgb_to_hsv(rgb): """ Convert an RGB color representation to an HSV color representation. (r, g, b) :: r -> [0, 255] g -> [0, 255] b -> [0, 255] :param rgb: A tuple of three numeric values corresponding to the red, green, and blue value. :return: HSV representa...
[ "def", "rgb_to_hsv", "(", "rgb", ")", ":", "r", ",", "g", ",", "b", "=", "rgb", "[", "0", "]", "/", "255", ",", "rgb", "[", "1", "]", "/", "255", ",", "rgb", "[", "2", "]", "/", "255", "_min", "=", "min", "(", "r", ",", "g", ",", "b", ...
Convert an RGB color representation to an HSV color representation. (r, g, b) :: r -> [0, 255] g -> [0, 255] b -> [0, 255] :param rgb: A tuple of three numeric values corresponding to the red, green, and blue value. :return: HSV representation of the input RGB value. ...
[ "Convert", "an", "RGB", "color", "representation", "to", "an", "HSV", "color", "representation", "." ]
python
valid
22.361111
openego/eDisGo
edisgo/data/import_data.py
https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/data/import_data.py#L1948-L1980
def _build_generator_list(network): """Builds DataFrames with all generators in MV and LV grids Returns ------- :pandas:`pandas.DataFrame<dataframe>` A DataFrame with id of and reference to MV generators :pandas:`pandas.DataFrame<dataframe>` A DataFrame with id of and refere...
[ "def", "_build_generator_list", "(", "network", ")", ":", "genos_mv", "=", "pd", ".", "DataFrame", "(", "columns", "=", "(", "'id'", ",", "'obj'", ")", ")", "genos_lv", "=", "pd", ".", "DataFrame", "(", "columns", "=", "(", "'id'", ",", "'obj'", ")", ...
Builds DataFrames with all generators in MV and LV grids Returns ------- :pandas:`pandas.DataFrame<dataframe>` A DataFrame with id of and reference to MV generators :pandas:`pandas.DataFrame<dataframe>` A DataFrame with id of and reference to LV generators :pandas:`pandas.Da...
[ "Builds", "DataFrames", "with", "all", "generators", "in", "MV", "and", "LV", "grids" ]
python
train
38.272727
UCBerkeleySETI/blimpy
blimpy/match_fils.py
https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/match_fils.py#L46-L142
def cmd_tool(args=None): """ Command line tool to make a md5sum comparison of two .fil files. """ if 'bl' in local_host: header_loc = '/usr/local/sigproc/bin/header' #Current location of header command in GBT. else: raise IOError('Script only able to run in BL systems.') p = OptionPars...
[ "def", "cmd_tool", "(", "args", "=", "None", ")", ":", "if", "'bl'", "in", "local_host", ":", "header_loc", "=", "'/usr/local/sigproc/bin/header'", "#Current location of header command in GBT.", "else", ":", "raise", "IOError", "(", "'Script only able to run in BL systems...
Command line tool to make a md5sum comparison of two .fil files.
[ "Command", "line", "tool", "to", "make", "a", "md5sum", "comparison", "of", "two", ".", "fil", "files", "." ]
python
test
27.082474
NiklasRosenstein-Python/nr-deprecated
nr/concurrency.py
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/concurrency.py#L95-L144
def synchronized(obj): """ This function has two purposes: 1. Decorate a function that automatically synchronizes access to the object passed as the first argument (usually `self`, for member methods) 2. Synchronize access to the object, used in a `with`-statement. Note that you can use #wait(), #notif...
[ "def", "synchronized", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'synchronizable_condition'", ")", ":", "return", "obj", ".", "synchronizable_condition", "elif", "callable", "(", "obj", ")", ":", "@", "functools", ".", "wraps", "(", "obj", "...
This function has two purposes: 1. Decorate a function that automatically synchronizes access to the object passed as the first argument (usually `self`, for member methods) 2. Synchronize access to the object, used in a `with`-statement. Note that you can use #wait(), #notify() and #notify_all() only on ...
[ "This", "function", "has", "two", "purposes", ":" ]
python
train
26.94
funilrys/PyFunceble
PyFunceble/helpers.py
https://github.com/funilrys/PyFunceble/blob/cdf69cbde120199171f7158e1c33635753e6e2f5/PyFunceble/helpers.py#L126-L149
def _hash_file(self, algo): """Get the hash of the given file :param algo: The algorithm to use. :type algo: str :return: The hexdigest of the data. :rtype: str """ # We het the algorithm function. hash_data = getattr(hashlib, algo)() with open...
[ "def", "_hash_file", "(", "self", ",", "algo", ")", ":", "# We het the algorithm function.", "hash_data", "=", "getattr", "(", "hashlib", ",", "algo", ")", "(", ")", "with", "open", "(", "self", ".", "path", ",", "\"rb\"", ")", "as", "file", ":", "# We o...
Get the hash of the given file :param algo: The algorithm to use. :type algo: str :return: The hexdigest of the data. :rtype: str
[ "Get", "the", "hash", "of", "the", "given", "file" ]
python
test
25.875
bitesofcode/projex
projex/urls.py
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/urls.py#L13-L63
def build(path, query=None, fragment=''): """ Generates a URL based on the inputted path and given query options and fragment. The query should be a dictionary of terms that will be generated into the URL, while the fragment is the anchor point within the target path that will be navigated to. If ...
[ "def", "build", "(", "path", ",", "query", "=", "None", ",", "fragment", "=", "''", ")", ":", "url", "=", "nstr", "(", "path", ")", "# replace the optional arguments in the url", "keys", "=", "projex", ".", "text", ".", "findkeys", "(", "path", ")", "if"...
Generates a URL based on the inputted path and given query options and fragment. The query should be a dictionary of terms that will be generated into the URL, while the fragment is the anchor point within the target path that will be navigated to. If there are any wildcards within the path that are f...
[ "Generates", "a", "URL", "based", "on", "the", "inputted", "path", "and", "given", "query", "options", "and", "fragment", ".", "The", "query", "should", "be", "a", "dictionary", "of", "terms", "that", "will", "be", "generated", "into", "the", "URL", "while...
python
train
30.72549
RedHatInsights/insights-core
insights/core/dr.py
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L745-L767
def add_observer(self, o, component_type=ComponentType): """ Add a callback that will get invoked after each component is called. Args: o (func): the callback function Keyword Args: component_type (ComponentType): the :class:`ComponentType` to observe. ...
[ "def", "add_observer", "(", "self", ",", "o", ",", "component_type", "=", "ComponentType", ")", ":", "self", ".", "observers", "[", "component_type", "]", ".", "add", "(", "o", ")" ]
Add a callback that will get invoked after each component is called. Args: o (func): the callback function Keyword Args: component_type (ComponentType): the :class:`ComponentType` to observe. The callback will fire any time an instance of the class or its ...
[ "Add", "a", "callback", "that", "will", "get", "invoked", "after", "each", "component", "is", "called", "." ]
python
train
29.913043
bcbio/bcbio-nextgen
bcbio/graph/graph.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L89-L99
def this_and_prev(iterable): """Walk an iterable, returning the current and previous items as a two-tuple.""" try: item = next(iterable) while True: next_item = next(iterable) yield item, next_item item = next_item except StopIteration: return
[ "def", "this_and_prev", "(", "iterable", ")", ":", "try", ":", "item", "=", "next", "(", "iterable", ")", "while", "True", ":", "next_item", "=", "next", "(", "iterable", ")", "yield", "item", ",", "next_item", "item", "=", "next_item", "except", "StopIt...
Walk an iterable, returning the current and previous items as a two-tuple.
[ "Walk", "an", "iterable", "returning", "the", "current", "and", "previous", "items", "as", "a", "two", "-", "tuple", "." ]
python
train
28.090909
Dallinger/Dallinger
dallinger/command_line.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L740-L753
def monitor(app): """Set up application monitoring.""" heroku_app = HerokuApp(dallinger_uid=app) webbrowser.open(heroku_app.dashboard_url) webbrowser.open("https://requester.mturk.com/mturk/manageHITs") heroku_app.open_logs() check_call(["open", heroku_app.db_uri]) while _keep_running(): ...
[ "def", "monitor", "(", "app", ")", ":", "heroku_app", "=", "HerokuApp", "(", "dallinger_uid", "=", "app", ")", "webbrowser", ".", "open", "(", "heroku_app", ".", "dashboard_url", ")", "webbrowser", ".", "open", "(", "\"https://requester.mturk.com/mturk/manageHITs\...
Set up application monitoring.
[ "Set", "up", "application", "monitoring", "." ]
python
train
35
loli/medpy
medpy/graphcut/energy_voxel.py
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L227-L288
def boundary_difference_exponential(graph, xxx_todo_changeme4): r""" Boundary term processing adjacent voxels difference value using an exponential relationship. An implementation of a boundary term, suitable to be used with the `~medpy.graphcut.generate.graph_from_voxels` function. Finds ...
[ "def", "boundary_difference_exponential", "(", "graph", ",", "xxx_todo_changeme4", ")", ":", "(", "original_image", ",", "sigma", ",", "spacing", ")", "=", "xxx_todo_changeme4", "original_image", "=", "scipy", ".", "asarray", "(", "original_image", ")", "def", "bo...
r""" Boundary term processing adjacent voxels difference value using an exponential relationship. An implementation of a boundary term, suitable to be used with the `~medpy.graphcut.generate.graph_from_voxels` function. Finds all edges between all neighbours of the image and uses their differe...
[ "r", "Boundary", "term", "processing", "adjacent", "voxels", "difference", "value", "using", "an", "exponential", "relationship", ".", "An", "implementation", "of", "a", "boundary", "term", "suitable", "to", "be", "used", "with", "the", "~medpy", ".", "graphcut"...
python
train
41.209677
ejeschke/ginga
ginga/misc/ModuleManager.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/misc/ModuleManager.py#L82-L88
def get_module(self, module_name): """Return loaded module from the given name.""" try: return self.module[module_name] except KeyError: return sys.modules[module_name]
[ "def", "get_module", "(", "self", ",", "module_name", ")", ":", "try", ":", "return", "self", ".", "module", "[", "module_name", "]", "except", "KeyError", ":", "return", "sys", ".", "modules", "[", "module_name", "]" ]
Return loaded module from the given name.
[ "Return", "loaded", "module", "from", "the", "given", "name", "." ]
python
train
30.142857
mitsei/dlkit
dlkit/records/repository/vcb/vcb_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/repository/vcb/vcb_records.py#L72-L105
def _init_metadata(self): """stub""" self._start_timestamp_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'start_timestamp'), 'element_label': 'start timestamp', ...
[ "def", "_init_metadata", "(", "self", ")", ":", "self", ".", "_start_timestamp_metadata", "=", "{", "'element_id'", ":", "Id", "(", "self", ".", "my_osid_object_form", ".", "_authority", ",", "self", ".", "my_osid_object_form", ".", "_namespace", ",", "'start_ti...
stub
[ "stub" ]
python
train
39.147059
apache/incubator-mxnet
python/mxnet/symbol/random.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/random.py#L116-L143
def poisson(lam=1, shape=_Null, dtype=_Null, **kwargs): """Draw random samples from a Poisson distribution. Samples are distributed according to a Poisson distribution parametrized by *lambda* (rate). Samples will always be returned as a floating point data type. Parameters ---------- lam : fl...
[ "def", "poisson", "(", "lam", "=", "1", ",", "shape", "=", "_Null", ",", "dtype", "=", "_Null", ",", "*", "*", "kwargs", ")", ":", "return", "_random_helper", "(", "_internal", ".", "_random_poisson", ",", "_internal", ".", "_sample_poisson", ",", "[", ...
Draw random samples from a Poisson distribution. Samples are distributed according to a Poisson distribution parametrized by *lambda* (rate). Samples will always be returned as a floating point data type. Parameters ---------- lam : float or Symbol, optional Expectation of interval, should...
[ "Draw", "random", "samples", "from", "a", "Poisson", "distribution", "." ]
python
train
45.678571
manns/pyspread
pyspread/src/actions/_grid_actions.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L1114-L1128
def _zoom_rows(self, zoom): """Zooms grid rows""" self.grid.SetDefaultRowSize(self.grid.std_row_size * zoom, resizeExistingRows=True) self.grid.SetRowLabelSize(self.grid.row_label_size * zoom) for row, tab in self.code_array.row_heights: ...
[ "def", "_zoom_rows", "(", "self", ",", "zoom", ")", ":", "self", ".", "grid", ".", "SetDefaultRowSize", "(", "self", ".", "grid", ".", "std_row_size", "*", "zoom", ",", "resizeExistingRows", "=", "True", ")", "self", ".", "grid", ".", "SetRowLabelSize", ...
Zooms grid rows
[ "Zooms", "grid", "rows" ]
python
train
46.333333
fastai/fastai
fastai/text/models/awd_lstm.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/text/models/awd_lstm.py#L165-L168
def awd_lstm_lm_split(model:nn.Module) -> List[nn.Module]: "Split a RNN `model` in groups for differential learning rates." groups = [[rnn, dp] for rnn, dp in zip(model[0].rnns, model[0].hidden_dps)] return groups + [[model[0].encoder, model[0].encoder_dp, model[1]]]
[ "def", "awd_lstm_lm_split", "(", "model", ":", "nn", ".", "Module", ")", "->", "List", "[", "nn", ".", "Module", "]", ":", "groups", "=", "[", "[", "rnn", ",", "dp", "]", "for", "rnn", ",", "dp", "in", "zip", "(", "model", "[", "0", "]", ".", ...
Split a RNN `model` in groups for differential learning rates.
[ "Split", "a", "RNN", "model", "in", "groups", "for", "differential", "learning", "rates", "." ]
python
train
69
gbowerman/azurerm
azurerm/computerp.py
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L107-L193
def create_vmss(access_token, subscription_id, resource_group, vmss_name, vm_size, capacity, publisher, offer, sku, version, subnet_id, location, be_pool_id=None, lb_pool_id=None, storage_type='Standard_LRS', username='azure', password=None, public_key=None, overprovision...
[ "def", "create_vmss", "(", "access_token", ",", "subscription_id", ",", "resource_group", ",", "vmss_name", ",", "vm_size", ",", "capacity", ",", "publisher", ",", "offer", ",", "sku", ",", "version", ",", "subnet_id", ",", "location", ",", "be_pool_id", "=", ...
Create virtual machine scale set. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. resource_group (str): Azure resource group name. vmss_name (str): Name of the new scale set. vm_size (str): Size of virtual machine, ...
[ "Create", "virtual", "machine", "scale", "set", "." ]
python
train
51.011494
saltstack/salt
salt/pillar/pillar_ldap.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/pillar_ldap.py#L270-L306
def _do_search(conf): ''' Builds connection and search arguments, performs the LDAP search and formats the results as a dictionary appropriate for pillar use. ''' # Build LDAP connection args connargs = {} for name in ['server', 'port', 'tls', 'binddn', 'bindpw', 'anonymous']: connar...
[ "def", "_do_search", "(", "conf", ")", ":", "# Build LDAP connection args", "connargs", "=", "{", "}", "for", "name", "in", "[", "'server'", ",", "'port'", ",", "'tls'", ",", "'binddn'", ",", "'bindpw'", ",", "'anonymous'", "]", ":", "connargs", "[", "name...
Builds connection and search arguments, performs the LDAP search and formats the results as a dictionary appropriate for pillar use.
[ "Builds", "connection", "and", "search", "arguments", "performs", "the", "LDAP", "search", "and", "formats", "the", "results", "as", "a", "dictionary", "appropriate", "for", "pillar", "use", "." ]
python
train
35.675676
lesscpy/lesscpy
lesscpy/plib/block.py
https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/plib/block.py#L199-L213
def copy_inner(self, scope): """Copy block contents (properties, inner blocks). Renames inner block from current scope. Used for mixins. args: scope (Scope): Current scope returns: list (block contents) """ if self.tokens[1]: to...
[ "def", "copy_inner", "(", "self", ",", "scope", ")", ":", "if", "self", ".", "tokens", "[", "1", "]", ":", "tokens", "=", "[", "u", ".", "copy", "(", ")", "if", "u", "else", "u", "for", "u", "in", "self", ".", "tokens", "[", "1", "]", "]", ...
Copy block contents (properties, inner blocks). Renames inner block from current scope. Used for mixins. args: scope (Scope): Current scope returns: list (block contents)
[ "Copy", "block", "contents", "(", "properties", "inner", "blocks", ")", ".", "Renames", "inner", "block", "from", "current", "scope", ".", "Used", "for", "mixins", ".", "args", ":", "scope", "(", "Scope", ")", ":", "Current", "scope", "returns", ":", "li...
python
valid
32.733333
xflr6/graphviz
graphviz/files.py
https://github.com/xflr6/graphviz/blob/7376095ef1e47abad7e0b0361b6c9720b706e7a0/graphviz/files.py#L136-L160
def save(self, filename=None, directory=None): """Save the DOT source to file. Ensure the file ends with a newline. Args: filename: Filename for saving the source (defaults to ``name`` + ``'.gv'``) directory: (Sub)directory for source saving and rendering. Returns: ...
[ "def", "save", "(", "self", ",", "filename", "=", "None", ",", "directory", "=", "None", ")", ":", "if", "filename", "is", "not", "None", ":", "self", ".", "filename", "=", "filename", "if", "directory", "is", "not", "None", ":", "self", ".", "direct...
Save the DOT source to file. Ensure the file ends with a newline. Args: filename: Filename for saving the source (defaults to ``name`` + ``'.gv'``) directory: (Sub)directory for source saving and rendering. Returns: The (possibly relative) path of the saved source fi...
[ "Save", "the", "DOT", "source", "to", "file", ".", "Ensure", "the", "file", "ends", "with", "a", "newline", "." ]
python
train
32.36
PythonCharmers/python-future
src/future/backports/email/quoprimime.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/email/quoprimime.py#L167-L170
def newline(self): """Write eol, then start new line.""" self.write_str(self.eol) self.room = self.maxlinelen
[ "def", "newline", "(", "self", ")", ":", "self", ".", "write_str", "(", "self", ".", "eol", ")", "self", ".", "room", "=", "self", ".", "maxlinelen" ]
Write eol, then start new line.
[ "Write", "eol", "then", "start", "new", "line", "." ]
python
train
32.5
vatlab/SoS
src/sos/converter.py
https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/converter.py#L111-L163
def script_to_html(script_file, html_file, args=None, unknown_args=None): ''' Convert sos file to html format with syntax highlighting, and either save the output either to a HTML file or view it in a broaser. This converter accepts additional parameters --style or pygments styles, --linenos for dis...
[ "def", "script_to_html", "(", "script_file", ",", "html_file", ",", "args", "=", "None", ",", "unknown_args", "=", "None", ")", ":", "from", "jinja2", "import", "Environment", ",", "PackageLoader", ",", "select_autoescape", "environment", "=", "Environment", "("...
Convert sos file to html format with syntax highlighting, and either save the output either to a HTML file or view it in a broaser. This converter accepts additional parameters --style or pygments styles, --linenos for displaying linenumbers, and a parameter --raw to embed a URL to the raw sos file.
[ "Convert", "sos", "file", "to", "html", "format", "with", "syntax", "highlighting", "and", "either", "save", "the", "output", "either", "to", "a", "HTML", "file", "or", "view", "it", "in", "a", "broaser", ".", "This", "converter", "accepts", "additional", ...
python
train
40.528302
hyperledger/indy-plenum
stp_core/loop/eventually.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/loop/eventually.py#L50-L113
async def eventuallyAll(*coroFuncs: FlexFunc, # (use functools.partials if needed) totalTimeout: float, retryWait: float=0.1, acceptableExceptions=None, acceptableFails: int=0, override_timeout_limit...
[ "async", "def", "eventuallyAll", "(", "*", "coroFuncs", ":", "FlexFunc", ",", "# (use functools.partials if needed)", "totalTimeout", ":", "float", ",", "retryWait", ":", "float", "=", "0.1", ",", "acceptableExceptions", "=", "None", ",", "acceptableFails", ":", "...
:param coroFuncs: iterable of no-arg functions :param totalTimeout: :param retryWait: :param acceptableExceptions: :param acceptableFails: how many of the passed in coroutines can ultimately fail and still be ok :return:
[ ":", "param", "coroFuncs", ":", "iterable", "of", "no", "-", "arg", "functions", ":", "param", "totalTimeout", ":", ":", "param", "retryWait", ":", ":", "param", "acceptableExceptions", ":", ":", "param", "acceptableFails", ":", "how", "many", "of", "the", ...
python
train
37.140625
tomprince/txgithub
txgithub/api.py
https://github.com/tomprince/txgithub/blob/3bd5eebb25db013e2193e6a102a91049f356710d/txgithub/api.py#L203-L233
def editHook(self, repo_user, repo_name, hook_id, name, config, events=None, add_events=None, remove_events=None, active=None): """ PATCH /repos/:owner/:repo/hooks/:id :param hook_id: Id of the hook. :param name: The name of the service that is being called. :param ...
[ "def", "editHook", "(", "self", ",", "repo_user", ",", "repo_name", ",", "hook_id", ",", "name", ",", "config", ",", "events", "=", "None", ",", "add_events", "=", "None", ",", "remove_events", "=", "None", ",", "active", "=", "None", ")", ":", "post",...
PATCH /repos/:owner/:repo/hooks/:id :param hook_id: Id of the hook. :param name: The name of the service that is being called. :param config: A Hash containing key/value pairs to provide settings for this hook.
[ "PATCH", "/", "repos", "/", ":", "owner", "/", ":", "repo", "/", "hooks", "/", ":", "id" ]
python
train
31.387097
jeffknupp/sandman
sandman/sandman.py
https://github.com/jeffknupp/sandman/blob/253ea4d15cbccd9f0016d66fedd7478614cc0b2f/sandman/sandman.py#L165-L174
def _collection_html_response(resources, start=0, stop=20): """Return the HTML representation of the collection *resources*. :param list resources: list of :class:`sandman.model.Model`s to render :rtype: :class:`flask.Response` """ return make_response(render_template( 'collection.html', ...
[ "def", "_collection_html_response", "(", "resources", ",", "start", "=", "0", ",", "stop", "=", "20", ")", ":", "return", "make_response", "(", "render_template", "(", "'collection.html'", ",", "resources", "=", "resources", "[", "start", ":", "stop", "]", "...
Return the HTML representation of the collection *resources*. :param list resources: list of :class:`sandman.model.Model`s to render :rtype: :class:`flask.Response`
[ "Return", "the", "HTML", "representation", "of", "the", "collection", "*", "resources", "*", "." ]
python
train
35.1
emc-openstack/storops
storops/lib/converter.py
https://github.com/emc-openstack/storops/blob/24b4b13bf065c0ef0538dd0b5ebb8f25d24176bd/storops/lib/converter.py#L312-L333
def ipv6_prefix_to_mask(prefix): """ ipv6 cidr prefix to net mask :param prefix: cidr prefix, rang in (0, 128) :type prefix: int :return: comma separated ipv6 net mask code, eg: ffff:ffff:ffff:ffff:0000:0000:0000:0000 :rtype: str """ if prefix > 128 or prefix < 0: r...
[ "def", "ipv6_prefix_to_mask", "(", "prefix", ")", ":", "if", "prefix", ">", "128", "or", "prefix", "<", "0", ":", "raise", "ValueError", "(", "\"invalid cidr prefix for ipv6\"", ")", "else", ":", "mask", "=", "(", "(", "1", "<<", "128", ")", "-", "1", ...
ipv6 cidr prefix to net mask :param prefix: cidr prefix, rang in (0, 128) :type prefix: int :return: comma separated ipv6 net mask code, eg: ffff:ffff:ffff:ffff:0000:0000:0000:0000 :rtype: str
[ "ipv6", "cidr", "prefix", "to", "net", "mask" ]
python
train
32.681818
danielhrisca/asammdf
asammdf/blocks/mdf_v4.py
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v4.py#L2229-L2276
def configure( self, *, read_fragment_size=None, write_fragment_size=None, use_display_names=None, single_bit_uint_as_bool=None, integer_interpolation=None, ): """ configure MDF parameters Parameters ---------- read_fragment_si...
[ "def", "configure", "(", "self", ",", "*", ",", "read_fragment_size", "=", "None", ",", "write_fragment_size", "=", "None", ",", "use_display_names", "=", "None", ",", "single_bit_uint_as_bool", "=", "None", ",", "integer_interpolation", "=", "None", ",", ")", ...
configure MDF parameters Parameters ---------- read_fragment_size : int size hint of split data blocks, default 8MB; if the initial size is smaller, then no data list is used. The actual split size depends on the data groups' records size write_fragme...
[ "configure", "MDF", "parameters" ]
python
train
36.3125
coleifer/walrus
walrus/database.py
https://github.com/coleifer/walrus/blob/82bf15a6613487b5b5fefeb488f186d7e0106547/walrus/database.py#L150-L163
def run_script(self, script_name, keys=None, args=None): """ Execute a walrus script with the given arguments. :param script_name: The base name of the script to execute. :param list keys: Keys referenced by the script. :param list args: Arguments passed in to the script. ...
[ "def", "run_script", "(", "self", ",", "script_name", ",", "keys", "=", "None", ",", "args", "=", "None", ")", ":", "return", "self", ".", "_scripts", "[", "script_name", "]", "(", "keys", ",", "args", ")" ]
Execute a walrus script with the given arguments. :param script_name: The base name of the script to execute. :param list keys: Keys referenced by the script. :param list args: Arguments passed in to the script. :returns: Return value of script. .. note:: Redis scripts require ...
[ "Execute", "a", "walrus", "script", "with", "the", "given", "arguments", "." ]
python
train
40.428571
cmbruns/pyopenvr
src/openvr/__init__.py
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5541-L5546
def removeNotification(self, notificationId): """Destroy a notification, hiding it first if it currently shown to the user.""" fn = self.function_table.removeNotification result = fn(notificationId) return result
[ "def", "removeNotification", "(", "self", ",", "notificationId", ")", ":", "fn", "=", "self", ".", "function_table", ".", "removeNotification", "result", "=", "fn", "(", "notificationId", ")", "return", "result" ]
Destroy a notification, hiding it first if it currently shown to the user.
[ "Destroy", "a", "notification", "hiding", "it", "first", "if", "it", "currently", "shown", "to", "the", "user", "." ]
python
train
40
stevelittlefish/littlefish
littlefish/timetool.py
https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/timetool.py#L290-L304
def unix_time(dt=None, as_int=False): """Generate a unix style timestamp (in seconds)""" if dt is None: dt = datetime.datetime.utcnow() if type(dt) is datetime.date: dt = date_to_datetime(dt) epoch = datetime.datetime.utcfromtimestamp(0) delta = dt - epoch if as_int: ...
[ "def", "unix_time", "(", "dt", "=", "None", ",", "as_int", "=", "False", ")", ":", "if", "dt", "is", "None", ":", "dt", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "if", "type", "(", "dt", ")", "is", "datetime", ".", "date", ":", ...
Generate a unix style timestamp (in seconds)
[ "Generate", "a", "unix", "style", "timestamp", "(", "in", "seconds", ")" ]
python
test
25.066667
ergo/ziggurat_foundations
ziggurat_foundations/models/services/user.py
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L367-L382
def user_names_like(cls, user_name, db_session=None): """ fetch users with similar names using LIKE clause :param user_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model) query = query....
[ "def", "user_names_like", "(", "cls", ",", "user_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", "query", "=", "query", ...
fetch users with similar names using LIKE clause :param user_name: :param db_session: :return:
[ "fetch", "users", "with", "similar", "names", "using", "LIKE", "clause" ]
python
train
32.875
Nachtfeuer/pipeline
spline/tools/condition.py
https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/condition.py#L144-L167
def match_tokens(ast_tokens, ast_types): """ Verify that each token in order does match the expected types. The list provided by `get_tokens` does have three more elements at the beginning of the list which should be always the same for a condition (Module and Expr). Those are a...
[ "def", "match_tokens", "(", "ast_tokens", ",", "ast_types", ")", ":", "ast_final_types", "=", "[", "ast", ".", "Module", ",", "ast", ".", "Expr", "]", "+", "ast_types", "return", "all", "(", "isinstance", "(", "ast_token", ",", "ast_type", ")", "for", "a...
Verify that each token in order does match the expected types. The list provided by `get_tokens` does have three more elements at the beginning of the list which should be always the same for a condition (Module and Expr). Those are automatically added first to the final list of expecte...
[ "Verify", "that", "each", "token", "in", "order", "does", "match", "the", "expected", "types", "." ]
python
train
41.625
totalgood/nlpia
src/nlpia/loaders.py
https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/loaders.py#L1027-L1113
def get_data(name='sms-spam', nrows=None, limit=None): """ Load data from a json, csv, or txt file if it exists in the data dir. References: [cities_air_pollution_index](https://www.numbeo.com/pollution/rankings.jsp) [cities](http://download.geonames.org/export/dump/cities.zip) [cities_us](ht...
[ "def", "get_data", "(", "name", "=", "'sms-spam'", ",", "nrows", "=", "None", ",", "limit", "=", "None", ")", ":", "nrows", "=", "nrows", "or", "limit", "if", "name", "in", "BIG_URLS", ":", "logger", ".", "info", "(", "'Downloading {}'", ".", "format",...
Load data from a json, csv, or txt file if it exists in the data dir. References: [cities_air_pollution_index](https://www.numbeo.com/pollution/rankings.jsp) [cities](http://download.geonames.org/export/dump/cities.zip) [cities_us](http://download.geonames.org/export/dump/cities_us.zip) >>> ...
[ "Load", "data", "from", "a", "json", "csv", "or", "txt", "file", "if", "it", "exists", "in", "the", "data", "dir", "." ]
python
train
42.517241
mitsei/dlkit
dlkit/json_/learning/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/managers.py#L1481-L1498
def get_objective_lookup_session(self, proxy): """Gets the ``OsidSession`` associated with the objective lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveLookupSession) - an ``ObjectiveLookupSession`` raise: NullArgument - ``prox...
[ "def", "get_objective_lookup_session", "(", "self", ",", "proxy", ")", ":", "if", "not", "self", ".", "supports_objective_lookup", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".", "Objectiv...
Gets the ``OsidSession`` associated with the objective lookup service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.learning.ObjectiveLookupSession) - an ``ObjectiveLookupSession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFailed - unable t...
[ "Gets", "the", "OsidSession", "associated", "with", "the", "objective", "lookup", "service", "." ]
python
train
45.333333
nccgroup/Scout2
AWSScout2/output/console.py
https://github.com/nccgroup/Scout2/blob/5d86d46d7ed91a92000496189e9cfa6b98243937/AWSScout2/output/console.py#L71-L95
def generate_listall_output(lines, resources, aws_config, template, arguments, nodup = False): """ Format and print the output of ListAll :param lines: :param resources: :param aws_config: :param template: :param arguments: :param nodup: :return: """ for line in lines: ...
[ "def", "generate_listall_output", "(", "lines", ",", "resources", ",", "aws_config", ",", "template", ",", "arguments", ",", "nodup", "=", "False", ")", ":", "for", "line", "in", "lines", ":", "output", "=", "[", "]", "for", "resource", "in", "resources", ...
Format and print the output of ListAll :param lines: :param resources: :param aws_config: :param template: :param arguments: :param nodup: :return:
[ "Format", "and", "print", "the", "output", "of", "ListAll" ]
python
train
34.36
openfisca/openfisca-france-indirect-taxation
openfisca_france_indirect_taxation/examples/calage_bdf_cn_bis.py
https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/examples/calage_bdf_cn_bis.py#L112-L125
def get_inflators(target_year): ''' Fonction qui calcule les ratios de calage (bdf sur cn pour année de données) et de vieillissement à partir des masses de comptabilité nationale et des masses de consommation de bdf. ''' data_year = find_nearest_inferior(data_years, target_year) inflators_bdf_t...
[ "def", "get_inflators", "(", "target_year", ")", ":", "data_year", "=", "find_nearest_inferior", "(", "data_years", ",", "target_year", ")", "inflators_bdf_to_cn", "=", "get_inflators_bdf_to_cn", "(", "data_year", ")", "inflators_cn_to_cn", "=", "get_inflators_cn_to_cn", ...
Fonction qui calcule les ratios de calage (bdf sur cn pour année de données) et de vieillissement à partir des masses de comptabilité nationale et des masses de consommation de bdf.
[ "Fonction", "qui", "calcule", "les", "ratios", "de", "calage", "(", "bdf", "sur", "cn", "pour", "année", "de", "données", ")", "et", "de", "vieillissement", "à", "partir", "des", "masses", "de", "comptabilité", "nationale", "et", "des", "masses", "de", "co...
python
train
42.642857
quantmind/pulsar
pulsar/apps/__init__.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/__init__.py#L633-L665
def new_app(self, App, prefix=None, callable=None, **params): """Invoke this method in the :meth:`build` method as many times as the number of :class:`Application` required by this :class:`MultiApp`. :param App: an :class:`Application` class. :param prefix: The prefix to use for...
[ "def", "new_app", "(", "self", ",", "App", ",", "prefix", "=", "None", ",", "callable", "=", "None", ",", "*", "*", "params", ")", ":", "params", ".", "update", "(", "self", ".", "cfg", ".", "params", ")", "params", ".", "pop", "(", "'name'", ","...
Invoke this method in the :meth:`build` method as many times as the number of :class:`Application` required by this :class:`MultiApp`. :param App: an :class:`Application` class. :param prefix: The prefix to use for the application, the prefix is appended to the a...
[ "Invoke", "this", "method", "in", "the", ":", "meth", ":", "build", "method", "as", "many", "times", "as", "the", "number", "of", ":", "class", ":", "Application", "required", "by", "this", ":", "class", ":", "MultiApp", "." ]
python
train
48.606061
DataBiosphere/dsub
dsub/commands/dstat.py
https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L192-L197
def string_presenter(self, dumper, data): """Presenter to force yaml.dump to use multi-line string style.""" if '\n' in data: return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') else: return dumper.represent_scalar('tag:yaml.org,2002:str', data)
[ "def", "string_presenter", "(", "self", ",", "dumper", ",", "data", ")", ":", "if", "'\\n'", "in", "data", ":", "return", "dumper", ".", "represent_scalar", "(", "'tag:yaml.org,2002:str'", ",", "data", ",", "style", "=", "'|'", ")", "else", ":", "return", ...
Presenter to force yaml.dump to use multi-line string style.
[ "Presenter", "to", "force", "yaml", ".", "dump", "to", "use", "multi", "-", "line", "string", "style", "." ]
python
valid
47.5