Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
40,
0
] | [
53,
20
] | python | en | ['en', 'es', 'en'] | True |
setup_input | (api: ProgettiHWSWAPI, input_number: int) | Initialize the input pin. | Initialize the input pin. | def setup_input(api: ProgettiHWSWAPI, input_number: int) -> Input:
"""Initialize the input pin."""
return api.get_input(input_number) | [
"def",
"setup_input",
"(",
"api",
":",
"ProgettiHWSWAPI",
",",
"input_number",
":",
"int",
")",
"->",
"Input",
":",
"return",
"api",
".",
"get_input",
"(",
"input_number",
")"
] | [
56,
0
] | [
58,
38
] | python | en | ['en', 'en', 'en'] | True |
setup_switch | (api: ProgettiHWSWAPI, switch_number: int, mode: str) | Initialize the output pin. | Initialize the output pin. | def setup_switch(api: ProgettiHWSWAPI, switch_number: int, mode: str) -> Relay:
"""Initialize the output pin."""
return api.get_relay(switch_number, mode) | [
"def",
"setup_switch",
"(",
"api",
":",
"ProgettiHWSWAPI",
",",
"switch_number",
":",
"int",
",",
"mode",
":",
"str",
")",
"->",
"Relay",
":",
"return",
"api",
".",
"get_relay",
"(",
"switch_number",
",",
"mode",
")"
] | [
61,
0
] | [
63,
45
] | python | en | ['en', 'en', 'en'] | True |
validate_input | (data) | Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
| Validate the user input allows us to connect. | async def validate_input(data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
userid = data.get(CONF_USERNAME)
password = data.get(CONF_PASSWORD)
prefix = data[CONF_PREFIX]
url = _make_url_from_data(data)
requ... | [
"async",
"def",
"validate_input",
"(",
"data",
")",
":",
"userid",
"=",
"data",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"data",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"prefix",
"=",
"data",
"[",
"CONF_PREFIX",
"]",
"url",
"=",
"_make_url_... | [
47,
0
] | [
73,
79
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.__init__ | (self) | Initialize the elkm1 config flow. | Initialize the elkm1 config flow. | def __init__(self):
"""Initialize the elkm1 config flow."""
self.importing = False | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"importing",
"=",
"False"
] | [
92,
4
] | [
94,
30
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
if self._url_already_configured(_make_url_from_data(user_input)):
return self.async_abort(reason="address_already_configured")
try:
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_url_already_configured",
"(",
"_make_url_from_data",
"(",
"user_input",
")",... | [
96,
4
] | [
135,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_import | (self, user_input) | Handle import. | Handle import. | async def async_step_import(self, user_input):
"""Handle import."""
self.importing = True
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
")",
":",
"self",
".",
"importing",
"=",
"True",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"user_input",
")"
] | [
137,
4
] | [
140,
53
] | python | en | ['en', 'ja', 'en'] | False |
ConfigFlow._url_already_configured | (self, url) | See if we already have a elkm1 matching user input configured. | See if we already have a elkm1 matching user input configured. | def _url_already_configured(self, url):
"""See if we already have a elkm1 matching user input configured."""
existing_hosts = {
urlparse(entry.data[CONF_HOST]).hostname
for entry in self._async_current_entries()
}
return urlparse(url).hostname in existing_hosts | [
"def",
"_url_already_configured",
"(",
"self",
",",
"url",
")",
":",
"existing_hosts",
"=",
"{",
"urlparse",
"(",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
")",
".",
"hostname",
"for",
"entry",
"in",
"self",
".",
"_async_current_entries",
"(",
")",
"}",... | [
142,
4
] | [
148,
55
] | python | en | ['en', 'en', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
32,
0
] | [
34,
57
] | python | en | ['en', 'en', 'en'] | True |
test_triggers | (hass, tag_setup, calls) | Test tag triggers. | Test tag triggers. | async def test_triggers(hass, tag_setup, calls):
"""Test tag triggers."""
assert await tag_setup()
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: [
{
"trigger": {"platform": DOMAIN, TAG_ID: "abc123"},
... | [
"async",
"def",
"test_triggers",
"(",
"hass",
",",
"tag_setup",
",",
"calls",
")",
":",
"assert",
"await",
"tag_setup",
"(",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN"... | [
37,
0
] | [
62,
55
] | python | en | ['en', 'mt', 'en'] | True |
test_exception_bad_trigger | (hass, calls, caplog) | Test for exception on event triggers firing. | Test for exception on event triggers firing. | async def test_exception_bad_trigger(hass, calls, caplog):
"""Test for exception on event triggers firing."""
await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: [
{
"trigger": {"trigger": {"platform": DOMAIN, "oops"... | [
"async",
"def",
"test_exception_bad_trigger",
"(",
"hass",
",",
"calls",
",",
"caplog",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"[",
"{",
"\"trigger\"",
":",
"{",
... | [
65,
0
] | [
84,
59
] | python | en | ['en', 'en', 'en'] | True |
cal_performance | (pred, gold, trg_pad_idx, smoothing=False) | Apply label smoothing if needed | Apply label smoothing if needed | def cal_performance(pred, gold, trg_pad_idx, smoothing=False):
''' Apply label smoothing if needed '''
loss = cal_loss(pred, gold, trg_pad_idx, smoothing=smoothing)
pred = pred.max(1)[1]
gold = gold.contiguous().view(-1)
non_pad_mask = gold.ne(trg_pad_idx)
n_correct = pred.eq(gold).masked_sele... | [
"def",
"cal_performance",
"(",
"pred",
",",
"gold",
",",
"trg_pad_idx",
",",
"smoothing",
"=",
"False",
")",
":",
"loss",
"=",
"cal_loss",
"(",
"pred",
",",
"gold",
",",
"trg_pad_idx",
",",
"smoothing",
"=",
"smoothing",
")",
"pred",
"=",
"pred",
".",
... | [
25,
0
] | [
36,
34
] | python | en | ['en', 'en', 'en'] | True |
cal_loss | (pred, gold, trg_pad_idx, smoothing=False) | Calculate cross entropy loss, apply label smoothing if needed. | Calculate cross entropy loss, apply label smoothing if needed. | def cal_loss(pred, gold, trg_pad_idx, smoothing=False):
''' Calculate cross entropy loss, apply label smoothing if needed. '''
gold = gold.contiguous().view(-1)
if smoothing:
eps = 0.1
n_class = pred.size(1)
one_hot = torch.zeros_like(pred).scatter(1, gold.view(-1, 1), 1)
... | [
"def",
"cal_loss",
"(",
"pred",
",",
"gold",
",",
"trg_pad_idx",
",",
"smoothing",
"=",
"False",
")",
":",
"gold",
"=",
"gold",
".",
"contiguous",
"(",
")",
".",
"view",
"(",
"-",
"1",
")",
"if",
"smoothing",
":",
"eps",
"=",
"0.1",
"n_class",
"=",... | [
39,
0
] | [
57,
15
] | python | en | ['en', 'en', 'en'] | True |
train_epoch | (model, training_data, optimizer, opt, device, smoothing) | Epoch operation in training phase | Epoch operation in training phase | def train_epoch(model, training_data, optimizer, opt, device, smoothing):
''' Epoch operation in training phase'''
model.train()
total_loss, n_word_total, n_word_correct = 0, 0, 0
desc = ' - (Training) '
for batch in tqdm(training_data, mininterval=2, desc=desc, leave=False):
# prepar... | [
"def",
"train_epoch",
"(",
"model",
",",
"training_data",
",",
"optimizer",
",",
"opt",
",",
"device",
",",
"smoothing",
")",
":",
"model",
".",
"train",
"(",
")",
"total_loss",
",",
"n_word_total",
",",
"n_word_correct",
"=",
"0",
",",
"0",
",",
"0",
... | [
74,
0
] | [
104,
34
] | python | en | ['en', 'en', 'en'] | True |
eval_epoch | (model, validation_data, device, opt) | Epoch operation in evaluation phase | Epoch operation in evaluation phase | def eval_epoch(model, validation_data, device, opt):
''' Epoch operation in evaluation phase '''
model.eval()
total_loss, n_word_total, n_word_correct = 0, 0, 0
desc = ' - (Validation) '
with torch.no_grad():
for batch in tqdm(validation_data, mininterval=2, desc=desc, leave=False):
... | [
"def",
"eval_epoch",
"(",
"model",
",",
"validation_data",
",",
"device",
",",
"opt",
")",
":",
"model",
".",
"eval",
"(",
")",
"total_loss",
",",
"n_word_total",
",",
"n_word_correct",
"=",
"0",
",",
"0",
",",
"0",
"desc",
"=",
"' - (Validation) '",
"w... | [
107,
0
] | [
133,
34
] | python | en | ['de', 'en', 'en'] | True |
train | (model, training_data, validation_data, optimizer, device, opt) | Start training | Start training | def train(model, training_data, validation_data, optimizer, device, opt):
''' Start training '''
# Use tensorboard to plot curves, e.g. perplexity, accuracy, learning rate
if opt.use_tb:
from torch.utils.tensorboard import SummaryWriter
tb_writer = SummaryWriter(log_dir=os.path.join(opt.out... | [
"def",
"train",
"(",
"model",
",",
"training_data",
",",
"validation_data",
",",
"optimizer",
",",
"device",
",",
"opt",
")",
":",
"# Use tensorboard to plot curves, e.g. perplexity, accuracy, learning rate",
"if",
"opt",
".",
"use_tb",
":",
"from",
"torch",
".",
"u... | [
136,
0
] | [
210,
62
] | python | en | ['en', 'sn', 'en'] | False |
main | () |
Usage:
python train.py -data_pkl m30k_deen_shr.pkl -log m30k_deen_shr -embs_share_weight -proj_share_weight -label_smoothing -output_dir output -b 256 -warmup 128000
|
Usage:
python train.py -data_pkl m30k_deen_shr.pkl -log m30k_deen_shr -embs_share_weight -proj_share_weight -label_smoothing -output_dir output -b 256 -warmup 128000
| def main():
'''
Usage:
python train.py -data_pkl m30k_deen_shr.pkl -log m30k_deen_shr -embs_share_weight -proj_share_weight -label_smoothing -output_dir output -b 256 -warmup 128000
'''
parser = argparse.ArgumentParser()
parser.add_argument('-data_pkl', default=None) # all-in-1 data pickl... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'-data_pkl'",
",",
"default",
"=",
"None",
")",
"# all-in-1 data pickle or bpe field",
"parser",
".",
"add_argument",
"(",
"'-train_pat... | [
216,
0
] | [
315,
78
] | python | en | ['en', 'ja', 'th'] | False |
split_index | (params) |
Delete index infromation from params
|
Delete index infromation from params
| def split_index(params):
"""
Delete index infromation from params
"""
if isinstance(params, dict):
if NodeType.INDEX in params.keys():
return split_index(params[NodeType.VALUE])
result = {}
for key in params:
result[key] = split_index(params[key])
... | [
"def",
"split_index",
"(",
"params",
")",
":",
"if",
"isinstance",
"(",
"params",
",",
"dict",
")",
":",
"if",
"NodeType",
".",
"INDEX",
"in",
"params",
".",
"keys",
"(",
")",
":",
"return",
"split_index",
"(",
"params",
"[",
"NodeType",
".",
"VALUE",
... | [
46,
0
] | [
58,
21
] | python | en | ['en', 'error', 'th'] | False |
extract_scalar_reward | (value, scalar_key='default') |
Extract scalar reward from trial result.
Parameters
----------
value : int, float, dict
the reported final metric data
scalar_key : str
the key name that indicates the numeric number
Raises
------
RuntimeError
Incorrect final result: the final result should be ... |
Extract scalar reward from trial result. | def extract_scalar_reward(value, scalar_key='default'):
"""
Extract scalar reward from trial result.
Parameters
----------
value : int, float, dict
the reported final metric data
scalar_key : str
the key name that indicates the numeric number
Raises
------
RuntimeEr... | [
"def",
"extract_scalar_reward",
"(",
"value",
",",
"scalar_key",
"=",
"'default'",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"float",
",",
"int",
")",
")",
":",
"reward",
"=",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"dict",
")",
"... | [
61,
0
] | [
85,
17
] | python | en | ['en', 'error', 'th'] | False |
extract_scalar_history | (trial_history, scalar_key='default') |
Extract scalar value from a list of intermediate results.
Parameters
----------
trial_history : list
accumulated intermediate results of a trial
scalar_key : str
the key name that indicates the numeric number
Raises
------
RuntimeError
Incorrect final result: t... |
Extract scalar value from a list of intermediate results. | def extract_scalar_history(trial_history, scalar_key='default'):
"""
Extract scalar value from a list of intermediate results.
Parameters
----------
trial_history : list
accumulated intermediate results of a trial
scalar_key : str
the key name that indicates the numeric number
... | [
"def",
"extract_scalar_history",
"(",
"trial_history",
",",
"scalar_key",
"=",
"'default'",
")",
":",
"return",
"[",
"extract_scalar_reward",
"(",
"ele",
",",
"scalar_key",
")",
"for",
"ele",
"in",
"trial_history",
"]"
] | [
88,
0
] | [
105,
76
] | python | en | ['en', 'error', 'th'] | False |
convert_dict2tuple | (value) |
convert dict type to tuple to solve unhashable problem.
NOTE: this function will change original data.
|
convert dict type to tuple to solve unhashable problem.
NOTE: this function will change original data.
| def convert_dict2tuple(value):
"""
convert dict type to tuple to solve unhashable problem.
NOTE: this function will change original data.
"""
if isinstance(value, dict):
for _keys in value:
value[_keys] = convert_dict2tuple(value[_keys])
return tuple(sorted(value.items())... | [
"def",
"convert_dict2tuple",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"for",
"_keys",
"in",
"value",
":",
"value",
"[",
"_keys",
"]",
"=",
"convert_dict2tuple",
"(",
"value",
"[",
"_keys",
"]",
")",
"return",
"tu... | [
108,
0
] | [
117,
16
] | python | en | ['en', 'error', 'th'] | False |
json2space | (x, oldy=None, name=NodeType.ROOT) |
Change search space from json format to hyperopt format
|
Change search space from json format to hyperopt format | def json2space(x, oldy=None, name=NodeType.ROOT):
"""
Change search space from json format to hyperopt format
"""
y = list()
if isinstance(x, dict):
if NodeType.TYPE in x.keys():
_type = x[NodeType.TYPE]
name = name + '-' + _type
if _type == 'choice':
... | [
"def",
"json2space",
"(",
"x",
",",
"oldy",
"=",
"None",
",",
"name",
"=",
"NodeType",
".",
"ROOT",
")",
":",
"y",
"=",
"list",
"(",
")",
"if",
"isinstance",
"(",
"x",
",",
"dict",
")",
":",
"if",
"NodeType",
".",
"TYPE",
"in",
"x",
".",
"keys"... | [
120,
0
] | [
147,
12
] | python | en | ['en', 'error', 'th'] | False |
json2parameter | (x, is_rand, random_state, oldy=None, Rand=False, name=NodeType.ROOT) |
Json to pramaters.
|
Json to pramaters. | def json2parameter(x, is_rand, random_state, oldy=None, Rand=False, name=NodeType.ROOT):
"""
Json to pramaters.
"""
if isinstance(x, dict):
if NodeType.TYPE in x.keys():
_type = x[NodeType.TYPE]
_value = x[NodeType.VALUE]
name = name + '-' + _type
... | [
"def",
"json2parameter",
"(",
"x",
",",
"is_rand",
",",
"random_state",
",",
"oldy",
"=",
"None",
",",
"Rand",
"=",
"False",
",",
"name",
"=",
"NodeType",
".",
"ROOT",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"dict",
")",
":",
"if",
"NodeType",
... | [
150,
0
] | [
206,
12
] | python | en | ['en', 'error', 'th'] | False |
merge_parameter | (base_params, override_params) |
Update the parameters in ``base_params`` with ``override_params``.
Can be useful to override parsed command line arguments.
Parameters
----------
base_params : namespace or dict
Base parameters. A key-value mapping.
override_params : dict or None
Parameters to override. Usually... |
Update the parameters in ``base_params`` with ``override_params``.
Can be useful to override parsed command line arguments. | def merge_parameter(base_params, override_params):
"""
Update the parameters in ``base_params`` with ``override_params``.
Can be useful to override parsed command line arguments.
Parameters
----------
base_params : namespace or dict
Base parameters. A key-value mapping.
override_par... | [
"def",
"merge_parameter",
"(",
"base_params",
",",
"override_params",
")",
":",
"if",
"override_params",
"is",
"None",
":",
"return",
"base_params",
"is_dict",
"=",
"isinstance",
"(",
"base_params",
",",
"dict",
")",
"for",
"k",
",",
"v",
"in",
"override_param... | [
208,
0
] | [
245,
22
] | python | en | ['en', 'error', 'th'] | False |
ClassArgsValidator.validate_class_args | (self, **kwargs) |
Validate the classArgs configuration in experiment configuration file.
Parameters
----------
kwargs: dict
kwargs passed to tuner/assessor/advisor constructor
Raises:
Raise an execption if the kwargs is invalid.
|
Validate the classArgs configuration in experiment configuration file. | def validate_class_args(self, **kwargs):
"""
Validate the classArgs configuration in experiment configuration file.
Parameters
----------
kwargs: dict
kwargs passed to tuner/assessor/advisor constructor
Raises:
Raise an execption if the kwargs is... | [
"def",
"validate_class_args",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
253,
4
] | [
265,
12
] | python | en | ['en', 'error', 'th'] | False |
ClassArgsValidator.choices | (self, key, *args) |
Utility method to create a scheme to check whether the `key` is one of the `args`.
Parameters:
----------
key: str
key name of the data to be validated
args: list of str
list of the choices
Returns: Schema
--------
A scheme t... |
Utility method to create a scheme to check whether the `key` is one of the `args`. | def choices(self, key, *args):
"""
Utility method to create a scheme to check whether the `key` is one of the `args`.
Parameters:
----------
key: str
key name of the data to be validated
args: list of str
list of the choices
Returns: Sche... | [
"def",
"choices",
"(",
"self",
",",
"key",
",",
"*",
"args",
")",
":",
"return",
"And",
"(",
"lambda",
"n",
":",
"n",
"in",
"args",
",",
"error",
"=",
"'%s should be in [%s]!'",
"%",
"(",
"key",
",",
"str",
"(",
"args",
")",
")",
")"
] | [
267,
4
] | [
282,
89
] | python | en | ['en', 'error', 'th'] | False |
ClassArgsValidator.range | (self, key, keyType, start, end) |
Utility method to create a schema to check whether the `key` is in the range of [start, end].
Parameters:
----------
key: str
key name of the data to be validated
keyType: type
python data type, such as int, float
start: type is specified by keyT... |
Utility method to create a schema to check whether the `key` is in the range of [start, end]. | def range(self, key, keyType, start, end):
"""
Utility method to create a schema to check whether the `key` is in the range of [start, end].
Parameters:
----------
key: str
key name of the data to be validated
keyType: type
python data type, such ... | [
"def",
"range",
"(",
"self",
",",
"key",
",",
"keyType",
",",
"start",
",",
"end",
")",
":",
"return",
"And",
"(",
"And",
"(",
"keyType",
",",
"error",
"=",
"'%s should be %s type!'",
"%",
"(",
"key",
",",
"keyType",
".",
"__name__",
")",
")",
",",
... | [
284,
4
] | [
306,
9
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Unifi LED platform. | Set up the Unifi LED platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Unifi LED platform."""
# Assign configuration variables.
# The configuration check takes care they are present.
host = config[CONF_HOST]
port = config[CONF_PORT]
username = config[CONF_USERNAME]
password = co... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"# Assign configuration variables.",
"# The configuration check takes care they are present.",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"port",
"... | [
28,
0
] | [
45,
72
] | python | en | ['en', 'zu', 'en'] | True |
UnifiLedLight.__init__ | (self, light, api) | Init Unifi LED Light. | Init Unifi LED Light. | def __init__(self, light, api):
"""Init Unifi LED Light."""
self._api = api
self._light = light
self._name = light["name"]
self._unique_id = light["id"]
self._state = light["status"]["output"]
self._available = light["isOnline"]
self._brightness = self._a... | [
"def",
"__init__",
"(",
"self",
",",
"light",
",",
"api",
")",
":",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_light",
"=",
"light",
"self",
".",
"_name",
"=",
"light",
"[",
"\"name\"",
"]",
"self",
".",
"_unique_id",
"=",
"light",
"[",
"\"id\... | [
51,
4
] | [
61,
43
] | python | it | ['ro', 'sq', 'it'] | False |
UnifiLedLight.name | (self) | Return the display name of this light. | Return the display name of this light. | def name(self):
"""Return the display name of this light."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
64,
4
] | [
66,
25
] | python | en | ['en', 'en', 'en'] | True |
UnifiLedLight.available | (self) | Return the available state of this light. | Return the available state of this light. | def available(self):
"""Return the available state of this light."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
69,
4
] | [
71,
30
] | python | en | ['en', 'en', 'en'] | True |
UnifiLedLight.brightness | (self) | Return the brightness name of this light. | Return the brightness name of this light. | def brightness(self):
"""Return the brightness name of this light."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
74,
4
] | [
76,
31
] | python | en | ['en', 'en', 'en'] | True |
UnifiLedLight.unique_id | (self) | Return the unique id of this light. | Return the unique id of this light. | def unique_id(self):
"""Return the unique id of this light."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
79,
4
] | [
81,
30
] | python | en | ['en', 'la', 'en'] | True |
UnifiLedLight.is_on | (self) | Return true if light is on. | Return true if light is on. | def is_on(self):
"""Return true if light is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
84,
4
] | [
86,
26
] | python | en | ['en', 'et', 'en'] | True |
UnifiLedLight.supported_features | (self) | Return the supported features of this light. | Return the supported features of this light. | def supported_features(self):
"""Return the supported features of this light."""
return self._features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_features"
] | [
89,
4
] | [
91,
29
] | python | en | ['en', 'en', 'en'] | True |
UnifiLedLight.turn_on | (self, **kwargs) | Instruct the light to turn on. | Instruct the light to turn on. | def turn_on(self, **kwargs):
"""Instruct the light to turn on."""
self._api.setdevicebrightness(
self._unique_id,
str(self._api.convertfrom255to100(kwargs.get(ATTR_BRIGHTNESS, 255))),
)
self._api.setdeviceoutput(self._unique_id, 1) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_api",
".",
"setdevicebrightness",
"(",
"self",
".",
"_unique_id",
",",
"str",
"(",
"self",
".",
"_api",
".",
"convertfrom255to100",
"(",
"kwargs",
".",
"get",
"(",
"ATTR_B... | [
93,
4
] | [
99,
53
] | python | en | ['en', 'en', 'en'] | True |
UnifiLedLight.turn_off | (self, **kwargs) | Instruct the light to turn off. | Instruct the light to turn off. | def turn_off(self, **kwargs):
"""Instruct the light to turn off."""
self._api.setdeviceoutput(self._unique_id, 0) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_api",
".",
"setdeviceoutput",
"(",
"self",
".",
"_unique_id",
",",
"0",
")"
] | [
101,
4
] | [
103,
53
] | python | en | ['en', 'en', 'en'] | True |
UnifiLedLight.update | (self) | Update the light states. | Update the light states. | def update(self):
"""Update the light states."""
self._state = self._api.getlightstate(self._unique_id)
self._brightness = self._api.convertfrom100to255(
self._api.getlightbrightness(self._unique_id)
)
self._available = self._api.getlightavailable(self._unique_id) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_api",
".",
"getlightstate",
"(",
"self",
".",
"_unique_id",
")",
"self",
".",
"_brightness",
"=",
"self",
".",
"_api",
".",
"convertfrom100to255",
"(",
"self",
".",
"_ap... | [
105,
4
] | [
111,
70
] | python | en | ['en', 'en', 'en'] | True |
setup_scanner | (hass, config, see, discovery_info=None) | Set up the demo tracker. | Set up the demo tracker. | def setup_scanner(hass, config, see, discovery_info=None):
"""Set up the demo tracker."""
def offset():
"""Return random offset."""
return (random.randrange(500, 2000)) / 2e5 * random.choice((-1, 1))
def random_see(dev_id, name):
"""Randomize a sighting."""
see(
... | [
"def",
"setup_scanner",
"(",
"hass",
",",
"config",
",",
"see",
",",
"discovery_info",
"=",
"None",
")",
":",
"def",
"offset",
"(",
")",
":",
"\"\"\"Return random offset.\"\"\"",
"return",
"(",
"random",
".",
"randrange",
"(",
"500",
",",
"2000",
")",
")",... | [
6,
0
] | [
40,
15
] | python | en | ['en', 'en', 'en'] | True |
generate_url | (host, port) | Create a URL from the host and port. | Create a URL from the host and port. | def generate_url(host, port) -> str:
"""Create a URL from the host and port."""
server_origin = host
if "://" not in host:
server_origin = f"http://{host}"
if server_origin[-1] == "/":
server_origin = server_origin[:-1]
return f"{server_origin}:{port}/" | [
"def",
"generate_url",
"(",
"host",
",",
"port",
")",
"->",
"str",
":",
"server_origin",
"=",
"host",
"if",
"\"://\"",
"not",
"in",
"host",
":",
"server_origin",
"=",
"f\"http://{host}\"",
"if",
"server_origin",
"[",
"-",
"1",
"]",
"==",
"\"/\"",
":",
"s... | [
3,
0
] | [
12,
37
] | python | en | ['en', 'en', 'en'] | True |
_create_processor_from_config | (hass, camera_entity, config) | Create an OpenCV processor from configuration. | Create an OpenCV processor from configuration. | def _create_processor_from_config(hass, camera_entity, config):
"""Create an OpenCV processor from configuration."""
classifier_config = config.get(CONF_CLASSIFIER)
name = f"{config[CONF_NAME]} {split_entity_id(camera_entity)[1].replace('_', ' ')}"
processor = OpenCVImageProcessor(hass, camera_entity, ... | [
"def",
"_create_processor_from_config",
"(",
"hass",
",",
"camera_entity",
",",
"config",
")",
":",
"classifier_config",
"=",
"config",
".",
"get",
"(",
"CONF_CLASSIFIER",
")",
"name",
"=",
"f\"{config[CONF_NAME]} {split_entity_id(camera_entity)[1].replace('_', ' ')}\"",
"p... | [
74,
0
] | [
81,
20
] | python | en | ['en', 'en', 'en'] | True |
_get_default_classifier | (dest_path) | Download the default OpenCV classifier. | Download the default OpenCV classifier. | def _get_default_classifier(dest_path):
"""Download the default OpenCV classifier."""
_LOGGER.info("Downloading default classifier")
req = requests.get(CASCADE_URL, stream=True)
with open(dest_path, "wb") as fil:
for chunk in req.iter_content(chunk_size=1024):
if chunk: # filter out... | [
"def",
"_get_default_classifier",
"(",
"dest_path",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Downloading default classifier\"",
")",
"req",
"=",
"requests",
".",
"get",
"(",
"CASCADE_URL",
",",
"stream",
"=",
"True",
")",
"with",
"open",
"(",
"dest_path",
","... | [
84,
0
] | [
91,
32
] | python | en | ['en', 'nl', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the OpenCV image processing platform. | Set up the OpenCV image processing platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the OpenCV image processing platform."""
if not CV2_IMPORTED:
_LOGGER.error(
"No OpenCV library found! Install or compile for your system "
"following instructions here: http://opencv.org/releases.html... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"not",
"CV2_IMPORTED",
":",
"_LOGGER",
".",
"error",
"(",
"\"No OpenCV library found! Install or compile for your system \"",
"\"following instr... | [
94,
0
] | [
119,
26
] | python | en | ['en', 'da', 'en'] | True |
OpenCVImageProcessor.__init__ | (self, hass, camera_entity, name, classifiers) | Initialize the OpenCV entity. | Initialize the OpenCV entity. | def __init__(self, hass, camera_entity, name, classifiers):
"""Initialize the OpenCV entity."""
self.hass = hass
self._camera_entity = camera_entity
if name:
self._name = name
else:
self._name = f"OpenCV {split_entity_id(camera_entity)[1]}"
self._c... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"camera_entity",
",",
"name",
",",
"classifiers",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_camera_entity",
"=",
"camera_entity",
"if",
"name",
":",
"self",
".",
"_name",
"=",
"name",
"... | [
125,
4
] | [
136,
31
] | python | en | ['en', 'en', 'en'] | True |
OpenCVImageProcessor.camera_entity | (self) | Return camera entity id from process pictures. | Return camera entity id from process pictures. | def camera_entity(self):
"""Return camera entity id from process pictures."""
return self._camera_entity | [
"def",
"camera_entity",
"(",
"self",
")",
":",
"return",
"self",
".",
"_camera_entity"
] | [
139,
4
] | [
141,
34
] | python | en | ['en', 'en', 'en'] | True |
OpenCVImageProcessor.name | (self) | Return the name of the image processor. | Return the name of the image processor. | def name(self):
"""Return the name of the image processor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
144,
4
] | [
146,
25
] | python | en | ['en', 'en', 'en'] | True |
OpenCVImageProcessor.state | (self) | Return the state of the entity. | Return the state of the entity. | def state(self):
"""Return the state of the entity."""
return self._total_matches | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_total_matches"
] | [
149,
4
] | [
151,
34
] | python | en | ['en', 'en', 'en'] | True |
OpenCVImageProcessor.state_attributes | (self) | Return device specific state attributes. | Return device specific state attributes. | def state_attributes(self):
"""Return device specific state attributes."""
return {ATTR_MATCHES: self._matches, ATTR_TOTAL_MATCHES: self._total_matches} | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_MATCHES",
":",
"self",
".",
"_matches",
",",
"ATTR_TOTAL_MATCHES",
":",
"self",
".",
"_total_matches",
"}"
] | [
154,
4
] | [
156,
85
] | python | en | ['fr', 'en', 'en'] | True |
OpenCVImageProcessor.process_image | (self, image) | Process the image. | Process the image. | def process_image(self, image):
"""Process the image."""
cv_image = cv2.imdecode(numpy.asarray(bytearray(image)), cv2.IMREAD_UNCHANGED)
matches = {}
total_matches = 0
for name, classifier in self._classifiers.items():
scale = DEFAULT_SCALE
neighbors = DE... | [
"def",
"process_image",
"(",
"self",
",",
"image",
")",
":",
"cv_image",
"=",
"cv2",
".",
"imdecode",
"(",
"numpy",
".",
"asarray",
"(",
"bytearray",
"(",
"image",
")",
")",
",",
"cv2",
".",
"IMREAD_UNCHANGED",
")",
"matches",
"=",
"{",
"}",
"total_mat... | [
158,
4
] | [
191,
43
] | python | en | ['en', 'en', 'en'] | True |
XboxBaseSensorEntity.__init__ | (self, coordinator: XboxUpdateCoordinator, xuid: str, attribute: str) | Initialize Xbox binary sensor. | Initialize Xbox binary sensor. | def __init__(self, coordinator: XboxUpdateCoordinator, xuid: str, attribute: str):
"""Initialize Xbox binary sensor."""
super().__init__(coordinator)
self.xuid = xuid
self.attribute = attribute | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"XboxUpdateCoordinator",
",",
"xuid",
":",
"str",
",",
"attribute",
":",
"str",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"xuid",
"=",
"xuid",
"self",
".... | [
12,
4
] | [
16,
34
] | python | en | ['en', 'pl', 'en'] | True |
XboxBaseSensorEntity.unique_id | (self) | Return a unique, Home Assistant friendly identifier for this entity. | Return a unique, Home Assistant friendly identifier for this entity. | def unique_id(self) -> str:
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self.xuid}_{self.attribute}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self.xuid}_{self.attribute}\""
] | [
19,
4
] | [
21,
46
] | python | en | ['en', 'en', 'en'] | True |
XboxBaseSensorEntity.data | (self) | Return coordinator data for this console. | Return coordinator data for this console. | def data(self) -> Optional[PresenceData]:
"""Return coordinator data for this console."""
return self.coordinator.data.presence.get(self.xuid) | [
"def",
"data",
"(",
"self",
")",
"->",
"Optional",
"[",
"PresenceData",
"]",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
".",
"presence",
".",
"get",
"(",
"self",
".",
"xuid",
")"
] | [
24,
4
] | [
26,
60
] | python | en | ['en', 'en', 'en'] | True |
XboxBaseSensorEntity.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
if not self.data:
return None
if self.attribute == "online":
return self.data.gamertag
attr_name = " ".join([part.title() for part in self.attribute.split("_")])
return f"{self.data.gamertag} {a... | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"data",
":",
"return",
"None",
"if",
"self",
".",
"attribute",
"==",
"\"online\"",
":",
"return",
"self",
".",
"data",
".",
"gamertag",
"attr_name",
"=",
"\" \"",
".",
"join... | [
29,
4
] | [
38,
50
] | python | en | ['en', 'mi', 'en'] | True |
XboxBaseSensorEntity.entity_picture | (self) | Return the gamer pic. | Return the gamer pic. | def entity_picture(self) -> str:
"""Return the gamer pic."""
if not self.data:
return None
return self.data.display_pic.replace("&mode=Padding", "") | [
"def",
"entity_picture",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"data",
":",
"return",
"None",
"return",
"self",
".",
"data",
".",
"display_pic",
".",
"replace",
"(",
"\"&mode=Padding\"",
",",
"\"\"",
")"
] | [
41,
4
] | [
46,
65
] | python | en | ['en', 'no', 'en'] | True |
XboxBaseSensorEntity.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return self.attribute == "online" | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"attribute",
"==",
"\"online\""
] | [
49,
4
] | [
51,
41
] | python | en | ['en', 'en', 'en'] | True |
XboxBaseSensorEntity.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
return {
"identifiers": {(DOMAIN, "xbox_live")},
"name": "Xbox Live",
"manufacturer": "Microsoft",
"model": "Xbox Live",
"entry_type": "service",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"\"xbox_live\"",
")",
"}",
",",
"\"name\"",
":",
"\"Xbox Live\"",
",",
"\"manufacturer\"",
":",
"\"Microsoft\"",
",",
"\"model\"",
":",
"\"Xbox Live\""... | [
54,
4
] | [
62,
9
] | python | en | ['ro', 'fr', 'en'] | False |
get_service | (hass, config, discovery_info=None) | Get the Dovado Router SMS notification service. | Get the Dovado Router SMS notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Dovado Router SMS notification service."""
return DovadoSMSNotificationService(hass.data[DOVADO_DOMAIN].client) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"DovadoSMSNotificationService",
"(",
"hass",
".",
"data",
"[",
"DOVADO_DOMAIN",
"]",
".",
"client",
")"
] | [
10,
0
] | [
12,
72
] | python | en | ['en', 'en', 'en'] | True |
DovadoSMSNotificationService.__init__ | (self, client) | Initialize the service. | Initialize the service. | def __init__(self, client):
"""Initialize the service."""
self._client = client | [
"def",
"__init__",
"(",
"self",
",",
"client",
")",
":",
"self",
".",
"_client",
"=",
"client"
] | [
18,
4
] | [
20,
29
] | python | en | ['en', 'en', 'en'] | True |
DovadoSMSNotificationService.send_message | (self, message, **kwargs) | Send SMS to the specified target phone number. | Send SMS to the specified target phone number. | def send_message(self, message, **kwargs):
"""Send SMS to the specified target phone number."""
target = kwargs.get(ATTR_TARGET)
if not target:
_LOGGER.error("One target is required")
return
self._client.send_sms(target, message) | [
"def",
"send_message",
"(",
"self",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"target",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TARGET",
")",
"if",
"not",
"target",
":",
"_LOGGER",
".",
"error",
"(",
"\"One target is required\"",
")",
"return",
"s... | [
22,
4
] | [
30,
46
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the Pilight component. | Set up the Pilight component. | def setup(hass, config):
"""Set up the Pilight component."""
host = config[DOMAIN][CONF_HOST]
port = config[DOMAIN][CONF_PORT]
send_throttler = CallRateDelayThrottle(hass, config[DOMAIN][CONF_SEND_DELAY])
try:
pilight_client = pilight.Client(host=host, port=port)
except (OSError, socke... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"host",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_HOST",
"]",
"port",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_PORT",
"]",
"send_throttler",
"=",
"CallRateDelayThrottle",
"(",
"hass",
",",
... | [
60,
0
] | [
120,
15
] | python | en | ['en', 'en', 'en'] | True |
CallRateDelayThrottle.__init__ | (self, hass, delay_seconds: float) | Initialize the delay handler. | Initialize the delay handler. | def __init__(self, hass, delay_seconds: float) -> None:
"""Initialize the delay handler."""
self._delay = timedelta(seconds=max(0.0, delay_seconds))
self._queue = []
self._active = False
self._lock = threading.Lock()
self._next_ts = dt_util.utcnow()
self._schedule... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"delay_seconds",
":",
"float",
")",
"->",
"None",
":",
"self",
".",
"_delay",
"=",
"timedelta",
"(",
"seconds",
"=",
"max",
"(",
"0.0",
",",
"delay_seconds",
")",
")",
"self",
".",
"_queue",
"=",
"[",... | [
135,
4
] | [
142,
73
] | python | en | ['en', 'en', 'en'] | True |
CallRateDelayThrottle.limited | (self, method) | Decorate to delay calls on a certain method. | Decorate to delay calls on a certain method. | def limited(self, method):
"""Decorate to delay calls on a certain method."""
@functools.wraps(method)
def decorated(*args, **kwargs):
"""Delay a call."""
if self._delay.total_seconds() == 0.0:
method(*args, **kwargs)
return
d... | [
"def",
"limited",
"(",
"self",
",",
"method",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"method",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Delay a call.\"\"\"",
"if",
"self",
".",
"_delay",
".",
"total_s... | [
144,
4
] | [
175,
24
] | python | en | ['en', 'en', 'en'] | True |
run_upload_docker | () | Run the Docker image to upload the translations. | Run the Docker image to upload the translations. | def run_upload_docker():
"""Run the Docker image to upload the translations."""
print("Running Docker to upload latest translations.")
run = subprocess.run(
[
"docker",
"run",
"-v",
f"{LOCAL_FILE}:{CONTAINER_FILE}",
"--rm",
f"lo... | [
"def",
"run_upload_docker",
"(",
")",
":",
"print",
"(",
"\"Running Docker to upload latest translations.\"",
")",
"run",
"=",
"subprocess",
".",
"run",
"(",
"[",
"\"docker\"",
",",
"\"run\"",
",",
"\"-v\"",
",",
"f\"{LOCAL_FILE}:{CONTAINER_FILE}\"",
",",
"\"--rm\"",
... | [
18,
0
] | [
48,
56
] | python | en | ['en', 'en', 'en'] | True |
generate_upload_data | () | Generate the data for uploading. | Generate the data for uploading. | def generate_upload_data():
"""Generate the data for uploading."""
translations = json.loads((INTEGRATIONS_DIR.parent / "strings.json").read_text())
translations["component"] = {}
for path in INTEGRATIONS_DIR.glob(f"*{os.sep}strings*.json"):
component = path.parent.name
match = FILENAME... | [
"def",
"generate_upload_data",
"(",
")",
":",
"translations",
"=",
"json",
".",
"loads",
"(",
"(",
"INTEGRATIONS_DIR",
".",
"parent",
"/",
"\"strings.json\"",
")",
".",
"read_text",
"(",
")",
")",
"translations",
"[",
"\"component\"",
"]",
"=",
"{",
"}",
"... | [
51,
0
] | [
69,
23
] | python | en | ['en', 'en', 'en'] | True |
run | () | Run the script. | Run the script. | def run():
"""Run the script."""
if get_current_branch() != "dev" and os.environ.get("AZURE_BRANCH") != "dev":
raise ExitApp(
"Please only run the translations upload script from a clean checkout of dev."
)
translations = generate_upload_data()
LOCAL_FILE.parent.mkdir(paren... | [
"def",
"run",
"(",
")",
":",
"if",
"get_current_branch",
"(",
")",
"!=",
"\"dev\"",
"and",
"os",
".",
"environ",
".",
"get",
"(",
"\"AZURE_BRANCH\"",
")",
"!=",
"\"dev\"",
":",
"raise",
"ExitApp",
"(",
"\"Please only run the translations upload script from a clean... | [
72,
0
] | [
86,
12
] | python | en | ['en', 'co', 'en'] | True |
mock_user_data | () | Mock os module. | Mock os module. | def mock_user_data():
"""Mock os module."""
with patch("hass_nabucasa.Cloud.write_user_info") as writer:
yield writer | [
"def",
"mock_user_data",
"(",
")",
":",
"with",
"patch",
"(",
"\"hass_nabucasa.Cloud.write_user_info\"",
")",
"as",
"writer",
":",
"yield",
"writer"
] | [
12,
0
] | [
15,
20
] | python | es | ['es', 'tr', 'pt'] | False |
mock_cloud_fixture | (hass) | Fixture for cloud component. | Fixture for cloud component. | def mock_cloud_fixture(hass):
"""Fixture for cloud component."""
hass.loop.run_until_complete(mock_cloud(hass))
return mock_cloud_prefs(hass) | [
"def",
"mock_cloud_fixture",
"(",
"hass",
")",
":",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"mock_cloud",
"(",
"hass",
")",
")",
"return",
"mock_cloud_prefs",
"(",
"hass",
")"
] | [
19,
0
] | [
22,
33
] | python | en | ['en', 'en', 'en'] | True |
cloud_prefs | (hass) | Fixture for cloud preferences. | Fixture for cloud preferences. | async def cloud_prefs(hass):
"""Fixture for cloud preferences."""
cloud_prefs = prefs.CloudPreferences(hass)
await cloud_prefs.async_initialize()
return cloud_prefs | [
"async",
"def",
"cloud_prefs",
"(",
"hass",
")",
":",
"cloud_prefs",
"=",
"prefs",
".",
"CloudPreferences",
"(",
"hass",
")",
"await",
"cloud_prefs",
".",
"async_initialize",
"(",
")",
"return",
"cloud_prefs"
] | [
26,
0
] | [
30,
22
] | python | en | ['en', 'en', 'en'] | True |
mock_cloud_setup | (hass) | Set up the cloud. | Set up the cloud. | async def mock_cloud_setup(hass):
"""Set up the cloud."""
await mock_cloud(hass) | [
"async",
"def",
"mock_cloud_setup",
"(",
"hass",
")",
":",
"await",
"mock_cloud",
"(",
"hass",
")"
] | [
34,
0
] | [
36,
26
] | python | en | ['en', 'fr', 'en'] | True |
mock_cloud_login | (hass, mock_cloud_setup) | Mock cloud is logged in. | Mock cloud is logged in. | def mock_cloud_login(hass, mock_cloud_setup):
"""Mock cloud is logged in."""
hass.data[const.DOMAIN].id_token = jwt.encode(
{
"email": "hello@home-assistant.io",
"custom:sub-exp": "2018-01-03",
"cognito:username": "abcdefghjkl",
},
"test",
) | [
"def",
"mock_cloud_login",
"(",
"hass",
",",
"mock_cloud_setup",
")",
":",
"hass",
".",
"data",
"[",
"const",
".",
"DOMAIN",
"]",
".",
"id_token",
"=",
"jwt",
".",
"encode",
"(",
"{",
"\"email\"",
":",
"\"hello@home-assistant.io\"",
",",
"\"custom:sub-exp\"",
... | [
40,
0
] | [
49,
5
] | python | en | ['en', 'fy', 'en'] | True |
test_setup_configuration | (hass) | Test for successfully setting up the IPMA platform. | Test for successfully setting up the IPMA platform. | async def test_setup_configuration(hass):
"""Test for successfully setting up the IPMA platform."""
with patch(
"homeassistant.components.ipma.weather.async_get_location",
return_value=MockLocation(),
):
assert await async_setup_component(
hass,
weather.DOMAIN... | [
"async",
"def",
"test_setup_configuration",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.ipma.weather.async_get_location\"",
",",
"return_value",
"=",
"MockLocation",
"(",
")",
",",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
... | [
131,
0
] | [
153,
62
] | python | en | ['en', 'en', 'en'] | True |
test_setup_config_flow | (hass) | Test for successfully setting up the IPMA platform. | Test for successfully setting up the IPMA platform. | async def test_setup_config_flow(hass):
"""Test for successfully setting up the IPMA platform."""
with patch(
"homeassistant.components.ipma.weather.async_get_location",
return_value=MockLocation(),
):
entry = MockConfigEntry(domain="ipma", data=TEST_CONFIG)
await hass.config... | [
"async",
"def",
"test_setup_config_flow",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.ipma.weather.async_get_location\"",
",",
"return_value",
"=",
"MockLocation",
"(",
")",
",",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
... | [
156,
0
] | [
175,
62
] | python | en | ['en', 'en', 'en'] | True |
test_daily_forecast | (hass) | Test for successfully getting daily forecast. | Test for successfully getting daily forecast. | async def test_daily_forecast(hass):
"""Test for successfully getting daily forecast."""
with patch(
"homeassistant.components.ipma.weather.async_get_location",
return_value=MockLocation(),
):
assert await async_setup_component(
hass,
weather.DOMAIN,
... | [
"async",
"def",
"test_daily_forecast",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.ipma.weather.async_get_location\"",
",",
"return_value",
"=",
"MockLocation",
"(",
")",
",",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"has... | [
178,
0
] | [
201,
58
] | python | en | ['en', 'en', 'en'] | True |
test_hourly_forecast | (hass) | Test for successfully getting daily forecast. | Test for successfully getting daily forecast. | async def test_hourly_forecast(hass):
"""Test for successfully getting daily forecast."""
with patch(
"homeassistant.components.ipma.weather.async_get_location",
return_value=MockLocation(),
):
assert await async_setup_component(
hass,
weather.DOMAIN,
... | [
"async",
"def",
"test_hourly_forecast",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.ipma.weather.async_get_location\"",
",",
"return_value",
"=",
"MockLocation",
"(",
")",
",",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"ha... | [
204,
0
] | [
225,
58
] | python | en | ['en', 'en', 'en'] | True |
MockLocation.observation | (self, api) | Mock Observation. | Mock Observation. | async def observation(self, api):
"""Mock Observation."""
Observation = namedtuple(
"Observation",
[
"accumulated_precipitation",
"humidity",
"pressure",
"radiation",
"temperature",
"w... | [
"async",
"def",
"observation",
"(",
"self",
",",
"api",
")",
":",
"Observation",
"=",
"namedtuple",
"(",
"\"Observation\"",
",",
"[",
"\"accumulated_precipitation\"",
",",
"\"humidity\"",
",",
"\"pressure\"",
",",
"\"radiation\"",
",",
"\"temperature\"",
",",
"\"w... | [
37,
4
] | [
52,
68
] | python | en | ['en', 'da', 'en'] | False |
MockLocation.forecast | (self, api) | Mock Forecast. | Mock Forecast. | async def forecast(self, api):
"""Mock Forecast."""
Forecast = namedtuple(
"Forecast",
[
"feels_like_temperature",
"forecast_date",
"forecasted_hours",
"humidity",
"max_temperature",
"... | [
"async",
"def",
"forecast",
"(",
"self",
",",
"api",
")",
":",
"Forecast",
"=",
"namedtuple",
"(",
"\"Forecast\"",
",",
"[",
"\"feels_like_temperature\"",
",",
"\"forecast_date\"",
",",
"\"forecasted_hours\"",
",",
"\"humidity\"",
",",
"\"max_temperature\"",
",",
... | [
54,
4
] | [
103,
9
] | python | en | ['en', 'zu', 'en'] | False |
MockLocation.name | (self) | Mock location. | Mock location. | def name(self):
"""Mock location."""
return "HomeTown" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"\"HomeTown\""
] | [
106,
4
] | [
108,
25
] | python | en | ['en', 'ja', 'en'] | False |
MockLocation.station_latitude | (self) | Mock latitude. | Mock latitude. | def station_latitude(self):
"""Mock latitude."""
return 0 | [
"def",
"station_latitude",
"(",
"self",
")",
":",
"return",
"0"
] | [
111,
4
] | [
113,
16
] | python | en | ['et', 'xh', 'en'] | False |
MockLocation.global_id_local | (self) | Mock global identifier of the location. | Mock global identifier of the location. | def global_id_local(self):
"""Mock global identifier of the location."""
return 1130600 | [
"def",
"global_id_local",
"(",
"self",
")",
":",
"return",
"1130600"
] | [
116,
4
] | [
118,
22
] | python | en | ['en', 'fy', 'en'] | True |
MockLocation.id_station | (self) | Mock identifier of the station. | Mock identifier of the station. | def id_station(self):
"""Mock identifier of the station."""
return 1200545 | [
"def",
"id_station",
"(",
"self",
")",
":",
"return",
"1200545"
] | [
121,
4
] | [
123,
22
] | python | en | ['en', 'fy', 'en'] | True |
MockLocation.station_longitude | (self) | Mock longitude. | Mock longitude. | def station_longitude(self):
"""Mock longitude."""
return 0 | [
"def",
"station_longitude",
"(",
"self",
")",
":",
"return",
"0"
] | [
126,
4
] | [
128,
16
] | python | en | ['et', 'xh', 'en'] | False |
count_flops_params | (model, x, custom_ops=None, verbose=True, mode='default') |
Count FLOPs and Params of the given model. This function would
identify the mask on the module and take the pruned shape into consideration.
Note that, for sturctured pruning, we only identify the remained filters
according to its mask, and do not take the pruned input channels into consideration,
... |
Count FLOPs and Params of the given model. This function would
identify the mask on the module and take the pruned shape into consideration.
Note that, for sturctured pruning, we only identify the remained filters
according to its mask, and do not take the pruned input channels into consideration,
... | def count_flops_params(model, x, custom_ops=None, verbose=True, mode='default'):
"""
Count FLOPs and Params of the given model. This function would
identify the mask on the module and take the pruned shape into consideration.
Note that, for sturctured pruning, we only identify the remained filters
a... | [
"def",
"count_flops_params",
"(",
"model",
",",
"x",
",",
"custom_ops",
"=",
"None",
",",
"verbose",
"=",
"True",
",",
"mode",
"=",
"'default'",
")",
":",
"assert",
"isinstance",
"(",
"x",
",",
"tuple",
")",
"or",
"isinstance",
"(",
"x",
",",
"torch",
... | [
330,
0
] | [
410,
72
] | python | en | ['en', 'error', 'th'] | False |
ModelProfiler.__init__ | (self, custom_ops=None, mode='default') |
ModelProfiler is used to share state to hooks.
Parameters
----------
custom_ops: dict
a mapping of (module -> torch.nn.Module : custom operation)
the custom operation is a callback funtion to calculate
the module flops, parameters and the weight shap... |
ModelProfiler is used to share state to hooks. | def __init__(self, custom_ops=None, mode='default'):
"""
ModelProfiler is used to share state to hooks.
Parameters
----------
custom_ops: dict
a mapping of (module -> torch.nn.Module : custom operation)
the custom operation is a callback funtion to calcul... | [
"def",
"__init__",
"(",
"self",
",",
"custom_ops",
"=",
"None",
",",
"mode",
"=",
"'default'",
")",
":",
"self",
".",
"ops",
"=",
"{",
"nn",
".",
"Conv1d",
":",
"self",
".",
"_count_convNd",
",",
"nn",
".",
"Conv2d",
":",
"self",
".",
"_count_convNd"... | [
22,
4
] | [
76,
25
] | python | en | ['en', 'error', 'th'] | False |
MBart50TokenizerFast.get_special_tokens_mask | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) |
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method.
Args:
token_ids_0 (:obj:`List[int]`):
List of ids.
token_ids_1 (:obj:`List[int]`... |
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method. | def get_special_tokens_mask(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) -> List[int]:
"""
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens... | [
"def",
"get_special_tokens_mask",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
",",
"already_has_special_tokens",
":",
"bool",
"=",
"False",
")",
"->",
... | [
162,
4
] | [
192,
94
] | python | en | ['en', 'error', 'th'] | False |
MBart50TokenizerFast.build_inputs_with_special_tokens | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. The special tokens depend on calling set_lang.
An MBART-50 sequence has the following format, where ``X`` represents the sequence:
- ``input_ids`` (fo... |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. The special tokens depend on calling set_lang. | def build_inputs_with_special_tokens(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. The special tokens de... | [
"def",
"build_inputs_with_special_tokens",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"if",
"token_ids_1",
... | [
194,
4
] | [
221,
82
] | python | en | ['en', 'error', 'th'] | False |
MBart50TokenizerFast.as_target_tokenizer | (self) |
Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to
sequence-to-sequence models that need a slightly different processing for the labels.
|
Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to
sequence-to-sequence models that need a slightly different processing for the labels.
| def as_target_tokenizer(self):
"""
Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to
sequence-to-sequence models that need a slightly different processing for the labels.
"""
self.set_tgt_lang_special_tokens(self.tgt_lang)
yield
... | [
"def",
"as_target_tokenizer",
"(",
"self",
")",
":",
"self",
".",
"set_tgt_lang_special_tokens",
"(",
"self",
".",
"tgt_lang",
")",
"yield",
"self",
".",
"set_src_lang_special_tokens",
"(",
"self",
".",
"src_lang",
")"
] | [
236,
4
] | [
243,
55
] | python | en | ['en', 'error', 'th'] | False |
MBart50TokenizerFast.set_src_lang_special_tokens | (self, src_lang: str) | Reset the special tokens to the source lang setting. prefix=[src_lang_code] and suffix=[eos]. | Reset the special tokens to the source lang setting. prefix=[src_lang_code] and suffix=[eos]. | def set_src_lang_special_tokens(self, src_lang: str) -> None:
"""Reset the special tokens to the source lang setting. prefix=[src_lang_code] and suffix=[eos]."""
self.cur_lang_code_id = self.convert_tokens_to_ids(src_lang)
self.prefix_tokens = [self.cur_lang_code_id]
self.suffix_tokens =... | [
"def",
"set_src_lang_special_tokens",
"(",
"self",
",",
"src_lang",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"cur_lang_code_id",
"=",
"self",
".",
"convert_tokens_to_ids",
"(",
"src_lang",
")",
"self",
".",
"prefix_tokens",
"=",
"[",
"self",
".",
"cu... | [
245,
4
] | [
258,
9
] | python | en | ['en', 'en', 'en'] | True |
MBart50TokenizerFast.set_tgt_lang_special_tokens | (self, tgt_lang: str) | Reset the special tokens to the target language setting. prefix=[src_lang_code] and suffix=[eos]. | Reset the special tokens to the target language setting. prefix=[src_lang_code] and suffix=[eos]. | def set_tgt_lang_special_tokens(self, tgt_lang: str) -> None:
"""Reset the special tokens to the target language setting. prefix=[src_lang_code] and suffix=[eos]."""
self.cur_lang_code_id = self.convert_tokens_to_ids(tgt_lang)
self.prefix_tokens = [self.cur_lang_code_id]
self.suffix_toke... | [
"def",
"set_tgt_lang_special_tokens",
"(",
"self",
",",
"tgt_lang",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"cur_lang_code_id",
"=",
"self",
".",
"convert_tokens_to_ids",
"(",
"tgt_lang",
")",
"self",
".",
"prefix_tokens",
"=",
"[",
"self",
".",
"cu... | [
260,
4
] | [
273,
9
] | python | en | ['en', 'en', 'en'] | True |
Control4Validator.__init__ | (self, host, username, password, hass) | Initialize. | Initialize. | def __init__(self, host, username, password, hass):
"""Initialize."""
self.host = host
self.username = username
self.password = password
self.controller_unique_id = None
self.director_bearer_token = None
self.hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"username",
",",
"password",
",",
"hass",
")",
":",
"self",
".",
"host",
"=",
"host",
"self",
".",
"username",
"=",
"username",
"self",
".",
"password",
"=",
"password",
"self",
".",
"controller_unique_id... | [
38,
4
] | [
45,
24
] | python | en | ['en', 'en', 'it'] | False |
Control4Validator.authenticate | (self) | Test if we can authenticate with the Control4 account API. | Test if we can authenticate with the Control4 account API. | async def authenticate(self) -> bool:
"""Test if we can authenticate with the Control4 account API."""
try:
account_session = aiohttp_client.async_get_clientsession(self.hass)
account = C4Account(self.username, self.password, account_session)
# Authenticate with Contr... | [
"async",
"def",
"authenticate",
"(",
"self",
")",
"->",
"bool",
":",
"try",
":",
"account_session",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"self",
".",
"hass",
")",
"account",
"=",
"C4Account",
"(",
"self",
".",
"username",
",",
"self",
... | [
47,
4
] | [
65,
24
] | python | en | ['en', 'en', 'en'] | True |
Control4Validator.connect_to_director | (self) | Test if we can connect to the local Control4 Director. | Test if we can connect to the local Control4 Director. | async def connect_to_director(self) -> bool:
"""Test if we can connect to the local Control4 Director."""
try:
director_session = aiohttp_client.async_get_clientsession(
self.hass, verify_ssl=False
)
director = C4Director(
self.host, se... | [
"async",
"def",
"connect_to_director",
"(",
"self",
")",
"->",
"bool",
":",
"try",
":",
"director_session",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"self",
".",
"hass",
",",
"verify_ssl",
"=",
"False",
")",
"director",
"=",
"C4Director",
"(... | [
67,
4
] | [
80,
24
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
hub = Control4Validator(
user_input["host"],
user_input["username"],
user_input["password"],
self.h... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"hub",
"=",
"Control4Validator",
"(",
"user_input",
"[",
"\"host\"",
"]",
",",
"user_input",
... | [
89,
4
] | [
131,
9
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_get_options_flow | (config_entry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry):
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
135,
4
] | [
137,
47
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry):
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
143,
4
] | [
145,
40
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (self, user_input=None) | Handle options flow. | Handle options flow. | async def async_step_init(self, user_input=None):
"""Handle options flow."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
data_schema = vol.Schema(
{
vol.Optional(
CONF_SCAN_INTERVAL,
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"\"\"",
",",
"data",
"=",
"user_input",
")",
"data_schem... | [
147,
4
] | [
162,
76
] | python | en | ['en', 'nl', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up 1-Wire platform. | Set up 1-Wire platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up 1-Wire platform."""
# Only OWServer implementation works with binary sensors
if config_entry.data[CONF_TYPE] == CONF_TYPE_OWSERVER:
onewirehub = hass.data[DOMAIN][config_entry.unique_id]
entities = await hass.asy... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"# Only OWServer implementation works with binary sensors",
"if",
"config_entry",
".",
"data",
"[",
"CONF_TYPE",
"]",
"==",
"CONF_TYPE_OWSERVER",
":",
"onewirehub",... | [
79,
0
] | [
86,
42
] | python | en | ['en', 'de', 'en'] | True |
get_entities | (onewirehub: OneWireHub) | Get a list of entities. | Get a list of entities. | def get_entities(onewirehub: OneWireHub):
"""Get a list of entities."""
entities = []
for device in onewirehub.devices:
family = device["family"]
device_type = device["type"]
sensor_id = os.path.split(os.path.split(device["path"])[0])[1]
if family not in DEVICE_BINARY_SENSO... | [
"def",
"get_entities",
"(",
"onewirehub",
":",
"OneWireHub",
")",
":",
"entities",
"=",
"[",
"]",
"for",
"device",
"in",
"onewirehub",
".",
"devices",
":",
"family",
"=",
"device",
"[",
"\"family\"",
"]",
"device_type",
"=",
"device",
"[",
"\"type\"",
"]",... | [
89,
0
] | [
122,
19
] | python | en | ['en', 'en', 'en'] | True |
OneWireProxyBinarySensor.is_on | (self) | Return true if sensor is on. | Return true if sensor is on. | def is_on(self):
"""Return true if sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
129,
4
] | [
131,
26
] | python | en | ['en', 'et', 'en'] | True |
mock_hass | () | Mock hass fixture. | Mock hass fixture. | def mock_hass():
"""Mock hass fixture."""
return Mock(data={}) | [
"def",
"mock_hass",
"(",
")",
":",
"return",
"Mock",
"(",
"data",
"=",
"{",
"}",
")"
] | [
9,
0
] | [
11,
24
] | python | en | ['en', 'nl', 'en'] | True |
test_singleton_async | (mock_hass) | Test singleton with async function. | Test singleton with async function. | async def test_singleton_async(mock_hass):
"""Test singleton with async function."""
@singleton.singleton("test_key")
async def something(hass):
return object()
result1 = await something(mock_hass)
result2 = await something(mock_hass)
assert result1 is result2
assert "test_key" in ... | [
"async",
"def",
"test_singleton_async",
"(",
"mock_hass",
")",
":",
"@",
"singleton",
".",
"singleton",
"(",
"\"test_key\"",
")",
"async",
"def",
"something",
"(",
"hass",
")",
":",
"return",
"object",
"(",
")",
"result1",
"=",
"await",
"something",
"(",
"... | [
14,
0
] | [
25,
48
] | python | en | ['en', 'el-Latn', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.