nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
jgirardet/sublack | 5b76fbce293ad3402547ed9f101291dff8a749a5 | sublack/checker.py | python | Checker.watch | (self) | [] | def watch(self):
while True:
time.sleep(self.interval)
if not self.is_running():
return | [
"def",
"watch",
"(",
"self",
")",
":",
"while",
"True",
":",
"time",
".",
"sleep",
"(",
"self",
".",
"interval",
")",
"if",
"not",
"self",
".",
"is_running",
"(",
")",
":",
"return"
] | https://github.com/jgirardet/sublack/blob/5b76fbce293ad3402547ed9f101291dff8a749a5/sublack/checker.py#L118-L123 | ||||
kennethreitz-archive/requests3 | 69eb662703b40db58fdc6c095d0fe130c56649bb | requests3/core/_http/_backends/trio_backend.py | python | TrioSocket.send_and_receive_for_a_while | (self, produce_bytes, consume_bytes) | [] | async def send_and_receive_for_a_while(self, produce_bytes, consume_bytes):
async def sender():
while True:
outgoing = await produce_bytes()
if outgoing is None:
break
await self._stream.send_all(outgoing)
async def receiv... | [
"async",
"def",
"send_and_receive_for_a_while",
"(",
"self",
",",
"produce_bytes",
",",
"consume_bytes",
")",
":",
"async",
"def",
"sender",
"(",
")",
":",
"while",
"True",
":",
"outgoing",
"=",
"await",
"produce_bytes",
"(",
")",
"if",
"outgoing",
"is",
"No... | https://github.com/kennethreitz-archive/requests3/blob/69eb662703b40db58fdc6c095d0fe130c56649bb/requests3/core/_http/_backends/trio_backend.py#L53-L72 | ||||
ahmetcemturan/SFACT | 7576e29ba72b33e5058049b77b7b558875542747 | fabmetheus_utilities/gcodec.py | python | getFirstWord | (splitLine) | return '' | Get the first word of a split line. | Get the first word of a split line. | [
"Get",
"the",
"first",
"word",
"of",
"a",
"split",
"line",
"."
] | def getFirstWord(splitLine):
'Get the first word of a split line.'
if len(splitLine) > 0:
return splitLine[0]
return '' | [
"def",
"getFirstWord",
"(",
"splitLine",
")",
":",
"if",
"len",
"(",
"splitLine",
")",
">",
"0",
":",
"return",
"splitLine",
"[",
"0",
"]",
"return",
"''"
] | https://github.com/ahmetcemturan/SFACT/blob/7576e29ba72b33e5058049b77b7b558875542747/fabmetheus_utilities/gcodec.py#L102-L106 | |
beeware/ouroboros | a29123c6fab6a807caffbb7587cf548e0c370296 | ouroboros/ast.py | python | iter_fields | (node) | Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
that is present on *node*. | Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
that is present on *node*. | [
"Yield",
"a",
"tuple",
"of",
"(",
"fieldname",
"value",
")",
"for",
"each",
"field",
"in",
"node",
".",
"_fields",
"that",
"is",
"present",
"on",
"*",
"node",
"*",
"."
] | def iter_fields(node):
"""
Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
that is present on *node*.
"""
for field in node._fields:
try:
yield field, getattr(node, field)
except AttributeError:
pass | [
"def",
"iter_fields",
"(",
"node",
")",
":",
"for",
"field",
"in",
"node",
".",
"_fields",
":",
"try",
":",
"yield",
"field",
",",
"getattr",
"(",
"node",
",",
"field",
")",
"except",
"AttributeError",
":",
"pass"
] | https://github.com/beeware/ouroboros/blob/a29123c6fab6a807caffbb7587cf548e0c370296/ouroboros/ast.py#L165-L174 | ||
frappe/erpnext | 9d36e30ef7043b391b5ed2523b8288bf46c45d18 | erpnext/accounts/doctype/sales_invoice/sales_invoice.py | python | SalesInvoice.set_against_income_account | (self) | Set against account for debit to account | Set against account for debit to account | [
"Set",
"against",
"account",
"for",
"debit",
"to",
"account"
] | def set_against_income_account(self):
"""Set against account for debit to account"""
against_acc = []
for d in self.get('items'):
if d.income_account and d.income_account not in against_acc:
against_acc.append(d.income_account)
self.against_income_account = ','.join(against_acc) | [
"def",
"set_against_income_account",
"(",
"self",
")",
":",
"against_acc",
"=",
"[",
"]",
"for",
"d",
"in",
"self",
".",
"get",
"(",
"'items'",
")",
":",
"if",
"d",
".",
"income_account",
"and",
"d",
".",
"income_account",
"not",
"in",
"against_acc",
":"... | https://github.com/frappe/erpnext/blob/9d36e30ef7043b391b5ed2523b8288bf46c45d18/erpnext/accounts/doctype/sales_invoice/sales_invoice.py#L614-L620 | ||
openedx/edx-platform | 68dd185a0ab45862a2a61e0f803d7e03d2be71b5 | openedx/core/djangoapps/embargo/forms.py | python | IPFilterForm._is_valid_ip | (self, address) | return True | Whether or not address is a valid ipv4 address or ipv6 address | Whether or not address is a valid ipv4 address or ipv6 address | [
"Whether",
"or",
"not",
"address",
"is",
"a",
"valid",
"ipv4",
"address",
"or",
"ipv6",
"address"
] | def _is_valid_ip(self, address):
"""Whether or not address is a valid ipv4 address or ipv6 address"""
try:
# Is this an valid ip address?
ipaddress.ip_network(address)
except ValueError:
return False
return True | [
"def",
"_is_valid_ip",
"(",
"self",
",",
"address",
")",
":",
"try",
":",
"# Is this an valid ip address?",
"ipaddress",
".",
"ip_network",
"(",
"address",
")",
"except",
"ValueError",
":",
"return",
"False",
"return",
"True"
] | https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/openedx/core/djangoapps/embargo/forms.py#L66-L73 | |
tp4a/teleport | 1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad | server/www/packages/packages-linux/x64/ldap3/operation/bind.py | python | bind_operation | (version,
authentication,
name='',
password=None,
sasl_mechanism=None,
sasl_credentials=None,
auto_encode=False) | return request | [] | def bind_operation(version,
authentication,
name='',
password=None,
sasl_mechanism=None,
sasl_credentials=None,
auto_encode=False):
# BindRequest ::= [APPLICATION 0] SEQUENCE {
# ... | [
"def",
"bind_operation",
"(",
"version",
",",
"authentication",
",",
"name",
"=",
"''",
",",
"password",
"=",
"None",
",",
"sasl_mechanism",
"=",
"None",
",",
"sasl_credentials",
"=",
"None",
",",
"auto_encode",
"=",
"False",
")",
":",
"# BindRequest ::= [APPL... | https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-linux/x64/ldap3/operation/bind.py#L36-L90 | |||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/IPython/lib/inputhook.py | python | InputHookManager.get_pyos_inputhook | (self) | return ctypes.c_void_p.in_dll(ctypes.pythonapi,"PyOS_InputHook") | DEPRECATED since IPython 5.0
Return the current PyOS_InputHook as a ctypes.c_void_p. | DEPRECATED since IPython 5.0 | [
"DEPRECATED",
"since",
"IPython",
"5",
".",
"0"
] | def get_pyos_inputhook(self):
"""DEPRECATED since IPython 5.0
Return the current PyOS_InputHook as a ctypes.c_void_p."""
warn("`get_pyos_inputhook` is deprecated since IPython 5.0 and will be removed in future versions.",
DeprecationWarning, stacklevel=2)
return ctypes.c... | [
"def",
"get_pyos_inputhook",
"(",
"self",
")",
":",
"warn",
"(",
"\"`get_pyos_inputhook` is deprecated since IPython 5.0 and will be removed in future versions.\"",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"2",
")",
"return",
"ctypes",
".",
"c_void_p",
".",
"in_dl... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/IPython/lib/inputhook.py#L132-L138 | |
codelucas/newspaper | f622011177f6c2e95e48d6076561e21c016f08c3 | newspaper/urls.py | python | prepare_url | (url, source_url=None) | return proper_url | Operations that purify a url, removes arguments,
redirects, and merges relatives with absolutes. | Operations that purify a url, removes arguments,
redirects, and merges relatives with absolutes. | [
"Operations",
"that",
"purify",
"a",
"url",
"removes",
"arguments",
"redirects",
"and",
"merges",
"relatives",
"with",
"absolutes",
"."
] | def prepare_url(url, source_url=None):
"""
Operations that purify a url, removes arguments,
redirects, and merges relatives with absolutes.
"""
try:
if source_url is not None:
source_domain = urlparse(source_url).netloc
proper_url = urljoin(source_url, url)
... | [
"def",
"prepare_url",
"(",
"url",
",",
"source_url",
"=",
"None",
")",
":",
"try",
":",
"if",
"source_url",
"is",
"not",
"None",
":",
"source_domain",
"=",
"urlparse",
"(",
"source_url",
")",
".",
"netloc",
"proper_url",
"=",
"urljoin",
"(",
"source_url",
... | https://github.com/codelucas/newspaper/blob/f622011177f6c2e95e48d6076561e21c016f08c3/newspaper/urls.py#L81-L99 | |
smokeleeteveryday/CTF_WRITEUPS | 4683f0d41c92c4ed407cc3dd3b1760c68a05943f | 2015/AIVD_CYBERCHALLENGE/solution/check_crack.py | python | reverse_fc | ( y ) | return solutionsx | [] | def reverse_fc( y ):
solutionsx = []
for i in xrange(0,6):
candidate = (((max_intval * i) + y ) - 2236067977 )
if candidate % 5 != 0:
continue
candidate /= 5
if candidate > 0 and (candidate % 4) == 2:
solutionsx.append(candidate)
return solutionsx | [
"def",
"reverse_fc",
"(",
"y",
")",
":",
"solutionsx",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"6",
")",
":",
"candidate",
"=",
"(",
"(",
"(",
"max_intval",
"*",
"i",
")",
"+",
"y",
")",
"-",
"2236067977",
")",
"if",
"candidat... | https://github.com/smokeleeteveryday/CTF_WRITEUPS/blob/4683f0d41c92c4ed407cc3dd3b1760c68a05943f/2015/AIVD_CYBERCHALLENGE/solution/check_crack.py#L35-L47 | |||
netbox-community/netbox | 50309d3ab3da2212343e1d9feaf47e497df9c3cb | netbox/extras/reports.py | python | Report.log | (self, message) | Log a message which is not associated with a particular object. | Log a message which is not associated with a particular object. | [
"Log",
"a",
"message",
"which",
"is",
"not",
"associated",
"with",
"a",
"particular",
"object",
"."
] | def log(self, message):
"""
Log a message which is not associated with a particular object.
"""
self._log(None, message, level=LogLevelChoices.LOG_DEFAULT)
self.logger.info(message) | [
"def",
"log",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"_log",
"(",
"None",
",",
"message",
",",
"level",
"=",
"LogLevelChoices",
".",
"LOG_DEFAULT",
")",
"self",
".",
"logger",
".",
"info",
"(",
"message",
")"
] | https://github.com/netbox-community/netbox/blob/50309d3ab3da2212343e1d9feaf47e497df9c3cb/netbox/extras/reports.py#L180-L185 | ||
PaddlePaddle/PaddleSpeech | 26524031d242876b7fdb71582b0b3a7ea45c7d9d | paddlespeech/t2s/modules/losses.py | python | weighted_mean | (input, weight) | return paddle.sum(input * weight) / (paddle.sum(weight) * broadcast_ratio) | Weighted mean. It can also be used as masked mean.
Parameters
-----------
input : Tensor
The input tensor.
weight : Tensor
The weight tensor with broadcastable shape with the input.
Returns
----------
Tensor [shape=(1,)]
Weighted mean tensor with the same dtype as ... | Weighted mean. It can also be used as masked mean. | [
"Weighted",
"mean",
".",
"It",
"can",
"also",
"be",
"used",
"as",
"masked",
"mean",
"."
] | def weighted_mean(input, weight):
"""Weighted mean. It can also be used as masked mean.
Parameters
-----------
input : Tensor
The input tensor.
weight : Tensor
The weight tensor with broadcastable shape with the input.
Returns
----------
Tensor [shape=(1,)]
Wei... | [
"def",
"weighted_mean",
"(",
"input",
",",
"weight",
")",
":",
"weight",
"=",
"paddle",
".",
"cast",
"(",
"weight",
",",
"input",
".",
"dtype",
")",
"broadcast_ratio",
"=",
"input",
".",
"size",
"/",
"weight",
".",
"size",
"return",
"paddle",
".",
"sum... | https://github.com/PaddlePaddle/PaddleSpeech/blob/26524031d242876b7fdb71582b0b3a7ea45c7d9d/paddlespeech/t2s/modules/losses.py#L420-L437 | |
jdf/processing.py | 76e48ac855fd34169a7576a5cbc396bda698e781 | mode/formatter/pep8.py | python | python_3000_not_equal | (logical_line) | r"""New code should always use != instead of <>.
The older syntax is removed in Python 3.
Okay: if a != 'no':
W603: if a <> 'no': | r"""New code should always use != instead of <>. | [
"r",
"New",
"code",
"should",
"always",
"use",
"!",
"=",
"instead",
"of",
"<",
">",
"."
] | def python_3000_not_equal(logical_line):
r"""New code should always use != instead of <>.
The older syntax is removed in Python 3.
Okay: if a != 'no':
W603: if a <> 'no':
"""
pos = logical_line.find('<>')
if pos > -1:
yield pos, "W603 '<>' is deprecated, use '!='" | [
"def",
"python_3000_not_equal",
"(",
"logical_line",
")",
":",
"pos",
"=",
"logical_line",
".",
"find",
"(",
"'<>'",
")",
"if",
"pos",
">",
"-",
"1",
":",
"yield",
"pos",
",",
"\"W603 '<>' is deprecated, use '!='\""
] | https://github.com/jdf/processing.py/blob/76e48ac855fd34169a7576a5cbc396bda698e781/mode/formatter/pep8.py#L1016-L1026 | ||
frankban/django-endless-pagination | 4814fe7cf81277efe35e96b88f57cc260a771255 | endless_pagination/views.py | python | MultipleObjectMixin.get_context_data | (self, **kwargs) | return context | Get the context for this view.
Also adds the *page_template* variable in the context.
If the *page_template* is not given as a kwarg of the *as_view*
method then it is generated using app label, model name
(obviously if the list is a queryset), *self.template_name_suffix*
and *... | Get the context for this view. | [
"Get",
"the",
"context",
"for",
"this",
"view",
"."
] | def get_context_data(self, **kwargs):
"""Get the context for this view.
Also adds the *page_template* variable in the context.
If the *page_template* is not given as a kwarg of the *as_view*
method then it is generated using app label, model name
(obviously if the list is a que... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"queryset",
"=",
"kwargs",
".",
"pop",
"(",
"'object_list'",
")",
"page_template",
"=",
"kwargs",
".",
"pop",
"(",
"'page_template'",
",",
"None",
")",
"context_object_name",
"=",
"... | https://github.com/frankban/django-endless-pagination/blob/4814fe7cf81277efe35e96b88f57cc260a771255/endless_pagination/views.py#L63-L93 | |
gaasedelen/lighthouse | 7245a2d2c4e84351cd259ed81dafa4263167909a | plugins/lighthouse/ui/coverage_overview.py | python | CoverageOverview._ui_init_toolbar | (self) | Initialize the coverage toolbar. | Initialize the coverage toolbar. | [
"Initialize",
"the",
"coverage",
"toolbar",
"."
] | def _ui_init_toolbar(self):
"""
Initialize the coverage toolbar.
"""
# initialize child elements to go on the toolbar
self._ui_init_toolbar_elements()
self._ui_init_settings()
#
# create the 'toolbar', and customize its style. specifically, we are
... | [
"def",
"_ui_init_toolbar",
"(",
"self",
")",
":",
"# initialize child elements to go on the toolbar",
"self",
".",
"_ui_init_toolbar_elements",
"(",
")",
"self",
".",
"_ui_init_settings",
"(",
")",
"#",
"# create the 'toolbar', and customize its style. specifically, we are",
"#... | https://github.com/gaasedelen/lighthouse/blob/7245a2d2c4e84351cd259ed81dafa4263167909a/plugins/lighthouse/ui/coverage_overview.py#L99-L119 | ||
n374/dmusic-plugin-NeteaseCloudMusic | 503701ce6c2c4d94f1fcd40a158c7a0077861793 | neteasecloudmusic/netease_music_playlist.py | python | MusicPlaylist.save | (self, *args) | [] | def save(self, *args):
if Player.get_source() == self.playing_list_item.song_view:
current_playing_item = 'playing_list'
elif Player.get_source() == self.personal_fm_item.song_view:
current_playing_item = 'personal_fm'
else:
current_playing_item = None
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"Player",
".",
"get_source",
"(",
")",
"==",
"self",
".",
"playing_list_item",
".",
"song_view",
":",
"current_playing_item",
"=",
"'playing_list'",
"elif",
"Player",
".",
"get_source",
"(",
")"... | https://github.com/n374/dmusic-plugin-NeteaseCloudMusic/blob/503701ce6c2c4d94f1fcd40a158c7a0077861793/neteasecloudmusic/netease_music_playlist.py#L224-L247 | ||||
wistbean/learn_python3_spider | 73c873f4845f4385f097e5057407d03dd37a117b | stackoverflow/venv/lib/python3.6/site-packages/twisted/web/microdom.py | python | getElementsByTagName | (iNode, name) | return matches | Return a list of all child elements of C{iNode} with a name matching
C{name}.
Note that this implementation does not conform to the DOM Level 1 Core
specification because it may return C{iNode}.
@param iNode: An element at which to begin searching. If C{iNode} has a
name matching C{name}, it ... | Return a list of all child elements of C{iNode} with a name matching
C{name}. | [
"Return",
"a",
"list",
"of",
"all",
"child",
"elements",
"of",
"C",
"{",
"iNode",
"}",
"with",
"a",
"name",
"matching",
"C",
"{",
"name",
"}",
"."
] | def getElementsByTagName(iNode, name):
"""
Return a list of all child elements of C{iNode} with a name matching
C{name}.
Note that this implementation does not conform to the DOM Level 1 Core
specification because it may return C{iNode}.
@param iNode: An element at which to begin searching. I... | [
"def",
"getElementsByTagName",
"(",
"iNode",
",",
"name",
")",
":",
"matches",
"=",
"[",
"]",
"matches_append",
"=",
"matches",
".",
"append",
"# faster lookup. don't do this at home",
"slice",
"=",
"[",
"iNode",
"]",
"while",
"len",
"(",
"slice",
")",
">",
... | https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/twisted/web/microdom.py#L32-L56 | |
canonical/cloud-init | dc1aabfca851e520693c05322f724bd102c76364 | cloudinit/sources/DataSourceMAAS.py | python | read_maas_seed_url | (
seed_url,
read_file_or_url=None,
timeout=None,
version=MD_VERSION,
paths=None,
retries=None,
) | return check_seed_contents(md, seed_url) | Read the maas datasource at seed_url.
read_file_or_url is a method that should provide an interface
like util.read_file_or_url
Expected format of seed_url is are the following files:
* <seed_url>/<version>/meta-data/instance-id
* <seed_url>/<version>/meta-data/local-hostname
* <seed_u... | Read the maas datasource at seed_url.
read_file_or_url is a method that should provide an interface
like util.read_file_or_url | [
"Read",
"the",
"maas",
"datasource",
"at",
"seed_url",
".",
"read_file_or_url",
"is",
"a",
"method",
"that",
"should",
"provide",
"an",
"interface",
"like",
"util",
".",
"read_file_or_url"
] | def read_maas_seed_url(
seed_url,
read_file_or_url=None,
timeout=None,
version=MD_VERSION,
paths=None,
retries=None,
):
"""
Read the maas datasource at seed_url.
read_file_or_url is a method that should provide an interface
like util.read_file_or_url
Expected format of s... | [
"def",
"read_maas_seed_url",
"(",
"seed_url",
",",
"read_file_or_url",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"version",
"=",
"MD_VERSION",
",",
"paths",
"=",
"None",
",",
"retries",
"=",
"None",
",",
")",
":",
"if",
"read_file_or_url",
"is",
"None... | https://github.com/canonical/cloud-init/blob/dc1aabfca851e520693c05322f724bd102c76364/cloudinit/sources/DataSourceMAAS.py#L196-L251 | |
neuropsychology/NeuroKit | d01111b9b82364d28da01c002e6cbfc45d9493d9 | neurokit2/hrv/hrv_rsa.py | python | _hrv_rsa_cycles | (signals) | return {
"RSP_Inspiration_Onsets": inspiration_onsets,
"RSP_Expiration_Onsets": expiration_onsets,
"RSP_Cycles_Length": cycles_length,
} | Extract respiratory cycles. | Extract respiratory cycles. | [
"Extract",
"respiratory",
"cycles",
"."
] | def _hrv_rsa_cycles(signals):
"""Extract respiratory cycles."""
inspiration_onsets = np.intersect1d(
np.where(signals["RSP_Phase"] == 1)[0],
np.where(signals["RSP_Phase_Completion"] == 0)[0],
assume_unique=True,
)
expiration_onsets = np.intersect1d(
np.where(signals["RSP... | [
"def",
"_hrv_rsa_cycles",
"(",
"signals",
")",
":",
"inspiration_onsets",
"=",
"np",
".",
"intersect1d",
"(",
"np",
".",
"where",
"(",
"signals",
"[",
"\"RSP_Phase\"",
"]",
"==",
"1",
")",
"[",
"0",
"]",
",",
"np",
".",
"where",
"(",
"signals",
"[",
... | https://github.com/neuropsychology/NeuroKit/blob/d01111b9b82364d28da01c002e6cbfc45d9493d9/neurokit2/hrv/hrv_rsa.py#L503-L523 | |
compas-dev/compas | 0b33f8786481f710115fb1ae5fe79abc2a9a5175 | src/compas/geometry/shapes/capsule.py | python | Capsule.transform | (self, transformation) | Transform this `Capsule` using a given transformation.
Parameters
----------
transformation : :class:`compas.geometry.Transformation`
The transformation used to transform the capsule.
Returns
-------
None | Transform this `Capsule` using a given transformation. | [
"Transform",
"this",
"Capsule",
"using",
"a",
"given",
"transformation",
"."
] | def transform(self, transformation):
"""Transform this `Capsule` using a given transformation.
Parameters
----------
transformation : :class:`compas.geometry.Transformation`
The transformation used to transform the capsule.
Returns
-------
None
... | [
"def",
"transform",
"(",
"self",
",",
"transformation",
")",
":",
"self",
".",
"line",
".",
"transform",
"(",
"transformation",
")"
] | https://github.com/compas-dev/compas/blob/0b33f8786481f710115fb1ae5fe79abc2a9a5175/src/compas/geometry/shapes/capsule.py#L283-L296 | ||
glouppe/info8006-introduction-to-ai | 8360cc9a8c418559e402be1454ec885b6c1062d7 | projects/project0/pacman_module/util.py | python | Stack.isEmpty | (self) | return len(self.list) == 0 | Returns true if the stack is empty | Returns true if the stack is empty | [
"Returns",
"true",
"if",
"the",
"stack",
"is",
"empty"
] | def isEmpty(self):
"Returns true if the stack is empty"
return len(self.list) == 0 | [
"def",
"isEmpty",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"list",
")",
"==",
"0"
] | https://github.com/glouppe/info8006-introduction-to-ai/blob/8360cc9a8c418559e402be1454ec885b6c1062d7/projects/project0/pacman_module/util.py#L151-L153 | |
hzlzh/AlfredWorkflow.com | 7055f14f6922c80ea5943839eb0caff11ae57255 | Sources/Workflows/KindleBookstore/PyAl/Request/requests/auth.py | python | HTTPDigestAuth.handle_401 | (self, r) | return r | Takes the given response and tries digest-auth, if needed. | Takes the given response and tries digest-auth, if needed. | [
"Takes",
"the",
"given",
"response",
"and",
"tries",
"digest",
"-",
"auth",
"if",
"needed",
"."
] | def handle_401(self, r):
"""Takes the given response and tries digest-auth, if needed."""
num_401_calls = r.request.hooks['response'].count(self.handle_401)
s_auth = r.headers.get('www-authenticate', '')
if 'digest' in s_auth.lower() and num_401_calls < 2:
self.chal = par... | [
"def",
"handle_401",
"(",
"self",
",",
"r",
")",
":",
"num_401_calls",
"=",
"r",
".",
"request",
".",
"hooks",
"[",
"'response'",
"]",
".",
"count",
"(",
"self",
".",
"handle_401",
")",
"s_auth",
"=",
"r",
".",
"headers",
".",
"get",
"(",
"'www-authe... | https://github.com/hzlzh/AlfredWorkflow.com/blob/7055f14f6922c80ea5943839eb0caff11ae57255/Sources/Workflows/KindleBookstore/PyAl/Request/requests/auth.py#L229-L252 | |
ayoolaolafenwa/PixelLib | ae56003c416a98780141a1170c9d888fe9a31317 | pixellib/torchbackend/instance/utils/visualizer.py | python | Visualizer.draw_circle | (self, circle_coord, color, radius=3) | return self.output | Args:
circle_coord (list(int) or tuple(int)): contains the x and y coordinates
of the center of the circle.
color: color of the polygon. Refer to `matplotlib.colors` for a full list of
formats that are accepted.
radius (int): radius of the circle.
... | Args:
circle_coord (list(int) or tuple(int)): contains the x and y coordinates
of the center of the circle.
color: color of the polygon. Refer to `matplotlib.colors` for a full list of
formats that are accepted.
radius (int): radius of the circle. | [
"Args",
":",
"circle_coord",
"(",
"list",
"(",
"int",
")",
"or",
"tuple",
"(",
"int",
"))",
":",
"contains",
"the",
"x",
"and",
"y",
"coordinates",
"of",
"the",
"center",
"of",
"the",
"circle",
".",
"color",
":",
"color",
"of",
"the",
"polygon",
".",... | def draw_circle(self, circle_coord, color, radius=3):
"""
Args:
circle_coord (list(int) or tuple(int)): contains the x and y coordinates
of the center of the circle.
color: color of the polygon. Refer to `matplotlib.colors` for a full list of
forma... | [
"def",
"draw_circle",
"(",
"self",
",",
"circle_coord",
",",
"color",
",",
"radius",
"=",
"3",
")",
":",
"x",
",",
"y",
"=",
"circle_coord",
"self",
".",
"output",
".",
"ax",
".",
"add_patch",
"(",
"mpl",
".",
"patches",
".",
"Circle",
"(",
"circle_c... | https://github.com/ayoolaolafenwa/PixelLib/blob/ae56003c416a98780141a1170c9d888fe9a31317/pixellib/torchbackend/instance/utils/visualizer.py#L986-L1002 | |
joe42/CloudFusion | c4b94124e74a81e0634578c7754d62160081f7a1 | cloudfusion/store/transparent_store.py | python | TransparentStore.get_dirty_files | (self) | return [] | Get a list of file paths to files that are not already synchronized with the store | Get a list of file paths to files that are not already synchronized with the store | [
"Get",
"a",
"list",
"of",
"file",
"paths",
"to",
"files",
"that",
"are",
"not",
"already",
"synchronized",
"with",
"the",
"store"
] | def get_dirty_files(self):
"""Get a list of file paths to files that are not already synchronized with the store"""
return [] | [
"def",
"get_dirty_files",
"(",
"self",
")",
":",
"return",
"[",
"]"
] | https://github.com/joe42/CloudFusion/blob/c4b94124e74a81e0634578c7754d62160081f7a1/cloudfusion/store/transparent_store.py#L56-L58 | |
Sprytile/Sprytile | 6b68d0069aef5bfed6ab40d1d5a94a3382b41619 | rx/linq/observable/min.py | python | min | (self, comparer=None) | return self.min_by(identity, comparer).map(first_only) | Returns the minimum element in an observable sequence according to
the optional comparer else a default greater than less than check.
Example
res = source.min()
res = source.min(lambda x, y: x.value - y.value)
comparer -- {Function} [Optional] Comparer used to compare elements.
Returns an obs... | Returns the minimum element in an observable sequence according to
the optional comparer else a default greater than less than check. | [
"Returns",
"the",
"minimum",
"element",
"in",
"an",
"observable",
"sequence",
"according",
"to",
"the",
"optional",
"comparer",
"else",
"a",
"default",
"greater",
"than",
"less",
"than",
"check",
"."
] | def min(self, comparer=None):
"""Returns the minimum element in an observable sequence according to
the optional comparer else a default greater than less than check.
Example
res = source.min()
res = source.min(lambda x, y: x.value - y.value)
comparer -- {Function} [Optional] Comparer used to ... | [
"def",
"min",
"(",
"self",
",",
"comparer",
"=",
"None",
")",
":",
"return",
"self",
".",
"min_by",
"(",
"identity",
",",
"comparer",
")",
".",
"map",
"(",
"first_only",
")"
] | https://github.com/Sprytile/Sprytile/blob/6b68d0069aef5bfed6ab40d1d5a94a3382b41619/rx/linq/observable/min.py#L15-L29 | |
cortex-lab/phy | 9a330b9437a3d0b40a37a201d147224e6e7fb462 | phy/cluster/views/raster.py | python | RasterView.update_color | (self) | Update the color of the spikes, depending on the selected clusters. | Update the color of the spikes, depending on the selected clusters. | [
"Update",
"the",
"color",
"of",
"the",
"spikes",
"depending",
"on",
"the",
"selected",
"clusters",
"."
] | def update_color(self):
"""Update the color of the spikes, depending on the selected clusters."""
box_index = self._get_box_index()
color = self._get_color(box_index, selected_clusters=self.cluster_ids)
self.visual.set_color(color)
self.canvas.update() | [
"def",
"update_color",
"(",
"self",
")",
":",
"box_index",
"=",
"self",
".",
"_get_box_index",
"(",
")",
"color",
"=",
"self",
".",
"_get_color",
"(",
"box_index",
",",
"selected_clusters",
"=",
"self",
".",
"cluster_ids",
")",
"self",
".",
"visual",
".",
... | https://github.com/cortex-lab/phy/blob/9a330b9437a3d0b40a37a201d147224e6e7fb462/phy/cluster/views/raster.py#L142-L147 | ||
pyvista/pyvista | 012dbb95a9aae406c3cd4cd94fc8c477f871e426 | pyvista/utilities/parametric_objects.py | python | KochanekSpline | (points, tension=None, bias=None, continuity=None, n_points=None) | return spline.compute_arc_length() | Create a Kochanek spline from points.
Parameters
----------
points : sequence
Array of points to build a Kochanek spline out of. Array must
be 3D and directionally ordered.
tension : sequence, optional
Changes the length of the tangent vector. Defaults to ``[0.0,
0.0,... | Create a Kochanek spline from points. | [
"Create",
"a",
"Kochanek",
"spline",
"from",
"points",
"."
] | def KochanekSpline(points, tension=None, bias=None, continuity=None, n_points=None):
"""Create a Kochanek spline from points.
Parameters
----------
points : sequence
Array of points to build a Kochanek spline out of. Array must
be 3D and directionally ordered.
tension : sequence, ... | [
"def",
"KochanekSpline",
"(",
"points",
",",
"tension",
"=",
"None",
",",
"bias",
"=",
"None",
",",
"continuity",
"=",
"None",
",",
"n_points",
"=",
"None",
")",
":",
"if",
"tension",
"is",
"None",
":",
"tension",
"=",
"np",
".",
"array",
"(",
"[",
... | https://github.com/pyvista/pyvista/blob/012dbb95a9aae406c3cd4cd94fc8c477f871e426/pyvista/utilities/parametric_objects.py#L60-L155 | |
golismero/golismero | 7d605b937e241f51c1ca4f47b20f755eeefb9d76 | tools/sqlmap/lib/utils/hash.py | python | oracle_old_passwd | (password, username, uppercase=True) | return retVal.upper() if uppercase else retVal.lower() | Reference(s):
http://www.notesbit.com/index.php/scripts-oracle/oracle-11g-new-password-algorithm-is-revealed-by-seclistsorg/
>>> oracle_old_passwd(password='tiger', username='scott', uppercase=True)
'F894844C34402B67' | Reference(s):
http://www.notesbit.com/index.php/scripts-oracle/oracle-11g-new-password-algorithm-is-revealed-by-seclistsorg/ | [
"Reference",
"(",
"s",
")",
":",
"http",
":",
"//",
"www",
".",
"notesbit",
".",
"com",
"/",
"index",
".",
"php",
"/",
"scripts",
"-",
"oracle",
"/",
"oracle",
"-",
"11g",
"-",
"new",
"-",
"password",
"-",
"algorithm",
"-",
"is",
"-",
"revealed",
... | def oracle_old_passwd(password, username, uppercase=True): # prior to version '11g'
"""
Reference(s):
http://www.notesbit.com/index.php/scripts-oracle/oracle-11g-new-password-algorithm-is-revealed-by-seclistsorg/
>>> oracle_old_passwd(password='tiger', username='scott', uppercase=True)
'F89484... | [
"def",
"oracle_old_passwd",
"(",
"password",
",",
"username",
",",
"uppercase",
"=",
"True",
")",
":",
"# prior to version '11g'",
"IV",
",",
"pad",
"=",
"\"\\0\"",
"*",
"8",
",",
"\"\\0\"",
"if",
"isinstance",
"(",
"username",
",",
"unicode",
")",
":",
"u... | https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/tools/sqlmap/lib/utils/hash.py#L194-L217 | |
enthought/chaco | 0907d1dedd07a499202efbaf2fe2a4e51b4c8e5f | chaco/examples/demo/hyetograph.py | python | Hyetograph.calculate_intensity | (self) | The Hyetograph calculations. | The Hyetograph calculations. | [
"The",
"Hyetograph",
"calculations",
"."
] | def calculate_intensity(self):
""" The Hyetograph calculations. """
# Assigning A, B, and C values based on year, storm, and county
year = YEARS[self.year_storm]
value = COUNTIES[self.county]
a, b, c = year[value], year[value+1], year[value+2]
self.timeline = [i for i in... | [
"def",
"calculate_intensity",
"(",
"self",
")",
":",
"# Assigning A, B, and C values based on year, storm, and county",
"year",
"=",
"YEARS",
"[",
"self",
".",
"year_storm",
"]",
"value",
"=",
"COUNTIES",
"[",
"self",
".",
"county",
"]",
"a",
",",
"b",
",",
"c",... | https://github.com/enthought/chaco/blob/0907d1dedd07a499202efbaf2fe2a4e51b4c8e5f/chaco/examples/demo/hyetograph.py#L71-L101 | ||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/lxml-4.4.2-py3.7-macosx-10.9-x86_64.egg/lxml/html/__init__.py | python | HtmlMixin.drop_tree | (self) | Removes this element from the tree, including its children and
text. The tail text is joined to the previous element or
parent. | Removes this element from the tree, including its children and
text. The tail text is joined to the previous element or
parent. | [
"Removes",
"this",
"element",
"from",
"the",
"tree",
"including",
"its",
"children",
"and",
"text",
".",
"The",
"tail",
"text",
"is",
"joined",
"to",
"the",
"previous",
"element",
"or",
"parent",
"."
] | def drop_tree(self):
"""
Removes this element from the tree, including its children and
text. The tail text is joined to the previous element or
parent.
"""
parent = self.getparent()
assert parent is not None
if self.tail:
previous = self.getp... | [
"def",
"drop_tree",
"(",
"self",
")",
":",
"parent",
"=",
"self",
".",
"getparent",
"(",
")",
"assert",
"parent",
"is",
"not",
"None",
"if",
"self",
".",
"tail",
":",
"previous",
"=",
"self",
".",
"getprevious",
"(",
")",
"if",
"previous",
"is",
"Non... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/lxml-4.4.2-py3.7-macosx-10.9-x86_64.egg/lxml/html/__init__.py#L332-L346 | ||
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/mpmath/matrices/eigen.py | python | hessenberg_reduce_0 | (ctx, A, T) | This routine computes the (upper) Hessenberg decomposition of a square matrix A.
Given A, an unitary matrix Q is calculated such that
Q' A Q = H and Q' Q = Q Q' = 1
where H is an upper Hessenberg matrix, meaning that it only contains zeros
below the first subdiagona... | This routine computes the (upper) Hessenberg decomposition of a square matrix A.
Given A, an unitary matrix Q is calculated such that | [
"This",
"routine",
"computes",
"the",
"(",
"upper",
")",
"Hessenberg",
"decomposition",
"of",
"a",
"square",
"matrix",
"A",
".",
"Given",
"A",
"an",
"unitary",
"matrix",
"Q",
"is",
"calculated",
"such",
"that"
] | def hessenberg_reduce_0(ctx, A, T):
"""
This routine computes the (upper) Hessenberg decomposition of a square matrix A.
Given A, an unitary matrix Q is calculated such that
Q' A Q = H and Q' Q = Q Q' = 1
where H is an upper Hessenberg matrix, meaning that it on... | [
"def",
"hessenberg_reduce_0",
"(",
"ctx",
",",
"A",
",",
"T",
")",
":",
"# internally we work with householder reflections from the right.",
"# let u be a row vector (i.e. u[i]=A[i,:i]). then",
"# Q is build up by reflectors of the type (1-v'v) where v is a suitable",
"# modification of u.... | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/mpmath/matrices/eigen.py#L44-L145 | ||
dhtech/swboot | b741e8f90f3941a7619e12addf337bed1d299204 | http/server.py | python | HTTPServer.server_bind | (self) | Override server_bind to store the server name. | Override server_bind to store the server name. | [
"Override",
"server_bind",
"to",
"store",
"the",
"server",
"name",
"."
] | def server_bind(self):
"""Override server_bind to store the server name."""
socketserver.TCPServer.server_bind(self)
host, port = self.server_address[:2]
self.server_name = socket.getfqdn(host)
self.server_port = port | [
"def",
"server_bind",
"(",
"self",
")",
":",
"socketserver",
".",
"TCPServer",
".",
"server_bind",
"(",
"self",
")",
"host",
",",
"port",
"=",
"self",
".",
"server_address",
"[",
":",
"2",
"]",
"self",
".",
"server_name",
"=",
"socket",
".",
"getfqdn",
... | https://github.com/dhtech/swboot/blob/b741e8f90f3941a7619e12addf337bed1d299204/http/server.py#L135-L140 | ||
scikit-hep/scikit-hep | 506149b352eeb2291f24aef3f40691b5f6be2da7 | skhep/math/vectors.py | python | LorentzVector.copy | (self) | return LorentzVector(self[0], self[1], self[2], self[3]) | Get a copy of the LorentzVector.
Example
-------
>>> v = ...
>>> v1 = v.copy() | Get a copy of the LorentzVector. | [
"Get",
"a",
"copy",
"of",
"the",
"LorentzVector",
"."
] | def copy(self):
"""Get a copy of the LorentzVector.
Example
-------
>>> v = ...
>>> v1 = v.copy()
"""
return LorentzVector(self[0], self[1], self[2], self[3]) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"LorentzVector",
"(",
"self",
"[",
"0",
"]",
",",
"self",
"[",
"1",
"]",
",",
"self",
"[",
"2",
"]",
",",
"self",
"[",
"3",
"]",
")"
] | https://github.com/scikit-hep/scikit-hep/blob/506149b352eeb2291f24aef3f40691b5f6be2da7/skhep/math/vectors.py#L896-L904 | |
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/zwave/lock.py | python | get_device | (node, values, **kwargs) | return ZwaveLock(values) | Create Z-Wave entity device. | Create Z-Wave entity device. | [
"Create",
"Z",
"-",
"Wave",
"entity",
"device",
"."
] | def get_device(node, values, **kwargs):
"""Create Z-Wave entity device."""
return ZwaveLock(values) | [
"def",
"get_device",
"(",
"node",
",",
"values",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"ZwaveLock",
"(",
"values",
")"
] | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/zwave/lock.py#L247-L249 | |
wger-project/wger | 3a17a2cf133d242d1f8c357faa53cf675a7b3223 | wger/measurements/api/views.py | python | CategoryViewSet.perform_create | (self, serializer) | Set the owner | Set the owner | [
"Set",
"the",
"owner"
] | def perform_create(self, serializer):
"""
Set the owner
"""
serializer.save(user=self.request.user) | [
"def",
"perform_create",
"(",
"self",
",",
"serializer",
")",
":",
"serializer",
".",
"save",
"(",
"user",
"=",
"self",
".",
"request",
".",
"user",
")"
] | https://github.com/wger-project/wger/blob/3a17a2cf133d242d1f8c357faa53cf675a7b3223/wger/measurements/api/views.py#L56-L60 | ||
robotlearn/pyrobolearn | 9cd7c060723fda7d2779fa255ac998c2c82b8436 | pyrobolearn/simulators/raisim.py | python | Raisim.get_joint_state | (self, body_id, joint_id) | Get the joint state.
Args:
body_id (int): unique body id.
joint_id (int): joint index in range [0..num_joints(body_id)]
Returns:
float: The position value of this joint.
float: The velocity value of this joint.
np.array[float[6]]: These are t... | Get the joint state. | [
"Get",
"the",
"joint",
"state",
"."
] | def get_joint_state(self, body_id, joint_id):
"""
Get the joint state.
Args:
body_id (int): unique body id.
joint_id (int): joint index in range [0..num_joints(body_id)]
Returns:
float: The position value of this joint.
float: The velocit... | [
"def",
"get_joint_state",
"(",
"self",
",",
"body_id",
",",
"joint_id",
")",
":",
"pass"
] | https://github.com/robotlearn/pyrobolearn/blob/9cd7c060723fda7d2779fa255ac998c2c82b8436/pyrobolearn/simulators/raisim.py#L1306-L1323 | ||
Urinx/WeixinBot | d9edcd2c9203fe7dd203b22b71bbc48a31e9492b | wxbot_project_py2.7/db/mysql_db.py | python | MysqlDB.close | (self) | @brief close connection to database | [] | def close(self):
"""
@brief close connection to database
"""
Log.debug('DB -> close')
# 关闭数据库连接
self.conn.close() | [
"def",
"close",
"(",
"self",
")",
":",
"Log",
".",
"debug",
"(",
"'DB -> close'",
")",
"# 关闭数据库连接",
"self",
".",
"conn",
".",
"close",
"(",
")"
] | https://github.com/Urinx/WeixinBot/blob/d9edcd2c9203fe7dd203b22b71bbc48a31e9492b/wxbot_project_py2.7/db/mysql_db.py#L192-L198 | |||
linxid/Machine_Learning_Study_Path | 558e82d13237114bbb8152483977806fc0c222af | Machine Learning In Action/Chapter8-Regression/venv/Lib/site-packages/pip-9.0.1-py3.6.egg/pip/_vendor/html5lib/treewalkers/base.py | python | TreeWalker.entity | (self, name) | return {"type": "Entity", "name": name} | [] | def entity(self, name):
return {"type": "Entity", "name": name} | [
"def",
"entity",
"(",
"self",
",",
"name",
")",
":",
"return",
"{",
"\"type\"",
":",
"\"Entity\"",
",",
"\"name\"",
":",
"name",
"}"
] | https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter8-Regression/venv/Lib/site-packages/pip-9.0.1-py3.6.egg/pip/_vendor/html5lib/treewalkers/base.py#L71-L72 | |||
onnx/onnx-coreml | 141fc33d7217674ea8bda36494fa8089a543a3f3 | onnx_coreml/_operators.py | python | _is_input_shape_mapping_defined | (node, graph) | [] | def _is_input_shape_mapping_defined(node, graph): # type: (Node, Graph) -> Bool
if node.inputs[0] in graph.onnx_coreml_shape_mapping:
return True
else:
return False | [
"def",
"_is_input_shape_mapping_defined",
"(",
"node",
",",
"graph",
")",
":",
"# type: (Node, Graph) -> Bool",
"if",
"node",
".",
"inputs",
"[",
"0",
"]",
"in",
"graph",
".",
"onnx_coreml_shape_mapping",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | https://github.com/onnx/onnx-coreml/blob/141fc33d7217674ea8bda36494fa8089a543a3f3/onnx_coreml/_operators.py#L28-L32 | ||||
aws-samples/aws-kube-codesuite | ab4e5ce45416b83bffb947ab8d234df5437f4fca | src/networkx/algorithms/coloring/greedy_coloring.py | python | strategy_random_sequential | (G, colors) | return nodes | Returns a random permutation of the nodes of ``G`` as a list.
``G`` is a NetworkX graph. ``colors`` is ignored. | Returns a random permutation of the nodes of ``G`` as a list. | [
"Returns",
"a",
"random",
"permutation",
"of",
"the",
"nodes",
"of",
"G",
"as",
"a",
"list",
"."
] | def strategy_random_sequential(G, colors):
"""Returns a random permutation of the nodes of ``G`` as a list.
``G`` is a NetworkX graph. ``colors`` is ignored.
"""
nodes = list(G)
random.shuffle(nodes)
return nodes | [
"def",
"strategy_random_sequential",
"(",
"G",
",",
"colors",
")",
":",
"nodes",
"=",
"list",
"(",
"G",
")",
"random",
".",
"shuffle",
"(",
"nodes",
")",
"return",
"nodes"
] | https://github.com/aws-samples/aws-kube-codesuite/blob/ab4e5ce45416b83bffb947ab8d234df5437f4fca/src/networkx/algorithms/coloring/greedy_coloring.py#L37-L45 | |
voxpupuli/puppetboard | f3d38384cd0cd940c22bc7661e98a7f56304ea2a | puppetboard/app.py | python | metric | (env, metric) | return render_template(
'metric.html',
name=name,
metric=sorted(metric.items()),
envs=envs,
current_env=env) | Lists all information about the metric of the given name.
:param env: While this parameter serves no function purpose it is required
for the environments template block
:type env: :obj:`string` | Lists all information about the metric of the given name. | [
"Lists",
"all",
"information",
"about",
"the",
"metric",
"of",
"the",
"given",
"name",
"."
] | def metric(env, metric):
"""Lists all information about the metric of the given name.
:param env: While this parameter serves no function purpose it is required
for the environments template block
:type env: :obj:`string`
"""
envs = environments()
check_env(env, envs)
db_version = ... | [
"def",
"metric",
"(",
"env",
",",
"metric",
")",
":",
"envs",
"=",
"environments",
"(",
")",
"check_env",
"(",
"env",
",",
"envs",
")",
"db_version",
"=",
"get_db_version",
"(",
"puppetdb",
")",
"query_type",
",",
"metric_version",
"=",
"metric_params",
"(... | https://github.com/voxpupuli/puppetboard/blob/f3d38384cd0cd940c22bc7661e98a7f56304ea2a/puppetboard/app.py#L946-L966 | |
giampaolo/psutil | 55161bd4850986359a029f1c9a81bcf66f37afa8 | psutil/_pslinux.py | python | cpu_count_logical | () | Return the number of logical CPUs in the system. | Return the number of logical CPUs in the system. | [
"Return",
"the",
"number",
"of",
"logical",
"CPUs",
"in",
"the",
"system",
"."
] | def cpu_count_logical():
"""Return the number of logical CPUs in the system."""
try:
return os.sysconf("SC_NPROCESSORS_ONLN")
except ValueError:
# as a second fallback we try to parse /proc/cpuinfo
num = 0
with open_binary('%s/cpuinfo' % get_procfs_path()) as f:
f... | [
"def",
"cpu_count_logical",
"(",
")",
":",
"try",
":",
"return",
"os",
".",
"sysconf",
"(",
"\"SC_NPROCESSORS_ONLN\"",
")",
"except",
"ValueError",
":",
"# as a second fallback we try to parse /proc/cpuinfo",
"num",
"=",
"0",
"with",
"open_binary",
"(",
"'%s/cpuinfo'"... | https://github.com/giampaolo/psutil/blob/55161bd4850986359a029f1c9a81bcf66f37afa8/psutil/_pslinux.py#L612-L638 | ||
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | Python-2.7.13/Lib/rfc822.py | python | dump_address_pair | (pair) | Dump a (name, address) pair in a canonicalized form. | Dump a (name, address) pair in a canonicalized form. | [
"Dump",
"a",
"(",
"name",
"address",
")",
"pair",
"in",
"a",
"canonicalized",
"form",
"."
] | def dump_address_pair(pair):
"""Dump a (name, address) pair in a canonicalized form."""
if pair[0]:
return '"' + pair[0] + '" <' + pair[1] + '>'
else:
return pair[1] | [
"def",
"dump_address_pair",
"(",
"pair",
")",
":",
"if",
"pair",
"[",
"0",
"]",
":",
"return",
"'\"'",
"+",
"pair",
"[",
"0",
"]",
"+",
"'\" <'",
"+",
"pair",
"[",
"1",
"]",
"+",
"'>'",
"else",
":",
"return",
"pair",
"[",
"1",
"]"
] | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/rfc822.py#L825-L830 | ||
GoogleCloudPlatform/PerfKitBenchmarker | 6e3412d7d5e414b8ca30ed5eaf970cef1d919a67 | perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | python | RackspaceVirtualMachine._FindBootBlockDevice | (self, blk_devices, boot_blk_device) | Helper method to search for backing block device of a partition. | Helper method to search for backing block device of a partition. | [
"Helper",
"method",
"to",
"search",
"for",
"backing",
"block",
"device",
"of",
"a",
"partition",
"."
] | def _FindBootBlockDevice(self, blk_devices, boot_blk_device):
"""Helper method to search for backing block device of a partition."""
blk_device_name = boot_blk_device['name'].rstrip('0123456789')
for dev in blk_devices:
if dev['type'] == 'disk' and dev['name'] == blk_device_name:
boot_blk_devi... | [
"def",
"_FindBootBlockDevice",
"(",
"self",
",",
"blk_devices",
",",
"boot_blk_device",
")",
":",
"blk_device_name",
"=",
"boot_blk_device",
"[",
"'name'",
"]",
".",
"rstrip",
"(",
"'0123456789'",
")",
"for",
"dev",
"in",
"blk_devices",
":",
"if",
"dev",
"[",
... | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/6e3412d7d5e414b8ca30ed5eaf970cef1d919a67/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py#L502-L508 | ||
IronLanguages/ironpython2 | 51fdedeeda15727717fb8268a805f71b06c0b9f1 | Src/StdLib/Lib/chunk.py | python | Chunk.getsize | (self) | return self.chunksize | Return the size of the current chunk. | Return the size of the current chunk. | [
"Return",
"the",
"size",
"of",
"the",
"current",
"chunk",
"."
] | def getsize(self):
"""Return the size of the current chunk."""
return self.chunksize | [
"def",
"getsize",
"(",
"self",
")",
":",
"return",
"self",
".",
"chunksize"
] | https://github.com/IronLanguages/ironpython2/blob/51fdedeeda15727717fb8268a805f71b06c0b9f1/Src/StdLib/Lib/chunk.py#L82-L84 | |
binaryage/drydrop | 2f27e15befd247255d89f9120eeee44851b82c4a | dryapp/drydrop/app/core/controller.py | python | AbstractController.redirect_to | (self, url) | Redirects to a specified url | Redirects to a specified url | [
"Redirects",
"to",
"a",
"specified",
"url"
] | def redirect_to(self, url):
"""Redirects to a specified url"""
# self.handler.redirect(url)
# self.emited = True
# raise PageRedirect, (url)
# mrizka delala problemy pri claimovani openid
m = re.match(r'^(.*)#.*?$', url)
if m: url = m.group(1)
... | [
"def",
"redirect_to",
"(",
"self",
",",
"url",
")",
":",
"# self.handler.redirect(url)",
"# self.emited = True",
"# raise PageRedirect, (url)",
"# mrizka delala problemy pri claimovani openid",
"m",
"=",
"re",
".",
"match",
"(",
"r'^(.*)#.*?$'",
",",
"url",
")",
"if",
"... | https://github.com/binaryage/drydrop/blob/2f27e15befd247255d89f9120eeee44851b82c4a/dryapp/drydrop/app/core/controller.py#L81-L96 | ||
nvbn/py-backwards | fd2d89ad972148024ee667eff5b9f19ac91d98ad | py_backwards/conf.py | python | init_settings | (args: Namespace) | [] | def init_settings(args: Namespace) -> None:
if args.debug:
settings.debug = True | [
"def",
"init_settings",
"(",
"args",
":",
"Namespace",
")",
"->",
"None",
":",
"if",
"args",
".",
"debug",
":",
"settings",
".",
"debug",
"=",
"True"
] | https://github.com/nvbn/py-backwards/blob/fd2d89ad972148024ee667eff5b9f19ac91d98ad/py_backwards/conf.py#L12-L14 | ||||
luyanger1799/Amazing-Semantic-Segmentation | 686ff29b1c97f93bc20e3bd8e8cb0e72a730de82 | models/fcn.py | python | FCN.__init__ | (self, num_classes, version='FCN-8s', base_model='VGG16', **kwargs) | The initialization of FCN-8s/16s/32s.
:param num_classes: the number of predicted classes.
:param version: 'FCN-8s', 'FCN-16s' or 'FCN-32s'.
:param base_model: the backbone model
:param kwargs: other parameters | The initialization of FCN-8s/16s/32s.
:param num_classes: the number of predicted classes.
:param version: 'FCN-8s', 'FCN-16s' or 'FCN-32s'.
:param base_model: the backbone model
:param kwargs: other parameters | [
"The",
"initialization",
"of",
"FCN",
"-",
"8s",
"/",
"16s",
"/",
"32s",
".",
":",
"param",
"num_classes",
":",
"the",
"number",
"of",
"predicted",
"classes",
".",
":",
"param",
"version",
":",
"FCN",
"-",
"8s",
"FCN",
"-",
"16s",
"or",
"FCN",
"-",
... | def __init__(self, num_classes, version='FCN-8s', base_model='VGG16', **kwargs):
"""
The initialization of FCN-8s/16s/32s.
:param num_classes: the number of predicted classes.
:param version: 'FCN-8s', 'FCN-16s' or 'FCN-32s'.
:param base_model: the backbone model
:param k... | [
"def",
"__init__",
"(",
"self",
",",
"num_classes",
",",
"version",
"=",
"'FCN-8s'",
",",
"base_model",
"=",
"'VGG16'",
",",
"*",
"*",
"kwargs",
")",
":",
"fcn",
"=",
"{",
"'FCN-8s'",
":",
"self",
".",
"_fcn_8s",
",",
"'FCN-16s'",
":",
"self",
".",
"... | https://github.com/luyanger1799/Amazing-Semantic-Segmentation/blob/686ff29b1c97f93bc20e3bd8e8cb0e72a730de82/models/fcn.py#L18-L33 | ||
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit - MAC OSX/scripts/nextpenbox.py | python | doork | () | [] | def doork():
print("doork is a open-source passive vulnerability auditor tool that automates the process of searching on Google information about specific website based on dorks. ")
doorkchice = raw_input("Continue Y / N: ")
if doorkchice in yes:
os.system("pip install beautifulsoup4 && pip install ... | [
"def",
"doork",
"(",
")",
":",
"print",
"(",
"\"doork is a open-source passive vulnerability auditor tool that automates the process of searching on Google information about specific website based on dorks. \"",
")",
"doorkchice",
"=",
"raw_input",
"(",
"\"Continue Y / N: \"",
")",
"if... | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit - MAC OSX/scripts/nextpenbox.py#L153-L161 | ||||
QUVA-Lab/artemis | 84d3b1daf0de363cc823d99f978e2861ed400b5b | artemis/general/display.py | python | truncate_string | (string, truncation, message = '') | Truncate a string to a given length. Optionally add a message at the end
explaining the truncation
:param string: A string
:param truncation: An int
:param message: A message, e.g. '...<truncated>'
:return: A new string no longer than truncation | Truncate a string to a given length. Optionally add a message at the end
explaining the truncation
:param string: A string
:param truncation: An int
:param message: A message, e.g. '...<truncated>'
:return: A new string no longer than truncation | [
"Truncate",
"a",
"string",
"to",
"a",
"given",
"length",
".",
"Optionally",
"add",
"a",
"message",
"at",
"the",
"end",
"explaining",
"the",
"truncation",
":",
"param",
"string",
":",
"A",
"string",
":",
"param",
"truncation",
":",
"An",
"int",
":",
"para... | def truncate_string(string, truncation, message = ''):
"""
Truncate a string to a given length. Optionally add a message at the end
explaining the truncation
:param string: A string
:param truncation: An int
:param message: A message, e.g. '...<truncated>'
:return: A new string no longer th... | [
"def",
"truncate_string",
"(",
"string",
",",
"truncation",
",",
"message",
"=",
"''",
")",
":",
"if",
"truncation",
"is",
"None",
":",
"return",
"string",
"assert",
"isinstance",
"(",
"truncation",
",",
"int",
")",
"if",
"len",
"(",
"string",
")",
">",
... | https://github.com/QUVA-Lab/artemis/blob/84d3b1daf0de363cc823d99f978e2861ed400b5b/artemis/general/display.py#L320-L335 | ||
mesalock-linux/mesapy | ed546d59a21b36feb93e2309d5c6b75aa0ad95c9 | lib_pypy/datetime.py | python | date.ctime | (self) | return "%s %s %2d 00:00:00 %04d" % (
_DAYNAMES[weekday],
_MONTHNAMES[self._month],
self._day, self._year) | Return ctime() style string. | Return ctime() style string. | [
"Return",
"ctime",
"()",
"style",
"string",
"."
] | def ctime(self):
"Return ctime() style string."
weekday = self.toordinal() % 7 or 7
return "%s %s %2d 00:00:00 %04d" % (
_DAYNAMES[weekday],
_MONTHNAMES[self._month],
self._day, self._year) | [
"def",
"ctime",
"(",
"self",
")",
":",
"weekday",
"=",
"self",
".",
"toordinal",
"(",
")",
"%",
"7",
"or",
"7",
"return",
"\"%s %s %2d 00:00:00 %04d\"",
"%",
"(",
"_DAYNAMES",
"[",
"weekday",
"]",
",",
"_MONTHNAMES",
"[",
"self",
".",
"_month",
"]",
",... | https://github.com/mesalock-linux/mesapy/blob/ed546d59a21b36feb93e2309d5c6b75aa0ad95c9/lib_pypy/datetime.py#L773-L779 | |
Teichlab/cellphonedb | dca1c26555b012df30af0f2521cd4df317cf4600 | cellphonedb/src/app/app_config.py | python | AppConfig._merge_configs | (self, config_base, new_config) | return config | [] | def _merge_configs(self, config_base, new_config):
config = {**config_base, **new_config}
for key in config_base:
if isinstance(config_base[key], dict) and key in new_config:
config[key] = self._merge_configs(config_base[key], new_config[key])
return config | [
"def",
"_merge_configs",
"(",
"self",
",",
"config_base",
",",
"new_config",
")",
":",
"config",
"=",
"{",
"*",
"*",
"config_base",
",",
"*",
"*",
"new_config",
"}",
"for",
"key",
"in",
"config_base",
":",
"if",
"isinstance",
"(",
"config_base",
"[",
"ke... | https://github.com/Teichlab/cellphonedb/blob/dca1c26555b012df30af0f2521cd4df317cf4600/cellphonedb/src/app/app_config.py#L92-L98 | |||
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/Ubuntu_13/rsa/cli.py | python | EncryptBigfileOperation.perform_operation | (self, infile, outfile, pub_key, cli_args=None) | return rsa.bigfile.encrypt_bigfile(infile, outfile, pub_key) | Encrypts files to VARBLOCK. | Encrypts files to VARBLOCK. | [
"Encrypts",
"files",
"to",
"VARBLOCK",
"."
] | def perform_operation(self, infile, outfile, pub_key, cli_args=None):
'''Encrypts files to VARBLOCK.'''
return rsa.bigfile.encrypt_bigfile(infile, outfile, pub_key) | [
"def",
"perform_operation",
"(",
"self",
",",
"infile",
",",
"outfile",
",",
"pub_key",
",",
"cli_args",
"=",
"None",
")",
":",
"return",
"rsa",
".",
"bigfile",
".",
"encrypt_bigfile",
"(",
"infile",
",",
"outfile",
",",
"pub_key",
")"
] | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Ubuntu_13/rsa/cli.py#L351-L354 | |
tensorflow/lattice | 784eca50cbdfedf39f183cc7d298c9fe376b69c0 | tensorflow_lattice/python/lattice_layer.py | python | LaplacianRegularizer.__init__ | (self, lattice_sizes, l1=0.0, l2=0.0) | Initializes an instance of `LaplacianRegularizer`.
Args:
lattice_sizes: Lattice sizes of `tfl.layers.Lattice` to regularize.
l1: l1 regularization amount. Either single float or list or tuple of
floats to specify different regularization amount per dimension.
l2: l2 regularization amount.... | Initializes an instance of `LaplacianRegularizer`. | [
"Initializes",
"an",
"instance",
"of",
"LaplacianRegularizer",
"."
] | def __init__(self, lattice_sizes, l1=0.0, l2=0.0):
"""Initializes an instance of `LaplacianRegularizer`.
Args:
lattice_sizes: Lattice sizes of `tfl.layers.Lattice` to regularize.
l1: l1 regularization amount. Either single float or list or tuple of
floats to specify different regularization... | [
"def",
"__init__",
"(",
"self",
",",
"lattice_sizes",
",",
"l1",
"=",
"0.0",
",",
"l2",
"=",
"0.0",
")",
":",
"lattice_lib",
".",
"verify_hyperparameters",
"(",
"lattice_sizes",
"=",
"lattice_sizes",
",",
"regularization_amount",
"=",
"l1",
",",
"regularizatio... | https://github.com/tensorflow/lattice/blob/784eca50cbdfedf39f183cc7d298c9fe376b69c0/tensorflow_lattice/python/lattice_layer.py#L1026-L1049 | ||
metabrainz/picard | 535bf8c7d9363ffc7abb3f69418ec11823c38118 | picard/util/bitreader.py | python | LSBBitReader._lsb | (self, count) | return value | [] | def _lsb(self, count):
value = self._buffer & 0xff >> (8 - count)
self._buffer = self._buffer >> count
self._bits -= count
return value | [
"def",
"_lsb",
"(",
"self",
",",
"count",
")",
":",
"value",
"=",
"self",
".",
"_buffer",
"&",
"0xff",
">>",
"(",
"8",
"-",
"count",
")",
"self",
".",
"_buffer",
"=",
"self",
".",
"_buffer",
">>",
"count",
"self",
".",
"_bits",
"-=",
"count",
"re... | https://github.com/metabrainz/picard/blob/535bf8c7d9363ffc7abb3f69418ec11823c38118/picard/util/bitreader.py#L135-L139 | |||
pyqt/examples | 843bb982917cecb2350b5f6d7f42c9b7fb142ec1 | src/pyqt-official/qml/referenceexamples/default.py | python | BirthdayParty.host | (self, host) | [] | def host(self, host):
self._host = host | [
"def",
"host",
"(",
"self",
",",
"host",
")",
":",
"self",
".",
"_host",
"=",
"host"
] | https://github.com/pyqt/examples/blob/843bb982917cecb2350b5f6d7f42c9b7fb142ec1/src/pyqt-official/qml/referenceexamples/default.py#L115-L116 | ||||
i3visio/osrframework | e02a6e9b1346ab5a01244c0d19bcec8232bf1a37 | osrframework/utils/general.py | python | osrf_to_png_export | (d, file_path) | Workaround to export to a png file.
Args:
d: Data to export.
file_path: File path for the output file. | Workaround to export to a png file. | [
"Workaround",
"to",
"export",
"to",
"a",
"png",
"file",
"."
] | def osrf_to_png_export(d, file_path):
"""Workaround to export to a png file.
Args:
d: Data to export.
file_path: File path for the output file.
"""
newGraph = _generate_graph_data(d)
import matplotlib.pyplot as plt
# Writing the png file
nx.draw(newGraph)
plt.savefig(fi... | [
"def",
"osrf_to_png_export",
"(",
"d",
",",
"file_path",
")",
":",
"newGraph",
"=",
"_generate_graph_data",
"(",
"d",
")",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"# Writing the png file",
"nx",
".",
"draw",
"(",
"newGraph",
")",
"plt",
".",
"sav... | https://github.com/i3visio/osrframework/blob/e02a6e9b1346ab5a01244c0d19bcec8232bf1a37/osrframework/utils/general.py#L587-L599 | ||
Pagure/pagure | 512f23f5cd1f965276969747792edeb1215cba68 | pagure/lib/git.py | python | _create_project_repo | (project, region, templ, ignore_existing, repotype) | Creates a single specific git repository on disk or repoSpanner
Args:
project (Project): Project to create repos for
region (string or None): repoSpanner region to create the repos in
templ (string): Template directory, only valid for non-repoSpanner
ignore_existing (bool): Whether ... | Creates a single specific git repository on disk or repoSpanner | [
"Creates",
"a",
"single",
"specific",
"git",
"repository",
"on",
"disk",
"or",
"repoSpanner"
] | def _create_project_repo(project, region, templ, ignore_existing, repotype):
"""Creates a single specific git repository on disk or repoSpanner
Args:
project (Project): Project to create repos for
region (string or None): repoSpanner region to create the repos in
templ (string): Templat... | [
"def",
"_create_project_repo",
"(",
"project",
",",
"region",
",",
"templ",
",",
"ignore_existing",
",",
"repotype",
")",
":",
"if",
"region",
":",
"# repoSpanner creation",
"regioninfo",
"=",
"pagure_config",
"[",
"\"REPOSPANNER_REGIONS\"",
"]",
"[",
"region",
"]... | https://github.com/Pagure/pagure/blob/512f23f5cd1f965276969747792edeb1215cba68/pagure/lib/git.py#L2819-L2893 | ||
naftaliharris/tauthon | 5587ceec329b75f7caf6d65a036db61ac1bae214 | Lib/copy_reg.py | python | _slotnames | (cls) | return names | Return a list of slot names for a given class.
This needs to find slots defined by the class and its bases, so we
can't simply return the __slots__ attribute. We must walk down
the Method Resolution Order and concatenate the __slots__ of each
class found there. (This assumes classes don't modify thei... | Return a list of slot names for a given class. | [
"Return",
"a",
"list",
"of",
"slot",
"names",
"for",
"a",
"given",
"class",
"."
] | def _slotnames(cls):
"""Return a list of slot names for a given class.
This needs to find slots defined by the class and its bases, so we
can't simply return the __slots__ attribute. We must walk down
the Method Resolution Order and concatenate the __slots__ of each
class found there. (This assum... | [
"def",
"_slotnames",
"(",
"cls",
")",
":",
"# Get the value from a cache in the class if possible",
"names",
"=",
"cls",
".",
"__dict__",
".",
"get",
"(",
"\"__slotnames__\"",
")",
"if",
"names",
"is",
"not",
"None",
":",
"return",
"names",
"# Not cached -- calculat... | https://github.com/naftaliharris/tauthon/blob/5587ceec329b75f7caf6d65a036db61ac1bae214/Lib/copy_reg.py#L95-L144 | |
braincorp/PVM | 3de2683634f372d2ac5aaa8b19e8ff23420d94d1 | PVM_models/demo04_run.py | python | Manager.running | (self) | return self._running | While returning True the simulation will keep going. | While returning True the simulation will keep going. | [
"While",
"returning",
"True",
"the",
"simulation",
"will",
"keep",
"going",
"."
] | def running(self):
"""
While returning True the simulation will keep going.
"""
return self._running | [
"def",
"running",
"(",
"self",
")",
":",
"return",
"self",
".",
"_running"
] | https://github.com/braincorp/PVM/blob/3de2683634f372d2ac5aaa8b19e8ff23420d94d1/PVM_models/demo04_run.py#L104-L108 | |
nameko/nameko | 17ecee2bcfa90cb0f3a2f3328c5004f48e4e02a3 | nameko/messaging.py | python | QueueConsumer.start | (self) | [] | def start(self):
if not self._starting:
self._starting = True
_log.debug('starting %s', self)
self._gt = self.container.spawn_managed_thread(self.run)
self._gt.link(self._handle_thread_exited)
try:
_log.debug('waiting for consumer ready %s', s... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_starting",
":",
"self",
".",
"_starting",
"=",
"True",
"_log",
".",
"debug",
"(",
"'starting %s'",
",",
"self",
")",
"self",
".",
"_gt",
"=",
"self",
".",
"container",
".",
"spawn_man... | https://github.com/nameko/nameko/blob/17ecee2bcfa90cb0f3a2f3328c5004f48e4e02a3/nameko/messaging.py#L224-L239 | ||||
TheHive-Project/Cortex-Analyzers | 2a16d0ed86af13c318d488f5ad994ef43940e6ba | analyzers/MISP/mispclient.py | python | MISPClient.__mispdomaintypes | () | return ['domain', 'hostname', 'domain|ip', 'email-src', 'email-dst', 'url', 'link', 'named pipe',
'target-email', 'uri', 'whois-registrant-email', 'dns-soa-email', 'hostname|port', 'jabber-id'] | Just for better readability, all __misp*type methods return just a list of misp data types
:returns: data types containing domains
:rtype: list | Just for better readability, all __misp*type methods return just a list of misp data types | [
"Just",
"for",
"better",
"readability",
"all",
"__misp",
"*",
"type",
"methods",
"return",
"just",
"a",
"list",
"of",
"misp",
"data",
"types"
] | def __mispdomaintypes():
"""Just for better readability, all __misp*type methods return just a list of misp data types
:returns: data types containing domains
:rtype: list
"""
return ['domain', 'hostname', 'domain|ip', 'email-src', 'email-dst', 'url', 'link', 'named pipe',
... | [
"def",
"__mispdomaintypes",
"(",
")",
":",
"return",
"[",
"'domain'",
",",
"'hostname'",
",",
"'domain|ip'",
",",
"'email-src'",
",",
"'email-dst'",
",",
"'url'",
",",
"'link'",
",",
"'named pipe'",
",",
"'target-email'",
",",
"'uri'",
",",
"'whois-registrant-em... | https://github.com/TheHive-Project/Cortex-Analyzers/blob/2a16d0ed86af13c318d488f5ad994ef43940e6ba/analyzers/MISP/mispclient.py#L101-L108 | |
aneisch/home-assistant-config | 86e381fde9609cb8871c439c433c12989e4e225d | custom_components/localtuya/pytuya/__init__.py | python | ContextualLogger.error | (self, msg, *args) | return self._logger.log(logging.ERROR, msg, *args) | Error level log. | Error level log. | [
"Error",
"level",
"log",
"."
] | def error(self, msg, *args):
"""Error level log."""
return self._logger.log(logging.ERROR, msg, *args) | [
"def",
"error",
"(",
"self",
",",
"msg",
",",
"*",
"args",
")",
":",
"return",
"self",
".",
"_logger",
".",
"log",
"(",
"logging",
".",
"ERROR",
",",
"msg",
",",
"*",
"args",
")"
] | https://github.com/aneisch/home-assistant-config/blob/86e381fde9609cb8871c439c433c12989e4e225d/custom_components/localtuya/pytuya/__init__.py#L141-L143 | |
microsoft/debugpy | be8dd607f6837244e0b565345e497aff7a0c08bf | src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/thread.py | python | _ThreadContainer.__add_created_thread | (self, event) | Private method to automatically add new thread objects from debug events.
@type event: L{Event}
@param event: Event object. | Private method to automatically add new thread objects from debug events. | [
"Private",
"method",
"to",
"automatically",
"add",
"new",
"thread",
"objects",
"from",
"debug",
"events",
"."
] | def __add_created_thread(self, event):
"""
Private method to automatically add new thread objects from debug events.
@type event: L{Event}
@param event: Event object.
"""
dwThreadId = event.get_tid()
hThread = event.get_thread_handle()
## if not self... | [
"def",
"__add_created_thread",
"(",
"self",
",",
"event",
")",
":",
"dwThreadId",
"=",
"event",
".",
"get_tid",
"(",
")",
"hThread",
"=",
"event",
".",
"get_thread_handle",
"(",
")",
"## if not self.has_thread(dwThreadId): # XXX this would trigger a scan",
"if"... | https://github.com/microsoft/debugpy/blob/be8dd607f6837244e0b565345e497aff7a0c08bf/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/thread.py#L2057-L2072 | ||
hyperledger/sawtooth-core | 704cd5837c21f53642c06ffc97ba7978a77940b0 | validator/sawtooth_validator/state/identity_view.py | python | IdentityView.get_policies | (self) | return sorted(policies, key=lambda p: p.name) | Returns all the Policies under the Identity namespace.
Returns:
(list): A list containing all the Policies under the Identity
namespace. | Returns all the Policies under the Identity namespace. | [
"Returns",
"all",
"the",
"Policies",
"under",
"the",
"Identity",
"namespace",
"."
] | def get_policies(self):
"""Returns all the Policies under the Identity namespace.
Returns:
(list): A list containing all the Policies under the Identity
namespace.
"""
prefix = _IDENTITY_NS + _POLICY_NS
policylist_list = [
_create_from_by... | [
"def",
"get_policies",
"(",
"self",
")",
":",
"prefix",
"=",
"_IDENTITY_NS",
"+",
"_POLICY_NS",
"policylist_list",
"=",
"[",
"_create_from_bytes",
"(",
"d",
",",
"identity_pb2",
".",
"PolicyList",
")",
"for",
"_",
",",
"d",
"in",
"self",
".",
"_state_view",
... | https://github.com/hyperledger/sawtooth-core/blob/704cd5837c21f53642c06ffc97ba7978a77940b0/validator/sawtooth_validator/state/identity_view.py#L156-L173 | |
jthsieh/DDPAE-video-prediction | 219e68301d24615410260c3d33c80ae74f6f2dc3 | utils/metrics.py | python | VelocityMetrics.update | (self, gt, pose, n_frames_input) | [] | def update(self, gt, pose, n_frames_input):
pred = utils.calculate_positions(pose.view(-1, pose.size(-1))).view_as(gt)
pred = utils.to_numpy(pred)
gt = utils.to_numpy(gt)
self.pred_positions.append(pred)
self.gt_positions.append(gt)
self.calculate_metrics(pred, gt, n_frames_input) | [
"def",
"update",
"(",
"self",
",",
"gt",
",",
"pose",
",",
"n_frames_input",
")",
":",
"pred",
"=",
"utils",
".",
"calculate_positions",
"(",
"pose",
".",
"view",
"(",
"-",
"1",
",",
"pose",
".",
"size",
"(",
"-",
"1",
")",
")",
")",
".",
"view_a... | https://github.com/jthsieh/DDPAE-video-prediction/blob/219e68301d24615410260c3d33c80ae74f6f2dc3/utils/metrics.py#L64-L70 | ||||
O365/python-o365 | 7f77005c3cee8177d0141e79b8eda8a7b60c5124 | O365/excel.py | python | WorkBook.get_worksheet | (self, id_or_name) | return self.worksheet_constructor(parent=self, **{self._cloud_data_key: response.json()}) | Gets a specific worksheet by id or name | Gets a specific worksheet by id or name | [
"Gets",
"a",
"specific",
"worksheet",
"by",
"id",
"or",
"name"
] | def get_worksheet(self, id_or_name):
""" Gets a specific worksheet by id or name """
url = self.build_url(self._endpoints.get('get_worksheet').format(id=quote(id_or_name)))
response = self.session.get(url)
if not response:
return None
return self.worksheet_constructor... | [
"def",
"get_worksheet",
"(",
"self",
",",
"id_or_name",
")",
":",
"url",
"=",
"self",
".",
"build_url",
"(",
"self",
".",
"_endpoints",
".",
"get",
"(",
"'get_worksheet'",
")",
".",
"format",
"(",
"id",
"=",
"quote",
"(",
"id_or_name",
")",
")",
")",
... | https://github.com/O365/python-o365/blob/7f77005c3cee8177d0141e79b8eda8a7b60c5124/O365/excel.py#L1835-L1841 | |
ethereum/research | f64776763a8687cbe220421e292e6e45db3d9172 | verkle_trie_pedersen/verkle_trie.py | python | check_verkle_proof | (trie, keys, values, proof, display_times=True) | return check_ipa_multiproof(Cs, indices, ys, [D_serialized, ipa_proof], display_times) | Checks Verkle tree proof according to
https://notes.ethereum.org/nrQqhVpQRi6acQckwm1Ryg?both | Checks Verkle tree proof according to
https://notes.ethereum.org/nrQqhVpQRi6acQckwm1Ryg?both | [
"Checks",
"Verkle",
"tree",
"proof",
"according",
"to",
"https",
":",
"//",
"notes",
".",
"ethereum",
".",
"org",
"/",
"nrQqhVpQRi6acQckwm1Ryg?both"
] | def check_verkle_proof(trie, keys, values, proof, display_times=True):
"""
Checks Verkle tree proof according to
https://notes.ethereum.org/nrQqhVpQRi6acQckwm1Ryg?both
"""
start_logging_time_if_eligible(" Starting proof check", display_times)
# Unpack the proof
depths, commitments_sorted... | [
"def",
"check_verkle_proof",
"(",
"trie",
",",
"keys",
",",
"values",
",",
"proof",
",",
"display_times",
"=",
"True",
")",
":",
"start_logging_time_if_eligible",
"(",
"\" Starting proof check\"",
",",
"display_times",
")",
"# Unpack the proof",
"depths",
",",
"co... | https://github.com/ethereum/research/blob/f64776763a8687cbe220421e292e6e45db3d9172/verkle_trie_pedersen/verkle_trie.py#L504-L560 | |
cyberark/KubiScan | cb2afebde8080ad6de458f9e013003d9da10278e | api/api_client_temp.py | python | ApiClientTemp.__deserialize_file | (self, response) | return path | Saves response body into a file in a temporary folder,
using the filename from the `Content-Disposition` header if provided.
:param response: RESTResponse.
:return: file path. | Saves response body into a file in a temporary folder,
using the filename from the `Content-Disposition` header if provided. | [
"Saves",
"response",
"body",
"into",
"a",
"file",
"in",
"a",
"temporary",
"folder",
"using",
"the",
"filename",
"from",
"the",
"Content",
"-",
"Disposition",
"header",
"if",
"provided",
"."
] | def __deserialize_file(self, response):
"""
Saves response body into a file in a temporary folder,
using the filename from the `Content-Disposition` header if provided.
:param response: RESTResponse.
:return: file path.
"""
fd, path = tempfile.mkstemp(dir=self.c... | [
"def",
"__deserialize_file",
"(",
"self",
",",
"response",
")",
":",
"fd",
",",
"path",
"=",
"tempfile",
".",
"mkstemp",
"(",
"dir",
"=",
"self",
".",
"configuration",
".",
"temp_folder_path",
")",
"os",
".",
"close",
"(",
"fd",
")",
"os",
".",
"remove... | https://github.com/cyberark/KubiScan/blob/cb2afebde8080ad6de458f9e013003d9da10278e/api/api_client_temp.py#L517-L539 | |
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/fibaro/light.py | python | FibaroLight.async_update | (self) | Update the state. | Update the state. | [
"Update",
"the",
"state",
"."
] | async def async_update(self):
"""Update the state."""
async with self._update_lock:
await self.hass.async_add_executor_job(self._update) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"async",
"with",
"self",
".",
"_update_lock",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_update",
")"
] | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/fibaro/light.py#L201-L204 | ||
mdiazcl/fuzzbunch-debian | 2b76c2249ade83a389ae3badb12a1bd09901fd2c | windows/Resources/Python/Core/Lib/lib2to3/fixes/fix_metaclass.py | python | fixup_parse_tree | (cls_node) | one-line classes don't get a suite in the parse tree so we add
one to normalize the tree | one-line classes don't get a suite in the parse tree so we add
one to normalize the tree | [
"one",
"-",
"line",
"classes",
"don",
"t",
"get",
"a",
"suite",
"in",
"the",
"parse",
"tree",
"so",
"we",
"add",
"one",
"to",
"normalize",
"the",
"tree"
] | def fixup_parse_tree(cls_node):
""" one-line classes don't get a suite in the parse tree so we add
one to normalize the tree
"""
for node in cls_node.children:
if node.type == syms.suite:
return
for i, node in enumerate(cls_node.children):
if node.type == token.COLON... | [
"def",
"fixup_parse_tree",
"(",
"cls_node",
")",
":",
"for",
"node",
"in",
"cls_node",
".",
"children",
":",
"if",
"node",
".",
"type",
"==",
"syms",
".",
"suite",
":",
"return",
"for",
"i",
",",
"node",
"in",
"enumerate",
"(",
"cls_node",
".",
"childr... | https://github.com/mdiazcl/fuzzbunch-debian/blob/2b76c2249ade83a389ae3badb12a1bd09901fd2c/windows/Resources/Python/Core/Lib/lib2to3/fixes/fix_metaclass.py#L46-L67 | ||
lordmauve/pgzero | 46a889fb918ccd606d39ba63680386d7f8fcbc5a | pgzero/screen.py | python | SurfacePainter.filled_rect | (self, rect, color) | Draw a filled rectangle. | Draw a filled rectangle. | [
"Draw",
"a",
"filled",
"rectangle",
"."
] | def filled_rect(self, rect, color):
"""Draw a filled rectangle."""
if not isinstance(rect, RECT_CLASSES):
raise TypeError("screen.draw.filled_rect() requires a rect to draw")
pygame.draw.rect(self._surf, make_color(color), rect, 0) | [
"def",
"filled_rect",
"(",
"self",
",",
"rect",
",",
"color",
")",
":",
"if",
"not",
"isinstance",
"(",
"rect",
",",
"RECT_CLASSES",
")",
":",
"raise",
"TypeError",
"(",
"\"screen.draw.filled_rect() requires a rect to draw\"",
")",
"pygame",
".",
"draw",
".",
... | https://github.com/lordmauve/pgzero/blob/46a889fb918ccd606d39ba63680386d7f8fcbc5a/pgzero/screen.py#L99-L103 | ||
colour-science/colour | 38782ac059e8ddd91939f3432bf06811c16667f0 | colour/contrast/__init__.py | python | contrast_sensitivity_function | (method='Barten 1999', **kwargs) | return S | Returns the contrast sensitivity :math:`S` of the human eye according to
the contrast sensitivity function (CSF) described by given method.
Parameters
----------
method : str, optional
**{'Barten 1999'}**,
Computation method.
Other Parameters
----------------
E : numeric or... | Returns the contrast sensitivity :math:`S` of the human eye according to
the contrast sensitivity function (CSF) described by given method. | [
"Returns",
"the",
"contrast",
"sensitivity",
":",
"math",
":",
"S",
"of",
"the",
"human",
"eye",
"according",
"to",
"the",
"contrast",
"sensitivity",
"function",
"(",
"CSF",
")",
"described",
"by",
"given",
"method",
"."
] | def contrast_sensitivity_function(method='Barten 1999', **kwargs):
"""
Returns the contrast sensitivity :math:`S` of the human eye according to
the contrast sensitivity function (CSF) described by given method.
Parameters
----------
method : str, optional
**{'Barten 1999'}**,
Co... | [
"def",
"contrast_sensitivity_function",
"(",
"method",
"=",
"'Barten 1999'",
",",
"*",
"*",
"kwargs",
")",
":",
"method",
"=",
"validate_method",
"(",
"method",
",",
"CONTRAST_SENSITIVITY_METHODS",
")",
"function",
"=",
"CONTRAST_SENSITIVITY_METHODS",
"[",
"method",
... | https://github.com/colour-science/colour/blob/38782ac059e8ddd91939f3432bf06811c16667f0/colour/contrast/__init__.py#L60-L149 | |
urwid/urwid | e2423b5069f51d318ea1ac0f355a0efe5448f7eb | urwid/main_loop.py | python | SelectEventLoop.enter_idle | (self, callback) | return self._idle_handle | Add a callback for entering idle.
Returns a handle that may be passed to remove_idle() | Add a callback for entering idle. | [
"Add",
"a",
"callback",
"for",
"entering",
"idle",
"."
] | def enter_idle(self, callback):
"""
Add a callback for entering idle.
Returns a handle that may be passed to remove_idle()
"""
self._idle_handle += 1
self._idle_callbacks[self._idle_handle] = callback
return self._idle_handle | [
"def",
"enter_idle",
"(",
"self",
",",
"callback",
")",
":",
"self",
".",
"_idle_handle",
"+=",
"1",
"self",
".",
"_idle_callbacks",
"[",
"self",
".",
"_idle_handle",
"]",
"=",
"callback",
"return",
"self",
".",
"_idle_handle"
] | https://github.com/urwid/urwid/blob/e2423b5069f51d318ea1ac0f355a0efe5448f7eb/urwid/main_loop.py#L752-L760 | |
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | Python-2.7.13/Lib/_pyio.py | python | TextIOBase.encoding | (self) | return None | Subclasses should override. | Subclasses should override. | [
"Subclasses",
"should",
"override",
"."
] | def encoding(self):
"""Subclasses should override."""
return None | [
"def",
"encoding",
"(",
"self",
")",
":",
"return",
"None"
] | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/_pyio.py#L1347-L1349 | |
cuthbertLab/music21 | bd30d4663e52955ed922c10fdf541419d8c67671 | music21/humdrum/questions.py | python | Test.xtest009 | (self) | Are lower pitches likely to be shorter and higher pitches likely to be longer? | Are lower pitches likely to be shorter and higher pitches likely to be longer? | [
"Are",
"lower",
"pitches",
"likely",
"to",
"be",
"shorter",
"and",
"higher",
"pitches",
"likely",
"to",
"be",
"longer?"
] | def xtest009(self):
'''Are lower pitches likely to be shorter and higher pitches likely to be longer?'''
partStream = music21.converter.parse('dichterliebe1.xml')
unused_noteStream = partStream['notes'] | [
"def",
"xtest009",
"(",
"self",
")",
":",
"partStream",
"=",
"music21",
".",
"converter",
".",
"parse",
"(",
"'dichterliebe1.xml'",
")",
"unused_noteStream",
"=",
"partStream",
"[",
"'notes'",
"]"
] | https://github.com/cuthbertLab/music21/blob/bd30d4663e52955ed922c10fdf541419d8c67671/music21/humdrum/questions.py#L217-L221 | ||
juefeix/pnn.pytorch.update | b9513ff372e89f3c26278e7796a38965592d3428 | models.py | python | PerturbBasicBlock.forward | (self, x) | return y | [] | def forward(self, x):
residual = x
y = self.layers(x)
if self.shortcut:
residual = self.shortcut(x)
y += residual
y = F.relu(y)
return y | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"residual",
"=",
"x",
"y",
"=",
"self",
".",
"layers",
"(",
"x",
")",
"if",
"self",
".",
"shortcut",
":",
"residual",
"=",
"self",
".",
"shortcut",
"(",
"x",
")",
"y",
"+=",
"residual",
"y",
"=... | https://github.com/juefeix/pnn.pytorch.update/blob/b9513ff372e89f3c26278e7796a38965592d3428/models.py#L221-L228 | |||
home-assistant/supervisor | 69c2517d5211b483fdfe968b0a2b36b672ee7ab2 | supervisor/discovery/__init__.py | python | Discovery.get | (self, uuid: str) | return self.message_obj.get(uuid) | Return discovery message. | Return discovery message. | [
"Return",
"discovery",
"message",
"."
] | def get(self, uuid: str) -> Message | None:
"""Return discovery message."""
return self.message_obj.get(uuid) | [
"def",
"get",
"(",
"self",
",",
"uuid",
":",
"str",
")",
"->",
"Message",
"|",
"None",
":",
"return",
"self",
".",
"message_obj",
".",
"get",
"(",
"uuid",
")"
] | https://github.com/home-assistant/supervisor/blob/69c2517d5211b483fdfe968b0a2b36b672ee7ab2/supervisor/discovery/__init__.py#L67-L69 | |
SickChill/SickChill | 01020f3636d01535f60b83464d8127ea0efabfc7 | sickchill/adba/aniDBresponses.py | python | NotifygetMessageResponse.__init__ | (self, cmd, restag, rescode, resstr, datalines) | attributes:
data:
nid - notify id
uid - from user id
uname - from username
date - date
type - type
title - title
body - body | attributes: | [
"attributes",
":"
] | def __init__(self, cmd, restag, rescode, resstr, datalines):
"""
attributes:
data:
nid - notify id
uid - from user id
uname - from username
date - date
type - type
title - title
body - body
"""
super().__init__(cmd, restag... | [
"def",
"__init__",
"(",
"self",
",",
"cmd",
",",
"restag",
",",
"rescode",
",",
"resstr",
",",
"datalines",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"cmd",
",",
"restag",
",",
"rescode",
",",
"resstr",
",",
"datalines",
")",
"self",
".",
... | https://github.com/SickChill/SickChill/blob/01020f3636d01535f60b83464d8127ea0efabfc7/sickchill/adba/aniDBresponses.py#L1015-L1033 | ||
flow-project/flow | a511c41c48e6b928bb2060de8ad1ef3c3e3d9554 | flow/envs/traffic_light_grid.py | python | TrafficLightGridTestEnv._apply_rl_actions | (self, rl_actions) | See class definition. | See class definition. | [
"See",
"class",
"definition",
"."
] | def _apply_rl_actions(self, rl_actions):
"""See class definition."""
pass | [
"def",
"_apply_rl_actions",
"(",
"self",
",",
"rl_actions",
")",
":",
"pass"
] | https://github.com/flow-project/flow/blob/a511c41c48e6b928bb2060de8ad1ef3c3e3d9554/flow/envs/traffic_light_grid.py#L753-L755 | ||
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/solvers/bivariate.py | python | _linab | (arg, symbol) | return a, b, x | Return ``a, b, X`` assuming ``arg`` can be written as ``a*X + b``
where ``X`` is a symbol-dependent factor and ``a`` and ``b`` are
independent of ``symbol``.
Examples
========
>>> from sympy.functions.elementary.exponential import exp
>>> from sympy.solvers.bivariate import _linab
>>> from... | Return ``a, b, X`` assuming ``arg`` can be written as ``a*X + b``
where ``X`` is a symbol-dependent factor and ``a`` and ``b`` are
independent of ``symbol``. | [
"Return",
"a",
"b",
"X",
"assuming",
"arg",
"can",
"be",
"written",
"as",
"a",
"*",
"X",
"+",
"b",
"where",
"X",
"is",
"a",
"symbol",
"-",
"dependent",
"factor",
"and",
"a",
"and",
"b",
"are",
"independent",
"of",
"symbol",
"."
] | def _linab(arg, symbol):
"""Return ``a, b, X`` assuming ``arg`` can be written as ``a*X + b``
where ``X`` is a symbol-dependent factor and ``a`` and ``b`` are
independent of ``symbol``.
Examples
========
>>> from sympy.functions.elementary.exponential import exp
>>> from sympy.solvers.biva... | [
"def",
"_linab",
"(",
"arg",
",",
"symbol",
")",
":",
"arg",
"=",
"arg",
".",
"expand",
"(",
")",
"ind",
",",
"dep",
"=",
"arg",
".",
"as_independent",
"(",
"symbol",
")",
"if",
"not",
"arg",
".",
"is_Add",
":",
"b",
"=",
"0",
"a",
",",
"x",
... | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/solvers/bivariate.py#L77-L110 | |
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/manifolds/differentiable/tensorfield.py | python | TensorField.divergence | (self, metric=None) | return resu | r"""
Return the divergence of ``self`` (with respect to a given
metric).
The divergence is taken on the *last* index: if
``self`` is a tensor field `t` of type `(k,0)` with `k\geq 1`, the
divergence of `t` with respect to the metric `g` is the tensor field
of type `(k-1,... | r"""
Return the divergence of ``self`` (with respect to a given
metric). | [
"r",
"Return",
"the",
"divergence",
"of",
"self",
"(",
"with",
"respect",
"to",
"a",
"given",
"metric",
")",
"."
] | def divergence(self, metric=None):
r"""
Return the divergence of ``self`` (with respect to a given
metric).
The divergence is taken on the *last* index: if
``self`` is a tensor field `t` of type `(k,0)` with `k\geq 1`, the
divergence of `t` with respect to the metric `g`... | [
"def",
"divergence",
"(",
"self",
",",
"metric",
"=",
"None",
")",
":",
"n_con",
"=",
"self",
".",
"_tensor_type",
"[",
"0",
"]",
"# number of contravariant indices = k",
"n_cov",
"=",
"self",
".",
"_tensor_type",
"[",
"1",
"]",
"# number of covariant indices = ... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/manifolds/differentiable/tensorfield.py#L4001-L4145 | |
librahfacebook/Detection | 84504d086634950224716f4de0e4c8a684493c34 | object_detection/utils/shape_utils.py | python | combined_static_and_dynamic_shape | (tensor) | return combined_shape | Returns a list containing static and dynamic values for the dimensions.
Returns a list of static and dynamic values for shape dimensions. This is
useful to preserve static shapes when available in reshape operation.
Args:
tensor: A tensor of any type.
Returns:
A list of size tensor.shape.ndims contai... | Returns a list containing static and dynamic values for the dimensions. | [
"Returns",
"a",
"list",
"containing",
"static",
"and",
"dynamic",
"values",
"for",
"the",
"dimensions",
"."
] | def combined_static_and_dynamic_shape(tensor):
"""Returns a list containing static and dynamic values for the dimensions.
Returns a list of static and dynamic values for shape dimensions. This is
useful to preserve static shapes when available in reshape operation.
Args:
tensor: A tensor of any type.
R... | [
"def",
"combined_static_and_dynamic_shape",
"(",
"tensor",
")",
":",
"static_tensor_shape",
"=",
"tensor",
".",
"shape",
".",
"as_list",
"(",
")",
"dynamic_tensor_shape",
"=",
"tf",
".",
"shape",
"(",
"tensor",
")",
"combined_shape",
"=",
"[",
"]",
"for",
"ind... | https://github.com/librahfacebook/Detection/blob/84504d086634950224716f4de0e4c8a684493c34/object_detection/utils/shape_utils.py#L154-L174 | |
JiYou/openstack | 8607dd488bde0905044b303eb6e52bdea6806923 | packages/source/quantum/quantum/agent/linux/iptables_manager.py | python | IptablesManager._apply | (self) | Apply the current in-memory set of iptables rules.
This will blow away any rules left over from previous runs of the
same component of Nova, and replace them with our current set of
rules. This happens atomically, thanks to iptables-restore. | Apply the current in-memory set of iptables rules. | [
"Apply",
"the",
"current",
"in",
"-",
"memory",
"set",
"of",
"iptables",
"rules",
"."
] | def _apply(self):
"""Apply the current in-memory set of iptables rules.
This will blow away any rules left over from previous runs of the
same component of Nova, and replace them with our current set of
rules. This happens atomically, thanks to iptables-restore.
"""
s =... | [
"def",
"_apply",
"(",
"self",
")",
":",
"s",
"=",
"[",
"(",
"'iptables'",
",",
"self",
".",
"ipv4",
")",
"]",
"if",
"self",
".",
"use_ipv6",
":",
"s",
"+=",
"[",
"(",
"'ip6tables'",
",",
"self",
".",
"ipv6",
")",
"]",
"for",
"cmd",
",",
"tables... | https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/quantum/quantum/agent/linux/iptables_manager.py#L313-L341 | ||
tristanguigue/dynamic-programming | eacfe883c55c77acf20a9028e7fad9c079ff481a | partition_string/recursion.py | python | cost | (word) | Evaluate the cost of a given word. 0 if the word is in the dictionary,
the number of characters otherwise
Args:
word (string): a string whose cost need to be evaluated
Returns:
The cost of the word (int) | Evaluate the cost of a given word. 0 if the word is in the dictionary,
the number of characters otherwise | [
"Evaluate",
"the",
"cost",
"of",
"a",
"given",
"word",
".",
"0",
"if",
"the",
"word",
"is",
"in",
"the",
"dictionary",
"the",
"number",
"of",
"characters",
"otherwise"
] | def cost(word):
"""Evaluate the cost of a given word. 0 if the word is in the dictionary,
the number of characters otherwise
Args:
word (string): a string whose cost need to be evaluated
Returns:
The cost of the word (int)
"""
if word in dictionary:
return 0
else:
... | [
"def",
"cost",
"(",
"word",
")",
":",
"if",
"word",
"in",
"dictionary",
":",
"return",
"0",
"else",
":",
"return",
"len",
"(",
"word",
")"
] | https://github.com/tristanguigue/dynamic-programming/blob/eacfe883c55c77acf20a9028e7fad9c079ff481a/partition_string/recursion.py#L19-L32 | ||
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/Ubuntu_12/ecdsa/ecdsa.py | python | digest_integer | ( m ) | return string_to_int( sha1( int_to_string( m ) ).digest() ) | Convert an integer into a string of bytes, compute
its SHA-1 hash, and convert the result to an integer. | Convert an integer into a string of bytes, compute
its SHA-1 hash, and convert the result to an integer. | [
"Convert",
"an",
"integer",
"into",
"a",
"string",
"of",
"bytes",
"compute",
"its",
"SHA",
"-",
"1",
"hash",
"and",
"convert",
"the",
"result",
"to",
"an",
"integer",
"."
] | def digest_integer( m ):
"""Convert an integer into a string of bytes, compute
its SHA-1 hash, and convert the result to an integer."""
#
# I don't expect this function to be used much. I wrote
# it in order to be able to duplicate the examples
# in ECDSAVS.
#
from hashlib import sha1
return string... | [
"def",
"digest_integer",
"(",
"m",
")",
":",
"#",
"# I don't expect this function to be used much. I wrote",
"# it in order to be able to duplicate the examples",
"# in ECDSAVS.",
"#",
"from",
"hashlib",
"import",
"sha1",
"return",
"string_to_int",
"(",
"sha1",
"(",
"int_to_s... | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Ubuntu_12/ecdsa/ecdsa.py#L178-L187 | |
bendmorris/static-python | 2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473 | Lib/decimal.py | python | Decimal.as_tuple | (self) | return DecimalTuple(self._sign, tuple(map(int, self._int)), self._exp) | Represents the number as a triple tuple.
To show the internals exactly as they are. | Represents the number as a triple tuple. | [
"Represents",
"the",
"number",
"as",
"a",
"triple",
"tuple",
"."
] | def as_tuple(self):
"""Represents the number as a triple tuple.
To show the internals exactly as they are.
"""
return DecimalTuple(self._sign, tuple(map(int, self._int)), self._exp) | [
"def",
"as_tuple",
"(",
"self",
")",
":",
"return",
"DecimalTuple",
"(",
"self",
".",
"_sign",
",",
"tuple",
"(",
"map",
"(",
"int",
",",
"self",
".",
"_int",
")",
")",
",",
"self",
".",
"_exp",
")"
] | https://github.com/bendmorris/static-python/blob/2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473/Lib/decimal.py#L1008-L1013 | |
andresriancho/w3af | cd22e5252243a87aaa6d0ddea47cf58dacfe00a9 | w3af/plugins/attack/db/sqlmap/lib/core/common.py | python | getPageWordSet | (page) | return retVal | Returns word set used in page content
>>> sorted(getPageWordSet(u'<html><title>foobar</title><body>test</body></html>'))
[u'foobar', u'test'] | Returns word set used in page content | [
"Returns",
"word",
"set",
"used",
"in",
"page",
"content"
] | def getPageWordSet(page):
"""
Returns word set used in page content
>>> sorted(getPageWordSet(u'<html><title>foobar</title><body>test</body></html>'))
[u'foobar', u'test']
"""
retVal = set()
# only if the page's charset has been successfully identified
if isinstance(page, unicode):
... | [
"def",
"getPageWordSet",
"(",
"page",
")",
":",
"retVal",
"=",
"set",
"(",
")",
"# only if the page's charset has been successfully identified",
"if",
"isinstance",
"(",
"page",
",",
"unicode",
")",
":",
"retVal",
"=",
"set",
"(",
"_",
".",
"group",
"(",
"0",
... | https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/plugins/attack/db/sqlmap/lib/core/common.py#L1831-L1845 | |
quodlibet/quodlibet | e3099c89f7aa6524380795d325cc14630031886c | quodlibet/formats/_image.py | python | APICType.sort_key | (cls, value) | Sorts picture types, most important picture is the lowest.
Important is defined as most representative of an album release, ymmv. | Sorts picture types, most important picture is the lowest.
Important is defined as most representative of an album release, ymmv. | [
"Sorts",
"picture",
"types",
"most",
"important",
"picture",
"is",
"the",
"lowest",
".",
"Important",
"is",
"defined",
"as",
"most",
"representative",
"of",
"an",
"album",
"release",
"ymmv",
"."
] | def sort_key(cls, value):
"""Sorts picture types, most important picture is the lowest.
Important is defined as most representative of an album release, ymmv.
"""
# index value -> important
important = [
cls.LEAFLET_PAGE, cls.MEDIA,
cls.COVER_BACK, cls.CO... | [
"def",
"sort_key",
"(",
"cls",
",",
"value",
")",
":",
"# index value -> important",
"important",
"=",
"[",
"cls",
".",
"LEAFLET_PAGE",
",",
"cls",
".",
"MEDIA",
",",
"cls",
".",
"COVER_BACK",
",",
"cls",
".",
"COVER_FRONT",
"]",
"try",
":",
"return",
"-... | https://github.com/quodlibet/quodlibet/blob/e3099c89f7aa6524380795d325cc14630031886c/quodlibet/formats/_image.py#L139-L156 | ||
numenta/numenta-apps | 02903b0062c89c2c259b533eea2df6e8bb44eaf3 | taurus_metric_collectors/taurus_metric_collectors/delete_companies.py | python | deleteCompanies | (tickerSymbols,
engineServer,
engineApiKey,
warnAboutDestructiveAction=True,
warningTimeout=_DEFAULT_WARNING_PROMPT_TIMEOUT_SEC) | Delete companies from Taurus Collector and their metrics/models from
Taurus Engine.
:param sequence tickerSymbols: stock ticker symbols of companies to be
deleted
:param str engineServer: dns name of ip addres of Taurus API server
:param str engineApiKey: API Key of Taurus HTM Engine
:param bool warnA... | Delete companies from Taurus Collector and their metrics/models from
Taurus Engine. | [
"Delete",
"companies",
"from",
"Taurus",
"Collector",
"and",
"their",
"metrics",
"/",
"models",
"from",
"Taurus",
"Engine",
"."
] | def deleteCompanies(tickerSymbols,
engineServer,
engineApiKey,
warnAboutDestructiveAction=True,
warningTimeout=_DEFAULT_WARNING_PROMPT_TIMEOUT_SEC):
"""Delete companies from Taurus Collector and their metrics/models from
Taurus Engine.
... | [
"def",
"deleteCompanies",
"(",
"tickerSymbols",
",",
"engineServer",
",",
"engineApiKey",
",",
"warnAboutDestructiveAction",
"=",
"True",
",",
"warningTimeout",
"=",
"_DEFAULT_WARNING_PROMPT_TIMEOUT_SEC",
")",
":",
"tickerSymbols",
"=",
"tuple",
"(",
"symbol",
".",
"u... | https://github.com/numenta/numenta-apps/blob/02903b0062c89c2c259b533eea2df6e8bb44eaf3/taurus_metric_collectors/taurus_metric_collectors/delete_companies.py#L81-L195 | ||
Shikhargupta/Spiking-Neural-Network | de3e24da2806f0a7006b37f395ed055497727ae6 | multi_layer/reconstruct.py | python | reconst_weights | (weights, num, layer, reshape_x, reshape_y) | return img | [] | def reconst_weights(weights, num, layer, reshape_x, reshape_y):
weights = np.array(weights)
weights = np.reshape(weights, (reshape_x, reshape_y))
img = np.zeros((reshape_x, reshape_y))
for i in range(reshape_x):
for j in range(reshape_y):
img[i][j] = int(interp(weights[i][j], [par.w_... | [
"def",
"reconst_weights",
"(",
"weights",
",",
"num",
",",
"layer",
",",
"reshape_x",
",",
"reshape_y",
")",
":",
"weights",
"=",
"np",
".",
"array",
"(",
"weights",
")",
"weights",
"=",
"np",
".",
"reshape",
"(",
"weights",
",",
"(",
"reshape_x",
",",... | https://github.com/Shikhargupta/Spiking-Neural-Network/blob/de3e24da2806f0a7006b37f395ed055497727ae6/multi_layer/reconstruct.py#L13-L23 | |||
BirdAPI/Google-Search-API | e091df9b0bd399fbb249b5eec78479ec27cd942d | BeautifulSoup.py | python | PageElement.toEncoding | (self, s, encoding=None) | return s | Encodes an object to a string in some encoding, or to Unicode.
. | Encodes an object to a string in some encoding, or to Unicode.
. | [
"Encodes",
"an",
"object",
"to",
"a",
"string",
"in",
"some",
"encoding",
"or",
"to",
"Unicode",
".",
"."
] | def toEncoding(self, s, encoding=None):
"""Encodes an object to a string in some encoding, or to Unicode.
."""
if isinstance(s, unicode):
if encoding:
s = s.encode(encoding)
elif isinstance(s, str):
if encoding:
s = s.encode(encodin... | [
"def",
"toEncoding",
"(",
"self",
",",
"s",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"unicode",
")",
":",
"if",
"encoding",
":",
"s",
"=",
"s",
".",
"encode",
"(",
"encoding",
")",
"elif",
"isinstance",
"(",
"s",
... | https://github.com/BirdAPI/Google-Search-API/blob/e091df9b0bd399fbb249b5eec78479ec27cd942d/BeautifulSoup.py#L406-L422 | |
chaoss/grimoirelab-perceval | ba19bfd5e40bffdd422ca8e68526326b47f97491 | perceval/backends/core/nntp.py | python | NNTTPClient.article | (self, article_id) | return self._fetch("article", article_id) | Fetch article data
:param article_id: id of the article to fetch | Fetch article data | [
"Fetch",
"article",
"data"
] | def article(self, article_id):
"""Fetch article data
:param article_id: id of the article to fetch
"""
return self._fetch("article", article_id) | [
"def",
"article",
"(",
"self",
",",
"article_id",
")",
":",
"return",
"self",
".",
"_fetch",
"(",
"\"article\"",
",",
"article_id",
")"
] | https://github.com/chaoss/grimoirelab-perceval/blob/ba19bfd5e40bffdd422ca8e68526326b47f97491/perceval/backends/core/nntp.py#L295-L300 | |
pyscf/pyscf | 0adfb464333f5ceee07b664f291d4084801bae64 | pyscf/gw/ugw_ac.py | python | UGWAC.kernel | (self, mo_energy=None, mo_coeff=None, Lpq=None, orbs=None, nw=100, vhf_df=False) | return self.mo_energy | Input:
orbs: self-energy orbs
nw: grid number
vhf_df: whether using density fitting for HF exchange
Output:
mo_energy: GW quasiparticle energy | Input:
orbs: self-energy orbs
nw: grid number
vhf_df: whether using density fitting for HF exchange
Output:
mo_energy: GW quasiparticle energy | [
"Input",
":",
"orbs",
":",
"self",
"-",
"energy",
"orbs",
"nw",
":",
"grid",
"number",
"vhf_df",
":",
"whether",
"using",
"density",
"fitting",
"for",
"HF",
"exchange",
"Output",
":",
"mo_energy",
":",
"GW",
"quasiparticle",
"energy"
] | def kernel(self, mo_energy=None, mo_coeff=None, Lpq=None, orbs=None, nw=100, vhf_df=False):
"""
Input:
orbs: self-energy orbs
nw: grid number
vhf_df: whether using density fitting for HF exchange
Output:
mo_energy: GW quasiparticle energy
"... | [
"def",
"kernel",
"(",
"self",
",",
"mo_energy",
"=",
"None",
",",
"mo_coeff",
"=",
"None",
",",
"Lpq",
"=",
"None",
",",
"orbs",
"=",
"None",
",",
"nw",
"=",
"100",
",",
"vhf_df",
"=",
"False",
")",
":",
"if",
"mo_coeff",
"is",
"None",
":",
"mo_c... | https://github.com/pyscf/pyscf/blob/0adfb464333f5ceee07b664f291d4084801bae64/pyscf/gw/ugw_ac.py#L453-L475 | |
toxinu/Sublimall | 58eb7bc624234720003ad4df82d13ce23d70e4e1 | sublimall/commands/command.py | python | CommandWithStatus.set_message | (self, message) | Set a message | Set a message | [
"Set",
"a",
"message"
] | def set_message(self, message):
""" Set a message """
self._messageStatus.set_message(message)
if not self._messageStatus.is_running:
self._messageStatus.is_running = True
self._messageStatus.run() | [
"def",
"set_message",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"_messageStatus",
".",
"set_message",
"(",
"message",
")",
"if",
"not",
"self",
".",
"_messageStatus",
".",
"is_running",
":",
"self",
".",
"_messageStatus",
".",
"is_running",
"=",
... | https://github.com/toxinu/Sublimall/blob/58eb7bc624234720003ad4df82d13ce23d70e4e1/sublimall/commands/command.py#L45-L50 | ||
neurolib-dev/neurolib | 8d8ed2ceb422e9a1367193495a7e2df96cf4e4a3 | neurolib/utils/signal.py | python | Signal.apply | (self, func, inplace=True) | Apply func for each timeseries.
:param func: function to be applied for each 1D timeseries
:type func: callable
:param inplace: whether to do the operation in place or return
:type inplace: bool | Apply func for each timeseries. | [
"Apply",
"func",
"for",
"each",
"timeseries",
"."
] | def apply(self, func, inplace=True):
"""
Apply func for each timeseries.
:param func: function to be applied for each 1D timeseries
:type func: callable
:param inplace: whether to do the operation in place or return
:type inplace: bool
"""
assert callable... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"inplace",
"=",
"True",
")",
":",
"assert",
"callable",
"(",
"func",
")",
"try",
":",
"# this will work for element-wise function that does not reduces dimensions",
"processed",
"=",
"xr",
".",
"apply_ufunc",
"(",
"fu... | https://github.com/neurolib-dev/neurolib/blob/8d8ed2ceb422e9a1367193495a7e2df96cf4e4a3/neurolib/utils/signal.py#L671-L698 | ||
tartiflette/tartiflette | e292c28ed4fa279ecedb8980fc3741965bd28c87 | tartiflette/language/ast/values.py | python | EnumValueNode.__init__ | (
self, value: str, location: Optional["Location"] = None
) | :param value: value of the enum value
:param location: location of the enum value in the query/SDL
:type value: str
:type location: Optional[Location] | :param value: value of the enum value
:param location: location of the enum value in the query/SDL
:type value: str
:type location: Optional[Location] | [
":",
"param",
"value",
":",
"value",
"of",
"the",
"enum",
"value",
":",
"param",
"location",
":",
"location",
"of",
"the",
"enum",
"value",
"in",
"the",
"query",
"/",
"SDL",
":",
"type",
"value",
":",
"str",
":",
"type",
"location",
":",
"Optional",
... | def __init__(
self, value: str, location: Optional["Location"] = None
) -> None:
"""
:param value: value of the enum value
:param location: location of the enum value in the query/SDL
:type value: str
:type location: Optional[Location]
"""
self.value =... | [
"def",
"__init__",
"(",
"self",
",",
"value",
":",
"str",
",",
"location",
":",
"Optional",
"[",
"\"Location\"",
"]",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"value",
"=",
"value",
"self",
".",
"location",
"=",
"location"
] | https://github.com/tartiflette/tartiflette/blob/e292c28ed4fa279ecedb8980fc3741965bd28c87/tartiflette/language/ast/values.py#L78-L88 | ||
mrJean1/PyGeodesy | 7da5ca71aa3edb7bc49e219e0b8190686e1a7965 | pygeodesy/basics.py | python | _xcopy | (inst, deep=False) | return _deepcopy(inst) if deep else _copy(inst) | (INTERNAL) Copy an object, shallow or deep.
@arg inst: The object to copy (any C{type}).
@kwarg deep: If C{True} make a deep, otherwise
a shallow copy (C{bool}).
@return: The copy of B{C{inst}}. | (INTERNAL) Copy an object, shallow or deep. | [
"(",
"INTERNAL",
")",
"Copy",
"an",
"object",
"shallow",
"or",
"deep",
"."
] | def _xcopy(inst, deep=False):
'''(INTERNAL) Copy an object, shallow or deep.
@arg inst: The object to copy (any C{type}).
@kwarg deep: If C{True} make a deep, otherwise
a shallow copy (C{bool}).
@return: The copy of B{C{inst}}.
'''
return _deepcopy(inst) if deep el... | [
"def",
"_xcopy",
"(",
"inst",
",",
"deep",
"=",
"False",
")",
":",
"return",
"_deepcopy",
"(",
"inst",
")",
"if",
"deep",
"else",
"_copy",
"(",
"inst",
")"
] | https://github.com/mrJean1/PyGeodesy/blob/7da5ca71aa3edb7bc49e219e0b8190686e1a7965/pygeodesy/basics.py#L475-L484 | |
UCL-INGI/INGInious | 60f10cb4c375ce207471043e76bd813220b95399 | inginious/frontend/course_factory.py | python | CourseFactory.delete_course | (self, courseid) | Erase the content of the course folder
:param courseid: the course id of the course
:raise: InvalidNameException or CourseNotFoundException | Erase the content of the course folder
:param courseid: the course id of the course
:raise: InvalidNameException or CourseNotFoundException | [
"Erase",
"the",
"content",
"of",
"the",
"course",
"folder",
":",
"param",
"courseid",
":",
"the",
"course",
"id",
"of",
"the",
"course",
":",
"raise",
":",
"InvalidNameException",
"or",
"CourseNotFoundException"
] | def delete_course(self, courseid):
"""
Erase the content of the course folder
:param courseid: the course id of the course
:raise: InvalidNameException or CourseNotFoundException
"""
if not id_checker(courseid):
raise InvalidNameException("Course with invalid ... | [
"def",
"delete_course",
"(",
"self",
",",
"courseid",
")",
":",
"if",
"not",
"id_checker",
"(",
"courseid",
")",
":",
"raise",
"InvalidNameException",
"(",
"\"Course with invalid name: \"",
"+",
"courseid",
")",
"course_fs",
"=",
"self",
".",
"get_course_fs",
"(... | https://github.com/UCL-INGI/INGInious/blob/60f10cb4c375ce207471043e76bd813220b95399/inginious/frontend/course_factory.py#L165-L181 | ||
knownsec/Pocsuite | 877d1b1604629b8dcd6e53b167c3c98249e5e94f | pocsuite/thirdparty/oset/_abc.py | python | abstractmethod | (funcobj) | return funcobj | A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A
class that has a metaclass derived from ABCMeta cannot be
instantiated unless all of its abstract methods are overridden.
The abstract methods can be called using any of the normal
'super' call me... | A decorator indicating abstract methods. | [
"A",
"decorator",
"indicating",
"abstract",
"methods",
"."
] | def abstractmethod(funcobj):
"""A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A
class that has a metaclass derived from ABCMeta cannot be
instantiated unless all of its abstract methods are overridden.
The abstract methods can be called using a... | [
"def",
"abstractmethod",
"(",
"funcobj",
")",
":",
"funcobj",
".",
"__isabstractmethod__",
"=",
"True",
"return",
"funcobj"
] | https://github.com/knownsec/Pocsuite/blob/877d1b1604629b8dcd6e53b167c3c98249e5e94f/pocsuite/thirdparty/oset/_abc.py#L22-L40 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.