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 |
|---|---|---|---|---|---|---|---|---|
kyuupichan/aiorpcX | aiorpcx/socks.py | https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/socks.py#L380-L393 | async def auto_detect_at_host(cls, host, ports, auth):
'''Try to detect a SOCKS proxy on a host on one of the ports.
Calls auto_detect_address for the ports in order. Returning a SOCKSProxy does not
mean it is functioning - for example, it may have no network connectivity.
If no proxy... | [
"async",
"def",
"auto_detect_at_host",
"(",
"cls",
",",
"host",
",",
"ports",
",",
"auth",
")",
":",
"for",
"port",
"in",
"ports",
":",
"proxy",
"=",
"await",
"cls",
".",
"auto_detect_at_address",
"(",
"NetAddress",
"(",
"host",
",",
"port",
")",
",",
... | Try to detect a SOCKS proxy on a host on one of the ports.
Calls auto_detect_address for the ports in order. Returning a SOCKSProxy does not
mean it is functioning - for example, it may have no network connectivity.
If no proxy is detected return None. | [
"Try",
"to",
"detect",
"a",
"SOCKS",
"proxy",
"on",
"a",
"host",
"on",
"one",
"of",
"the",
"ports",
"."
] | python | train |
jamesturk/django-honeypot | honeypot/decorators.py | https://github.com/jamesturk/django-honeypot/blob/4b149bfca81828eaf418b5a6854e670d156f5e35/honeypot/decorators.py#L36-L60 | def check_honeypot(func=None, field_name=None):
"""
Check request.POST for valid honeypot field.
Takes an optional field_name that defaults to HONEYPOT_FIELD_NAME if
not specified.
"""
# hack to reverse arguments if called with str param
if isinstance(func, six.string_types):
... | [
"def",
"check_honeypot",
"(",
"func",
"=",
"None",
",",
"field_name",
"=",
"None",
")",
":",
"# hack to reverse arguments if called with str param",
"if",
"isinstance",
"(",
"func",
",",
"six",
".",
"string_types",
")",
":",
"func",
",",
"field_name",
"=",
"fiel... | Check request.POST for valid honeypot field.
Takes an optional field_name that defaults to HONEYPOT_FIELD_NAME if
not specified. | [
"Check",
"request",
".",
"POST",
"for",
"valid",
"honeypot",
"field",
"."
] | python | train |
mardix/Mocha | mocha/contrib/auth/models.py | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/models.py#L180-L189 | def search_by_name(cls, query, name):
"""
Make a search
:param query:
:param name:
:return:
"""
query = query.filter(db.or_(cls.first_name.contains(name),
cls.last_name.contains(name)))
return query | [
"def",
"search_by_name",
"(",
"cls",
",",
"query",
",",
"name",
")",
":",
"query",
"=",
"query",
".",
"filter",
"(",
"db",
".",
"or_",
"(",
"cls",
".",
"first_name",
".",
"contains",
"(",
"name",
")",
",",
"cls",
".",
"last_name",
".",
"contains",
... | Make a search
:param query:
:param name:
:return: | [
"Make",
"a",
"search",
":",
"param",
"query",
":",
":",
"param",
"name",
":",
":",
"return",
":"
] | python | train |
tijme/not-your-average-web-crawler | nyawc/helpers/RandomInputHelper.py | https://github.com/tijme/not-your-average-web-crawler/blob/d77c14e1616c541bb3980f649a7e6f8ed02761fb/nyawc/helpers/RandomInputHelper.py#L142-L161 | def get_random_email(ltd="com"):
"""Get a random email address with the given ltd.
Args:
ltd (str): The ltd to use (e.g. com).
Returns:
str: The random email.
"""
email = [
RandomInputHelper.get_random_value(6, [string.ascii_lowercase]),
... | [
"def",
"get_random_email",
"(",
"ltd",
"=",
"\"com\"",
")",
":",
"email",
"=",
"[",
"RandomInputHelper",
".",
"get_random_value",
"(",
"6",
",",
"[",
"string",
".",
"ascii_lowercase",
"]",
")",
",",
"\"@\"",
",",
"RandomInputHelper",
".",
"get_random_value",
... | Get a random email address with the given ltd.
Args:
ltd (str): The ltd to use (e.g. com).
Returns:
str: The random email. | [
"Get",
"a",
"random",
"email",
"address",
"with",
"the",
"given",
"ltd",
"."
] | python | train |
pvlib/pvlib-python | pvlib/forecast.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/forecast.py#L504-L537 | def cloud_cover_to_irradiance_liujordan(self, cloud_cover, **kwargs):
"""
Estimates irradiance from cloud cover in the following steps:
1. Determine transmittance using a function of cloud cover e.g.
:py:meth:`~ForecastModel.cloud_cover_to_transmittance_linear`
2. Calculate G... | [
"def",
"cloud_cover_to_irradiance_liujordan",
"(",
"self",
",",
"cloud_cover",
",",
"*",
"*",
"kwargs",
")",
":",
"# in principle, get_solarposition could use the forecast",
"# pressure, temp, etc., but the cloud cover forecast is not",
"# accurate enough to justify using these minor cor... | Estimates irradiance from cloud cover in the following steps:
1. Determine transmittance using a function of cloud cover e.g.
:py:meth:`~ForecastModel.cloud_cover_to_transmittance_linear`
2. Calculate GHI, DNI, DHI using the
:py:func:`pvlib.irradiance.liujordan` model
Par... | [
"Estimates",
"irradiance",
"from",
"cloud",
"cover",
"in",
"the",
"following",
"steps",
":"
] | python | train |
LIVVkit/LIVVkit | livvkit/bundles/CISM_glissade/verification.py | https://github.com/LIVVkit/LIVVkit/blob/680120cd437e408673e62e535fc0a246c7fc17db/livvkit/bundles/CISM_glissade/verification.py#L43-L102 | def parse_log(file_path):
"""
Parse a CISM output log and extract some information.
Args:
file_path: absolute path to the log file
Return:
A dictionary created by the elements object corresponding to
the results of the bit for bit testing
"""
if not os.path.isfile(file_... | [
"def",
"parse_log",
"(",
"file_path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"file_path",
")",
":",
"return",
"elements",
".",
"error",
"(",
"\"Output Log\"",
",",
"\"Could not open file: \"",
"+",
"file_path",
".",
"split",
"(",
"os... | Parse a CISM output log and extract some information.
Args:
file_path: absolute path to the log file
Return:
A dictionary created by the elements object corresponding to
the results of the bit for bit testing | [
"Parse",
"a",
"CISM",
"output",
"log",
"and",
"extract",
"some",
"information",
"."
] | python | train |
umich-brcf-bioinf/Jacquard | jacquard/variant_caller_transforms/mutect.py | https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/variant_caller_transforms/mutect.py#L253-L278 | def _get_new_column_header(self, vcf_reader):
"""Returns a standardized column header.
MuTect sample headers include the name of input alignment, which is
nice, but doesn't match up with the sample names reported in Strelka
or VarScan. To fix this, we replace with NORMAL and TUMOR using... | [
"def",
"_get_new_column_header",
"(",
"self",
",",
"vcf_reader",
")",
":",
"mutect_dict",
"=",
"self",
".",
"_build_mutect_dict",
"(",
"vcf_reader",
".",
"metaheaders",
")",
"new_header_list",
"=",
"[",
"]",
"required_keys",
"=",
"set",
"(",
"[",
"self",
".",
... | Returns a standardized column header.
MuTect sample headers include the name of input alignment, which is
nice, but doesn't match up with the sample names reported in Strelka
or VarScan. To fix this, we replace with NORMAL and TUMOR using the
MuTect metadata command line to replace them... | [
"Returns",
"a",
"standardized",
"column",
"header",
"."
] | python | test |
dw/mitogen | mitogen/core.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/core.py#L381-L388 | def has_parent_authority(msg, _stream=None):
"""Policy function for use with :class:`Receiver` and
:meth:`Router.add_handler` that requires incoming messages to originate
from a parent context, or on a :class:`Stream` whose :attr:`auth_id
<Stream.auth_id>` has been set to that of a parent context or the... | [
"def",
"has_parent_authority",
"(",
"msg",
",",
"_stream",
"=",
"None",
")",
":",
"return",
"(",
"msg",
".",
"auth_id",
"==",
"mitogen",
".",
"context_id",
"or",
"msg",
".",
"auth_id",
"in",
"mitogen",
".",
"parent_ids",
")"
] | Policy function for use with :class:`Receiver` and
:meth:`Router.add_handler` that requires incoming messages to originate
from a parent context, or on a :class:`Stream` whose :attr:`auth_id
<Stream.auth_id>` has been set to that of a parent context or the current
context. | [
"Policy",
"function",
"for",
"use",
"with",
":",
"class",
":",
"Receiver",
"and",
":",
"meth",
":",
"Router",
".",
"add_handler",
"that",
"requires",
"incoming",
"messages",
"to",
"originate",
"from",
"a",
"parent",
"context",
"or",
"on",
"a",
":",
"class"... | python | train |
profitbricks/profitbricks-sdk-python | examples/pb_snapshotDatacenter.py | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_snapshotDatacenter.py#L393-L588 | def main(argv=None):
'''Parse command line options and dump a datacenter to snapshots and file.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated_... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"else",
":",
"sys",
".",
"argv",
".",
"extend",
"(",
"argv",
")",
"program_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
... | Parse command line options and dump a datacenter to snapshots and file. | [
"Parse",
"command",
"line",
"options",
"and",
"dump",
"a",
"datacenter",
"to",
"snapshots",
"and",
"file",
"."
] | python | valid |
gunthercox/ChatterBot | chatterbot/trainers.py | https://github.com/gunthercox/ChatterBot/blob/1a03dcb45cba7bdc24d3db5e750582e0cb1518e2/chatterbot/trainers.py#L66-L74 | def export_for_training(self, file_path='./export.json'):
"""
Create a file from the database that can be used to
train other chat bots.
"""
import json
export = {'conversations': self._generate_export_data()}
with open(file_path, 'w+') as jsonfile:
js... | [
"def",
"export_for_training",
"(",
"self",
",",
"file_path",
"=",
"'./export.json'",
")",
":",
"import",
"json",
"export",
"=",
"{",
"'conversations'",
":",
"self",
".",
"_generate_export_data",
"(",
")",
"}",
"with",
"open",
"(",
"file_path",
",",
"'w+'",
"... | Create a file from the database that can be used to
train other chat bots. | [
"Create",
"a",
"file",
"from",
"the",
"database",
"that",
"can",
"be",
"used",
"to",
"train",
"other",
"chat",
"bots",
"."
] | python | train |
ligyxy/DictMySQL | dictmysql.py | https://github.com/ligyxy/DictMySQL/blob/f40d649193ccf58d1c7933189be1042b37afbe31/dictmysql.py#L99-L117 | def _value_parser(self, value, columnname=False, placeholder='%s'):
"""
Input: {'c1': 'v', 'c2': None, '#c3': 'uuid()'}
Output:
('%s, %s, uuid()', [None, 'v']) # insert; columnname=False
('`c2` = %s, `c1` = %s, `c3` = uuid()', [None, 'v']) # upd... | [
"def",
"_value_parser",
"(",
"self",
",",
"value",
",",
"columnname",
"=",
"False",
",",
"placeholder",
"=",
"'%s'",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"'Input value should be a dictionary'",
... | Input: {'c1': 'v', 'c2': None, '#c3': 'uuid()'}
Output:
('%s, %s, uuid()', [None, 'v']) # insert; columnname=False
('`c2` = %s, `c1` = %s, `c3` = uuid()', [None, 'v']) # update; columnname=True
No need to transform NULL value since it's supported in exe... | [
"Input",
":",
"{",
"c1",
":",
"v",
"c2",
":",
"None",
"#c3",
":",
"uuid",
"()",
"}",
"Output",
":",
"(",
"%s",
"%s",
"uuid",
"()",
"[",
"None",
"v",
"]",
")",
"#",
"insert",
";",
"columnname",
"=",
"False",
"(",
"c2",
"=",
"%s",
"c1",
"=",
... | python | train |
zyga/python-glibc | pyglibc/_signalfd.py | https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/pyglibc/_signalfd.py#L182-L200 | def update(self, signals):
"""
Update the mask of signals this signalfd reacts to
:param signals:
A replacement set of signal numbers to monitor
:raises ValueError:
If :meth:`closed()` is True
"""
if self._sfd < 0:
_err_closed()
... | [
"def",
"update",
"(",
"self",
",",
"signals",
")",
":",
"if",
"self",
".",
"_sfd",
"<",
"0",
":",
"_err_closed",
"(",
")",
"mask",
"=",
"sigset_t",
"(",
")",
"sigemptyset",
"(",
"mask",
")",
"if",
"signals",
"is",
"not",
"None",
":",
"for",
"signal... | Update the mask of signals this signalfd reacts to
:param signals:
A replacement set of signal numbers to monitor
:raises ValueError:
If :meth:`closed()` is True | [
"Update",
"the",
"mask",
"of",
"signals",
"this",
"signalfd",
"reacts",
"to"
] | python | train |
saeschdivara/ArangoPy | arangodb/api.py | https://github.com/saeschdivara/ArangoPy/blob/b924cc57bed71520fc2ef528b917daeb98e10eca/arangodb/api.py#L145-L164 | def remove(cls, name):
"""
Destroys the database.
"""
client = Client.instance()
new_current_database = None
if client.database != name:
new_current_database = name
# Deletions are only possible from the system database
client.set_datab... | [
"def",
"remove",
"(",
"cls",
",",
"name",
")",
":",
"client",
"=",
"Client",
".",
"instance",
"(",
")",
"new_current_database",
"=",
"None",
"if",
"client",
".",
"database",
"!=",
"name",
":",
"new_current_database",
"=",
"name",
"# Deletions are only possible... | Destroys the database. | [
"Destroys",
"the",
"database",
"."
] | python | train |
coleifer/irc | irc.py | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L176-L185 | def new_nick(self):
"""\
Generates a new nickname based on original nickname followed by a
random number
"""
old = self.nick
self.nick = '%s_%s' % (self.base_nick, random.randint(1, 1000))
self.logger.warn('Nick %s already taken, trying %s' % (old, self.nick))
... | [
"def",
"new_nick",
"(",
"self",
")",
":",
"old",
"=",
"self",
".",
"nick",
"self",
".",
"nick",
"=",
"'%s_%s'",
"%",
"(",
"self",
".",
"base_nick",
",",
"random",
".",
"randint",
"(",
"1",
",",
"1000",
")",
")",
"self",
".",
"logger",
".",
"warn"... | \
Generates a new nickname based on original nickname followed by a
random number | [
"\\",
"Generates",
"a",
"new",
"nickname",
"based",
"on",
"original",
"nickname",
"followed",
"by",
"a",
"random",
"number"
] | python | test |
saltstack/salt | salt/modules/git.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/git.py#L192-L211 | def _find_ssh_exe():
'''
Windows only: search for Git's bundled ssh.exe in known locations
'''
# Known locations for Git's ssh.exe in Windows
globmasks = [os.path.join(os.getenv('SystemDrive'), os.sep,
'Program Files*', 'Git', 'usr', 'bin',
... | [
"def",
"_find_ssh_exe",
"(",
")",
":",
"# Known locations for Git's ssh.exe in Windows",
"globmasks",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getenv",
"(",
"'SystemDrive'",
")",
",",
"os",
".",
"sep",
",",
"'Program Files*'",
",",
"'Git'",
... | Windows only: search for Git's bundled ssh.exe in known locations | [
"Windows",
"only",
":",
"search",
"for",
"Git",
"s",
"bundled",
"ssh",
".",
"exe",
"in",
"known",
"locations"
] | python | train |
cloud-custodian/cloud-custodian | tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py#L67-L71 | def lock_status(account_id, resource_id, parent_id):
"""Show extant locks' status
"""
return output(
Client(BASE_URL, account_id).lock_status(resource_id, parent_id)) | [
"def",
"lock_status",
"(",
"account_id",
",",
"resource_id",
",",
"parent_id",
")",
":",
"return",
"output",
"(",
"Client",
"(",
"BASE_URL",
",",
"account_id",
")",
".",
"lock_status",
"(",
"resource_id",
",",
"parent_id",
")",
")"
] | Show extant locks' status | [
"Show",
"extant",
"locks",
"status"
] | python | train |
projectshift/shift-boiler | boiler/user/models.py | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/models.py#L224-L232 | def increment_failed_logins(self):
""" Increment failed logins counter"""
if not self.failed_logins:
self.failed_logins = 1
elif not self.failed_login_limit_reached():
self.failed_logins += 1
else:
self.reset_login_counter()
self.lock_accou... | [
"def",
"increment_failed_logins",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"failed_logins",
":",
"self",
".",
"failed_logins",
"=",
"1",
"elif",
"not",
"self",
".",
"failed_login_limit_reached",
"(",
")",
":",
"self",
".",
"failed_logins",
"+=",
"1",... | Increment failed logins counter | [
"Increment",
"failed",
"logins",
"counter"
] | python | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_model.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_model.py#L972-L1049 | def calc_qib2_v1(self):
"""Calculate the first inflow component released from the soil.
Required control parameters:
|NHRU|
|Lnk|
|NFk|
|DMin|
|DMax|
Required derived parameter:
|WZ|
Required state sequence:
|BoWa|
Calculated flux sequence:
|QIB2|
... | [
"def",
"calc_qib2_v1",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"parameters",
".",
"control",
".",
"fastaccess",
"der",
"=",
"self",
".",
"parameters",
".",
"derived",
".",
"fastaccess",
"flu",
"=",
"self",
".",
"sequences",
".",
"fluxes",
".",
... | Calculate the first inflow component released from the soil.
Required control parameters:
|NHRU|
|Lnk|
|NFk|
|DMin|
|DMax|
Required derived parameter:
|WZ|
Required state sequence:
|BoWa|
Calculated flux sequence:
|QIB2|
Basic equation:
:mat... | [
"Calculate",
"the",
"first",
"inflow",
"component",
"released",
"from",
"the",
"soil",
"."
] | python | train |
jasonrbriggs/stomp.py | stomp/connect.py | https://github.com/jasonrbriggs/stomp.py/blob/643843c5fbf25fd24339dd0e69a9411c3d8b94c7/stomp/connect.py#L176-L185 | def disconnect(self, receipt=None, headers=None, **keyword_headers):
"""
Call the protocol disconnection, and then stop the transport itself.
:param str receipt: the receipt to use with the disconnect
:param dict headers: a map of any additional headers to send with the disconnection
... | [
"def",
"disconnect",
"(",
"self",
",",
"receipt",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"*",
"*",
"keyword_headers",
")",
":",
"Protocol11",
".",
"disconnect",
"(",
"self",
",",
"receipt",
",",
"headers",
",",
"*",
"*",
"keyword_headers",
")",
... | Call the protocol disconnection, and then stop the transport itself.
:param str receipt: the receipt to use with the disconnect
:param dict headers: a map of any additional headers to send with the disconnection
:param keyword_headers: any additional headers to send with the disconnection | [
"Call",
"the",
"protocol",
"disconnection",
"and",
"then",
"stop",
"the",
"transport",
"itself",
"."
] | python | train |
linkedin/Zopkio | zopkio/adhoc_deployer.py | https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/adhoc_deployer.py#L396-L406 | def get_host(self, unique_id):
"""Gets the host of the process with `unique_id`. If the deployer does not know of a process
with `unique_id` then it should return a value of SOME_SENTINAL_VALUE
:Parameter unique_id: the name of the process
:raises NameError if the name is not valid process
"""
... | [
"def",
"get_host",
"(",
"self",
",",
"unique_id",
")",
":",
"if",
"unique_id",
"in",
"self",
".",
"processes",
":",
"return",
"self",
".",
"processes",
"[",
"unique_id",
"]",
".",
"hostname",
"logger",
".",
"error",
"(",
"\"{0} not a known process\"",
".",
... | Gets the host of the process with `unique_id`. If the deployer does not know of a process
with `unique_id` then it should return a value of SOME_SENTINAL_VALUE
:Parameter unique_id: the name of the process
:raises NameError if the name is not valid process | [
"Gets",
"the",
"host",
"of",
"the",
"process",
"with",
"unique_id",
".",
"If",
"the",
"deployer",
"does",
"not",
"know",
"of",
"a",
"process",
"with",
"unique_id",
"then",
"it",
"should",
"return",
"a",
"value",
"of",
"SOME_SENTINAL_VALUE"
] | python | train |
adaptive-learning/proso-apps | proso_user/views_classes.py | https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_user/views_classes.py#L181-L222 | def login_student(request):
"""
Log in student
POST parameters (JSON):
student:
profile id of the student
"""
if not get_config('proso_user', 'allow_login_students', default=False):
return render_json(request, {
'error': _('Log in as student is not allowed.')... | [
"def",
"login_student",
"(",
"request",
")",
":",
"if",
"not",
"get_config",
"(",
"'proso_user'",
",",
"'allow_login_students'",
",",
"default",
"=",
"False",
")",
":",
"return",
"render_json",
"(",
"request",
",",
"{",
"'error'",
":",
"_",
"(",
"'Log in as ... | Log in student
POST parameters (JSON):
student:
profile id of the student | [
"Log",
"in",
"student"
] | python | train |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/pip/req/req_set.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/req/req_set.py#L205-L253 | def add_requirement(self, install_req, parent_req_name=None):
"""Add install_req as a requirement to install.
:param parent_req_name: The name of the requirement that needed this
added. The name is used because when multiple unnamed requirements
resolve to the same name, we coul... | [
"def",
"add_requirement",
"(",
"self",
",",
"install_req",
",",
"parent_req_name",
"=",
"None",
")",
":",
"name",
"=",
"install_req",
".",
"name",
"if",
"not",
"install_req",
".",
"match_markers",
"(",
")",
":",
"logger",
".",
"warning",
"(",
"\"Ignoring %s:... | Add install_req as a requirement to install.
:param parent_req_name: The name of the requirement that needed this
added. The name is used because when multiple unnamed requirements
resolve to the same name, we could otherwise end up with dependency
links that point outside t... | [
"Add",
"install_req",
"as",
"a",
"requirement",
"to",
"install",
"."
] | python | test |
clalancette/pycdlib | pycdlib/eltorito.py | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L306-L339 | def parse(self, valstr):
# type: (bytes) -> None
'''
A method to parse an El Torito Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Entry out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlib... | [
"def",
"parse",
"(",
"self",
",",
"valstr",
")",
":",
"# type: (bytes) -> None",
"if",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'El Torito Entry already initialized'",
")",
"(",
"self",
".",
"boot_indicator",
... | A method to parse an El Torito Entry out of a string.
Parameters:
valstr - The string to parse the El Torito Entry out of.
Returns:
Nothing. | [
"A",
"method",
"to",
"parse",
"an",
"El",
"Torito",
"Entry",
"out",
"of",
"a",
"string",
"."
] | python | train |
CodersOfTheNight/oshino | oshino/agents/__init__.py | https://github.com/CodersOfTheNight/oshino/blob/00f7e151e3ce1f3a7f43b353b695c4dba83c7f28/oshino/agents/__init__.py#L66-L78 | def ready(self):
"""
Function used when agent is `lazy`.
It is being processed only when `ready` condition is satisfied
"""
logger = self.get_logger()
now = current_ts()
logger.trace("Current time: {0}".format(now))
logger.trace("Last Run: {0}".format(self... | [
"def",
"ready",
"(",
"self",
")",
":",
"logger",
"=",
"self",
".",
"get_logger",
"(",
")",
"now",
"=",
"current_ts",
"(",
")",
"logger",
".",
"trace",
"(",
"\"Current time: {0}\"",
".",
"format",
"(",
"now",
")",
")",
"logger",
".",
"trace",
"(",
"\"... | Function used when agent is `lazy`.
It is being processed only when `ready` condition is satisfied | [
"Function",
"used",
"when",
"agent",
"is",
"lazy",
".",
"It",
"is",
"being",
"processed",
"only",
"when",
"ready",
"condition",
"is",
"satisfied"
] | python | train |
bjodah/pycompilation | pycompilation/compilation.py | https://github.com/bjodah/pycompilation/blob/43eac8d82f8258d30d4df77fd2ad3f3e4f4dca18/pycompilation/compilation.py#L617-L673 | def compile_link_import_py_ext(
srcs, extname=None, build_dir=None, compile_kwargs=None,
link_kwargs=None, **kwargs):
"""
Compiles sources in `srcs` to a shared object (python extension)
which is imported. If shared object is newer than the sources, they
are not recompiled but instead it... | [
"def",
"compile_link_import_py_ext",
"(",
"srcs",
",",
"extname",
"=",
"None",
",",
"build_dir",
"=",
"None",
",",
"compile_kwargs",
"=",
"None",
",",
"link_kwargs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"build_dir",
"=",
"build_dir",
"or",
"'.'"... | Compiles sources in `srcs` to a shared object (python extension)
which is imported. If shared object is newer than the sources, they
are not recompiled but instead it is imported.
Parameters
----------
srcs: string
list of paths to sources
extname: string
name of extension (defa... | [
"Compiles",
"sources",
"in",
"srcs",
"to",
"a",
"shared",
"object",
"(",
"python",
"extension",
")",
"which",
"is",
"imported",
".",
"If",
"shared",
"object",
"is",
"newer",
"than",
"the",
"sources",
"they",
"are",
"not",
"recompiled",
"but",
"instead",
"i... | python | train |
swharden/SWHLab | swhlab/core.py | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L445-L449 | def output_touch(self):
"""ensure the ./swhlab/ folder exists."""
if not os.path.exists(self.outFolder):
self.log.debug("creating %s",self.outFolder)
os.mkdir(self.outFolder) | [
"def",
"output_touch",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"outFolder",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"creating %s\"",
",",
"self",
".",
"outFolder",
")",
"os",
".",
"mkdir",
... | ensure the ./swhlab/ folder exists. | [
"ensure",
"the",
".",
"/",
"swhlab",
"/",
"folder",
"exists",
"."
] | python | valid |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_dai.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_dai.py#L68-L88 | def arp_access_list_permit_permit_list_mac_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
arp = ET.SubElement(config, "arp", xmlns="urn:brocade.com:mgmt:brocade-dai")
access_list = ET.SubElement(arp, "access-list")
acl_name_key = ET.SubElem... | [
"def",
"arp_access_list_permit_permit_list_mac_type",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"arp",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"arp\"",
",",
"xmlns",
"=",
"\"urn... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
bukun/TorCMS | torcms/model/post_model.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L384-L397 | def query_by_tag(cat_id, kind='1'):
'''
Query recent posts of catalog.
'''
return TabPost.select().join(
TabPost2Tag,
on=(TabPost.uid == TabPost2Tag.post_id)
).where(
(TabPost.kind == kind) &
(TabPost2Tag.tag_id == cat_id)
... | [
"def",
"query_by_tag",
"(",
"cat_id",
",",
"kind",
"=",
"'1'",
")",
":",
"return",
"TabPost",
".",
"select",
"(",
")",
".",
"join",
"(",
"TabPost2Tag",
",",
"on",
"=",
"(",
"TabPost",
".",
"uid",
"==",
"TabPost2Tag",
".",
"post_id",
")",
")",
".",
... | Query recent posts of catalog. | [
"Query",
"recent",
"posts",
"of",
"catalog",
"."
] | python | train |
tensorflow/cleverhans | cleverhans/attacks/max_confidence.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/attacks/max_confidence.py#L112-L121 | def attack_class(self, x, target_y):
"""
Run the attack on a specific target class.
:param x: tf Tensor. The input example.
:param target_y: tf Tensor. The attacker's desired target class.
Returns:
A targeted adversarial example, intended to be classified as the target class.
"""
adv =... | [
"def",
"attack_class",
"(",
"self",
",",
"x",
",",
"target_y",
")",
":",
"adv",
"=",
"self",
".",
"base_attacker",
".",
"generate",
"(",
"x",
",",
"y_target",
"=",
"target_y",
",",
"*",
"*",
"self",
".",
"params",
")",
"return",
"adv"
] | Run the attack on a specific target class.
:param x: tf Tensor. The input example.
:param target_y: tf Tensor. The attacker's desired target class.
Returns:
A targeted adversarial example, intended to be classified as the target class. | [
"Run",
"the",
"attack",
"on",
"a",
"specific",
"target",
"class",
".",
":",
"param",
"x",
":",
"tf",
"Tensor",
".",
"The",
"input",
"example",
".",
":",
"param",
"target_y",
":",
"tf",
"Tensor",
".",
"The",
"attacker",
"s",
"desired",
"target",
"class"... | python | train |
PyAr/fades | fades/helpers.py | https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/helpers.py#L245-L258 | def check_pypi_exists(dependencies):
"""Check if the indicated dependencies actually exists in pypi."""
for dependency in dependencies.get('pypi', []):
logger.debug("Checking if %r exists in PyPI", dependency)
try:
exists = _pypi_head_package(dependency)
except Exception as e... | [
"def",
"check_pypi_exists",
"(",
"dependencies",
")",
":",
"for",
"dependency",
"in",
"dependencies",
".",
"get",
"(",
"'pypi'",
",",
"[",
"]",
")",
":",
"logger",
".",
"debug",
"(",
"\"Checking if %r exists in PyPI\"",
",",
"dependency",
")",
"try",
":",
"e... | Check if the indicated dependencies actually exists in pypi. | [
"Check",
"if",
"the",
"indicated",
"dependencies",
"actually",
"exists",
"in",
"pypi",
"."
] | python | train |
ccubed/PyMoe | Pymoe/Kitsu/library.py | https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/library.py#L122-L133 | def __format_filters(filters):
"""
Format filters for the api query (to filter[<filter-name>])
:param filters: dict: can be None, filters for the query
:return: the formatted filters, or None
"""
if filters is not None:
for k in filters:
if 'f... | [
"def",
"__format_filters",
"(",
"filters",
")",
":",
"if",
"filters",
"is",
"not",
"None",
":",
"for",
"k",
"in",
"filters",
":",
"if",
"'filter['",
"not",
"in",
"k",
":",
"filters",
"[",
"'filter[{}]'",
".",
"format",
"(",
"k",
")",
"]",
"=",
"filte... | Format filters for the api query (to filter[<filter-name>])
:param filters: dict: can be None, filters for the query
:return: the formatted filters, or None | [
"Format",
"filters",
"for",
"the",
"api",
"query",
"(",
"to",
"filter",
"[",
"<filter",
"-",
"name",
">",
"]",
")"
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L6733-L6759 | def gnpool(name, start, room, lenout=_default_len_out):
"""
Return names of kernel variables matching a specified template.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gnpool_c.html
:param name: Template that names should match.
:type name: str
:param start: Index of first matching... | [
"def",
"gnpool",
"(",
"name",
",",
"start",
",",
"room",
",",
"lenout",
"=",
"_default_len_out",
")",
":",
"name",
"=",
"stypes",
".",
"stringToCharP",
"(",
"name",
")",
"start",
"=",
"ctypes",
".",
"c_int",
"(",
"start",
")",
"kvars",
"=",
"stypes",
... | Return names of kernel variables matching a specified template.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gnpool_c.html
:param name: Template that names should match.
:type name: str
:param start: Index of first matching name to retrieve.
:type start: int
:param room: The largest... | [
"Return",
"names",
"of",
"kernel",
"variables",
"matching",
"a",
"specified",
"template",
"."
] | python | train |
BD2KOnFHIR/fhirtordf | fhirtordf/rdfsupport/prettygraph.py | https://github.com/BD2KOnFHIR/fhirtordf/blob/f97b3df683fa4caacf5cf4f29699ab060bcc0fbf/fhirtordf/rdfsupport/prettygraph.py#L98-L102 | def strip_prefixes(g: Graph):
""" Remove the prefixes from the graph for aesthetics """
return re.sub(r'^@prefix .* .\n', '',
g.serialize(format="turtle").decode(),
flags=re.MULTILINE).strip() | [
"def",
"strip_prefixes",
"(",
"g",
":",
"Graph",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'^@prefix .* .\\n'",
",",
"''",
",",
"g",
".",
"serialize",
"(",
"format",
"=",
"\"turtle\"",
")",
".",
"decode",
"(",
")",
",",
"flags",
"=",
"re",
".",
... | Remove the prefixes from the graph for aesthetics | [
"Remove",
"the",
"prefixes",
"from",
"the",
"graph",
"for",
"aesthetics"
] | python | train |
hyperledger/sawtooth-core | validator/sawtooth_validator/execution/execution_context.py | https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L230-L242 | def create_prefetch(self, addresses):
"""Create futures needed before starting the process of reading the
address's value from the merkle tree.
Args:
addresses (list of str): addresses in the txn's inputs that
aren't in any base context (or any in the chain).
... | [
"def",
"create_prefetch",
"(",
"self",
",",
"addresses",
")",
":",
"with",
"self",
".",
"_lock",
":",
"for",
"add",
"in",
"addresses",
":",
"self",
".",
"_state",
"[",
"add",
"]",
"=",
"_ContextFuture",
"(",
"address",
"=",
"add",
",",
"wait_for_tree",
... | Create futures needed before starting the process of reading the
address's value from the merkle tree.
Args:
addresses (list of str): addresses in the txn's inputs that
aren't in any base context (or any in the chain). | [
"Create",
"futures",
"needed",
"before",
"starting",
"the",
"process",
"of",
"reading",
"the",
"address",
"s",
"value",
"from",
"the",
"merkle",
"tree",
"."
] | python | train |
devassistant/devassistant | devassistant/dapi/dapicli.py | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L337-L346 | def format_search(q, **kwargs):
'''Formats the results of a search'''
m = search(q, **kwargs)
count = m['count']
if not count:
raise DapiCommError('Could not find any DAP packages for your query.')
return
for mdap in m['results']:
mdap = mdap['content_object']
return ... | [
"def",
"format_search",
"(",
"q",
",",
"*",
"*",
"kwargs",
")",
":",
"m",
"=",
"search",
"(",
"q",
",",
"*",
"*",
"kwargs",
")",
"count",
"=",
"m",
"[",
"'count'",
"]",
"if",
"not",
"count",
":",
"raise",
"DapiCommError",
"(",
"'Could not find any DA... | Formats the results of a search | [
"Formats",
"the",
"results",
"of",
"a",
"search"
] | python | train |
dshean/pygeotools | pygeotools/lib/geolib.py | https://github.com/dshean/pygeotools/blob/5ac745717c0098d01eb293ff1fe32fd7358c76ab/pygeotools/lib/geolib.py#L1940-L1949 | def get_xy_1D(ds, stride=1, getval=False):
"""Return 1D arrays of x and y map coordinates for input GDAL Dataset
"""
gt = ds.GetGeoTransform()
#stride = stride_m/gt[1]
pX = np.arange(0, ds.RasterXSize, stride)
pY = np.arange(0, ds.RasterYSize, stride)
mX, dummy = pixelToMap(pX, pY[0], gt)
... | [
"def",
"get_xy_1D",
"(",
"ds",
",",
"stride",
"=",
"1",
",",
"getval",
"=",
"False",
")",
":",
"gt",
"=",
"ds",
".",
"GetGeoTransform",
"(",
")",
"#stride = stride_m/gt[1]",
"pX",
"=",
"np",
".",
"arange",
"(",
"0",
",",
"ds",
".",
"RasterXSize",
","... | Return 1D arrays of x and y map coordinates for input GDAL Dataset | [
"Return",
"1D",
"arrays",
"of",
"x",
"and",
"y",
"map",
"coordinates",
"for",
"input",
"GDAL",
"Dataset"
] | python | train |
AoiKuiyuyou/AoikLiveReload | src/aoiklivereload/aoiklivereload.py | https://github.com/AoiKuiyuyou/AoikLiveReload/blob/0d5adb12118a33749e6690a8165fdb769cff7d5c/src/aoiklivereload/aoiklivereload.py#L158-L223 | def run_watcher(self):
"""
Watcher thread's function.
:return:
None.
"""
# Create observer
observer = Observer()
# Start observer
observer.start()
# Dict that maps file path to `watch object`
watche_obj_map = {}
# Ru... | [
"def",
"run_watcher",
"(",
"self",
")",
":",
"# Create observer",
"observer",
"=",
"Observer",
"(",
")",
"# Start observer",
"observer",
".",
"start",
"(",
")",
"# Dict that maps file path to `watch object`",
"watche_obj_map",
"=",
"{",
"}",
"# Run change check in a loo... | Watcher thread's function.
:return:
None. | [
"Watcher",
"thread",
"s",
"function",
"."
] | python | train |
nadirizr/json-logic-py | json_logic/__init__.py | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L47-L56 | def less(a, b, *args):
"""Implements the '<' operator with JS-style type coertion."""
types = set([type(a), type(b)])
if float in types or int in types:
try:
a, b = float(a), float(b)
except TypeError:
# NaN
return False
return a < b and (not args or l... | [
"def",
"less",
"(",
"a",
",",
"b",
",",
"*",
"args",
")",
":",
"types",
"=",
"set",
"(",
"[",
"type",
"(",
"a",
")",
",",
"type",
"(",
"b",
")",
"]",
")",
"if",
"float",
"in",
"types",
"or",
"int",
"in",
"types",
":",
"try",
":",
"a",
","... | Implements the '<' operator with JS-style type coertion. | [
"Implements",
"the",
"<",
"operator",
"with",
"JS",
"-",
"style",
"type",
"coertion",
"."
] | python | valid |
tensorflow/tensor2tensor | tensor2tensor/trax/jaxboard.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/jaxboard.py#L212-L249 | def audio(self, tag, audiodata, step=None, sample_rate=44100):
"""Saves audio.
NB: single channel only right now.
Args:
tag: str: label for this data
audiodata: ndarray [Nsamples,]: data between (-1.0,1.0) to save as wave
step: int: training step
sample_rate: sample rate of passed ... | [
"def",
"audio",
"(",
"self",
",",
"tag",
",",
"audiodata",
",",
"step",
"=",
"None",
",",
"sample_rate",
"=",
"44100",
")",
":",
"audiodata",
"=",
"onp",
".",
"array",
"(",
"audiodata",
")",
"if",
"step",
"is",
"None",
":",
"step",
"=",
"self",
"."... | Saves audio.
NB: single channel only right now.
Args:
tag: str: label for this data
audiodata: ndarray [Nsamples,]: data between (-1.0,1.0) to save as wave
step: int: training step
sample_rate: sample rate of passed in audio buffer | [
"Saves",
"audio",
"."
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L108-L118 | def get_attribute_by_name_and_dimension(name, dimension_id=None,**kwargs):
"""
Get a specific attribute by its name.
dimension_id can be None, because in attribute the dimension_id is not anymore mandatory
"""
try:
attr_i = db.DBSession.query(Attr).filter(and_(Attr.name==name, Attr.d... | [
"def",
"get_attribute_by_name_and_dimension",
"(",
"name",
",",
"dimension_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"attr_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Attr",
")",
".",
"filter",
"(",
"and_",
"(",
"Attr",
... | Get a specific attribute by its name.
dimension_id can be None, because in attribute the dimension_id is not anymore mandatory | [
"Get",
"a",
"specific",
"attribute",
"by",
"its",
"name",
".",
"dimension_id",
"can",
"be",
"None",
"because",
"in",
"attribute",
"the",
"dimension_id",
"is",
"not",
"anymore",
"mandatory"
] | python | train |
Kortemme-Lab/klab | klab/bio/relatrix.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/relatrix.py#L347-L372 | def _create_inverse_maps(self):
'''Create the inverse mappings (UniParc -> SEQRES -> ATOM -> Rosetta).'''
# We have already determined that the inverse maps are well-defined (the normal maps are injective). The inverse maps will be partial maps in general.
self.atom_to_rosetta_sequence_maps = ... | [
"def",
"_create_inverse_maps",
"(",
"self",
")",
":",
"# We have already determined that the inverse maps are well-defined (the normal maps are injective). The inverse maps will be partial maps in general.",
"self",
".",
"atom_to_rosetta_sequence_maps",
"=",
"{",
"}",
"for",
"chain_id",
... | Create the inverse mappings (UniParc -> SEQRES -> ATOM -> Rosetta). | [
"Create",
"the",
"inverse",
"mappings",
"(",
"UniParc",
"-",
">",
"SEQRES",
"-",
">",
"ATOM",
"-",
">",
"Rosetta",
")",
"."
] | python | train |
thespacedoctor/polyglot | polyglot/markdown/translate.py | https://github.com/thespacedoctor/polyglot/blob/98038d746aa67e343b73b3ccee1e02d31dab81ec/polyglot/markdown/translate.py#L639-L669 | def ul(
self,
text):
"""*convert plain-text to MMD unordered list*
**Key Arguments:**
- ``text`` -- the text to convert to MMD unordered list
**Return:**
- ``ul`` -- the MMD unordered list
**Usage:**
To convert text to a MMD... | [
"def",
"ul",
"(",
"self",
",",
"text",
")",
":",
"m",
"=",
"self",
".",
"reWS",
".",
"match",
"(",
"text",
")",
"ul",
"=",
"[",
"]",
"for",
"l",
"in",
"m",
".",
"group",
"(",
"2",
")",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"prefix",
",",
... | *convert plain-text to MMD unordered list*
**Key Arguments:**
- ``text`` -- the text to convert to MMD unordered list
**Return:**
- ``ul`` -- the MMD unordered list
**Usage:**
To convert text to a MMD unordered list:
.. code-block:: python
... | [
"*",
"convert",
"plain",
"-",
"text",
"to",
"MMD",
"unordered",
"list",
"*"
] | python | train |
Dentosal/python-sc2 | sc2/bot_ai.py | https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/bot_ai.py#L474-L480 | def in_placement_grid(self, pos: Union[Point2, Point3, Unit]) -> bool:
""" Returns True if you can place something at a position. Remember, buildings usually use 2x2, 3x3 or 5x5 of these grid points.
Caution: some x and y offset might be required, see ramp code:
https://github.com/Dentosal/pytho... | [
"def",
"in_placement_grid",
"(",
"self",
",",
"pos",
":",
"Union",
"[",
"Point2",
",",
"Point3",
",",
"Unit",
"]",
")",
"->",
"bool",
":",
"assert",
"isinstance",
"(",
"pos",
",",
"(",
"Point2",
",",
"Point3",
",",
"Unit",
")",
")",
"pos",
"=",
"po... | Returns True if you can place something at a position. Remember, buildings usually use 2x2, 3x3 or 5x5 of these grid points.
Caution: some x and y offset might be required, see ramp code:
https://github.com/Dentosal/python-sc2/blob/master/sc2/game_info.py#L17-L18 | [
"Returns",
"True",
"if",
"you",
"can",
"place",
"something",
"at",
"a",
"position",
".",
"Remember",
"buildings",
"usually",
"use",
"2x2",
"3x3",
"or",
"5x5",
"of",
"these",
"grid",
"points",
".",
"Caution",
":",
"some",
"x",
"and",
"y",
"offset",
"might... | python | train |
zimeon/iiif | iiif/auth.py | https://github.com/zimeon/iiif/blob/9d10018d01202fa2a76dfa61598dc6eca07b471f/iiif/auth.py#L82-L99 | def login_service_description(self):
"""Login service description.
The login service description _MUST_ include the token service
description. The authentication pattern is indicated via the
profile URI which is built using self.auth_pattern.
"""
label = 'Login to ' + se... | [
"def",
"login_service_description",
"(",
"self",
")",
":",
"label",
"=",
"'Login to '",
"+",
"self",
".",
"name",
"if",
"(",
"self",
".",
"auth_type",
")",
":",
"label",
"=",
"label",
"+",
"' ('",
"+",
"self",
".",
"auth_type",
"+",
"')'",
"desc",
"=",... | Login service description.
The login service description _MUST_ include the token service
description. The authentication pattern is indicated via the
profile URI which is built using self.auth_pattern. | [
"Login",
"service",
"description",
"."
] | python | train |
PmagPy/PmagPy | pmagpy/convert_2_magic.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/convert_2_magic.py#L4830-L5092 | def jr6_jr6(mag_file, dir_path=".", input_dir_path="",
meas_file="measurements.txt", spec_file="specimens.txt",
samp_file="samples.txt", site_file="sites.txt", loc_file="locations.txt",
specnum=1, samp_con='1', location='unknown', lat='', lon='',
noave=False, meth_code="L... | [
"def",
"jr6_jr6",
"(",
"mag_file",
",",
"dir_path",
"=",
"\".\"",
",",
"input_dir_path",
"=",
"\"\"",
",",
"meas_file",
"=",
"\"measurements.txt\"",
",",
"spec_file",
"=",
"\"specimens.txt\"",
",",
"samp_file",
"=",
"\"samples.txt\"",
",",
"site_file",
"=",
"\"s... | Convert JR6 .jr6 files to MagIC file(s)
Parameters
----------
mag_file : str
input file name
dir_path : str
working directory, default "."
input_dir_path : str
input file directory IF different from dir_path, default ""
meas_file : str
output measurement file nam... | [
"Convert",
"JR6",
".",
"jr6",
"files",
"to",
"MagIC",
"file",
"(",
"s",
")"
] | python | train |
raamana/mrivis | mrivis/base.py | https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/base.py#L876-L886 | def _check_image(self, image_nD):
"""Sanity checks on the image data"""
self.input_image = load_image_from_disk(image_nD)
if len(self.input_image.shape) < 3:
raise ValueError('Input image must be atleast 3D')
if np.count_nonzero(self.input_image) == 0:
raise Va... | [
"def",
"_check_image",
"(",
"self",
",",
"image_nD",
")",
":",
"self",
".",
"input_image",
"=",
"load_image_from_disk",
"(",
"image_nD",
")",
"if",
"len",
"(",
"self",
".",
"input_image",
".",
"shape",
")",
"<",
"3",
":",
"raise",
"ValueError",
"(",
"'In... | Sanity checks on the image data | [
"Sanity",
"checks",
"on",
"the",
"image",
"data"
] | python | train |
python-wink/python-wink | src/pywink/devices/powerstrip.py | https://github.com/python-wink/python-wink/blob/cf8bdce8c6518f30b91b23aa7aa32e89c2ce48da/src/pywink/devices/powerstrip.py#L79-L91 | def set_state(self, state):
"""
:param state: a boolean of true (on) or false ('off')
:return: nothing
"""
if self.index() == 0:
values = {"outlets": [{"desired_state": {"powered": state}}, {}]}
else:
values = {"outlets": [{}, {"desired_s... | [
"def",
"set_state",
"(",
"self",
",",
"state",
")",
":",
"if",
"self",
".",
"index",
"(",
")",
"==",
"0",
":",
"values",
"=",
"{",
"\"outlets\"",
":",
"[",
"{",
"\"desired_state\"",
":",
"{",
"\"powered\"",
":",
"state",
"}",
"}",
",",
"{",
"}",
... | :param state: a boolean of true (on) or false ('off')
:return: nothing | [
":",
"param",
"state",
":",
"a",
"boolean",
"of",
"true",
"(",
"on",
")",
"or",
"false",
"(",
"off",
")",
":",
"return",
":",
"nothing"
] | python | train |
Azure/azure-sdk-for-python | azure-mgmt-resource/azure/mgmt/resource/links/management_link_client.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/links/management_link_client.py#L96-L104 | def models(cls, api_version=DEFAULT_API_VERSION):
"""Module depends on the API version:
* 2016-09-01: :mod:`v2016_09_01.models<azure.mgmt.resource.links.v2016_09_01.models>`
"""
if api_version == '2016-09-01':
from .v2016_09_01 import models
return models
... | [
"def",
"models",
"(",
"cls",
",",
"api_version",
"=",
"DEFAULT_API_VERSION",
")",
":",
"if",
"api_version",
"==",
"'2016-09-01'",
":",
"from",
".",
"v2016_09_01",
"import",
"models",
"return",
"models",
"raise",
"NotImplementedError",
"(",
"\"APIVersion {} is not av... | Module depends on the API version:
* 2016-09-01: :mod:`v2016_09_01.models<azure.mgmt.resource.links.v2016_09_01.models>` | [
"Module",
"depends",
"on",
"the",
"API",
"version",
":"
] | python | test |
Robin8Put/pmes | storage/rpc_methods.py | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L110-L148 | async def find_recent_news(self, **params):
"""Looking up recent news for account.
Accepts:
- public_key
Returns:
- list with dicts or empty
"""
# Check if params is not empty
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason... | [
"async",
"def",
"find_recent_news",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"# Check if params is not empty",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\... | Looking up recent news for account.
Accepts:
- public_key
Returns:
- list with dicts or empty | [
"Looking",
"up",
"recent",
"news",
"for",
"account",
".",
"Accepts",
":",
"-",
"public_key",
"Returns",
":",
"-",
"list",
"with",
"dicts",
"or",
"empty"
] | python | train |
StanfordVL/robosuite | robosuite/environments/base.py | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/environments/base.py#L142-L149 | def reset(self):
"""Resets simulation."""
# TODO(yukez): investigate black screen of death
# if there is an active viewer window, destroy it
self._destroy_viewer()
self._reset_internal()
self.sim.forward()
return self._get_observation() | [
"def",
"reset",
"(",
"self",
")",
":",
"# TODO(yukez): investigate black screen of death",
"# if there is an active viewer window, destroy it",
"self",
".",
"_destroy_viewer",
"(",
")",
"self",
".",
"_reset_internal",
"(",
")",
"self",
".",
"sim",
".",
"forward",
"(",
... | Resets simulation. | [
"Resets",
"simulation",
"."
] | python | train |
ArduPilot/MAVProxy | MAVProxy/modules/mavproxy_antenna.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_antenna.py#L32-L52 | def mavlink_packet(self, m):
'''handle an incoming mavlink packet'''
if self.gcs_location is None and self.module('wp').wploader.count() > 0:
home = self.module('wp').get_home()
self.gcs_location = (home.x, home.y)
print("Antenna home set")
if self.gcs_locatio... | [
"def",
"mavlink_packet",
"(",
"self",
",",
"m",
")",
":",
"if",
"self",
".",
"gcs_location",
"is",
"None",
"and",
"self",
".",
"module",
"(",
"'wp'",
")",
".",
"wploader",
".",
"count",
"(",
")",
">",
"0",
":",
"home",
"=",
"self",
".",
"module",
... | handle an incoming mavlink packet | [
"handle",
"an",
"incoming",
"mavlink",
"packet"
] | python | train |
jalanb/pysyte | pysyte/bash/shell.py | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/shell.py#L69-L71 | def full_path(path):
"""Get the real path, expanding links and bashisms"""
return os.path.realpath(os.path.expanduser(os.path.expandvars(path))) | [
"def",
"full_path",
"(",
"path",
")",
":",
"return",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"os",
".",
"path",
".",
"expandvars",
"(",
"path",
")",
")",
")"
] | Get the real path, expanding links and bashisms | [
"Get",
"the",
"real",
"path",
"expanding",
"links",
"and",
"bashisms"
] | python | train |
bootphon/h5features | h5features/features.py | https://github.com/bootphon/h5features/blob/d5f95db0f1cee58ac1ba4575d1212e796c39e1f9/h5features/features.py#L215-L256 | def create_dataset(self, group, chunk_size):
"""Initializes sparse specific datasets"""
group.attrs['format'] = self.dformat
group.attrs['dim'] = self.dim
if chunk_size == 'auto':
group.create_dataset(
'coordinates', (0, 2), dtype=np.float64,
... | [
"def",
"create_dataset",
"(",
"self",
",",
"group",
",",
"chunk_size",
")",
":",
"group",
".",
"attrs",
"[",
"'format'",
"]",
"=",
"self",
".",
"dformat",
"group",
".",
"attrs",
"[",
"'dim'",
"]",
"=",
"self",
".",
"dim",
"if",
"chunk_size",
"==",
"'... | Initializes sparse specific datasets | [
"Initializes",
"sparse",
"specific",
"datasets"
] | python | train |
sailthru/sailthru-python-client | sailthru/sailthru_client.py | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L88-L108 | def multi_send(self, template, emails, _vars=None, evars=None, schedule_time=None, options=None):
"""
Remotely send an email template to multiple email addresses.
http://docs.sailthru.com/api/send
@param template: template string
@param emails: List with email values or comma sep... | [
"def",
"multi_send",
"(",
"self",
",",
"template",
",",
"emails",
",",
"_vars",
"=",
"None",
",",
"evars",
"=",
"None",
",",
"schedule_time",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"_vars",
"=",
"_vars",
"or",
"{",
"}",
"evars",
"=",
"... | Remotely send an email template to multiple email addresses.
http://docs.sailthru.com/api/send
@param template: template string
@param emails: List with email values or comma separated email string
@param _vars: a key/value hash of the replacement vars to use in the send. Each var may be... | [
"Remotely",
"send",
"an",
"email",
"template",
"to",
"multiple",
"email",
"addresses",
".",
"http",
":",
"//",
"docs",
".",
"sailthru",
".",
"com",
"/",
"api",
"/",
"send"
] | python | train |
catherinedevlin/ddl-generator | ddlgenerator/reshape.py | https://github.com/catherinedevlin/ddl-generator/blob/db6741216d1e9ad84b07d4ad281bfff021d344ea/ddlgenerator/reshape.py#L18-L34 | def clean_key_name(key):
"""
Makes ``key`` a valid and appropriate SQL column name:
1. Replaces illegal characters in column names with ``_``
2. Prevents name from beginning with a digit (prepends ``_``)
3. Lowercases name. If you want case-sensitive table
or column names, you are a bad pers... | [
"def",
"clean_key_name",
"(",
"key",
")",
":",
"result",
"=",
"_illegal_in_column_name",
".",
"sub",
"(",
"\"_\"",
",",
"key",
".",
"strip",
"(",
")",
")",
"if",
"result",
"[",
"0",
"]",
".",
"isdigit",
"(",
")",
":",
"result",
"=",
"'_%s'",
"%",
"... | Makes ``key`` a valid and appropriate SQL column name:
1. Replaces illegal characters in column names with ``_``
2. Prevents name from beginning with a digit (prepends ``_``)
3. Lowercases name. If you want case-sensitive table
or column names, you are a bad person and you should feel bad. | [
"Makes",
"key",
"a",
"valid",
"and",
"appropriate",
"SQL",
"column",
"name",
":"
] | python | train |
jrderuiter/pybiomart | src/pybiomart/server.py | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/server.py#L58-L62 | def marts(self):
"""List of available marts."""
if self._marts is None:
self._marts = self._fetch_marts()
return self._marts | [
"def",
"marts",
"(",
"self",
")",
":",
"if",
"self",
".",
"_marts",
"is",
"None",
":",
"self",
".",
"_marts",
"=",
"self",
".",
"_fetch_marts",
"(",
")",
"return",
"self",
".",
"_marts"
] | List of available marts. | [
"List",
"of",
"available",
"marts",
"."
] | python | train |
jpablo128/simplystatic | bin/addrandompages.py | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/bin/addrandompages.py#L17-L25 | def setup_parser():
'''Set up the command-line options.'''
parser = argparse.ArgumentParser(description='Add random pages to existing site.')
parser.add_argument('-d','--directory', action='store', default= os.getcwd(),
help='Site directory (must be a valid s2 structure).')
... | [
"def",
"setup_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Add random pages to existing site.'",
")",
"parser",
".",
"add_argument",
"(",
"'-d'",
",",
"'--directory'",
",",
"action",
"=",
"'store'",
",",
"d... | Set up the command-line options. | [
"Set",
"up",
"the",
"command",
"-",
"line",
"options",
"."
] | python | train |
seleniumbase/SeleniumBase | seleniumbase/fixtures/base_case.py | https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/base_case.py#L1851-L1876 | def set_value(self, selector, new_value, by=By.CSS_SELECTOR,
timeout=settings.LARGE_TIMEOUT):
""" This method uses JavaScript to update a text field. """
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
timeout = self.__get_new_timeout(timeout)
if p... | [
"def",
"set_value",
"(",
"self",
",",
"selector",
",",
"new_value",
",",
"by",
"=",
"By",
".",
"CSS_SELECTOR",
",",
"timeout",
"=",
"settings",
".",
"LARGE_TIMEOUT",
")",
":",
"if",
"self",
".",
"timeout_multiplier",
"and",
"timeout",
"==",
"settings",
"."... | This method uses JavaScript to update a text field. | [
"This",
"method",
"uses",
"JavaScript",
"to",
"update",
"a",
"text",
"field",
"."
] | python | train |
scanny/python-pptx | spec/gen_spec/gen_spec.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/spec/gen_spec/gen_spec.py#L241-L251 | def render_desc(desc):
"""calculate desc string, wrapped if too long"""
desc = desc + '.'
desc_lines = split_len(desc, 54)
if len(desc_lines) > 1:
join_str = "'\n%s'" % (' '*21)
lines_str = join_str.join(desc_lines)
out = "('%s')" % lines_str
else:
out = "'%s'" % desc... | [
"def",
"render_desc",
"(",
"desc",
")",
":",
"desc",
"=",
"desc",
"+",
"'.'",
"desc_lines",
"=",
"split_len",
"(",
"desc",
",",
"54",
")",
"if",
"len",
"(",
"desc_lines",
")",
">",
"1",
":",
"join_str",
"=",
"\"'\\n%s'\"",
"%",
"(",
"' '",
"*",
"21... | calculate desc string, wrapped if too long | [
"calculate",
"desc",
"string",
"wrapped",
"if",
"too",
"long"
] | python | train |
genialis/resolwe | resolwe/flow/executors/run.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/run.py#L134-L279 | async def _run(self, data_id, script):
"""Execute the script and save results."""
self.data_id = data_id
# Fetch data instance to get any executor requirements.
self.process = PROCESS
requirements = self.process['requirements']
self.requirements = requirements.get('execu... | [
"async",
"def",
"_run",
"(",
"self",
",",
"data_id",
",",
"script",
")",
":",
"self",
".",
"data_id",
"=",
"data_id",
"# Fetch data instance to get any executor requirements.",
"self",
".",
"process",
"=",
"PROCESS",
"requirements",
"=",
"self",
".",
"process",
... | Execute the script and save results. | [
"Execute",
"the",
"script",
"and",
"save",
"results",
"."
] | python | train |
SeleniumHQ/selenium | py/selenium/webdriver/remote/webdriver.py | https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webdriver.py#L1122-L1143 | def set_window_size(self, width, height, windowHandle='current'):
"""
Sets the width and height of the current window. (window.resizeTo)
:Args:
- width: the width in pixels to set the window to
- height: the height in pixels to set the window to
:Usage:
::... | [
"def",
"set_window_size",
"(",
"self",
",",
"width",
",",
"height",
",",
"windowHandle",
"=",
"'current'",
")",
":",
"if",
"self",
".",
"w3c",
":",
"if",
"windowHandle",
"!=",
"'current'",
":",
"warnings",
".",
"warn",
"(",
"\"Only 'current' window is supporte... | Sets the width and height of the current window. (window.resizeTo)
:Args:
- width: the width in pixels to set the window to
- height: the height in pixels to set the window to
:Usage:
::
driver.set_window_size(800,600) | [
"Sets",
"the",
"width",
"and",
"height",
"of",
"the",
"current",
"window",
".",
"(",
"window",
".",
"resizeTo",
")"
] | python | train |
limodou/uliweb | uliweb/lib/werkzeug/serving.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/serving.py#L469-L486 | def make_server(host, port, app=None, threaded=False, processes=1,
request_handler=None, passthrough_errors=False,
ssl_context=None):
"""Create a new server instance that is either threaded, or forks
or just processes one request after another.
"""
if threaded and process... | [
"def",
"make_server",
"(",
"host",
",",
"port",
",",
"app",
"=",
"None",
",",
"threaded",
"=",
"False",
",",
"processes",
"=",
"1",
",",
"request_handler",
"=",
"None",
",",
"passthrough_errors",
"=",
"False",
",",
"ssl_context",
"=",
"None",
")",
":",
... | Create a new server instance that is either threaded, or forks
or just processes one request after another. | [
"Create",
"a",
"new",
"server",
"instance",
"that",
"is",
"either",
"threaded",
"or",
"forks",
"or",
"just",
"processes",
"one",
"request",
"after",
"another",
"."
] | python | train |
tjcsl/cslbot | cslbot/hooks/url.py | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/hooks/url.py#L37-L77 | def handle(send, msg, args):
"""Get titles for urls.
Generate a short url. Get the page title.
"""
worker = args["handler"].workers
result = worker.run_pool(get_urls, [msg])
try:
urls = result.get(5)
except multiprocessing.TimeoutError:
worker.restart_pool()
send("U... | [
"def",
"handle",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"worker",
"=",
"args",
"[",
"\"handler\"",
"]",
".",
"workers",
"result",
"=",
"worker",
".",
"run_pool",
"(",
"get_urls",
",",
"[",
"msg",
"]",
")",
"try",
":",
"urls",
"=",
"result"... | Get titles for urls.
Generate a short url. Get the page title. | [
"Get",
"titles",
"for",
"urls",
"."
] | python | train |
PythonCharmers/python-future | src/future/backports/email/__init__.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/email/__init__.py#L72-L78 | def message_from_binary_file(fp, *args, **kws):
"""Read a binary file and parse its contents into a Message object model.
Optional _class and strict are passed to the Parser constructor.
"""
from future.backports.email.parser import BytesParser
return BytesParser(*args, **kws).parse(fp) | [
"def",
"message_from_binary_file",
"(",
"fp",
",",
"*",
"args",
",",
"*",
"*",
"kws",
")",
":",
"from",
"future",
".",
"backports",
".",
"email",
".",
"parser",
"import",
"BytesParser",
"return",
"BytesParser",
"(",
"*",
"args",
",",
"*",
"*",
"kws",
"... | Read a binary file and parse its contents into a Message object model.
Optional _class and strict are passed to the Parser constructor. | [
"Read",
"a",
"binary",
"file",
"and",
"parse",
"its",
"contents",
"into",
"a",
"Message",
"object",
"model",
"."
] | python | train |
pytroll/satpy | satpy/readers/hrit_jma.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/hrit_jma.py#L298-L301 | def _mask_space(self, data):
"""Mask space pixels"""
geomask = get_geostationary_mask(area=self.area)
return data.where(geomask) | [
"def",
"_mask_space",
"(",
"self",
",",
"data",
")",
":",
"geomask",
"=",
"get_geostationary_mask",
"(",
"area",
"=",
"self",
".",
"area",
")",
"return",
"data",
".",
"where",
"(",
"geomask",
")"
] | Mask space pixels | [
"Mask",
"space",
"pixels"
] | python | train |
abingham/spor | src/spor/cli.py | https://github.com/abingham/spor/blob/673c8c36c99a4b9ea882f002bfb529f1eca89126/src/spor/cli.py#L227-L261 | def details_handler(args):
"""usage: {program} details <anchor-id> [<path>]
Get the details of a single anchor.
"""
repo = _open_repo(args)
_, anchor = _get_anchor(repo, args['<anchor-id>'])
print("""path: {file_path}
encoding: {encoding}
[before]
{before}
--------------
[topic]
{topic}
---... | [
"def",
"details_handler",
"(",
"args",
")",
":",
"repo",
"=",
"_open_repo",
"(",
"args",
")",
"_",
",",
"anchor",
"=",
"_get_anchor",
"(",
"repo",
",",
"args",
"[",
"'<anchor-id>'",
"]",
")",
"print",
"(",
"\"\"\"path: {file_path}\nencoding: {encoding}\n\n[befor... | usage: {program} details <anchor-id> [<path>]
Get the details of a single anchor. | [
"usage",
":",
"{",
"program",
"}",
"details",
"<anchor",
"-",
"id",
">",
"[",
"<path",
">",
"]"
] | python | train |
pkgw/pwkit | pwkit/bblocks.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/bblocks.py#L386-L444 | def bs_tt_bblock (times, tstarts, tstops, p0=0.05, nbootstrap=512):
"""Bayesian Blocks for time-tagged events with bootstrapping uncertainty
assessment. THE UNCERTAINTIES ARE NOT VERY GOOD! Arguments:
tstarts - Array of input bin start times.
tstops - Array of input bin stop times.
t... | [
"def",
"bs_tt_bblock",
"(",
"times",
",",
"tstarts",
",",
"tstops",
",",
"p0",
"=",
"0.05",
",",
"nbootstrap",
"=",
"512",
")",
":",
"times",
"=",
"np",
".",
"asarray",
"(",
"times",
")",
"tstarts",
"=",
"np",
".",
"asarray",
"(",
"tstarts",
")",
"... | Bayesian Blocks for time-tagged events with bootstrapping uncertainty
assessment. THE UNCERTAINTIES ARE NOT VERY GOOD! Arguments:
tstarts - Array of input bin start times.
tstops - Array of input bin stop times.
times - Array of event arrival times.
p0=0.05 - Probabil... | [
"Bayesian",
"Blocks",
"for",
"time",
"-",
"tagged",
"events",
"with",
"bootstrapping",
"uncertainty",
"assessment",
".",
"THE",
"UNCERTAINTIES",
"ARE",
"NOT",
"VERY",
"GOOD!",
"Arguments",
":"
] | python | train |
dhermes/bezier | src/bezier/_curve_helpers.py | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L871-L923 | def maybe_reduce(nodes):
r"""Reduce nodes in a curve if they are degree-elevated.
.. note::
This is a helper for :func:`_full_reduce`. Hence there is no
corresponding Fortran speedup.
We check if the nodes are degree-elevated by projecting onto the
space of degree-elevated curves of t... | [
"def",
"maybe_reduce",
"(",
"nodes",
")",
":",
"_",
",",
"num_nodes",
"=",
"nodes",
".",
"shape",
"if",
"num_nodes",
"<",
"2",
":",
"return",
"False",
",",
"nodes",
"elif",
"num_nodes",
"==",
"2",
":",
"projection",
"=",
"_PROJECTION0",
"denom",
"=",
"... | r"""Reduce nodes in a curve if they are degree-elevated.
.. note::
This is a helper for :func:`_full_reduce`. Hence there is no
corresponding Fortran speedup.
We check if the nodes are degree-elevated by projecting onto the
space of degree-elevated curves of the same degree, then comparin... | [
"r",
"Reduce",
"nodes",
"in",
"a",
"curve",
"if",
"they",
"are",
"degree",
"-",
"elevated",
"."
] | python | train |
Neurita/boyle | boyle/files/file_tree_map.py | https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/files/file_tree_map.py#L326-L334 | def create_folder(dirpath, overwrite=False):
""" Will create dirpath folder. If dirpath already exists and overwrite is False,
will append a '+' suffix to dirpath until dirpath does not exist."""
if not overwrite:
while op.exists(dirpath):
dirpath += '+'
os.m... | [
"def",
"create_folder",
"(",
"dirpath",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"not",
"overwrite",
":",
"while",
"op",
".",
"exists",
"(",
"dirpath",
")",
":",
"dirpath",
"+=",
"'+'",
"os",
".",
"makedirs",
"(",
"dirpath",
",",
"exist_ok",
"="... | Will create dirpath folder. If dirpath already exists and overwrite is False,
will append a '+' suffix to dirpath until dirpath does not exist. | [
"Will",
"create",
"dirpath",
"folder",
".",
"If",
"dirpath",
"already",
"exists",
"and",
"overwrite",
"is",
"False",
"will",
"append",
"a",
"+",
"suffix",
"to",
"dirpath",
"until",
"dirpath",
"does",
"not",
"exist",
"."
] | python | valid |
tensorflow/tensor2tensor | tensor2tensor/models/transformer.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/transformer.py#L1736-L1742 | def transformer_ada_lmpackedbase_dialog():
"""Set of hyperparameters."""
hparams = transformer_base_vq_ada_32ex_packed()
hparams.max_length = 1024
hparams.ffn_layer = "dense_relu_dense"
hparams.batch_size = 4096
return hparams | [
"def",
"transformer_ada_lmpackedbase_dialog",
"(",
")",
":",
"hparams",
"=",
"transformer_base_vq_ada_32ex_packed",
"(",
")",
"hparams",
".",
"max_length",
"=",
"1024",
"hparams",
".",
"ffn_layer",
"=",
"\"dense_relu_dense\"",
"hparams",
".",
"batch_size",
"=",
"4096"... | Set of hyperparameters. | [
"Set",
"of",
"hyperparameters",
"."
] | python | train |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2419-L2422 | def oauth_client_create(self, data, **kwargs):
"https://developer.zendesk.com/rest_api/docs/core/oauth_clients#create-client"
api_path = "/api/v2/oauth/clients.json"
return self.call(api_path, method="POST", data=data, **kwargs) | [
"def",
"oauth_client_create",
"(",
"self",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/oauth/clients.json\"",
"return",
"self",
".",
"call",
"(",
"api_path",
",",
"method",
"=",
"\"POST\"",
",",
"data",
"=",
"data",
",",
"*"... | https://developer.zendesk.com/rest_api/docs/core/oauth_clients#create-client | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"core",
"/",
"oauth_clients#create",
"-",
"client"
] | python | train |
IdentityPython/pysaml2 | example/idp2/idp_uwsgi.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/example/idp2/idp_uwsgi.py#L342-L389 | def redirect(self):
""" This is the HTTP-redirect endpoint """
logger.info("--- In SSO Redirect ---")
saml_msg = self.unpack_redirect()
try:
_key = saml_msg["key"]
saml_msg = IDP.ticket[_key]
self.req_info = saml_msg["req_info"]
del IDP.t... | [
"def",
"redirect",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"--- In SSO Redirect ---\"",
")",
"saml_msg",
"=",
"self",
".",
"unpack_redirect",
"(",
")",
"try",
":",
"_key",
"=",
"saml_msg",
"[",
"\"key\"",
"]",
"saml_msg",
"=",
"IDP",
".",
"t... | This is the HTTP-redirect endpoint | [
"This",
"is",
"the",
"HTTP",
"-",
"redirect",
"endpoint"
] | python | train |
Jammy2211/PyAutoLens | autolens/model/profiles/geometry_profiles.py | https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L75-L119 | def move_grid_to_radial_minimum(func):
""" Checks whether any coordinates in the grid are radially near (0.0, 0.0), which can lead to numerical faults in \
the evaluation of a light or mass profiles. If any coordinates are radially within the the radial minimum \
threshold, their (y,x) coordinates are shift... | [
"def",
"move_grid_to_radial_minimum",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"profile",
",",
"grid",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"\n\n Parameters\n ----------\n profile : Sp... | Checks whether any coordinates in the grid are radially near (0.0, 0.0), which can lead to numerical faults in \
the evaluation of a light or mass profiles. If any coordinates are radially within the the radial minimum \
threshold, their (y,x) coordinates are shifted to that value to ensure they are evaluated c... | [
"Checks",
"whether",
"any",
"coordinates",
"in",
"the",
"grid",
"are",
"radially",
"near",
"(",
"0",
".",
"0",
"0",
".",
"0",
")",
"which",
"can",
"lead",
"to",
"numerical",
"faults",
"in",
"\\",
"the",
"evaluation",
"of",
"a",
"light",
"or",
"mass",
... | python | valid |
ranaroussi/qtpylib | qtpylib/tools.py | https://github.com/ranaroussi/qtpylib/blob/0dbbc465fafd9cb9b0f4d10e1e07fae4e15032dd/qtpylib/tools.py#L459-L473 | def get_timezone(as_timedelta=False):
""" utility to get the machine's timezone """
try:
offset_hour = -(time.altzone if time.daylight else time.timezone)
except Exception as e:
offset_hour = -(datetime.datetime.now() -
datetime.datetime.utcnow()).seconds
offset_... | [
"def",
"get_timezone",
"(",
"as_timedelta",
"=",
"False",
")",
":",
"try",
":",
"offset_hour",
"=",
"-",
"(",
"time",
".",
"altzone",
"if",
"time",
".",
"daylight",
"else",
"time",
".",
"timezone",
")",
"except",
"Exception",
"as",
"e",
":",
"offset_hour... | utility to get the machine's timezone | [
"utility",
"to",
"get",
"the",
"machine",
"s",
"timezone"
] | python | train |
pandas-dev/pandas | pandas/core/internals/blocks.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/blocks.py#L2508-L2519 | def _try_coerce_result(self, result):
""" reverse of try_coerce_args / try_operate """
if isinstance(result, np.ndarray):
mask = isna(result)
if result.dtype.kind in ['i', 'f']:
result = result.astype('m8[ns]')
result[mask] = tslibs.iNaT
elif ... | [
"def",
"_try_coerce_result",
"(",
"self",
",",
"result",
")",
":",
"if",
"isinstance",
"(",
"result",
",",
"np",
".",
"ndarray",
")",
":",
"mask",
"=",
"isna",
"(",
"result",
")",
"if",
"result",
".",
"dtype",
".",
"kind",
"in",
"[",
"'i'",
",",
"'... | reverse of try_coerce_args / try_operate | [
"reverse",
"of",
"try_coerce_args",
"/",
"try_operate"
] | python | train |
bskinn/opan | opan/xyz.py | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L725-L770 | def geom_iter(self, g_nums):
"""Iterator over a subset of geometries.
The indices of the geometries to be returned are indicated by an
iterable of |int|\\ s passed as `g_nums`.
As with :meth:`geom_single`, each geometry is returned as a
length-3N |npfloat_| with each atom's x/y... | [
"def",
"geom_iter",
"(",
"self",
",",
"g_nums",
")",
":",
"# Using the custom coded pack_tups to not have to care whether the",
"# input is iterable",
"from",
".",
"utils",
"import",
"pack_tups",
"vals",
"=",
"pack_tups",
"(",
"g_nums",
")",
"for",
"val",
"in",
"vals... | Iterator over a subset of geometries.
The indices of the geometries to be returned are indicated by an
iterable of |int|\\ s passed as `g_nums`.
As with :meth:`geom_single`, each geometry is returned as a
length-3N |npfloat_| with each atom's x/y/z coordinates
grouped together:... | [
"Iterator",
"over",
"a",
"subset",
"of",
"geometries",
"."
] | python | train |
Contraz/demosys-py | demosys/project/base.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/project/base.py#L270-L276 | def get_runnable_effects(self) -> List[Effect]:
"""
Returns all runnable effects in the project.
:return: List of all runnable effects
"""
return [effect for name, effect in self._effects.items() if effect.runnable] | [
"def",
"get_runnable_effects",
"(",
"self",
")",
"->",
"List",
"[",
"Effect",
"]",
":",
"return",
"[",
"effect",
"for",
"name",
",",
"effect",
"in",
"self",
".",
"_effects",
".",
"items",
"(",
")",
"if",
"effect",
".",
"runnable",
"]"
] | Returns all runnable effects in the project.
:return: List of all runnable effects | [
"Returns",
"all",
"runnable",
"effects",
"in",
"the",
"project",
".",
":",
"return",
":",
"List",
"of",
"all",
"runnable",
"effects"
] | python | valid |
captin411/ofxclient | ofxclient/institution.py | https://github.com/captin411/ofxclient/blob/4da2719f0ecbbf5eee62fb82c1b3b34ec955ee5e/ofxclient/institution.py#L98-L132 | def authenticate(self, username=None, password=None):
"""Test the authentication credentials
Raises a ``ValueError`` if there is a problem authenticating
with the human readable reason given by the institution.
:param username: optional username (use self.username by default)
:... | [
"def",
"authenticate",
"(",
"self",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"u",
"=",
"self",
".",
"username",
"p",
"=",
"self",
".",
"password",
"if",
"username",
"and",
"password",
":",
"u",
"=",
"username",
"p",
"=",
... | Test the authentication credentials
Raises a ``ValueError`` if there is a problem authenticating
with the human readable reason given by the institution.
:param username: optional username (use self.username by default)
:type username: string or None
:param password: optional p... | [
"Test",
"the",
"authentication",
"credentials"
] | python | train |
acutesoftware/virtual-AI-simulator | vais/envirosim.py | https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/envirosim.py#L79-L88 | def get_affects_for_param(self, nme):
"""
searches all affects and returns a list
that affect the param named 'nme'
"""
res = []
for a in self.affects:
if a.name == nme:
res.append(a)
return res | [
"def",
"get_affects_for_param",
"(",
"self",
",",
"nme",
")",
":",
"res",
"=",
"[",
"]",
"for",
"a",
"in",
"self",
".",
"affects",
":",
"if",
"a",
".",
"name",
"==",
"nme",
":",
"res",
".",
"append",
"(",
"a",
")",
"return",
"res"
] | searches all affects and returns a list
that affect the param named 'nme' | [
"searches",
"all",
"affects",
"and",
"returns",
"a",
"list",
"that",
"affect",
"the",
"param",
"named",
"nme"
] | python | train |
cldf/clts | src/pyclts/transcriptionsystem.py | https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/transcriptionsystem.py#L179-L276 | def _parse(self, string):
"""Parse a string and return its features.
:param string: A one-symbol string in NFD
Notes
-----
Strategy is rather simple: we determine the base part of a string and
then search left and right of this part for the additional features as
... | [
"def",
"_parse",
"(",
"self",
",",
"string",
")",
":",
"nstring",
"=",
"self",
".",
"_norm",
"(",
"string",
")",
"# check whether sound is in self.sounds",
"if",
"nstring",
"in",
"self",
".",
"sounds",
":",
"sound",
"=",
"self",
".",
"sounds",
"[",
"nstrin... | Parse a string and return its features.
:param string: A one-symbol string in NFD
Notes
-----
Strategy is rather simple: we determine the base part of a string and
then search left and right of this part for the additional features as
expressed by the diacritics. Fails ... | [
"Parse",
"a",
"string",
"and",
"return",
"its",
"features",
"."
] | python | valid |
mrstephenneal/mysql-toolkit | mysql/toolkit/components/operations/remove.py | https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/components/operations/remove.py#L5-L11 | def truncate(self, table):
"""Empty a table by deleting all of its rows."""
if isinstance(table, (list, set, tuple)):
for t in table:
self._truncate(t)
else:
self._truncate(table) | [
"def",
"truncate",
"(",
"self",
",",
"table",
")",
":",
"if",
"isinstance",
"(",
"table",
",",
"(",
"list",
",",
"set",
",",
"tuple",
")",
")",
":",
"for",
"t",
"in",
"table",
":",
"self",
".",
"_truncate",
"(",
"t",
")",
"else",
":",
"self",
"... | Empty a table by deleting all of its rows. | [
"Empty",
"a",
"table",
"by",
"deleting",
"all",
"of",
"its",
"rows",
"."
] | python | train |
apple/turicreate | src/unity/python/turicreate/data_structures/sgraph.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sgraph.py#L1326-L1368 | def _vertex_data_to_sframe(data, vid_field):
"""
Convert data into a vertex data sframe. Using vid_field to identify the id
column. The returned sframe will have id column name '__id'.
"""
if isinstance(data, SFrame):
# '__id' already in the sframe, and it is ok to not specify vid_field
... | [
"def",
"_vertex_data_to_sframe",
"(",
"data",
",",
"vid_field",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"SFrame",
")",
":",
"# '__id' already in the sframe, and it is ok to not specify vid_field",
"if",
"vid_field",
"is",
"None",
"and",
"_VID_COLUMN",
"in",
"d... | Convert data into a vertex data sframe. Using vid_field to identify the id
column. The returned sframe will have id column name '__id'. | [
"Convert",
"data",
"into",
"a",
"vertex",
"data",
"sframe",
".",
"Using",
"vid_field",
"to",
"identify",
"the",
"id",
"column",
".",
"The",
"returned",
"sframe",
"will",
"have",
"id",
"column",
"name",
"__id",
"."
] | python | train |
bitesofcode/projexui | projexui/dialogs/xmessagebox.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xmessagebox.py#L25-L36 | def setVisible( self, state ):
"""
Updates the visible state for this message box.
:param state | <bool>
"""
super(XMessageBox, self).setVisible(state)
if ( state ):
self.startTimer(100)
self.layout().setSizeConstraint(QLayou... | [
"def",
"setVisible",
"(",
"self",
",",
"state",
")",
":",
"super",
"(",
"XMessageBox",
",",
"self",
")",
".",
"setVisible",
"(",
"state",
")",
"if",
"(",
"state",
")",
":",
"self",
".",
"startTimer",
"(",
"100",
")",
"self",
".",
"layout",
"(",
")"... | Updates the visible state for this message box.
:param state | <bool> | [
"Updates",
"the",
"visible",
"state",
"for",
"this",
"message",
"box",
".",
":",
"param",
"state",
"|",
"<bool",
">"
] | python | train |
rwl/pylon | pyreto/rlopf.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L241-L253 | def getActorLimits(self):
""" Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)],
one tuple per parameter, giving min and max for that parameter.
"""
generators = [g for g in self.env.case.online_generators
if g.bus.type != REFERENCE]
limits =... | [
"def",
"getActorLimits",
"(",
"self",
")",
":",
"generators",
"=",
"[",
"g",
"for",
"g",
"in",
"self",
".",
"env",
".",
"case",
".",
"online_generators",
"if",
"g",
".",
"bus",
".",
"type",
"!=",
"REFERENCE",
"]",
"limits",
"=",
"[",
"]",
"for",
"g... | Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)],
one tuple per parameter, giving min and max for that parameter. | [
"Returns",
"a",
"list",
"of",
"2",
"-",
"tuples",
"e",
".",
"g",
".",
"[",
"(",
"-",
"3",
".",
"14",
"3",
".",
"14",
")",
"(",
"-",
"0",
".",
"001",
"0",
".",
"001",
")",
"]",
"one",
"tuple",
"per",
"parameter",
"giving",
"min",
"and",
"max... | python | train |
unbit/sftpclone | sftpclone/sftpclone.py | https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L415-L445 | def check_for_deletion(self, relative_path=None):
"""Traverse the entire remote_path tree.
Find files/directories that need to be deleted,
not being present in the local folder.
"""
if not relative_path:
relative_path = str() # root of shared directory tree
... | [
"def",
"check_for_deletion",
"(",
"self",
",",
"relative_path",
"=",
"None",
")",
":",
"if",
"not",
"relative_path",
":",
"relative_path",
"=",
"str",
"(",
")",
"# root of shared directory tree",
"remote_path",
"=",
"path_join",
"(",
"self",
".",
"remote_path",
... | Traverse the entire remote_path tree.
Find files/directories that need to be deleted,
not being present in the local folder. | [
"Traverse",
"the",
"entire",
"remote_path",
"tree",
"."
] | python | train |
tradenity/python-sdk | tradenity/resources/table_rate_rule.py | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/table_rate_rule.py#L492-L512 | def get_table_rate_rule_by_id(cls, table_rate_rule_id, **kwargs):
"""Find TableRateRule
Return single instance of TableRateRule by its ID.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_t... | [
"def",
"get_table_rate_rule_by_id",
"(",
"cls",
",",
"table_rate_rule_id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async'",
")",
":",
"return",
"cls",
".",
"_get_table... | Find TableRateRule
Return single instance of TableRateRule by its ID.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_table_rate_rule_by_id(table_rate_rule_id, async=True)
>>> result = thr... | [
"Find",
"TableRateRule"
] | python | train |
mgraffg/EvoDAG | EvoDAG/model.py | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/model.py#L438-L445 | def graphviz(self, directory, **kwargs):
"Directory to store the graphviz models"
import os
if not os.path.isdir(directory):
os.mkdir(directory)
output = os.path.join(directory, 'evodag-%s')
for k, m in enumerate(self.models):
m.graphviz(output % k, **kwar... | [
"def",
"graphviz",
"(",
"self",
",",
"directory",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"os",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"os",
".",
"mkdir",
"(",
"directory",
")",
"output",
"=",
"os",
".",
"p... | Directory to store the graphviz models | [
"Directory",
"to",
"store",
"the",
"graphviz",
"models"
] | python | train |
stephenmcd/sphinx-me | sphinx_me.py | https://github.com/stephenmcd/sphinx-me/blob/9f51a04d58a90834a787246ce475a564b4f9e5ee/sphinx_me.py#L21-L57 | def install():
"""
Main entry point for running sphinx_me as a script.
Creates a docs directory in the current directory and adds the
required files for generating Sphinx docs from the project's
README file - a conf module that calls setup_conf() from this
module, and an index file that includes... | [
"def",
"install",
"(",
")",
":",
"for",
"name",
"in",
"listdir",
"(",
"getcwd",
"(",
")",
")",
":",
"if",
"splitext",
"(",
"name",
")",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"==",
"\"README\"",
":",
"readme",
"=",
"name",
"break",
"else",
":",
... | Main entry point for running sphinx_me as a script.
Creates a docs directory in the current directory and adds the
required files for generating Sphinx docs from the project's
README file - a conf module that calls setup_conf() from this
module, and an index file that includes the project's README. | [
"Main",
"entry",
"point",
"for",
"running",
"sphinx_me",
"as",
"a",
"script",
".",
"Creates",
"a",
"docs",
"directory",
"in",
"the",
"current",
"directory",
"and",
"adds",
"the",
"required",
"files",
"for",
"generating",
"Sphinx",
"docs",
"from",
"the",
"pro... | python | train |
hozn/coilmq | coilmq/store/sa/__init__.py | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/sa/__init__.py#L169-L187 | def size(self, destination):
"""
Size of the queue for specified destination.
@param destination: The queue destination (e.g. /queue/foo)
@type destination: C{str}
@return: The number of frames in specified queue.
@rtype: C{int}
"""
session = meta.Sessio... | [
"def",
"size",
"(",
"self",
",",
"destination",
")",
":",
"session",
"=",
"meta",
".",
"Session",
"(",
")",
"sel",
"=",
"select",
"(",
"[",
"func",
".",
"count",
"(",
"model",
".",
"frames_table",
".",
"c",
".",
"message_id",
")",
"]",
")",
".",
... | Size of the queue for specified destination.
@param destination: The queue destination (e.g. /queue/foo)
@type destination: C{str}
@return: The number of frames in specified queue.
@rtype: C{int} | [
"Size",
"of",
"the",
"queue",
"for",
"specified",
"destination",
"."
] | python | train |
solvebio/solvebio-python | solvebio/cli/auth.py | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/auth.py#L48-L75 | def login(*args, **kwargs):
"""
Prompt user for login information (domain/email/password).
Domain, email and password are used to get the user's API key.
Always updates the stored credentials file.
"""
if args and args[0].api_key:
# Handle command-line arguments if provided.
sol... | [
"def",
"login",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
"and",
"args",
"[",
"0",
"]",
".",
"api_key",
":",
"# Handle command-line arguments if provided.",
"solvebio",
".",
"login",
"(",
"api_key",
"=",
"args",
"[",
"0",
"]",
... | Prompt user for login information (domain/email/password).
Domain, email and password are used to get the user's API key.
Always updates the stored credentials file. | [
"Prompt",
"user",
"for",
"login",
"information",
"(",
"domain",
"/",
"email",
"/",
"password",
")",
".",
"Domain",
"email",
"and",
"password",
"are",
"used",
"to",
"get",
"the",
"user",
"s",
"API",
"key",
"."
] | python | test |
Kortemme-Lab/pull_into_place | pull_into_place/structures.py | https://github.com/Kortemme-Lab/pull_into_place/blob/247f303100a612cc90cf31c86e4fe5052eb28c8d/pull_into_place/structures.py#L121-L449 | def read_and_calculate(workspace, pdb_paths):
"""
Calculate a variety of score and distance metrics for the given structures.
"""
# Parse the given restraints file. The restraints definitions are used to
# calculate the "restraint_dist" metric, which reflects how well each
# structure achieves... | [
"def",
"read_and_calculate",
"(",
"workspace",
",",
"pdb_paths",
")",
":",
"# Parse the given restraints file. The restraints definitions are used to",
"# calculate the \"restraint_dist\" metric, which reflects how well each",
"# structure achieves the desired geometry. Note that this is calcul... | Calculate a variety of score and distance metrics for the given structures. | [
"Calculate",
"a",
"variety",
"of",
"score",
"and",
"distance",
"metrics",
"for",
"the",
"given",
"structures",
"."
] | python | train |
KE-works/pykechain | pykechain/client.py | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L870-L901 | def teams(self, name=None, id=None, is_hidden=False, **kwargs):
"""
Teams of KE-chain.
Provide a list of :class:`Team`s of KE-chain. You can filter on teamname or id or any other advanced filter.
:param name: (optional) teamname to filter
:type name: basestring or None
... | [
"def",
"teams",
"(",
"self",
",",
"name",
"=",
"None",
",",
"id",
"=",
"None",
",",
"is_hidden",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"request_params",
"=",
"{",
"'name'",
":",
"name",
",",
"'id'",
":",
"id",
",",
"'is_hidden'",
":",
... | Teams of KE-chain.
Provide a list of :class:`Team`s of KE-chain. You can filter on teamname or id or any other advanced filter.
:param name: (optional) teamname to filter
:type name: basestring or None
:param id: (optional) id of the team to filter
:type id: basestring or None
... | [
"Teams",
"of",
"KE",
"-",
"chain",
"."
] | python | train |
python-bugzilla/python-bugzilla | bugzilla/rhbugzilla.py | https://github.com/python-bugzilla/python-bugzilla/blob/7de8b225104f24a1eee3e837bf1e02d60aefe69f/bugzilla/rhbugzilla.py#L160-L207 | def update_external_tracker(self, ids=None, ext_type_id=None,
ext_type_description=None, ext_type_url=None,
ext_bz_bug_id=None, bug_ids=None,
ext_status=None, ext_description=None,
ext_priorit... | [
"def",
"update_external_tracker",
"(",
"self",
",",
"ids",
"=",
"None",
",",
"ext_type_id",
"=",
"None",
",",
"ext_type_description",
"=",
"None",
",",
"ext_type_url",
"=",
"None",
",",
"ext_bz_bug_id",
"=",
"None",
",",
"bug_ids",
"=",
"None",
",",
"ext_sta... | Wrapper method to allow adding of external tracking bugs using the
ExternalBugs::WebService::update_external_bug method.
This is documented at
https://bugzilla.redhat.com/docs/en/html/api/extensions/ExternalBugs/lib/WebService.html#update_external_bug
ids: A single external tracker bug... | [
"Wrapper",
"method",
"to",
"allow",
"adding",
"of",
"external",
"tracking",
"bugs",
"using",
"the",
"ExternalBugs",
"::",
"WebService",
"::",
"update_external_bug",
"method",
"."
] | python | train |
pantsbuild/pants | src/python/pants/source/wrapped_globs.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/source/wrapped_globs.py#L176-L211 | def create_fileset_with_spec(cls, rel_path, *patterns, **kwargs):
"""
:param rel_path: The relative path to create a FilesetWithSpec for.
:param patterns: glob patterns to apply.
:param exclude: A list of {,r,z}globs objects, strings, or lists of strings to exclude.
NB: this argument... | [
"def",
"create_fileset_with_spec",
"(",
"cls",
",",
"rel_path",
",",
"*",
"patterns",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"pattern",
"in",
"patterns",
":",
"if",
"not",
"isinstance",
"(",
"pattern",
",",
"string_types",
")",
":",
"raise",
"ValueError... | :param rel_path: The relative path to create a FilesetWithSpec for.
:param patterns: glob patterns to apply.
:param exclude: A list of {,r,z}globs objects, strings, or lists of strings to exclude.
NB: this argument is contained within **kwargs! | [
":",
"param",
"rel_path",
":",
"The",
"relative",
"path",
"to",
"create",
"a",
"FilesetWithSpec",
"for",
".",
":",
"param",
"patterns",
":",
"glob",
"patterns",
"to",
"apply",
".",
":",
"param",
"exclude",
":",
"A",
"list",
"of",
"{",
"r",
"z",
"}",
... | python | train |
sentinel-hub/eo-learn | core/eolearn/core/graph.py | https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/graph.py#L187-L208 | def _is_cyclic(dag):
"""True if the directed graph dag contains a cycle. False otherwise.
The algorithm is naive, running in O(V^2) time, and not intended for serious use! For production purposes on
larger graphs consider implementing Tarjan's O(V+E)-time algorithm instead.
:type... | [
"def",
"_is_cyclic",
"(",
"dag",
")",
":",
"# pylint: disable=invalid-name\r",
"vertices",
"=",
"dag",
".",
"vertices",
"(",
")",
"for",
"w",
"in",
"vertices",
":",
"stack",
"=",
"[",
"w",
"]",
"seen",
"=",
"set",
"(",
")",
"while",
"stack",
":",
"u",
... | True if the directed graph dag contains a cycle. False otherwise.
The algorithm is naive, running in O(V^2) time, and not intended for serious use! For production purposes on
larger graphs consider implementing Tarjan's O(V+E)-time algorithm instead.
:type dag: DirectedGraph | [
"True",
"if",
"the",
"directed",
"graph",
"dag",
"contains",
"a",
"cycle",
".",
"False",
"otherwise",
".",
"The",
"algorithm",
"is",
"naive",
"running",
"in",
"O",
"(",
"V^2",
")",
"time",
"and",
"not",
"intended",
"for",
"serious",
"use!",
"For",
"produ... | python | train |
gboeing/osmnx | osmnx/core.py | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1525-L1601 | def graph_from_point(center_point, distance=1000, distance_type='bbox',
network_type='all_private', simplify=True, retain_all=False,
truncate_by_edge=False, name='unnamed', timeout=180,
memory=None, max_query_area_size=50*1000*50*1000,
... | [
"def",
"graph_from_point",
"(",
"center_point",
",",
"distance",
"=",
"1000",
",",
"distance_type",
"=",
"'bbox'",
",",
"network_type",
"=",
"'all_private'",
",",
"simplify",
"=",
"True",
",",
"retain_all",
"=",
"False",
",",
"truncate_by_edge",
"=",
"False",
... | Create a networkx graph from OSM data within some distance of some (lat,
lon) center point.
Parameters
----------
center_point : tuple
the (lat, lon) central point around which to construct the graph
distance : int
retain only those nodes within this many meters of the center of the... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"within",
"some",
"distance",
"of",
"some",
"(",
"lat",
"lon",
")",
"center",
"point",
"."
] | python | train |
cltk/cltk | cltk/stem/akkadian/atf_converter.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/stem/akkadian/atf_converter.py#L66-L79 | def _convert_number_to_subscript(num):
"""
Converts number into subscript
input = ["a", "a1", "a2", "a3", "be2", "be3", "bad2", "bad3"]
output = ["a", "a₁", "a₂", "a₃", "be₂", "be₃", "bad₂", "bad₃"]
:param num: number called after sign
:return: number in subscript
... | [
"def",
"_convert_number_to_subscript",
"(",
"num",
")",
":",
"subscript",
"=",
"''",
"for",
"character",
"in",
"str",
"(",
"num",
")",
":",
"subscript",
"+=",
"chr",
"(",
"0x2080",
"+",
"int",
"(",
"character",
")",
")",
"return",
"subscript"
] | Converts number into subscript
input = ["a", "a1", "a2", "a3", "be2", "be3", "bad2", "bad3"]
output = ["a", "a₁", "a₂", "a₃", "be₂", "be₃", "bad₂", "bad₃"]
:param num: number called after sign
:return: number in subscript | [
"Converts",
"number",
"into",
"subscript"
] | python | train |
Kortemme-Lab/klab | klab/benchmarking/analysis/ddg_monomeric_stability_analysis.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ddg_monomeric_stability_analysis.py#L862-L993 | def analyze_multiple(
benchmark_runs,
analysis_sets = [],
# Singleton arguments
analysis_directory = None,
remove_existing_analysis_directory = True,
quick_plots = False,
use_multiprocessing = True,
verbose = True,
... | [
"def",
"analyze_multiple",
"(",
"benchmark_runs",
",",
"analysis_sets",
"=",
"[",
"]",
",",
"# Singleton arguments",
"analysis_directory",
"=",
"None",
",",
"remove_existing_analysis_directory",
"=",
"True",
",",
"quick_plots",
"=",
"False",
",",
"use_multiprocessing",
... | This function runs the analysis for multiple input settings | [
"This",
"function",
"runs",
"the",
"analysis",
"for",
"multiple",
"input",
"settings"
] | python | train |
wndhydrnt/python-oauth2 | oauth2/client_authenticator.py | https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/client_authenticator.py#L123-L151 | def http_basic_auth(request):
"""
Extracts the credentials of a client using HTTP Basic Auth.
Expects the ``client_id`` to be the username and the ``client_secret`` to
be the password part of the Authorization header.
:param request: The incoming request
:type request: oauth2.web.Request
... | [
"def",
"http_basic_auth",
"(",
"request",
")",
":",
"auth_header",
"=",
"request",
".",
"header",
"(",
"\"authorization\"",
")",
"if",
"auth_header",
"is",
"None",
":",
"raise",
"OAuthInvalidError",
"(",
"error",
"=",
"\"invalid_request\"",
",",
"explanation",
"... | Extracts the credentials of a client using HTTP Basic Auth.
Expects the ``client_id`` to be the username and the ``client_secret`` to
be the password part of the Authorization header.
:param request: The incoming request
:type request: oauth2.web.Request
:return: A tuple in the format of (<CLIENT... | [
"Extracts",
"the",
"credentials",
"of",
"a",
"client",
"using",
"HTTP",
"Basic",
"Auth",
"."
] | python | train |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/rest.py | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/rest.py#L21-L92 | def create_requests_session(
retries=None,
backoff_factor=None,
status_forcelist=None,
pools_size=4,
maxsize=4,
ssl_verify=None,
ssl_cert=None,
proxy=None,
session=None,
):
"""Create a requests session that retries some errors."""
# pylint: disable=too-many-branches
confi... | [
"def",
"create_requests_session",
"(",
"retries",
"=",
"None",
",",
"backoff_factor",
"=",
"None",
",",
"status_forcelist",
"=",
"None",
",",
"pools_size",
"=",
"4",
",",
"maxsize",
"=",
"4",
",",
"ssl_verify",
"=",
"None",
",",
"ssl_cert",
"=",
"None",
",... | Create a requests session that retries some errors. | [
"Create",
"a",
"requests",
"session",
"that",
"retries",
"some",
"errors",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.