repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
hmmlearn/hmmlearn | lib/hmmlearn/base.py | https://github.com/hmmlearn/hmmlearn/blob/e86fe4349bce78ad6b3d3eb53e3545902d59abbd/lib/hmmlearn/base.py#L378-L394 | def predict_proba(self, X, lengths=None):
"""Compute the posterior probability for each state in the model.
X : array-like, shape (n_samples, n_features)
Feature matrix of individual samples.
lengths : array-like of integers, shape (n_sequences, ), optional
Lengths of t... | [
"def",
"predict_proba",
"(",
"self",
",",
"X",
",",
"lengths",
"=",
"None",
")",
":",
"_",
",",
"posteriors",
"=",
"self",
".",
"score_samples",
"(",
"X",
",",
"lengths",
")",
"return",
"posteriors"
] | Compute the posterior probability for each state in the model.
X : array-like, shape (n_samples, n_features)
Feature matrix of individual samples.
lengths : array-like of integers, shape (n_sequences, ), optional
Lengths of the individual sequences in ``X``. The sum of
... | [
"Compute",
"the",
"posterior",
"probability",
"for",
"each",
"state",
"in",
"the",
"model",
"."
] | python | train |
thespacedoctor/qubits | qubits/results.py | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/results.py#L780-L945 | def log_the_survey_settings(
log,
pathToYamlFile):
"""
*Create a MD log of the survey settings*
**Key Arguments:**
- ``log`` -- logger
- ``pathToYamlFile`` -- yaml results file
**Return:**
- None
"""
################ > IMPORTS ################
## STA... | [
"def",
"log_the_survey_settings",
"(",
"log",
",",
"pathToYamlFile",
")",
":",
"################ > IMPORTS ################",
"## STANDARD LIB ##",
"## THIRD PARTY ##",
"import",
"yaml",
"## LOCAL APPLICATION ##",
"from",
"datetime",
"import",
"datetime",
",",
"date",
",",
... | *Create a MD log of the survey settings*
**Key Arguments:**
- ``log`` -- logger
- ``pathToYamlFile`` -- yaml results file
**Return:**
- None | [
"*",
"Create",
"a",
"MD",
"log",
"of",
"the",
"survey",
"settings",
"*"
] | python | train |
GoogleCloudPlatform/cloud-debug-python | src/googleclouddebugger/gcp_hub_client.py | https://github.com/GoogleCloudPlatform/cloud-debug-python/blob/89ce3782c98b814838a3ecb5479ed3882368cbee/src/googleclouddebugger/gcp_hub_client.py#L271-L286 | def _MainThreadProc(self):
"""Entry point for the worker thread."""
registration_required = True
while not self._shutdown:
if registration_required:
service = self._BuildService()
registration_required, delay = self._RegisterDebuggee(service)
if not registration_required:
... | [
"def",
"_MainThreadProc",
"(",
"self",
")",
":",
"registration_required",
"=",
"True",
"while",
"not",
"self",
".",
"_shutdown",
":",
"if",
"registration_required",
":",
"service",
"=",
"self",
".",
"_BuildService",
"(",
")",
"registration_required",
",",
"delay... | Entry point for the worker thread. | [
"Entry",
"point",
"for",
"the",
"worker",
"thread",
"."
] | python | train |
dmlc/gluon-nlp | scripts/bert/create_pretraining_data.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/bert/create_pretraining_data.py#L533-L548 | def truncate_seq_pair(tokens_a, tokens_b, max_num_tokens, rng):
"""Truncates a pair of sequences to a maximum sequence length."""
while True:
total_length = len(tokens_a) + len(tokens_b)
if total_length <= max_num_tokens:
break
trunc_tokens = tokens_a if len(tokens_a) > len(... | [
"def",
"truncate_seq_pair",
"(",
"tokens_a",
",",
"tokens_b",
",",
"max_num_tokens",
",",
"rng",
")",
":",
"while",
"True",
":",
"total_length",
"=",
"len",
"(",
"tokens_a",
")",
"+",
"len",
"(",
"tokens_b",
")",
"if",
"total_length",
"<=",
"max_num_tokens",... | Truncates a pair of sequences to a maximum sequence length. | [
"Truncates",
"a",
"pair",
"of",
"sequences",
"to",
"a",
"maximum",
"sequence",
"length",
"."
] | python | train |
eXamadeus/godaddypy | godaddypy/client.py | https://github.com/eXamadeus/godaddypy/blob/67820604ffe233a67ef9f6b3a59ab85b02653e57/godaddypy/client.py#L284-L305 | def update_record(self, domain, record, record_type=None, name=None):
"""Call to GoDaddy API to update a single DNS record
:param name: only required if the record is None (deletion)
:param record_type: only required if the record is None (deletion)
:param domain: the domain where the D... | [
"def",
"update_record",
"(",
"self",
",",
"domain",
",",
"record",
",",
"record_type",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"record_type",
"is",
"None",
":",
"record_type",
"=",
"record",
"[",
"'type'",
"]",
"if",
"name",
"is",
"None"... | Call to GoDaddy API to update a single DNS record
:param name: only required if the record is None (deletion)
:param record_type: only required if the record is None (deletion)
:param domain: the domain where the DNS belongs to (eg. 'example.com')
:param record: dict with record info (e... | [
"Call",
"to",
"GoDaddy",
"API",
"to",
"update",
"a",
"single",
"DNS",
"record"
] | python | train |
vladsaveliev/TargQC | targqc/summarize.py | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/summarize.py#L193-L223 | def _correct_qualimap_insert_size_histogram(work_dir, samples):
""" replacing Qualimap insert size histogram with Picard one.
"""
for s in samples:
qualimap1_dirname = dirname(s.qualimap_ins_size_hist_fpath).replace('raw_data_qualimapReport', 'raw_data')
qualimap2_dirname = dirname(s.qualima... | [
"def",
"_correct_qualimap_insert_size_histogram",
"(",
"work_dir",
",",
"samples",
")",
":",
"for",
"s",
"in",
"samples",
":",
"qualimap1_dirname",
"=",
"dirname",
"(",
"s",
".",
"qualimap_ins_size_hist_fpath",
")",
".",
"replace",
"(",
"'raw_data_qualimapReport'",
... | replacing Qualimap insert size histogram with Picard one. | [
"replacing",
"Qualimap",
"insert",
"size",
"histogram",
"with",
"Picard",
"one",
"."
] | python | train |
hmmlearn/hmmlearn | lib/hmmlearn/base.py | https://github.com/hmmlearn/hmmlearn/blob/e86fe4349bce78ad6b3d3eb53e3545902d59abbd/lib/hmmlearn/base.py#L606-L631 | def _initialize_sufficient_statistics(self):
"""Initializes sufficient statistics required for M-step.
The method is *pure*, meaning that it doesn't change the state of
the instance. For extensibility computed statistics are stored
in a dictionary.
Returns
-------
... | [
"def",
"_initialize_sufficient_statistics",
"(",
"self",
")",
":",
"stats",
"=",
"{",
"'nobs'",
":",
"0",
",",
"'start'",
":",
"np",
".",
"zeros",
"(",
"self",
".",
"n_components",
")",
",",
"'trans'",
":",
"np",
".",
"zeros",
"(",
"(",
"self",
".",
... | Initializes sufficient statistics required for M-step.
The method is *pure*, meaning that it doesn't change the state of
the instance. For extensibility computed statistics are stored
in a dictionary.
Returns
-------
nobs : int
Number of samples in the data... | [
"Initializes",
"sufficient",
"statistics",
"required",
"for",
"M",
"-",
"step",
"."
] | python | train |
spotify/luigi | luigi/contrib/redshift.py | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L489-L495 | def post_copy(self, cursor):
"""
Performs post-copy sql - such as cleansing data, inserting into production table (if copied to temp table), etc.
"""
logger.info('Executing post copy queries')
for query in self.queries:
cursor.execute(query) | [
"def",
"post_copy",
"(",
"self",
",",
"cursor",
")",
":",
"logger",
".",
"info",
"(",
"'Executing post copy queries'",
")",
"for",
"query",
"in",
"self",
".",
"queries",
":",
"cursor",
".",
"execute",
"(",
"query",
")"
] | Performs post-copy sql - such as cleansing data, inserting into production table (if copied to temp table), etc. | [
"Performs",
"post",
"-",
"copy",
"sql",
"-",
"such",
"as",
"cleansing",
"data",
"inserting",
"into",
"production",
"table",
"(",
"if",
"copied",
"to",
"temp",
"table",
")",
"etc",
"."
] | python | train |
chrisrink10/basilisp | src/basilisp/lang/runtime.py | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L233-L240 | def intern(
ns: sym.Symbol, name: sym.Symbol, val, dynamic: bool = False, meta=None
) -> "Var":
"""Intern the value bound to the symbol `name` in namespace `ns`."""
var_ns = Namespace.get_or_create(ns)
var = var_ns.intern(name, Var(var_ns, name, dynamic=dynamic, meta=meta))
v... | [
"def",
"intern",
"(",
"ns",
":",
"sym",
".",
"Symbol",
",",
"name",
":",
"sym",
".",
"Symbol",
",",
"val",
",",
"dynamic",
":",
"bool",
"=",
"False",
",",
"meta",
"=",
"None",
")",
"->",
"\"Var\"",
":",
"var_ns",
"=",
"Namespace",
".",
"get_or_crea... | Intern the value bound to the symbol `name` in namespace `ns`. | [
"Intern",
"the",
"value",
"bound",
"to",
"the",
"symbol",
"name",
"in",
"namespace",
"ns",
"."
] | python | test |
mitsei/dlkit | dlkit/json_/repository/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L2058-L2077 | def register_for_new_assets_by_genus_type(self, asset_genus_type):
"""Registers for notification of new assets of the given asset genus type.
``AssetReceiver.newAssets()`` is invoked when an asset is
appears in this repository.
arg: asset_genus_type (osid.type.Type): the genus type ... | [
"def",
"register_for_new_assets_by_genus_type",
"(",
"self",
",",
"asset_genus_type",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceNotificationSession.register_for_changed_resource",
"if",
"not",
"MONGO_LISTENER",
".",
"receivers",
"[",
"self",
".",
"_ns"... | Registers for notification of new assets of the given asset genus type.
``AssetReceiver.newAssets()`` is invoked when an asset is
appears in this repository.
arg: asset_genus_type (osid.type.Type): the genus type of the
``Asset`` to monitor
raise: NullArgument - ``a... | [
"Registers",
"for",
"notification",
"of",
"new",
"assets",
"of",
"the",
"given",
"asset",
"genus",
"type",
"."
] | python | train |
log2timeline/dfvfs | dfvfs/vfs/cpio_file_system.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/cpio_file_system.py#L76-L92 | def FileEntryExistsByPathSpec(self, path_spec):
"""Determines if a file entry for a path specification exists.
Args:
path_spec (PathSpec): a path specification.
Returns:
bool: True if the file entry exists.
"""
location = getattr(path_spec, 'location', None)
if location is None or ... | [
"def",
"FileEntryExistsByPathSpec",
"(",
"self",
",",
"path_spec",
")",
":",
"location",
"=",
"getattr",
"(",
"path_spec",
",",
"'location'",
",",
"None",
")",
"if",
"location",
"is",
"None",
"or",
"not",
"location",
".",
"startswith",
"(",
"self",
".",
"L... | Determines if a file entry for a path specification exists.
Args:
path_spec (PathSpec): a path specification.
Returns:
bool: True if the file entry exists. | [
"Determines",
"if",
"a",
"file",
"entry",
"for",
"a",
"path",
"specification",
"exists",
"."
] | python | train |
AoiKuiyuyou/AoikLiveReload | tools/waf/aoikwafutil.py | https://github.com/AoiKuiyuyou/AoikLiveReload/blob/0d5adb12118a33749e6690a8165fdb769cff7d5c/tools/waf/aoikwafutil.py#L69-L95 | def print_title(title, is_end=False):
"""
Print title like ``----- {title} -----`` or ``===== {title} =====``.
:param title: Title.
:param is_end: Whether is end title. End title use ``=`` instead of ``-``.
:return: None.
"""
# If is end title
if is_end:
# Use `=`
sep ... | [
"def",
"print_title",
"(",
"title",
",",
"is_end",
"=",
"False",
")",
":",
"# If is end title",
"if",
"is_end",
":",
"# Use `=`",
"sep",
"=",
"'====='",
"# If is not end title",
"else",
":",
"# Use `-`",
"sep",
"=",
"'-----'",
"# If is not end title",
"if",
"not... | Print title like ``----- {title} -----`` or ``===== {title} =====``.
:param title: Title.
:param is_end: Whether is end title. End title use ``=`` instead of ``-``.
:return: None. | [
"Print",
"title",
"like",
"-----",
"{",
"title",
"}",
"-----",
"or",
"=====",
"{",
"title",
"}",
"=====",
"."
] | python | train |
bykof/billomapy | billomapy/billomapy.py | https://github.com/bykof/billomapy/blob/a28ba69fd37654fa145d0411d52c200e7f8984ab/billomapy/billomapy.py#L2107-L2120 | def complete_offer(self, offer_id, complete_dict):
"""
Completes an offer
:param complete_dict: the complete dict with the template id
:param offer_id: the offer id
:return: Response
"""
return self._create_put_request(
resource=OFFERS,
bi... | [
"def",
"complete_offer",
"(",
"self",
",",
"offer_id",
",",
"complete_dict",
")",
":",
"return",
"self",
".",
"_create_put_request",
"(",
"resource",
"=",
"OFFERS",
",",
"billomat_id",
"=",
"offer_id",
",",
"command",
"=",
"COMPLETE",
",",
"send_data",
"=",
... | Completes an offer
:param complete_dict: the complete dict with the template id
:param offer_id: the offer id
:return: Response | [
"Completes",
"an",
"offer"
] | python | train |
Locu/chronology | kronos/kronos/core/validator.py | https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/kronos/kronos/core/validator.py#L65-L70 | def validate_stream(stream):
"""
Check that the stream name is well-formed.
"""
if not STREAM_REGEX.match(stream) or len(stream) > MAX_STREAM_LENGTH:
raise InvalidStreamName(stream) | [
"def",
"validate_stream",
"(",
"stream",
")",
":",
"if",
"not",
"STREAM_REGEX",
".",
"match",
"(",
"stream",
")",
"or",
"len",
"(",
"stream",
")",
">",
"MAX_STREAM_LENGTH",
":",
"raise",
"InvalidStreamName",
"(",
"stream",
")"
] | Check that the stream name is well-formed. | [
"Check",
"that",
"the",
"stream",
"name",
"is",
"well",
"-",
"formed",
"."
] | python | train |
assemblerflow/flowcraft | flowcraft/templates/trimmomatic.py | https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/templates/trimmomatic.py#L265-L283 | def merge_default_adapters():
"""Merges the default adapters file in the trimmomatic adapters directory
Returns
-------
str
Path with the merged adapters file.
"""
default_adapters = [os.path.join(ADAPTERS_PATH, x) for x in
os.listdir(ADAPTERS_PATH)]
filepat... | [
"def",
"merge_default_adapters",
"(",
")",
":",
"default_adapters",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"ADAPTERS_PATH",
",",
"x",
")",
"for",
"x",
"in",
"os",
".",
"listdir",
"(",
"ADAPTERS_PATH",
")",
"]",
"filepath",
"=",
"os",
".",
"path... | Merges the default adapters file in the trimmomatic adapters directory
Returns
-------
str
Path with the merged adapters file. | [
"Merges",
"the",
"default",
"adapters",
"file",
"in",
"the",
"trimmomatic",
"adapters",
"directory"
] | python | test |
twilio/twilio-python | twilio/rest/ip_messaging/v2/service/channel/invite.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/ip_messaging/v2/service/channel/invite.py#L152-L166 | def get(self, sid):
"""
Constructs a InviteContext
:param sid: The unique string that identifies the resource
:returns: twilio.rest.chat.v2.service.channel.invite.InviteContext
:rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext
"""
return InviteCon... | [
"def",
"get",
"(",
"self",
",",
"sid",
")",
":",
"return",
"InviteContext",
"(",
"self",
".",
"_version",
",",
"service_sid",
"=",
"self",
".",
"_solution",
"[",
"'service_sid'",
"]",
",",
"channel_sid",
"=",
"self",
".",
"_solution",
"[",
"'channel_sid'",... | Constructs a InviteContext
:param sid: The unique string that identifies the resource
:returns: twilio.rest.chat.v2.service.channel.invite.InviteContext
:rtype: twilio.rest.chat.v2.service.channel.invite.InviteContext | [
"Constructs",
"a",
"InviteContext"
] | python | train |
square/pylink | pylink/jlink.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L2676-L2732 | def memory_read(self, addr, num_units, zone=None, nbits=None):
"""Reads memory from a target system or specific memory zone.
The optional ``zone`` specifies a memory zone to access to read from,
e.g. ``IDATA``, ``DDATA``, or ``CODE``.
The given number of bits, if provided, must be eith... | [
"def",
"memory_read",
"(",
"self",
",",
"addr",
",",
"num_units",
",",
"zone",
"=",
"None",
",",
"nbits",
"=",
"None",
")",
":",
"buf_size",
"=",
"num_units",
"buf",
"=",
"None",
"access",
"=",
"0",
"if",
"nbits",
"is",
"None",
":",
"buf",
"=",
"("... | Reads memory from a target system or specific memory zone.
The optional ``zone`` specifies a memory zone to access to read from,
e.g. ``IDATA``, ``DDATA``, or ``CODE``.
The given number of bits, if provided, must be either ``8``, ``16``, or
``32``. If not provided, always reads ``num_... | [
"Reads",
"memory",
"from",
"a",
"target",
"system",
"or",
"specific",
"memory",
"zone",
"."
] | python | train |
XuShaohua/bcloud | bcloud/DownloadPage.py | https://github.com/XuShaohua/bcloud/blob/4b54e0fdccf2b3013285fef05c97354cfa31697b/bcloud/DownloadPage.py#L372-L376 | def remove_task_db(self, fs_id):
'''将任务从数据库中删除'''
sql = 'DELETE FROM tasks WHERE fsid=?'
self.cursor.execute(sql, [fs_id, ])
self.check_commit() | [
"def",
"remove_task_db",
"(",
"self",
",",
"fs_id",
")",
":",
"sql",
"=",
"'DELETE FROM tasks WHERE fsid=?'",
"self",
".",
"cursor",
".",
"execute",
"(",
"sql",
",",
"[",
"fs_id",
",",
"]",
")",
"self",
".",
"check_commit",
"(",
")"
] | 将任务从数据库中删除 | [
"将任务从数据库中删除"
] | python | train |
mongodb/mongo-python-driver | pymongo/mongo_client.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/mongo_client.py#L1175-L1206 | def _select_server(self, server_selector, session, address=None):
"""Select a server to run an operation on this client.
:Parameters:
- `server_selector`: The server selector to use if the session is
not pinned and no address is given.
- `session`: The ClientSession for ... | [
"def",
"_select_server",
"(",
"self",
",",
"server_selector",
",",
"session",
",",
"address",
"=",
"None",
")",
":",
"try",
":",
"topology",
"=",
"self",
".",
"_get_topology",
"(",
")",
"address",
"=",
"address",
"or",
"(",
"session",
"and",
"session",
"... | Select a server to run an operation on this client.
:Parameters:
- `server_selector`: The server selector to use if the session is
not pinned and no address is given.
- `session`: The ClientSession for the next operation, or None. May
be pinned to a mongos server add... | [
"Select",
"a",
"server",
"to",
"run",
"an",
"operation",
"on",
"this",
"client",
"."
] | python | train |
AmesCornish/buttersink | buttersink/btrfs.py | https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/btrfs.py#L24-L30 | def bytes2uuid(b):
""" Return standard human-friendly UUID. """
if b.strip(chr(0)) == '':
return None
s = b.encode('hex')
return "%s-%s-%s-%s-%s" % (s[0:8], s[8:12], s[12:16], s[16:20], s[20:]) | [
"def",
"bytes2uuid",
"(",
"b",
")",
":",
"if",
"b",
".",
"strip",
"(",
"chr",
"(",
"0",
")",
")",
"==",
"''",
":",
"return",
"None",
"s",
"=",
"b",
".",
"encode",
"(",
"'hex'",
")",
"return",
"\"%s-%s-%s-%s-%s\"",
"%",
"(",
"s",
"[",
"0",
":",
... | Return standard human-friendly UUID. | [
"Return",
"standard",
"human",
"-",
"friendly",
"UUID",
"."
] | python | train |
bububa/pyTOP | pyTOP/simba.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/simba.py#L414-L425 | def update(self, campaign_id, search_channels, nonsearch_channels, outside_discount, nick=None):
'''xxxxx.xxxxx.campaign.platform.update
===================================
取得一个推广计划的投放平台设置'''
request = TOPRequest('xxxxx.xxxxx.campaign.platform.update')
request['campaign_id'] = ca... | [
"def",
"update",
"(",
"self",
",",
"campaign_id",
",",
"search_channels",
",",
"nonsearch_channels",
",",
"outside_discount",
",",
"nick",
"=",
"None",
")",
":",
"request",
"=",
"TOPRequest",
"(",
"'xxxxx.xxxxx.campaign.platform.update'",
")",
"request",
"[",
"'ca... | xxxxx.xxxxx.campaign.platform.update
===================================
取得一个推广计划的投放平台设置 | [
"xxxxx",
".",
"xxxxx",
".",
"campaign",
".",
"platform",
".",
"update",
"===================================",
"取得一个推广计划的投放平台设置"
] | python | train |
ornlneutronimaging/ImagingReso | ImagingReso/_utilities.py | https://github.com/ornlneutronimaging/ImagingReso/blob/2da5cd1f565b3128f59d86bcedfd9adc2b02218b/ImagingReso/_utilities.py#L74-L141 | def get_list_element_from_database(database='ENDF_VII'):
"""return a string array of all the element from the database
Parameters:
==========
database: string. Name of database
Raises:
======
ValueError if database can not be found
"""
_file_path = os.path.abspath(os.path.dirname(... | [
"def",
"get_list_element_from_database",
"(",
"database",
"=",
"'ENDF_VII'",
")",
":",
"_file_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"_ref_data_folder",
"=",
"os",
".",
"path",
".",... | return a string array of all the element from the database
Parameters:
==========
database: string. Name of database
Raises:
======
ValueError if database can not be found | [
"return",
"a",
"string",
"array",
"of",
"all",
"the",
"element",
"from",
"the",
"database"
] | python | train |
mixmastamyk/console | console/windows.py | https://github.com/mixmastamyk/console/blob/afe6c95d5a7b83d85376f450454e3769e4a5c3d0/console/windows.py#L160-L185 | def get_color(name, stream=STD_OUTPUT_HANDLE):
''' Returns current colors of console.
https://docs.microsoft.com/en-us/windows/console/getconsolescreenbufferinfo
Arguments:
name: one of ('background', 'bg', 'foreground', 'fg')
stream: Handle to stdout, stderr, etc.
... | [
"def",
"get_color",
"(",
"name",
",",
"stream",
"=",
"STD_OUTPUT_HANDLE",
")",
":",
"stream",
"=",
"kernel32",
".",
"GetStdHandle",
"(",
"stream",
")",
"csbi",
"=",
"CONSOLE_SCREEN_BUFFER_INFO",
"(",
")",
"kernel32",
".",
"GetConsoleScreenBufferInfo",
"(",
"stre... | Returns current colors of console.
https://docs.microsoft.com/en-us/windows/console/getconsolescreenbufferinfo
Arguments:
name: one of ('background', 'bg', 'foreground', 'fg')
stream: Handle to stdout, stderr, etc.
Returns:
int: a color id from the conho... | [
"Returns",
"current",
"colors",
"of",
"console",
"."
] | python | train |
LonamiWebs/Telethon | telethon/network/mtprotostate.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/mtprotostate.py#L170-L189 | def update_time_offset(self, correct_msg_id):
"""
Updates the time offset to the correct
one given a known valid message ID.
"""
bad = self._get_new_msg_id()
old = self.time_offset
now = int(time.time())
correct = correct_msg_id >> 32
self.time_of... | [
"def",
"update_time_offset",
"(",
"self",
",",
"correct_msg_id",
")",
":",
"bad",
"=",
"self",
".",
"_get_new_msg_id",
"(",
")",
"old",
"=",
"self",
".",
"time_offset",
"now",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"correct",
"=",
"correc... | Updates the time offset to the correct
one given a known valid message ID. | [
"Updates",
"the",
"time",
"offset",
"to",
"the",
"correct",
"one",
"given",
"a",
"known",
"valid",
"message",
"ID",
"."
] | python | train |
pip-services3-python/pip-services3-components-python | pip_services3_components/count/CachedCounters.py | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/count/CachedCounters.py#L243-L253 | def timestamp(self, name, value):
"""
Records the given timestamp.
:param name: a counter name of Timestamp type.
:param value: a timestamp to record.
"""
counter = self.get(name, CounterType.Timestamp)
counter.time = value if value != None else datetime.datetim... | [
"def",
"timestamp",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"counter",
"=",
"self",
".",
"get",
"(",
"name",
",",
"CounterType",
".",
"Timestamp",
")",
"counter",
".",
"time",
"=",
"value",
"if",
"value",
"!=",
"None",
"else",
"datetime",
"... | Records the given timestamp.
:param name: a counter name of Timestamp type.
:param value: a timestamp to record. | [
"Records",
"the",
"given",
"timestamp",
"."
] | python | train |
django-parler/django-parler | parler/templatetags/parler_tags.py | https://github.com/django-parler/django-parler/blob/11ae4af5e8faddb74c69c848870122df4006a54e/parler/templatetags/parler_tags.py#L67-L164 | def get_translated_url(context, lang_code, object=None):
"""
Get the proper URL for this page in a different language.
Note that this algorithm performs a "best effect" approach to give a proper URL.
To make sure the proper view URL is returned, add the :class:`~parler.views.ViewUrlMixin` to your view.... | [
"def",
"get_translated_url",
"(",
"context",
",",
"lang_code",
",",
"object",
"=",
"None",
")",
":",
"view",
"=",
"context",
".",
"get",
"(",
"'view'",
",",
"None",
")",
"request",
"=",
"context",
"[",
"'request'",
"]",
"if",
"object",
"is",
"not",
"No... | Get the proper URL for this page in a different language.
Note that this algorithm performs a "best effect" approach to give a proper URL.
To make sure the proper view URL is returned, add the :class:`~parler.views.ViewUrlMixin` to your view.
Example, to build a language menu::
<ul>
{... | [
"Get",
"the",
"proper",
"URL",
"for",
"this",
"page",
"in",
"a",
"different",
"language",
"."
] | python | train |
cisco-sas/kitty | kitty/remote/rpc.py | https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/remote/rpc.py#L55-L66 | def decode_string(data, encoding='hex'):
'''
Decode string
:param data: string to decode
:param encoding: encoding to use (default: 'hex')
:return: decoded string
'''
if six.PY2:
return data.decode(encoding)
else:
return codecs.decode(data.encode('ascii'), encoding) | [
"def",
"decode_string",
"(",
"data",
",",
"encoding",
"=",
"'hex'",
")",
":",
"if",
"six",
".",
"PY2",
":",
"return",
"data",
".",
"decode",
"(",
"encoding",
")",
"else",
":",
"return",
"codecs",
".",
"decode",
"(",
"data",
".",
"encode",
"(",
"'asci... | Decode string
:param data: string to decode
:param encoding: encoding to use (default: 'hex')
:return: decoded string | [
"Decode",
"string"
] | python | train |
gitpython-developers/smmap | smmap/util.py | https://github.com/gitpython-developers/smmap/blob/48e9e30b0ef3c24ac7ed88e6e3bfa37dc945bf4c/smmap/util.py#L78-L83 | def align(self):
"""Assures the previous window area is contained in the new one"""
nofs = align_to_mmap(self.ofs, 0)
self.size += self.ofs - nofs # keep size constant
self.ofs = nofs
self.size = align_to_mmap(self.size, 1) | [
"def",
"align",
"(",
"self",
")",
":",
"nofs",
"=",
"align_to_mmap",
"(",
"self",
".",
"ofs",
",",
"0",
")",
"self",
".",
"size",
"+=",
"self",
".",
"ofs",
"-",
"nofs",
"# keep size constant",
"self",
".",
"ofs",
"=",
"nofs",
"self",
".",
"size",
"... | Assures the previous window area is contained in the new one | [
"Assures",
"the",
"previous",
"window",
"area",
"is",
"contained",
"in",
"the",
"new",
"one"
] | python | train |
pgmpy/pgmpy | pgmpy/sampling/HMC.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/sampling/HMC.py#L88-L102 | def _acceptance_prob(self, position, position_bar, momentum, momentum_bar):
"""
Returns the acceptance probability for given new position(position) and momentum
"""
# Parameters to help in evaluating Joint distribution P(position, momentum)
_, logp = self.grad_log_pdf(position, ... | [
"def",
"_acceptance_prob",
"(",
"self",
",",
"position",
",",
"position_bar",
",",
"momentum",
",",
"momentum_bar",
")",
":",
"# Parameters to help in evaluating Joint distribution P(position, momentum)",
"_",
",",
"logp",
"=",
"self",
".",
"grad_log_pdf",
"(",
"positio... | Returns the acceptance probability for given new position(position) and momentum | [
"Returns",
"the",
"acceptance",
"probability",
"for",
"given",
"new",
"position",
"(",
"position",
")",
"and",
"momentum"
] | python | train |
bfontaine/p7magma | magma/session.py | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L85-L93 | def get_results_soup(self, year=None):
"""
``get_soup`` on the results page. The page URL depends on the year.
"""
if year is None:
year = self.year
year = YEARS.get(year, year)
return self.get_soup(URLS['results'][year]) | [
"def",
"get_results_soup",
"(",
"self",
",",
"year",
"=",
"None",
")",
":",
"if",
"year",
"is",
"None",
":",
"year",
"=",
"self",
".",
"year",
"year",
"=",
"YEARS",
".",
"get",
"(",
"year",
",",
"year",
")",
"return",
"self",
".",
"get_soup",
"(",
... | ``get_soup`` on the results page. The page URL depends on the year. | [
"get_soup",
"on",
"the",
"results",
"page",
".",
"The",
"page",
"URL",
"depends",
"on",
"the",
"year",
"."
] | python | train |
mozilla/treeherder | treeherder/seta/high_value_jobs.py | https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/seta/high_value_jobs.py#L34-L64 | def build_removals(active_jobs, failures, target):
"""
active_jobs - all possible desktop & android jobs on Treeherder (no PGO)
failures - list of all failures
target - percentage of failures we're going to process
Return list of jobs to remove and list of revisions that are regressed
"""
#... | [
"def",
"build_removals",
"(",
"active_jobs",
",",
"failures",
",",
"target",
")",
":",
"# Determine the number of failures we're going to process",
"# A failure is a revision + all of the jobs that were fixed by it",
"number_of_failures",
"=",
"int",
"(",
"(",
"target",
"/",
"1... | active_jobs - all possible desktop & android jobs on Treeherder (no PGO)
failures - list of all failures
target - percentage of failures we're going to process
Return list of jobs to remove and list of revisions that are regressed | [
"active_jobs",
"-",
"all",
"possible",
"desktop",
"&",
"android",
"jobs",
"on",
"Treeherder",
"(",
"no",
"PGO",
")",
"failures",
"-",
"list",
"of",
"all",
"failures",
"target",
"-",
"percentage",
"of",
"failures",
"we",
"re",
"going",
"to",
"process"
] | python | train |
openstack/swauth | swauth/middleware.py | https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L525-L577 | def handle_request(self, req):
"""Entry point for auth requests (ones that match the self.auth_prefix).
Should return a WSGI-style callable (such as swob.Response).
:param req: swob.Request object
"""
req.start_time = time()
handler = None
try:
versio... | [
"def",
"handle_request",
"(",
"self",
",",
"req",
")",
":",
"req",
".",
"start_time",
"=",
"time",
"(",
")",
"handler",
"=",
"None",
"try",
":",
"version",
",",
"account",
",",
"user",
",",
"_junk",
"=",
"split_path",
"(",
"req",
".",
"path_info",
",... | Entry point for auth requests (ones that match the self.auth_prefix).
Should return a WSGI-style callable (such as swob.Response).
:param req: swob.Request object | [
"Entry",
"point",
"for",
"auth",
"requests",
"(",
"ones",
"that",
"match",
"the",
"self",
".",
"auth_prefix",
")",
".",
"Should",
"return",
"a",
"WSGI",
"-",
"style",
"callable",
"(",
"such",
"as",
"swob",
".",
"Response",
")",
"."
] | python | train |
splunk/splunk-sdk-python | splunklib/client.py | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/splunklib/client.py#L2940-L2984 | def export(self, query, **params):
"""Runs a search and immediately starts streaming preview events.
This method returns a streaming handle to this job's events as an XML
document from the server. To parse this stream into usable Python objects,
pass the handle to :class:`splunklib.resul... | [
"def",
"export",
"(",
"self",
",",
"query",
",",
"*",
"*",
"params",
")",
":",
"if",
"\"exec_mode\"",
"in",
"params",
":",
"raise",
"TypeError",
"(",
"\"Cannot specify an exec_mode to export.\"",
")",
"params",
"[",
"'segmentation'",
"]",
"=",
"params",
".",
... | Runs a search and immediately starts streaming preview events.
This method returns a streaming handle to this job's events as an XML
document from the server. To parse this stream into usable Python objects,
pass the handle to :class:`splunklib.results.ResultsReader`::
import splunk... | [
"Runs",
"a",
"search",
"and",
"immediately",
"starts",
"streaming",
"preview",
"events",
".",
"This",
"method",
"returns",
"a",
"streaming",
"handle",
"to",
"this",
"job",
"s",
"events",
"as",
"an",
"XML",
"document",
"from",
"the",
"server",
".",
"To",
"p... | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/process.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/process.py#L2430-L2467 | def peek_pointers_in_data(self, data, peekSize = 16, peekStep = 1):
"""
Tries to guess which values in the given data are valid pointers,
and reads some data from them.
@see: L{peek}
@type data: str
@param data: Binary data to find pointers in.
@type peekSize... | [
"def",
"peek_pointers_in_data",
"(",
"self",
",",
"data",
",",
"peekSize",
"=",
"16",
",",
"peekStep",
"=",
"1",
")",
":",
"result",
"=",
"dict",
"(",
")",
"ptrSize",
"=",
"win32",
".",
"sizeof",
"(",
"win32",
".",
"LPVOID",
")",
"if",
"ptrSize",
"==... | Tries to guess which values in the given data are valid pointers,
and reads some data from them.
@see: L{peek}
@type data: str
@param data: Binary data to find pointers in.
@type peekSize: int
@param peekSize: Number of bytes to read from each pointer found.
... | [
"Tries",
"to",
"guess",
"which",
"values",
"in",
"the",
"given",
"data",
"are",
"valid",
"pointers",
"and",
"reads",
"some",
"data",
"from",
"them",
"."
] | python | train |
yyuu/botornado | boto/route53/connection.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/route53/connection.py#L297-L320 | def get_change(self, change_id):
"""
Get information about a proposed set of changes, as submitted
by the change_rrsets method.
Returns a Python data structure with status information about the
changes.
:type change_id: str
:param change_id: The unique identifier... | [
"def",
"get_change",
"(",
"self",
",",
"change_id",
")",
":",
"uri",
"=",
"'/%s/change/%s'",
"%",
"(",
"self",
".",
"Version",
",",
"change_id",
")",
"response",
"=",
"self",
".",
"make_request",
"(",
"'GET'",
",",
"uri",
")",
"body",
"=",
"response",
... | Get information about a proposed set of changes, as submitted
by the change_rrsets method.
Returns a Python data structure with status information about the
changes.
:type change_id: str
:param change_id: The unique identifier for the set of changes.
This ID is retur... | [
"Get",
"information",
"about",
"a",
"proposed",
"set",
"of",
"changes",
"as",
"submitted",
"by",
"the",
"change_rrsets",
"method",
".",
"Returns",
"a",
"Python",
"data",
"structure",
"with",
"status",
"information",
"about",
"the",
"changes",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/io/abinit/wrappers.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/wrappers.py#L68-L103 | def _execute(self, workdir, with_mpirun=False, exec_args=None):
"""
Execute the executable in a subprocess inside workdir.
Some executables fail if we try to launch them with mpirun.
Use with_mpirun=False to run the binary without it.
"""
qadapter = self.manager.qadapter... | [
"def",
"_execute",
"(",
"self",
",",
"workdir",
",",
"with_mpirun",
"=",
"False",
",",
"exec_args",
"=",
"None",
")",
":",
"qadapter",
"=",
"self",
".",
"manager",
".",
"qadapter",
"if",
"not",
"with_mpirun",
":",
"qadapter",
".",
"name",
"=",
"None",
... | Execute the executable in a subprocess inside workdir.
Some executables fail if we try to launch them with mpirun.
Use with_mpirun=False to run the binary without it. | [
"Execute",
"the",
"executable",
"in",
"a",
"subprocess",
"inside",
"workdir",
"."
] | python | train |
DataDog/integrations-core | sqlserver/datadog_checks/sqlserver/sqlserver.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/sqlserver/datadog_checks/sqlserver/sqlserver.py#L766-L818 | def fetch_metric(self, cursor, results, tags):
'''
Because we need to query the metrics by matching pairs, we can't query
all of them together without having to perform some matching based on
the name afterwards so instead we query instance by instance.
We cache the list of insta... | [
"def",
"fetch_metric",
"(",
"self",
",",
"cursor",
",",
"results",
",",
"tags",
")",
":",
"if",
"self",
".",
"sql_name",
"not",
"in",
"results",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"Couldn't find {} in results\"",
".",
"format",
"(",
"self",
... | Because we need to query the metrics by matching pairs, we can't query
all of them together without having to perform some matching based on
the name afterwards so instead we query instance by instance.
We cache the list of instance so that we don't have to look it up every time | [
"Because",
"we",
"need",
"to",
"query",
"the",
"metrics",
"by",
"matching",
"pairs",
"we",
"can",
"t",
"query",
"all",
"of",
"them",
"together",
"without",
"having",
"to",
"perform",
"some",
"matching",
"based",
"on",
"the",
"name",
"afterwards",
"so",
"in... | python | train |
rycus86/ghost-client | ghost_client/api.py | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L346-L389 | def execute_get(self, resource, **kwargs):
"""
Execute an HTTP GET request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional query parameters (and optionally headers)
:return: The HTTP re... | [
"def",
"execute_get",
"(",
"self",
",",
"resource",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"base_url",
",",
"resource",
")",
"headers",
"=",
"kwargs",
".",
"pop",
"(",
"'headers'",
",",
"dict",
"(",
")",
")... | Execute an HTTP GET request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional query parameters (and optionally headers)
:return: The HTTP response as JSON or `GhostException` if unsuccessful | [
"Execute",
"an",
"HTTP",
"GET",
"request",
"against",
"the",
"API",
"endpoints",
".",
"This",
"method",
"is",
"meant",
"for",
"internal",
"use",
"."
] | python | train |
todbot/blink1-python | blink1/kelvin.py | https://github.com/todbot/blink1-python/blob/7a5183becd9662f88da3c29afd3447403f4ef82f/blink1/kelvin.py#L24-L35 | def correct_output(luminosity):
"""
:param luminosity: Input luminosity
:return: Luminosity limited to the 0 <= l <= 255 range.
"""
if luminosity < 0:
val = 0
elif luminosity > 255:
val = 255
else:
val = luminosity
return round(val) | [
"def",
"correct_output",
"(",
"luminosity",
")",
":",
"if",
"luminosity",
"<",
"0",
":",
"val",
"=",
"0",
"elif",
"luminosity",
">",
"255",
":",
"val",
"=",
"255",
"else",
":",
"val",
"=",
"luminosity",
"return",
"round",
"(",
"val",
")"
] | :param luminosity: Input luminosity
:return: Luminosity limited to the 0 <= l <= 255 range. | [
":",
"param",
"luminosity",
":",
"Input",
"luminosity",
":",
"return",
":",
"Luminosity",
"limited",
"to",
"the",
"0",
"<",
"=",
"l",
"<",
"=",
"255",
"range",
"."
] | python | train |
markchil/gptools | gptools/kernel/core.py | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L709-L732 | def _compute_dk_dtau_on_partition(self, tau, p):
"""Evaluate the term inside the sum of Faa di Bruno's formula for the given partition.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
p : list of :py:class:`Array`
... | [
"def",
"_compute_dk_dtau_on_partition",
"(",
"self",
",",
"tau",
",",
"p",
")",
":",
"y",
",",
"r2l2",
"=",
"self",
".",
"_compute_y",
"(",
"tau",
",",
"return_r2l2",
"=",
"True",
")",
"# Compute the d^(|pi|)f/dy term:",
"dk_dtau",
"=",
"self",
".",
"_comput... | Evaluate the term inside the sum of Faa di Bruno's formula for the given partition.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
p : list of :py:class:`Array`
Each element is a block of the partition representi... | [
"Evaluate",
"the",
"term",
"inside",
"the",
"sum",
"of",
"Faa",
"di",
"Bruno",
"s",
"formula",
"for",
"the",
"given",
"partition",
".",
"Parameters",
"----------",
"tau",
":",
":",
"py",
":",
"class",
":",
"Matrix",
"(",
"M",
"D",
")",
"M",
"inputs",
... | python | train |
gwpy/gwpy | gwpy/plot/gps.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/plot/gps.py#L69-L78 | def _truncate(f, n):
"""Truncates/pads a float `f` to `n` decimal places without rounding
From https://stackoverflow.com/a/783927/1307974 (CC-BY-SA)
"""
s = "{}".format(f)
if "e" in s or "E" in s:
return "{0:.{1}f}".format(f, n)
i, p, d = s.partition(".")
return ".".join([i, (d+"0"*... | [
"def",
"_truncate",
"(",
"f",
",",
"n",
")",
":",
"s",
"=",
"\"{}\"",
".",
"format",
"(",
"f",
")",
"if",
"\"e\"",
"in",
"s",
"or",
"\"E\"",
"in",
"s",
":",
"return",
"\"{0:.{1}f}\"",
".",
"format",
"(",
"f",
",",
"n",
")",
"i",
",",
"p",
","... | Truncates/pads a float `f` to `n` decimal places without rounding
From https://stackoverflow.com/a/783927/1307974 (CC-BY-SA) | [
"Truncates",
"/",
"pads",
"a",
"float",
"f",
"to",
"n",
"decimal",
"places",
"without",
"rounding"
] | python | train |
Bachmann1234/diff-cover | diff_cover/report_generator.py | https://github.com/Bachmann1234/diff-cover/blob/901cb3fc986982961785e841658085ead453c6c9/diff_cover/report_generator.py#L309-L333 | def _src_path_stats(self, src_path):
"""
Return a dict of statistics for the source file at `src_path`.
"""
# Find violation lines
violation_lines = self.violation_lines(src_path)
violations = sorted(self._diff_violations()[src_path].violations)
# Load source sn... | [
"def",
"_src_path_stats",
"(",
"self",
",",
"src_path",
")",
":",
"# Find violation lines",
"violation_lines",
"=",
"self",
".",
"violation_lines",
"(",
"src_path",
")",
"violations",
"=",
"sorted",
"(",
"self",
".",
"_diff_violations",
"(",
")",
"[",
"src_path"... | Return a dict of statistics for the source file at `src_path`. | [
"Return",
"a",
"dict",
"of",
"statistics",
"for",
"the",
"source",
"file",
"at",
"src_path",
"."
] | python | train |
ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_image.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_image.py#L188-L196 | def events(self):
'''check for events a list of events'''
ret = []
while True:
e = self.poll()
if e is None:
break
ret.append(e)
return ret | [
"def",
"events",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"while",
"True",
":",
"e",
"=",
"self",
".",
"poll",
"(",
")",
"if",
"e",
"is",
"None",
":",
"break",
"ret",
".",
"append",
"(",
"e",
")",
"return",
"ret"
] | check for events a list of events | [
"check",
"for",
"events",
"a",
"list",
"of",
"events"
] | python | train |
joowani/quadriga | quadriga/client.py | https://github.com/joowani/quadriga/blob/412f88f414ef0cb53efa6d5841b9674eb9718359/quadriga/client.py#L130-L151 | def book(self, name):
"""Return an API wrapper for the given order book.
:param name: Order book name (e.g. "btc_cad").
:type name: str | unicode
:return: Order book API wrapper.
:rtype: quadriga.book.OrderBook
:raise InvalidOrderBookError: If an invalid order book is gi... | [
"def",
"book",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_validate_order_book",
"(",
"name",
")",
"return",
"OrderBook",
"(",
"name",
",",
"self",
".",
"_rest_client",
",",
"self",
".",
"_logger",
")"
] | Return an API wrapper for the given order book.
:param name: Order book name (e.g. "btc_cad").
:type name: str | unicode
:return: Order book API wrapper.
:rtype: quadriga.book.OrderBook
:raise InvalidOrderBookError: If an invalid order book is given.
**Example**:
... | [
"Return",
"an",
"API",
"wrapper",
"for",
"the",
"given",
"order",
"book",
"."
] | python | train |
Microsoft/nni | src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L377-L392 | def generate_new_bracket(self):
"""generate a new bracket"""
logger.debug(
'start to create a new SuccessiveHalving iteration, self.curr_s=%d', self.curr_s)
if self.curr_s < 0:
logger.info("s < 0, Finish this round of Hyperband in BOHB. Generate new round")
se... | [
"def",
"generate_new_bracket",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'start to create a new SuccessiveHalving iteration, self.curr_s=%d'",
",",
"self",
".",
"curr_s",
")",
"if",
"self",
".",
"curr_s",
"<",
"0",
":",
"logger",
".",
"info",
"(",
"\"... | generate a new bracket | [
"generate",
"a",
"new",
"bracket"
] | python | train |
lsst-sqre/sqre-codekit | codekit/cli/github_tag_release.py | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/cli/github_tag_release.py#L32-L229 | def parse_args():
"""Parse command-line arguments"""
prog = 'github-tag-release'
parser = argparse.ArgumentParser(
prog=prog,
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent("""
Tag git repositories, in a GitHub org, that correspond to t... | [
"def",
"parse_args",
"(",
")",
":",
"prog",
"=",
"'github-tag-release'",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"prog",
",",
"formatter_class",
"=",
"argparse",
".",
"RawDescriptionHelpFormatter",
",",
"description",
"=",
"textwrap",
... | Parse command-line arguments | [
"Parse",
"command",
"-",
"line",
"arguments"
] | python | train |
Kortemme-Lab/klab | klab/general/strutil.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/general/strutil.py#L15-L19 | def parse_range(s, range_separator = '-'):
''' Parses the string s which contains indices and ranges and returns the explicit list of integers defined by s.
Written by Laurens Kraal 2014.
'''
return reduce(lambda x,y: x+y, (map(lambda r: (range(int(r.split(range_separator)[0]), int(r.split(range_sep... | [
"def",
"parse_range",
"(",
"s",
",",
"range_separator",
"=",
"'-'",
")",
":",
"return",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
"+",
"y",
",",
"(",
"map",
"(",
"lambda",
"r",
":",
"(",
"range",
"(",
"int",
"(",
"r",
".",
"split",
"(",... | Parses the string s which contains indices and ranges and returns the explicit list of integers defined by s.
Written by Laurens Kraal 2014. | [
"Parses",
"the",
"string",
"s",
"which",
"contains",
"indices",
"and",
"ranges",
"and",
"returns",
"the",
"explicit",
"list",
"of",
"integers",
"defined",
"by",
"s",
".",
"Written",
"by",
"Laurens",
"Kraal",
"2014",
"."
] | python | train |
saltstack/salt | salt/modules/pf.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pf.py#L99-L135 | def loglevel(level):
'''
Set the debug level which limits the severity of log messages printed by ``pf(4)``.
level:
Log level. Should be one of the following: emerg, alert, crit, err, warning, notice,
info or debug (OpenBSD); or none, urgent, misc, loud (FreeBSD).
CLI example:
.. ... | [
"def",
"loglevel",
"(",
"level",
")",
":",
"# There's no way to getting the previous loglevel so imply we've",
"# always made a change.",
"ret",
"=",
"{",
"'changes'",
":",
"True",
"}",
"myos",
"=",
"__grains__",
"[",
"'os'",
"]",
"if",
"myos",
"==",
"'FreeBSD'",
":... | Set the debug level which limits the severity of log messages printed by ``pf(4)``.
level:
Log level. Should be one of the following: emerg, alert, crit, err, warning, notice,
info or debug (OpenBSD); or none, urgent, misc, loud (FreeBSD).
CLI example:
.. code-block:: bash
salt '... | [
"Set",
"the",
"debug",
"level",
"which",
"limits",
"the",
"severity",
"of",
"log",
"messages",
"printed",
"by",
"pf",
"(",
"4",
")",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/pathlib2/__init__.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pathlib2/__init__.py#L1230-L1237 | def _raw_open(self, flags, mode=0o777):
"""
Open the file pointed by this path and return a file descriptor,
as os.open() does.
"""
if self._closed:
self._raise_closed()
return self._accessor.open(self, flags, mode) | [
"def",
"_raw_open",
"(",
"self",
",",
"flags",
",",
"mode",
"=",
"0o777",
")",
":",
"if",
"self",
".",
"_closed",
":",
"self",
".",
"_raise_closed",
"(",
")",
"return",
"self",
".",
"_accessor",
".",
"open",
"(",
"self",
",",
"flags",
",",
"mode",
... | Open the file pointed by this path and return a file descriptor,
as os.open() does. | [
"Open",
"the",
"file",
"pointed",
"by",
"this",
"path",
"and",
"return",
"a",
"file",
"descriptor",
"as",
"os",
".",
"open",
"()",
"does",
"."
] | python | train |
iotile/coretools | iotilecore/iotile/core/hw/transport/server/standard.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/server/standard.py#L288-L309 | async def open_interface(self, client_id, conn_string, interface):
"""Open a device interface on behalf of a client.
See :meth:`AbstractDeviceAdapter.open_interface`.
Args:
client_id (str): The client we are working for.
conn_string (str): A connection string that will ... | [
"async",
"def",
"open_interface",
"(",
"self",
",",
"client_id",
",",
"conn_string",
",",
"interface",
")",
":",
"conn_id",
"=",
"self",
".",
"_client_connection",
"(",
"client_id",
",",
"conn_string",
")",
"# Hook first so there is no race on getting the first event",
... | Open a device interface on behalf of a client.
See :meth:`AbstractDeviceAdapter.open_interface`.
Args:
client_id (str): The client we are working for.
conn_string (str): A connection string that will be
passed to the underlying device adapter.
interf... | [
"Open",
"a",
"device",
"interface",
"on",
"behalf",
"of",
"a",
"client",
"."
] | python | train |
rodluger/everest | everest/missions/k2/pbs.py | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/pbs.py#L322-L350 | def _Publish(campaign, subcampaign, strkwargs):
'''
The actual function that publishes a given campaign; this must
be called from ``missions/k2/publish.pbs``.
'''
# Get kwargs from string
kwargs = pickle.loads(strkwargs.replace('%%%', '\n').encode('utf-8'))
# Check the cadence
cadence... | [
"def",
"_Publish",
"(",
"campaign",
",",
"subcampaign",
",",
"strkwargs",
")",
":",
"# Get kwargs from string",
"kwargs",
"=",
"pickle",
".",
"loads",
"(",
"strkwargs",
".",
"replace",
"(",
"'%%%'",
",",
"'\\n'",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")... | The actual function that publishes a given campaign; this must
be called from ``missions/k2/publish.pbs``. | [
"The",
"actual",
"function",
"that",
"publishes",
"a",
"given",
"campaign",
";",
"this",
"must",
"be",
"called",
"from",
"missions",
"/",
"k2",
"/",
"publish",
".",
"pbs",
"."
] | python | train |
area4lib/area4 | area4/util.py | https://github.com/area4lib/area4/blob/7f71b58d6b44b1a61284a8a01f26afd3138b9b17/area4/util.py#L42-L62 | def reduce_to_unit(divider):
"""
Reduce a repeating divider to the smallest repeating unit possible.
Note: this function is used by make-div
:param divider: the divider
:return: smallest repeating unit possible
:rtype: str
:Example:
'XxXxXxX' -> 'Xx'
"""
for unit_size in range(... | [
"def",
"reduce_to_unit",
"(",
"divider",
")",
":",
"for",
"unit_size",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"divider",
")",
"//",
"2",
"+",
"1",
")",
":",
"length",
"=",
"len",
"(",
"divider",
")",
"unit",
"=",
"divider",
"[",
":",
"unit_size"... | Reduce a repeating divider to the smallest repeating unit possible.
Note: this function is used by make-div
:param divider: the divider
:return: smallest repeating unit possible
:rtype: str
:Example:
'XxXxXxX' -> 'Xx' | [
"Reduce",
"a",
"repeating",
"divider",
"to",
"the",
"smallest",
"repeating",
"unit",
"possible",
"."
] | python | train |
Clinical-Genomics/scout | scout/server/blueprints/cases/views.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/cases/views.py#L582-L595 | def status(institute_id, case_name):
"""Update status of a specific case."""
institute_obj, case_obj = institute_and_case(store, institute_id, case_name)
user_obj = store.user(current_user.email)
status = request.form.get('status', case_obj['status'])
link = url_for('.case', institute_id=institute_... | [
"def",
"status",
"(",
"institute_id",
",",
"case_name",
")",
":",
"institute_obj",
",",
"case_obj",
"=",
"institute_and_case",
"(",
"store",
",",
"institute_id",
",",
"case_name",
")",
"user_obj",
"=",
"store",
".",
"user",
"(",
"current_user",
".",
"email",
... | Update status of a specific case. | [
"Update",
"status",
"of",
"a",
"specific",
"case",
"."
] | python | test |
zhanglab/psamm | psamm/massconsistency.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/massconsistency.py#L141-L186 | def check_compound_consistency(database, solver, exchange=set(),
zeromass=set()):
"""Yield each compound in the database with assigned mass
Each compound will be assigned a mass and the number of compounds having a
positive mass will be approximately maximized.
This is a... | [
"def",
"check_compound_consistency",
"(",
"database",
",",
"solver",
",",
"exchange",
"=",
"set",
"(",
")",
",",
"zeromass",
"=",
"set",
"(",
")",
")",
":",
"# Create mass balance problem",
"prob",
"=",
"solver",
".",
"create_problem",
"(",
")",
"compound_set"... | Yield each compound in the database with assigned mass
Each compound will be assigned a mass and the number of compounds having a
positive mass will be approximately maximized.
This is an implementation of the solution originally proposed by
[Gevorgyan08]_ but using the new method proposed by [Thiele... | [
"Yield",
"each",
"compound",
"in",
"the",
"database",
"with",
"assigned",
"mass"
] | python | train |
polysquare/polysquare-setuptools-lint | polysquare_setuptools_lint/__init__.py | https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L479-L490 | def _file_lines(self, filename):
"""Get lines for filename, caching opened files."""
try:
return self._file_lines_cache[filename]
except KeyError:
if os.path.isfile(filename):
with open(filename) as python_file:
self._file_lines_cache[f... | [
"def",
"_file_lines",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"return",
"self",
".",
"_file_lines_cache",
"[",
"filename",
"]",
"except",
"KeyError",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"with",
"open",
"(... | Get lines for filename, caching opened files. | [
"Get",
"lines",
"for",
"filename",
"caching",
"opened",
"files",
"."
] | python | train |
voidpp/python-tools | voidpp_tools/daemon.py | https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/daemon.py#L99-L116 | def start(self):
"""
Start the daemon
"""
if self.is_running():
msg = "Daemon already running (pidfile:%s)" % self.pidfile
self.logger.error(msg)
return msg
initres = self.init()
if not initres[0]:
return initres[1]
... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_running",
"(",
")",
":",
"msg",
"=",
"\"Daemon already running (pidfile:%s)\"",
"%",
"self",
".",
"pidfile",
"self",
".",
"logger",
".",
"error",
"(",
"msg",
")",
"return",
"msg",
"initres",
"... | Start the daemon | [
"Start",
"the",
"daemon"
] | python | train |
proteanhq/protean | src/protean/impl/email/local_mem.py | https://github.com/proteanhq/protean/blob/0e29873f4aa634aa93cc08ed675dd749c7ed4b0f/src/protean/impl/email/local_mem.py#L19-L27 | def send_messages(self, messages):
"""Redirect messages to the dummy outbox"""
msg_count = 0
for message in messages: # .message() triggers header validation
message.message()
email.outbox.append(message)
msg_count += 1
return msg_count | [
"def",
"send_messages",
"(",
"self",
",",
"messages",
")",
":",
"msg_count",
"=",
"0",
"for",
"message",
"in",
"messages",
":",
"# .message() triggers header validation",
"message",
".",
"message",
"(",
")",
"email",
".",
"outbox",
".",
"append",
"(",
"message... | Redirect messages to the dummy outbox | [
"Redirect",
"messages",
"to",
"the",
"dummy",
"outbox"
] | python | train |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L595-L598 | def create_serv_obj(self, tenant_id):
"""Creates and stores the service object associated with a tenant. """
self.service_attr[tenant_id] = ServiceIpSegTenantMap()
self.store_tenant_obj(tenant_id, self.service_attr[tenant_id]) | [
"def",
"create_serv_obj",
"(",
"self",
",",
"tenant_id",
")",
":",
"self",
".",
"service_attr",
"[",
"tenant_id",
"]",
"=",
"ServiceIpSegTenantMap",
"(",
")",
"self",
".",
"store_tenant_obj",
"(",
"tenant_id",
",",
"self",
".",
"service_attr",
"[",
"tenant_id"... | Creates and stores the service object associated with a tenant. | [
"Creates",
"and",
"stores",
"the",
"service",
"object",
"associated",
"with",
"a",
"tenant",
"."
] | python | train |
junzis/pyModeS | pyModeS/decoder/bds/bds20.py | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds20.py#L50-L73 | def cs20(msg):
"""Aircraft callsign
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
Returns:
string: callsign, max. 8 chars
"""
chars = '#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'
d = hex2bin(data(msg))
cs = ''
cs += chars[bin2in... | [
"def",
"cs20",
"(",
"msg",
")",
":",
"chars",
"=",
"'#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"cs",
"=",
"''",
"cs",
"+=",
"chars",
"[",
"bin2int",
"(",
"d",
"[",
"8",
":",
... | Aircraft callsign
Args:
msg (String): 28 bytes hexadecimal message (BDS40) string
Returns:
string: callsign, max. 8 chars | [
"Aircraft",
"callsign"
] | python | train |
Komnomnomnom/swigibpy | swigibpy.py | https://github.com/Komnomnomnom/swigibpy/blob/cfd307fdbfaffabc69a2dc037538d7e34a8b8daf/swigibpy.py#L2441-L2443 | def tickString(self, tickerId, tickType, value):
"""tickString(EWrapper self, TickerId tickerId, TickType tickType, IBString const & value)"""
return _swigibpy.EWrapper_tickString(self, tickerId, tickType, value) | [
"def",
"tickString",
"(",
"self",
",",
"tickerId",
",",
"tickType",
",",
"value",
")",
":",
"return",
"_swigibpy",
".",
"EWrapper_tickString",
"(",
"self",
",",
"tickerId",
",",
"tickType",
",",
"value",
")"
] | tickString(EWrapper self, TickerId tickerId, TickType tickType, IBString const & value) | [
"tickString",
"(",
"EWrapper",
"self",
"TickerId",
"tickerId",
"TickType",
"tickType",
"IBString",
"const",
"&",
"value",
")"
] | python | train |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L6089-L6096 | def saveFormatFileTo(self, cur, encoding, format):
"""Dump an XML document to an I/O buffer. Warning ! This call
xmlOutputBufferClose() on buf which is not available after
this call. """
if cur is None: cur__o = None
else: cur__o = cur._o
ret = libxml2mod.xmlSaveForm... | [
"def",
"saveFormatFileTo",
"(",
"self",
",",
"cur",
",",
"encoding",
",",
"format",
")",
":",
"if",
"cur",
"is",
"None",
":",
"cur__o",
"=",
"None",
"else",
":",
"cur__o",
"=",
"cur",
".",
"_o",
"ret",
"=",
"libxml2mod",
".",
"xmlSaveFormatFileTo",
"("... | Dump an XML document to an I/O buffer. Warning ! This call
xmlOutputBufferClose() on buf which is not available after
this call. | [
"Dump",
"an",
"XML",
"document",
"to",
"an",
"I",
"/",
"O",
"buffer",
".",
"Warning",
"!",
"This",
"call",
"xmlOutputBufferClose",
"()",
"on",
"buf",
"which",
"is",
"not",
"available",
"after",
"this",
"call",
"."
] | python | train |
wonambi-python/wonambi | wonambi/attr/annotations.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/attr/annotations.py#L1315-L1366 | def get_cycles(self):
"""Return the cycle start and end times.
Returns
-------
list of tuple of float
start and end times for each cycle, in seconds from recording start
and the cycle index starting at 1
"""
cycles = self.rater.find('cycles')
... | [
"def",
"get_cycles",
"(",
"self",
")",
":",
"cycles",
"=",
"self",
".",
"rater",
".",
"find",
"(",
"'cycles'",
")",
"if",
"not",
"cycles",
":",
"return",
"None",
"starts",
"=",
"sorted",
"(",
"[",
"float",
"(",
"mrkr",
".",
"text",
")",
"for",
"mrk... | Return the cycle start and end times.
Returns
-------
list of tuple of float
start and end times for each cycle, in seconds from recording start
and the cycle index starting at 1 | [
"Return",
"the",
"cycle",
"start",
"and",
"end",
"times",
"."
] | python | train |
noahbenson/neuropythy | neuropythy/geometry/mesh.py | https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/geometry/mesh.py#L2648-L2706 | def to_map_projection(arg, hemi=Ellipsis, chirality=Ellipsis,
center=Ellipsis, center_right=Ellipsis, radius=Ellipsis,
method=Ellipsis, registration=Ellipsis, sphere_radius=Ellipsis,
pre_affine=Ellipsis, post_affine=Ellipsis, meta_data=Ellipsis):
'''... | [
"def",
"to_map_projection",
"(",
"arg",
",",
"hemi",
"=",
"Ellipsis",
",",
"chirality",
"=",
"Ellipsis",
",",
"center",
"=",
"Ellipsis",
",",
"center_right",
"=",
"Ellipsis",
",",
"radius",
"=",
"Ellipsis",
",",
"method",
"=",
"Ellipsis",
",",
"registration"... | to_map_projection(mp) yields mp if mp is a map projection object.
to_map_projection((name, hemi)) is equivalent to map_projection(name, chirality=hemi).
to_map_projection((name, opts)) uses the given options dictionary as options to map_projection;
(name, hemi, opts) is also allowed as input.
to_map_p... | [
"to_map_projection",
"(",
"mp",
")",
"yields",
"mp",
"if",
"mp",
"is",
"a",
"map",
"projection",
"object",
".",
"to_map_projection",
"((",
"name",
"hemi",
"))",
"is",
"equivalent",
"to",
"map_projection",
"(",
"name",
"chirality",
"=",
"hemi",
")",
".",
"t... | python | train |
moonlitesolutions/SolrClient | SolrClient/indexq.py | https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L240-L279 | def complete(self, filepath):
'''
Marks the item as complete by moving it to the done directory and optionally gzipping it.
'''
if not os.path.exists(filepath):
raise FileNotFoundError("Can't Complete {}, it doesn't exist".format(filepath))
if self._devel: self.logger... | [
"def",
"complete",
"(",
"self",
",",
"filepath",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
":",
"raise",
"FileNotFoundError",
"(",
"\"Can't Complete {}, it doesn't exist\"",
".",
"format",
"(",
"filepath",
")",
")",
"if",... | Marks the item as complete by moving it to the done directory and optionally gzipping it. | [
"Marks",
"the",
"item",
"as",
"complete",
"by",
"moving",
"it",
"to",
"the",
"done",
"directory",
"and",
"optionally",
"gzipping",
"it",
"."
] | python | train |
Accelize/pycosio | pycosio/storage/oss.py | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L238-L250 | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_oss_error():
response = _oss.Service(
self.client, endpoint=self._endpoint).list_buckets()
for bucke... | [
"def",
"_list_locators",
"(",
"self",
")",
":",
"with",
"_handle_oss_error",
"(",
")",
":",
"response",
"=",
"_oss",
".",
"Service",
"(",
"self",
".",
"client",
",",
"endpoint",
"=",
"self",
".",
"_endpoint",
")",
".",
"list_buckets",
"(",
")",
"for",
... | Lists locators.
Returns:
generator of tuple: locator name str, locator header dict | [
"Lists",
"locators",
"."
] | python | train |
cloudmesh/cloudmesh-common | cloudmesh/common/ssh/authorized_keys.py | https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ssh/authorized_keys.py#L17-L40 | def get_fingerprint_from_public_key(pubkey):
"""Generate the fingerprint of a public key
:param str pubkey: the value of the public key
:returns: fingerprint
:rtype: str
"""
# TODO: why is there a tmpdir?
with tempdir() as workdir:
key = os.path.join(workdir, 'key.pub')
wit... | [
"def",
"get_fingerprint_from_public_key",
"(",
"pubkey",
")",
":",
"# TODO: why is there a tmpdir?",
"with",
"tempdir",
"(",
")",
"as",
"workdir",
":",
"key",
"=",
"os",
".",
"path",
".",
"join",
"(",
"workdir",
",",
"'key.pub'",
")",
"with",
"open",
"(",
"k... | Generate the fingerprint of a public key
:param str pubkey: the value of the public key
:returns: fingerprint
:rtype: str | [
"Generate",
"the",
"fingerprint",
"of",
"a",
"public",
"key"
] | python | train |
nilp0inter/cpe | cpe/comp/cpecomp_simple.py | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L367-L390 | def set_value(self, comp_str, comp_att):
"""
Set the value of component. By default, the component has a simple
value.
:param string comp_str: new value of component
:param string comp_att: attribute associated with value of component
:returns: None
:exception: V... | [
"def",
"set_value",
"(",
"self",
",",
"comp_str",
",",
"comp_att",
")",
":",
"old_value",
"=",
"self",
".",
"_encoded_value",
"self",
".",
"_encoded_value",
"=",
"comp_str",
"# Check the value of component",
"try",
":",
"self",
".",
"_parse",
"(",
"comp_att",
... | Set the value of component. By default, the component has a simple
value.
:param string comp_str: new value of component
:param string comp_att: attribute associated with value of component
:returns: None
:exception: ValueError - incorrect value of component | [
"Set",
"the",
"value",
"of",
"component",
".",
"By",
"default",
"the",
"component",
"has",
"a",
"simple",
"value",
"."
] | python | train |
sassoftware/saspy | saspy/sasets.py | https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasets.py#L153-L207 | def ucm(self, data: ['SASdata', str] = None,
autoreg: str = None,
blockseason: str = None,
by: str = None,
cycle: str = None,
deplag: str = None,
estimate: [str, bool] = None,
forecast: str = None,
id: str = None,
... | [
"def",
"ucm",
"(",
"self",
",",
"data",
":",
"[",
"'SASdata'",
",",
"str",
"]",
"=",
"None",
",",
"autoreg",
":",
"str",
"=",
"None",
",",
"blockseason",
":",
"str",
"=",
"None",
",",
"by",
":",
"str",
"=",
"None",
",",
"cycle",
":",
"str",
"="... | Python method to call the UCM procedure
Documentation link:
http://support.sas.com/documentation/cdl//en/etsug/68148/HTML/default/viewer.htm#etsug_ucm_syntax.htm
:param data: SASdata object or string. This parameter is required.
:parm autoreg: The autoreg variable can only be a string ... | [
"Python",
"method",
"to",
"call",
"the",
"UCM",
"procedure"
] | python | train |
Becksteinlab/GromacsWrapper | gromacs/utilities.py | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/utilities.py#L411-L435 | def in_dir(directory, create=True):
"""Context manager to execute a code block in a directory.
* The directory is created if it does not exist (unless
create=False is set)
* At the end or after an exception code always returns to
the directory that was the current directory before entering
... | [
"def",
"in_dir",
"(",
"directory",
",",
"create",
"=",
"True",
")",
":",
"startdir",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"try",
":",
"os",
".",
"chdir",
"(",
"directory",
")",
"logger",
".",
"debug",
"(",
"\"Working in {directory!r}...\"",
... | Context manager to execute a code block in a directory.
* The directory is created if it does not exist (unless
create=False is set)
* At the end or after an exception code always returns to
the directory that was the current directory before entering
the block. | [
"Context",
"manager",
"to",
"execute",
"a",
"code",
"block",
"in",
"a",
"directory",
"."
] | python | valid |
pypa/setuptools | setuptools/dist.py | https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/dist.py#L878-L898 | def include(self, **attrs):
"""Add items to distribution that are named in keyword arguments
For example, 'dist.include(py_modules=["x"])' would add 'x' to
the distribution's 'py_modules' attribute, if it was not already
there.
Currently, this method only supports inclusion for... | [
"def",
"include",
"(",
"self",
",",
"*",
"*",
"attrs",
")",
":",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"include",
"=",
"getattr",
"(",
"self",
",",
"'_include_'",
"+",
"k",
",",
"None",
")",
"if",
"include",
":",
"in... | Add items to distribution that are named in keyword arguments
For example, 'dist.include(py_modules=["x"])' would add 'x' to
the distribution's 'py_modules' attribute, if it was not already
there.
Currently, this method only supports inclusion for attributes that are
lists or t... | [
"Add",
"items",
"to",
"distribution",
"that",
"are",
"named",
"in",
"keyword",
"arguments"
] | python | train |
inasafe/inasafe | safe/common/utilities.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L488-L520 | def get_utm_epsg(longitude, latitude, crs=None):
"""Return epsg code of the utm zone according to X, Y coordinates.
By default, the CRS is EPSG:4326. If the CRS is provided, first X,Y will
be reprojected from the input CRS to WGS84.
The code is based on the code:
http://gis.stackexchange.com/quest... | [
"def",
"get_utm_epsg",
"(",
"longitude",
",",
"latitude",
",",
"crs",
"=",
"None",
")",
":",
"if",
"crs",
"is",
"None",
"or",
"crs",
".",
"authid",
"(",
")",
"==",
"'EPSG:4326'",
":",
"epsg",
"=",
"32600",
"if",
"latitude",
"<",
"0.0",
":",
"epsg",
... | Return epsg code of the utm zone according to X, Y coordinates.
By default, the CRS is EPSG:4326. If the CRS is provided, first X,Y will
be reprojected from the input CRS to WGS84.
The code is based on the code:
http://gis.stackexchange.com/questions/34401
:param longitude: The longitude.
:ty... | [
"Return",
"epsg",
"code",
"of",
"the",
"utm",
"zone",
"according",
"to",
"X",
"Y",
"coordinates",
"."
] | python | train |
saltstack/salt | salt/modules/virt.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5060-L5082 | def pool_start(name, **kwargs):
'''
Start a defined libvirt storage pool.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding de... | [
"def",
"pool_start",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"pool",
"."... | Start a defined libvirt storage pool.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
... | [
"Start",
"a",
"defined",
"libvirt",
"storage",
"pool",
"."
] | python | train |
loli/medpy | medpy/features/texture.py | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L33-L126 | def coarseness(image, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the coarseness of the texture.
Step1 At each pixel, compute six averages for the windows of size 2**k x 2**k,
k=0,1,...,5, around the pixel.
Step2 At each pixel, co... | [
"def",
"coarseness",
"(",
"image",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"# Step1: At each pixel (x,y), compute six averages for the windows",
"# of size 2**k x 2**k, k=0,1,...,5, around the pixel.",
"image",
"=",
"numpy",... | r"""
Takes a simple or multi-spectral image and returns the coarseness of the texture.
Step1 At each pixel, compute six averages for the windows of size 2**k x 2**k,
k=0,1,...,5, around the pixel.
Step2 At each pixel, compute absolute differences E between the pairs of non
o... | [
"r",
"Takes",
"a",
"simple",
"or",
"multi",
"-",
"spectral",
"image",
"and",
"returns",
"the",
"coarseness",
"of",
"the",
"texture",
".",
"Step1",
"At",
"each",
"pixel",
"compute",
"six",
"averages",
"for",
"the",
"windows",
"of",
"size",
"2",
"**",
"k",... | python | train |
ronaldguillen/wave | wave/validators.py | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/validators.py#L95-L109 | def enforce_required_fields(self, attrs):
"""
The `UniqueTogetherValidator` always forces an implied 'required'
state on the fields it applies to.
"""
if self.instance is not None:
return
missing = {
field_name: self.missing_message
fo... | [
"def",
"enforce_required_fields",
"(",
"self",
",",
"attrs",
")",
":",
"if",
"self",
".",
"instance",
"is",
"not",
"None",
":",
"return",
"missing",
"=",
"{",
"field_name",
":",
"self",
".",
"missing_message",
"for",
"field_name",
"in",
"self",
".",
"field... | The `UniqueTogetherValidator` always forces an implied 'required'
state on the fields it applies to. | [
"The",
"UniqueTogetherValidator",
"always",
"forces",
"an",
"implied",
"required",
"state",
"on",
"the",
"fields",
"it",
"applies",
"to",
"."
] | python | train |
redcap-tools/PyCap | redcap/project.py | https://github.com/redcap-tools/PyCap/blob/f44c9b62a4f62675aa609c06608663f37e12097e/redcap/project.py#L354-L382 | def backfill_fields(self, fields, forms):
"""
Properly backfill fields to explicitly request specific
keys. The issue is that >6.X servers *only* return requested fields
so to improve backwards compatiblity for PyCap clients, add specific fields
when required.
Parameters... | [
"def",
"backfill_fields",
"(",
"self",
",",
"fields",
",",
"forms",
")",
":",
"if",
"forms",
"and",
"not",
"fields",
":",
"new_fields",
"=",
"[",
"self",
".",
"def_field",
"]",
"elif",
"fields",
"and",
"self",
".",
"def_field",
"not",
"in",
"fields",
"... | Properly backfill fields to explicitly request specific
keys. The issue is that >6.X servers *only* return requested fields
so to improve backwards compatiblity for PyCap clients, add specific fields
when required.
Parameters
----------
fields: list
requested... | [
"Properly",
"backfill",
"fields",
"to",
"explicitly",
"request",
"specific",
"keys",
".",
"The",
"issue",
"is",
"that",
">",
"6",
".",
"X",
"servers",
"*",
"only",
"*",
"return",
"requested",
"fields",
"so",
"to",
"improve",
"backwards",
"compatiblity",
"for... | python | train |
TheGhouls/oct | oct/tools/results_to_csv.py | https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/tools/results_to_csv.py#L8-L49 | def to_csv(args):
"""Take a sqlite filled database of results and return a csv file
:param str result_file: the path of the sqlite database
:param str output_file: the path of the csv output file
:param str delimiter: the desired delimiter for the output csv file
"""
result_file = args.result_f... | [
"def",
"to_csv",
"(",
"args",
")",
":",
"result_file",
"=",
"args",
".",
"result_file",
"output_file",
"=",
"args",
".",
"output_file",
"delimiter",
"=",
"args",
".",
"delimiter",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"result_file",
")",
":... | Take a sqlite filled database of results and return a csv file
:param str result_file: the path of the sqlite database
:param str output_file: the path of the csv output file
:param str delimiter: the desired delimiter for the output csv file | [
"Take",
"a",
"sqlite",
"filled",
"database",
"of",
"results",
"and",
"return",
"a",
"csv",
"file"
] | python | train |
NYUCCL/psiTurk | psiturk/experiment.py | https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/experiment.py#L564-L593 | def update(uid=None):
"""
Save experiment data, which should be a JSON object and will be stored
after converting to string.
"""
app.logger.info("PUT /sync route with id: %s" % uid)
try:
user = Participant.query.\
filter(Participant.uniqueid == uid).\
one()
e... | [
"def",
"update",
"(",
"uid",
"=",
"None",
")",
":",
"app",
".",
"logger",
".",
"info",
"(",
"\"PUT /sync route with id: %s\"",
"%",
"uid",
")",
"try",
":",
"user",
"=",
"Participant",
".",
"query",
".",
"filter",
"(",
"Participant",
".",
"uniqueid",
"=="... | Save experiment data, which should be a JSON object and will be stored
after converting to string. | [
"Save",
"experiment",
"data",
"which",
"should",
"be",
"a",
"JSON",
"object",
"and",
"will",
"be",
"stored",
"after",
"converting",
"to",
"string",
"."
] | python | train |
JelleAalbers/multihist | multihist.py | https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L482-L486 | def central_likelihood(self, axis):
"""Returns new histogram with all values replaced by their central likelihoods along axis."""
result = self.cumulative_density(axis)
result.histogram = 1 - 2 * np.abs(result.histogram - 0.5)
return result | [
"def",
"central_likelihood",
"(",
"self",
",",
"axis",
")",
":",
"result",
"=",
"self",
".",
"cumulative_density",
"(",
"axis",
")",
"result",
".",
"histogram",
"=",
"1",
"-",
"2",
"*",
"np",
".",
"abs",
"(",
"result",
".",
"histogram",
"-",
"0.5",
"... | Returns new histogram with all values replaced by their central likelihoods along axis. | [
"Returns",
"new",
"histogram",
"with",
"all",
"values",
"replaced",
"by",
"their",
"central",
"likelihoods",
"along",
"axis",
"."
] | python | train |
django-extensions/django-extensions | django_extensions/management/commands/pipchecker.py | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/pipchecker.py#L116-L119 | def _urlopen_as_json(self, url, headers=None):
"""Shorcut for return contents as json"""
req = Request(url, headers=headers)
return json.loads(urlopen(req).read()) | [
"def",
"_urlopen_as_json",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
")",
":",
"req",
"=",
"Request",
"(",
"url",
",",
"headers",
"=",
"headers",
")",
"return",
"json",
".",
"loads",
"(",
"urlopen",
"(",
"req",
")",
".",
"read",
"(",
")... | Shorcut for return contents as json | [
"Shorcut",
"for",
"return",
"contents",
"as",
"json"
] | python | train |
oanda/v20-python | src/v20/instrument.py | https://github.com/oanda/v20-python/blob/f28192f4a31bce038cf6dfa302f5878bec192fe5/src/v20/instrument.py#L712-L816 | def price(
self,
instrument,
**kwargs
):
"""
Fetch a price for an instrument. Accounts are not associated in any way
with this endpoint.
Args:
instrument:
Name of the Instrument
time:
The time at which t... | [
"def",
"price",
"(",
"self",
",",
"instrument",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
"=",
"Request",
"(",
"'GET'",
",",
"'/v3/instruments/{instrument}/price'",
")",
"request",
".",
"set_path_param",
"(",
"'instrument'",
",",
"instrument",
")",
"reques... | Fetch a price for an instrument. Accounts are not associated in any way
with this endpoint.
Args:
instrument:
Name of the Instrument
time:
The time at which the desired price is in effect. The current
price is returned if no time i... | [
"Fetch",
"a",
"price",
"for",
"an",
"instrument",
".",
"Accounts",
"are",
"not",
"associated",
"in",
"any",
"way",
"with",
"this",
"endpoint",
"."
] | python | train |
klen/muffin-debugtoolbar | muffin_debugtoolbar/panels.py | https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/panels.py#L57-L66 | def render_content(self):
"""Render the panel's content."""
if not self.has_content:
return ""
template = self.template
if isinstance(self.template, str):
template = self.app.ps.jinja2.env.get_template(self.template)
context = self.render_vars()
co... | [
"def",
"render_content",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_content",
":",
"return",
"\"\"",
"template",
"=",
"self",
".",
"template",
"if",
"isinstance",
"(",
"self",
".",
"template",
",",
"str",
")",
":",
"template",
"=",
"self",
"... | Render the panel's content. | [
"Render",
"the",
"panel",
"s",
"content",
"."
] | python | train |
zhmcclient/python-zhmcclient | zhmcclient_mock/_urihandler.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient_mock/_urihandler.py#L2291-L2309 | def get(method, hmc, uri, uri_parms, logon_required):
"""Operation: List Logical Partitions of CPC (empty result in DPM
mode."""
cpc_oid = uri_parms[0]
query_str = uri_parms[1]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise Inval... | [
"def",
"get",
"(",
"method",
",",
"hmc",
",",
"uri",
",",
"uri_parms",
",",
"logon_required",
")",
":",
"cpc_oid",
"=",
"uri_parms",
"[",
"0",
"]",
"query_str",
"=",
"uri_parms",
"[",
"1",
"]",
"try",
":",
"cpc",
"=",
"hmc",
".",
"cpcs",
".",
"look... | Operation: List Logical Partitions of CPC (empty result in DPM
mode. | [
"Operation",
":",
"List",
"Logical",
"Partitions",
"of",
"CPC",
"(",
"empty",
"result",
"in",
"DPM",
"mode",
"."
] | python | train |
deepmipt/DeepPavlov | deeppavlov/models/classifiers/utils.py | https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/models/classifiers/utils.py#L24-L49 | def labels2onehot(labels: [List[str], List[List[str]], np.ndarray], classes: [list, np.ndarray]) -> np.ndarray:
"""
Convert labels to one-hot vectors for multi-class multi-label classification
Args:
labels: list of samples where each sample is a class or a list of classes which sample belongs with... | [
"def",
"labels2onehot",
"(",
"labels",
":",
"[",
"List",
"[",
"str",
"]",
",",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"np",
".",
"ndarray",
"]",
",",
"classes",
":",
"[",
"list",
",",
"np",
".",
"ndarray",
"]",
")",
"->",
"np",
".",
... | Convert labels to one-hot vectors for multi-class multi-label classification
Args:
labels: list of samples where each sample is a class or a list of classes which sample belongs with
classes: array of classes' names
Returns:
2d array with one-hot representation of given samples | [
"Convert",
"labels",
"to",
"one",
"-",
"hot",
"vectors",
"for",
"multi",
"-",
"class",
"multi",
"-",
"label",
"classification"
] | python | test |
addisonlynch/iexfinance | iexfinance/__init__.py | https://github.com/addisonlynch/iexfinance/blob/40f0bdcc51b329031d06178020fd774494250456/iexfinance/__init__.py#L202-L208 | def get_stats_monthly(start=None, end=None, **kwargs):
"""
MOVED to iexfinance.iexdata.get_stats_summary
"""
import warnings
warnings.warn(WNG_MSG % ("get_stats_monthly", "iexdata.get_stats_summary"))
return MonthlySummaryReader(start=start, end=end, **kwargs).fetch() | [
"def",
"get_stats_monthly",
"(",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"warnings",
"warnings",
".",
"warn",
"(",
"WNG_MSG",
"%",
"(",
"\"get_stats_monthly\"",
",",
"\"iexdata.get_stats_summary\"",
")",
")... | MOVED to iexfinance.iexdata.get_stats_summary | [
"MOVED",
"to",
"iexfinance",
".",
"iexdata",
".",
"get_stats_summary"
] | python | train |
secdev/scapy | scapy/arch/windows/__init__.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L686-L694 | def dev_from_name(self, name):
"""Return the first pcap device name for a given Windows
device name.
"""
try:
return next(iface for iface in six.itervalues(self)
if (iface.name == name or iface.description == name))
except (StopIteration, Runti... | [
"def",
"dev_from_name",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"return",
"next",
"(",
"iface",
"for",
"iface",
"in",
"six",
".",
"itervalues",
"(",
"self",
")",
"if",
"(",
"iface",
".",
"name",
"==",
"name",
"or",
"iface",
".",
"description"... | Return the first pcap device name for a given Windows
device name. | [
"Return",
"the",
"first",
"pcap",
"device",
"name",
"for",
"a",
"given",
"Windows",
"device",
"name",
"."
] | python | train |
BYU-PCCL/holodeck | holodeck/agents.py | https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/agents.py#L79-L98 | def teleport(self, location=None, rotation=None):
"""Teleports the agent to a specific location, with a specific rotation.
Args:
location (np.ndarray, optional): An array with three elements specifying the target world coordinate in meters.
If None, keeps the current location. D... | [
"def",
"teleport",
"(",
"self",
",",
"location",
"=",
"None",
",",
"rotation",
"=",
"None",
")",
":",
"val",
"=",
"0",
"if",
"location",
"is",
"not",
"None",
":",
"val",
"+=",
"1",
"np",
".",
"copyto",
"(",
"self",
".",
"_teleport_buffer",
",",
"lo... | Teleports the agent to a specific location, with a specific rotation.
Args:
location (np.ndarray, optional): An array with three elements specifying the target world coordinate in meters.
If None, keeps the current location. Defaults to None.
rotation (np.ndarray, optional):... | [
"Teleports",
"the",
"agent",
"to",
"a",
"specific",
"location",
"with",
"a",
"specific",
"rotation",
"."
] | python | train |
h2oai/h2o-3 | h2o-py/h2o/estimators/estimator_base.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/estimators/estimator_base.py#L325-L350 | def fit(self, X, y=None, **params):
"""
Fit an H2O model as part of a scikit-learn pipeline or grid search.
A warning will be issued if a caller other than sklearn attempts to use this method.
:param H2OFrame X: An H2OFrame consisting of the predictor variables.
:param H2OFrame... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"stk",
"=",
"inspect",
".",
"stack",
"(",
")",
"[",
"1",
":",
"]",
"warn",
"=",
"True",
"for",
"s",
"in",
"stk",
":",
"mod",
"=",
"inspect",
".",... | Fit an H2O model as part of a scikit-learn pipeline or grid search.
A warning will be issued if a caller other than sklearn attempts to use this method.
:param H2OFrame X: An H2OFrame consisting of the predictor variables.
:param H2OFrame y: An H2OFrame consisting of the response variable.
... | [
"Fit",
"an",
"H2O",
"model",
"as",
"part",
"of",
"a",
"scikit",
"-",
"learn",
"pipeline",
"or",
"grid",
"search",
"."
] | python | test |
bram85/topydo | topydo/lib/ChangeSet.py | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/ChangeSet.py#L121-L134 | def delete(self, p_timestamp=None, p_write=True):
""" Removes backup from the backup file. """
timestamp = p_timestamp or self.timestamp
index = self._get_index()
try:
del self.backup_dict[timestamp]
index.remove(index[[change[0] for change in index].index(timest... | [
"def",
"delete",
"(",
"self",
",",
"p_timestamp",
"=",
"None",
",",
"p_write",
"=",
"True",
")",
":",
"timestamp",
"=",
"p_timestamp",
"or",
"self",
".",
"timestamp",
"index",
"=",
"self",
".",
"_get_index",
"(",
")",
"try",
":",
"del",
"self",
".",
... | Removes backup from the backup file. | [
"Removes",
"backup",
"from",
"the",
"backup",
"file",
"."
] | python | train |
Autodesk/aomi | aomi/cli.py | https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/cli.py#L403-L411 | def do_thaw(client, args):
"""Execute the thaw operation, pulling in an actual Vault
client if neccesary"""
vault_client = None
if args.gpg_pass_path:
vault_client = client.connect(args)
aomi.filez.thaw(vault_client, args.icefile, args)
sys.exit(0) | [
"def",
"do_thaw",
"(",
"client",
",",
"args",
")",
":",
"vault_client",
"=",
"None",
"if",
"args",
".",
"gpg_pass_path",
":",
"vault_client",
"=",
"client",
".",
"connect",
"(",
"args",
")",
"aomi",
".",
"filez",
".",
"thaw",
"(",
"vault_client",
",",
... | Execute the thaw operation, pulling in an actual Vault
client if neccesary | [
"Execute",
"the",
"thaw",
"operation",
"pulling",
"in",
"an",
"actual",
"Vault",
"client",
"if",
"neccesary"
] | python | train |
wandb/client | wandb/vendor/prompt_toolkit/interface.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/interface.py#L574-L593 | def abort(self):
"""
Set abort. When Control-C has been pressed.
"""
on_abort = self.application.on_abort
self._abort_flag = True
self._redraw()
if on_abort == AbortAction.RAISE_EXCEPTION:
def keyboard_interrupt():
raise KeyboardInterr... | [
"def",
"abort",
"(",
"self",
")",
":",
"on_abort",
"=",
"self",
".",
"application",
".",
"on_abort",
"self",
".",
"_abort_flag",
"=",
"True",
"self",
".",
"_redraw",
"(",
")",
"if",
"on_abort",
"==",
"AbortAction",
".",
"RAISE_EXCEPTION",
":",
"def",
"ke... | Set abort. When Control-C has been pressed. | [
"Set",
"abort",
".",
"When",
"Control",
"-",
"C",
"has",
"been",
"pressed",
"."
] | python | train |
sendwithus/sendwithus_python | sendwithus/__init__.py | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L470-L566 | def send(
self,
email_id,
recipient,
email_data=None,
sender=None,
cc=None,
bcc=None,
tags=[],
headers={},
esp_account=None,
locale=None,
email_version_name=None,
inline=None,
files=[],
timeout=None
... | [
"def",
"send",
"(",
"self",
",",
"email_id",
",",
"recipient",
",",
"email_data",
"=",
"None",
",",
"sender",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"tags",
"=",
"[",
"]",
",",
"headers",
"=",
"{",
"}",
",",
"esp_accou... | API call to send an email | [
"API",
"call",
"to",
"send",
"an",
"email"
] | python | valid |
mikedh/trimesh | trimesh/base.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/base.py#L2485-L2501 | def intersection(self, other, engine=None):
"""
Boolean intersection between this mesh and n other meshes
Parameters
---------
other : trimesh.Trimesh, or list of trimesh.Trimesh objects
Meshes to calculate intersections with
Returns
---------
... | [
"def",
"intersection",
"(",
"self",
",",
"other",
",",
"engine",
"=",
"None",
")",
":",
"result",
"=",
"boolean",
".",
"intersection",
"(",
"meshes",
"=",
"np",
".",
"append",
"(",
"self",
",",
"other",
")",
",",
"engine",
"=",
"engine",
")",
"return... | Boolean intersection between this mesh and n other meshes
Parameters
---------
other : trimesh.Trimesh, or list of trimesh.Trimesh objects
Meshes to calculate intersections with
Returns
---------
intersection : trimesh.Trimesh
Mesh of the volume cont... | [
"Boolean",
"intersection",
"between",
"this",
"mesh",
"and",
"n",
"other",
"meshes"
] | python | train |
elliterate/capybara.py | capybara/result.py | https://github.com/elliterate/capybara.py/blob/0c6ae449cc37e4445ec3cd6af95674533beedc6c/capybara/result.py#L54-L89 | def compare_count(self):
"""
Returns how the result count compares to the query options.
The return value is negative if too few results were found, zero if enough were found, and
positive if too many were found.
Returns:
int: -1, 0, or 1.
"""
if se... | [
"def",
"compare_count",
"(",
"self",
")",
":",
"if",
"self",
".",
"query",
".",
"options",
"[",
"\"count\"",
"]",
"is",
"not",
"None",
":",
"count_opt",
"=",
"int",
"(",
"self",
".",
"query",
".",
"options",
"[",
"\"count\"",
"]",
")",
"self",
".",
... | Returns how the result count compares to the query options.
The return value is negative if too few results were found, zero if enough were found, and
positive if too many were found.
Returns:
int: -1, 0, or 1. | [
"Returns",
"how",
"the",
"result",
"count",
"compares",
"to",
"the",
"query",
"options",
"."
] | python | test |
saltstack/salt | salt/netapi/rest_tornado/__init__.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/__init__.py#L87-L133 | def start():
'''
Start the saltnado!
'''
mod_opts = __opts__.get(__virtualname__, {})
if 'num_processes' not in mod_opts:
mod_opts['num_processes'] = 1
if mod_opts['num_processes'] > 1 and mod_opts.get('debug', False) is True:
raise Exception((
'Tornado\'s debug imp... | [
"def",
"start",
"(",
")",
":",
"mod_opts",
"=",
"__opts__",
".",
"get",
"(",
"__virtualname__",
",",
"{",
"}",
")",
"if",
"'num_processes'",
"not",
"in",
"mod_opts",
":",
"mod_opts",
"[",
"'num_processes'",
"]",
"=",
"1",
"if",
"mod_opts",
"[",
"'num_pro... | Start the saltnado! | [
"Start",
"the",
"saltnado!"
] | python | train |
samastur/pyimagediet | pyimagediet/process.py | https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L171-L192 | def backup_file(filename, backup_ext):
'''
Make a file backup if:
- backup extension is defined
- backup file does not exist yet
If backup file exists:
- do nothing if it is same
- complain loudly otherwise
Return file name of the back up if successful. None otherwise.
'''
ext =... | [
"def",
"backup_file",
"(",
"filename",
",",
"backup_ext",
")",
":",
"ext",
"=",
"backup_ext",
".",
"strip",
"(",
"\" .\"",
")",
"if",
"ext",
":",
"backup_filename",
"=",
"\".\"",
".",
"join",
"(",
"[",
"filename",
",",
"ext",
"]",
")",
"if",
"not",
"... | Make a file backup if:
- backup extension is defined
- backup file does not exist yet
If backup file exists:
- do nothing if it is same
- complain loudly otherwise
Return file name of the back up if successful. None otherwise. | [
"Make",
"a",
"file",
"backup",
"if",
":",
"-",
"backup",
"extension",
"is",
"defined",
"-",
"backup",
"file",
"does",
"not",
"exist",
"yet",
"If",
"backup",
"file",
"exists",
":",
"-",
"do",
"nothing",
"if",
"it",
"is",
"same",
"-",
"complain",
"loudly... | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/core/completerlib.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/completerlib.py#L192-L221 | def module_completion(line):
"""
Returns a list containing the completion possibilities for an import line.
The line looks like this :
'import xml.d'
'from xml.dom import'
"""
words = line.split(' ')
nwords = len(words)
# from whatever <tab> -> 'import '
if nwords == 3 and wor... | [
"def",
"module_completion",
"(",
"line",
")",
":",
"words",
"=",
"line",
".",
"split",
"(",
"' '",
")",
"nwords",
"=",
"len",
"(",
"words",
")",
"# from whatever <tab> -> 'import '",
"if",
"nwords",
"==",
"3",
"and",
"words",
"[",
"0",
"]",
"==",
"'from'... | Returns a list containing the completion possibilities for an import line.
The line looks like this :
'import xml.d'
'from xml.dom import' | [
"Returns",
"a",
"list",
"containing",
"the",
"completion",
"possibilities",
"for",
"an",
"import",
"line",
"."
] | python | test |
smarie/python-parsyfiles | parsyfiles/type_inspection_tools.py | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/type_inspection_tools.py#L395-L409 | def is_pep484_nonable(typ):
"""
Checks if a given type is nonable, meaning that it explicitly or implicitly declares a Union with NoneType.
Nested TypeVars and Unions are supported.
:param typ:
:return:
"""
# TODO rely on typing_inspect if there is an answer to https://github.com/ilevkivsky... | [
"def",
"is_pep484_nonable",
"(",
"typ",
")",
":",
"# TODO rely on typing_inspect if there is an answer to https://github.com/ilevkivskyi/typing_inspect/issues/14",
"if",
"typ",
"is",
"type",
"(",
"None",
")",
":",
"return",
"True",
"elif",
"is_typevar",
"(",
"typ",
")",
"... | Checks if a given type is nonable, meaning that it explicitly or implicitly declares a Union with NoneType.
Nested TypeVars and Unions are supported.
:param typ:
:return: | [
"Checks",
"if",
"a",
"given",
"type",
"is",
"nonable",
"meaning",
"that",
"it",
"explicitly",
"or",
"implicitly",
"declares",
"a",
"Union",
"with",
"NoneType",
".",
"Nested",
"TypeVars",
"and",
"Unions",
"are",
"supported",
"."
] | python | train |
mbi/django-simple-captcha | captcha/fields.py | https://github.com/mbi/django-simple-captcha/blob/e96cd8f63e41e658d103d12d6486b34195aee555/captcha/fields.py#L127-L132 | def get_context(self, name, value, attrs):
"""Add captcha specific variables to context."""
context = super(CaptchaTextInput, self).get_context(name, value, attrs)
context['image'] = self.image_url()
context['audio'] = self.audio_url()
return context | [
"def",
"get_context",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
")",
":",
"context",
"=",
"super",
"(",
"CaptchaTextInput",
",",
"self",
")",
".",
"get_context",
"(",
"name",
",",
"value",
",",
"attrs",
")",
"context",
"[",
"'image'",
"]",
... | Add captcha specific variables to context. | [
"Add",
"captcha",
"specific",
"variables",
"to",
"context",
"."
] | python | train |
saltstack/salt | salt/modules/xbpspkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xbpspkg.py#L533-L575 | def _locate_repo_files(repo, rewrite=False):
'''
Find what file a repo is called in.
Helper function for add_repo() and del_repo()
repo
url of the repo to locate (persistent).
rewrite
Whether to remove matching repository settings during this process.
Returns a list of absolu... | [
"def",
"_locate_repo_files",
"(",
"repo",
",",
"rewrite",
"=",
"False",
")",
":",
"ret_val",
"=",
"[",
"]",
"files",
"=",
"[",
"]",
"conf_dirs",
"=",
"[",
"'/etc/xbps.d/'",
",",
"'/usr/share/xbps.d/'",
"]",
"name_glob",
"=",
"'*.conf'",
"# Matches a line where... | Find what file a repo is called in.
Helper function for add_repo() and del_repo()
repo
url of the repo to locate (persistent).
rewrite
Whether to remove matching repository settings during this process.
Returns a list of absolute paths. | [
"Find",
"what",
"file",
"a",
"repo",
"is",
"called",
"in",
"."
] | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/thread.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/thread.py#L1036-L1059 | def get_seh_chain(self):
"""
@rtype: list of tuple( int, int )
@return: List of structured exception handlers.
Each SEH is represented as a tuple of two addresses:
- Address of this SEH block
- Address of the SEH callback function
Do not c... | [
"def",
"get_seh_chain",
"(",
"self",
")",
":",
"seh_chain",
"=",
"list",
"(",
")",
"try",
":",
"process",
"=",
"self",
".",
"get_process",
"(",
")",
"seh",
"=",
"self",
".",
"get_seh_chain_pointer",
"(",
")",
"while",
"seh",
"!=",
"0xFFFFFFFF",
":",
"s... | @rtype: list of tuple( int, int )
@return: List of structured exception handlers.
Each SEH is represented as a tuple of two addresses:
- Address of this SEH block
- Address of the SEH callback function
Do not confuse this with the contents of the SEH bloc... | [
"@rtype",
":",
"list",
"of",
"tuple",
"(",
"int",
"int",
")",
"@return",
":",
"List",
"of",
"structured",
"exception",
"handlers",
".",
"Each",
"SEH",
"is",
"represented",
"as",
"a",
"tuple",
"of",
"two",
"addresses",
":",
"-",
"Address",
"of",
"this",
... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.