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 |
|---|---|---|---|---|---|---|---|---|
O365/python-o365 | O365/message.py | https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/message.py#L613-L638 | def reply(self, to_all=True):
""" Creates a new message that is a reply to this message
:param bool to_all: whether or not to replies to all the recipients
instead to just the sender
:return: new message
:rtype: Message
"""
if not self.object_id or self.__is_dr... | [
"def",
"reply",
"(",
"self",
",",
"to_all",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"object_id",
"or",
"self",
".",
"__is_draft",
":",
"raise",
"RuntimeError",
"(",
"\"Can't reply to this message\"",
")",
"if",
"to_all",
":",
"url",
"=",
"self",
... | Creates a new message that is a reply to this message
:param bool to_all: whether or not to replies to all the recipients
instead to just the sender
:return: new message
:rtype: Message | [
"Creates",
"a",
"new",
"message",
"that",
"is",
"a",
"reply",
"to",
"this",
"message"
] | python | train |
pdkit/pdkit | pdkit/tremor_processor.py | https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/tremor_processor.py#L94-L115 | def filter_signal(self, data_frame, ts='mag_sum_acc'):
"""
This method filters a data frame signal as suggested in :cite:`Kassavetis2015`. First step is to high \
pass filter the data frame using a \
`Butterworth <https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/sc... | [
"def",
"filter_signal",
"(",
"self",
",",
"data_frame",
",",
"ts",
"=",
"'mag_sum_acc'",
")",
":",
"b",
",",
"a",
"=",
"signal",
".",
"butter",
"(",
"self",
".",
"filter_order",
",",
"2",
"*",
"self",
".",
"cutoff_frequency",
"/",
"self",
".",
"samplin... | This method filters a data frame signal as suggested in :cite:`Kassavetis2015`. First step is to high \
pass filter the data frame using a \
`Butterworth <https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.butter.html>`_ \
digital and analog filter. Then this me... | [
"This",
"method",
"filters",
"a",
"data",
"frame",
"signal",
"as",
"suggested",
"in",
":",
"cite",
":",
"Kassavetis2015",
".",
"First",
"step",
"is",
"to",
"high",
"\\",
"pass",
"filter",
"the",
"data",
"frame",
"using",
"a",
"\\",
"Butterworth",
"<https",... | python | train |
rootpy/rootpy | rootpy/plotting/utils.py | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/utils.py#L151-L194 | def _limits_helper(x1, x2, a, b, snap=False):
"""
Given x1, x2, a, b, where:
x1 - x0 x3 - x2
a = ------- , b = -------
x3 - x0 x3 - x0
determine the points x0 and x3:
x0 x1 x2 x3
|----------|-----------------|--------|
"""
... | [
"def",
"_limits_helper",
"(",
"x1",
",",
"x2",
",",
"a",
",",
"b",
",",
"snap",
"=",
"False",
")",
":",
"if",
"x2",
"<",
"x1",
":",
"raise",
"ValueError",
"(",
"\"x2 < x1\"",
")",
"if",
"a",
"+",
"b",
">=",
"1",
":",
"raise",
"ValueError",
"(",
... | Given x1, x2, a, b, where:
x1 - x0 x3 - x2
a = ------- , b = -------
x3 - x0 x3 - x0
determine the points x0 and x3:
x0 x1 x2 x3
|----------|-----------------|--------| | [
"Given",
"x1",
"x2",
"a",
"b",
"where",
":"
] | python | train |
3ll3d00d/vibe | backend/src/analyser/common/signal.py | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L155-L177 | def spectrogram(self, ref=None, segmentLengthMultiplier=1, window='hann'):
"""
analyses the source to generate a spectrogram
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:return:
t : ndarray
... | [
"def",
"spectrogram",
"(",
"self",
",",
"ref",
"=",
"None",
",",
"segmentLengthMultiplier",
"=",
"1",
",",
"window",
"=",
"'hann'",
")",
":",
"t",
",",
"f",
",",
"Sxx",
"=",
"signal",
".",
"spectrogram",
"(",
"self",
".",
"samples",
",",
"self",
".",... | analyses the source to generate a spectrogram
:param ref: the reference value for dB purposes.
:param segmentLengthMultiplier: allow for increased resolution.
:return:
t : ndarray
Array of time slices.
f : ndarray
Array of sample frequencies.
... | [
"analyses",
"the",
"source",
"to",
"generate",
"a",
"spectrogram",
":",
"param",
"ref",
":",
"the",
"reference",
"value",
"for",
"dB",
"purposes",
".",
":",
"param",
"segmentLengthMultiplier",
":",
"allow",
"for",
"increased",
"resolution",
".",
":",
"return",... | python | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1804-L1812 | def act(self):
"""
Carries out the action associated with the Unfreeze button
"""
g = get_root(self).globals
g.ipars.unfreeze()
g.rpars.unfreeze()
g.observe.load.enable()
self.disable() | [
"def",
"act",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"g",
".",
"ipars",
".",
"unfreeze",
"(",
")",
"g",
".",
"rpars",
".",
"unfreeze",
"(",
")",
"g",
".",
"observe",
".",
"load",
".",
"enable",
"(",
")",
... | Carries out the action associated with the Unfreeze button | [
"Carries",
"out",
"the",
"action",
"associated",
"with",
"the",
"Unfreeze",
"button"
] | python | train |
boriel/zxbasic | arch/zx48k/backend/__f16.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__f16.py#L21-L45 | def f16(op):
""" Returns a floating point operand converted to 32 bits unsigned int.
Negative numbers are returned in 2 complement.
The result is returned in a tuple (DE, HL) => High16 (Int part), Low16 (Decimal part)
"""
op = float(op)
negative = op < 0
if negative:
op = -op
... | [
"def",
"f16",
"(",
"op",
")",
":",
"op",
"=",
"float",
"(",
"op",
")",
"negative",
"=",
"op",
"<",
"0",
"if",
"negative",
":",
"op",
"=",
"-",
"op",
"DE",
"=",
"int",
"(",
"op",
")",
"HL",
"=",
"int",
"(",
"(",
"op",
"-",
"DE",
")",
"*",
... | Returns a floating point operand converted to 32 bits unsigned int.
Negative numbers are returned in 2 complement.
The result is returned in a tuple (DE, HL) => High16 (Int part), Low16 (Decimal part) | [
"Returns",
"a",
"floating",
"point",
"operand",
"converted",
"to",
"32",
"bits",
"unsigned",
"int",
".",
"Negative",
"numbers",
"are",
"returned",
"in",
"2",
"complement",
"."
] | python | train |
LionelAuroux/pyrser | pyrser/parsing/base.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/base.py#L304-L312 | def read_until_eof(self) -> bool:
"""Consume all the stream. Same as EOF in BNF."""
if self.read_eof():
return True
# TODO: read ALL
self._stream.save_context()
while not self.read_eof():
self._stream.incpos()
return self._stream.validate_context() | [
"def",
"read_until_eof",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"read_eof",
"(",
")",
":",
"return",
"True",
"# TODO: read ALL",
"self",
".",
"_stream",
".",
"save_context",
"(",
")",
"while",
"not",
"self",
".",
"read_eof",
"(",
")",
... | Consume all the stream. Same as EOF in BNF. | [
"Consume",
"all",
"the",
"stream",
".",
"Same",
"as",
"EOF",
"in",
"BNF",
"."
] | python | test |
mgaitan/waliki | waliki/acl.py | https://github.com/mgaitan/waliki/blob/5baaf6f043275920a1174ff233726f7ff4bfb5cf/waliki/acl.py#L19-L45 | def check_perms(perms, user, slug, raise_exception=False):
"""a helper user to check if a user has the permissions
for a given slug"""
if isinstance(perms, string_types):
perms = {perms}
else:
perms = set(perms)
allowed_users = ACLRule.get_users_for(perms, slug)
if allowed_user... | [
"def",
"check_perms",
"(",
"perms",
",",
"user",
",",
"slug",
",",
"raise_exception",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"perms",
",",
"string_types",
")",
":",
"perms",
"=",
"{",
"perms",
"}",
"else",
":",
"perms",
"=",
"set",
"(",
"pe... | a helper user to check if a user has the permissions
for a given slug | [
"a",
"helper",
"user",
"to",
"check",
"if",
"a",
"user",
"has",
"the",
"permissions",
"for",
"a",
"given",
"slug"
] | python | train |
secdev/scapy | scapy/utils6.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L462-L482 | def in6_ptoc(addr):
"""
Converts an IPv6 address in printable representation to RFC
1924 Compact Representation ;-)
Returns None on error.
"""
try:
d = struct.unpack("!IIII", inet_pton(socket.AF_INET6, addr))
except Exception:
return None
res = 0
m = [2**96, 2**64, 2*... | [
"def",
"in6_ptoc",
"(",
"addr",
")",
":",
"try",
":",
"d",
"=",
"struct",
".",
"unpack",
"(",
"\"!IIII\"",
",",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"addr",
")",
")",
"except",
"Exception",
":",
"return",
"None",
"res",
"=",
"0",
"m",
... | Converts an IPv6 address in printable representation to RFC
1924 Compact Representation ;-)
Returns None on error. | [
"Converts",
"an",
"IPv6",
"address",
"in",
"printable",
"representation",
"to",
"RFC",
"1924",
"Compact",
"Representation",
";",
"-",
")",
"Returns",
"None",
"on",
"error",
"."
] | python | train |
UCSBarchlab/PyRTL | pyrtl/rtllib/adders.py | https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/adders.py#L84-L94 | def carrysave_adder(a, b, c, final_adder=ripple_add):
"""
Adds three wirevectors up in an efficient manner
:param WireVector a, b, c : the three wires to add up
:param function final_adder : The adder to use to do the final addition
:return: a wirevector with length 2 longer than the largest input
... | [
"def",
"carrysave_adder",
"(",
"a",
",",
"b",
",",
"c",
",",
"final_adder",
"=",
"ripple_add",
")",
":",
"a",
",",
"b",
",",
"c",
"=",
"libutils",
".",
"match_bitwidth",
"(",
"a",
",",
"b",
",",
"c",
")",
"partial_sum",
"=",
"a",
"^",
"b",
"^",
... | Adds three wirevectors up in an efficient manner
:param WireVector a, b, c : the three wires to add up
:param function final_adder : The adder to use to do the final addition
:return: a wirevector with length 2 longer than the largest input | [
"Adds",
"three",
"wirevectors",
"up",
"in",
"an",
"efficient",
"manner",
":",
"param",
"WireVector",
"a",
"b",
"c",
":",
"the",
"three",
"wires",
"to",
"add",
"up",
":",
"param",
"function",
"final_adder",
":",
"The",
"adder",
"to",
"use",
"to",
"do",
... | python | train |
hid-io/layouts-python | layouts/__init__.py | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L217-L246 | def dict_merge(self, merge_to, merge_in):
'''
Recursively merges two dicts
Overwrites any non-dictionary items
merge_to <- merge_in
Modifies merge_to dictionary
@param merge_to: Base dictionary to merge into
@param merge_in: Dictionary that may overwrite element... | [
"def",
"dict_merge",
"(",
"self",
",",
"merge_to",
",",
"merge_in",
")",
":",
"for",
"key",
",",
"value",
"in",
"merge_in",
".",
"items",
"(",
")",
":",
"# Just add, if the key doesn't exist yet",
"# Or if set to None/Null",
"if",
"key",
"not",
"in",
"merge_to",... | Recursively merges two dicts
Overwrites any non-dictionary items
merge_to <- merge_in
Modifies merge_to dictionary
@param merge_to: Base dictionary to merge into
@param merge_in: Dictionary that may overwrite elements in merge_in | [
"Recursively",
"merges",
"two",
"dicts"
] | python | train |
ctuning/ck | ck/kernel.py | https://github.com/ctuning/ck/blob/7e009814e975f8742790d3106340088a46223714/ck/kernel.py#L450-L466 | def err(r):
"""
Input: {
return - return code
error - error text
}
Output: Nothing; quits program
"""
import sys
rc=r['return']
re=r['error']
out('Error: '+re)
sys.exit(rc) | [
"def",
"err",
"(",
"r",
")",
":",
"import",
"sys",
"rc",
"=",
"r",
"[",
"'return'",
"]",
"re",
"=",
"r",
"[",
"'error'",
"]",
"out",
"(",
"'Error: '",
"+",
"re",
")",
"sys",
".",
"exit",
"(",
"rc",
")"
] | Input: {
return - return code
error - error text
}
Output: Nothing; quits program | [
"Input",
":",
"{",
"return",
"-",
"return",
"code",
"error",
"-",
"error",
"text",
"}"
] | python | train |
iotile/coretools | iotilecore/iotile/core/hw/auth/auth_chain.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/auth/auth_chain.py#L48-L79 | def encrypt_report(self, device_id, root, data, **kwargs):
"""Encrypt a buffer of report data on behalf of a device.
Args:
device_id (int): The id of the device that we should encrypt for
root (int): The root key type that should be used to generate the report
data (... | [
"def",
"encrypt_report",
"(",
"self",
",",
"device_id",
",",
"root",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"_priority",
",",
"provider",
"in",
"self",
".",
"providers",
":",
"try",
":",
"return",
"provider",
".",
"encrypt_report",
"(",
... | Encrypt a buffer of report data on behalf of a device.
Args:
device_id (int): The id of the device that we should encrypt for
root (int): The root key type that should be used to generate the report
data (bytearray): The data that we should encrypt.
**kwargs: The... | [
"Encrypt",
"a",
"buffer",
"of",
"report",
"data",
"on",
"behalf",
"of",
"a",
"device",
"."
] | python | train |
asphalt-framework/asphalt-templating | asphalt/templating/api.py | https://github.com/asphalt-framework/asphalt-templating/blob/e5f836290820aa295b048b17b96d3896d5f1eeac/asphalt/templating/api.py#L53-L65 | def render(self, template: str, **vars) -> str:
"""
Render the named template.
The current context will be available to the template as the ``ctx`` variable.
:param template: name of the template file
:param vars: extra template variables
:return: the rendered results
... | [
"def",
"render",
"(",
"self",
",",
"template",
":",
"str",
",",
"*",
"*",
"vars",
")",
"->",
"str",
":",
"vars",
".",
"setdefault",
"(",
"'ctx'",
",",
"self",
".",
"_ctx",
")",
"return",
"self",
".",
"_renderer",
".",
"render",
"(",
"template",
","... | Render the named template.
The current context will be available to the template as the ``ctx`` variable.
:param template: name of the template file
:param vars: extra template variables
:return: the rendered results | [
"Render",
"the",
"named",
"template",
"."
] | python | train |
python-xlib/python-xlib | Xlib/rdb.py | https://github.com/python-xlib/python-xlib/blob/8901e831737e79fe5645f48089d70e1d1046d2f2/Xlib/rdb.py#L332-L341 | def output(self):
"""output()
Return the resource database in text representation.
"""
self.lock.acquire()
text = output_db('', self.db)
self.lock.release()
return text | [
"def",
"output",
"(",
"self",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"text",
"=",
"output_db",
"(",
"''",
",",
"self",
".",
"db",
")",
"self",
".",
"lock",
".",
"release",
"(",
")",
"return",
"text"
] | output()
Return the resource database in text representation. | [
"output",
"()"
] | python | train |
google/grumpy | third_party/pypy/datetime.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/datetime.py#L1670-L1679 | def utcoffset(self):
"""Return the timezone offset in minutes east of UTC (negative west of
UTC)."""
if self._tzinfo is None:
return None
offset = self._tzinfo.utcoffset(self)
offset = _check_utc_offset("utcoffset", offset)
if offset is not None:
o... | [
"def",
"utcoffset",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tzinfo",
"is",
"None",
":",
"return",
"None",
"offset",
"=",
"self",
".",
"_tzinfo",
".",
"utcoffset",
"(",
"self",
")",
"offset",
"=",
"_check_utc_offset",
"(",
"\"utcoffset\"",
",",
"offse... | Return the timezone offset in minutes east of UTC (negative west of
UTC). | [
"Return",
"the",
"timezone",
"offset",
"in",
"minutes",
"east",
"of",
"UTC",
"(",
"negative",
"west",
"of",
"UTC",
")",
"."
] | python | valid |
Tanganelli/CoAPthon3 | coapthon/messages/message.py | https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/messages/message.py#L505-L518 | def observe(self):
"""
Check if the request is an observing request.
:return: 0, if the request is an observing request
"""
for option in self.options:
if option.number == defines.OptionRegistry.OBSERVE.number:
# if option.value is None:
... | [
"def",
"observe",
"(",
"self",
")",
":",
"for",
"option",
"in",
"self",
".",
"options",
":",
"if",
"option",
".",
"number",
"==",
"defines",
".",
"OptionRegistry",
".",
"OBSERVE",
".",
"number",
":",
"# if option.value is None:",
"# return 0",
"if",
"opti... | Check if the request is an observing request.
:return: 0, if the request is an observing request | [
"Check",
"if",
"the",
"request",
"is",
"an",
"observing",
"request",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/datarepo.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datarepo.py#L1353-L1362 | def insertPeer(self, peer):
"""
Accepts a peer datamodel object and adds it to the registry.
"""
try:
models.Peer.create(
url=peer.getUrl(),
attributes=json.dumps(peer.getAttributes()))
except Exception as e:
raise exception... | [
"def",
"insertPeer",
"(",
"self",
",",
"peer",
")",
":",
"try",
":",
"models",
".",
"Peer",
".",
"create",
"(",
"url",
"=",
"peer",
".",
"getUrl",
"(",
")",
",",
"attributes",
"=",
"json",
".",
"dumps",
"(",
"peer",
".",
"getAttributes",
"(",
")",
... | Accepts a peer datamodel object and adds it to the registry. | [
"Accepts",
"a",
"peer",
"datamodel",
"object",
"and",
"adds",
"it",
"to",
"the",
"registry",
"."
] | python | train |
noahbenson/pimms | pimms/util.py | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L488-L496 | def curry(f, *args0, **kwargs0):
'''
curry(f, ...) yields a function equivalent to f with all following arguments and keyword
arguments passed. This is much like the partial function, but yields a function instead of
a partial object and thus is suitable for use with pimms lazy maps.
'''
def... | [
"def",
"curry",
"(",
"f",
",",
"*",
"args0",
",",
"*",
"*",
"kwargs0",
")",
":",
"def",
"curried_f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"f",
"(",
"*",
"(",
"args0",
"+",
"args",
")",
",",
"*",
"*",
"merge",
"(",
... | curry(f, ...) yields a function equivalent to f with all following arguments and keyword
arguments passed. This is much like the partial function, but yields a function instead of
a partial object and thus is suitable for use with pimms lazy maps. | [
"curry",
"(",
"f",
"...",
")",
"yields",
"a",
"function",
"equivalent",
"to",
"f",
"with",
"all",
"following",
"arguments",
"and",
"keyword",
"arguments",
"passed",
".",
"This",
"is",
"much",
"like",
"the",
"partial",
"function",
"but",
"yields",
"a",
"fun... | python | train |
bunq/sdk_python | bunq/sdk/model/generated/object_.py | https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/model/generated/object_.py#L5429-L5443 | def is_all_field_none(self):
"""
:rtype: bool
"""
if self._country is not None:
return False
if self._tax_number is not None:
return False
if self._status is not None:
return False
return True | [
"def",
"is_all_field_none",
"(",
"self",
")",
":",
"if",
"self",
".",
"_country",
"is",
"not",
"None",
":",
"return",
"False",
"if",
"self",
".",
"_tax_number",
"is",
"not",
"None",
":",
"return",
"False",
"if",
"self",
".",
"_status",
"is",
"not",
"No... | :rtype: bool | [
":",
"rtype",
":",
"bool"
] | python | train |
bokeh/bokeh | bokeh/models/sources.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/models/sources.py#L325-L343 | def add(self, data, name=None):
''' Appends a new column of data to the data source.
Args:
data (seq) : new data to add
name (str, optional) : column name to use.
If not supplied, generate a name of the form "Series ####"
Returns:
str: the c... | [
"def",
"add",
"(",
"self",
",",
"data",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"n",
"=",
"len",
"(",
"self",
".",
"data",
")",
"while",
"\"Series %d\"",
"%",
"n",
"in",
"self",
".",
"data",
":",
"n",
"+=",
"1",
"... | Appends a new column of data to the data source.
Args:
data (seq) : new data to add
name (str, optional) : column name to use.
If not supplied, generate a name of the form "Series ####"
Returns:
str: the column name used | [
"Appends",
"a",
"new",
"column",
"of",
"data",
"to",
"the",
"data",
"source",
"."
] | python | train |
twilio/twilio-python | twilio/rest/preview/deployed_devices/fleet/device.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/deployed_devices/fleet/device.py#L494-L512 | def update(self, friendly_name=values.unset, identity=values.unset,
deployment_sid=values.unset, enabled=values.unset):
"""
Update the DeviceInstance
:param unicode friendly_name: A human readable description for this Device.
:param unicode identity: An identifier of the ... | [
"def",
"update",
"(",
"self",
",",
"friendly_name",
"=",
"values",
".",
"unset",
",",
"identity",
"=",
"values",
".",
"unset",
",",
"deployment_sid",
"=",
"values",
".",
"unset",
",",
"enabled",
"=",
"values",
".",
"unset",
")",
":",
"return",
"self",
... | Update the DeviceInstance
:param unicode friendly_name: A human readable description for this Device.
:param unicode identity: An identifier of the Device user.
:param unicode deployment_sid: The unique SID of the Deployment group.
:param bool enabled: The enabled
:returns: Upd... | [
"Update",
"the",
"DeviceInstance"
] | python | train |
python-useful-helpers/advanced-descriptors | advanced_descriptors/log_on_access.py | https://github.com/python-useful-helpers/advanced-descriptors/blob/17ee4a35b3bfcb4adf4ed2f41e75c4c6b71cb003/advanced_descriptors/log_on_access.py#L300-L305 | def logger(self, logger: typing.Union[logging.Logger, str, None]) -> None:
"""Logger instance to use as override."""
if logger is None or isinstance(logger, logging.Logger):
self.__logger = logger
else:
self.__logger = logging.getLogger(logger) | [
"def",
"logger",
"(",
"self",
",",
"logger",
":",
"typing",
".",
"Union",
"[",
"logging",
".",
"Logger",
",",
"str",
",",
"None",
"]",
")",
"->",
"None",
":",
"if",
"logger",
"is",
"None",
"or",
"isinstance",
"(",
"logger",
",",
"logging",
".",
"Lo... | Logger instance to use as override. | [
"Logger",
"instance",
"to",
"use",
"as",
"override",
"."
] | python | test |
saltstack/salt | salt/modules/boto_asg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_asg.py#L814-L858 | def get_instances(name, lifecycle_state="InService", health_status="Healthy",
attribute="private_ip_address", attributes=None, region=None,
key=None, keyid=None, profile=None):
'''
return attribute of all instances in the named autoscale group.
CLI example::
sal... | [
"def",
"get_instances",
"(",
"name",
",",
"lifecycle_state",
"=",
"\"InService\"",
",",
"health_status",
"=",
"\"Healthy\"",
",",
"attribute",
"=",
"\"private_ip_address\"",
",",
"attributes",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
"... | return attribute of all instances in the named autoscale group.
CLI example::
salt-call boto_asg.get_instances my_autoscale_group_name | [
"return",
"attribute",
"of",
"all",
"instances",
"in",
"the",
"named",
"autoscale",
"group",
"."
] | python | train |
pbrisk/timewave | timewave/consumers.py | https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/consumers.py#L182-L192 | def get(self, queue_get):
"""
get to given consumer states.
This function is used for merging of results of parallelized MC.
The first state is used for merging in place. The states must be disjoint.
:param object queue_get: second consumer state
"""
for (c, cs) ... | [
"def",
"get",
"(",
"self",
",",
"queue_get",
")",
":",
"for",
"(",
"c",
",",
"cs",
")",
"in",
"izip",
"(",
"self",
".",
"consumers",
",",
"queue_get",
")",
":",
"c",
".",
"get",
"(",
"cs",
")",
"self",
".",
"result",
"=",
"[",
"c",
".",
"resu... | get to given consumer states.
This function is used for merging of results of parallelized MC.
The first state is used for merging in place. The states must be disjoint.
:param object queue_get: second consumer state | [
"get",
"to",
"given",
"consumer",
"states",
".",
"This",
"function",
"is",
"used",
"for",
"merging",
"of",
"results",
"of",
"parallelized",
"MC",
".",
"The",
"first",
"state",
"is",
"used",
"for",
"merging",
"in",
"place",
".",
"The",
"states",
"must",
"... | python | train |
hardbyte/python-can | can/io/sqlite.py | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/io/sqlite.py#L79-L85 | def read_all(self):
"""Fetches all messages in the database.
:rtype: Generator[can.Message]
"""
result = self._cursor.execute("SELECT * FROM {}".format(self.table_name)).fetchall()
return (SqliteReader._assemble_message(frame) for frame in result) | [
"def",
"read_all",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"_cursor",
".",
"execute",
"(",
"\"SELECT * FROM {}\"",
".",
"format",
"(",
"self",
".",
"table_name",
")",
")",
".",
"fetchall",
"(",
")",
"return",
"(",
"SqliteReader",
".",
"_assemb... | Fetches all messages in the database.
:rtype: Generator[can.Message] | [
"Fetches",
"all",
"messages",
"in",
"the",
"database",
"."
] | python | train |
andymccurdy/redis-py | redis/client.py | https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L770-L786 | def execute_command(self, *args, **options):
"Execute a command and return a parsed response"
pool = self.connection_pool
command_name = args[0]
connection = pool.get_connection(command_name, **options)
try:
connection.send_command(*args)
return self.parse... | [
"def",
"execute_command",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"pool",
"=",
"self",
".",
"connection_pool",
"command_name",
"=",
"args",
"[",
"0",
"]",
"connection",
"=",
"pool",
".",
"get_connection",
"(",
"command_name",
"... | Execute a command and return a parsed response | [
"Execute",
"a",
"command",
"and",
"return",
"a",
"parsed",
"response"
] | python | train |
Jajcus/pyxmpp2 | pyxmpp2/ext/dataforms.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/dataforms.py#L98-L118 | def _new_from_xml(cls, xmlnode):
"""Create a new `Option` object from an XML element.
:Parameters:
- `xmlnode`: the XML element.
:Types:
- `xmlnode`: `libxml2.xmlNode`
:return: the object created.
:returntype: `Option`
"""
label = from_ut... | [
"def",
"_new_from_xml",
"(",
"cls",
",",
"xmlnode",
")",
":",
"label",
"=",
"from_utf8",
"(",
"xmlnode",
".",
"prop",
"(",
"\"label\"",
")",
")",
"child",
"=",
"xmlnode",
".",
"children",
"value",
"=",
"None",
"for",
"child",
"in",
"xml_element_ns_iter",
... | Create a new `Option` object from an XML element.
:Parameters:
- `xmlnode`: the XML element.
:Types:
- `xmlnode`: `libxml2.xmlNode`
:return: the object created.
:returntype: `Option` | [
"Create",
"a",
"new",
"Option",
"object",
"from",
"an",
"XML",
"element",
"."
] | python | valid |
ff0000/scarlet | scarlet/cms/base_views.py | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L319-L349 | def customize_form_widgets(self, form_class, fields=None):
"""
Hook for customizing widgets for a form_class. This is needed
for forms that specify their own fields causing the
default db_field callback to not be run for that field.
Default implementation checks for APIModelChoi... | [
"def",
"customize_form_widgets",
"(",
"self",
",",
"form_class",
",",
"fields",
"=",
"None",
")",
":",
"attrs",
"=",
"{",
"}",
"if",
"fields",
":",
"fields",
"=",
"set",
"(",
"fields",
")",
"for",
"k",
",",
"f",
"in",
"form_class",
".",
"base_fields",
... | Hook for customizing widgets for a form_class. This is needed
for forms that specify their own fields causing the
default db_field callback to not be run for that field.
Default implementation checks for APIModelChoiceWidgets
or APIManyChoiceWidgets and runs the update_links method
... | [
"Hook",
"for",
"customizing",
"widgets",
"for",
"a",
"form_class",
".",
"This",
"is",
"needed",
"for",
"forms",
"that",
"specify",
"their",
"own",
"fields",
"causing",
"the",
"default",
"db_field",
"callback",
"to",
"not",
"be",
"run",
"for",
"that",
"field"... | python | train |
rndmcnlly/ansunit | ansunit/__init__.py | https://github.com/rndmcnlly/ansunit/blob/3d45e22ab1ae131b6eda25d5ae2ead2c5cfee02a/ansunit/__init__.py#L97-L108 | def flatten_spec(spec, prefix,joiner=" :: "):
"""Flatten a canonical specification with nesting into one without nesting.
When building unique names, concatenate the given prefix to the local test
name without the "Test " tag."""
if any(filter(operator.methodcaller("startswith","Test"),spec.keys())):
flat_... | [
"def",
"flatten_spec",
"(",
"spec",
",",
"prefix",
",",
"joiner",
"=",
"\" :: \"",
")",
":",
"if",
"any",
"(",
"filter",
"(",
"operator",
".",
"methodcaller",
"(",
"\"startswith\"",
",",
"\"Test\"",
")",
",",
"spec",
".",
"keys",
"(",
")",
")",
")",
... | Flatten a canonical specification with nesting into one without nesting.
When building unique names, concatenate the given prefix to the local test
name without the "Test " tag. | [
"Flatten",
"a",
"canonical",
"specification",
"with",
"nesting",
"into",
"one",
"without",
"nesting",
".",
"When",
"building",
"unique",
"names",
"concatenate",
"the",
"given",
"prefix",
"to",
"the",
"local",
"test",
"name",
"without",
"the",
"Test",
"tag",
".... | python | train |
5j9/wikitextparser | wikitextparser/_wikitext.py | https://github.com/5j9/wikitextparser/blob/1347425814361d7955342c53212edbb27f0ff4b5/wikitextparser/_wikitext.py#L394-L403 | def _insert_update(self, index: int, length: int) -> None:
"""Update self._type_to_spans according to the added length."""
ss, se = self._span
for spans in self._type_to_spans.values():
for span in spans:
if index < span[1] or span[1] == index == se:
... | [
"def",
"_insert_update",
"(",
"self",
",",
"index",
":",
"int",
",",
"length",
":",
"int",
")",
"->",
"None",
":",
"ss",
",",
"se",
"=",
"self",
".",
"_span",
"for",
"spans",
"in",
"self",
".",
"_type_to_spans",
".",
"values",
"(",
")",
":",
"for",... | Update self._type_to_spans according to the added length. | [
"Update",
"self",
".",
"_type_to_spans",
"according",
"to",
"the",
"added",
"length",
"."
] | python | test |
ministryofjustice/money-to-prisoners-common | mtp_common/build_tasks/tasks.py | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/build_tasks/tasks.py#L220-L238 | def bundle_stylesheets(context: Context):
"""
Compiles stylesheets
"""
args = [
'--output', context.app.scss_build_path,
'--output-style', 'compressed',
]
if context.verbosity == 0:
args.append('--quiet')
if not context.use_colour:
args.append('--no-color')
... | [
"def",
"bundle_stylesheets",
"(",
"context",
":",
"Context",
")",
":",
"args",
"=",
"[",
"'--output'",
",",
"context",
".",
"app",
".",
"scss_build_path",
",",
"'--output-style'",
",",
"'compressed'",
",",
"]",
"if",
"context",
".",
"verbosity",
"==",
"0",
... | Compiles stylesheets | [
"Compiles",
"stylesheets"
] | python | train |
Hackerfleet/hfos | hfos/schemata/defaultform.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L117-L127 | def fieldset(title, items, options=None):
"""A field set with a title and sub items"""
result = {
'title': title,
'type': 'fieldset',
'items': items
}
if options is not None:
result.update(options)
return result | [
"def",
"fieldset",
"(",
"title",
",",
"items",
",",
"options",
"=",
"None",
")",
":",
"result",
"=",
"{",
"'title'",
":",
"title",
",",
"'type'",
":",
"'fieldset'",
",",
"'items'",
":",
"items",
"}",
"if",
"options",
"is",
"not",
"None",
":",
"result... | A field set with a title and sub items | [
"A",
"field",
"set",
"with",
"a",
"title",
"and",
"sub",
"items"
] | python | train |
roanuz/py-cricket | src/pycricket.py | https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L404-L416 | def get_fantasy_points(self, match_key):
"""
Calling Fantasy Points API
Arg:
match_key: key of the match
Return:
json data
"""
fantasy_points_url = self.api_path_v3 + "fantasy-match-points/" + match_key + "/"
response = self.get_response(... | [
"def",
"get_fantasy_points",
"(",
"self",
",",
"match_key",
")",
":",
"fantasy_points_url",
"=",
"self",
".",
"api_path_v3",
"+",
"\"fantasy-match-points/\"",
"+",
"match_key",
"+",
"\"/\"",
"response",
"=",
"self",
".",
"get_response",
"(",
"fantasy_points_url",
... | Calling Fantasy Points API
Arg:
match_key: key of the match
Return:
json data | [
"Calling",
"Fantasy",
"Points",
"API"
] | python | train |
gem/oq-engine | openquake/hazardlib/gsim/yu_2013.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/yu_2013.py#L296-L356 | def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values.
"""
# Check that the requested standard deviation type is available
... | [
"def",
"get_mean_and_stddevs",
"(",
"self",
",",
"sites",
",",
"rup",
",",
"dists",
",",
"imt",
",",
"stddev_types",
")",
":",
"# Check that the requested standard deviation type is available",
"assert",
"all",
"(",
"stddev_type",
"in",
"self",
".",
"DEFINED_FOR_STAND... | See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values. | [
"See",
":",
"meth",
":",
"superclass",
"method",
"<",
".",
"base",
".",
"GroundShakingIntensityModel",
".",
"get_mean_and_stddevs",
">",
"for",
"spec",
"of",
"input",
"and",
"result",
"values",
"."
] | python | train |
Gandi/gandi.cli | gandi/cli/commands/vm.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/vm.py#L32-L52 | def list(gandi, state, id, limit, datacenter):
"""List virtual machines."""
options = {
'items_per_page': limit,
}
if state:
options['state'] = state
if datacenter:
options['datacenter_id'] = gandi.datacenter.usable_id(datacenter)
output_keys = ['hostname', 'state']
... | [
"def",
"list",
"(",
"gandi",
",",
"state",
",",
"id",
",",
"limit",
",",
"datacenter",
")",
":",
"options",
"=",
"{",
"'items_per_page'",
":",
"limit",
",",
"}",
"if",
"state",
":",
"options",
"[",
"'state'",
"]",
"=",
"state",
"if",
"datacenter",
":... | List virtual machines. | [
"List",
"virtual",
"machines",
"."
] | python | train |
saltstack/salt | salt/modules/cron.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/cron.py#L248-L267 | def _write_cron_lines(user, lines):
'''
Takes a list of lines to be committed to a user's crontab and writes it
'''
lines = [salt.utils.stringutils.to_str(_l) for _l in lines]
path = salt.utils.files.mkstemp()
if _check_instance_uid_match(user) or __grains__.get('os_family') in ('Solaris', 'AIX'... | [
"def",
"_write_cron_lines",
"(",
"user",
",",
"lines",
")",
":",
"lines",
"=",
"[",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_str",
"(",
"_l",
")",
"for",
"_l",
"in",
"lines",
"]",
"path",
"=",
"salt",
".",
"utils",
".",
"files",
".",
"mks... | Takes a list of lines to be committed to a user's crontab and writes it | [
"Takes",
"a",
"list",
"of",
"lines",
"to",
"be",
"committed",
"to",
"a",
"user",
"s",
"crontab",
"and",
"writes",
"it"
] | python | train |
mcs07/ChemDataExtractor | chemdataextractor/nlp/tokenize.py | https://github.com/mcs07/ChemDataExtractor/blob/349a3bea965f2073141d62043b89319222e46af1/chemdataextractor/nlp/tokenize.py#L565-L571 | def _is_saccharide_arrow(self, before, after):
"""Return True if the arrow is in a chemical name."""
if (before and after and before[-1].isdigit() and after[0].isdigit() and
before.rstrip('0123456789').endswith('(') and after.lstrip('0123456789').startswith(')-')):
return True
... | [
"def",
"_is_saccharide_arrow",
"(",
"self",
",",
"before",
",",
"after",
")",
":",
"if",
"(",
"before",
"and",
"after",
"and",
"before",
"[",
"-",
"1",
"]",
".",
"isdigit",
"(",
")",
"and",
"after",
"[",
"0",
"]",
".",
"isdigit",
"(",
")",
"and",
... | Return True if the arrow is in a chemical name. | [
"Return",
"True",
"if",
"the",
"arrow",
"is",
"in",
"a",
"chemical",
"name",
"."
] | python | train |
smdabdoub/phylotoast | bin/diversity.py | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/diversity.py#L106-L119 | def write_diversity_metrics(data, sample_ids, fp=None):
"""
Given a dictionary of diversity calculations (keyed by method)
write out the data to a file.
"""
if fp is None:
fp = "./diversity_data.txt"
with open(fp, "w") as outf:
out = csv.writer(outf, delimiter="\t")
out.... | [
"def",
"write_diversity_metrics",
"(",
"data",
",",
"sample_ids",
",",
"fp",
"=",
"None",
")",
":",
"if",
"fp",
"is",
"None",
":",
"fp",
"=",
"\"./diversity_data.txt\"",
"with",
"open",
"(",
"fp",
",",
"\"w\"",
")",
"as",
"outf",
":",
"out",
"=",
"csv"... | Given a dictionary of diversity calculations (keyed by method)
write out the data to a file. | [
"Given",
"a",
"dictionary",
"of",
"diversity",
"calculations",
"(",
"keyed",
"by",
"method",
")",
"write",
"out",
"the",
"data",
"to",
"a",
"file",
"."
] | python | train |
Erotemic/ubelt | ubelt/util_memoize.py | https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/util_memoize.py#L58-L100 | def _make_signature_key(args, kwargs):
"""
Transforms function args into a key that can be used by the cache
CommandLine:
xdoctest -m ubelt.util_memoize _make_signature_key
Example:
>>> args = (4, [1, 2])
>>> kwargs = {'a': 'b'}
>>> key = _make_signature_key(args, kwarg... | [
"def",
"_make_signature_key",
"(",
"args",
",",
"kwargs",
")",
":",
"kwitems",
"=",
"kwargs",
".",
"items",
"(",
")",
"# TODO: we should check if Python is at least 3.7 and sort by kwargs",
"# keys otherwise. Should we use hash_data for key generation",
"if",
"(",
"sys",
".",... | Transforms function args into a key that can be used by the cache
CommandLine:
xdoctest -m ubelt.util_memoize _make_signature_key
Example:
>>> args = (4, [1, 2])
>>> kwargs = {'a': 'b'}
>>> key = _make_signature_key(args, kwargs)
>>> print('key = {!r}'.format(key))
... | [
"Transforms",
"function",
"args",
"into",
"a",
"key",
"that",
"can",
"be",
"used",
"by",
"the",
"cache"
] | python | valid |
political-memory/django-representatives | representatives/contrib/francedata/import_representatives.py | https://github.com/political-memory/django-representatives/blob/811c90d0250149e913e6196f0ab11c97d396be39/representatives/contrib/francedata/import_representatives.py#L218-L270 | def add_mandates(self, representative, rep_json):
'''
Create mandates from rep data based on variant configuration
'''
# Mandate in country group for party constituency
if rep_json.get('parti_ratt_financier'):
constituency, _ = Constituency.objects.get_or_create(
... | [
"def",
"add_mandates",
"(",
"self",
",",
"representative",
",",
"rep_json",
")",
":",
"# Mandate in country group for party constituency",
"if",
"rep_json",
".",
"get",
"(",
"'parti_ratt_financier'",
")",
":",
"constituency",
",",
"_",
"=",
"Constituency",
".",
"obj... | Create mandates from rep data based on variant configuration | [
"Create",
"mandates",
"from",
"rep",
"data",
"based",
"on",
"variant",
"configuration"
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/utils/traitlets.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/utils/traitlets.py#L245-L267 | def set_default_value(self, obj):
"""Set the default value on a per instance basis.
This method is called by :meth:`instance_init` to create and
validate the default value. The creation and validation of
default values must be delayed until the parent :class:`HasTraits`
class h... | [
"def",
"set_default_value",
"(",
"self",
",",
"obj",
")",
":",
"# Check for a deferred initializer defined in the same class as the",
"# trait declaration or above.",
"mro",
"=",
"type",
"(",
"obj",
")",
".",
"mro",
"(",
")",
"meth_name",
"=",
"'_%s_default'",
"%",
"s... | Set the default value on a per instance basis.
This method is called by :meth:`instance_init` to create and
validate the default value. The creation and validation of
default values must be delayed until the parent :class:`HasTraits`
class has been instantiated. | [
"Set",
"the",
"default",
"value",
"on",
"a",
"per",
"instance",
"basis",
"."
] | python | test |
lago-project/lago | lago/plugins/cli.py | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/plugins/cli.py#L243-L282 | def cli_plugin_add_help(help):
"""
Decorator generator that adds the cli help to the cli plugin based on the
decorated function
Args:
help (str): help string for the cli plugin
Returns:
function: Decorator that builds or extends the cliplugin for the
decorated function,... | [
"def",
"cli_plugin_add_help",
"(",
"help",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"if",
"not",
"isinstance",
"(",
"func",
",",
"CLIPluginFuncWrapper",
")",
":",
"func",
"=",
"CLIPluginFuncWrapper",
"(",
"do_run",
"=",
"func",
")",
"func",
"."... | Decorator generator that adds the cli help to the cli plugin based on the
decorated function
Args:
help (str): help string for the cli plugin
Returns:
function: Decorator that builds or extends the cliplugin for the
decorated function, setting the given help
Examples:
... | [
"Decorator",
"generator",
"that",
"adds",
"the",
"cli",
"help",
"to",
"the",
"cli",
"plugin",
"based",
"on",
"the",
"decorated",
"function"
] | python | train |
NASA-AMMOS/AIT-Core | ait/core/geom.py | https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/geom.py#L671-L697 | def contains (self, p):
"""Returns True if point is contained inside this Polygon, False
otherwise.
This method uses the Ray Casting algorithm.
Examples:
>>> p = Polygon()
>>> p.vertices = [Point(1, 1), Point(1, -1), Point(-1, -1), Point(-1, 1)]
>>> p.contains( Point(0, 0) )
True... | [
"def",
"contains",
"(",
"self",
",",
"p",
")",
":",
"inside",
"=",
"False",
"if",
"p",
"in",
"self",
".",
"bounds",
"(",
")",
":",
"for",
"s",
"in",
"self",
".",
"segments",
"(",
")",
":",
"if",
"(",
"(",
"s",
".",
"p",
".",
"y",
">",
"p",
... | Returns True if point is contained inside this Polygon, False
otherwise.
This method uses the Ray Casting algorithm.
Examples:
>>> p = Polygon()
>>> p.vertices = [Point(1, 1), Point(1, -1), Point(-1, -1), Point(-1, 1)]
>>> p.contains( Point(0, 0) )
True
>>> p.contains( Point(2, ... | [
"Returns",
"True",
"if",
"point",
"is",
"contained",
"inside",
"this",
"Polygon",
"False",
"otherwise",
"."
] | python | train |
hynek/environ_config | src/environ/_environ_config.py | https://github.com/hynek/environ_config/blob/d61c0822bf0b6516932534e0496bd3f360a3e5e2/src/environ/_environ_config.py#L156-L198 | def _generate_help_dicts(config_cls, _prefix=None):
"""
Generate dictionaries for use in building help strings.
Every dictionary includes the keys...
var_name: The env var that should be set to populate the value.
required: A bool, True if the var is required, False if it's optional.
Conditio... | [
"def",
"_generate_help_dicts",
"(",
"config_cls",
",",
"_prefix",
"=",
"None",
")",
":",
"help_dicts",
"=",
"[",
"]",
"if",
"_prefix",
"is",
"None",
":",
"_prefix",
"=",
"config_cls",
".",
"_prefix",
"for",
"a",
"in",
"attr",
".",
"fields",
"(",
"config_... | Generate dictionaries for use in building help strings.
Every dictionary includes the keys...
var_name: The env var that should be set to populate the value.
required: A bool, True if the var is required, False if it's optional.
Conditionally, the following are included...
default: Included if a... | [
"Generate",
"dictionaries",
"for",
"use",
"in",
"building",
"help",
"strings",
"."
] | python | train |
jupyter-widgets/ipywidgets | ipywidgets/widgets/widget_float.py | https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/ipywidgets/widgets/widget_float.py#L68-L73 | def _validate_value(self, proposal):
"""Cap and floor value"""
value = proposal['value']
if self.base ** self.min > value or self.base ** self.max < value:
value = min(max(value, self.base ** self.min), self.base ** self.max)
return value | [
"def",
"_validate_value",
"(",
"self",
",",
"proposal",
")",
":",
"value",
"=",
"proposal",
"[",
"'value'",
"]",
"if",
"self",
".",
"base",
"**",
"self",
".",
"min",
">",
"value",
"or",
"self",
".",
"base",
"**",
"self",
".",
"max",
"<",
"value",
"... | Cap and floor value | [
"Cap",
"and",
"floor",
"value"
] | python | train |
bitesofcode/projexui | projexui/widgets/xtreewidget/xtreewidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidget.py#L149-L183 | def __collectFilterTerms( self,
mapping,
item = None,
level = 0 ):
"""
Generates a list of filter terms based on the column data for the \
items in the tree. If no parent is supplied, then the top level... | [
"def",
"__collectFilterTerms",
"(",
"self",
",",
"mapping",
",",
"item",
"=",
"None",
",",
"level",
"=",
"0",
")",
":",
"if",
"not",
"mapping",
":",
"return",
"max_level",
"=",
"self",
".",
"maximumFilterLevel",
"(",
")",
"if",
"max_level",
"!=",
"None",... | Generates a list of filter terms based on the column data for the \
items in the tree. If no parent is supplied, then the top level items \
will be used, otherwise the children will be searched through. The \
level value will drive how far down the tree we will look for the terms.
... | [
"Generates",
"a",
"list",
"of",
"filter",
"terms",
"based",
"on",
"the",
"column",
"data",
"for",
"the",
"\\",
"items",
"in",
"the",
"tree",
".",
"If",
"no",
"parent",
"is",
"supplied",
"then",
"the",
"top",
"level",
"items",
"\\",
"will",
"be",
"used"... | python | train |
ray-project/ray | python/ray/autoscaler/aws/node_provider.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/aws/node_provider.py#L18-L24 | def to_aws_format(tags):
"""Convert the Ray node name tag to the AWS-specific 'Name' tag."""
if TAG_RAY_NODE_NAME in tags:
tags["Name"] = tags[TAG_RAY_NODE_NAME]
del tags[TAG_RAY_NODE_NAME]
return tags | [
"def",
"to_aws_format",
"(",
"tags",
")",
":",
"if",
"TAG_RAY_NODE_NAME",
"in",
"tags",
":",
"tags",
"[",
"\"Name\"",
"]",
"=",
"tags",
"[",
"TAG_RAY_NODE_NAME",
"]",
"del",
"tags",
"[",
"TAG_RAY_NODE_NAME",
"]",
"return",
"tags"
] | Convert the Ray node name tag to the AWS-specific 'Name' tag. | [
"Convert",
"the",
"Ray",
"node",
"name",
"tag",
"to",
"the",
"AWS",
"-",
"specific",
"Name",
"tag",
"."
] | python | train |
sirfoga/pyhal | hal/strings/utils.py | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/strings/utils.py#L33-L42 | def get_average_length_of_string(strings):
"""Computes average length of words
:param strings: list of words
:return: Average length of word on list
"""
if not strings:
return 0
return sum(len(word) for word in strings) / len(strings) | [
"def",
"get_average_length_of_string",
"(",
"strings",
")",
":",
"if",
"not",
"strings",
":",
"return",
"0",
"return",
"sum",
"(",
"len",
"(",
"word",
")",
"for",
"word",
"in",
"strings",
")",
"/",
"len",
"(",
"strings",
")"
] | Computes average length of words
:param strings: list of words
:return: Average length of word on list | [
"Computes",
"average",
"length",
"of",
"words"
] | python | train |
Robpol86/libnl | libnl/cache_mngt.py | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/cache_mngt.py#L97-L123 | def nl_cache_mngt_register(ops):
"""Register a set of cache operations.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/cache_mngt.c#L252
Called by users of caches to announce the availability of a certain cache type.
Positional arguments:
ops -- cache operations (nl_cache_ops class instanc... | [
"def",
"nl_cache_mngt_register",
"(",
"ops",
")",
":",
"global",
"cache_ops",
"if",
"not",
"ops",
".",
"co_name",
"or",
"not",
"ops",
".",
"co_obj_ops",
":",
"return",
"-",
"NLE_INVAL",
"with",
"cache_ops_lock",
":",
"if",
"_nl_cache_ops_lookup",
"(",
"ops",
... | Register a set of cache operations.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/cache_mngt.c#L252
Called by users of caches to announce the availability of a certain cache type.
Positional arguments:
ops -- cache operations (nl_cache_ops class instance).
Returns:
0 on success or a ... | [
"Register",
"a",
"set",
"of",
"cache",
"operations",
"."
] | python | train |
RRZE-HPC/kerncraft | kerncraft/kernel.py | https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/kernel.py#L1172-L1197 | def _build_dummy_calls(self):
"""
Generate false if branch with dummy calls
Requires kerncraft.h to be included, which defines dummy(...) and var_false.
:return: dummy statement
"""
# Make sure nothing gets removed by inserting dummy calls
dummy_calls = []
... | [
"def",
"_build_dummy_calls",
"(",
"self",
")",
":",
"# Make sure nothing gets removed by inserting dummy calls",
"dummy_calls",
"=",
"[",
"]",
"for",
"d",
"in",
"self",
".",
"kernel_ast",
".",
"block_items",
":",
"# Only consider toplevel declarations from kernel ast",
"if"... | Generate false if branch with dummy calls
Requires kerncraft.h to be included, which defines dummy(...) and var_false.
:return: dummy statement | [
"Generate",
"false",
"if",
"branch",
"with",
"dummy",
"calls"
] | python | test |
aliyun/aliyun-odps-python-sdk | odps/console.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/console.py#L498-L539 | def _write_with_fallback(s, write, fileobj):
"""Write the supplied string with the given write function like
``write(s)``, but use a writer for the locale's preferred encoding in case
of a UnicodeEncodeError. Failing that attempt to write with 'utf-8' or
'latin-1'.
"""
if IPythonIOStream is no... | [
"def",
"_write_with_fallback",
"(",
"s",
",",
"write",
",",
"fileobj",
")",
":",
"if",
"IPythonIOStream",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"fileobj",
",",
"IPythonIOStream",
")",
":",
"# If the output stream is an IPython.utils.io.IOStream object that's",
... | Write the supplied string with the given write function like
``write(s)``, but use a writer for the locale's preferred encoding in case
of a UnicodeEncodeError. Failing that attempt to write with 'utf-8' or
'latin-1'. | [
"Write",
"the",
"supplied",
"string",
"with",
"the",
"given",
"write",
"function",
"like",
"write",
"(",
"s",
")",
"but",
"use",
"a",
"writer",
"for",
"the",
"locale",
"s",
"preferred",
"encoding",
"in",
"case",
"of",
"a",
"UnicodeEncodeError",
".",
"Faili... | python | train |
sergiocorreia/panflute | examples/panflute/gabc.py | https://github.com/sergiocorreia/panflute/blob/65c2d570c26a190deb600cab5e2ad8a828a3302e/examples/panflute/gabc.py#L120-L157 | def gabc(elem, doc):
"""Handle gabc file inclusion and gabc code block."""
if type(elem) == Code and "gabc" in elem.classes:
if doc.format == "latex":
if elem.identifier == "":
label = ""
else:
label = '\\label{' + elem.identifier + '}'
... | [
"def",
"gabc",
"(",
"elem",
",",
"doc",
")",
":",
"if",
"type",
"(",
"elem",
")",
"==",
"Code",
"and",
"\"gabc\"",
"in",
"elem",
".",
"classes",
":",
"if",
"doc",
".",
"format",
"==",
"\"latex\"",
":",
"if",
"elem",
".",
"identifier",
"==",
"\"\"",... | Handle gabc file inclusion and gabc code block. | [
"Handle",
"gabc",
"file",
"inclusion",
"and",
"gabc",
"code",
"block",
"."
] | python | train |
hydpy-dev/hydpy | hydpy/auxs/armatools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/armatools.py#L586-L591 | def norm_coefs(self):
"""Multiply all coefficients by the same factor, so that their sum
becomes one."""
sum_coefs = self.sum_coefs
self.ar_coefs /= sum_coefs
self.ma_coefs /= sum_coefs | [
"def",
"norm_coefs",
"(",
"self",
")",
":",
"sum_coefs",
"=",
"self",
".",
"sum_coefs",
"self",
".",
"ar_coefs",
"/=",
"sum_coefs",
"self",
".",
"ma_coefs",
"/=",
"sum_coefs"
] | Multiply all coefficients by the same factor, so that their sum
becomes one. | [
"Multiply",
"all",
"coefficients",
"by",
"the",
"same",
"factor",
"so",
"that",
"their",
"sum",
"becomes",
"one",
"."
] | python | train |
google/brotli | research/brotlidump.py | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1190-L1200 | def explanation(self, index, extra):
"""
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> d[55].explanation(13)
'11[1101]01-5: [0]+240'
"""
extraBits = self.extraBits(index)
extraString = '[{:0{}b}]'.format(extra, extraBits)
return '{0}: [{1[0]}]{... | [
"def",
"explanation",
"(",
"self",
",",
"index",
",",
"extra",
")",
":",
"extraBits",
"=",
"self",
".",
"extraBits",
"(",
"index",
")",
"extraString",
"=",
"'[{:0{}b}]'",
".",
"format",
"(",
"extra",
",",
"extraBits",
")",
"return",
"'{0}: [{1[0]}]{1[1]:+d}'... | >>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> d[55].explanation(13)
'11[1101]01-5: [0]+240' | [
">>>",
"d",
"=",
"DistanceAlphabet",
"(",
"D",
"NPOSTFIX",
"=",
"2",
"NDIRECT",
"=",
"10",
")",
">>>",
"d",
"[",
"55",
"]",
".",
"explanation",
"(",
"13",
")",
"11",
"[",
"1101",
"]",
"01",
"-",
"5",
":",
"[",
"0",
"]",
"+",
"240"
] | python | test |
danielhrisca/asammdf | asammdf/blocks/utils.py | https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L1178-L1237 | def master_using_raster(mdf, raster, endpoint=False):
""" get single master based on the raster
Parameters
----------
mdf : asammdf.MDF
measurement object
raster : float
new raster
endpoint=False : bool
include maximum time stamp in the new master
Returns
------... | [
"def",
"master_using_raster",
"(",
"mdf",
",",
"raster",
",",
"endpoint",
"=",
"False",
")",
":",
"if",
"not",
"raster",
":",
"master",
"=",
"np",
".",
"array",
"(",
"[",
"]",
",",
"dtype",
"=",
"'<f8'",
")",
"else",
":",
"t_min",
"=",
"[",
"]",
... | get single master based on the raster
Parameters
----------
mdf : asammdf.MDF
measurement object
raster : float
new raster
endpoint=False : bool
include maximum time stamp in the new master
Returns
-------
master : np.array
new master | [
"get",
"single",
"master",
"based",
"on",
"the",
"raster"
] | python | train |
dnanexus/dx-toolkit | src/python/dxpy/api.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L403-L409 | def database_add_tags(object_id, input_params={}, always_retry=True, **kwargs):
"""
Invokes the /database-xxxx/addTags API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Tags#API-method%3A-%2Fclass-xxxx%2FaddTags
"""
return DXHTTPRequest('/%s/addTags' % object_id, in... | [
"def",
"database_add_tags",
"(",
"object_id",
",",
"input_params",
"=",
"{",
"}",
",",
"always_retry",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DXHTTPRequest",
"(",
"'/%s/addTags'",
"%",
"object_id",
",",
"input_params",
",",
"always_retry",
... | Invokes the /database-xxxx/addTags API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Tags#API-method%3A-%2Fclass-xxxx%2FaddTags | [
"Invokes",
"the",
"/",
"database",
"-",
"xxxx",
"/",
"addTags",
"API",
"method",
"."
] | python | train |
boriel/zxbasic | arch/zx48k/optimizer.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L286-L307 | def single_registers(op):
""" Given a list of registers like ['a', 'bc', 'h', 'hl'] returns
a set of single registers: ['a', 'b', 'c', 'h', 'l'].
Non register parameters, like numbers will be ignored.
"""
result = set()
if isinstance(op, str):
op = [op]
for x in op:
if is_8b... | [
"def",
"single_registers",
"(",
"op",
")",
":",
"result",
"=",
"set",
"(",
")",
"if",
"isinstance",
"(",
"op",
",",
"str",
")",
":",
"op",
"=",
"[",
"op",
"]",
"for",
"x",
"in",
"op",
":",
"if",
"is_8bit_register",
"(",
"x",
")",
":",
"result",
... | Given a list of registers like ['a', 'bc', 'h', 'hl'] returns
a set of single registers: ['a', 'b', 'c', 'h', 'l'].
Non register parameters, like numbers will be ignored. | [
"Given",
"a",
"list",
"of",
"registers",
"like",
"[",
"a",
"bc",
"h",
"hl",
"]",
"returns",
"a",
"set",
"of",
"single",
"registers",
":",
"[",
"a",
"b",
"c",
"h",
"l",
"]",
".",
"Non",
"register",
"parameters",
"like",
"numbers",
"will",
"be",
"ign... | python | train |
apple/turicreate | src/unity/python/turicreate/toolkits/evaluation.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/evaluation.py#L87-L245 | def log_loss(targets, predictions, index_map=None):
r"""
Compute the logloss for the given targets and the given predicted
probabilities. This quantity is defined to be the negative of the sum
of the log probability of each observation, normalized by the number of
observations:
.. math::
... | [
"def",
"log_loss",
"(",
"targets",
",",
"predictions",
",",
"index_map",
"=",
"None",
")",
":",
"_supervised_evaluation_error_checking",
"(",
"targets",
",",
"predictions",
")",
"_check_prob_and_prob_vector",
"(",
"predictions",
")",
"_check_target_not_float",
"(",
"t... | r"""
Compute the logloss for the given targets and the given predicted
probabilities. This quantity is defined to be the negative of the sum
of the log probability of each observation, normalized by the number of
observations:
.. math::
\textrm{logloss} = - \frac{1}{N} \sum_{i \in 1,\ldots... | [
"r",
"Compute",
"the",
"logloss",
"for",
"the",
"given",
"targets",
"and",
"the",
"given",
"predicted",
"probabilities",
".",
"This",
"quantity",
"is",
"defined",
"to",
"be",
"the",
"negative",
"of",
"the",
"sum",
"of",
"the",
"log",
"probability",
"of",
"... | python | train |
fishtown-analytics/dbt | core/dbt/task/deps.py | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/task/deps.py#L259-L279 | def _checkout(self, project):
"""Performs a shallow clone of the repository into the downloads
directory. This function can be called repeatedly. If the project has
already been checked out at this version, it will be a no-op. Returns
the path to the checked out directory."""
if ... | [
"def",
"_checkout",
"(",
"self",
",",
"project",
")",
":",
"if",
"len",
"(",
"self",
".",
"version",
")",
"!=",
"1",
":",
"dbt",
".",
"exceptions",
".",
"raise_dependency_error",
"(",
"'Cannot checkout repository until the version is pinned.'",
")",
"try",
":",
... | Performs a shallow clone of the repository into the downloads
directory. This function can be called repeatedly. If the project has
already been checked out at this version, it will be a no-op. Returns
the path to the checked out directory. | [
"Performs",
"a",
"shallow",
"clone",
"of",
"the",
"repository",
"into",
"the",
"downloads",
"directory",
".",
"This",
"function",
"can",
"be",
"called",
"repeatedly",
".",
"If",
"the",
"project",
"has",
"already",
"been",
"checked",
"out",
"at",
"this",
"ver... | python | train |
matrix-org/matrix-python-sdk | matrix_client/room.py | https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/room.py#L405-L412 | def set_room_name(self, name):
"""Return True if room name successfully changed."""
try:
self.client.api.set_room_name(self.room_id, name)
self.name = name
return True
except MatrixRequestError:
return False | [
"def",
"set_room_name",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"self",
".",
"client",
".",
"api",
".",
"set_room_name",
"(",
"self",
".",
"room_id",
",",
"name",
")",
"self",
".",
"name",
"=",
"name",
"return",
"True",
"except",
"MatrixRequest... | Return True if room name successfully changed. | [
"Return",
"True",
"if",
"room",
"name",
"successfully",
"changed",
"."
] | python | train |
inveniosoftware/invenio-files-rest | invenio_files_rest/views.py | https://github.com/inveniosoftware/invenio-files-rest/blob/59a950da61cc8d5882a03c6fde6db2e2ed10befd/invenio_files_rest/views.py#L413-L422 | def get(self, bucket=None, versions=missing, uploads=missing):
"""Get list of objects in the bucket.
:param bucket: A :class:`invenio_files_rest.models.Bucket` instance.
:returns: The Flask response.
"""
if uploads is not missing:
return self.multipart_listuploads(bu... | [
"def",
"get",
"(",
"self",
",",
"bucket",
"=",
"None",
",",
"versions",
"=",
"missing",
",",
"uploads",
"=",
"missing",
")",
":",
"if",
"uploads",
"is",
"not",
"missing",
":",
"return",
"self",
".",
"multipart_listuploads",
"(",
"bucket",
")",
"else",
... | Get list of objects in the bucket.
:param bucket: A :class:`invenio_files_rest.models.Bucket` instance.
:returns: The Flask response. | [
"Get",
"list",
"of",
"objects",
"in",
"the",
"bucket",
"."
] | python | train |
usc-isi-i2/etk | etk/extractors/table_extractor.py | https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/extractors/table_extractor.py#L463-L474 | def gen_html(row_list):
""" Return html table string from a list of data rows """
table = "<table>"
for row in row_list:
table += "<tr>"
cells = row["cells"]
for c in cells:
t = c['cell'] if c else ''
table += t
tabl... | [
"def",
"gen_html",
"(",
"row_list",
")",
":",
"table",
"=",
"\"<table>\"",
"for",
"row",
"in",
"row_list",
":",
"table",
"+=",
"\"<tr>\"",
"cells",
"=",
"row",
"[",
"\"cells\"",
"]",
"for",
"c",
"in",
"cells",
":",
"t",
"=",
"c",
"[",
"'cell'",
"]",
... | Return html table string from a list of data rows | [
"Return",
"html",
"table",
"string",
"from",
"a",
"list",
"of",
"data",
"rows"
] | python | train |
sods/paramz | paramz/model.py | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/model.py#L284-L408 | def _checkgrad(self, target_param=None, verbose=False, step=1e-6, tolerance=1e-3, df_tolerance=1e-12):
"""
Check the gradient of the ,odel by comparing to a numerical
estimate. If the verbose flag is passed, individual
components are tested (and printed)
:param verbose: If True... | [
"def",
"_checkgrad",
"(",
"self",
",",
"target_param",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"step",
"=",
"1e-6",
",",
"tolerance",
"=",
"1e-3",
",",
"df_tolerance",
"=",
"1e-12",
")",
":",
"if",
"not",
"self",
".",
"_model_initialized_",
":",
... | Check the gradient of the ,odel by comparing to a numerical
estimate. If the verbose flag is passed, individual
components are tested (and printed)
:param verbose: If True, print a "full" checking of each parameter
:type verbose: bool
:param step: The size of the step around wh... | [
"Check",
"the",
"gradient",
"of",
"the",
"odel",
"by",
"comparing",
"to",
"a",
"numerical",
"estimate",
".",
"If",
"the",
"verbose",
"flag",
"is",
"passed",
"individual",
"components",
"are",
"tested",
"(",
"and",
"printed",
")"
] | python | train |
cltk/cltk | cltk/text_reuse/levenshtein.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/text_reuse/levenshtein.py#L124-L141 | def ratio(string_a, string_b):
"""At the most basic level, return a Levenshtein distance ratio via
fuzzywuzzy.
:param string_a: str
:param string_b: str
:return: float
"""
from cltk.utils.cltk_logger import logger
try:
from fuzzywuzzy import fu... | [
"def",
"ratio",
"(",
"string_a",
",",
"string_b",
")",
":",
"from",
"cltk",
".",
"utils",
".",
"cltk_logger",
"import",
"logger",
"try",
":",
"from",
"fuzzywuzzy",
"import",
"fuzz",
"except",
"ImportError",
"as",
"imp_err",
":",
"# pragma: no cover",
"message"... | At the most basic level, return a Levenshtein distance ratio via
fuzzywuzzy.
:param string_a: str
:param string_b: str
:return: float | [
"At",
"the",
"most",
"basic",
"level",
"return",
"a",
"Levenshtein",
"distance",
"ratio",
"via",
"fuzzywuzzy",
".",
":",
"param",
"string_a",
":",
"str",
":",
"param",
"string_b",
":",
"str",
":",
"return",
":",
"float"
] | python | train |
WebarchivCZ/WA-KAT | src/wa_kat/templates/static/js/Lib/site-packages/components/author_picker.py | https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/templates/static/js/Lib/site-packages/components/author_picker.py#L246-L253 | def bind(cls):
"""
Bind the buttons to adapter's event handler.
"""
super(cls, cls).bind()
cls.search_btn_el.bind("click", cls.start)
cls.input_el.bind("keypress", func_on_enter(cls.start)) | [
"def",
"bind",
"(",
"cls",
")",
":",
"super",
"(",
"cls",
",",
"cls",
")",
".",
"bind",
"(",
")",
"cls",
".",
"search_btn_el",
".",
"bind",
"(",
"\"click\"",
",",
"cls",
".",
"start",
")",
"cls",
".",
"input_el",
".",
"bind",
"(",
"\"keypress\"",
... | Bind the buttons to adapter's event handler. | [
"Bind",
"the",
"buttons",
"to",
"adapter",
"s",
"event",
"handler",
"."
] | python | train |
NoneGG/aredis | aredis/commands/sets.py | https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/commands/sets.py#L110-L116 | async def sunionstore(self, dest, keys, *args):
"""
Store the union of sets specified by ``keys`` into a new
set named ``dest``. Returns the number of keys in the new set.
"""
args = list_or_args(keys, args)
return await self.execute_command('SUNIONSTORE', dest, *args) | [
"async",
"def",
"sunionstore",
"(",
"self",
",",
"dest",
",",
"keys",
",",
"*",
"args",
")",
":",
"args",
"=",
"list_or_args",
"(",
"keys",
",",
"args",
")",
"return",
"await",
"self",
".",
"execute_command",
"(",
"'SUNIONSTORE'",
",",
"dest",
",",
"*"... | Store the union of sets specified by ``keys`` into a new
set named ``dest``. Returns the number of keys in the new set. | [
"Store",
"the",
"union",
"of",
"sets",
"specified",
"by",
"keys",
"into",
"a",
"new",
"set",
"named",
"dest",
".",
"Returns",
"the",
"number",
"of",
"keys",
"in",
"the",
"new",
"set",
"."
] | python | train |
amzn/ion-python | amazon/ion/reader_binary.py | https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/reader_binary.py#L838-L870 | def raw_reader(queue=None):
"""Returns a raw binary reader co-routine.
Args:
queue (Optional[BufferQueue]): The buffer read data for parsing, if ``None`` a
new one will be created.
Yields:
IonEvent: parse events, will have an event type of ``INCOMPLETE`` if data is needed
... | [
"def",
"raw_reader",
"(",
"queue",
"=",
"None",
")",
":",
"if",
"queue",
"is",
"None",
":",
"queue",
"=",
"BufferQueue",
"(",
")",
"ctx",
"=",
"_HandlerContext",
"(",
"position",
"=",
"0",
",",
"limit",
"=",
"None",
",",
"queue",
"=",
"queue",
",",
... | Returns a raw binary reader co-routine.
Args:
queue (Optional[BufferQueue]): The buffer read data for parsing, if ``None`` a
new one will be created.
Yields:
IonEvent: parse events, will have an event type of ``INCOMPLETE`` if data is needed
in the middle of a value or ... | [
"Returns",
"a",
"raw",
"binary",
"reader",
"co",
"-",
"routine",
"."
] | python | train |
pycontribs/pyrax | pyrax/autoscale.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/autoscale.py#L485-L495 | def update_launch_metadata(self, scaling_group, metadata):
"""
Adds the given metadata dict to the existing metadata for the scaling
group's launch configuration.
"""
if not isinstance(scaling_group, ScalingGroup):
scaling_group = self.get(scaling_group)
curr_... | [
"def",
"update_launch_metadata",
"(",
"self",
",",
"scaling_group",
",",
"metadata",
")",
":",
"if",
"not",
"isinstance",
"(",
"scaling_group",
",",
"ScalingGroup",
")",
":",
"scaling_group",
"=",
"self",
".",
"get",
"(",
"scaling_group",
")",
"curr_meta",
"="... | Adds the given metadata dict to the existing metadata for the scaling
group's launch configuration. | [
"Adds",
"the",
"given",
"metadata",
"dict",
"to",
"the",
"existing",
"metadata",
"for",
"the",
"scaling",
"group",
"s",
"launch",
"configuration",
"."
] | python | train |
quantmind/dynts | dynts/api/timeseries.py | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L119-L128 | def getalgo(self, operation, name):
'''Return the algorithm for *operation* named *name*'''
if operation not in self._algorithms:
raise NotAvailable('{0} not registered.'.format(operation))
oper = self._algorithms[operation]
try:
return oper[name]
e... | [
"def",
"getalgo",
"(",
"self",
",",
"operation",
",",
"name",
")",
":",
"if",
"operation",
"not",
"in",
"self",
".",
"_algorithms",
":",
"raise",
"NotAvailable",
"(",
"'{0} not registered.'",
".",
"format",
"(",
"operation",
")",
")",
"oper",
"=",
"self",
... | Return the algorithm for *operation* named *name* | [
"Return",
"the",
"algorithm",
"for",
"*",
"operation",
"*",
"named",
"*",
"name",
"*"
] | python | train |
saltstack/salt | salt/cloud/clouds/gogrid.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gogrid.py#L367-L382 | def list_common_lookups(kwargs=None, call=None):
'''
List common lookups for a particular type of item
.. versionadded:: 2015.8.0
'''
if kwargs is None:
kwargs = {}
args = {}
if 'lookup' in kwargs:
args['lookup'] = kwargs['lookup']
response = _query('common', 'lookup/l... | [
"def",
"list_common_lookups",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"args",
"=",
"{",
"}",
"if",
"'lookup'",
"in",
"kwargs",
":",
"args",
"[",
"'lookup'",
"]",
"=... | List common lookups for a particular type of item
.. versionadded:: 2015.8.0 | [
"List",
"common",
"lookups",
"for",
"a",
"particular",
"type",
"of",
"item"
] | python | train |
sony/nnabla | python/src/nnabla/models/utils.py | https://github.com/sony/nnabla/blob/aaf3d33b7cbb38f2a03aa754178ba8f7c8481320/python/src/nnabla/models/utils.py#L41-L50 | def get_model_url_base():
'''
Returns a root folder for models.
'''
url_base = get_model_url_base_from_env()
if url_base is not None:
logger.info('NNBLA_MODELS_URL_BASE is set as {}.'.format(url_base))
else:
url_base = 'https://nnabla.org/pretrained-models/nnp_models/'
return... | [
"def",
"get_model_url_base",
"(",
")",
":",
"url_base",
"=",
"get_model_url_base_from_env",
"(",
")",
"if",
"url_base",
"is",
"not",
"None",
":",
"logger",
".",
"info",
"(",
"'NNBLA_MODELS_URL_BASE is set as {}.'",
".",
"format",
"(",
"url_base",
")",
")",
"else... | Returns a root folder for models. | [
"Returns",
"a",
"root",
"folder",
"for",
"models",
"."
] | python | train |
fananimi/pyzk | zk/base.py | https://github.com/fananimi/pyzk/blob/1a765d616526efdcb4c9adfcc9b1d10f6ed8b938/zk/base.py#L739-L751 | def set_time(self, timestamp):
"""
set Device time (pass datetime object)
:param timestamp: python datetime object
"""
command = const.CMD_SET_TIME
command_string = pack(b'I', self.__encode_time(timestamp))
cmd_response = self.__send_command(command, command_stri... | [
"def",
"set_time",
"(",
"self",
",",
"timestamp",
")",
":",
"command",
"=",
"const",
".",
"CMD_SET_TIME",
"command_string",
"=",
"pack",
"(",
"b'I'",
",",
"self",
".",
"__encode_time",
"(",
"timestamp",
")",
")",
"cmd_response",
"=",
"self",
".",
"__send_c... | set Device time (pass datetime object)
:param timestamp: python datetime object | [
"set",
"Device",
"time",
"(",
"pass",
"datetime",
"object",
")"
] | python | train |
mongodb/mongo-python-driver | pymongo/client_session.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/client_session.py#L504-L527 | def start_transaction(self, read_concern=None, write_concern=None,
read_preference=None):
"""Start a multi-statement transaction.
Takes the same arguments as :class:`TransactionOptions`.
.. versionadded:: 3.7
"""
self._check_ended()
if self._i... | [
"def",
"start_transaction",
"(",
"self",
",",
"read_concern",
"=",
"None",
",",
"write_concern",
"=",
"None",
",",
"read_preference",
"=",
"None",
")",
":",
"self",
".",
"_check_ended",
"(",
")",
"if",
"self",
".",
"_in_transaction",
":",
"raise",
"InvalidOp... | Start a multi-statement transaction.
Takes the same arguments as :class:`TransactionOptions`.
.. versionadded:: 3.7 | [
"Start",
"a",
"multi",
"-",
"statement",
"transaction",
"."
] | python | train |
Qiskit/qiskit-terra | qiskit/qasm/node/gate.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/gate.py#L53-L60 | def qasm(self, prec=15):
"""Return the corresponding OPENQASM string."""
string = "gate " + self.name
if self.arguments is not None:
string += "(" + self.arguments.qasm(prec) + ")"
string += " " + self.bitlist.qasm(prec) + "\n"
string += "{\n" + self.body.qasm(prec) +... | [
"def",
"qasm",
"(",
"self",
",",
"prec",
"=",
"15",
")",
":",
"string",
"=",
"\"gate \"",
"+",
"self",
".",
"name",
"if",
"self",
".",
"arguments",
"is",
"not",
"None",
":",
"string",
"+=",
"\"(\"",
"+",
"self",
".",
"arguments",
".",
"qasm",
"(",
... | Return the corresponding OPENQASM string. | [
"Return",
"the",
"corresponding",
"OPENQASM",
"string",
"."
] | python | test |
romanz/trezor-agent | libagent/ssh/protocol.py | https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/ssh/protocol.py#L108-L118 | def list_pubs(self, buf):
"""SSH v2 public keys are serialized and returned."""
assert not buf.read()
keys = self.conn.parse_public_keys()
code = util.pack('B', msg_code('SSH2_AGENT_IDENTITIES_ANSWER'))
num = util.pack('L', len(keys))
log.debug('available keys: %s', [k['n... | [
"def",
"list_pubs",
"(",
"self",
",",
"buf",
")",
":",
"assert",
"not",
"buf",
".",
"read",
"(",
")",
"keys",
"=",
"self",
".",
"conn",
".",
"parse_public_keys",
"(",
")",
"code",
"=",
"util",
".",
"pack",
"(",
"'B'",
",",
"msg_code",
"(",
"'SSH2_A... | SSH v2 public keys are serialized and returned. | [
"SSH",
"v2",
"public",
"keys",
"are",
"serialized",
"and",
"returned",
"."
] | python | train |
googleapis/google-cloud-python | bigquery/google/cloud/bigquery/table.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/table.py#L293-L332 | def to_bqstorage(self):
"""Construct a BigQuery Storage API representation of this table.
Install the ``google-cloud-bigquery-storage`` package to use this
feature.
If the ``table_id`` contains a partition identifier (e.g.
``my_table$201812``) or a snapshot identifier (e.g.
... | [
"def",
"to_bqstorage",
"(",
"self",
")",
":",
"if",
"bigquery_storage_v1beta1",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"_NO_BQSTORAGE_ERROR",
")",
"table_ref",
"=",
"bigquery_storage_v1beta1",
".",
"types",
".",
"TableReference",
"(",
")",
"table_ref",
"."... | Construct a BigQuery Storage API representation of this table.
Install the ``google-cloud-bigquery-storage`` package to use this
feature.
If the ``table_id`` contains a partition identifier (e.g.
``my_table$201812``) or a snapshot identifier (e.g.
``mytable@1234567890``), it is... | [
"Construct",
"a",
"BigQuery",
"Storage",
"API",
"representation",
"of",
"this",
"table",
"."
] | python | train |
xeroc/python-graphenelib | graphenecommon/wallet.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenecommon/wallet.py#L260-L269 | def getAccounts(self):
""" Return all accounts installed in the wallet database
"""
pubkeys = self.getPublicKeys()
accounts = []
for pubkey in pubkeys:
# Filter those keys not for our network
if pubkey[: len(self.prefix)] == self.prefix:
ac... | [
"def",
"getAccounts",
"(",
"self",
")",
":",
"pubkeys",
"=",
"self",
".",
"getPublicKeys",
"(",
")",
"accounts",
"=",
"[",
"]",
"for",
"pubkey",
"in",
"pubkeys",
":",
"# Filter those keys not for our network",
"if",
"pubkey",
"[",
":",
"len",
"(",
"self",
... | Return all accounts installed in the wallet database | [
"Return",
"all",
"accounts",
"installed",
"in",
"the",
"wallet",
"database"
] | python | valid |
wmayner/pyphi | pyphi/validate.py | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/validate.py#L177-L186 | def subsystem(s):
"""Validate a |Subsystem|.
Checks its state and cut.
"""
node_states(s.state)
cut(s.cut, s.cut_indices)
if config.VALIDATE_SUBSYSTEM_STATES:
state_reachable(s)
return True | [
"def",
"subsystem",
"(",
"s",
")",
":",
"node_states",
"(",
"s",
".",
"state",
")",
"cut",
"(",
"s",
".",
"cut",
",",
"s",
".",
"cut_indices",
")",
"if",
"config",
".",
"VALIDATE_SUBSYSTEM_STATES",
":",
"state_reachable",
"(",
"s",
")",
"return",
"True... | Validate a |Subsystem|.
Checks its state and cut. | [
"Validate",
"a",
"|Subsystem|",
"."
] | python | train |
noirbizarre/flask-fs | flask_fs/backends/s3.py | https://github.com/noirbizarre/flask-fs/blob/092e9327384b8411c9bb38ca257ecb558584d201/flask_fs/backends/s3.py#L89-L99 | def get_metadata(self, filename):
'''Fetch all availabe metadata'''
obj = self.bucket.Object(filename)
checksum = 'md5:{0}'.format(obj.e_tag[1:-1])
mime = obj.content_type.split(';', 1)[0] if obj.content_type else None
return {
'checksum': checksum,
'size'... | [
"def",
"get_metadata",
"(",
"self",
",",
"filename",
")",
":",
"obj",
"=",
"self",
".",
"bucket",
".",
"Object",
"(",
"filename",
")",
"checksum",
"=",
"'md5:{0}'",
".",
"format",
"(",
"obj",
".",
"e_tag",
"[",
"1",
":",
"-",
"1",
"]",
")",
"mime",... | Fetch all availabe metadata | [
"Fetch",
"all",
"availabe",
"metadata"
] | python | train |
openego/ding0 | ding0/grid/mv_grid/mv_connect.py | https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/grid/mv_grid/mv_connect.py#L583-L601 | def parametrize_lines(mv_grid):
""" Set unparametrized branches to default branch type
Args
----
mv_grid: MVGridDing0
MV grid instance
Notes
-----
During the connection process of satellites, new branches are created -
these have to be parametrized.
"""
for branch... | [
"def",
"parametrize_lines",
"(",
"mv_grid",
")",
":",
"for",
"branch",
"in",
"mv_grid",
".",
"graph_edges",
"(",
")",
":",
"if",
"branch",
"[",
"'branch'",
"]",
".",
"kind",
"is",
"None",
":",
"branch",
"[",
"'branch'",
"]",
".",
"kind",
"=",
"mv_grid"... | Set unparametrized branches to default branch type
Args
----
mv_grid: MVGridDing0
MV grid instance
Notes
-----
During the connection process of satellites, new branches are created -
these have to be parametrized. | [
"Set",
"unparametrized",
"branches",
"to",
"default",
"branch",
"type",
"Args",
"----",
"mv_grid",
":",
"MVGridDing0",
"MV",
"grid",
"instance"
] | python | train |
slightlynybbled/tk_tools | tk_tools/canvas.py | https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L579-L595 | def to_red(self, on: bool=False):
"""
Change the LED to red (on or off)
:param on: True or False
:return: None
"""
self._on = on
if on:
self._load_new(led_red_on)
if self._toggle_on_click:
self._canvas.bind('<Button-1>', la... | [
"def",
"to_red",
"(",
"self",
",",
"on",
":",
"bool",
"=",
"False",
")",
":",
"self",
".",
"_on",
"=",
"on",
"if",
"on",
":",
"self",
".",
"_load_new",
"(",
"led_red_on",
")",
"if",
"self",
".",
"_toggle_on_click",
":",
"self",
".",
"_canvas",
".",... | Change the LED to red (on or off)
:param on: True or False
:return: None | [
"Change",
"the",
"LED",
"to",
"red",
"(",
"on",
"or",
"off",
")",
":",
"param",
"on",
":",
"True",
"or",
"False",
":",
"return",
":",
"None"
] | python | train |
privacee/freelan-configurator | freelan_configurator/freelan_cfg.py | https://github.com/privacee/freelan-configurator/blob/7c070f8958454792f870ef0d195a7f5da36edb5a/freelan_configurator/freelan_cfg.py#L192-L247 | def validate(self):
"""Validation of configuration to check for required values"""
if not self.server.enabled:
if self.security.signature_certificate_file is self.security.defaults['signature_certificate_file']:
print("ISSUE: If you are not configuring a server, you need to... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"server",
".",
"enabled",
":",
"if",
"self",
".",
"security",
".",
"signature_certificate_file",
"is",
"self",
".",
"security",
".",
"defaults",
"[",
"'signature_certificate_file'",
"]",
":"... | Validation of configuration to check for required values | [
"Validation",
"of",
"configuration",
"to",
"check",
"for",
"required",
"values"
] | python | train |
mitsei/dlkit | dlkit/json_/authorization/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/sessions.py#L1716-L1741 | def delete_authorization(self, authorization_id):
"""Deletes the ``Authorization`` identified by the given ``Id``.
arg: authorization_id (osid.id.Id): the ``Id`` of the
``Authorization`` to delete
raise: NotFound - an ``Authorization`` was not found identified
... | [
"def",
"delete_authorization",
"(",
"self",
",",
"authorization_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceAdminSession.delete_resource_template",
"collection",
"=",
"JSONClientValidated",
"(",
"'authorization'",
",",
"collection",
"=",
"'Authoriza... | Deletes the ``Authorization`` identified by the given ``Id``.
arg: authorization_id (osid.id.Id): the ``Id`` of the
``Authorization`` to delete
raise: NotFound - an ``Authorization`` was not found identified
by the given ``Id``
raise: NullArgument - ``author... | [
"Deletes",
"the",
"Authorization",
"identified",
"by",
"the",
"given",
"Id",
"."
] | python | train |
ray-project/ray | python/ray/experimental/streaming/communication.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/communication.py#L205-L233 | def _flush(self, close=False):
"""Flushes remaining output records in the output queues to plasma.
None is used as special type of record that is propagated from sources
to sink to notify that the end of data in a stream.
Attributes:
close (bool): A flag denoting whether t... | [
"def",
"_flush",
"(",
"self",
",",
"close",
"=",
"False",
")",
":",
"for",
"channel",
"in",
"self",
".",
"forward_channels",
":",
"if",
"close",
"is",
"True",
":",
"channel",
".",
"queue",
".",
"put_next",
"(",
"None",
")",
"channel",
".",
"queue",
"... | Flushes remaining output records in the output queues to plasma.
None is used as special type of record that is propagated from sources
to sink to notify that the end of data in a stream.
Attributes:
close (bool): A flag denoting whether the channel should be
also mar... | [
"Flushes",
"remaining",
"output",
"records",
"in",
"the",
"output",
"queues",
"to",
"plasma",
"."
] | python | train |
numenta/nupic | src/nupic/algorithms/fdrutilities.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/fdrutilities.py#L1311-L1399 | def predictionExtent(inputs, resets, outputs, minOverlapPct=100.0):
"""
Computes the predictive ability of a temporal memory (TM). This routine returns
a value which is the average number of time steps of prediction provided
by the TM. It accepts as input the inputs, outputs, and resets provided to
the TM as ... | [
"def",
"predictionExtent",
"(",
"inputs",
",",
"resets",
",",
"outputs",
",",
"minOverlapPct",
"=",
"100.0",
")",
":",
"# List of how many times we encountered each prediction amount. Element 0",
"# is how many times we successfully predicted 0 steps in advance, element 1",
"# is h... | Computes the predictive ability of a temporal memory (TM). This routine returns
a value which is the average number of time steps of prediction provided
by the TM. It accepts as input the inputs, outputs, and resets provided to
the TM as well as a 'minOverlapPct' used to evalulate whether or not a
prediction is... | [
"Computes",
"the",
"predictive",
"ability",
"of",
"a",
"temporal",
"memory",
"(",
"TM",
")",
".",
"This",
"routine",
"returns",
"a",
"value",
"which",
"is",
"the",
"average",
"number",
"of",
"time",
"steps",
"of",
"prediction",
"provided",
"by",
"the",
"TM... | python | valid |
polyaxon/polyaxon | polyaxon/scheduler/spawners/templates/project_jobs/pods.py | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/scheduler/spawners/templates/project_jobs/pods.py#L41-L90 | def get_project_pod_spec(volume_mounts,
volumes,
image,
command,
args,
ports,
env_vars=None,
env_from=None,
container_na... | [
"def",
"get_project_pod_spec",
"(",
"volume_mounts",
",",
"volumes",
",",
"image",
",",
"command",
",",
"args",
",",
"ports",
",",
"env_vars",
"=",
"None",
",",
"env_from",
"=",
"None",
",",
"container_name",
"=",
"None",
",",
"resources",
"=",
"None",
","... | Pod spec to be used to create pods for project: tensorboard, notebooks. | [
"Pod",
"spec",
"to",
"be",
"used",
"to",
"create",
"pods",
"for",
"project",
":",
"tensorboard",
"notebooks",
"."
] | python | train |
nsavch/python-xonotic-db | xon_db/cli.py | https://github.com/nsavch/python-xonotic-db/blob/339fe4c2c74880fd66712ae32789d7e9ae3e8f02/xon_db/cli.py#L65-L71 | def remove_cts_record(file_name, map, position):
"""
Remove cts record on MAP and POSITION
"""
db = XonoticDB.load_path(file_name)
db.remove_cts_record(map, position)
db.save(file_name) | [
"def",
"remove_cts_record",
"(",
"file_name",
",",
"map",
",",
"position",
")",
":",
"db",
"=",
"XonoticDB",
".",
"load_path",
"(",
"file_name",
")",
"db",
".",
"remove_cts_record",
"(",
"map",
",",
"position",
")",
"db",
".",
"save",
"(",
"file_name",
"... | Remove cts record on MAP and POSITION | [
"Remove",
"cts",
"record",
"on",
"MAP",
"and",
"POSITION"
] | python | train |
matthieugouel/gibica | gibica/parser.py | https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/parser.py#L102-L117 | def parameters(self):
"""
parameters: '(' logical_or_expr (',' logical_or_expr)* ')'
"""
nodes = []
self._process(Nature.LPAREN)
while self.token.nature != Nature.RPAREN:
nodes.append(Parameters(variable=self.logical_or_expr()))
if self.token.na... | [
"def",
"parameters",
"(",
"self",
")",
":",
"nodes",
"=",
"[",
"]",
"self",
".",
"_process",
"(",
"Nature",
".",
"LPAREN",
")",
"while",
"self",
".",
"token",
".",
"nature",
"!=",
"Nature",
".",
"RPAREN",
":",
"nodes",
".",
"append",
"(",
"Parameters... | parameters: '(' logical_or_expr (',' logical_or_expr)* ')' | [
"parameters",
":",
"(",
"logical_or_expr",
"(",
"logical_or_expr",
")",
"*",
")"
] | python | train |
ema/pycodicefiscale | codicefiscale.py | https://github.com/ema/pycodicefiscale/blob/4d06a145cdcffe7ee576f2fedaf40e2c6f7692a4/codicefiscale.py#L147-L176 | def build(surname, name, birthday, sex, municipality):
"""``build(surname, name, birthday, sex, municipality) -> string``
Computes the fiscal code for the given person data.
eg: build('Rocca', 'Emanuele', datetime.datetime(1983, 11, 18), 'M', 'D969')
-> RCCMNL83S18D969H
"""
# RCCMNL
... | [
"def",
"build",
"(",
"surname",
",",
"name",
",",
"birthday",
",",
"sex",
",",
"municipality",
")",
":",
"# RCCMNL",
"output",
"=",
"__surname_triplet",
"(",
"surname",
")",
"+",
"__name_triplet",
"(",
"name",
")",
"# RCCMNL83",
"output",
"+=",
"str",
"(",... | ``build(surname, name, birthday, sex, municipality) -> string``
Computes the fiscal code for the given person data.
eg: build('Rocca', 'Emanuele', datetime.datetime(1983, 11, 18), 'M', 'D969')
-> RCCMNL83S18D969H | [
"build",
"(",
"surname",
"name",
"birthday",
"sex",
"municipality",
")",
"-",
">",
"string"
] | python | valid |
softlayer/softlayer-python | SoftLayer/managers/hardware.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/hardware.py#L459-L523 | def _generate_create_dict(self,
size=None,
hostname=None,
domain=None,
location=None,
os=None,
port_speed=None,
... | [
"def",
"_generate_create_dict",
"(",
"self",
",",
"size",
"=",
"None",
",",
"hostname",
"=",
"None",
",",
"domain",
"=",
"None",
",",
"location",
"=",
"None",
",",
"os",
"=",
"None",
",",
"port_speed",
"=",
"None",
",",
"ssh_keys",
"=",
"None",
",",
... | Translates arguments into a dictionary for creating a server. | [
"Translates",
"arguments",
"into",
"a",
"dictionary",
"for",
"creating",
"a",
"server",
"."
] | python | train |
awslabs/serverless-application-model | samtranslator/model/eventsources/cloudwatchlogs.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/eventsources/cloudwatchlogs.py#L18-L36 | def to_cloudformation(self, **kwargs):
"""Returns the CloudWatch Logs Subscription Filter and Lambda Permission to which this CloudWatch Logs event source
corresponds.
:param dict kwargs: no existing resources need to be modified
:returns: a list of vanilla CloudFormation Resources, to ... | [
"def",
"to_cloudformation",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"function",
"=",
"kwargs",
".",
"get",
"(",
"'function'",
")",
"if",
"not",
"function",
":",
"raise",
"TypeError",
"(",
"\"Missing required keyword argument: function\"",
")",
"source_ar... | Returns the CloudWatch Logs Subscription Filter and Lambda Permission to which this CloudWatch Logs event source
corresponds.
:param dict kwargs: no existing resources need to be modified
:returns: a list of vanilla CloudFormation Resources, to which this push event expands
:rtype: list | [
"Returns",
"the",
"CloudWatch",
"Logs",
"Subscription",
"Filter",
"and",
"Lambda",
"Permission",
"to",
"which",
"this",
"CloudWatch",
"Logs",
"event",
"source",
"corresponds",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_span.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_span.py#L12-L22 | def monitor_session_session_number(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
monitor = ET.SubElement(config, "monitor", xmlns="urn:brocade.com:mgmt:brocade-span")
session = ET.SubElement(monitor, "session")
session_number = ET.SubElement(se... | [
"def",
"monitor_session_session_number",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"monitor",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"monitor\"",
",",
"xmlns",
"=",
"\"urn:broc... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
OSSOS/MOP | src/ossos/core/ossos/astrom.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/astrom.py#L675-L687 | def _original_frame(self, x, y):
"""
Return x/y in the original frame, based on a guess as much as anything.
:param x: x pixel coordinate
:type x: float
:param y: y pixel coordinate
:type y: float
:return: x,y
:rtype: float, float
"""
if se... | [
"def",
"_original_frame",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"self",
".",
"_inverted",
":",
"return",
"self",
".",
"obs",
".",
"naxis1",
"-",
"x",
",",
"self",
".",
"obs",
".",
"naxis2",
"-",
"y",
"return",
"x",
",",
"y"
] | Return x/y in the original frame, based on a guess as much as anything.
:param x: x pixel coordinate
:type x: float
:param y: y pixel coordinate
:type y: float
:return: x,y
:rtype: float, float | [
"Return",
"x",
"/",
"y",
"in",
"the",
"original",
"frame",
"based",
"on",
"a",
"guess",
"as",
"much",
"as",
"anything",
".",
":",
"param",
"x",
":",
"x",
"pixel",
"coordinate",
":",
"type",
"x",
":",
"float",
":",
"param",
"y",
":",
"y",
"pixel",
... | python | train |
kensho-technologies/graphql-compiler | graphql_compiler/query_formatting/match_formatting.py | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L59-L75 | def _safe_match_list(inner_type, argument_value):
"""Represent the list of "inner_type" objects in MATCH form."""
stripped_type = strip_non_null_from_type(inner_type)
if isinstance(stripped_type, GraphQLList):
raise GraphQLInvalidArgumentError(u'MATCH does not currently support nested lists, '
... | [
"def",
"_safe_match_list",
"(",
"inner_type",
",",
"argument_value",
")",
":",
"stripped_type",
"=",
"strip_non_null_from_type",
"(",
"inner_type",
")",
"if",
"isinstance",
"(",
"stripped_type",
",",
"GraphQLList",
")",
":",
"raise",
"GraphQLInvalidArgumentError",
"("... | Represent the list of "inner_type" objects in MATCH form. | [
"Represent",
"the",
"list",
"of",
"inner_type",
"objects",
"in",
"MATCH",
"form",
"."
] | python | train |
urinieto/msaf | msaf/algorithms/interface.py | https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/algorithms/interface.py#L102-L123 | def _postprocess(self, est_idxs, est_labels):
"""Post processes the estimations from the algorithm, removing empty
segments and making sure the lenghts of the boundaries and labels
match."""
# Make sure we are using the previously input bounds, if any
if self.in_bound_idxs is not... | [
"def",
"_postprocess",
"(",
"self",
",",
"est_idxs",
",",
"est_labels",
")",
":",
"# Make sure we are using the previously input bounds, if any",
"if",
"self",
".",
"in_bound_idxs",
"is",
"not",
"None",
":",
"F",
"=",
"self",
".",
"_preprocess",
"(",
")",
"est_lab... | Post processes the estimations from the algorithm, removing empty
segments and making sure the lenghts of the boundaries and labels
match. | [
"Post",
"processes",
"the",
"estimations",
"from",
"the",
"algorithm",
"removing",
"empty",
"segments",
"and",
"making",
"sure",
"the",
"lenghts",
"of",
"the",
"boundaries",
"and",
"labels",
"match",
"."
] | python | test |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/qt/console/frontend_widget.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/frontend_widget.py#L674-L687 | def _complete(self):
""" Performs completion at the current cursor location.
"""
context = self._get_context()
if context:
# Send the completion request to the kernel
msg_id = self.kernel_manager.shell_channel.complete(
'.'.join(context), ... | [
"def",
"_complete",
"(",
"self",
")",
":",
"context",
"=",
"self",
".",
"_get_context",
"(",
")",
"if",
"context",
":",
"# Send the completion request to the kernel",
"msg_id",
"=",
"self",
".",
"kernel_manager",
".",
"shell_channel",
".",
"complete",
"(",
"'.'"... | Performs completion at the current cursor location. | [
"Performs",
"completion",
"at",
"the",
"current",
"cursor",
"location",
"."
] | python | test |
Stranger6667/postmarker | postmarker/models/stats.py | https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L26-L30 | def spam(self, tag=None, fromdate=None, todate=None):
"""
Gets a total count of recipients who have marked your email as spam.
"""
return self.call("GET", "/stats/outbound/spam", tag=tag, fromdate=fromdate, todate=todate) | [
"def",
"spam",
"(",
"self",
",",
"tag",
"=",
"None",
",",
"fromdate",
"=",
"None",
",",
"todate",
"=",
"None",
")",
":",
"return",
"self",
".",
"call",
"(",
"\"GET\"",
",",
"\"/stats/outbound/spam\"",
",",
"tag",
"=",
"tag",
",",
"fromdate",
"=",
"fr... | Gets a total count of recipients who have marked your email as spam. | [
"Gets",
"a",
"total",
"count",
"of",
"recipients",
"who",
"have",
"marked",
"your",
"email",
"as",
"spam",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/rbridge_id/interface/ve/ipv6/ipv6_local_anycast_gateway/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/interface/ve/ipv6/ipv6_local_anycast_gateway/__init__.py#L201-L222 | def _set_load_balancing(self, v, load=False):
"""
Setter method for load_balancing, mapped from YANG variable /rbridge_id/interface/ve/ipv6/ipv6_local_anycast_gateway/load_balancing (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_load_balancing is considered ... | [
"def",
"_set_load_balancing",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
... | Setter method for load_balancing, mapped from YANG variable /rbridge_id/interface/ve/ipv6/ipv6_local_anycast_gateway/load_balancing (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_load_balancing is considered as a private
method. Backends looking to populate this... | [
"Setter",
"method",
"for",
"load_balancing",
"mapped",
"from",
"YANG",
"variable",
"/",
"rbridge_id",
"/",
"interface",
"/",
"ve",
"/",
"ipv6",
"/",
"ipv6_local_anycast_gateway",
"/",
"load_balancing",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read... | python | train |
dw/mitogen | mitogen/compat/pkgutil.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/compat/pkgutil.py#L468-L481 | def find_loader(fullname):
"""Find a PEP 302 "loader" object for fullname
If fullname contains dots, path must be the containing package's __path__.
Returns None if the module cannot be found or imported. This function uses
iter_importers(), and is thus subject to the same limitations regarding
pla... | [
"def",
"find_loader",
"(",
"fullname",
")",
":",
"for",
"importer",
"in",
"iter_importers",
"(",
"fullname",
")",
":",
"loader",
"=",
"importer",
".",
"find_module",
"(",
"fullname",
")",
"if",
"loader",
"is",
"not",
"None",
":",
"return",
"loader",
"retur... | Find a PEP 302 "loader" object for fullname
If fullname contains dots, path must be the containing package's __path__.
Returns None if the module cannot be found or imported. This function uses
iter_importers(), and is thus subject to the same limitations regarding
platform-specific special import loca... | [
"Find",
"a",
"PEP",
"302",
"loader",
"object",
"for",
"fullname"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.